-- 医生接诊备注表（按天一条，多次追加更新）

CREATE TABLE IF NOT EXISTS `zyt_doctor_note` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `diagnosis_id` int(11) unsigned NOT NULL COMMENT '诊单ID (tcm_diagnosis.id)',
  `doctor_id` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '医生ID (system_admin.id)',
  `note_date` date NOT NULL COMMENT '记录日期',
  `content` text DEFAULT NULL COMMENT '备注文字（多次追加以换行分隔，带时间戳前缀）',
  `tongue_images` json DEFAULT NULL COMMENT '舌苔/截屏照片路径数组',
  `report_files` json DEFAULT NULL COMMENT '检查报告图片路径数组',
  `create_time` int(10) unsigned NOT NULL DEFAULT 0,
  `update_time` int(10) unsigned NOT NULL DEFAULT 0,
  `delete_time` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_diagnosis_date` (`diagnosis_id`, `note_date`),
  KEY `idx_doctor` (`doctor_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='医生接诊备注';


ALTER TABLE `zyt_doctor_note` ADD COLUMN `report_files` json DEFAULT NULL COMMENT               
  '检查报告图片路径数组' AFTER `tongue_images`;   