ข้ามไปที่เนื้อหา

Data Flow Diagram (DFD)

ระบบซักประวัติ (Medical History and Examination System)

เวอร์ชัน: 1.0

วันที่: 7 ตุลาคม 2568

สอดคล้องกับ: SRS ระบบซักประวัติ v1.0, TOR ระบบซักประวัติ, ERD v1.0, และ Schema v1.0


สารบัญ

  1. ภาพรวมระบบ
  2. Context Diagram
  3. Level 0 DFD
  4. Level 1 DFD - การตรวจรักษาและซักประวัติ
  5. Level 1 DFD - การจัดการนัดหมาย
  6. Level 1 DFD - การขอปรึกษา
  7. Level 1 DFD - การพิมพ์เอกสาร
  8. Data Dictionary
  9. API Integration Flow

1. ภาพรวมระบบ

ระบบซักประวัติทำหน้าที่เป็น Clinical Core System ที่จัดการข้อมูลการซักประวัติและการตรวจรักษาผู้ป่วย โดยมีการไหลของข้อมูลหลักดังนี้:

  • Input: ข้อมูลผู้ป่วยจากระบบเวชระเบียน, สัญญาณชีพ, อาการสำคัญ, ประวัติการเจ็บป่วย
  • Processing: บันทึกการซักประวัติ, วินิจฉัยโรค, สั่งจ่ายยา, สั่งตรวจ Lab/X-Ray, การนัดหมาย
  • Output: เอกสารทางการแพทย์, ใบสั่งยา, ใบส่งตรวจ, ใบนัดหมาย
  • Integration: เชื่อมต่อกับระบบอื่นผ่าน API สำหรับการสั่งจ่ายยา, ตรวจ Lab/X-Ray, การเงิน

2. Context Diagram

graph TD
    %% External Entities
    DOC["👨‍⚕️ แพทย์"]
    NURSE["👩‍⚕️ พยาบาล"]
    PHAR["💊 เจ้าหน้าที่เภสัช"]
    PAT["👤 ผู้ป่วย"]
    ADMIN["👨‍💼 ผู้ดูแลระบบ"]

    %% Central System
    HIS["🏥 ระบบซักประวัติ<br/>(Medical History System)"]

    %% External Systems
    MRS["📋 ระบบเวชระเบียน<br/>(1.2.1)"]
    EXAM["🔬 ระบบห้องตรวจแพทย์<br/>(1.2.3)"]
    RIGHTS["🆔 ระบบตรวจสอบสิทธิ<br/>(1.2.15)"]
    PHAR_SYS["💊 ระบบเภสัชกรรม<br/>(1.2.13)"]
    FIN["💰 ระบบการเงิน<br/>(1.2.14)"]
    LAB["🧪 ระบบงานชันสูตร<br/>(1.2.7)"]
    XRAY["📸 ระบบรังสีวิทยา<br/>(1.2.8)"]

    %% Data Flows - Input to System
    DOC -->|"ข้อมูลการซักประวัติ<br/>การวินิจฉัย<br/>การสั่งการรักษา"| HIS
    NURSE -->|"สัญญาณชีพ<br/>ข้อมูลเบื้องต้น<br/>การปฏิบัติตามแพทย์สั่ง"| HIS
    PHAR -->|"ตรวจสอบ Drug Interaction<br/>การแพ้ยา<br/>ข้อมูลยา"| HIS
    PAT -->|"อาการสำคัญ<br/>ประวัติการเจ็บป่วย"| HIS
    ADMIN -->|"การจัดการ Master Data<br/>ICD Codes<br/>Template"| HIS

    %% Data Flows - Output from System
    HIS -->|"ใบสั่งยา<br/>ใบรับรองแพทย์<br/>ใบนัดหมาย"| DOC
    HIS -->|"คำสั่งการพยาบาล<br/>ข้อมูลการรักษา"| NURSE
    HIS -->|"รายการยาที่สั่ง<br/>ข้อมูลการแพ้ยา"| PHAR
    HIS -->|"ข้อมูลการรักษา<br/>ใบนัดหมาย"| PAT

    %% System Integration
    MRS <-->|"ข้อมูลผู้ป่วย<br/>Visit Information<br/>HN Lookup"| HIS
    EXAM <-->|"การส่งต่อการตรวจ<br/>ข้อมูลการรักษา"| HIS
    RIGHTS <-->|"ตรวจสอบสิทธิ<br/>การรักษา"| HIS
    PHAR_SYS <-->|"การสั่งจ่ายยา<br/>Drug Interaction<br/>Allergy Check"| HIS
    FIN <-->|"ข้อมูลการคิดเงิน<br/>ค่าบริการ"| HIS
    LAB <-->|"การสั่ง Lab<br/>ผล Lab"| HIS
    XRAY <-->|"การสั่ง X-Ray<br/>ผล X-Ray"| HIS

    %% Styling
    style HIS fill:#e1f5fe,stroke:#01579b,stroke-width:3px
    style MRS fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
    style EXAM fill:#e8f5e8,stroke:#1b5e20,stroke-width:2px
    style RIGHTS fill:#fff3e0,stroke:#e65100,stroke-width:2px
    style PHAR_SYS fill:#fce4ec,stroke:#880e4f,stroke-width:2px
    style FIN fill:#e0f2f1,stroke:#004d40,stroke-width:2px
    style LAB fill:#f1f8e9,stroke:#33691e,stroke-width:2px
    style XRAY fill:#fafafa,stroke:#424242,stroke-width:2px

3. Level 0 DFD

graph TD
    %% External Entities
    DOC["👨‍⚕️ แพทย์"]
    NURSE["👩‍⚕️ พยาบาล"]
    PHAR["💊 เจ้าหน้าที่เภสัช"]
    PAT["👤 ผู้ป่วย"]
    ADMIN["👨‍💼 ผู้ดูแลระบบ"]

    %% External Systems
    MRS["📋 ระบบเวชระเบียน"]
    EXAM["🔬 ระบบห้องตรวจแพทย์"]
    RIGHTS["🆔 ระบบตรวจสอบสิทธิ"]
    PHAR_SYS["💊 ระบบเภสัชกรรม"]
    FIN["💰 ระบบการเงิน"]
    LAB["🧪 ระบบงานชันสูตร"]
    XRAY["📸 ระบบรังสีวิทยา"]

    %% Core Processes
    P1["1.0<br/>🏥<br/>การตรวจรักษา<br/>และซักประวัติ"]
    P2["2.0<br/>📅<br/>การจัดการ<br/>นัดหมาย"]
    P3["3.0<br/>👥<br/>การขอ<br/>ปรึกษา"]
    P4["4.0<br/>🖨️<br/>การพิมพ์<br/>เอกสาร"]
    P5["5.0<br/>⚙️<br/>การจัดการ<br/>ข้อมูลพื้นฐาน"]

    %% Data Stores
    DS1[("D1<br/>HISTORY_TAKING<br/>การซักประวัติหลัก")]
    DS2[("D2<br/>VITAL_SIGNS<br/>สัญญาณชีพ")]
    DS3[("D3<br/>DRUG_ALLERGY<br/>การแพ้ยา")]
    DS4[("D4<br/>MEDICAL_DIAGNOSIS<br/>การวินิจฉัยโรค")]
    DS5[("D5<br/>MEDICAL_PROCEDURE<br/>หัตถการทางการแพทย์")]
    DS6[("D6<br/>MEDICATION_ORDER<br/>การสั่งจ่ายยา")]
    DS7[("D7<br/>LAB_ORDER<br/>การสั่ง Lab")]
    DS8[("D8<br/>XRAY_ORDER<br/>การสั่ง X-Ray")]
    DS9[("D9<br/>APPOINTMENTS<br/>การนัดหมาย")]
    DS10[("D10<br/>CONSULTATIONS<br/>การขอปรึกษา")]
    DS11[("D11<br/>PATIENT_REFER<br/>การส่งต่อผู้ป่วย")]
    DS12[("D12<br/>PATIENT_ADVICE<br/>คำแนะนำผู้ป่วย")]
    DS13[("D13<br/>ICD_CODES<br/>รหัส ICD")]
    DS14[("D14<br/>TEMPLATES<br/>แม่แบบ")]

    %% Process 1.0 - การตรวจรักษาและซักประวัติ
    DOC -->|"ข้อมูลการซักประวัติ"| P1
    NURSE -->|"สัญญาณชีพ"| P1
    PAT -->|"อาการสำคัญ, ประวัติ"| P1
    PHAR -->|"ข้อมูลการแพ้ยา"| P1

    P1 -->|"บันทึกการซักประวัติ"| DS1
    P1 -->|"บันทึกสัญญาณชีพ"| DS2
    P1 -->|"บันทึกการแพ้ยา"| DS3
    P1 -->|"บันทึกการวินิจฉัย"| DS4
    P1 -->|"บันทึกหัตถการ"| DS5
    P1 -->|"การสั่งจ่ายยา"| DS6
    P1 -->|"การสั่ง Lab"| DS7
    P1 -->|"การสั่ง X-Ray"| DS8
    P1 -->|"การส่งต่อผู้ป่วย"| DS11
    P1 -->|"คำแนะนำผู้ป่วย"| DS12

    DS1 -->|"ข้อมูลการซักประวัติ"| P1
    DS2 -->|"ประวัติสัญญาณชีพ"| P1
    DS3 -->|"ข้อมูลการแพ้ยา"| P1
    DS13 -->|"รหัส ICD"| P1
    DS14 -->|"Template"| P1

    %% Process 2.0 - การจัดการนัดหมาย
    DOC -->|"ข้อมูลนัดหมาย"| P2
    P2 -->|"บันทึกนัดหมาย"| DS9
    P2 -->|"การสั่งล่วงหน้า"| DS7
    P2 -->|"การสั่งล่วงหน้า"| DS8
    DS9 -->|"ข้อมูลนัดหมาย"| P2

    %% Process 3.0 - การขอปรึกษา
    DOC -->|"ข้อมูลการ Consult"| P3
    P3 -->|"บันทึกการ Consult"| DS10
    DS10 -->|"ข้อมูลการ Consult"| P3

    %% Process 4.0 - การพิมพ์เอกสาร
    DOC -->|"คำขอพิมพ์เอกสาร"| P4
    DS1 -->|"ข้อมูลการซักประวัติ"| P4
    DS4 -->|"ข้อมูลการวินิจฉัย"| P4
    DS6 -->|"ข้อมูลการสั่งยา"| P4
    DS9 -->|"ข้อมูลนัดหมาย"| P4
    DS11 -->|"ข้อมูลการส่งต่อ"| P4
    P4 -->|"เอกสารต่างๆ"| DOC

    %% Process 5.0 - การจัดการข้อมูลพื้นฐาน
    ADMIN -->|"จัดการ Master Data"| P5
    P5 -->|"อัพเดท ICD Codes"| DS13
    P5 -->|"จัดการ Template"| DS14
    DS13 -->|"รหัส ICD"| P5
    DS14 -->|"Template"| P5

    %% External System Integration
    MRS <-->|"ข้อมูลผู้ป่วย, Visit"| P1
    EXAM <-->|"การส่งต่อการตรวจ"| P1
    RIGHTS <-->|"ตรวจสอบสิทธิ"| P1
    PHAR_SYS <-->|"การสั่งจ่ายยา, Drug Check"| P1
    FIN <-->|"ข้อมูลการคิดเงิน"| P1
    LAB <-->|"การสั่ง Lab, ผล Lab"| P1
    XRAY <-->|"การสั่ง X-Ray, ผล X-Ray"| P1

    %% Styling
    style P1 fill:#e3f2fd,stroke:#0d47a1,stroke-width:2px
    style P2 fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
    style P3 fill:#e8f5e8,stroke:#1b5e20,stroke-width:2px
    style P4 fill:#fff3e0,stroke:#e65100,stroke-width:2px
    style P5 fill:#fce4ec,stroke:#880e4f,stroke-width:2px

    style DS1 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS2 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS3 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS4 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS5 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS6 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS7 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS8 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS9 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS10 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS11 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS12 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS13 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS14 fill:#e0f2f1,stroke:#00695c,stroke-width:2px

