-- 中医处方单表
CREATE TABLE IF NOT EXISTS `zyt_tcm_prescription` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `sn` varchar(50) NOT NULL DEFAULT '' COMMENT '处方编号',
  `diagnosis_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '诊单ID',
  `appointment_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '预约ID',
  `patient_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '患者ID',
  `patient_name` varchar(50) NOT NULL DEFAULT '' COMMENT '患者姓名',
  `gender` tinyint(1) NOT NULL DEFAULT '0' COMMENT '性别：0-女 1-男',
  `age` int(3) NOT NULL DEFAULT '0' COMMENT '年龄',
  `phone` varchar(20) DEFAULT '' COMMENT '电话',
  `visit_no` varchar(50) DEFAULT '' COMMENT '门诊号',
  `prescription_date` date DEFAULT NULL COMMENT '处方日期',
  `pulse` varchar(100) DEFAULT '' COMMENT '脉象',
  `tongue` varchar(100) DEFAULT '' COMMENT '舌象',
  `clinical_diagnosis` varchar(500) DEFAULT '' COMMENT '临床诊断',
  `herbs` text COMMENT '中药列表JSON：[{name, dosage}]',
  `dose_count` int(11) NOT NULL DEFAULT '1' COMMENT '剂数',
  `usage_instruction` varchar(200) DEFAULT '水煎服一日二次' COMMENT '用法',
  `amount` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '金额',
  `doctor_name` varchar(50) DEFAULT '' COMMENT '医师姓名',
  `template_id` int(11) unsigned DEFAULT '0' COMMENT '模板ID',
  `creator_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建人ID',
  `create_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  `update_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
  `delete_time` int(10) unsigned DEFAULT NULL COMMENT '删除时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_sn` (`sn`),
  KEY `idx_diagnosis` (`diagnosis_id`),
  KEY `idx_appointment` (`appointment_id`),
  KEY `idx_patient` (`patient_id`),
  KEY `idx_create_time` (`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='中医处方单表';
