-- ============================================================
-- HealthLink-HIS 三甲医院全流程测试数据（修正版）
-- 版本: v2.0 (JDK 25 + Spring Boot 4.0.6 + Vue 3)
-- 日期: 2026-06-07
-- 说明: 覆盖门诊/住院/药房/检验/影像/手术/麻醉/护理/院感/质控/中医/会诊全流程
-- 注意: 仅插入测试数据，不删除现有数据，使用ON CONFLICT避免重复
-- ============================================================

SET search_path TO healthlink_his;

-- ============================
-- 一、基础数据（科室/人员）
-- ============================

INSERT INTO sys_dept (dept_id, parent_id, ancestors, dept_name, order_num, leader, phone, email, status, del_flag, create_by, create_time)
VALUES 
  (1001, 0, '0', '门诊内科', 10, '张主任', '13800000001', 'mnk@hospital.com', '0', '0', 'admin', NOW()),
  (1002, 0, '0', '门诊外科', 11, '李主任', '13800000002', 'mwk@hospital.com', '0', '0', 'admin', NOW()),
  (1003, 0, '0', '儿科门诊', 12, '王主任', '13800000003', 'ek@hospital.com', '0', '0', 'admin', NOW()),
  (1004, 0, '0', '妇产科', 13, '赵主任', '13800000004', 'fck@hospital.com', '0', '0', 'admin', NOW()),
  (1005, 0, '0', 'ICU', 14, '刘主任', '13800000005', 'icu@hospital.com', '0', '0', 'admin', NOW()),
  (1006, 0, '0', '急诊科', 15, '陈主任', '13800000006', 'jzk@hospital.com', '0', '0', 'admin', NOW()),
  (1007, 0, '0', '手术室', 16, '孙主任', '13800000007', 'ss@hospital.com', '0', '0', 'admin', NOW()),
  (1008, 0, '0', '药房', 17, '周主任', '13800000008', 'yf@hospital.com', '0', '0', 'admin', NOW()),
  (1009, 0, '0', '检验科', 18, '吴主任', '13800000009', 'jyk@hospital.com', '0', '0', 'admin', NOW()),
  (1010, 0, '0', '影像科', 19, '郑主任', '13800000010', 'yxk@hospital.com', '0', '0', 'admin', NOW()),
  (1011, 0, '0', '门诊部', 20, '黄院长', '13800000011', 'mzb@hospital.com', '0', '0', 'admin', NOW()),
  (1012, 0, '0', '住院部', 21, '杨院长', '13800000012', 'zyb@hospital.com', '0', '0', 'admin', NOW())
ON CONFLICT (dept_id) DO NOTHING;

INSERT INTO sys_user (user_id, user_name, nick_name, dept_id, email, phonenumber, sex, status, del_flag, create_by, create_time)
VALUES 
  (2001, 'doctor_zhang', '张三医生', 1001, 'zhangsan@hospital.com', '13900000001', '1', '0', '0', 'admin', NOW()),
  (2002, 'doctor_li', '李四医生', 1002, 'lisi@hospital.com', '13900000002', '1', '0', '0', 'admin', NOW()),
  (2003, 'doctor_wang', '王五医生', 1003, 'wangwu@hospital.com', '13900000003', '1', '0', '0', 'admin', NOW()),
  (2004, 'doctor_zhao', '赵六医生', 1004, 'zhaoliu@hospital.com', '13900000004', '1', '0', '0', 'admin', NOW()),
  (2005, 'doctor_liu', '刘七医生', 1005, 'liuqi@hospital.com', '13900000005', '1', '0', '0', 'admin', NOW()),
  (2006, 'doctor_chen', '陈八医生', 1006, 'chenba@hospital.com', '13900000006', '1', '0', '0', 'admin', NOW()),
  (2007, 'doctor_sun', '孙九医生', 1007, 'sunjiu@hospital.com', '13900000007', '1', '0', '0', 'admin', NOW()),
  (2008, 'doctor_zhou', '周十医生', 1008, 'zhoushi@hospital.com', '13900000008', '1', '0', '0', 'admin', NOW()),
  (2009, 'doctor_wu', '吴十一医生', 1009, 'wushiyi@hospital.com', '13900000009', '1', '0', '0', 'admin', NOW()),
  (2010, 'doctor_zheng', '郑十二医生', 1010, 'zhengershi@hospital.com', '13900000010', '1', '0', '0', 'admin', NOW())