4. Level 1 DFD - การตรวจรักษาและซักประวัติ

graph TD
    %% External Entities
    DOC["👨‍⚕️ แพทย์"]
    NURSE["👩‍⚕️ พยาบาล"]
    PHAR["💊 เจ้าหน้าที่เภสัช"]
    PAT["👤 ผู้ป่วย"]

    %% External Systems
    MRS["📋 ระบบเวชระเบียน"]
    EXAM["🔬 ระบบห้องตรวจแพทย์"]
    RIGHTS["🆔 ระบบตรวจสอบสิทธิ"]
    PHAR_SYS["💊 ระบบเภสัชกรรม"]
    FIN["💰 ระบบการเงิน"]
    LAB["🧪 ระบบงานชันสูตร"]
    XRAY["📸 ระบบรังสีวิทยา"]

    %% Sub-processes of Process 1.0
    P11["1.1<br/>📝<br/>บันทึกข้อมูล<br/>Screen และ CC"]
    P12["1.2<br/>🩺<br/>บันทึกประวัติ<br/>การเจ็บป่วย"]
    P13["1.3<br/>💊<br/>จัดการข้อมูล<br/>การแพ้ยา"]
    P14["1.4<br/>🔬<br/>การวินิจฉัย<br/>และหัตถการ"]
    P15["1.5<br/>💉<br/>การสั่งจ่ายยา<br/>และเวชภัณฑ์"]
    P16["1.6<br/>🧪<br/>การสั่ง Lab<br/>และ X-Ray"]
    P17["1.7<br/>🚑<br/>การส่งต่อ<br/>ผู้ป่วย"]
    P18["1.8<br/>📋<br/>การให้คำแนะนำ<br/>ผู้ป่วย"]
    P19["1.9<br/>🔄<br/>การใช้ข้อมูลเดิม<br/>และ Template"]

    %% Data Stores
    DS1[("D1<br/>HISTORY_TAKING<br/>การซักประวัติหลัก")]
    DS2[("D2<br/>VITAL_SIGNS<br/>สัญญาณชีพ")]
    DS3[("D3<br/>DRUG_ALLERGY<br/>การแพ้ยา")]
    DS4[("D4<br/>MEDICAL_DIAGNOSIS<br/>การวินิจฉัยโรค")]
    DS5[("D5<br/>MEDICAL_PROCEDURE<br/>หัตถการทางการแพทย์")]
    DS6[("D6<br/>MEDICATION_ORDER<br/>การสั่งจ่ายยา")]
    DS7[("D7<br/>LAB_ORDER<br/>การสั่ง Lab")]
    DS8[("D8<br/>XRAY_ORDER<br/>การสั่ง X-Ray")]
    DS11[("D11<br/>PATIENT_REFER<br/>การส่งต่อผู้ป่วย")]
    DS12[("D12<br/>PATIENT_ADVICE<br/>คำแนะนำผู้ป่วย")]
    DS13[("D13<br/>ICD_CODES<br/>รหัส ICD")]
    DS14[("D14<br/>TEMPLATES<br/>แม่แบบ")]

    %% Process 1.1 - บันทึกข้อมูล Screen และ Chief Complaint
    NURSE -->|"สัญญาณชีพ<br/>น้ำหนัก, ส่วนสูง<br/>อุณหภูมิ, BP"| P11
    PAT -->|"อาการสำคัญ (CC)<br/>เป็นมากี่วันแล้ว"| P11
    P11 -->|"บันทึกสัญญาณชีพ<br/>BMI คำนวณอัตโนมัติ"| DS2
    P11 -->|"บันทึก Chief Complaint"| DS1

    %% Process 1.2 - บันทึกประวัติการเจ็บป่วย
    DOC -->|"HPI, PMH, FH, SH<br/>สถานะตั้งครรภ์"| P12
    P12 -->|"บันทึกประวัติครบถ้วน"| DS1
    DS1 -->|"ข้อมูลประวัติเดิม"| P12

    %% Process 1.3 - จัดการข้อมูลการแพ้ยา
    DOC -->|"ข้อมูลการแพ้ยา<br/>Naranjo Assessment"| P13
    PHAR -->|"ตรวจสอบข้อมูลยา<br/>Drug Information"| P13
    P13 -->|"บันทึกการแพ้ยา<br/>ห้ามสั่งใช้"| DS3
    DS3 -->|"ประวัติการแพ้ยา"| P13

    %% Process 1.4 - การวินิจฉัยและหัตถการ
    DOC -->|"การวินิจฉัย<br/>หัตถการ"| P14
    DS13 -->|"รหัส ICD<br/>WHO & ไทย"| P14
    P14 -->|"บันทึกการวินิจฉัย<br/>ICD Mapping"| DS4
    P14 -->|"บันทึกหัตถการ<br/>ผู้ทำ, เวลา"| DS5

    %% Process 1.5 - การสั่งจ่ายยาและเวชภัณฑ์
    DOC -->|"การสั่งจ่ายยา<br/>RE-MED, Template"| P15
    DS3 -->|"ตรวจสอบการแพ้ยา"| P15
    DS14 -->|"Template การใช้ยา"| P15
    P15 -->|"บันทึกการสั่งยา<br/>Drug Interaction Check"| DS6
    P15 -->|"ส่งข้อมูลการสั่งยา"| PHAR_SYS
    PHAR_SYS -->|"Drug Interaction Alert<br/>Allergy Warning"| P15

    %% Process 1.6 - การสั่ง Lab และ X-Ray
    DOC -->|"การสั่ง Lab<br/>การสั่ง X-Ray"| P16
    P16 -->|"บันทึกการสั่ง Lab<br/>ความเร่งด่วน"| DS7
    P16 -->|"บันทึกการสั่ง X-Ray<br/>ท่า, ด้าน"| DS8
    P16 -->|"ส่งข้อมูลการสั่ง Lab"| LAB
    P16 -->|"ส่งข้อมูลการสั่ง X-Ray"| XRAY
    LAB -->|"ผล Lab<br/>สถานะการตรวจ"| P16
    XRAY -->|"ผล X-Ray<br/>การอ่านผล"| P16

    %% Process 1.7 - การส่งต่อผู้ป่วย
    DOC -->|"ข้อมูลการ Refer<br/>เหตุผลการส่งตัว"| P17
    P17 -->|"บันทึกการ Refer<br/>สถานพยาบาล"| DS11
    P17 -->|"แจ้งข้อมูลการ Refer"| RIGHTS

    %% Process 1.8 - การให้คำแนะนำผู้ป่วย
    DOC -->|"คำแนะนำการใช้ยา<br/>การปฏิบัติตัว"| P18
    P18 -->|"บันทึกคำแนะนำ<br/>การป้องกันโรค"| DS12

    %% Process 1.9 - การใช้ข้อมูลเดิมและ Template
    DOC -->|"ขอใช้ข้อมูลเดิม<br/>เลือก Template"| P19
    DS1 -->|"ข้อมูลการซักประวัติเดิม"| P19
    DS2 -->|"สัญญาณชีพครั้งล่าสุด"| P19
    DS14 -->|"Template โรคเฉพาะ"| P19
    P19 -->|"ข้อมูลเพื่อใช้ซ้ำ"| P11
    P19 -->|"ข้อมูลเพื่อใช้ซ้ำ"| P12

    %% Integration with External Systems
    MRS -->|"ข้อมูลผู้ป่วย<br/>Visit Information"| P11
    P14 -->|"ข้อมูลการวินิจฉัย"| EXAM
    P14 -->|"ข้อมูลค่าบริการ"| FIN
    RIGHTS -->|"ตรวจสอบสิทธิ"| P17

    %% Styling
    style P11 fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
    style P12 fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
    style P13 fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
    style P14 fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
    style P15 fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
    style P16 fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
    style P17 fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
    style P18 fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
    style P19 fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px

    style DS1 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS2 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS3 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS4 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS5 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS6 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS8 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS11 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS12 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS13 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS14 fill:#e0f2f1,stroke:#00695c,stroke-width:2px

5. Level 1 DFD - การจัดการนัดหมาย

