CREATE TABLE `his` (
  `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '与exams表主键一致，用于关联',
  `exam_project` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '检查项目',
  `hopitalized_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '住院号',
  `bed_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '病床号',
  `exam_status` tinyint DEFAULT '1' COMMENT '检查状态\r\n1  登记\r\n2  登记完成\r\n3  影像到达\r\n7  写报告\r\n8  审核报告\r\n9  确认报告',
  `report_result` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '检查结果  1阴性 2阳性',
  `report_status` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '远程诊断状态\r\n2  保存完善病例资料\r\n3  完善病例资料保存继续\r\n4  选择医院发起申请\r\n5  驳回申请\r\n6  接收申请\r\n7  写报告\r\n8  审核报告\r\n9  最终完成报告\r\n11  撤回报告\r\n10  确认报告',
  `pay_status` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '支付状态  0未支付 1已支付',
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '1' COMMENT '删除状态 0 禁用 1 正常',
  `urgent` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '是否急诊 0 否 1是',
  `severe` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '重症标识 0 否 1 是',
  `film_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '2' COMMENT '胶片属性：0 未定义  1传统胶片  2电子胶片',
  `del_datetime` datetime DEFAULT NULL COMMENT '删除时间',
  `del_doctor_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '删除医师ID',
  `del_doctor_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '删除医师姓名',
  `patient_area` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '病区',
  `createdAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updatedAt` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  `exam_sub_class` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '检查子类',
  `application_department` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '申请科室',
  `application_doctor` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '申请医生',
  `clin_diag` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '临床诊断',
  `out_patient` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '门诊号',
  `ext` json DEFAULT NULL COMMENT '扩展字段',
  `delivery_doctor` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '送诊医生',
  `push_api` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '0 推送失败  1推送成功',
  `clin_symp` varchar(2048) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '症状',
  `api_message` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '失败返回信息',
  `flag` int NOT NULL DEFAULT '0' COMMENT '重症标识 0 否 1 是',
  `his_patient_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'his系统患者ID',
  `doctor_sign` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '医生专属标记',
  `qr_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '二维码',
  `exam_method` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '检查方法',
  `write_report` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '写报告状态',
  `patient_source` int DEFAULT NULL COMMENT '患者来源\r\n''1''=>''急诊号  ''2''=>住院号'', ''3''=>''门诊号'' ''4''=>''体检号''',
  `is_dcm` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '1' COMMENT '是否为dcm影像 1 dcm  2 附件',
  `body_part_text` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '检查部位文本描述',
  `sync_exam` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '同步检查状态  0 未同步  1 已同步',
  `depart` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '部门',
  `report_score` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '报告评分',
  `report_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '报告描述',
  `report_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '报告标题',
  `qc_status` int NOT NULL DEFAULT '1' COMMENT '质控同步状态',
  `exam_datetime_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '检查时间编码',
  `medical_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '00000000000000000000000000' COMMENT '国家医保信息平台人员管理码',
  `body_part_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '000000000' COMMENT '检查部位代码',
  `device_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0000000000000' COMMENT '医保医用设备代码',
  `report_interpret` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '报告解读  0否 1是',
  `lw_sync_status` int DEFAULT '1' COMMENT '莱芜数据对接标识  1 未同步  2已同步',
  `lw_report_sync_status` int DEFAULT '1' COMMENT '莱芜报告对接标识  1 未同步  2已同步',
  PRIMARY KEY (`id`) USING BTREE,
  -- 保留高频查询所需索引（复用原表核心索引逻辑）
  KEY `his_report_status` (`report_status`) USING BTREE,
  KEY `his_exam_status` (`exam_status`) USING BTREE,
  KEY `his_pay_status` (`pay_status`) USING BTREE,
  KEY `his_hopitalized_no` (`hopitalized_no`) USING BTREE,
  KEY `his_out_patient` (`out_patient`) USING BTREE,
  KEY `his_createdAt` (`createdAt`) USING BTREE,
  KEY `his_his_patient_id` (`his_patient_id`) USING BTREE,
  KEY `his_lw_sync_status` (`lw_sync_status`) USING BTREE,
  KEY `his_lw_report_sync_status` (`lw_report_sync_status`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='exams表独有扩展字段表（与exam表互补）';