ON CONFLICT (user_id) DO NOTHING;

INSERT INTO sys_user (user_id, user_name, nick_name, dept_id, email, phonenumber, sex, status, del_flag, create_by, create_time)
VALUES 
  (3001, 'nurse_a', '护士A', 1001, 'nursea@hospital.com', '13700000001', '2', '0', '0', 'admin', NOW()),
  (3002, 'nurse_b', '护士B', 1005, 'nurseb@hospital.com', '13700000002', '2', '0', '0', 'admin', NOW()),
  (3003, 'nurse_c', '护士C', 1006, 'nursec@hospital.com', '13700000003', '2', '0', '0', 'admin', NOW()),
  (3004, 'nurse_d', '护士D', 1007, 'nursed@hospital.com', '13700000004', '2', '0', '0', 'admin', NOW())
ON CONFLICT (user_id) DO NOTHING;

-- ============================
-- 二、测试患者数据
-- ============================

INSERT INTO adm_patient (id, name, gender_enum, birth_date, phone, id_card, address, organization_id, tenant_id, delete_flag, create_by, create_time)
VALUES 
  (5001, '测试患者甲', 1, '1990-01-15 00:00:00+08', '13800138001', '450102199001011234', '广西南宁市青秀区民族大道100号', 1, 1, '0', 'admin', NOW()),
  (5002, '测试患者乙', 2, '1985-05-20 00:00:00+08', '13800138002', '450102198505052345', '广西南宁市兴宁区朝阳路200号', 1, 1, '0', 'admin', NOW()),
  (5003, '测试患者丙', 1, '2000-10-08 00:00:00+08', '13800138003', '450102200010103456', '广西南宁市西乡塘区大学路300号', 1, 1, '0', 'admin', NOW()),
  (5004, '测试患者丁', 2, '1975-12-25 00:00:00+08', '13800138004', '450102197512124567', '广西南宁市良庆区银海大道400号', 1, 1, '0', 'admin', NOW()),
  (5005, '测试患者戊', 1, '1965-03-10 00:00:00+08', '13800138005', '450102196503101234', '广西南宁市邕宁区蒲庙镇500号', 1, 1, '0', 'admin', NOW()),
  (5006, '测试患者己', 2, '2015-08-18 00:00:00+08', '13800138006', '450102201508186789', '广西南宁市江南区星光大道600号', 1, 1, '0', 'admin', NOW()),
  (5007, '急诊患者庚', 1, '1988-07-07 00:00:00+08', '13800138007', '450102198807071111', '广西南宁市青秀区东葛路700号', 1, 1, '0', 'admin', NOW()),
  (5008, '急诊患者辛', 2, '1992-11-11 00:00:00+08', '13800138008', '450102199211112222', '广西南宁市青秀区凤岭北路800号', 1, 1, '0', 'admin', NOW())
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 三、就诊记录
-- ============================

INSERT INTO adm_encounter (id, patient_id, status_enum, class_enum, type_enum, start_time, organization_id, tenant_id, delete_flag, create_by, create_time)
VALUES 
  (6001, 5001, 2, 1, 1, '2026-06-07 09:00:00+08', 1, 1, '0', 'admin', NOW()),
  (6002, 5002, 2, 1, 1, '2026-06-07 09:30:00+08', 1, 1, '0', 'admin', NOW()),
  (6003, 5003, 2, 1, 1, '2026-06-07 10:00:00+08', 1, 1, '0', 'admin', NOW()),
  (6004, 5004, 2, 1, 1, '2026-06-07 10:30:00+08', 1, 1, '0', 'admin', NOW()),
  (6005, 5005, 2, 1, 1, '2026-06-07 11:00:00+08', 1, 1, '0', 'admin', NOW()),
  (6006, 5001, 2, 2, 1, '2026-06-01 14:00:00+08', 1, 1, '0', 'admin', NOW()),
  (6007, 5002, 2, 2, 1, '2026-06-02 08:00:00+08', 1, 1, '0', 'admin', NOW()),
  (6008, 5004, 2, 2, 1, '2026-06-03 10:00:00+08', 1, 1, '0', 'admin', NOW()),
  (6009, 5005, 4, 2, 1, '2026-06-04 09:00:00+08', 1, 1, '0', 'admin', NOW()),
  (6010, 5006, 2, 1, 1, '2026-06-07 14:00:00+08', 1, 1, '0', 'admin', NOW()),
  (6011, 5007, 2, 1, 1, '2026-06-07 02:30:00+08', 1, 1, '0', 'admin', NOW()),
  (6012, 5008, 2, 1, 1, '2026-06-07 03:15:00+08', 1, 1, '0', 'admin', NOW())
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 四、检查检验数据
-- ============================