graph TD
    %% External Entities
    DOC["👨‍⚕️ แพทย์"]
    NURSE["👩‍⚕️ พยาบาล"]
    PAT["👤 ผู้ป่วย"]

    %% External Systems
    MRS["📋 ระบบเวชระเบียน"]
    LAB["🧪 ระบบงานชันสูตร"]
    XRAY["📸 ระบบรังสีวิทยา"]

    %% Sub-processes of Process 2.0
    P21["2.1<br/>📅<br/>บันทึกการ<br/>นัดหมาย"]
    P22["2.2<br/>🗓️<br/>จัดการนัดหมาย<br/>หลายแผนก"]
    P23["2.3<br/>⚠️<br/>ตรวจสอบ<br/>วันหยุด"]
    P24["2.4<br/>🔬<br/>การสั่งตรวจ<br/>ล่วงหน้า"]
    P25["2.5<br/>📝<br/>ระบุสาเหตุ<br/>การนัด"]
    P26["2.6<br/>🔄<br/>การนัดหมาย<br/>แบบ Template"]

    %% Data Stores
    DS9[("D9<br/>APPOINTMENTS<br/>การนัดหมาย")]
    DS7[("D7<br/>LAB_ORDER<br/>การสั่ง Lab")]
    DS8[("D8<br/>XRAY_ORDER<br/>การสั่ง X-Ray")]
    DS15[("D15<br/>HOLIDAY_CALENDAR<br/>ปฏิทินวันหยุด")]
    DS16[("D16<br/>APPOINTMENT_TEMPLATES<br/>แม่แบบการนัด")]
    DS17[("D17<br/>MULTI_DEPT_VISITS<br/>การมาหลายแผนก")]

    %% Process 2.1 - บันทึกการนัดหมาย
    DOC -->|"ข้อมูลการนัด<br/>วันที่/สัปดาห์/เดือน"| P21
    P21 -->|"บันทึกการนัดหมาย<br/>วันที่และเวลา"| DS9
    DS9 -->|"ข้อมูลการนัดเดิม"| P21

    %% Process 2.2 - จัดการนัดหมายหลายแผนก
    DOC -->|"การนัดหลายแผนก<br/>ใน Visit เดียว"| P22
    P22 -->|"บันทึกการมา<br/>หลายแผนก"| DS17
    P22 -->|"ประสานการนัด<br/>แต่ละแผนก"| DS9
    DS17 -->|"ข้อมูลแผนก<br/>ที่เกี่ยวข้อง"| P22

    %% Process 2.3 - ตรวจสอบวันหยุด
    P21 -->|"ตรวจสอบวันที่นัด"| P23
    P22 -->|"ตรวจสอบวันที่นัด"| P23
    DS15 -->|"ข้อมูลวันหยุด<br/>ต่างๆ"| P23
    P23 -->|"แจ้งเตือน<br/>วันหยุด"| DOC
    P23 -->|"แนะนำวันที่<br/>ทางเลือก"| P21

    %% Process 2.4 - การสั่งตรวจล่วงหน้า
    DOC -->|"การสั่ง Lab/X-Ray<br/>ล่วงหน้า"| P24
    P24 -->|"บันทึกการสั่ง Lab<br/>สำหรับวันนัด"| DS7
    P24 -->|"บันทึกการสั่ง X-Ray<br/>สำหรับวันนัด"| DS8
    P24 -->|"ส่งข้อมูลการสั่ง<br/>ล่วงหน้า"| LAB
    P24 -->|"ส่งข้อมูลการสั่ง<br/>ล่วงหน้า"| XRAY

    %% Process 2.5 - ระบุสาเหตุการนัด
    DOC -->|"สาเหตุการนัด<br/>คำแนะนำการปฏิบัติตัว"| P25
    P25 -->|"บันทึกสาเหตุ<br/>และคำแนะนำ"| DS9
    P25 -->|"ข้อมูลเพื่อพิมพ์<br/>ใบนัดหมาย"| PAT

    %% Process 2.6 - การนัดหมายแบบ Template
    DOC -->|"การนัดแบบต่อเนื่อง<br/>นัดรับยา, ฉีดยา"| P26
    DS16 -->|"Template การนัด<br/>รูปแบบต่างๆ"| P26
    P26 -->|"สร้างการนัด<br/>หลายครั้ง"| DS9
    P26 -->|"การนัดตาม Template<br/>อัตโนมัติ"| P21

    %% Integration with External Systems
    MRS -->|"ข้อมูลผู้ป่วย<br/>แพทย์เจ้าของไข้"| P21
    DS9 -->|"ข้อมูลการนัดหมาย"| MRS

    %% Output flows
    P21 -->|"ข้อมูลการนัดหมาย"| PAT
    P22 -->|"รายละเอียดการมา<br/>หลายแผนก"| PAT
    P25 -->|"คำแนะนำการปฏิบัติตัว"| PAT

    %% Styling
    style P21 fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
    style P22 fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
    style P23 fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
    style P24 fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
    style P25 fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
    style P26 fill:#f3e5f5,stroke:#4a148c,stroke-width:2px

    style DS9 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS7 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS8 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS15 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS16 fill:#e0f2f1,stroke:#00695c,stroke-width:2px

6. Level 1 DFD - การขอปรึกษา

graph TD
    %% External Entities
    DOC["👨‍⚕️ แพทย์ผู้ส่ง"]
    CONS_DOC["👨‍⚕️ แพทย์ผู้รับปรึกษา"]
    DENT["🦷 ทันตแพทย์"]
    DEPT["🏥 แผนกต่างๆ"]

    %% External Systems
    MRS["📋 ระบบเวชระเบียน"]
    NOTIFY["📱 ระบบแจ้งเตือน"]

    %% Sub-processes of Process 3.0
    P31["3.1<br/>📤<br/>ส่งคำขอ<br/>ปรึกษา"]
    P32["3.2<br/>📥<br/>รับและตอบ<br/>การปรึกษา"]
    P33["3.3<br/>⚡<br/>จัดการความ<br/>เร่งด่วน"]
    P34["3.4<br/>📋<br/>ติดตามสถานะ<br/>การปรึกษา"]

    %% Data Stores
    DS10[("D10<br/>CONSULTATIONS<br/>การขอปรึกษา")]
    DS18[("D18<br/>CONSULT_QUESTIONS<br/>คำถามการปรึกษา")]
    DS19[("D19<br/>CONSULT_ANSWERS<br/>คำตอบการปรึกษา")]
    DS20[("D20<br/>URGENCY_LEVELS<br/>ระดับความเร่งด่วน")]

    %% Process 3.1 - ส่งคำขอปรึกษา
    DOC -->|"คำขอปรึกษา<br/>แพทย์/แผนกเป้าหมาย"| P31
    P31 -->|"บันทึกคำขอ<br/>ปรึกษา"| DS10
    P31 -->|"บันทึกคำถาม<br/>การปรึกษา"| DS18
    P31 -->|"แจ้งคำขอปรึกษา"| NOTIFY

    %% Process 3.2 - รับและตอบการปรึกษา
    CONS_DOC -->|"คำตอบการปรึกษา<br/>คำแนะนำ"| P32
    DENT -->|"คำตอบทางทันตกรรม"| P32
    DEPT -->|"คำตอบจากแผนก"| P32
    P32 -->|"บันทึกคำตอบ<br/>การปรึกษา"| DS19
    P32 -->|"อัพเดทสถานะ<br/>การปรึกษา"| DS10
    DS18 -->|"คำถามการปรึกษา"| P32

    %% Process 3.3 - จัดการความเร่งด่วน
    DOC -->|"ระดับความเร่งด่วน<br/>STAT/URGENT/ROUTINE"| P33
    DS20 -->|"เกณฑ์ความเร่งด่วน"| P33
    P33 -->|"จัดลำดับความสำคัญ"| DS10
    P33 -->|"แจ้งเตือนตามระดับ<br/>ความเร่งด่วน"| NOTIFY

    %% Process 3.4 - ติดตามสถานะการปรึกษา
    DOC -->|"ตรวจสอบสถานะ<br/>การปรึกษา"| P34
    DS10 -->|"สถานะการปรึกษา<br/>ปัจจุบัน"| P34
    DS19 -->|"คำตอบที่ได้รับ"| P34
    P34 -->|"รายงานสถานะ<br/>การปรึกษา"| DOC
    P34 -->|"แจ้งเตือนการตอบ<br/>ที่ค้างอยู่"| NOTIFY

    %% Integration with External Systems
    MRS -->|"ข้อมูลผู้ป่วย<br/>ประวัติการรักษา"| P31
    P32 -->|"ผลการปรึกษา"| MRS

    %% Output flows
    P32 -->|"คำตอบการปรึกษา"| DOC
    P34 -->|"สถานะการปรึกษา"| DOC
    NOTIFY -->|"การแจ้งเตือน"| CONS_DOC
    NOTIFY -->|"การแจ้งเตือน"| DENT
    NOTIFY -->|"การแจ้งเตือน"| DEPT

    %% Styling
    style P31 fill:#e8f5e8,stroke:#1b5e20,stroke-width:2px
    style P32 fill:#e8f5e8,stroke:#1b5e20,stroke-width:2px
    style P33 fill:#e8f5e8,stroke:#1b5e20,stroke-width:2px
    style P34 fill:#e8f5e8,stroke:#1b5e20,stroke-width:2px

    style DS10 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS18 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS19 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS20 fill:#e0f2f1,stroke:#00695c,stroke-width:2px

7. Level 1 DFD - การพิมพ์เอกสาร

graph TD
    %% External Entities
    DOC["👨‍⚕️ แพทย์"]
    PAT["👤 ผู้ป่วย"]
    ADMIN["👨‍💼 เจ้าหน้าที่"]

    %% External Systems
    PRINTER["🖨️ เครื่องพิมพ์"]

    %% Sub-processes of Process 4.0
    P41["4.1<br/>📄<br/>พิมพ์ใบรับรอง<br/>แพทย์"]
    P42["4.2<br/>📋<br/>พิมพ์ตรวจรักษา<br/>(OPD CARD)"]
    P43["4.3<br/>💊<br/>พิมพ์ใบสั่งยา"]
    P44["4.4<br/>🚑<br/>พิมพ์ใบส่งต่อ<br/>รักษา"]
    P45["4.5<br/>↩️<br/>พิมพ์ใบตอบกลับ<br/>Refer"]
    P46["4.6<br/>📅<br/>พิมพ์ใบ<br/>นัดหมาย"]
    P47["4.7<br/>🌐<br/>จัดการภาษา<br/>ไทย-อังกฤษ"]

    %% Data Stores
    DS1[("D1<br/>HISTORY_TAKING<br/>การซักประวัติหลัก")]
    DS4[("D4<br/>MEDICAL_DIAGNOSIS<br/>การวินิจฉัยโรค")]
    DS6[("D6<br/>MEDICATION_ORDER<br/>การสั่งจ่ายยา")]
    DS9[("D9<br/>APPOINTMENTS<br/>การนัดหมาย")]
    DS11[("D11<br/>PATIENT_REFER<br/>การส่งต่อผู้ป่วย")]
    DS21[("D21<br/>DOCUMENT_TEMPLATES<br/>แม่แบบเอกสาร")]
    DS22[("D22<br/>PRINT_LOGS<br/>บันทึกการพิมพ์")]

    %% Process 4.1 - พิมพ์ใบรับรองแพทย์
    DOC -->|"คำขอใบรับรอง<br/>สมัครงาน/ลาป่วย"| P41
    DS1 -->|"ข้อมูลการซักประวัติ"| P41
    DS4 -->|"ข้อมูลการวินิจฉัย"| P41
    DS21 -->|"แม่แบบใบรับรอง<br/>ไทย/อังกฤษ"| P41
    P41 -->|"ใบรับรองแพทย์"| PAT
    P41 -->|"บันทึกการพิมพ์"| DS22

    %% Process 4.2 - พิมพ์ตรวจรักษา (OPD CARD)
    DOC -->|"คำขอพิมพ์ OPD CARD"| P42
    DS1 -->|"ข้อมูลการตรวจรักษา"| P42
    DS4 -->|"การวินิจฉัย"| P42
    DS6 -->|"การสั่งยา"| P42
    DS21 -->|"แม่แบบ OPD CARD"| P42
    P42 -->|"OPD CARD"| PAT
    P42 -->|"บันทึกการพิมพ์"| DS22

    %% Process 4.3 - พิมพ์ใบสั่งยา
    DOC -->|"คำขอพิมพ์ใบสั่งยา"| P43
    DS6 -->|"ข้อมูลการสั่งยา<br/>รายละเอียดยา"| P43
    DS21 -->|"แม่แบบใบสั่งยา"| P43
    P43 -->|"ใบสั่งยา"| PAT
    P43 -->|"บันทึกการพิมพ์"| DS22

    %% Process 4.4 - พิมพ์ใบส่งต่อรักษา
    DOC -->|"คำขอพิมพ์ใบ Refer"| P44
    DS11 -->|"ข้อมูลการส่งต่อ<br/>สถานพยาบาล"| P44
    DS1 -->|"ประวัติการรักษา"| P44
    DS4 -->|"การวินิจฉัย"| P44
    DS21 -->|"แม่แบบใบ Refer"| P44
    P44 -->|"ใบส่งต่อรักษา"| PAT
    P44 -->|"บันทึกการพิมพ์"| DS22

    %% Process 4.5 - พิมพ์ใบตอบกลับ Refer
    DOC -->|"คำขอพิมพ์ใบตอบกลับ"| P45
    DS11 -->|"ข้อมูลการรับ Refer"| P45
    DS1 -->|"ผลการรักษา"| P45
    DS4 -->|"การวินิจฉัยใหม่"| P45
    DS21 -->|"แม่แบบใบตอบกลับ"| P45
    P45 -->|"ใบตอบกลับ Refer"| ADMIN
    P45 -->|"บันทึกการพิมพ์"| DS22

    %% Process 4.6 - พิมพ์ใบนัดหมาย
    DOC -->|"คำขอพิมพ์ใบนัด"| P46
    DS9 -->|"ข้อมูลการนัดหมาย<br/>วันที่และเวลา"| P46
    DS21 -->|"แม่แบบใบนัดหมาย<br/>ไทย/อังกฤษ"| P46
    P46 -->|"ใบนัดหมาย"| PAT
    P46 -->|"บันทึกการพิมพ์"| DS22

    %% Process 4.7 - จัดการภาษา
    DOC -->|"เลือกภาษา<br/>ไทย/อังกฤษ"| P47
    DS21 -->|"Template ทั้งสองภาษา"| P47
    P47 -->|"Template ตามภาษา"| P41
    P47 -->|"Template ตามภาษา"| P46

    %% Integration with External Systems
    P41 -->|"ส่งคำสั่งพิมพ์"| PRINTER
    P42 -->|"ส่งคำสั่งพิมพ์"| PRINTER
    P43 -->|"ส่งคำสั่งพิมพ์"| PRINTER
    P44 -->|"ส่งคำสั่งพิมพ์"| PRINTER
    P45 -->|"ส่งคำสั่งพิมพ์"| PRINTER
    P46 -->|"ส่งคำสั่งพิมพ์"| PRINTER

    %% Styling
    style P41 fill:#fff3e0,stroke:#e65100,stroke-width:2px
    style P42 fill:#fff3e0,stroke:#e65100,stroke-width:2px
    style P43 fill:#fff3e0,stroke:#e65100,stroke-width:2px
    style P44 fill:#fff3e0,stroke:#e65100,stroke-width:2px
    style P45 fill:#fff3e0,stroke:#e65100,stroke-width:2px
    style P46 fill:#fff3e0,stroke:#e65100,stroke-width:2px
    style P47 fill:#fff3e0,stroke:#e65100,stroke-width:2px

    style DS1 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS4 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS6 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS9 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS11 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS21 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS22 fill:#e0f2f1,stroke:#00695c,stroke-width:2px

