-- 2023122901
ALTER TABLE `h_health_chinese_medicine` 
ADD COLUMN `visit` VARCHAR ( 255 ) NULL DEFAULT NULL COMMENT '中医体质——望',
ADD COLUMN `tongue` VARCHAR ( 255 ) NULL DEFAULT NULL COMMENT '中医体质——舌',
ADD COLUMN `coated_tongue` VARCHAR ( 255 ) NULL DEFAULT NULL COMMENT '中医体质——苔',
ADD COLUMN `smell` VARCHAR ( 255 ) NULL DEFAULT NULL COMMENT '中医体质——闻',
ADD COLUMN `asking` VARCHAR ( 255 ) NULL DEFAULT NULL COMMENT '中医体质——问',
ADD COLUMN `pulse_taking` VARCHAR ( 255 ) NULL DEFAULT NULL COMMENT '中医体质——切';

-- 2024010501
ALTER TABLE `h_exception_set` 
ADD COLUMN `alias_title` varchar(255) NULL DEFAULT NULL COMMENT '冒号前缀开头' AFTER `exception_code`;

-- 2024012601
ALTER TABLE `h_basic_info` 
CHANGE COLUMN `cert_num` `current_village_code` varchar(12) NULL DEFAULT NULL COMMENT '现住址-村级区划编号' AFTER `current_add`,
CHANGE COLUMN `symptoms` `permanent_village_code` varchar(12) NULL DEFAULT NULL COMMENT '户籍地址-村级区划编号' AFTER `permanent_add`;

-- 2024031201
ALTER TABLE `h_health_checklst_rskctrlfac` 
CHANGE COLUMN `descr` `descr` varchar(1000) NULL DEFAULT NULL COMMENT '描述';

-- 2024041801
ALTER TABLE `h_device_urin_items` 
ADD COLUMN `test_count` double(8, 3) NULL DEFAULT NULL COMMENT '定量数据' AFTER `test_result`;

-- 2024052501
ALTER TABLE `h_device_ecg_data` 
ADD COLUMN `asses_doc_id` varchar(64) NULL DEFAULT NULL COMMENT '评估医生code' AFTER `division_id`,
ADD COLUMN `asses_doc` varchar(64) NULL DEFAULT NULL COMMENT '评估医生' AFTER `asses_doc_id`;

ALTER TABLE `h_device_urin_items` 
ADD COLUMN `asses_doc_id` varchar(64) NULL DEFAULT NULL COMMENT '评估医生code' AFTER `prompt`,
ADD COLUMN `asses_doc` varchar(64) NULL DEFAULT NULL COMMENT '评估医生' AFTER `asses_doc_id`;

ALTER TABLE `h_device_bmode_data` 
ADD COLUMN `asses_doc_id` varchar(64) NULL DEFAULT NULL COMMENT '评估医生code' AFTER `prompt`,
ADD COLUMN `asses_doc` varchar(64) NULL DEFAULT NULL COMMENT '评估医生' AFTER `asses_doc_id`;

ALTER TABLE `h_health_checklst` 
ADD COLUMN `asses_doc_id` varchar(64) NULL DEFAULT NULL COMMENT '一般检查责任医生' AFTER `resp_doc`,
ADD COLUMN `asses_doc` varchar(64) NULL DEFAULT NULL COMMENT '一般检查责任医生' AFTER `asses_doc_id`;

-- 2024050701
ALTER TABLE `h_device_ecg_data` 
ADD COLUMN `doctor_name` varchar(32) NULL COMMENT '心电图报告医生' AFTER `pict_path`,
ADD COLUMN `doctor_name_other` varchar(32) NULL COMMENT '其他心电图报告医生' AFTER `doctor_name`;

ALTER TABLE `h_device_bmode_data` 
ADD COLUMN `doctor_name` varchar(32) NULL COMMENT 'B超报告医生' AFTER `prompt`,
ADD COLUMN `doctor_name_other` varchar(32) NULL COMMENT '其他B超报告医生' AFTER `doctor_name`;

ALTER TABLE `h_basic_info_history` 
ADD COLUMN `remark` varchar(255) NULL COMMENT '备注' AFTER `descr`;

-- 2024052701
ALTER TABLE `h_health_checklst` 
ADD COLUMN `laboratory_status` int NULL COMMENT '检验报告单上传状态' AFTER `asses_doc_id`;

