-- 患者登记表
DROP TABLE IF EXISTS `patient_registration`;
CREATE TABLE `patient_registration` (
  `id` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '主键ID',
  `patient_id` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '病人ID',
  `medical_record_no` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '病历号',
  `patient_name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '患者姓名',
  `id_card` varchar(18) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '身份证号',
  `sex` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '性别：男/女',
  `age` int DEFAULT NULL COMMENT '年龄',
  `birth_date` date DEFAULT NULL COMMENT '出生日期',
  `phone` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '手机号码',
  `ward` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '病区',
  `admission_no` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '住院号',
  `bed_no` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '床号',
  `outpatient_no` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '门诊号',
  `check_equipment` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '检查设备',
  `check_date` date DEFAULT NULL COMMENT '检查时间',
  `body_part` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '检查部位',
  `check_method` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '检查方法',
  `capture_method` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '拍摄方法',
  `check_method_detail` text COLLATE utf8mb4_unicode_ci COMMENT '检查方法详细',
  `institution_id` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '所属机构ID',
  `registrant_id` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '登记人ID',
  `registrant_name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '登记人姓名',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  KEY `idx_patient_id` (`patient_id`),
  KEY `idx_institution` (`institution_id`),
  KEY `idx_check_date` (`check_date`),
  KEY `idx_body_part` (`body_part`),
  KEY `idx_check_method` (`check_method`),
  UNIQUE KEY `uk_registration` (`patient_id`, `body_part`, `check_method`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='患者登记表';