8. Data Dictionary

8.1 Data Elements

Element Name Description Type Length Format
HistoryID รหัสการซักประวัติ VARCHAR 20 HIST-XXXXXXXXXX
VisitID รหัส Visit (อ้างอิงจากระบบเวชระเบียน) VARCHAR 20 VISIT-XXXXXXXXX
HN หมายเลขประจำตัวผู้ป่วย VARCHAR 10 XXXXXXXXXX
DoctorID รหัสแพทย์ผู้ซักประวัติ VARCHAR 20 DOC-XXXXXXXX
ChiefComplaint อาการสำคัญ (CC) NTEXT MAX Text
PresentIllness ประวัติการเจ็บป่วยในปัจจุบัน (HPI) NTEXT MAX Text
OnsetDuration เป็นมากี่วันแล้ว VARCHAR 50 Text/Number
PastMedicalHistory ประวัติการเจ็บป่วยในอดีต (PMH) NTEXT MAX Text
FamilyHistory ประวัติการเจ็บป่วยในครอบครัว (FH) NTEXT MAX Text
SocialHistory ประวัติเกี่ยวกับการดำเนินชีวิต (SH) NTEXT MAX Text
IsPregnant กำลังตั้งครรภ์ BIT 1 0/1
IsBreastfeeding กำลังให้นมบุตร BIT 1 0/1
TemplateName ชื่อ Template ที่ใช้ NVARCHAR 100 Text
Weight น้ำหนัก (กิโลกรัม) DECIMAL 5,2 XXX.XX
Height ส่วนสูง (เซนติเมตร) DECIMAL 5,2 XXX.XX
BMI ดัชนีมวลกาย (คำนวณอัตโนมัติ) DECIMAL 5,2 XX.XX
Temperature อุณหภูมิ (องศาเซลเซียส) DECIMAL 4,1 XX.X
WaistCircumference รอบเอว (เซนติเมตร) DECIMAL 5,2 XXX.XX
PulseRate อัตราเต้นชีพจร (ครั้ง/นาที) INT 3 XXX
RespiratoryRate อัตราหายใจ (ครั้ง/นาที) INT 3 XXX
SystolicBP ความดันโลหิตซิสโตลิก INT 3 XXX
DiastolicBP ความดันโลหิตไดแอสโตลิก INT 3 XXX
BloodPressurePosition ท่าวัดความดันโลหิต VARCHAR 20 Text
DrugName ชื่อยาที่แพ้ (ชื่อสามัญ) NVARCHAR 200 Text
DrugCode รหัสยา VARCHAR 20 Text
AllergySymptoms อาการที่แพ้ NTEXT MAX Text
Severity ความร้ายแรง VARCHAR 20 MILD/MODERATE/SEVERE
NaranjoScore คะแนน Naranjo Algorithm INT 2 XX
NaranjoResult ผลการประเมินระดับการแพ้ยา VARCHAR 50 Text
IsContraindicated ห้ามสั่งใช้กับผู้ป่วย BIT 1 0/1
ICDCode รหัส ICD (WHO) VARCHAR 10 XXX.XXX
ICDCodeThai รหัส ICD ไทย VARCHAR 10 XXX.XXX
DiseaseName ชื่อโรค NVARCHAR 200 Text
DiseaseNameEng ชื่อโรค (อังกฤษ) NVARCHAR 200 Text
DiagnosisType ประเภทการวินิจฉัย VARCHAR 20 PRIMARY/SECONDARY/PROVISIONAL
CertaintyLevel ระดับความแน่นอน VARCHAR 20 CONFIRMED/SUSPECTED/RULE_OUT
ProcedureName ชื่อหัตถการ NVARCHAR 200 Text
PerformerID รหัสแพทย์/เจ้าหน้าที่ผู้ทำ VARCHAR 20 Text
StartTime เวลาเริ่ม DATETIME 19 DD/MM/YYYY HH:MM:SS
EndTime เวลาสิ้นสุด DATETIME 19 DD/MM/YYYY HH:MM:SS
MedicationName ชื่อยา NVARCHAR 200 Text
GenericName ชื่อสามัญยา NVARCHAR 200 Text
Strength ความแรง VARCHAR 50 Text
DosageForm รูปแบบยา VARCHAR 50 Text
Quantity จำนวน DECIMAL 10,2 XXXXX.XX
Unit หน่วย VARCHAR 20 Text
Frequency ความถี่การใช้ยา VARCHAR 50 Text
Duration จำนวนวันใช้ยา INT 3 XXX
Instructions วิธีการใช้ NTEXT MAX Text
Route วิธีให้ยา VARCHAR 50 Text
IsFromTemplate มาจาก Template BIT 1 0/1
AppointmentDate วันที่นัดหมาย DATETIME 19 DD/MM/YYYY HH:MM:SS
AppointmentWeeks จำนวนสัปดาห์ข้างหน้า INT 2 XX
AppointmentMonths จำนวนเดือนข้างหน้า INT 2 XX
IsMultipleDepartments นัดหลายแผนก BIT 1 0/1
ConsultReason เหตุผลการปรึกษา NTEXT MAX Text
TargetDoctorID รหัสแพทย์เป้าหมาย VARCHAR 20 Text
TargetDepartment แผนกเป้าหมาย VARCHAR 50 Text
UrgencyLevel ระดับความเร่งด่วน VARCHAR 20 STAT/URGENT/ROUTINE
ConsultQuestion คำถามการปรึกษา NTEXT MAX Text
ConsultAnswer คำตอบการปรึกษา NTEXT MAX Text
DocumentType ประเภทเอกสาร VARCHAR 50 Text
LanguageType ภาษาเอกสาร VARCHAR 10 TH/EN

8.2 Data Flows

Flow Name Description Composition
history_taking_data ข้อมูลการซักประวัติ HistoryID + VisitID + HN + ChiefComplaint + PresentIllness + OnsetDuration + PastMedicalHistory + FamilyHistory + SocialHistory + IsPregnant + IsBreastfeeding + TemplateName
vital_signs_data ข้อมูลสัญญาณชีพ Weight + Height + BMI + Temperature + WaistCircumference + PulseRate + RespiratoryRate + SystolicBP + DiastolicBP + BloodPressurePosition
drug_allergy_data ข้อมูลการแพ้ยา DrugName + DrugCode + AllergySymptoms + Severity + NaranjoScore + NaranjoResult + IsContraindicated + OnsetDate + Reporter
diagnosis_data ข้อมูลการวินิจฉัย ICDCode + ICDCodeThai + DiseaseName + DiseaseNameEng + DiagnosisType + CertaintyLevel + OnsetType + DiagnosisText
procedure_data ข้อมูลหัตถการ ProcedureName + ICDProcedureCode + PerformerID + PerformerName + StartTime + EndTime + Duration + ProcedureLocation + ProcedureNotes
medication_order_data ข้อมูลการสั่งยา MedicationName + GenericName + Strength + DosageForm + Quantity + Unit + Frequency + Duration + Instructions + Route + IsFromTemplate + TemplateID
lab_order_data ข้อมูลการสั่ง Lab LabTestName + Urgency + SpecimenType + DoctorID + LabRoom + NotificationRoom + OrderDate + ClinicalInfo
xray_order_data ข้อมูลการสั่ง X-Ray XRayType + Position + Side + RoomCode + PatientCondition + Urgency + ClinicalInfo + ClinicalDiagnosis + Notes
appointment_data ข้อมูลการนัดหมาย AppointmentDate + AppointmentWeeks + AppointmentMonths + DepartmentCode + DoctorCode + Reason + Instructions + IsMultipleDepartments
consultation_data ข้อมูลการปรึกษา ConsultReason + TargetDoctorID + TargetDepartment + UrgencyLevel + ConsultQuestion + ConsultAnswer + ConsultationStatus
refer_data ข้อมูลการส่งต่อ TargetHospital + ReferReason + PrimaryDiagnosis + MainDiagnosis + TreatmentGiven + ReferType + EndDate + ReferPoint
patient_advice_data ข้อมูลคำแนะนำผู้ป่วย AdviceType + AdviceText + MedicationInstructions + LifestyleAdvice + DietInstructions + ExerciseInstructions + ComplicationPrevention
re_med_data ข้อมูลการสั่งยาซ้ำ PreviousMedicationOrderID + MedicationName + PreviousDosage + NewDosage + ModificationReason + DoctorApproval
template_appointment_data ข้อมูลการนัดแบบ Template TemplateID + TemplateName + AppointmentCount + IntervalDays + AppointmentType + AutoGenerate
naranjo_assessment_data ข้อมูลการประเมิน Naranjo Question1 + Question2 + Question3 + Question4 + Question5 + Question6 + Question7 + Question8 + Question9 + Question10 + TotalScore + AssessmentResult
pregnancy_check_data ข้อมูลตรวจสอบการตั้งครรภ์ IsPregnant + IsBreastfeeding + PregnancyWeeks + LastMenstrualPeriod + RiskCategory + PregnancyWarnings
document_template_data ข้อมูล Template เอกสาร TemplateID + DocumentType + LanguageType + TemplateName + TemplateContent + IsActive + Version