INSERT INTO check_apply (id, apply_no, encounter_id, patient_id, patient_name, id_card, fee_type, apply_date, apply_dept_id, apply_doctor_id, diagnosis_desc, check_purpose, status, total_amount, create_time)
VALUES 
  (8001, 'CK20260607001', 6001, 5001, '测试患者甲', '450102199001011234', '1', '2026-06-07 09:15:00+08', 1010, 2001, '咳嗽咳痰3天', '排除肺炎', 1, 280.00, NOW()),
  (8002, 'CK20260607002', 6002, 5002, '测试患者乙', '450102198505052345', '1', '2026-06-07 09:45:00+08', 1010, 2002, '头痛头晕1周', '排除颅内病变', 1, 560.00, NOW()),
  (8003, 'CK20260607003', 6011, 5007, '急诊患者庚', '450102198807071111', '1', '2026-06-07 02:45:00+08', 1010, 2006, '外伤后腹痛2小时', '排除脏器损伤', 1, 420.00, NOW())
ON CONFLICT (id) DO NOTHING;

INSERT INTO check_apply_detail (id, apply_id, check_item_name, check_part, check_method, create_time)
VALUES 
  (9001, 8001, '胸部CT平扫', '胸部', 'CT', NOW()),
  (9002, 8001, '血常规', '静脉血', '检验', NOW()),
  (9003, 8002, '头颅MRI', '头部', 'MRI', NOW()),
  (9004, 8002, '经颅多普勒', '头部', '超声', NOW()),
  (9005, 8003, '腹部CT增强', '腹部', 'CT', NOW()),
  (9006, 8003, '全血细胞计数', '静脉血', '检验', NOW())
ON CONFLICT (id) DO NOTHING;

INSERT INTO lab_apply (id, apply_no, patient_id, patient_name, apply_dept_code, apply_doc_code, apply_doc_name, apply_time, apply_status, delete_flag, create_by, create_time)
VALUES 
  (10001, 'LAB20260607001', 5001, '测试患者甲', '1009', '2009', '吴十一医生', '2026-06-07 09:20:00+08', '1', '0', 'admin', NOW()),
  (10002, 'LAB20260607002', 5002, '测试患者乙', '1009', '2009', '吴十一医生', '2026-06-07 09:50:00+08', '1', '0', 'admin', NOW()),
  (10003, 'LAB20260607003', 5006, '测试患者己', '1009', '2009', '吴十一医生', '2026-06-07 14:10:00+08', '1', '0', 'admin', NOW())
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 五、影像数据
-- ============================

INSERT INTO radiology_image_report (id, apply_no, patient_id, patient_name, report_status, create_time)
VALUES 
  (11001, 'CK20260607001', 5001, '测试患者甲', '1', NOW()),
  (11002, 'CK20260607002', 5002, '测试患者乙', '1', NOW()),
  (11003, 'CK20260607003', 5007, '急诊患者庚', '1', NOW())
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 六、手术数据
-- ============================

INSERT INTO cli_surgery (id, patient_id, encounter_id, delete_flag, create_by, create_time)
VALUES 
  (12001, 5001, 6006, '0', 'admin', NOW()),
  (12002, 5004, 6008, '0', 'admin', NOW())
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 七、麻醉数据
-- ============================

INSERT INTO anes_record (id, patient_id, encounter_id, delete_flag, create_by, create_time)
VALUES 
  (13001, 5001, 6006, '0', 'admin', NOW()),
  (13002, 5004, 6008, '0', 'admin', NOW())
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 八、护理数据
-- ============================

INSERT INTO nursing_assessment (id, patient_id, encounter_id, assessment_type, assessment_score, risk_level, delete_flag, create_by, create_time)
VALUES 
  (14001, 5001, 6006, 'braden', 12, 'high', '0', 'admin', NOW()),
  (14002, 5002, 6007, 'morse', 45, 'high', '0', 'admin', NOW()),
  (14003, 5004, 6008, 'nrs2002', 4, 'at_risk', '0', 'admin', NOW())