-- 2024061201
CREATE TABLE `h_device_xray_data`  (
  `id` bigint NOT NULL COMMENT 'id',
  `exam_num` varchar(32) NULL DEFAULT NULL COMMENT '唯一码-关联体检信息',
  `name` varchar(64) NULL DEFAULT NULL COMMENT '居民档案编号',
  `cert_num_id` varchar(32) NULL DEFAULT NULL COMMENT '身份证号',
  `barcode_num` varchar(32) NULL DEFAULT NULL COMMENT '条码编号',
  `hospital_num` varchar(32) NULL DEFAULT NULL COMMENT '住院号',
  `check_date` date NULL DEFAULT NULL COMMENT '检查日期',
  `test_part` varchar(200) NULL DEFAULT NULL COMMENT '检测部位',
  `test_result` text NULL COMMENT '检测结果',
  `result_img` longtext NULL COMMENT 'X光图片Base64',
  `prompt` varchar(600) NULL DEFAULT NULL COMMENT '结果提示',
  `xray_result` varchar(60) NULL DEFAULT NULL COMMENT 'X光结果',
  `xray_dec` varchar(600) NULL DEFAULT NULL COMMENT 'X光结果描述',
  `other_result` varchar(60) NULL DEFAULT NULL COMMENT '其他结果',
  `other_dec` varchar(600) NULL DEFAULT NULL COMMENT '其他结果描述',
  `doctor_name` varchar(32) NULL DEFAULT NULL COMMENT 'X光报告医生',
  `doctor_name_other` varchar(32) NULL DEFAULT NULL COMMENT '其他X光报告医生',
  `tenant_id` varchar(12) NULL DEFAULT '000000' COMMENT '租户ID',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人',
  `create_dept` bigint NULL DEFAULT NULL COMMENT '创建部门',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `status` int NULL DEFAULT NULL COMMENT '状态',
  `is_deleted` int NULL DEFAULT 0 COMMENT '是否已删除',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `exam_num`(`exam_num` ASC) USING BTREE,
  INDEX `barcode_num`(`barcode_num` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'X光检验数据' ROW_FORMAT = Dynamic;

CREATE TABLE `h_device_xray_img`  (
  `id` bigint NOT NULL COMMENT 'id',
  `xray_id` bigint NOT NULL COMMENT 'X光数据id',
  `img_name` varchar(10) NULL DEFAULT NULL COMMENT '图片名称',
  `result_img` longtext NULL COMMENT 'X光图片Base64',
  `prompt` varchar(600) NULL DEFAULT NULL COMMENT '结果提示',
  `tenant_id` varchar(12) NULL DEFAULT '000000' COMMENT '租户ID',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人',
  `create_dept` bigint NULL DEFAULT NULL COMMENT '创建部门',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `status` int NULL DEFAULT NULL COMMENT '状态',
  `is_deleted` int NULL DEFAULT 0 COMMENT '是否已删除',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `xray_id`(`xray_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'X光检验数据图片' ROW_FORMAT = Dynamic;

ALTER TABLE `h_device_bmode_data` 
ADD COLUMN `b_mode_result` varchar(60) NULL DEFAULT NULL COMMENT 'B超结果' AFTER `prompt`,
ADD COLUMN `b_mode_dec` varchar(600) NULL DEFAULT NULL COMMENT 'B超结果描述' AFTER `b_mode_result`,
ADD COLUMN `other_result` varchar(60) NULL DEFAULT NULL COMMENT '其他结果' AFTER `b_mode_dec`,
ADD COLUMN `other_dec` varchar(600) NULL DEFAULT NULL COMMENT '其他结果描述' AFTER `other_result`;

ALTER TABLE `h_device_ecg_data` 
ADD COLUMN `heart_rate_type` varchar(32) NULL DEFAULT NULL COMMENT '心率类型' AFTER `is_extract`,
ADD COLUMN `heart_rate` int NULL DEFAULT NULL COMMENT '心率值' AFTER `heart_rate_type`,
ADD COLUMN `p_exist` int NULL DEFAULT NULL COMMENT 'P波是否存在' AFTER `heart_rate`,
ADD COLUMN `p_width` int NULL DEFAULT NULL COMMENT 'P波宽度' AFTER `p_exist`,
ADD COLUMN `pr_interval` int NULL DEFAULT NULL COMMENT 'PR间期值' AFTER `p_width`,
ADD COLUMN `qrs_duration` int NULL DEFAULT NULL COMMENT 'QRS宽度值' AFTER `pr_interval`,
ADD COLUMN `rr_interval` int NULL DEFAULT NULL COMMENT 'RR间期值' AFTER `qrs_duration`,
ADD COLUMN `qt_interval` int NULL DEFAULT NULL COMMENT 'QT间期值' AFTER `rr_interval`,
ADD COLUMN `qtc_interval` int NULL DEFAULT NULL COMMENT 'QTc间期值' AFTER `qt_interval`,
ADD COLUMN `p_axis` int NULL DEFAULT NULL COMMENT 'P波电轴值' AFTER `qtc_interval`,
ADD COLUMN `qrs_axis` int NULL DEFAULT NULL COMMENT 'QRS波电轴值' AFTER `p_axis`,
ADD COLUMN `t_axis` int NULL DEFAULT NULL COMMENT 'T波电轴值' AFTER `qrs_axis`,
ADD COLUMN `rv5` int NULL DEFAULT NULL COMMENT 'V5导联的R波幅度值' AFTER `t_axis`,
ADD COLUMN `sv1` int NULL DEFAULT NULL COMMENT 'V1导联的S波幅度值' AFTER `rv5`,
ADD COLUMN `device_name` varchar(32) NULL DEFAULT NULL COMMENT '设备名称' AFTER `sv1`,
ADD COLUMN `device_id` varchar(32) NULL DEFAULT NULL COMMENT '设备编号' AFTER `device_name`,
ADD COLUMN `manufacturer` varchar(32) NULL DEFAULT NULL COMMENT '设备厂商' AFTER `device_id`,
ADD COLUMN `data_file` varchar(255) NULL DEFAULT NULL COMMENT '心电数据文件路径' AFTER `manufacturer`,
ADD COLUMN `atrial_rate` int NULL DEFAULT NULL COMMENT '心房率' AFTER `data_file`,
ADD COLUMN `ventricular_rate` int NULL DEFAULT NULL COMMENT '心室率' AFTER `atrial_rate`;

-- 2024061301
ALTER TABLE `h_basic_info` 
ADD COLUMN `spec_pop_class_desc` varchar(60) NULL COMMENT '特殊人群分类-其他' AFTER `spec_pop_class`,
ADD COLUMN `other_file_info_desc` varchar(240) NULL DEFAULT NULL COMMENT '档案标识-其它' AFTER `other_file_info`;

-- 2024062201
ALTER TABLE `h_device_bioch_bld_equit` 
ADD COLUMN `send_doctor` varchar(32) NULL DEFAULT NULL COMMENT '送检医生' AFTER `is_extract`,
ADD COLUMN `test_doctor` varchar(32) NULL DEFAULT NULL COMMENT '检验医生' AFTER `send_doctor`,
ADD COLUMN `review_doctor` varchar(32) NULL DEFAULT NULL COMMENT '审核医生' AFTER `test_doctor`,
ADD COLUMN `send_time` datetime NULL DEFAULT NULL COMMENT '送检时间' AFTER `review_doctor`,
ADD COLUMN `test_time` datetime NULL DEFAULT NULL COMMENT '检验时间' AFTER `send_time`;

ALTER TABLE `h_device_cbc_info` 
ADD COLUMN `send_doctor` varchar(32) NULL DEFAULT NULL COMMENT '送检医生' AFTER `is_extract`,
ADD COLUMN `test_doctor` varchar(32) NULL DEFAULT NULL COMMENT '检验医生' AFTER `send_doctor`,
ADD COLUMN `review_doctor` varchar(32) NULL DEFAULT NULL COMMENT '审核医生' AFTER `test_doctor`,
ADD COLUMN `send_time` datetime NULL DEFAULT NULL COMMENT '送检时间' AFTER `review_doctor`,
ADD COLUMN `test_time` datetime NULL DEFAULT NULL COMMENT '检验时间' AFTER `send_time`;

ALTER TABLE `h_device_urin_record` 
ADD COLUMN `send_doctor` varchar(32) NULL DEFAULT NULL COMMENT '送检医生' AFTER `is_extract`,
ADD COLUMN `test_doctor` varchar(32) NULL DEFAULT NULL COMMENT '检验医生' AFTER `send_doctor`,
ADD COLUMN `review_doctor` varchar(32) NULL DEFAULT NULL COMMENT '审核医生' AFTER `test_doctor`,
ADD COLUMN `send_time` datetime NULL DEFAULT NULL COMMENT '送检时间' AFTER `review_doctor`,
ADD COLUMN `test_time` datetime NULL DEFAULT NULL COMMENT '检验时间' AFTER `send_time`,
ADD COLUMN `asses_doc` varchar(64) NULL DEFAULT NULL COMMENT '评估医生' AFTER `test_time`,
ADD COLUMN `asses_doc_id` varchar(64) NULL DEFAULT NULL COMMENT '评估医生code' AFTER `asses_doc`;

-- 2024070701
ALTER TABLE `h_device_bioch_bld_equit` 
ADD COLUMN `cert_num_id` varchar(64) NULL DEFAULT NULL COMMENT '身份证号' AFTER `barcode_num`;
ALTER TABLE `h_device_cbc_info` 
ADD COLUMN `cert_num_id` varchar(32) NULL DEFAULT NULL COMMENT '身份证号' AFTER `barcode_num`;

-- 20250321
ALTER TABLE `h_checklst_entry_set` 
ADD COLUMN `group_name` varchar(255) NULL COMMENT '缺项模块名' AFTER `entry_from`;

ALTER TABLE `h_health_checklst` 
ADD COLUMN `phy_exam_no` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '当天体检序号' AFTER `barcode_num`;

ALTER TABLE h_health_checklst 
ADD COLUMN `postprandial_blood_glucose` double(8,3) DEFAULT NULL COMMENT '餐后血糖(mmol/L )' AFTER `fasting_blood_glucose_two`,
 ADD COLUMN `postprandial_blood_glucose_two` double(8,3) DEFAULT NULL COMMENT '餐后血糖(mg/dL )' AFTER `fasting_blood_glucose`;

ALTER TABLE `h_basic_info` 
ADD COLUMN `address_number` varchar(32) NULL COMMENT '现住址门牌号' AFTER `current_village_code`,
ADD COLUMN `home_place_number` varchar(32) NULL COMMENT '户籍地址门牌号' AFTER `permanent_village_code`;

ALTER TABLE `h_device_bioch_bld_equit` 
ADD COLUMN `memo` varchar(255) NULL COMMENT '备注' AFTER `test_time`;

ALTER TABLE `h_checklst_entry_set` 
ADD COLUMN `expression` varchar(255) NULL COMMENT '表达式' AFTER `type`;

ALTER TABLE h_health_checklst_guid
MODIFY COLUMN descr TEXT;  

-- 20250508
CREATE TABLE `h_health_check_audit`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `barcode_num` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '条码(体检)编号',
  `audit_status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '审核状态',
  `audit_user` bigint(20) NULL DEFAULT NULL COMMENT '审核人',
  `audit_time` datetime NULL DEFAULT NULL COMMENT '审核时间',
  `audit_opinion` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '审核意见',
  `tenant_id` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '000000' COMMENT '租户ID',
  `create_user` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_dept` bigint(20) NULL DEFAULT NULL COMMENT '创建部门',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` bigint(20) NULL DEFAULT NULL COMMENT '修改人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `status` int(11) NULL DEFAULT NULL COMMENT '状态',
  `is_deleted` int(11) NULL DEFAULT 0 COMMENT '是否已删除',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '健康体检审核表' ROW_FORMAT = DYNAMIC;

-- 20250523
ALTER TABLE `h_health_checklst_maindruguse` 
ADD COLUMN `comsmpt_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用量时间频次' AFTER `comsmpt`;

-- 20250610
ALTER TABLE `h_health_checklst` 
ADD COLUMN `hipline` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '臀围' AFTER `waistline`;

-- 20250626
ALTER TABLE `h_device_bmode_data` 
ADD COLUMN `audit_status` varchar(32) NULL COMMENT '审核状态' AFTER `doctor_name_other`;

ALTER TABLE `h_device_ecg_data` 
ADD COLUMN `audit_status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '审核状态' AFTER `ventricular_rate`;

-- 20250728
ALTER TABLE `h_health_checklst` 
ADD COLUMN `spo2` varchar(32) NULL COMMENT '血氧饱和度' AFTER `body_mass_index`;