8.3 Data Stores

Store Name Description Key Fields Related Entities
D1: HISTORY_TAKING การซักประวัติหลัก HistoryID (PK), VisitID (FK), HN (FK) การซักประวัติ, แพทย์, ผู้ป่วย
D2: VITAL_SIGNS สัญญาณชีพ VitalSignsID (PK), HistoryID (FK) การวัดสัญญาณชีพ, ผู้วัด
D3: DRUG_ALLERGY การแพ้ยา AllergyID (PK), HN (FK) การแพ้ยา, ยา, ผู้ป่วย
D4: MEDICAL_DIAGNOSIS การวินิจฉัยโรค DiagnosisID (PK), HistoryID (FK) การวินิจฉัย, รหัส ICD, แพทย์
D5: MEDICAL_PROCEDURE หัตถการทางการแพทย์ ProcedureID (PK), HistoryID (FK) หัตถการ, ผู้ทำ, เวลา
D6: MEDICATION_ORDER การสั่งจ่ายยา MedicationOrderID (PK), HistoryID (FK) การสั่งยา, ยา, แพทย์
D7: LAB_ORDER การสั่ง Lab LabOrderID (PK), HistoryID (FK) การสั่ง Lab, รายการตรวจ
D8: XRAY_ORDER การสั่ง X-Ray XRayOrderID (PK), HistoryID (FK) การสั่ง X-Ray, รายการตรวจ
D9: APPOINTMENTS การนัดหมาย AppointmentID (PK), HN (FK) การนัดหมาย, แพทย์, แผนก
D10: CONSULTATIONS การขอปรึกษา ConsultationID (PK), HistoryID (FK) การปรึกษา, แพทย์ผู้ส่ง/รับ
D11: PATIENT_REFER การส่งต่อผู้ป่วย ReferID (PK), HistoryID (FK) การส่งต่อ, สถานพยาบาล
D12: PATIENT_ADVICE คำแนะนำผู้ป่วย AdviceID (PK), HistoryID (FK) คำแนะนำ, การดูแลตนเอง
D13: ICD_CODES รหัส ICD ICDCode (PK) รหัสโรค, รหัสหัตถการ
D14: TEMPLATES แม่แบบ TemplateID (PK) Template การซักประวัติ
D15: HOLIDAY_CALENDAR ปฏิทินวันหยุด HolidayDate (PK) วันหยุดราชการ, วันหยุดพิเศษ
D16: APPOINTMENT_TEMPLATES แม่แบบการนัด TemplateID (PK) Template การนัดหมาย
D17: MULTI_DEPT_VISITS การมาหลายแผนก VisitID (PK), DepartmentCode (PK) การมาหลายแผนกในครั้งเดียว
D18: CONSULT_QUESTIONS คำถามการปรึกษา QuestionID (PK), ConsultationID (FK) คำถามการปรึกษา
D19: CONSULT_ANSWERS คำตอบการปรึกษา AnswerID (PK), ConsultationID (FK) คำตอบการปรึกษา
D20: URGENCY_LEVELS ระดับความเร่งด่วน UrgencyCode (PK) เกณฑ์ความเร่งด่วน
D21: DOCUMENT_TEMPLATES แม่แบบเอกสาร TemplateID (PK) Template เอกสารต่างๆ
D22: PRINT_LOGS บันทึกการพิมพ์ LogID (PK) การพิมพ์เอกสาร, ผู้พิมพ์
D23: BUSINESS_RULES กฎทางธุรกิจ RuleID (PK) กฎการตรวจสอบ, เงื่อนไข
D24: CALCULATION_FORMULAS สูตรคำนวณ FormulaID (PK) สูตร BMI, Dosage, คำนวณต่างๆ
D25: VALIDATION_PATTERNS รูปแบบการตรวจสอบ PatternID (PK) Pattern สำหรับ validation
D26: NARANJO_ASSESSMENTS การประเมิน Naranjo AssessmentID (PK), AllergyID (FK) คำถาม/คำตอบ Naranjo Algorithm
D27: PREGNANCY_RISK_DRUGS ยาเสี่ยงสำหรับหญิงตั้งครรภ์ DrugCode (PK) ยาที่ห้ามใช้กับหญิงตั้งครรภ์
D28: RE_MED_HISTORY ประวัติการสั่งยาซ้ำ ReMedID (PK), OriginalOrderID (FK) การสั่งยาซ้ำ, การปรับเปลี่ยน
D29: DETAILED_FORMS แบบฟอร์มละเอียด FormID (PK), HistoryID (FK) แบบฟอร์มการซักประวัติละเอียด
D30: BLOOD_PRESSURE_RECHECK การวัด BP ซ้ำ RecheckID (PK), VitalSignsID (FK) การนั่งพักวัด BP ซ้ำ

9. API Integration Flow

9.1 การเชื่อมต่อกับระบบเภสัชกรรม (Drug Interaction & Allergy Check)

sequenceDiagram
    participant H as History System
    participant P as Pharmacy System
    participant A as Allergy Database
    participant D as Drug Database

    H->>P: 1. Send medication order<br/>(DrugCode, Dosage, PatientHN)
    P->>A: 2. Check patient allergy history<br/>(PatientHN)
    A-->>P: 3. Return allergy data<br/>(AllergyList, Severity)
    P->>D: 4. Check drug interactions<br/>(DrugList in current order)
    D-->>P: 5. Return interaction warnings<br/>(InteractionLevel, Description)
    P->>P: 6. Process business rules<br/>(Dosage validation, Contraindications)

    alt Allergy or Interaction Found
        P-->>H: 7a. Return warnings<br/>(AllergyAlert, InteractionAlert)
        H->>H: 8a. Display warnings to doctor
        H->>P: 9a. Confirm or modify order
    else No Issues
        P-->>H: 7b. Order approved<br/>(OrderStatus: APPROVED)
    end

    P->>P: 10. Log medication order
    P-->>H: 11. Return final status<br/>(OrderID, Status, Warnings)

9.2 การส่งข้อมูลไปยังระบบ Lab และ X-Ray

sequenceDiagram
    participant H as History System
    participant L as Lab System
    participant X as X-Ray System
    participant N as Notification System

    H->>L: 1. Send lab order<br/>(TestCodes, Urgency, PatientHN)
    L->>L: 2. Validate test codes<br/>and patient eligibility
    L-->>H: 3. Return order confirmation<br/>(LabOrderID, ScheduledTime)

    H->>X: 4. Send X-Ray order<br/>(XRayType, Position, Urgency)
    X->>X: 5. Check equipment availability<br/>and schedule
    X-->>H: 6. Return order confirmation<br/>(XRayOrderID, ScheduledTime)

    L->>N: 7. Notify when results ready<br/>(LabOrderID, ResultStatus)
    X->>N: 8. Notify when images ready<br/>(XRayOrderID, ImageStatus)
    N-->>H: 9. Forward notifications<br/>(ResultNotification)

    H->>L: 10. Request lab results<br/>(LabOrderID)
    L-->>H: 11. Return results<br/>(TestResults, InterpretationFlags)

    H->>X: 12. Request X-Ray results<br/>(XRayOrderID)
    X-->>H: 13. Return images & reports<br/>(ImageURL, RadiologyReport)

9.3 การซิงค์ข้อมูลกับระบบการเงิน

sequenceDiagram
    participant H as History System
    participant F as Finance System
    participant R as Rights System
    participant B as Billing Engine

    H->>R: 1. Validate patient rights<br/>(PatientHN, ServiceCodes)
    R-->>H: 2. Return coverage info<br/>(CoverageType, CopayAmount)

    H->>F: 3. Send billing data<br/>(ServiceCodes, Procedures, Medications)
    F->>B: 4. Calculate charges<br/>(ServiceRates, PatientType)
    B-->>F: 5. Return calculated amounts<br/>(TotalCharge, PatientPay, InsurancePay)

    F->>F: 6. Create billing record<br/>(VisitID, ChargeBreakdown)
    F-->>H: 7. Return billing confirmation<br/>(BillID, PaymentStatus)

    loop Real-time Updates
        H->>F: 8. Send additional services<br/>(NewServiceCodes)
        F->>B: 9. Update charges
        B-->>F: 10. Return updated amounts
        F-->>H: 11. Billing update confirmation
    end

    F->>F: 12. Generate receipt/invoice
    F-->>H: 13. Receipt ready notification

9.4 การเชื่อมต่อกับระบบเวชระเบียนหลัก

sequenceDiagram
    participant H as History System
    participant M as Medical Record System
    participant Q as Queue System
    participant V as Visit Management

    M->>H: 1. Patient visit initiated<br/>(VisitID, PatientHN, QueueNumber)
    H->>M: 2. Request patient data<br/>(PatientHN, DataTypes)
    M-->>H: 3. Return patient info<br/>(Demographics, PreviousVisits, Allergies)

    H->>H: 4. Conduct history taking<br/>(CC, HPI, Physical Exam)
    H->>M: 5. Save history data<br/>(HistoryID, CompletedSections)
    M-->>H: 6. Confirm data saved<br/>(SaveStatus, Timestamp)

    H->>Q: 7. Update queue status<br/>(QueueNumber, Status: IN_PROGRESS)
    Q-->>H: 8. Queue updated<br/>(NewStatus, EstimatedTime)

    H->>V: 9. Complete visit section<br/>(VisitID, SectionType: HISTORY)
    V->>V: 10. Check visit completeness
    V-->>H: 11. Visit section confirmed<br/>(CompletionStatus)

    alt Visit Complete
        H->>M: 12a. Finalize visit record<br/>(VisitID, FinalDiagnosis)
        M->>Q: 13a. Clear from queue<br/>(QueueNumber)
    else More Sections Needed
        H->>M: 12b. Save partial visit<br/>(VisitID, PartialData)
        M->>Q: 13b. Update queue status<br/>(Status: PENDING_NEXT_SECTION)
    end

10. การจัดการข้อผิดพลาดและ Fallback

10.1 Error Handling Matrix