ON CONFLICT (id) DO NOTHING;

INSERT INTO nursing_vital_signs_chart (id, patient_id, encounter_id, temperature, pulse, respiration, blood_pressure_systolic, blood_pressure_diastolic, oxygen_saturation, delete_flag, create_by, create_time)
VALUES 
  (15001, 5001, 6006, 37.2, 78, 18, 125, 82, 98.5, '0', 'admin', NOW()),
  (15002, 5002, 6007, 36.8, 72, 16, 130, 85, 99.0, '0', 'admin', NOW()),
  (15003, 5004, 6008, 37.5, 85, 20, 140, 90, 97.5, '0', 'admin', NOW()),
  (15004, 5005, 6009, 38.2, 92, 22, 150, 95, 96.0, '0', 'admin', NOW())
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 九、院感数据
-- ============================

INSERT INTO hir_infection_case (id, patient_id, encounter_id, infection_type, infection_site, pathogen, diagnosis_date, reporter_id, reporter_name, report_time, status, create_time, tenant_id, delete_flag, create_by)
VALUES 
  (16001, 5001, 6006, '医院获得性肺炎', '肺部', '铜绿假单胞菌', '2026-06-03', 2001, '张三医生', '2026-06-03 10:00:00+08', 1, NOW(), 1, '0', 'admin'),
  (16002, 5002, 6007, '导管相关血流感染', '血流', '金黄色葡萄球菌', '2026-06-05', 2002, '李四医生', '2026-06-05 14:00:00+08', 1, NOW(), 1, '0', 'admin')
ON CONFLICT (id) DO NOTHING;

INSERT INTO hir_hand_hygiene (id, department_id, department_name, monitor_date, observe_count, comply_count, comply_rate, observer_name, remarks, tenant_id, is_deleted, create_by, create_time)
VALUES 
  (17001, 1005, 'ICU', '2026-06-07', 120, 114, 95.0, '院感科', '手卫生依从性检查', 1, '0', 'admin', NOW()),
  (17002, 1001, '门诊内科', '2026-06-07', 80, 72, 90.0, '院感科', '手卫生依从性检查', 1, '0', 'admin', NOW())
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 十、质控数据
-- ============================

INSERT INTO emr_quality_score (id, encounter_id, patient_id, emr_type, score, max_score, grade, checker_id, checker_name, check_type, check_time, del_flag, create_time, tenant_id)
VALUES 
  (18001, 6006, 5001, '入院记录', 92.5, 100, '优秀', 2001, '张三医生', '运行质控', '2026-06-02 10:00:00+08', '0', NOW(), 1),
  (18002, 6007, 5002, '入院记录', 88.0, 100, '良好', 2002, '李四医生', '终末质控', '2026-06-06 14:00:00+08', '0', NOW(), 1),
  (18003, 6008, 5004, '入院记录', 95.0, 100, '优秀', 2006, '陈八医生', '运行质控', '2026-06-04 09:00:00+08', '0', NOW(), 1)
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 十一、中医数据
-- ============================

INSERT INTO tcm_constitution_assessment (id, encounter_id, patient_id, constitution_type, score, recommendation, assessor_id, assessment_time, tenant_id, delete_flag, create_by, create_time)
VALUES 
  (19001, 6006, 5001, '气虚质', 65, '建议加强锻炼，饮食调理', 2005, '2026-06-02 10:00:00+08', 1, '0', 'admin', NOW()),
  (19002, 6007, 5002, '阳虚质', 70, '建议保暖，避免生冷食物', 2005, '2026-06-03 10:00:00+08', 1, '0', 'admin', NOW())
ON CONFLICT (id) DO NOTHING;

INSERT INTO tcm_prescription (id, prescription_name, prescription_type, herbs, dosage, usage, indication, source, enabled, tenant_id, delete_flag, create_by, create_time)
VALUES 
  (20001, '四君子汤', '补益剂', '人参、白术、茯苓、甘草', '水煎服', '日一剂，分两次温服', '脾胃气虚', '伤寒论', 1, 1, '0', 'admin', NOW()),
  (20002, '六味地黄丸', '补益剂', '熟地黄、山药、泽泻、牡丹皮、茯苓、山茱萸', '口服', '一次8丸，一日3次', '肾阴虚', '小儿药证直诀', 1, 1, '0', 'admin', NOW()),
  (20003, '小柴胡汤', '和解剂', '柴胡、黄芩、人参、半夏、甘草、生姜、大枣', '水煎服', '日一剂，分两次温服', '少阳证', '伤寒论', 1, 1, '0', 'admin', NOW())
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 十二、会诊数据
-- ============================

