-- 1. 科室表
INSERT INTO department (department_id, dept_name, dept_type, address, phone)
VALUES ('DEPT001', '内科', '内科', '1号楼3F', '025-8001'),
       ('DEPT002', '外科', '外科', '1号楼4F', '025-8002'),
       ('DEPT003', '儿科', '内科', '2号楼1F', '025-8003');

-- 2. 医生表
INSERT INTO doctor (doctor_id, name, gender, department_id, title, employee_no, username, password_hash, schedule)
VALUES ('DOC001', '张三', '女', 'DEPT001', '主任医师', 'E001', 'lipeihang', '123456', '周一,周三'),
       ('DOC002', '李四', '男', 'DEPT002', '副主任医师', 'E002', 'zhanghaoyu', '123456', '周二,周四');

-- 3. 患者表
INSERT INTO patient (patient_id, name, gender, age, id_card, phone, username, password_hash)
VALUES ('PAT001', '王五', '男', 25, '320101199801011234', '13811112222', 'chenjiale', '123456'),
       ('PAT002', '赵六', '女', 30, '320101199305055678', '13933334444', 'chenzhuyang', '123456');

-- 4. 预约表
INSERT INTO reservation (reservation_id, patient_id, doctor_id, department_id, reservation_date, timeslot, status,
                         channel)
VALUES ('RES001', 'PAT001', 'DOC001', 'DEPT001', '2025-11-22', '09:00-09:30', '已完成', 'APP'),
       ('RES002', 'PAT002', 'DOC002', 'DEPT002', '2025-11-23', '14:00-14:30', '待就诊', '微信');

-- 5. 就诊记录表
INSERT INTO medical_record (record_id, patient_id, doctor_id, reservation_id, visit_department_id, visit_time,
                            chief_complaint, diagnosis, status)
VALUES ('REC001', 'PAT001', 'DOC001', 'RES001', 'DEPT001', '2025-11-22 09:15:00', '咳嗽感冒', '上呼吸道感染', '已完成');

-- 6. 电子病历表
INSERT INTO emr (emr_id, patient_id, record_id, created_at, updated_at, signer, content, archived_status)
VALUES ('EMR001', 'PAT001', 'REC001', '2025-11-22 09:30:00', '2025-11-22 09:30:00', '张三',
        '{"symptoms":"发热38度", "heart_rate":80}', '已归档');

-- 7. 检查项目表
INSERT INTO examination_item (item_id, item_name, item_type, department_id, price, description)
VALUES ('ITEM001', '血常规', '检验', 'DEPT001', 50.00, '常规血液检查'),
       ('ITEM002', '胸部CT', '影像', 'DEPT002', 300.00, '肺部扫描');

-- 8. 检验结果表
INSERT INTO examination_result (result_id, patient_id, item_id, record_id, report_status, view_status, data,
                                report_time)
VALUES ('EXR001', 'PAT001', 'ITEM001', 'REC001', '已出报告', '已查看', '白细胞偏高', '2025-11-22 10:00:00');

-- 9. 药品表
INSERT INTO medicine (medicine_id, name, spec, unit_price, stock, stock_threshold, manufacturer)
VALUES ('MED001', '阿莫西林', '0.25g*24粒', 15.00, 100, 10, '恒瑞医药'),
       ('MED002', '感冒灵颗粒', '10g*9袋', 25.00, 50, 15, '华润三九');

-- 10. 处方表
INSERT INTO prescription (prescription_id, patient_id, doctor_id, record_id, status, created_at)
VALUES ('PRE001', 'PAT001', 'DOC001', 'REC001', '已支付', '2025-11-22 09:40:00');

-- 11. 处方详情表
INSERT INTO prescription_detail (detail_id, prescription_id, medicine_id, quantity, dose, frequency, duration)
VALUES ('DTL001', 'PRE001', 'MED001', 2, '0.5g', '1日3次', '3天');

-- 12. 缴费表
INSERT INTO payment (payment_id, patient_id, amount, insurance_amount, self_pay_amount, business_type, method, status,
                     paid_at)
VALUES ('PAY001', 'PAT001', 80.00, 24.00, 56.00, '药费', '微信', '已支付', '2025-11-22 10:10:00');