Error Type System Impact Fallback Strategy Manual Process Recovery Time
Pharmacy System Down Drug interaction check fails Use local drug database cache Manual drug review by pharmacist 2-4 hours
Lab System Unavailable Cannot send lab orders Queue orders for later transmission Paper-based lab requisitions 1-2 hours
X-Ray System Down Cannot schedule X-Ray Manual scheduling system Phone coordination with radiology 30 minutes
Finance System Error Billing calculation fails Use standard rates, calculate later Manual billing verification 4-6 hours
Database Connection Lost Core functions stop Use read-only replica database Paper documentation temporarily 5-10 minutes
ICD Lookup Service Down Cannot validate diagnosis codes Use cached ICD codes Manual ICD code verification 1 hour
Template Service Error Cannot load templates Use default templates Manual template creation 15 minutes
Print Service Failure Cannot print documents Queue print jobs Handwritten documents 30 minutes
Naranjo Service Down Cannot calculate allergy score Manual Naranjo calculation Paper-based assessment 1 hour
Drug Allergy Check Failed Cannot verify allergies Display warning, require confirmation Manual allergy review Immediate
Pregnancy Check Failed Cannot verify pregnancy status Require manual confirmation Ask patient directly Immediate
Holiday Calendar Error Cannot check appointment conflicts Use static holiday list Manual calendar check 15 minutes
RE-MED Service Down Cannot load previous medications Manual entry required Review paper records 30 minutes
Template Appointment Failed Cannot create multiple appointments Create appointments one by one Manual scheduling 1 hour
Auto-fill Service Error Cannot populate forms automatically Manual data entry Handwritten forms Immediate
Language Service Down Cannot switch languages Use default language (Thai) Manual translation 2 hours
Document Template Error Cannot generate specific documents Use generic templates Manual document creation 30 minutes
Audit Log Service Down Cannot record activities Queue audit logs Manual activity log 1 hour
Notification Service Failed Cannot send alerts Manual notification Phone/verbal communication Immediate
Integration API Down Cannot sync with external systems Store data locally, sync later Manual data transfer 2-6 hours

10.2 Data Integrity Checks

graph TD
    START["🔄 Start Data Integrity Check"]
    CHECK1["📋 Validate Required Fields<br/>CC, HPI, Vital Signs"]
    CHECK2["💊 Cross-check Drug Allergies<br/>Against Medication Orders"]
    CHECK3["🔍 Verify ICD Code Mappings<br/>WHO vs Thai Codes"]
    CHECK4["📅 Validate Appointment Dates<br/>Against Holiday Calendar"]
    CHECK5["⚖️ Check Business Rules<br/>Age restrictions, Dosage limits"]

    ERROR1["❌ Missing Required Data"]
    ERROR2["⚠️ Drug Allergy Conflict"]
    ERROR3["🔧 ICD Mapping Issue"]
    ERROR4["📆 Holiday Conflict"]
    ERROR5["⚖️ Business Rule Violation"]

    FIX1["✏️ Prompt for Missing Data"]
    FIX2["🚨 Display Allergy Warning"]
    FIX3["🔄 Use Alternative ICD Code"]
    FIX4["📅 Suggest Alternative Date"]
    FIX5["📋 Override with Justification"]

    SUCCESS["✅ Data Integrity Verified"]
    SAVE["💾 Save to Database"]
    AUDIT["📝 Log Audit Trail"]

    START --> CHECK1
    CHECK1 --> CHECK2
    CHECK2 --> CHECK3
    CHECK3 --> CHECK4
    CHECK4 --> CHECK5

    CHECK1 --"Validation Failed"--> ERROR1
    CHECK2 --"Allergy Found"--> ERROR2
    CHECK3 --"Code Mismatch"--> ERROR3
    CHECK4 --"Holiday Conflict"--> ERROR4
    CHECK5 --"Rule Violated"--> ERROR5

    ERROR1 --> FIX1
    ERROR2 --> FIX2
    ERROR3 --> FIX3
    ERROR4 --> FIX4
    ERROR5 --> FIX5

    FIX1 --> CHECK1
    FIX2 --> CHECK2
    FIX3 --> CHECK3
    FIX4 --> CHECK4
    FIX5 --> CHECK5

    CHECK5 --"All Checks Passed"--> SUCCESS
    SUCCESS --> SAVE
    SAVE --> AUDIT

    style START fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
    style SUCCESS fill:#e8f5e8,stroke:#4caf50,stroke-width:2px
    style ERROR1 fill:#ffebee,stroke:#f44336,stroke-width:2px
    style ERROR2 fill:#ffebee,stroke:#f44336,stroke-width:2px
    style ERROR3 fill:#ffebee,stroke:#f44336,stroke-width:2px
    style ERROR4 fill:#ffebee,stroke:#f44336,stroke-width:2px
    style ERROR5 fill:#ffebee,stroke:#f44336,stroke-width:2px
    style AUDIT fill:#fff3e0,stroke:#f57c00,stroke-width:2px

10.3 Business Rules Validation

Rule ID Description Implementation Error Handling
BR001 Chief Complaint ต้องไม่เป็นค่าว่าง Required field validation Prompt user to enter CC
BR002 น้ำหนักและส่วนสูงต้องอยู่ในช่วงที่เหมาะสม Range validation (Weight: 0.5-300kg, Height: 30-250cm) Display valid range message
BR003 BMI คำนวณต้องถูกต้อง Automatic calculation with validation Recalculate if values change
BR004 ยาที่ผู้ป่วยแพ้ห้ามสั่งใช้ Cross-reference with allergy database Block order with warning
BR005 Drug Interaction Level HIGH ต้องได้รับการอนุมัติ Check interaction severity Require doctor confirmation
BR006 หญิงตั้งครรภ์ห้ามใช้ยาเสี่ยง Cross-check pregnancy status with drug safety Display pregnancy warning
BR007 การนัดหมายห้ามตรงกับวันหยุด Check against holiday calendar Suggest alternative dates
BR008 การสั่ง Lab ต้องระบุเหตุผล Required field for lab orders Prompt for clinical indication
BR009 รหัส ICD ต้องถูกต้องตามมาตรฐาน Validate against ICD database Suggest similar codes
BR010 การ Refer ต้องมีการวินิจฉัยเบื้องต้น Check diagnosis before refer Require provisional diagnosis
BR011 Naranjo Score ต้องคำนวณถูกต้อง Validate 10 questions assessment Recalculate score automatically
BR012 การสั่งยาซ้ำ (RE-MED) ต้องมีการอ้างอิง Check previous medication order Display previous order history
BR013 หญิงให้นมบุตรห้ามใช้ยาเสี่ยง Check breastfeeding status Display lactation safety warning
BR014 การนัดแบบ Template ต้องระบุจำนวนครั้ง Validate template parameters Set default values
BR015 อายุผู้ป่วยต้องสอดคล้องกับขนาดยา Age-based dosage validation Suggest pediatric/geriatric doses
BR016 การวัด BP ซ้ำต้องมีช่วงเวลาเหมาะสม Minimum 5-minute interval Display time requirement
BR017 การส่งต่อต้องระบุจุดส่งต่อ Required field validation Prompt for refer point
BR018 รหัส ICD ไทยต้อง Map กับ WHO Cross-validate ICD mapping Display mapping conflicts
BR019 ใบสั่งยาต้องมีลายเซ็นแพทย์ Digital signature validation Require doctor authentication
BR020 การนัดหลายแผนกต้องไม่ซ้ำเวลา Time conflict validation Suggest time alternatives

11. Performance Monitoring และ Optimization

11.1 Performance Metrics

graph LR
    M1["📊 Response Time<br/>Monitoring"]
    M2["📈 Throughput<br/>Measurement"]
    M3["💾 Database<br/>Performance"]
    M4["🔗 API Call<br/>Latency"]
    M5["👥 Concurrent<br/>Users"]

    THRESH1["⏱️ Response Time<br/>< 2 seconds"]
    THRESH2["📊 Throughput<br/>> 100 TPS"]
    THRESH3["🗄️ DB Query<br/>< 500ms"]
    THRESH4["🌐 API Calls<br/>< 1 second"]
    THRESH5["👥 Users<br/>< 200 concurrent"]

    ALERT["🚨 Performance<br/>Alert System"]

    M1 --> THRESH1
    M2 --> THRESH2
    M3 --> THRESH3
    M4 --> THRESH4
    M5 --> THRESH5

    THRESH1 --> ALERT
    THRESH2 --> ALERT
    THRESH3 --> ALERT
    THRESH4 --> ALERT
    THRESH5 --> ALERT

    style M1 fill:#e1f5fe,stroke:#0277bd,stroke-width:2px
    style M2 fill:#e1f5fe,stroke:#0277bd,stroke-width:2px
    style M3 fill:#e1f5fe,stroke:#0277bd,stroke-width:2px
    style M4 fill:#e1f5fe,stroke:#0277bd,stroke-width:2px
    style M5 fill:#e1f5fe,stroke:#0277bd,stroke-width:2px
    style ALERT fill:#ffebee,stroke:#d32f2f,stroke-width:2px

11.2 Database Optimization Strategies

Optimization Area Strategy Implementation
Indexing Create indexes on frequently queried fields HN, VisitID, HistoryDate, ICDCode
Query Optimization Use query execution plans Optimize JOIN operations, avoid N+1 queries
Caching Implement Redis caching Cache ICD codes, drug information, templates
Partitioning Partition large tables by date History_Taking, Vital_Signs by month
Archive Strategy Move old data to archive History > 5 years to archive database
Connection Pooling Use database connection pools Limit concurrent connections

12. Security และ Audit Trail

12.1 Data Access Control

graph TD
    USER["👤 User Login"]
    AUTH["🔐 Authentication<br/>Username/Password"]
    ROLE["👨‍⚕️ Role Assignment<br/>Doctor/Nurse/Admin"]
    PERM["🔑 Permission Check<br/>Resource Access"]

    HIST_READ["📖 Read History Data"]
    HIST_WRITE["✏️ Write History Data"]
    DIAG_WRITE["🩺 Write Diagnosis"]
    MED_ORDER["💊 Order Medications"]
    PRINT_DOC["🖨️ Print Documents"]

    AUDIT["📝 Audit Logging"]

    USER --> AUTH
    AUTH --> ROLE
    ROLE --> PERM

    PERM --> HIST_READ
    PERM --> HIST_WRITE
    PERM --> DIAG_WRITE
    PERM --> MED_ORDER
    PERM --> PRINT_DOC

    HIST_READ --> AUDIT
    HIST_WRITE --> AUDIT
    DIAG_WRITE --> AUDIT
    MED_ORDER --> AUDIT
    PRINT_DOC --> AUDIT

    style AUTH fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
    style AUDIT fill:#e8f5e8,stroke:#388e3c,stroke-width:2px

12.2 Audit Trail Requirements

Action Type Logged Information Retention Period
Login/Logout UserID, Timestamp, IP Address 1 year
Patient Access UserID, PatientHN, AccessType, Timestamp 7 years
Data Modification UserID, TableName, RecordID, OldValue, NewValue Permanent
Medication Orders UserID, PatientHN, DrugCode, Timestamp Permanent
Document Printing UserID, DocumentType, PatientHN, Timestamp 3 years
System Errors ErrorCode, Description, UserID, Timestamp 2 years