INSERT INTO consultation_record (id, consultation_request_id, participant_doctor_id, participant_doctor_name, participant_department_id, participant_department_name, opinion, suggestion, record_date, creator_id, creator_name, create_time, valid_flag, tenant_id)
VALUES 
  (21001, 'CONS20260607001', 2005, '刘七医生', 1005, 'ICU', '患者肺部感染较重，建议加强抗感染治疗', '建议升级抗生素', '2026-06-03', 2001, '张三医生', NOW(), 1, 1),
  (21002, 'CONS20260607002', 2002, '李四医生', 1002, '门诊外科', '患者心脏功能尚可，可以耐受手术', '建议术前心功能评估', '2026-06-04', 2004, '赵六医生', NOW(), 1, 1)
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 十三、临床路径数据
-- ============================

INSERT INTO clinical_pathway (id, pathway_name, disease_code, disease_name, department_name, avg_days, avg_cost, version, status, tenant_id, is_deleted, create_time, delete_flag, create_by)
VALUES 
  (22001, '社区获得性肺炎', 'J18.9', '社区获得性肺炎', '呼吸内科', 10, 8000.00, '1.0', '1', 1, '0', NOW(), '0', 'admin'),
  (22002, '急性阑尾炎', 'K35.8', '急性阑尾炎', '普外科', 7, 12000.00, '1.0', '1', 1, '0', NOW(), '0', 'admin'),
  (22003, '2型糖尿病', 'E11.9', '2型糖尿病', '内分泌科', 14, 6000.00, '1.0', '1', 1, '0', NOW(), '0', 'admin')
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 十四、危急值数据
-- ============================

INSERT INTO critical_value (id, encounter_id, patient_id, patient_name, item_code, item_name, result_value, reference_range, unit, lab_department, report_time, status, create_time, tenant_id, delete_flag, create_by)
VALUES 
  (23001, 6006, 5001, '测试患者甲', 'K', '血钾', '6.8', '3.5-5.5', 'mmol/L', '检验科', '2026-06-03 15:30:00+08', 1, NOW(), 1, '0', 'admin'),
  (23002, 6007, 5002, '测试患者乙', 'HGB', '血红蛋白', '52', '110-160', 'g/L', '检验科', '2026-06-05 08:00:00+08', 1, NOW(), 1, '0', 'admin')
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 十五、电子病历数据
-- ============================

INSERT INTO doc_emr (id, patient_id, encounter_id, emr_enum, record_id, tenant_id, delete_flag, create_by, create_time, class_enum)
VALUES 
  (24001, 5001, 6006, 1, 1001, 1, '0', 'admin', NOW(), 2),
  (24002, 5002, 6007, 1, 1002, 1, '0', 'admin', NOW(), 2),
  (24003, 5004, 6008, 1, 1003, 1, '0', 'admin', NOW(), 2)
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 十六、药品追溯数据
-- ============================

INSERT INTO drug_trace_code (id, drug_code, drug_name, generic_name, specification, manufacturer, batch_no, trace_code, production_date, expiry_date, approval_number, dosage_form, unit, barcode, qr_code, status, delete_flag, create_by, create_time, tenant_id)
VALUES 
  (28001, 'DRG001', '阿莫西林胶囊', '阿莫西林', '0.5g*24片', '华北制药', 'B20260101', 'TR20260101001', '2026-01-01', '2028-01-01', '国药准字H13023964', '胶囊剂', '盒', '6901234567890', 'QR001', 1, '0', 'admin', NOW(), 1),
  (28002, 'DRG002', '布洛芬缓释胶囊', '布洛芬', '0.3g*20粒', '中美史克', 'B20260201', 'TR20260201001', '2026-02-01', '2028-02-01', '国药准字H10900089', '胶囊剂', '盒', '6901234567891', 'QR002', 1, '0', 'admin', NOW(), 1)
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 十七、处方点评数据
-- ============================

INSERT INTO review_plan (id, plan_name, review_type, dept_name, target_count, sample_count, reviewed_count, start_date, end_date, status, delete_flag, create_by, create_time, tenant_id)
VALUES 
  (29001, '2026年6月处方点评', '月度', '全部科室', 200, 50, 30, '2026-06-01', '2026-06-30', 1, '0', 'admin', NOW(), 1),
  (29002, '2026年第二季度处方点评', '季度', '全部科室', 600, 100, 80, '2026-04-01', '2026-06-30', 1, '0', 'admin', NOW(), 1)
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 十八、DRG分析数据
-- ============================

INSERT INTO drg_analysis_stats (id, stat_month, department_name, drg_code, case_count, avg_cost, avg_los, avg_weight, cost_efficiency, time_efficiency, tenant_id, create_time)
VALUES 
  (30001, '2026-06', '呼吸内科', 'ER1', 15, 12000.00, 10, 1.2, 1.05, 0.95, 1, NOW()),
  (30002, '2026-06', '普外科', 'FR1', 20, 15000.00, 7, 0.8, 1.10, 0.90, 1, NOW())
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 十九、随访数据
-- ============================

INSERT INTO followup_plan (id, patient_id, patient_name, encounter_id, disease_code, disease_name, followup_type, frequency, total_times, completed_times, responsible_doctor, responsible_nurse, start_date, end_date, status, tenant_id, is_deleted, create_time, delete_flag, create_by)
VALUES 
  (31001, 5001, '测试患者甲', 6006, 'J18.9', '重症肺炎', '电话随访', '每周1次', 4, 1, '刘七医生', '护士B', '2026-06-07', '2026-07-07', 1, 1, '0', NOW(), '0', 'admin'),
  (31002, 5002, '测试患者乙', 6007, 'I10', '高血压3级', '门诊复查', '每月1次', 3, 0, '李四医生', '护士A', '2026-06-07', '2026-09-07', 1, 1, '0', NOW(), '0', 'admin')
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 二十、知情同意数据
-- ============================

INSERT INTO sys_informed_consent (id, encounter_id, patient_id, patient_name, consent_type, diagnosis, procedure_name, procedure_purpose, procedure_method, expected_outcome, risks_and_complications, doctor_user_id, doctor_name, doctor_sign_time, status, version, tenant_id, is_deleted, create_by, create_time, delete_flag)
VALUES 
  (32001, 6006, 5001, '测试患者甲', '手术知情同意书', '重症肺炎', '胸腔镜手术', '治疗肺部感染', '胸腔镜下肺叶切除', '感染控制', '出血、感染', 2005, '刘七医生', '2026-06-03 10:00:00+08', 1, 1, 1, '0', 'admin', NOW(), '0'),
  (32002, 6007, 5002, '测试患者乙', '麻醉知情同意书', '高血压3级', '全身麻醉', '手术麻醉', '气管插管全麻', '麻醉成功', '过敏、呼吸抑制', 2005, '刘七医生', '2026-06-04 10:00:00+08', 1, 1, 1, '0', 'admin', NOW(), '0')
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 二十一、消毒供应中心数据
-- ============================

INSERT INTO cssd_sterilize_batch (id, batch_code, sterilizer_name, sterilizer_code, start_time, end_time, cycle_type, temperature, pressure, exposure_time, biological_result, chemical_result, physical_result, batch_status, release_by, release_time, tenant_id, is_deleted, create_time, delete_flag)
VALUES 
  (33001, 'CSSD20260607001', '脉动真空灭菌器', 'PVS001', '2026-06-07 08:00:00+08', '2026-06-07 09:30:00+08', 'B-D', 134, 0.21, 30, '合格', '合格', '合格', 1, '护士D', '2026-06-07 10:00:00+08', 1, '0', NOW(), '0'),
  (33002, 'CSSD20260607002', '低温等离子灭菌器', 'LTP001', '2026-06-07 10:00:00+08', '2026-06-07 11:30:00+08', '标准', 55, NULL, 45, '合格', '合格', '合格', 1, '护士D', '2026-06-07 12:00:00+08', 1, '0', NOW(), '0')
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 二十二、EMPI主索引数据
-- ============================