13. Level 2 DFD - Critical Processes

13.1. Level 2 DFD - Drug Allergy Management (Process 1.3)

graph TD
    %% External Entities
    DOC["👨‍⚕️ แพทย์"]
    PHAR["💊 เจ้าหน้าที่เภสัช"]

    %% External Systems
    PHAR_SYS["💊 ระบบเภสัชกรรม"]

    %% Sub-processes of Process 1.3
    P131["1.3.1<br/>📝<br/>บันทึกข้อมูล<br/>การแพ้ยาเบื้องต้น"]
    P132["1.3.2<br/>🔬<br/>ประเมิน Naranjo<br/>Algorithm"]
    P133["1.3.3<br/>⚠️<br/>ตรวจสอบความ<br/>ร้ายแรง"]
    P134["1.3.4<br/>🚫<br/>กำหนดยาที่<br/>ห้ามสั่งใช้"]
    P135["1.3.5<br/>📋<br/>อัพเดทประวัติ<br/>การแพ้ยา"]

    %% Data Stores
    DS3[("D3<br/>DRUG_ALLERGY<br/>การแพ้ยา")]
    DS26[("D26<br/>NARANJO_ASSESSMENTS<br/>การประเมิน Naranjo")]
    DS23[("D23<br/>BUSINESS_RULES<br/>กฎทางธุรกิจ")]

    %% Process 1.3.1 - บันทึกข้อมูลการแพ้ยาเบื้องต้น
    DOC -->|"ข้อมูลการแพ้ยา<br/>ชื่อยา, อาการ, วันที่"| P131
    PHAR -->|"ตรวจสอบข้อมูลยา<br/>ชื่อสามัญ, รหัสยา"| P131
    P131 -->|"บันทึกข้อมูลเบื้องต้น<br/>ชื่อยา, อาการ"| DS3
    P131 -->|"ส่งข้อมูลเพื่อประเมิน"| P132

    %% Process 1.3.2 - ประเมิน Naranjo Algorithm
    P132 -->|"คำถาม Naranjo<br/>10 ข้อ"| DOC
    DOC -->|"คำตอบประเมิน<br/>Naranjo"| P132
    P132 -->|"บันทึกการประเมิน<br/>คำถาม/คำตอบ"| DS26
    P132 -->|"คำนวณคะแนน<br/>Naranjo Score"| P133
    DS26 -->|"ข้อมูลการประเมิน<br/>ก่อนหน้า"| P132

    %% Process 1.3.3 - ตรวจสอบความร้ายแรง
    P133 -->|"ประเมินความร้ายแรง<br/>MILD/MODERATE/SEVERE"| P134
    DS23 -->|"เกณฑ์การจัดกลุ่ม<br/>ความร้ายแรง"| P133
    P133 -->|"อัพเดท Severity<br/>และ Naranjo Result"| DS3

    %% Process 1.3.4 - กำหนดยาที่ห้ามสั่งใช้
    P134 -->|"กำหนดสถานะ<br/>ห้ามสั่งใช้"| DS3
    P134 -->|"ส่งข้อมูลยาที่แพ้<br/>ไปยังระบบเภสัช"| PHAR_SYS
    DS3 -->|"ข้อมูลยาที่แพ้<br/>ปัจจุบัน"| P134

    %% Process 1.3.5 - อัพเดทประวัติการแพ้ยา
    P135 -->|"อัพเดทประวัติ<br/>การแพ้ยาสมบูรณ์"| DS3
    P135 -->|"แจ้งเตือนการแพ้ยา<br/>ใหม่"| DOC
    P135 -->|"ส่งข้อมูลอัพเดท<br/>ไปยังระบบอื่น"| PHAR_SYS
    DS3 -->|"ข้อมูลการแพ้ยา<br/>ที่บันทึกแล้ว"| P135

    %% Data flows between processes
    P133 --> P134
    P134 --> P135

    %% External system integration
    PHAR_SYS -->|"ข้อมูลยาและ<br/>Drug Information"| P131
    PHAR_SYS -->|"Cross-reference<br/>ยาที่แพ้"| P134

    %% Styling
    style P131 fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
    style P132 fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
    style P133 fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
    style P134 fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
    style P135 fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px

    style DS3 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS26 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS23 fill:#e0f2f1,stroke:#00695c,stroke-width:2px

13.2. Level 2 DFD - Medication Ordering with RE-MED (Process 1.5)

graph TD
    %% External Entities
    DOC["👨‍⚕️ แพทย์"]
    PHAR["💊 เจ้าหน้าที่เภสัช"]

    %% External Systems
    PHAR_SYS["💊 ระบบเภสัชกรรม"]

    %% Sub-processes of Process 1.5
    P151["1.5.1<br/>🔄<br/>เลือกวิธีการ<br/>สั่งยา"]
    P152["1.5.2<br/>📋<br/>RE-MED<br/>สั่งยาซ้ำ"]
    P153["1.5.3<br/>📝<br/>สั่งยาใหม่<br/>Manual/Template"]
    P154["1.5.4<br/>⚠️<br/>ตรวจสอบ<br/>Drug Interaction"]
    P155["1.5.5<br/>🚫<br/>ตรวจสอบ<br/>การแพ้ยา"]
    P156["1.5.6<br/>🤰<br/>ตรวจสอบ<br/>หญิงตั้งครรภ์"]
    P157["1.5.7<br/>✅<br/>อนุมัติและ<br/>บันทึกคำสั่ง"]

    %% Data Stores
    DS6[("D6<br/>MEDICATION_ORDER<br/>การสั่งจ่ายยา")]
    DS28[("D28<br/>RE_MED_HISTORY<br/>ประวัติการสั่งยาซ้ำ")]
    DS14[("D14<br/>TEMPLATES<br/>แม่แบบ")]
    DS3[("D3<br/>DRUG_ALLERGY<br/>การแพ้ยา")]
    DS27[("D27<br/>PREGNANCY_RISK_DRUGS<br/>ยาเสี่ยงสำหรับหญิงตั้งครรภ์")]
    DS1[("D1<br/>HISTORY_TAKING<br/>การซักประวัติหลัก")]

    %% Process 1.5.1 - เลือกวิธีการสั่งยา
    DOC -->|"เลือกวิธีการสั่งยา<br/>RE-MED/New/Template"| P151
    P151 -->|"ไปยัง RE-MED"| P152
    P151 -->|"ไปยังการสั่งใหม่"| P153

    %% Process 1.5.2 - RE-MED สั่งยาซ้ำ
    DS6 -->|"ข้อมูลยาเดิม<br/>ของผู้ป่วย"| P152
    DS28 -->|"ประวัติ RE-MED<br/>ก่อนหน้า"| P152
    P152 -->|"เลือกยาเดิม<br/>ปรับแต่งขนาด"| DOC
    DOC -->|"ยืนยันหรือปรับแต่ง<br/>ยาที่เลือก"| P152
    P152 -->|"ข้อมูลยาที่ปรับแต่ง"| P154
    P152 -->|"บันทึก RE-MED<br/>History"| DS28

    %% Process 1.5.3 - สั่งยาใหม่
    DOC -->|"เลือก Template<br/>หรือสั่งใหม่"| P153
    DS14 -->|"Template การใช้ยา<br/>ตามโรค"| P153
    P153 -->|"ข้อมูลยาใหม่<br/>หรือจาก Template"| P154

    %% Process 1.5.4 - ตรวจสอบ Drug Interaction
    P154 -->|"รายการยาทั้งหมด<br/>ในใบสั่ง"| PHAR_SYS
    PHAR_SYS -->|"Drug Interaction<br/>Warning/Alert"| P154
    P154 -->|"แสดงคำเตือน<br/>Drug Interaction"| DOC
    DOC -->|"ยืนยันหรือแก้ไข<br/>รายการยา"| P154
    P154 -->|"ข้อมูลยาที่ผ่าน<br/>การตรวจสอบ"| P155

    %% Process 1.5.5 - ตรวจสอบการแพ้ยา
    DS3 -->|"ข้อมูลการแพ้ยา<br/>ของผู้ป่วย"| P155
    P155 -->|"ตรวจสอบยาแต่ละตัว<br/>กับการแพ้ยา"| P156
    P155 -->|"แสดงคำเตือน<br/>การแพ้ยา"| DOC
    DOC -->|"ยืนยันหรือเปลี่ยน<br/>ยาอื่น"| P155

    %% Process 1.5.6 - ตรวจสอบหญิงตั้งครรภ์
    DS1 -->|"สถานะการตั้งครรภ์<br/>ให้นมบุตร"| P156
    DS27 -->|"รายการยาเสี่ยง<br/>สำหรับหญิงตั้งครรภ์"| P156
    P156 -->|"แสดงคำเตือน<br/>ยาเสี่ยงต่อครรภ์"| DOC
    DOC -->|"ยืนยันหรือเปลี่ยน<br/>ยาที่ปลอดภัย"| P156
    P156 -->|"ข้อมูลยาที่ผ่าน<br/>การตรวจสอบครรภ์"| P157

    %% Process 1.5.7 - อนุมัติและบันทึกคำสั่ง
    P157 -->|"บันทึกคำสั่งยา<br/>สมบูรณ์"| DS6
    P157 -->|"ส่งคำสั่งยา<br/>ไปยังเภสัชกรรม"| PHAR_SYS
    P157 -->|"ยืนยันการสั่งยา<br/>เสร็จสิ้น"| DOC
    PHAR_SYS -->|"ยืนยันการรับ<br/>คำสั่งยา"| P157

    %% Styling
    style P151 fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
    style P152 fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
    style P153 fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
    style P154 fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
    style P155 fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
    style P156 fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
    style P157 fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px

    style DS6 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS28 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS14 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS3 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS27 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS1 fill:#e0f2f1,stroke:#00695c,stroke-width:2px

13.3. Level 2 DFD - Template Appointments (Process 2.6)

graph TD
    %% External Entities
    DOC["👨‍⚕️ แพทย์"]
    PAT["👤 ผู้ป่วย"]

    %% External Systems
    MRS["📋 ระบบเวชระเบียน"]

    %% Sub-processes of Process 2.6
    P261["2.6.1<br/>📋<br/>เลือก Template<br/>การนัดหมาย"]
    P262["2.6.2<br/>⚙️<br/>กำหนดพารามิเตอร์<br/>การนัด"]
    P263["2.6.3<br/>📅<br/>สร้างการนัด<br/>หลายครั้ง"]
    P264["2.6.4<br/>🔍<br/>ตรวจสอบ<br/>วันหยุด"]
    P265["2.6.5<br/>💾<br/>บันทึกและ<br/>แจ้งเตือน"]

    %% Data Stores
    DS16[("D16<br/>APPOINTMENT_TEMPLATES<br/>แม่แบบการนัด")]
    DS9[("D9<br/>APPOINTMENTS<br/>การนัดหมาย")]
    DS15[("D15<br/>HOLIDAY_CALENDAR<br/>ปฏิทินวันหยุด")]
    DS24[("D24<br/>CALCULATION_FORMULAS<br/>สูตรคำนวณ")]

    %% Process 2.6.1 - เลือก Template การนัดหมาย
    DOC -->|"เลือกประเภทการนัด<br/>รับยา/ฉีดยา/ติดตาม"| P261
    DS16 -->|"รายการ Template<br/>การนัดแต่ละประเภท"| P261
    P261 -->|"Template ที่เลือก<br/>พร้อมค่าเริ่มต้น"| P262

    %% Process 2.6.2 - กำหนดพารามิเตอร์การนัด
    DOC -->|"กำหนดพารามิเตอร์<br/>จำนวนครั้ง, ช่วงเวลา"| P262
    P262 -->|"พารามิเตอร์การนัด<br/>ที่กำหนด"| P263
    DS16 -->|"ค่าเริ่มต้นของ<br/>Template"| P262

    %% Process 2.6.3 - สร้างการนัดหลายครั้ง
    DS24 -->|"สูตรคำนวณ<br/>วันที่นัด"| P263
    P263 -->|"คำนวณวันที่นัด<br/>ทุกครั้ง"| P264
    P263 -->|"รายการวันที่นัด<br/>เบื้องต้น"| P264

    %% Process 2.6.4 - ตรวจสอบวันหยุด
    DS15 -->|"ข้อมูลวันหยุด<br/>ทั้งหมด"| P264
    P264 -->|"ตรวจสอบวันที่นัด<br/>แต่ละครั้ง"| P265
    P264 -->|"ปรับวันที่นัด<br/>หลีกเลี่ยงวันหยุด"| P265
    P264 -->|"แจ้งการปรับเปลี่ยน<br/>วันที่นัด"| DOC

    %% Process 2.6.5 - บันทึกและแจ้งเตือน
    P265 -->|"บันทึกการนัด<br/>ทุกครั้ง"| DS9
    P265 -->|"ส่งข้อมูลการนัด<br/>ไปยังระบบหลัก"| MRS
    P265 -->|"แจ้งผลการสร้างการนัด<br/>แบบ Template"| DOC
    P265 -->|"แจ้งการนัดหมาย<br/>ทั้งหมด"| PAT
    DS9 -->|"ตรวจสอบการนัด<br/>ที่มีอยู่แล้ว"| P264

    %% Data flows between processes
    P262 --> P263
    P263 --> P264
    P264 --> P265

    %% Feedback loops
    DOC -->|"อนุมัติการปรับเปลี่ยน<br/>วันที่นัด"| P264
    DOC -->|"ยืนยันการสร้างการนัด<br/>ทั้งหมด"| P265

    %% Styling
    style P261 fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
    style P262 fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
    style P263 fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
    style P264 fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
    style P265 fill:#f3e5f5,stroke:#4a148c,stroke-width:2px

    style DS16 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS9 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS15 fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    style DS24 fill:#e0f2f1,stroke:#00695c,stroke-width:2px

ภาคผนวก

ภาคผนวก A: Notation และ Symbol

Symbol Description
🟦 Process กระบวนการประมวลผลข้อมูล
🟫 External Entity หน่วยงานหรือระบบภายนอก
🗂️ Data Store ที่เก็บข้อมูล
➡️ Data Flow การไหลของข้อมูล
🔄 Bidirectional Flow การไหลของข้อมูลสองทิศทาง
👨‍⚕️ Doctor แพทย์
👩‍⚕️ Nurse พยาบาล
👤 Patient ผู้ป่วย
💊 Pharmacist เจ้าหน้าที่เภสัช
🏥 System ระบบสารสนเทศ

ภาคผนวก B: การอ้างอิงเอกสาร

  • SRS ระบบซักประวัติ v1.0 - Software Requirements Specification
  • TOR ระบบซักประวัติ - Terms of Reference
  • ER Diagram ระบบซักประวัติ - Entity Relationship Diagram
  • Schema ระบบซักประวัติ - Database Schema Design
  • Test Cases ระบบซักประวัติ - Test Case Specifications

ภาคผนวก C: Business Process Mapping

TOR Reference Process Name DFD Process Related Data Stores Level 2 Process
1.2.2.1.1 เชื่อมโยงรหัส ICD หัตถการ 5.0 D13: ICD_CODES -
1.2.2.1.2 บันทึกรหัสโรค ICD 5.0 D13: ICD_CODES -
1.2.2.1.3 กำหนดข้อมูลการรักษา 5.0 D23: BUSINESS_RULES -
1.2.2.2.1 Screen และ Chief Complaint 1.1, 1.2 D1: HISTORY_TAKING, D2: VITAL_SIGNS -
1.2.2.2.2 ใช้ข้อมูล Screen เดิม 1.9 D1: HISTORY_TAKING, D2: VITAL_SIGNS -
1.2.2.2.3 เรียกดูประวัติการตรวจ 1.9 D1: HISTORY_TAKING -
1.2.2.2.4 การแพ้ยา 1.3 D3: DRUG_ALLERGY, D26: NARANJO_ASSESSMENTS 1.3.1-1.3.5
1.2.2.2.5 การสั่งจ่ายยา RE-MED 1.5 D6: MEDICATION_ORDER, D28: RE_MED_HISTORY 1.5.1-1.5.7
1.2.2.2.6 ตรวจสอบ Drug Interaction 1.5 D6: MEDICATION_ORDER, D3: DRUG_ALLERGY 1.5.4, 1.5.5
1.2.2.2.7 การวินิจฉัยโรค 1.4 D4: MEDICAL_DIAGNOSIS, D13: ICD_CODES -
1.2.2.2.8 หัตถการทางการแพทย์ 1.4 D5: MEDICAL_PROCEDURE -
1.2.2.2.9 การสั่ง Lab 1.6 D7: LAB_ORDER -
1.2.2.2.10 การส่งต่อผู้ป่วย (Refer) 1.7 D11: PATIENT_REFER -
1.2.2.2.11 การวัด BP ซ้ำ 1.1 D30: BLOOD_PRESSURE_RECHECK -
1.2.2.2.12 การให้คำแนะนำผู้ป่วย 1.8 D12: PATIENT_ADVICE -
1.2.2.2.13 การสั่ง X-Ray 1.6 D8: XRAY_ORDER -
1.2.2.2.14 แสดงประวัติ X-Ray 1.6 D8: XRAY_ORDER -
1.2.2.3.1 บันทึกนัดหมาย 2.1 D9: APPOINTMENTS -
1.2.2.3.2 นัดหลายแผนก 2.2 D17: MULTI_DEPT_VISITS -
1.2.2.3.3 ตรวจสอบวันหยุด 2.3 D15: HOLIDAY_CALENDAR -
1.2.2.3.4 การสั่งตรวจล่วงหน้า 2.4 D7: LAB_ORDER, D8: XRAY_ORDER -
1.2.2.3.5 ระบุสาเหตุการนัด 2.5 D9: APPOINTMENTS -
1.2.2.3.6 นัดหมายแบบ Template 2.6 D16: APPOINTMENT_TEMPLATES 2.6.1-2.6.5
1.2.2.4.1 ส่งคำขอปรึกษา 3.1 D10: CONSULTATIONS, D18: CONSULT_QUESTIONS -
1.2.2.4.2 บันทึกการ Consult 3.2 D19: CONSULT_ANSWERS -
1.2.2.5.1 พิมพ์ใบรับรองแพทย์ 4.1 D21: DOCUMENT_TEMPLATES 4.0.1-4.0.6
1.2.2.5.2 พิมพ์ตรวจรักษา OPD CARD 4.2 D21: DOCUMENT_TEMPLATES 4.0.1-4.0.6
1.2.2.5.3 พิมพ์ใบสั่งยา 4.3 D21: DOCUMENT_TEMPLATES 4.0.1-4.0.6
1.2.2.5.4 พิมพ์ใบส่งต่อรักษา 4.4 D21: DOCUMENT_TEMPLATES 4.0.1-4.0.6
1.2.2.5.5 พิมพ์ใบตอบกลับ Refer 4.5 D21: DOCUMENT_TEMPLATES 4.0.1-4.0.6
1.2.2.5.6 พิมพ์ใบนัดหมาย 4.6 D21: DOCUMENT_TEMPLATES 4.0.1-4.0.6
Paper Output แบบฟอร์มละเอียด 4.7.1 D29: DETAILED_FORMS 4.7.1
Paper Output คำแนะนำการใช้ยา 4.7.2 D12: PATIENT_ADVICE 4.7.2
Paper Output แบบฟอร์มตรวจร่างกาย 4.7.3 D2: VITAL_SIGNS 4.7.3

ภาคผนวก D: API Endpoints Mapping

External System API Endpoint Data Exchange Integration Type
ระบบเวชระเบียน /api/patient/{hn} Patient Demographics Real-time
ระบบเภสัชกรรม /api/drug/interaction Drug Interaction Check Real-time
ระบบงานชันสูตร /api/lab/order Lab Order Submission Asynchronous
ระบบรังสีวิทยา /api/xray/order X-Ray Order Submission Asynchronous
ระบบการเงิน /api/billing/calculate Billing Calculation Near Real-time
ระบบตรวจสอบสิทธิ /api/rights/validate Rights Verification Real-time

ภาคผนวก E: Version History

Version Date Changes Author
1.0 07/10/2568 Initial version based on TOR and SRS System Analyst
1.1 07/10/2568 Added detailed Level 1 DFDs for all processes System Analyst
1.2 07/10/2568 Added API integration flows and error handling System Analyst
1.3 07/10/2568 Added performance monitoring and security sections System Analyst

ภาคผนวก F: Glossary

Term Thai Definition
CC อาการสำคัญ Chief Complaint - อาการหลักที่ผู้ป่วยมาร้องเรียน
HPI ประวัติการเจ็บป่วยปัจจุบัน History of Present Illness
PMH ประวัติการเจ็บป่วยในอดีต Past Medical History
FH ประวัติครอบครัว Family History
SH ประวัติสังคม Social History
BMI ดัชนีมวลกาย Body Mass Index
BP ความดันโลหิต Blood Pressure
RE-MED การสั่งยาซ้ำ Re-medication
ICD รหัสการจำแนกโรคสากล International Classification of Diseases
DRG กลุ่มวินิจฉัยที่เกี่ยวข้อง Diagnosis Related Group

หมายเหตุ: เอกสาร Data Flow Diagram นี้จัดทำขึ้นให้สอดคล้องกับ TOR และ SRS ระบบซักประวัติ และจะมีการปรับปรุงตามการเปลี่ยนแปลงของความต้องการและการพัฒนาระบบ

ผู้จัดทำ: ทีมพัฒนาระบบ HIS โรงพยาบาลค่ายธนรัชน์
วันที่จัดทำ: 7 ตุลาคม 2568
สถานะ: รออนุมัติ
การอนุมัติ: ผู้อำนวยการโรงพยาบาลค่ายธนรัชน์