INSERT INTO empi_person (id, global_id, patient_name, gender, birth_date, id_card_no, phone, address, status, source_system, delete_flag, create_by, create_time, tenant_id, merge_status)
VALUES 
  (34001, 'EMPI001', '测试患者甲', 1, '1990-01-15', '450102199001011234', '13800138001', '广西南宁市青秀区民族大道100号', 1, 'HIS', '0', 'admin', NOW(), 1, 0),
  (34002, 'EMPI002', '测试患者乙', 2, '1985-05-20', '450102198505052345', '13800138002', '广西南宁市兴宁区朝阳路200号', 1, 'HIS', '0', 'admin', NOW(), 1, 0)
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 二十三、ESB数据集成数据
-- ============================

INSERT INTO sys_esb_service_registry (id, service_name, service_version, service_endpoint, service_description, service_status, protocol, timeout_ms, create_by, create_time, tenant_id, delete_flag)
VALUES 
  (35001, '患者信息查询', '1.0', '/fhir/Patient', 'FHIR患者信息查询服务', 1, 'FHIR', 3000, 'admin', NOW(), 1, '0'),
  (35002, '检验结果查询', '1.0', '/hl7/ORU', 'HL7检验结果查询服务', 1, 'HL7', 5000, 'admin', NOW(), 1, '0'),
  (35003, '医嘱查询', '1.0', '/fhir/Order', 'FHIR医嘱查询服务', 1, 'FHIR', 3000, 'admin', NOW(), 1, '0')
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 二十四、急诊绿色通道数据
-- ============================

INSERT INTO emergency_green_channel (id, patient_id, disease_type, door_to_treatment_time, target_time, is_achieved, doctor, activate_time, tenant_id, is_deleted, create_time, delete_flag, create_by)
VALUES 
  (36001, 5007, '胸痛', '2026-06-07 02:45:00+08', '2026-06-07 03:15:00+08', 1, '陈八医生', '2026-06-07 02:35:00+08', 1, '0', NOW(), '0', 'admin'),
  (36002, 5008, '卒中', '2026-06-07 03:30:00+08', '2026-06-07 04:00:00+08', 1, '陈八医生', '2026-06-07 03:20:00+08', 1, '0', NOW(), '0', 'admin')
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 二十五、病案首页数据
-- ============================

INSERT INTO mr_homepage (id, encounter_id, patient_id, admission_date, discharge_date, los_days, primary_diagnosis_code, primary_diagnosis_name, primary_procedure_code, primary_procedure_name, drg_group, drg_weight, total_cost, self_pay_cost, insurance_cost, quality_status, quality_score, del_flag, create_by, create_time, tenant_id)
VALUES 
  (37001, 6009, 5005, '2026-06-04', '2026-06-07', 3, 'J18.9', '重症肺炎', '0B113J0', '胸腔镜下肺叶切除术', 'ER1', 1.2, 25000.00, 5000.00, 20000.00, '1', 92.5, '0', 'admin', NOW(), 1),
  (37002, 6008, 5004, '2026-06-03', '2026-06-07', 4, 'K35.8', '急性阑尾炎', '0DTJ0ZZ', '腹腔镜下阑尾切除术', 'FR1', 0.8, 18000.00, 4000.00, 14000.00, '1', 95.0, '0', 'admin', NOW(), 1)
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 二十六、医嘱主表数据
-- ============================

INSERT INTO order_main (id, order_no, patient_id, patient_name, department_id, department_name, doctor_id, doctor_name, reg_type, fee, appointment_date, appointment_time, status, pay_status, tenant_id, delete_flag, create_by, create_time)
VALUES 
  (38001, 'ORD20260607001', 5001, '测试患者甲', 1001, '门诊内科', 2001, '张三医生', 1, 50.00, '2026-06-07', '09:00', 1, 1, 1, '0', 'admin', NOW()),
  (38002, 'ORD20260607002', 5002, '测试患者乙', 1002, '门诊外科', 2002, '李四医生', 1, 80.00, '2026-06-07', '09:30', 1, 1, 1, '0', 'admin', NOW()),
  (38003, 'ORD20260607003', 5004, '测试患者丁', 1004, '妇产科', 2004, '赵六医生', 2, 100.00, '2026-06-07', '10:30', 1, 1, 1, '0', 'admin', NOW())
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 二十七、护理质量指标数据
-- ============================

INSERT INTO nursing_quality_indicator (id, indicator_code, indicator_name, indicator_category, target_value, actual_value, unit, stat_period, stat_date, department_id, department_name, status, tenant_id, is_deleted, create_by, create_time, delete_flag)
VALUES 
  (39001, 'NQ001', '压疮发生率', '护理质量', '0.5', '0.3', '%', '2026-06', '2026-06-07', 1005, 'ICU', 1, 1, '0', 'admin', NOW(), '0'),
  (39002, 'NQ002', '跌倒发生率', '护理质量', '1.0', '0.8', '%', '2026-06', '2026-06-07', 1005, 'ICU', 1, 1, '0', 'admin', NOW(), '0'),
  (39003, 'NQ003', '导管滑脱率', '护理质量', '0.5', '0.2', '%', '2026-06', '2026-06-07', 1005, 'ICU', 1, 1, '0', 'admin', NOW(), '0'),
  (39004, 'NQ004', '给药差错率', '护理质量', '0.1', '0.05', '%', '2026-06', '2026-06-07', 1008, '药房', 1, 1, '0', 'admin', NOW(), '0')
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 二十八、抗菌药物使用数据
-- ============================

INSERT INTO hir_antibiotic_usage (id, encounter_id, patient_id, drug_code, drug_name, ddd_value, usage_days, usage_type, start_date, end_date, indication, doctor_id, create_time, tenant_id, delete_flag, create_by)
VALUES 
  (40001, 6006, 5001, 'DRG005', '头孢曲松注射液', 2.0, 7, '治疗性', '2026-06-01', '2026-06-07', '肺部感染', 2005, NOW(), 1, '0', 'admin'),
  (40002, 6007, 5002, 'DRG006', '万古霉素', 1.5, 10, '治疗性', '2026-06-02', '2026-06-11', '血流感染', 2005, NOW(), 1, '0', 'admin')
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 二十九、DRG分组数据
-- ============================

INSERT INTO mr_drg_grouping (id, encounter_id, patient_id, patient_name, discharge_date, primary_diagnosis, primary_diagnosis_code, primary_procedure, primary_procedure_code, drg_code, drg_name, drg_weight, total_cost, insurance_payment, patient_payment, los_days, grouping_result, is_valid, tenant_id, is_deleted, create_time, delete_flag)
VALUES 
  (41001, 6009, 5005, '测试患者戊', '2026-06-07', '重症肺炎', 'J18.9', '胸腔镜下肺叶切除术', '0B113J0', 'ER1', '呼吸系统感染', 1.2, 25000.00, 20000.00, 5000.00, 3, '正常', 1, 1, '0', NOW(), '0'),
  (41002, 6008, 5004, '测试患者丁', '2026-06-07', '急性阑尾炎', 'K35.8', '腹腔镜下阑尾切除术', '0DTJ0ZZ', 'FR1', '急性阑尾炎', 0.8, 18000.00, 14000.00, 4000.00, 4, '正常', 1, 1, '0', NOW(), '0')
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 三十、满意度调查数据
-- ============================

INSERT INTO satisfaction_survey (id, patient_id, patient_name, survey_type, department_name, doctor_name, overall_score, service_score, environment_score, suggestions, survey_date, tenant_id, create_time, create_by)
VALUES 
  (42001, 5005, '测试患者戊', '出院患者', '呼吸内科', '刘七医生', 92, 95, 90, '服务态度很好', '2026-06-07', 1, NOW(), 'admin'),
  (42002, 5001, '测试患者甲', '住院患者', 'ICU', '刘七医生', 88, 90, 85, '希望能改善病房环境', '2026-06-07', 1, NOW(), 'admin')
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 三十一、交接班数据
-- ============================

INSERT INTO nursing_handoff (id, encounter_id, patient_id, patient_name, ward, bed_no, shift, handoff_nurse_id, handoff_nurse_name, oncoming_nurse_id, oncoming_nurse_name, patient_condition, key_points, handoff_time, del_flag, create_time, tenant_id)
VALUES 
  (43001, 6006, 5001, '测试患者甲', 'ICU', 'ICU-01', '白班转夜班', 3001, '护士A', 3002, '护士B', '患者生命体征平稳', '继续观察体温变化', '2026-06-07 08:00:00+08', '0', NOW(), 1)
ON CONFLICT (id) DO NOTHING;

-- ============================
-- 完成！
-- ============================
