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

Data Flow Diagram (DFD)

ระบบผู้ดูแลระบบ (System Administrator Management System)

เวอร์ชัน: 1.0 (ใหม่ - เน้น User Management ตามแนวทาง AWS IAM)

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

สอดคล้องกับ: SRS ระบบผู้ดูแลระบบ v1.0, TOR ระบบผู้ดูแลระบบ, Detail TOR


สารบัญ

  1. ภาพรวมระบบ
  2. Context Diagram
  3. Level 0 DFD
  4. Level 1 DFD - Identity and Access Management (IAM)
  5. Level 1 DFD - System Configuration
  6. Level 1 DFD - Communication & Monitoring
  7. Level 1 DFD - Reporting & Analytics
  8. Data Dictionary
  9. API Integration Flow

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

ระบบผู้ดูแลระบบทำหน้าที่เป็น Central Control System ที่จัดการและควบคุมการทำงานของระบบ HIS ทั้งหมด โดยมีการไหลของข้อมูลหลักดังนี้:

  • Input: การจัดการผู้ใช้งาน, การตั้งค่าระบบ, การกำหนดสิทธิ์, การสื่อสาร
  • Processing: การยืนยันตัวตน, การควบคุมการเข้าถึง, การจัดการข้อมูลพื้นฐาน, การตรวจสอบระบบ
  • Output: รายงานการใช้งาน, การแจ้งเตือน, ข้อมูลการตรวจสอบ, การกำหนดค่า
  • Integration: เชื่อมต่อกับระบบ HIS ทั้งหมดผ่าน IAM และ Configuration APIs

หลักการออกแบบ: ใช้แนวทาง AWS IAM (Identity and Access Management) เป็นฐานในการออกแบบ DFD เพื่อให้ระบบมีความปลอดภัยและสามารถจัดการสิทธิ์ได้อย่างละเอียดและยืดหยุ่น


2. Context Diagram

graph TD
    %% External Entities - Administrative Users
    SUPER["👑 Super Administrator<br/>(ผู้ดูแลระบบระดับสูงสุด)"]
    SYS_ADMIN["🔧 System Administrator<br/>(ผู้ดูแลระบบทั่วไป)"]
    DEPT_ADMIN["🏢 Department Administrator<br/>(ผู้ดูแลระบบระดับแผนก)"]
    SEC_ADMIN["🛡️ Security Administrator<br/>(ผู้ดูแลระบบด้านความปลอดภัย)"]

    %% External Entities - End Users
    ALL_USERS["👥 ผู้ใช้งานทั้งหมด<br/>(แพทย์, พยาบาล, เจ้าหน้าที่)"]

    %% Central System
    ADMIN_SYS["🎛️ ระบบผู้ดูแลระบบ<br/>(System Admin Management)<br/>IAM-Based Architecture"]

    %% External Systems - All HIS Modules
    MED_REC["📋 ระบบเวชระเบียน<br/>(1.2.1)"]
    HISTORY["📝 ระบบซักประวัติ<br/>(1.2.2)"]
    EXAM["🏥 ระบบห้องตรวจแพทย์<br/>(1.2.3)"]
    EMERGENCY["🚨 ระบบห้องฉุกเฉิน<br/>(1.2.4)"]
    DENTAL["🦷 ระบบทันตกรรม<br/>(1.2.5)"]
    APPOINTMENT["📅 ระบบนัดหมายและตารางเวรแพทย์<br/>(1.2.6)"]
    AUTOPSY["🔬 ระบบงานชันสูตร<br/>(1.2.7)"]
    RADIOLOGY["📡 ระบบรังสีวิทยา<br/>(1.2.8)"]
    SPECIAL["⭐ ระบบคลินิกพิเศษ<br/>(1.2.9)"]
    TRADITIONAL["🌿 ระบบแพทย์แผนไทย<br/>(1.2.10)"]
    HEALTH_PROMO["💪 ระบบงานส่งเสริมสุขภาพ<br/>(1.2.11)"]
    REHAB["♿ ระบบเวชศาสตร์ฟื้นฟู<br/>(1.2.12)"]
    PHARMACY["💊 ระบบเภสัชกรรม<br/>(1.2.13)"]
    FINANCE["💰 ระบบการเงิน<br/>(1.2.14)"]
    INSURANCE["💳 ระบบตรวจสอบสิทธิ<br/>(1.2.15)"]
    ADMISSION["🏨 ระบบ Admission Center<br/>(1.2.16)"]
    INPATIENT["🛏️ ระบบผู้ป่วยใน<br/>(1.2.17)"]
    OPERATING["⚔️ ระบบห้องผ่าตัด และวิสัญญี<br/>(1.2.18)"]
    DELIVERY["👶 ระบบห้องคลอด<br/>(1.2.19)"]
    NUTRITION["🍎 ระบบโภชนาการ<br/>(1.2.20)"]
    BLOOD_BANK["🩸 ระบบงานคลังโลหิต<br/>(1.2.22)"]
    HEALTH_CHECK["🔍 ระบบงานตรวจสุขภาพ<br/>(1.2.23)"]
    DATA_EXPORT["📤 การส่งออกข้อมูล<br/>(1.2.24)"]

    %% External Systems - Infrastructure
    DATABASE["🗄️ MySQL/PostgreSQL<br/>Database Server"]
    EMAIL_SYS["📧 Email Server<br/>(SMTP)"]
    SMS_SYS["📱 SMS Gateway"]
    LDAP_AD["🔐 LDAP/Active Directory<br/>(External Authentication)"]
    BACKUP_SYS["💾 Backup System<br/>(NAS/Cloud Storage)"]
    MONITOR_SYS["📊 Monitoring System<br/>(System Health)"]

    %% Data Flows - Administrative Actions
    SUPER -->|"ข้อมูลการจัดการผู้ดูแลระบบ<br/>การอนุมัติการเปลี่ยนแปลงสำคัญ<br/>การตั้งค่าความปลอดภัยระดับสูง"| ADMIN_SYS
    SYS_ADMIN -->|"ข้อมูลการจัดการผู้ใช้งานและสิทธิ์<br/>การตั้งค่าระบบและการกำหนดค่า<br/>การจัดการรายงานและเทมเพลต"| ADMIN_SYS
    DEPT_ADMIN -->|"ข้อมูลการจัดการผู้ใช้งานในแผนก<br/>การตั้งค่าข้อมูลและรายงานของแผนก"| ADMIN_SYS
    SEC_ADMIN -->|"ข้อมูลการตรวจสอบ Audit Logs<br/>การจัดการเหตุการณ์ความปลอดภัย<br/>การกำหนดนโยบายความปลอดภัย"| ADMIN_SYS

    %% Data Flows - User Interactions
    ALL_USERS -->|"คำขอการเข้าใช้งาน (Authentication)<br/>การเปลี่ยนแปลงข้อมูลส่วนตัว<br/>การรับประกาศและการแจ้งเตือน"| ADMIN_SYS

    %% Data Flows - System Outputs to Users
    ADMIN_SYS -->|"การอนุญาต/ปฏิเสธการเข้าถึง<br/>ข้อมูลสิทธิ์และบทบาท<br/>การแจ้งเตือนและประกาศ"| ALL_USERS
    ADMIN_SYS -->|"รายงานการจัดการระบบ<br/>ผลการตั้งค่าและการกำหนดค่า<br/>ข้อมูลการตรวจสอบและ Audit Logs"| SUPER
    ADMIN_SYS -->|"รายงานการใช้งานและสถิติ<br/>ข้อมูลการจัดการผู้ใช้งาน<br/>ผลการกำหนดค่าระบบ"| SYS_ADMIN
    ADMIN_SYS -->|"รายงานกิจกรรมของแผนก<br/>ข้อมูลผู้ใช้งานในแผนก<br/>สถิติการใช้งานของแผนก"| DEPT_ADMIN
    ADMIN_SYS -->|"รายงานความปลอดภัย<br/>ข้อมูล Audit Trail<br/>การแจ้งเตือนเหตุการณ์ความปลอดภัย"| SEC_ADMIN

    %% Data Flows - HIS System Integration (IAM & Configuration)
    ADMIN_SYS <-->|"User Authentication & Authorization<br/>Permission Policies & Role Assignments<br/>Configuration Parameters"| MED_REC
    ADMIN_SYS <-->|"User Access Control<br/>System Settings<br/>Master Data Updates"| HISTORY
    ADMIN_SYS <-->|"Role-Based Access Control<br/>Department-specific Settings<br/>User Session Management"| EXAM
    ADMIN_SYS <-->|"Emergency Access Protocols<br/>Critical System Alerts<br/>Priority User Management"| EMERGENCY
    ADMIN_SYS <-->|"Specialist User Management<br/>Department Configuration<br/>Appointment System Settings"| DENTAL
    ADMIN_SYS <-->|"Schedule Management Access<br/>Doctor Availability Settings<br/>Appointment Policies"| APPOINTMENT
    ADMIN_SYS <-->|"Forensic System Access<br/>Sensitive Data Controls<br/>Legal Compliance Settings"| AUTOPSY
    ADMIN_SYS <-->|"Medical Imaging Access<br/>Equipment Configuration<br/>Quality Control Settings"| RADIOLOGY
    ADMIN_SYS <-->|"Specialty Clinic Management<br/>Custom Workflow Settings<br/>Specialized User Roles"| SPECIAL
    ADMIN_SYS <-->|"Traditional Medicine Access<br/>Cultural Settings<br/>Specialized Practitioner Roles"| TRADITIONAL
    ADMIN_SYS <-->|"Health Promotion Settings<br/>Community Access Controls<br/>Prevention Program Management"| HEALTH_PROMO
    ADMIN_SYS <-->|"Rehabilitation Access<br/>Therapy Settings<br/>Progress Tracking Configuration"| REHAB
    ADMIN_SYS <-->|"Pharmacy User Management<br/>Drug Database Updates<br/>Prescription Controls"| PHARMACY
    ADMIN_SYS <-->|"Financial System Access<br/>Billing Configuration<br/>Payment Processing Settings"| FINANCE
    ADMIN_SYS <-->|"Insurance Verification Settings<br/>Coverage Database Updates<br/>Eligibility Check Configuration"| INSURANCE
    ADMIN_SYS <-->|"Admission Process Control<br/>Bed Management Settings<br/>Patient Flow Configuration"| ADMISSION
    ADMIN_SYS <-->|"Inpatient Care Access<br/>Ward Management Settings<br/>Nursing Station Configuration"| INPATIENT
    ADMIN_SYS <-->|"Operating Room Access<br/>Surgical Team Management<br/>Equipment Configuration"| OPERATING
    ADMIN_SYS <-->|"Delivery Room Access<br/>Maternity Care Settings<br/>Newborn Registration Configuration"| DELIVERY
    ADMIN_SYS <-->|"Nutrition Care Access<br/>Dietary Settings<br/>Meal Planning Configuration"| NUTRITION
    ADMIN_SYS <-->|"Blood Bank Access<br/>Transfusion Protocols<br/>Blood Product Management"| BLOOD_BANK
    ADMIN_SYS <-->|"Health Screening Settings<br/>Preventive Care Configuration<br/>Population Health Management"| HEALTH_CHECK
    ADMIN_SYS <-->|"Data Export Permissions<br/>Format Configuration<br/>Transfer Protocols"| DATA_EXPORT

    %% Data Flows - Infrastructure Integration
    ADMIN_SYS <-->|"Database Schema Management<br/>User Privileges & Access Control<br/>Backup/Restore Operations<br/>Performance Monitoring"| DATABASE
    ADMIN_SYS <-->|"Email Notifications<br/>System Alerts<br/>User Communications<br/>Report Distribution"| EMAIL_SYS
    ADMIN_SYS <-->|"SMS Alerts<br/>Emergency Notifications<br/>OTP/MFA Messages<br/>Critical System Messages"| SMS_SYS
    ADMIN_SYS <-->|"External Authentication<br/>User Synchronization<br/>Group Management<br/>Single Sign-On (SSO)"| LDAP_AD
    ADMIN_SYS <-->|"System Backup Configuration<br/>Data Retention Policies<br/>Disaster Recovery Settings<br/>Archive Management"| BACKUP_SYS
    ADMIN_SYS <-->|"System Health Monitoring<br/>Performance Metrics<br/>Alert Configuration<br/>Uptime Tracking"| MONITOR_SYS

    %% Styling for different entity types
    classDef adminUser fill:#e1f5fe,stroke:#01579b,stroke-width:2px
    classDef endUser fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
    classDef centralSys fill:#fff3e0,stroke:#e65100,stroke-width:3px
    classDef hisSys fill:#e8f5e8,stroke:#2e7d32,stroke-width:2px
    classDef infraSys fill:#fff8e1,stroke:#f57f17,stroke-width:2px

    class SUPER,SYS_ADMIN,DEPT_ADMIN,SEC_ADMIN adminUser
    class ALL_USERS endUser
    class ADMIN_SYS centralSys
    class MED_REC,HISTORY,EXAM,EMERGENCY,DENTAL,APPOINTMENT,AUTOPSY,RADIOLOGY,SPECIAL,TRADITIONAL,HEALTH_PROMO,REHAB,PHARMACY,FINANCE,INSURANCE,ADMISSION,INPATIENT,OPERATING,DELIVERY,NUTRITION,BLOOD_BANK,HEALTH_CHECK,DATA_EXPORT hisSys
    class DATABASE,EMAIL_SYS,SMS_SYS,LDAP_AD,BACKUP_SYS,MONITOR_SYS infraSys

3. Level 0 DFD

graph TD
    %% External Entities
    ADMIN_USERS["👑 ผู้ดูแลระบบทุกระดับ<br/>(Super Admin, System Admin,<br/>Dept Admin, Security Admin)"]
    END_USERS["👥 ผู้ใช้งานทั้งหมด<br/>(แพทย์, พยาบาล, เจ้าหน้าที่)"]
    HIS_SYSTEMS["🏥 ระบบ HIS ทั้งหมด<br/>(24 ระบบย่อย)"]
    EXTERNAL_SYS["🌐 ระบบภายนอก<br/>(Database, Email, SMS,<br/>LDAP/AD, Backup, Monitor)"]

    %% Data Stores
    DS1[("D1: Users & Groups<br/>(ผู้ใช้งานและกลุ่ม)")]
    DS2[("D2: Roles & Policies<br/>(บทบาทและนโยบาย)")]
    DS3[("D3: System Configuration<br/>(การตั้งค่าระบบ)")]
    DS4[("D4: Master Data<br/>(ข้อมูลพื้นฐาน)")]
    DS5[("D5: Audit Logs<br/>(บันทึกการตรวจสอบ)")]
    DS6[("D6: Communications<br/>(การสื่อสาร)")]
    DS7[("D7: Reports & Templates<br/>(รายงานและเทมเพลต)")]
    DS8[("D8: Sessions & Tokens<br/>(เซสชันและโทเค็น)")]

    %% Core Processes
    P1["1.0<br/>Identity & Access<br/>Management (IAM)<br/>🔐"]
    P2["2.0<br/>System<br/>Configuration<br/>⚙️"]
    P3["3.0<br/>Communication<br/>& Monitoring<br/>📡"]
    P4["4.0<br/>Reporting<br/>& Analytics<br/>📊"]

    %% Data Flows from External Entities to Processes
    ADMIN_USERS -->|"คำขอจัดการผู้ใช้และสิทธิ์<br/>การตั้งค่าระบบ<br/>การสร้างรายงาน"| P1
    ADMIN_USERS -->|"คำขอการตั้งค่าระบบ<br/>การกำหนดพารามิเตอร์<br/>การจัดการข้อมูลพื้นฐาน"| P2
    ADMIN_USERS -->|"การสร้างประกาศ<br/>การส่งแจ้งเตือน<br/>การตรวจสอบผู้ใช้งาน"| P3
    ADMIN_USERS -->|"คำขอสร้างรายงาน<br/>การออกแบบเทมเพลต<br/>การส่งออกข้อมูล"| P4

    END_USERS -->|"คำขอการล็อกอิน<br/>การเปลี่ยนรหัสผ่าน<br/>การขอสิทธิ์เพิ่มเติม"| P1
    END_USERS -->|"การรับประกาศ<br/>การตอบรับแจ้งเตือน"| P3

    HIS_SYSTEMS -->|"คำขอการยืนยันตัวตน<br/>การตรวจสอบสิทธิ์<br/>คำขอการตั้งค่า"| P1
    HIS_SYSTEMS -->|"คำขอข้อมูลการตั้งค่า<br/>การอัปเดตพารามิเตอร์"| P2
    HIS_SYSTEMS -->|"ข้อมูลการใช้งาน<br/>ข้อมูลประสิทธิภาพ<br/>เหตุการณ์ระบบ"| P3

    EXTERNAL_SYS -->|"ข้อมูลการยืนยันตัวตน<br/>ข้อมูลผู้ใช้จากภายนอก"| P1
    EXTERNAL_SYS -->|"สถานะการสำรองข้อมูล<br/>ข้อมูลการตรวจสอบระบบ"| P2

    %% Data Flows from Processes to External Entities
    P1 -->|"ผลการยืนยันตัวตน<br/>ข้อมูลสิทธิ์และบทบาท<br/>Access Tokens"| END_USERS
    P1 -->|"รายงานการจัดการผู้ใช้<br/>สถิติการใช้งาน<br/>ข้อมูลการเข้าถึง"| ADMIN_USERS
    P1 -->|"การอนุญาต/ปฏิเสธการเข้าถึง<br/>ข้อมูลสิทธิ์ผู้ใช้<br/>Session Management"| HIS_SYSTEMS
    P1 -->|"คำขอการยืนยันตัวตน<br/>การซิงค์ข้อมูลผู้ใช้"| EXTERNAL_SYS

    P2 -->|"ผลการตั้งค่าระบบ<br/>ข้อมูลการกำหนดค่า<br/>สถานะการปรับปรุง"| ADMIN_USERS
    P2 -->|"พารามิเตอร์การทำงาน<br/>ข้อมูลการตั้งค่า<br/>Master Data Updates"| HIS_SYSTEMS
    P2 -->|"คำสั่งการสำรองข้อมูล<br/>การตั้งค่าการตรวจสอบ"| EXTERNAL_SYS

    P3 -->|"ประกาศและข่าวสาร<br/>การแจ้งเตือน<br/>สถานะระบบ"| END_USERS
    P3 -->|"รายงานการติดตาม<br/>ข้อมูลผู้ใช้งานออนไลน์<br/>Audit Reports"| ADMIN_USERS
    P3 -->|"การแจ้งเตือนระบบ<br/>คำสั่งการสื่อสาร"| HIS_SYSTEMS
    P3 -->|"ข้อความ Email/SMS<br/>การแจ้งเตือนภายนอก"| EXTERNAL_SYS

    P4 -->|"รายงานการจัดการ<br/>สถิติการใช้งาน<br/>ข้อมูลวิเคราะห์"| ADMIN_USERS
    P4 -->|"รายงานสำหรับผู้ใช้<br/>ข้อมูลส่วนตัว"| END_USERS
    P4 -->|"รายงานข้อมูลระบบ<br/>เอกสารส่งออก"| HIS_SYSTEMS

    %% Data Flows between Processes and Data Stores
    P1 <--> DS1
    P1 <--> DS2
    P1 <--> DS5
    P1 <--> DS8

    P2 <--> DS3
    P2 <--> DS4
    P2 <--> DS5

    P3 <--> DS5
    P3 <--> DS6
    P3 <--> DS8

    P4 <--> DS1
    P4 <--> DS2
    P4 <--> DS3
    P4 <--> DS4
    P4 <--> DS5
    P4 <--> DS6
    P4 <--> DS7

    %% Inter-process Data Flows
    P1 -.->|"ข้อมูลการยืนยันตัวตน<br/>สิทธิ์การเข้าถึง"| P2
    P1 -.->|"ข้อมูลผู้ใช้งาน<br/>สถานะการล็อกอิน"| P3
    P1 -.->|"ข้อมูลผู้ใช้และสิทธิ์<br/>Audit Trail"| P4

    P2 -.->|"การตั้งค่าความปลอดภัย<br/>พารามิเตอร์ระบบ"| P1
    P2 -.->|"การตั้งค่าการสื่อสาร<br/>พารามิเตอร์การติดตาม"| P3
    P2 -.->|"ข้อมูลการตั้งค่า<br/>Master Data สำหรับรายงาน"| P4

    P3 -.->|"ข้อมูลการตรวจสอบ<br/>เหตุการณ์ความปลอดภัย"| P1
    P3 -.->|"ข้อมูลประสิทธิภาพ<br/>สถานะระบบ"| P2
    P3 -.->|"ข้อมูลการใช้งาน<br/>สถิติการสื่อสาร"| P4

    P4 -.->|"รายงานการใช้งาน<br/>ข้อมูลวิเคราะห์"| P1
    P4 -.->|"รายงานการตั้งค่า<br/>ข้อมูลประสิทธิภาพ"| P2
    P4 -.->|"รายงานการสื่อสาร<br/>สถิติการใช้งาน"| P3

    %% Styling
    classDef process fill:#bbdefb,stroke:#1976d2,stroke-width:2px
    classDef datastore fill:#c8e6c9,stroke:#388e3c,stroke-width:2px
    classDef entity fill:#ffe0b2,stroke:#f57c00,stroke-width:2px

    class P1,P2,P3,P4 process
    class DS1,DS2,DS3,DS4,DS5,DS6,DS7,DS8 datastore
    class ADMIN_USERS,END_USERS,HIS_SYSTEMS,EXTERNAL_SYS entity

4. Level 1 DFD - Identity and Access Management (IAM)

กระบวนการหลัก: การจัดการตัวตนและการเข้าถึง (ตามแนวทาง AWS IAM)

graph TD
    %% External Entities
    ADMIN_USERS["👑 ผู้ดูแลระบบทุกระดับ"]
    END_USERS["👥 ผู้ใช้งานทั้งหมด"]
    HIS_SYSTEMS["🏥 ระบบ HIS ทั้งหมด"]
    LDAP_AD["🔐 LDAP/Active Directory"]

    %% Sub-processes
    P11["1.1<br/>User Management<br/>(การจัดการผู้ใช้งาน)<br/>👤"]
    P12["1.2<br/>Group Management<br/>(การจัดการกลุ่มผู้ใช้)<br/>👥"]
    P13["1.3<br/>Role Management<br/>(การจัดการบทบาท)<br/>🎭"]
    P14["1.4<br/>Policy Management<br/>(การจัดการนโยบาย)<br/>📋"]
    P15["1.5<br/>Authentication<br/>(การยืนยันตัวตน)<br/>🔑"]
    P16["1.6<br/>Authorization<br/>(การอนุญาตการเข้าถึง)<br/>✅"]
    P17["1.7<br/>Session Management<br/>(การจัดการเซสชัน)<br/>⏱️"]
    P18["1.8<br/>MFA & Security<br/>(การยืนยันตัวตนหลายปัจจัย)<br/>🛡️"]

    %% Data Stores
    DS1[("D1: Users & Groups<br/>(ผู้ใช้งานและกลุ่ม)")]
    DS2[("D2: Roles & Policies<br/>(บทบาทและนโยบาย)")]
    DS5[("D5: Audit Logs<br/>(บันทึกการตรวจสอบ)")]
    DS8[("D8: Sessions & Tokens<br/>(เซสชันและโทเค็น)")]
    DS9[("D9: MFA Credentials<br/>(ข้อมูลการยืนยันหลายปัจจัย)")]

    %% Data Flows from External Entities
    ADMIN_USERS -->|"คำขอสร้าง/แก้ไข/ลบผู้ใช้<br/>ข้อมูลผู้ใช้ใหม่<br/>การอัปเดตข้อมูล"| P11
    ADMIN_USERS -->|"คำขอสร้าง/แก้ไขกลุ่ม<br/>การกำหนดสมาชิกกลุ่ม<br/>การจัดลำดับชั้นกลุ่ม"| P12
    ADMIN_USERS -->|"คำขอสร้าง/แก้ไขบทบาท<br/>การกำหนดหน้าที่<br/>การ assume role"| P13
    ADMIN_USERS -->|"คำขอสร้าง/แก้ไขนโยบาย<br/>การกำหนดเงื่อนไขการเข้าถึง<br/>Policy Simulator"| P14
    ADMIN_USERS -->|"การตั้งค่าการยืนยันตัวตน<br/>การกำหนดวิธีการล็อกอิน<br/>การรีเซ็ตรหัสผ่าน"| P15
    ADMIN_USERS -->|"การตั้งค่า MFA<br/>การจัดการ Security Keys<br/>การกำหนดนโยบายความปลอดภัย"| P18

    END_USERS -->|"คำขอล็อกอิน<br/>Username/Password<br/>ข้อมูลการยืนยันตัวตน"| P15
    END_USERS -->|"MFA Tokens<br/>Biometric Data<br/>Security Key Authentication"| P18
    END_USERS -->|"คำขอเปลี่ยนรหัสผ่าน<br/>การอัปเดตข้อมูลส่วนตัว<br/>คำขอสิทธิ์เพิ่มเติม"| P11

    HIS_SYSTEMS -->|"คำขอการยืนยันตัวตน<br/>Access Token Validation<br/>API Authentication"| P15
    HIS_SYSTEMS -->|"คำขอตรวจสอบสิทธิ์<br/>Resource Access Request<br/>Permission Evaluation"| P16
    HIS_SYSTEMS -->|"Session Token Validation<br/>Session Refresh Request<br/>Logout Request"| P17

    LDAP_AD -->|"ข้อมูลผู้ใช้จากภายนอก<br/>Group Membership<br/>Authentication Response"| P15

    %% Data Flows to External Entities
    P11 -->|"ผลการจัดการผู้ใช้<br/>ข้อมูลผู้ใช้ที่อัปเดต<br/>สถานะการดำเนินการ"| ADMIN_USERS
    P12 -->|"ผลการจัดการกลุ่ม<br/>รายชื่อสมาชิกกลุ่ม<br/>โครงสร้างกลุ่ม"| ADMIN_USERS
    P13 -->|"ผลการจัดการบทบาท<br/>การกำหนดสิทธิ์บทบาท<br/>Role Assignment Results"| ADMIN_USERS
    P14 -->|"ผลการจัดการนโยบาย<br/>Policy Evaluation Results<br/>Permission Impact Analysis"| ADMIN_USERS

    P15 -->|"ผลการยืนยันตัวตน<br/>Access Token<br/>Session Information"| END_USERS
    P16 -->|"ผลการตรวจสอบสิทธิ์<br/>Permission Granted/Denied<br/>Access Decision"| END_USERS
    P17 -->|"Session Status<br/>Session Extension<br/>Logout Confirmation"| END_USERS
    P18 -->|"MFA Challenge<br/>Security Verification Result<br/>Additional Security Requirements"| END_USERS

    P15 -->|"Authentication Result<br/>User Identity Information<br/>Session Token"| HIS_SYSTEMS
    P16 -->|"Authorization Decision<br/>User Permissions<br/>Resource Access Rights"| HIS_SYSTEMS
    P17 -->|"Session Validation Result<br/>Session Status<br/>Token Refresh"| HIS_SYSTEMS

    P15 -->|"External Authentication Request<br/>User Synchronization<br/>Directory Queries"| LDAP_AD

    %% Data Flows with Data Stores
    P11 <--> DS1
    P11 --> DS5

    P12 <--> DS1
    P12 --> DS5

    P13 <--> DS2
    P13 --> DS5

    P14 <--> DS2
    P14 --> DS5

    P15 <--> DS1
    P15 <--> DS8
    P15 <--> DS9
    P15 --> DS5

    P16 <--> DS1
    P16 <--> DS2
    P16 <--> DS8
    P16 --> DS5

    P17 <--> DS8
    P17 --> DS5

    P18 <--> DS9
    P18 --> DS5

    %% Inter-process Data Flows
    P11 -.->|"ข้อมูลผู้ใช้<br/>User Profile Updates"| P12
    P11 -.->|"ข้อมูลผู้ใช้<br/>User Attributes"| P13
    P11 -.->|"ข้อมูลผู้ใช้<br/>User Credentials"| P15
    P11 -.->|"ข้อมูลผู้ใช้<br/>MFA Settings"| P18

    P12 -.->|"ข้อมูลกลุ่ม<br/>Group Membership"| P13
    P12 -.->|"ข้อมูลกลุ่ม<br/>Group Policies"| P14
    P12 -.->|"ข้อมูลกลุ่ม<br/>Group Authentication"| P15

    P13 -.->|"ข้อมูลบทบาท<br/>Role Definitions"| P14
    P13 -.->|"ข้อมูลบทบาท<br/>Role Assignments"| P16
    P13 -.->|"ข้อมูลบทบาท<br/>Role-based Sessions"| P17

    P14 -.->|"นโยบายการเข้าถึง<br/>Access Policies"| P16
    P14 -.->|"นโยบายความปลอดภัย<br/>Security Policies"| P18

    P15 -.->|"ข้อมูลการยืนยันตัวตน<br/>Authentication Context"| P16
    P15 -.->|"Session Creation<br/>Initial Session Data"| P17
    P15 -.->|"MFA Requirements<br/>Additional Authentication"| P18

    P16 -.->|"Authorization Result<br/>Access Decisions"| P17

    P17 -.->|"Session Events<br/>User Activity"| P16
    P17 -.->|"Session Security Events<br/>Suspicious Activity"| P18

    P18 -.->|"MFA Results<br/>Security Verification"| P15
    P18 -.->|"Security Decisions<br/>Risk Assessment"| P16

    %% Styling
    classDef process fill:#e3f2fd,stroke:#1565c0,stroke-width:2px
    classDef datastore fill:#e8f5e8,stroke:#2e7d32,stroke-width:2px
    classDef entity fill:#fff3e0,stroke:#e65100,stroke-width:2px

    class P11,P12,P13,P14,P15,P16,P17,P18 process
    class DS1,DS2,DS5,DS8,DS9 datastore
    class ADMIN_USERS,END_USERS,HIS_SYSTEMS,LDAP_AD entity

5. Level 1 DFD - System Configuration

กระบวนการหลัก: การตั้งค่าและจัดการระบบ

graph TD
    %% External Entities
    ADMIN_USERS["👑 ผู้ดูแลระบบทุกระดับ"]
    HIS_SYSTEMS["🏥 ระบบ HIS ทั้งหมด"]
    DATABASE["🗄️ Database Server<br/>(MySQL/PostgreSQL)"]
    BACKUP_SYS["💾 Backup System"]
    MONITOR_SYS["📊 Monitoring System"]

    %% Sub-processes
    P21["2.1<br/>System Settings<br/>(การตั้งค่าระบบ)<br/>⚙️"]
    P22["2.2<br/>HN/VN/AN Configuration<br/>(การตั้งค่าหมายเลข)<br/>🔢"]
    P23["2.3<br/>Database Configuration<br/>(การตั้งค่าฐานข้อมูล)<br/>🗄️"]
    P24["2.4<br/>Master Data Management<br/>(การจัดการข้อมูลพื้นฐาน)<br/>📚"]
    P25["2.5<br/>Backup & Recovery<br/>(การสำรองและกู้คืนข้อมูล)<br/>💾"]
    P26["2.6<br/>Performance Monitoring<br/>(การติดตามประสิทธิภาพ)<br/>📈"]
    P27["2.7<br/>Version & Update Management<br/>(การจัดการเวอร์ชันและอัปเดต)<br/>🔄"]

    %% Data Stores
    DS3[("D3: System Configuration<br/>(การตั้งค่าระบบ)")]
    DS4[("D4: Master Data<br/>(ข้อมูลพื้นฐาน)")]
    DS5[("D5: Audit Logs<br/>(บันทึกการตรวจสอบ)")]
    DS10[("D10: Backup Files<br/>(ไฟล์สำรอง)")]
    DS11[("D11: Performance Metrics<br/>(ข้อมูลประสิทธิภาพ)")]
    DS12[("D12: Version History<br/>(ประวัติเวอร์ชัน)")]

    %% Data Flows from External Entities
    ADMIN_USERS -->|"คำขอตั้งค่าระบบ<br/>ข้อมูลโรงพยาบาล<br/>การตั้งค่าความปลอดภัย"| P21
    ADMIN_USERS -->|"คำขอตั้งค่าหมายเลข<br/>รูปแบบ HN/VN/AN<br/>การรีเซ็ตหมายเลข"| P22
    ADMIN_USERS -->|"คำขอตั้งค่าฐานข้อมูล<br/>Connection String<br/>การจัดการ Schema"| P23
    ADMIN_USERS -->|"คำขอจัดการข้อมูลพื้นฐาน<br/>อัปเดต Master Data<br/>การซิงค์ข้อมูล"| P24
    ADMIN_USERS -->|"คำขอสำรองข้อมูล<br/>การกู้คืนข้อมูล<br/>การตั้งค่าการสำรอง"| P25
    ADMIN_USERS -->|"คำขอรายงานประสิทธิภาพ<br/>การตั้งค่าการติดตาม<br/>การปรับแต่งระบบ"| P26
    ADMIN_USERS -->|"คำขออัปเดตระบบ<br/>การจัดการเวอร์ชัน<br/>การ Rollback"| P27

    HIS_SYSTEMS -->|"คำขอพารามิเตอร์การทำงาน<br/>การตั้งค่าเฉพาะโมดูล<br/>การซิงค์การตั้งค่า"| P21
    HIS_SYSTEMS -->|"คำขอสร้างหมายเลขใหม่<br/>การตรวจสอบรูปแบบ<br/>การขอหมายเลขถัดไป"| P22
    HIS_SYSTEMS -->|"คำขอเชื่อมต่อฐานข้อมูล<br/>การ Execute Query<br/>การจัดการ Transaction"| P23
    HIS_SYSTEMS -->|"คำขอข้อมูลพื้นฐาน<br/>การตรวจสอบข้อมูล<br/>การอัปเดตข้อมูล"| P24
    HIS_SYSTEMS -->|"ข้อมูลประสิทธิภาพ<br/>Log การใช้งาน<br/>ข้อมูลการทำงาน"| P26

    DATABASE -->|"สถานะการเชื่อมต่อ<br/>ข้อมูลประสิทธิภาพ<br/>Log ฐานข้อมูล"| P23
    DATABASE -->|"ข้อมูลจากตาราง<br/>ผลการ Query<br/>ข้อมูลสำรอง"| P24
    DATABASE -->|"ข้อมูลการใช้งาน<br/>Statistics<br/>Performance Metrics"| P26

    BACKUP_SYS -->|"สถานะการสำรอง<br/>ข้อมูลไฟล์สำรอง<br/>ผลการกู้คืน"| P25
    MONITOR_SYS -->|"ข้อมูลการตรวจสอบ<br/>Alert และ Warning<br/>System Health Data"| P26

    %% Data Flows to External Entities
    P21 -->|"ผลการตั้งค่าระบบ<br/>การยืนยันการเปลี่ยนแปลง<br/>ข้อมูลการตั้งค่าปัจจุบัน"| ADMIN_USERS
    P22 -->|"ผลการตั้งค่าหมายเลข<br/>หมายเลขถัดไปที่จะใช้<br/>รายงานการใช้หมายเลข"| ADMIN_USERS
    P23 -->|"ผลการตั้งค่าฐานข้อมูล<br/>สถานะการเชื่อมต่อ<br/>รายงานประสิทธิภาพ DB"| ADMIN_USERS
    P24 -->|"ผลการจัดการข้อมูลพื้นฐาน<br/>รายงานการอัปเดต<br/>สถิติข้อมูล Master"| ADMIN_USERS
    P25 -->|"ผลการสำรองข้อมูล<br/>รายงานการกู้คืน<br/>สถานะไฟล์สำรอง"| ADMIN_USERS
    P26 -->|"รายงานประสิทธิภาพ<br/>การแจ้งเตือนปัญหา<br/>คำแนะนำการปรับแต่ง"| ADMIN_USERS
    P27 -->|"ผลการอัปเดต<br/>รายงานการเปลี่ยนแปลง<br/>ข้อมูลเวอร์ชันใหม่"| ADMIN_USERS

    P21 -->|"พารามิเตอร์การทำงาน<br/>การตั้งค่าระบบ<br/>ข้อมูลการกำหนดค่า"| HIS_SYSTEMS
    P22 -->|"หมายเลขใหม่<br/>การตั้งค่าหมายเลข<br/>รูปแบบการสร้าง"| HIS_SYSTEMS
    P23 -->|"Connection Pool<br/>การเชื่อมต่อฐานข้อมูล<br/>ข้อมูลการตั้งค่า DB"| HIS_SYSTEMS
    P24 -->|"ข้อมูลพื้นฐาน<br/>Master Data Updates<br/>ข้อมูลอ้างอิง"| HIS_SYSTEMS
    P26 -->|"ข้อมูลประสิทธิภาพ<br/>การแจ้งเตือนระบบ<br/>คำแนะนำการปรับแต่ง"| HIS_SYSTEMS
    P27 -->|"การอัปเดตระบบ<br/>ข้อมูลเวอร์ชันใหม่<br/>การเปลี่ยนแปลงระบบ"| HIS_SYSTEMS

    P23 -->|"SQL Commands<br/>Database Operations<br/>Connection Management"| DATABASE
    P24 -->|"Data Insert/Update/Delete<br/>Bulk Data Operations<br/>Data Validation"| DATABASE
    P25 -->|"Backup Commands<br/>Restore Operations<br/>Data Export/Import"| DATABASE
    P26 -->|"Performance Queries<br/>Statistics Collection<br/>Health Checks"| DATABASE

    P25 -->|"Backup Requests<br/>Restore Commands<br/>Archive Operations"| BACKUP_SYS
    P26 -->|"Monitoring Configuration<br/>Alert Settings<br/>Performance Thresholds"| MONITOR_SYS

    %% Data Flows with Data Stores
    P21 <--> DS3
    P21 --> DS5

    P22 <--> DS3
    P22 --> DS5

    P23 <--> DS3
    P23 --> DS5

    P24 <--> DS4
    P24 --> DS5

    P25 <--> DS10
    P25 --> DS5

    P26 <--> DS11
    P26 --> DS5

    P27 <--> DS12
    P27 --> DS5

    %% Inter-process Data Flows
    P21 -.->|"การตั้งค่าระบบ<br/>Configuration Parameters"| P22
    P21 -.->|"การตั้งค่าฐานข้อมูล<br/>Database Settings"| P23
    P21 -.->|"การตั้งค่าการสำรอง<br/>Backup Policies"| P25
    P21 -.->|"การตั้งค่าการติดตาม<br/>Monitoring Settings"| P26

    P22 -.->|"ข้อมูลการใช้หมายเลข<br/>Number Usage Data"| P26

    P23 -.->|"ข้อมูลฐานข้อมูล<br/>Database Status"| P25
    P23 -.->|"ข้อมูลการเชื่อมต่อ<br/>Connection Data"| P26

    P24 -.->|"ข้อมูลพื้นฐาน<br/>Master Data Changes"| P21
    P24 -.->|"ข้อมูลสำหรับสำรอง<br/>Data for Backup"| P25

    P25 -.->|"ข้อมูลการสำรอง<br/>Backup Status"| P26

    P26 -.->|"ข้อมูลประสิทธิภาพ<br/>Performance Data"| P21
    P26 -.->|"แนวโน้มการใช้งาน<br/>Usage Trends"| P27

    P27 -.->|"การเปลี่ยนแปลงระบบ<br/>System Changes"| P21
    P27 -.->|"อัปเดตข้อมูลพื้นฐาน<br/>Master Data Updates"| P24

    %% Styling
    classDef process fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
    classDef datastore fill:#e8f5e8,stroke:#2e7d32,stroke-width:2px
    classDef entity fill:#fff3e0,stroke:#e65100,stroke-width:2px

    class P21,P22,P23,P24,P25,P26,P27 process
    class DS3,DS4,DS5,DS10,DS11,DS12 datastore
    class ADMIN_USERS,HIS_SYSTEMS,DATABASE,BACKUP_SYS,MONITOR_SYS entity

6. Level 1 DFD - Communication & Monitoring

กระบวนการหลัก: การสื่อสารและการติดตามระบบ

graph TD
    %% External Entities
    ADMIN_USERS["👑 ผู้ดูแลระบบทุกระดับ"]
    END_USERS["👥 ผู้ใช้งานทั้งหมด"]
    HIS_SYSTEMS["🏥 ระบบ HIS ทั้งหมด"]
    EMAIL_SYS["📧 Email Server"]
    SMS_SYS["📱 SMS Gateway"]
    MONITOR_SYS["📊 External Monitoring"]

    %% Sub-processes
    P31["3.1<br/>News & Announcements<br/>(การจัดการประกาศข่าว)<br/>📢"]
    P32["3.2<br/>Alert & Notification<br/>(การแจ้งเตือน)<br/>🔔"]
    P33["3.3<br/>User Session Monitoring<br/>(การติดตามผู้ใช้งาน)<br/>👁️"]
    P34["3.4<br/>System Health Monitoring<br/>(การติดตามสุขภาพระบบ)<br/>❤️"]
    P35["3.5<br/>Audit Trail Management<br/>(การจัดการบันทึกตรวจสอบ)<br/>🔍"]
    P36["3.6<br/>Communication Routing<br/>(การจัดเส้นทางการสื่อสาร)<br/>🔀"]
    P37["3.7<br/>Emergency Broadcast<br/>(การแจ้งเตือนฉุกเฉิน)<br/>🚨"]

    %% Data Stores
    DS5[("D5: Audit Logs<br/>(บันทึกการตรวจสอบ)")]
    DS6[("D6: Communications<br/>(การสื่อสาร)")]
    DS8[("D8: Sessions & Tokens<br/>(เซสชันและโทเค็น)")]
    DS11[("D11: Performance Metrics<br/>(ข้อมูลประสิทธิภาพ)")]
    DS13[("D13: News & Announcements<br/>(ข่าวสารและประกาศ)")]
    DS14[("D14: Notification Queue<br/>(คิวการแจ้งเตือน)")]
    DS15[("D15: System Events<br/>(เหตุการณ์ระบบ)")]

    %% Data Flows from External Entities
    ADMIN_USERS -->|"คำขอสร้างประกาศ<br/>เนื้อหาข่าวสาร<br/>การกำหนดกลุ่มเป้าหมาย"| P31
    ADMIN_USERS -->|"คำขอส่งการแจ้งเตือน<br/>การตั้งค่าการแจ้งเตือน<br/>การกำหนดระดับความสำคัญ"| P32
    ADMIN_USERS -->|"คำขอดูผู้ใช้งานออนไลน์<br/>การจัดการ Session<br/>การส่งข้อความหาผู้ใช้"| P33
    ADMIN_USERS -->|"คำขอรายงานสุขภาพระบบ<br/>การตั้งค่าการติดตาม<br/>การกำหนด Threshold"| P34
    ADMIN_USERS -->|"คำขอรายงาน Audit<br/>การค้นหา Log<br/>การวิเคราะห์การใช้งาน"| P35
    ADMIN_USERS -->|"การตั้งค่าการส่งข้อความ<br/>การกำหนดช่องทางการสื่อสาร<br/>การจัดการคิว"| P36
    ADMIN_USERS -->|"การส่งแจ้งเตือนฉุกเฉิน<br/>การแจ้งข้อความสำคัญ<br/>การบรอดแคสต์ทันที"| P37

    END_USERS -->|"การรับข่าวสาร<br/>การตอบรับประกาศ<br/>การแสดงความคิดเห็น"| P31
    END_USERS -->|"การรับการแจ้งเตือน<br/>การตอบรับข้อความ<br/>การตั้งค่าการแจ้งเตือน"| P32
    END_USERS -->|"ข้อมูลการใช้งาน<br/>User Activity<br/>Session Heartbeat"| P33
    END_USERS -->|"การรับแจ้งเตือนฉุกเฉิน<br/>การตอบรับข้อความสำคัญ<br/>การรายงานปัญหา"| P37

    HIS_SYSTEMS -->|"ข้อมูลผู้ใช้งานระบบ<br/>System Events<br/>Performance Data"| P33
    HIS_SYSTEMS -->|"System Health Data<br/>Error Logs<br/>Performance Metrics"| P34
    HIS_SYSTEMS -->|"การใช้งานระบบ<br/>Database Activities<br/>User Actions"| P35
    HIS_SYSTEMS -->|"การขอส่งการแจ้งเตือน<br/>System Alerts<br/>Error Notifications"| P32
    HIS_SYSTEMS -->|"เหตุการณ์ฉุกเฉิน<br/>Critical System Events<br/>Security Incidents"| P37

    EMAIL_SYS -->|"Email Delivery Status<br/>Bounce Messages<br/>Email Queue Status"| P36
    SMS_SYS -->|"SMS Delivery Status<br/>Message Status<br/>Gateway Response"| P36
    MONITOR_SYS -->|"External Monitoring Data<br/>Infrastructure Status<br/>Network Performance"| P34

    %% Data Flows to External Entities
    P31 -->|"ประกาศและข่าวสาร<br/>ข้อมูลอัปเดต<br/>การแจ้งเตือนใหม่"| END_USERS
    P31 -->|"รายงานการเผยแพร่<br/>สถิติการอ่าน<br/>ผลตอบรับ"| ADMIN_USERS

    P32 -->|"การแจ้งเตือน<br/>ข้อความสำคัญ<br/>การเตือนระบบ"| END_USERS
    P32 -->|"รายงานการแจ้งเตือน<br/>สถิติการส่ง<br/>ผลการตอบรับ"| ADMIN_USERS

    P33 -->|"รายชื่อผู้ใช้งานออนไลน์<br/>ข้อมูลการใช้งาน<br/>Session Status"| ADMIN_USERS
    P33 -->|"Session Management<br/>User Status Updates<br/>Activity Notifications"| HIS_SYSTEMS

    P34 -->|"รายงานสุขภาพระบบ<br/>การแจ้งเตือนปัญหา<br/>ข้อมูลประสิทธิภาพ"| ADMIN_USERS
    P34 -->|"System Health Alerts<br/>Performance Warnings<br/>Resource Usage Alerts"| HIS_SYSTEMS

    P35 -->|"รายงาน Audit<br/>ข้อมูลการตรวจสอบ<br/>การวิเคราะห์ความปลอดภัย"| ADMIN_USERS
    P35 -->|"Compliance Reports<br/>Security Audit Results<br/>Usage Analytics"| HIS_SYSTEMS

    P36 -->|"Email Messages<br/>Notification Emails<br/>System Reports"| EMAIL_SYS
    P36 -->|"SMS Messages<br/>Alert SMS<br/>Emergency Notifications"| SMS_SYS

    P37 -->|"ข้อความฉุกเฉิน<br/>การแจ้งเตือนสำคัญ<br/>ข้อมูลเหตุการณ์วิกฤต"| END_USERS
    P37 -->|"รายงานเหตุการณ์ฉุกเฉิน<br/>สถิติการแจ้งเตือน<br/>ผลการตอบสนอง"| ADMIN_USERS
    P37 -->|"Emergency Commands<br/>Critical System Messages<br/>Priority Alerts"| HIS_SYSTEMS

    %% Data Flows with Data Stores
    P31 <--> DS13
    P31 --> DS5
    P31 <--> DS6

    P32 <--> DS14
    P32 --> DS5
    P32 <--> DS6

    P33 <--> DS8
    P33 --> DS5
    P33 <--> DS11

    P34 <--> DS15
    P34 --> DS5
    P34 <--> DS11

    P35 <--> DS5

    P36 <--> DS14
    P36 <--> DS6
    P36 --> DS5

    P37 <--> DS14
    P37 --> DS5
    P37 <--> DS15

    %% Inter-process Data Flows
    P31 -.->|"ประกาศสำคัญ<br/>การแจ้งเตือนข่าวใหม่"| P32
    P31 -.->|"ข้อมูลการเผยแพร่<br/>การติดตามการอ่าน"| P35

    P32 -.->|"คิวการแจ้งเตือน<br/>ข้อความที่รอส่ง"| P36
    P32 -.->|"ข้อมูลการแจ้งเตือน<br/>การตอบรับข้อความ"| P35

    P33 -.->|"ข้อมูลผู้ใช้งาน<br/>Session Activities"| P32
    P33 -.->|"การใช้งานผิดปกติ<br/>Suspicious Activities"| P35
    P33 -.->|"ข้อมูลผู้ใช้งาน<br/>User Load Data"| P34

    P34 -.->|"การแจ้งเตือนระบบ<br/>System Health Alerts"| P32
    P34 -.->|"เหตุการณ์วิกฤต<br/>Critical System Events"| P37
    P34 -.->|"ข้อมูลสุขภาพระบบ<br/>System Performance"| P35

    P35 -.->|"การตรวจพบภัยคุกคาม<br/>Security Incidents"| P37
    P35 -.->|"ข้อมูลการวิเคราะห์<br/>Audit Analytics"| P34

    P36 -.->|"สถานะการส่ง<br/>Delivery Status"| P32
    P36 -.->|"ข้อมูลการส่งข้อความ<br/>Message Delivery Logs"| P35

    P37 -.->|"การแจ้งเตือนฉุกเฉิน<br/>Emergency Broadcasts"| P32
    P37 -.->|"เหตุการณ์ฉุกเฉิน<br/>Emergency Events"| P35
    P37 -.->|"ผลการตอบสนอง<br/>Emergency Response"| P34

    %% Styling
    classDef process fill:#fce4ec,stroke:#c2185b,stroke-width:2px
    classDef datastore fill:#e8f5e8,stroke:#2e7d32,stroke-width:2px
    classDef entity fill:#fff3e0,stroke:#e65100,stroke-width:2px

    class P31,P32,P33,P34,P35,P36,P37 process
    class DS5,DS6,DS8,DS11,DS13,DS14,DS15 datastore
    class ADMIN_USERS,END_USERS,HIS_SYSTEMS,EMAIL_SYS,SMS_SYS,MONITOR_SYS entity

7. Level 1 DFD - Reporting & Analytics

กระบวนการหลัก: การรายงานและการวิเคราะห์ข้อมูล

graph TD
    %% External Entities
    ADMIN_USERS["👑 ผู้ดูแลระบบทุกระดับ"]
    END_USERS["👥 ผู้ใช้งานทั้งหมด"]
    HIS_SYSTEMS["🏥 ระบบ HIS ทั้งหมด"]
    EXTERNAL_APPS["🌐 ระบบภายนอก<br/>(BI Tools, Excel, etc.)"]

    %% Sub-processes
    P41["4.1<br/>Report Designer<br/>(การออกแบบรายงาน)<br/>🎨"]
    P42["4.2<br/>Standard Reports<br/>(รายงานมาตรฐาน)<br/>📋"]
    P43["4.3<br/>Custom Reports<br/>(รายงานกำหนดเอง)<br/>📊"]
    P44["4.4<br/>Data Export<br/>(การส่งออกข้อมูล)<br/>📤"]
    P45["4.5<br/>Analytics Engine<br/>(เครื่องมือวิเคราะห์)<br/>🔍"]
    P46["4.6<br/>Dashboard Management<br/>(การจัดการแดชบอร์ด)<br/>📈"]
    P47["4.7<br/>Report Scheduling<br/>(การกำหนดเวลารายงาน)<br/>⏰"]

    %% Data Stores
    DS1[("D1: Users & Groups<br/>(ผู้ใช้งานและกลุ่ม)")]
    DS2[("D2: Roles & Policies<br/>(บทบาทและนโยบาย)")]
    DS3[("D3: System Configuration<br/>(การตั้งค่าระบบ)")]
    DS4[("D4: Master Data<br/>(ข้อมูลพื้นฐาน)")]
    DS5[("D5: Audit Logs<br/>(บันทึกการตรวจสอบ)")]
    DS6[("D6: Communications<br/>(การสื่อสาร)")]
    DS7[("D7: Reports & Templates<br/>(รายงานและเทมเพลต)")]
    DS11[("D11: Performance Metrics<br/>(ข้อมูลประสิทธิภาพ)")]
    DS16[("D16: Analytics Data<br/>(ข้อมูลวิเคราะห์)")]
    DS17[("D17: Report Cache<br/>(แคชรายงาน)")]

    %% Data Flows from External Entities
    ADMIN_USERS -->|"คำขอสร้างรายงานใหม่<br/>การออกแบบเทมเพลต<br/>การปรับแต่งรายงาน"| P41
    ADMIN_USERS -->|"คำขอรายงานมาตรฐาน<br/>การกำหนดพารามิเตอร์<br/>การเลือกช่วงเวลา"| P42
    ADMIN_USERS -->|"คำขอรายงานเฉพาะ<br/>การกำหนดเงื่อนไข<br/>การเลือกข้อมูล"| P43
    ADMIN_USERS -->|"คำขอส่งออกข้อมูล<br/>การเลือกรูปแบบ<br/>การกำหนดช่วงข้อมูล"| P44
    ADMIN_USERS -->|"คำขอวิเคราะห์ข้อมูล<br/>การสร้างกราฟ<br/>การหาแนวโน้ม"| P45
    ADMIN_USERS -->|"คำขอสร้างแดชบอร์ด<br/>การปรับแต่งหน้าจอ<br/>การตั้งค่าการแสดงผล"| P46
    ADMIN_USERS -->|"คำขอกำหนดเวลารายงาน<br/>การส่งรายงานอัตโนมัติ<br/>การแจ้งเตือนรายงาน"| P47

    END_USERS -->|"คำขอดูรายงาน<br/>การกรองข้อมูล<br/>การส่งออกข้อมูลส่วนตัว"| P42
    END_USERS -->|"คำขอข้อมูลส่วนตัว<br/>รายงานการใช้งาน<br/>ประวัติการเข้าถึง"| P43
    END_USERS -->|"คำขอส่งออกข้อมูล<br/>การดาวน์โหลดรายงาน<br/>การแชร์ข้อมูล"| P44

    HIS_SYSTEMS -->|"ข้อมูลสำหรับรายงาน<br/>สถิติการใช้งาน<br/>ข้อมูลประสิทธิภาพ"| P42
    HIS_SYSTEMS -->|"ข้อมูลเฉพาะระบบ<br/>ข้อมูลธุรกรรม<br/>Log การทำงาน"| P43
    HIS_SYSTEMS -->|"ข้อมูลดิบ<br/>Database Records<br/>ข้อมูลการวิเคราะห์"| P45

    EXTERNAL_APPS -->|"คำขอข้อมูลผ่าน API<br/>การเชื่อมต่อ BI Tools<br/>การส่งข้อมูลไปยังระบบอื่น"| P44

    %% Data Flows to External Entities
    P41 -->|"เทมเพลตรายงานใหม่<br/>การอัปเดตรายงาน<br/>ผลการออกแบบ"| ADMIN_USERS

    P42 -->|"รายงานมาตรฐาน<br/>ข้อมูลสถิติ<br/>รายงานประจำ"| ADMIN_USERS
    P42 -->|"รายงานส่วนตัว<br/>ข้อมูลการใช้งาน<br/>สถิติผู้ใช้"| END_USERS
    P42 -->|"รายงานระบบ<br/>ข้อมูลประสิทธิภาพ<br/>สถิติการทำงาน"| HIS_SYSTEMS

    P43 -->|"รายงานกำหนดเอง<br/>ข้อมูลวิเคราะห์<br/>รายงานเฉพาะด้าน"| ADMIN_USERS
    P43 -->|"รายงานส่วนบุคคล<br/>ข้อมูลเฉพาะผู้ใช้<br/>ประวัติการทำงาน"| END_USERS

    P44 -->|"ไฟล์ส่งออก<br/>ข้อมูลในรูปแบบต่างๆ<br/>การแจ้งเตือนการส่งออก"| ADMIN_USERS
    P44 -->|"ข้อมูลส่วนตัว<br/>ไฟล์ดาวน์โหลด<br/>ข้อมูลที่ส่งออก"| END_USERS
    P44 -->|"API Data Response<br/>Exported Data Files<br/>Integration Data"| EXTERNAL_APPS

    P45 -->|"ผลการวิเคราะห์<br/>แนวโน้มข้อมูล<br/>ข้อมูลเชิงลึก"| ADMIN_USERS
    P45 -->|"ข้อมูลวิเคราะห์ระบบ<br/>คำแนะนำการปรับปรุง<br/>การพยากรณ์"| HIS_SYSTEMS

    P46 -->|"แดชบอร์ดการจัดการ<br/>ข้อมูลสรุป<br/>การแสดงผลแบบ Real-time"| ADMIN_USERS
    P46 -->|"แดชบอร์ดส่วนตัว<br/>ข้อมูลสรุปผู้ใช้<br/>การแสดงผลเฉพาะ"| END_USERS

    P47 -->|"รายงานตามกำหนดเวลา<br/>การแจ้งเตือนรายงาน<br/>ผลการส่งรายงาน"| ADMIN_USERS
    P47 -->|"รายงานประจำ<br/>ข้อมูลตามช่วงเวลา<br/>การแจ้งเตือนอัตโนมัติ"| END_USERS

    %% Data Flows with Data Stores
    P41 <--> DS7
    P41 --> DS5

    P42 <--> DS7
    P42 <--> DS17
    P42 --> DS1
    P42 --> DS3
    P42 --> DS4
    P42 --> DS5
    P42 --> DS11

    P43 <--> DS7
    P43 <--> DS17
    P43 --> DS1
    P43 --> DS2
    P43 --> DS5
    P43 --> DS6

    P44 --> DS1
    P44 --> DS2
    P44 --> DS3
    P44 --> DS4
    P44 --> DS5
    P44 --> DS6
    P44 --> DS7
    P44 --> DS11
    P44 --> DS16

    P45 <--> DS16
    P45 --> DS1
    P45 --> DS5
    P45 --> DS11

    P46 <--> DS7
    P46 <--> DS16
    P46 <--> DS17
    P46 --> DS1
    P46 --> DS11

    P47 <--> DS7
    P47 --> DS5

    %% Inter-process Data Flows
    P41 -.->|"เทมเพลตรายงาน<br/>Report Templates"| P42
    P41 -.->|"เทมเพลตกำหนดเอง<br/>Custom Templates"| P43
    P41 -.->|"รูปแบบการส่งออก<br/>Export Formats"| P44

    P42 -.->|"ข้อมูลรายงาน<br/>Report Data"| P45
    P42 -.->|"ข้อมูลสำหรับแดชบอร์ด<br/>Dashboard Data"| P46
    P42 -.->|"รายงานที่ใช้บ่อย<br/>Frequently Used Reports"| P47

    P43 -.->|"ข้อมูลกำหนดเอง<br/>Custom Data"| P45
    P43 -.->|"รายงานเฉพาะ<br/>Specialized Reports"| P46

    P44 -.->|"ข้อมูลส่งออก<br/>Exported Data"| P45

    P45 -.->|"ผลการวิเคราะห์<br/>Analytics Results"| P42
    P45 -.->|"ข้อมูลเชิงลึก<br/>Insights Data"| P43
    P45 -.->|"ข้อมูลสำหรับแดชบอร์ด<br/>Dashboard Analytics"| P46

    P46 -.->|"ข้อมูลแดชบอร์ด<br/>Dashboard Settings"| P41
    P46 -.->|"การแสดงผลข้อมูล<br/>Data Visualization"| P42

    P47 -.->|"รายงานตามกำหนด<br/>Scheduled Reports"| P42
    P47 -.->|"การส่งรายงาน<br/>Report Distribution"| P44

    %% Styling
    classDef process fill:#e1f5fe,stroke:#0277bd,stroke-width:2px
    classDef datastore fill:#e8f5e8,stroke:#2e7d32,stroke-width:2px
    classDef entity fill:#fff3e0,stroke:#e65100,stroke-width:2px

    class P41,P42,P43,P44,P45,P46,P47 process
    class DS1,DS2,DS3,DS4,DS5,DS6,DS7,DS11,DS16,DS17 datastore
    class ADMIN_USERS,END_USERS,HIS_SYSTEMS,EXTERNAL_APPS entity

8. Data Dictionary

8.1 Data Stores (ที่เก็บข้อมูล)

Data Store ID ชื่อ คำอธิบาย ประเภทข้อมูล ความถี่การอัปเดต
D1 Users & Groups ข้อมูลผู้ใช้งาน กลุ่มผู้ใช้ และการเป็นสมาชิก Master Data ปานกลาง
D2 Roles & Policies ข้อมูลบทบาท นโยบายการเข้าถึง และสิทธิ์ Configuration ต่ำ
D3 System Configuration การตั้งค่าระบบ พารามิเตอร์ และการกำหนดค่า Configuration ต่ำ
D4 Master Data ข้อมูลพื้นฐาน อ้างอิง และข้อมูลมาตรฐาน Master Data ต่ำ
D5 Audit Logs บันทึกการตรวจสอบ ประวัติการใช้งาน และ Security Events Transaction สูงมาก
D6 Communications ข้อความ ประกาศ และการสื่อสารต่างๆ Transaction สูง
D7 Reports & Templates เทมเพลตรายงาน และการตั้งค่ารายงาน Configuration ปานกลาง
D8 Sessions & Tokens เซสชันผู้ใช้งาน Access Tokens และ Authentication Data Temporary สูงมาก
D9 MFA Credentials ข้อมูลการยืนยันตัวตนหลายปัจจัย Security ปานกลาง
D10 Backup Files ไฟล์สำรองข้อมูล และข้อมูลการกู้คืน Archive ต่ำ
D11 Performance Metrics ข้อมูลประสิทธิภาพระบบ และสถิติการใช้งาน Analytics สูง
D12 Version History ประวัติเวอร์ชัน และการเปลี่ยนแปลงระบบ Archive ต่ำ
D13 News & Announcements ข่าวสาร ประกาศ และข้อมูลการเผยแพร่ Content ปานกลาง
D14 Notification Queue คิวการแจ้งเตือน และข้อมูลการส่งข้อความ Queue สูง
D15 System Events เหตุการณ์ระบบ และข้อมูลการติดตาม Transaction สูง
D16 Analytics Data ข้อมูลวิเคราะห์ และผลการประมวลผล Analytics ปานกลาง
D17 Report Cache แคชรายงาน และข้อมูลชั่วคราว Cache สูง

8.2 External Entities (หน่วยงานภายนอก)

Entity คำอธิบาย ประเภท Interface
Super Administrator ผู้ดูแลระบบระดับสูงสุด มีสิทธิ์ทุกอย่าง Human User Web Interface
System Administrator ผู้ดูแลระบบทั่วไป มีสิทธิ์จัดการระบบ Human User Web Interface
Department Administrator ผู้ดูแลระบบระดับแผนก มีสิทธิ์เฉพาะแผนก Human User Web Interface
Security Administrator ผู้ดูแลระบบด้านความปลอดภัย Human User Web Interface
End Users ผู้ใช้งานทั้งหมด (แพทย์, พยาบาล, เจ้าหน้าที่) Human User Web Interface
HIS Systems ระบบ HIS ทั้งหมด 24 ระบบย่อย Software System API/REST
Database Server เซิร์ฟเวอร์ฐานข้อมูล MySQL/PostgreSQL Infrastructure Database API
Email Server เซิร์ฟเวอร์อีเมล SMTP Infrastructure SMTP Protocol
SMS Gateway เกตเวย์ส่ง SMS Infrastructure HTTP API
LDAP/Active Directory ระบบการยืนยันตัวตนภายนอก Software System LDAP Protocol
Backup System ระบบสำรองข้อมูล Infrastructure File System API
Monitoring System ระบบติดตามประสิทธิภาพ Software System SNMP/HTTP API

8.3 Data Elements (องค์ประกอบข้อมูล)

8.3.1 User Management Data

User_Profile:
  user_id: "UUID (Primary Key)"
  username: "String (Unique, 3-50 chars)"
  email: "String (Unique, Email format)"
  display_name: "String (1-100 chars)"
  first_name: "String (1-50 chars)"
  last_name: "String (1-50 chars)"
  phone_number: "String (10-15 chars)"
  employee_id: "String (Unique, 5-20 chars)"
  department_id: "UUID (Foreign Key)"
  position_id: "UUID (Foreign Key)"
  status: "Enum (ACTIVE, INACTIVE, SUSPENDED, LOCKED)"
  created_date: "DateTime"
  modified_date: "DateTime"
  last_login: "DateTime"
  password_hash: "String (Encrypted)"
  password_expiry: "DateTime"
  failed_login_attempts: "Integer (0-99)"
  mfa_enabled: "Boolean"
  mfa_secret: "String (Encrypted)"
  profile_picture: "String (File Path)"
  timezone: "String (Timezone ID)"
  language_preference: "String (Language Code)"

8.3.2 Access Control Data

Role_Definition:
  role_id: "UUID (Primary Key)"
  role_name: "String (Unique, 3-50 chars)"
  role_arn: "String (AWS ARN format)"
  description: "Text (Max 500 chars)"
  trust_policy: "JSON (Trust Relationship)"
  max_session_duration: "Integer (Seconds)"
  permissions_boundary: "String (Policy ARN)"
  created_date: "DateTime"
  modified_date: "DateTime"
  created_by: "UUID (User ID)"

Policy_Document:
  policy_id: "UUID (Primary Key)"
  policy_name: "String (Unique, 3-100 chars)"
  policy_arn: "String (AWS ARN format)"
  policy_type: "Enum (AWS_MANAGED, CUSTOMER_MANAGED, INLINE)"
  policy_document: "JSON (IAM Policy)"
  version: "String (Version Number)"
  description: "Text (Max 1000 chars)"
  created_date: "DateTime"
  modified_date: "DateTime"
  is_default_version: "Boolean"

8.3.3 Session Management Data

User_Session:
  session_id: "UUID (Primary Key)"
  user_id: "UUID (Foreign Key)"
  session_token: "String (JWT Token)"
  refresh_token: "String (Encrypted)"
  ip_address: "String (IP Address)"
  user_agent: "String (Browser Info)"
  login_time: "DateTime"
  last_activity: "DateTime"
  expiry_time: "DateTime"
  is_active: "Boolean"
  device_type: "String (Desktop/Mobile/Tablet)"
  location: "String (Geographic Location)"
  mfa_verified: "Boolean"
  risk_score: "Decimal (0-10)"

8.3.4 Audit Trail Data

Audit_Log:
  log_id: "UUID (Primary Key)"
  timestamp: "DateTime (With Timezone)"
  user_id: "UUID (Foreign Key)"
  session_id: "UUID (Foreign Key)"
  event_type: "String (Event Category)"
  event_name: "String (Specific Event)"
  resource_type: "String (Resource Category)"
  resource_id: "String (Resource Identifier)"
  source_ip: "String (IP Address)"
  user_agent: "String (Browser/App Info)"
  request_id: "UUID (Request Tracking)"
  response_code: "Integer (HTTP/Result Code)"
  error_message: "Text (Error Details)"
  additional_data: "JSON (Extra Information)"
  risk_score: "Decimal (0-10)"
  compliance_flags: "Array[String] (Compliance Tags)"

9. API Integration Flow

9.1 Authentication & Authorization API Flow

sequenceDiagram
    participant HIS as HIS System
    participant IAM as IAM Service
    participant DB as Database
    participant AUDIT as Audit Logger

    Note over HIS,AUDIT: การยืนยันตัวตนและอนุญาตการเข้าถึง

    HIS->>IAM: 1. Authentication Request
    Note right of HIS: {username, password, mfa_token}

    IAM->>DB: 2. Validate User Credentials
    DB-->>IAM: 3. User Data + Status

    alt Valid Credentials
        IAM->>IAM: 4. Generate Access Token
        IAM->>DB: 5. Create User Session
        IAM-->>HIS: 6. Authentication Success
        Note left of IAM: {access_token, refresh_token, user_info}
        IAM->>AUDIT: 7. Log Successful Login
    else Invalid Credentials
        IAM-->>HIS: 6. Authentication Failed
        Note left of IAM: {error, retry_count}
        IAM->>AUDIT: 7. Log Failed Login Attempt
    end

    Note over HIS,AUDIT: การตรวจสอบสิทธิ์การเข้าถึง

    HIS->>IAM: 8. Authorization Request
    Note right of HIS: {access_token, resource, action}

    IAM->>DB: 9. Validate Token & Get User Permissions
    DB-->>IAM: 10. User Roles + Policies

    IAM->>IAM: 11. Evaluate Permissions
    Note over IAM: Policy Engine Processing

    alt Permission Granted
        IAM-->>HIS: 12. Access Granted
        Note left of IAM: {authorized: true, permissions}
    else Permission Denied
        IAM-->>HIS: 12. Access Denied
        Note left of IAM: {authorized: false, reason}
    end

    IAM->>AUDIT: 13. Log Access Decision

9.2 Configuration Management API Flow

sequenceDiagram
    participant ADMIN as Admin User
    participant CONFIG as Config Service
    participant VALID as Validator
    participant DB as Database
    participant HIS as HIS Systems
    participant AUDIT as Audit Logger

    Note over ADMIN,AUDIT: การจัดการการตั้งค่าระบบ

    ADMIN->>CONFIG: 1. Update Configuration Request
    Note right of ADMIN: {config_type, parameters, values}

    CONFIG->>VALID: 2. Validate Configuration
    VALID-->>CONFIG: 3. Validation Result

    alt Valid Configuration
        CONFIG->>DB: 4. Save Configuration
        DB-->>CONFIG: 5. Save Confirmation

        CONFIG->>HIS: 6. Notify Configuration Change
        Note right of CONFIG: Broadcast to affected systems

        HIS-->>CONFIG: 7. Acknowledge Receipt

        CONFIG-->>ADMIN: 8. Configuration Updated
        Note left of CONFIG: {status: success, config_id}

        CONFIG->>AUDIT: 9. Log Configuration Change
    else Invalid Configuration
        CONFIG-->>ADMIN: 8. Configuration Error
        Note left of CONFIG: {status: error, validation_errors}

        CONFIG->>AUDIT: 9. Log Configuration Error
    end

9.3 Communication & Notification API Flow

sequenceDiagram
    participant SENDER as Message Sender
    participant COMM as Communication Service
    participant ROUTE as Message Router
    participant EMAIL as Email Gateway
    participant SMS as SMS Gateway
    participant PUSH as Push Notification
    participant USERS as Target Users
    participant AUDIT as Audit Logger

    Note over SENDER,AUDIT: การส่งข้อความและการแจ้งเตือน

    SENDER->>COMM: 1. Send Message Request
    Note right of SENDER: {message, recipients, channels, priority}

    COMM->>ROUTE: 2. Route Message
    Note right of COMM: Determine delivery channels

    par Email Delivery
        ROUTE->>EMAIL: 3a. Send Email
        EMAIL-->>ROUTE: 4a. Email Status
    and SMS Delivery
        ROUTE->>SMS: 3b. Send SMS
        SMS-->>ROUTE: 4b. SMS Status
    and Push Notification
        ROUTE->>PUSH: 3c. Send Push
        PUSH-->>ROUTE: 4c. Push Status
    end

    ROUTE->>USERS: 5. Deliver Notifications
    USERS-->>ROUTE: 6. Read Receipts (optional)

    ROUTE-->>COMM: 7. Delivery Summary
    COMM-->>SENDER: 8. Message Status Report
    Note left of COMM: {delivered, failed, pending}

    COMM->>AUDIT: 9. Log Communication Event

9.4 Reporting & Analytics API Flow

sequenceDiagram
    participant USER as Report User
    participant REPORT as Report Service
    participant CACHE as Report Cache
    participant DATA as Data Sources
    participant EXPORT as Export Service
    participant STORAGE as File Storage
    participant AUDIT as Audit Logger

    Note over USER,AUDIT: การสร้างและส่งออกรายงาน

    USER->>REPORT: 1. Generate Report Request
    Note right of USER: {report_type, parameters, format}

    REPORT->>CACHE: 2. Check Cache
    alt Report Cached
        CACHE-->>REPORT: 3. Cached Report
    else Report Not Cached
        REPORT->>DATA: 3. Query Data Sources
        DATA-->>REPORT: 4. Raw Data

        REPORT->>REPORT: 5. Process & Format Data

        REPORT->>CACHE: 6. Store in Cache
    end

    alt Real-time View
        REPORT-->>USER: 7. Display Report
        Note left of REPORT: HTML/JSON response
    else Export Request
        REPORT->>EXPORT: 7. Export Report
        Note right of REPORT: {data, format, options}

        EXPORT->>STORAGE: 8. Generate File
        STORAGE-->>EXPORT: 9. File Location

        EXPORT-->>REPORT: 10. Export Complete
        REPORT-->>USER: 11. Download Link
        Note left of REPORT: {download_url, expires_at}
    end

    REPORT->>AUDIT: 12. Log Report Generation

9.5 Error Handling & Recovery Flow

graph TD
    START["API Request Received"]

    VALIDATE{"Input Validation"}
    AUTH{"Authentication Check"}
    AUTHZ{"Authorization Check"}
    PROCESS{"Business Logic Processing"}

    ERROR_HANDLER["Error Handler"]
    LOG_ERROR["Log Error Details"]
    NOTIFY_ADMIN["Notify Administrators"]
    RETURN_ERROR["Return Error Response"]

    SUCCESS["Process Successfully"]
    LOG_SUCCESS["Log Success Event"]
    RETURN_SUCCESS["Return Success Response"]

    START --> VALIDATE
    VALIDATE -->|Invalid| ERROR_HANDLER
    VALIDATE -->|Valid| AUTH

    AUTH -->|Failed| ERROR_HANDLER
    AUTH -->|Success| AUTHZ

    AUTHZ -->|Denied| ERROR_HANDLER
    AUTHZ -->|Granted| PROCESS

    PROCESS -->|Error| ERROR_HANDLER
    PROCESS -->|Success| SUCCESS

    ERROR_HANDLER --> LOG_ERROR
    LOG_ERROR --> NOTIFY_ADMIN
    NOTIFY_ADMIN --> RETURN_ERROR

    SUCCESS --> LOG_SUCCESS
    LOG_SUCCESS --> RETURN_SUCCESS

    %% Styling
    classDef errorPath fill:#ffebee,stroke:#c62828,stroke-width:2px
    classDef successPath fill:#e8f5e8,stroke:#2e7d32,stroke-width:2px
    classDef processPath fill:#e3f2fd,stroke:#1565c0,stroke-width:2px

    class ERROR_HANDLER,LOG_ERROR,NOTIFY_ADMIN,RETURN_ERROR errorPath
    class SUCCESS,LOG_SUCCESS,RETURN_SUCCESS successPath
    class VALIDATE,AUTH,AUTHZ,PROCESS processPath

9.6 API Endpoint Categories

9.6.1 Identity & Access Management APIs

Authentication_APIs:
  - POST /api/v1/auth/login
  - POST /api/v1/auth/logout
  - POST /api/v1/auth/refresh
  - POST /api/v1/auth/mfa/verify
  - POST /api/v1/auth/password/reset

User_Management_APIs:
  - GET /api/v1/users
  - POST /api/v1/users
  - GET /api/v1/users/{id}
  - PUT /api/v1/users/{id}
  - DELETE /api/v1/users/{id}
  - PUT /api/v1/users/{id}/status

Group_Management_APIs:
  - GET /api/v1/groups
  - POST /api/v1/groups
  - GET /api/v1/groups/{id}
  - PUT /api/v1/groups/{id}
  - POST /api/v1/groups/{id}/members
  - DELETE /api/v1/groups/{id}/members/{userId}

Role_Management_APIs:
  - GET /api/v1/roles
  - POST /api/v1/roles
  - GET /api/v1/roles/{id}
  - PUT /api/v1/roles/{id}
  - POST /api/v1/roles/{id}/assign

Policy_Management_APIs:
  - GET /api/v1/policies
  - POST /api/v1/policies
  - GET /api/v1/policies/{id}
  - PUT /api/v1/policies/{id}
  - POST /api/v1/policies/simulate

9.6.2 System Configuration APIs

Configuration_APIs:
  - GET /api/v1/config/system
  - PUT /api/v1/config/system
  - GET /api/v1/config/database
  - PUT /api/v1/config/database
  - GET /api/v1/config/security
  - PUT /api/v1/config/security

Master_Data_APIs:
  - GET /api/v1/masterdata/{category}
  - POST /api/v1/masterdata/{category}
  - PUT /api/v1/masterdata/{category}/{id}
  - DELETE /api/v1/masterdata/{category}/{id}
  - POST /api/v1/masterdata/import
  - GET /api/v1/masterdata/export

Backup_APIs:
  - POST /api/v1/backup/create
  - GET /api/v1/backup/status
  - GET /api/v1/backup/list
  - POST /api/v1/backup/restore
  - DELETE /api/v1/backup/{id}

9.6.3 Communication & Monitoring APIs

Communication_APIs:
  - POST /api/v1/announcements
  - GET /api/v1/announcements
  - PUT /api/v1/announcements/{id}
  - DELETE /api/v1/announcements/{id}
  - POST /api/v1/notifications/send
  - GET /api/v1/notifications/status

Monitoring_APIs:
  - GET /api/v1/sessions/active
  - DELETE /api/v1/sessions/{sessionId}
  - POST /api/v1/sessions/broadcast
  - GET /api/v1/system/health
  - GET /api/v1/system/performance
  - GET /api/v1/audit/logs

Emergency_APIs:
  - POST /api/v1/emergency/broadcast
  - POST /api/v1/emergency/alert
  - GET /api/v1/emergency/status

9.6.4 Reporting & Analytics APIs

Report_APIs:
  - GET /api/v1/reports/templates
  - POST /api/v1/reports/generate
  - GET /api/v1/reports/{reportId}
  - POST /api/v1/reports/schedule
  - GET /api/v1/reports/scheduled

Analytics_APIs:
  - GET /api/v1/analytics/usage
  - GET /api/v1/analytics/performance
  - GET /api/v1/analytics/security
  - POST /api/v1/analytics/custom

Export_APIs:
  - POST /api/v1/export/data
  - GET /api/v1/export/status/{jobId}
  - GET /api/v1/export/download/{fileId}

สรุป

Data Flow Diagram ของระบบผู้ดูแลระบบนี้แสดงให้เห็นถึง:

  1. การไหลของข้อมูลที่ครอบคลุม - ตั้งแต่ระดับ Context จนถึง Level 1 DFD ที่ละเอียด
  2. การออกแบบตามแนวทาง AWS IAM - ใช้หลักการ Identity and Access Management ที่เป็นมาตรฐานสากล
  3. การเชื่อมโยงกับระบบ HIS ทั้งหมด - แสดงการเชื่อมต่อกับระบบย่อย 24 ระบบ
  4. ความปลอดภัยและการตรวจสอบ - มี Audit Trail และ Security Controls ครอบคลุม
  5. ความยืดหยุ่นและขยายได้ - สามารถปรับปรุงและขยายฟังก์ชันได้ตามความต้องการ

DFD นี้สามารถใช้เป็นพื้นฐานในการพัฒนาระบบผู้ดูแลระบบที่มีประสิทธิภาพและปลอดภัยสำหรับโรงพยาบาลค่ายธนรัชน์


10. Detailed API Integration Flow

10.1 การเชื่อมต่อกับระบบ HIS แต่ละระบบ

graph TD
    subgraph "🔗 API Gateway & Authentication"
        GATEWAY[API Gateway]
        AUTH[Authentication Service]
        RATE[Rate Limiter]
        MONITOR[API Monitor]
    end

    subgraph "📋 Medical Systems (1.2.1 - 1.2.12)"
        MED1[ระบบเวชระเบียน<br/>1.2.1]
        MED2[ระบบซักประวัติ<br/>1.2.2]  
        MED3[ระบบห้องตรวจแพทย์<br/>1.2.3]
        MED4[ระบบห้องฉุกเฉิน<br/>1.2.4]
        MED5[ระบบทันตกรรม<br/>1.2.5]
        MED6[ระบบนัดหมาย<br/>1.2.6]
        MED7[ระบบชันสูตร<br/>1.2.7]
        MED8[ระบบรังสี<br/>1.2.8]
        MED9[ระบบคลินิกพิเศษ<br/>1.2.9]
        MED10[ระบบแพทย์แผนไทย<br/>1.2.10]
        MED11[ระบบส่งเสริมสุขภาพ<br/>1.2.11]
        MED12[ระบบเวชศาสตร์ฟื้นฟู<br/>1.2.12]
    end

    subgraph "💊 Support Systems (1.2.13 - 1.2.20)"
        SUP1[ระบบเภสัชกรรม<br/>1.2.13]
        SUP2[ระบบการเงิน<br/>1.2.14]
        SUP3[ระบบตรวจสอบสิทธิ<br/>1.2.15]
        SUP4[ระบบ Admission Center<br/>1.2.16]
        SUP5[ระบบผู้ป่วยใน<br/>1.2.17]
        SUP6[ระบบห้องผ่าตัด<br/>1.2.18]
        SUP7[ระบบห้องคลอด<br/>1.2.19]
        SUP8[ระบบโภชนาการ<br/>1.2.20]
    end

    subgraph "🔧 Admin Systems (1.2.21 - 1.2.24)"
        ADM1[ระบบผู้ดูแลระบบ<br/>1.2.21]
        ADM2[ระบบคลังโลหิต<br/>1.2.22]
        ADM3[ระบบตรวจสุขภาพ<br/>1.2.23]
        ADM4[การส่งออกข้อมูล<br/>1.2.24]
    end

    %% Authentication Flow
    GATEWAY --> AUTH
    AUTH --> RATE
    RATE --> MONITOR

    %% Medical Systems Integration
    MONITOR -.->|IAM & User Sync| MED1
    MONITOR -.->|IAM & User Sync| MED2
    MONITOR -.->|IAM & User Sync| MED3
    MONITOR -.->|IAM & User Sync| MED4
    MONITOR -.->|IAM & User Sync| MED5
    MONITOR -.->|IAM & User Sync| MED6
    MONITOR -.->|IAM & User Sync| MED7
    MONITOR -.->|IAM & User Sync| MED8
    MONITOR -.->|IAM & User Sync| MED9
    MONITOR -.->|IAM & User Sync| MED10
    MONITOR -.->|IAM & User Sync| MED11
    MONITOR -.->|IAM & User Sync| MED12

    %% Support Systems Integration
    MONITOR -.->|IAM & Master Data| SUP1
    MONITOR -.->|IAM & Config| SUP2
    MONITOR -.->|Master Data Sync| SUP3
    MONITOR -.->|IAM & Config| SUP4
    MONITOR -.->|IAM & Config| SUP5
    MONITOR -.->|IAM & Config| SUP6
    MONITOR -.->|IAM & Config| SUP7
    MONITOR -.->|IAM & Config| SUP8

    %% Admin Systems Integration
    ADM1 -.->|Central Management| GATEWAY
    MONITOR -.->|Integration & Sync| ADM2
    MONITOR -.->|Integration & Sync| ADM3
    MONITOR -.->|Data Export| ADM4

    classDef apiGateway fill:#e3f2fd,stroke:#1976d2,stroke-width:3px
    classDef medicalSys fill:#e8f5e8,stroke:#388e3c,stroke-width:2px
    classDef supportSys fill:#fff3e0,stroke:#f57c00,stroke-width:2px
    classDef adminSys fill:#fce4ec,stroke:#c2185b,stroke-width:2px

    class GATEWAY,AUTH,RATE,MONITOR apiGateway
    class MED1,MED2,MED3,MED4,MED5,MED6,MED7,MED8,MED9,MED10,MED11,MED12 medicalSys
    class SUP1,SUP2,SUP3,SUP4,SUP5,SUP6,SUP7,SUP8 supportSys
    class ADM1,ADM2,ADM3,ADM4 adminSys

10.2 API Endpoints Specification

10.2.1 Identity and Access Management APIs

User Management APIs:

# สำหรับการจัดการผู้ใช้งาน
GET    /api/v1/users                     # ดึงรายชื่อผู้ใช้งาน
POST   /api/v1/users                     # สร้างผู้ใช้งานใหม่
GET    /api/v1/users/{userId}             # ดึงข้อมูลผู้ใช้งาน
PUT    /api/v1/users/{userId}             # อัปเดตข้อมูลผู้ใช้งาน
DELETE /api/v1/users/{userId}             # ลบผู้ใช้งาน
POST   /api/v1/users/{userId}/activate    # เปิดใช้งานบัญชี
POST   /api/v1/users/{userId}/deactivate  # ปิดใช้งานบัญชี

# สำหรับการจัดการรหัสผ่าน
POST   /api/v1/users/{userId}/password/reset      # รีเซ็ตรหัสผ่าน
POST   /api/v1/users/{userId}/password/change     # เปลี่ยนรหัสผ่าน
GET    /api/v1/users/{userId}/password/policy     # ดูนโยบายรหัสผ่าน

Permission & Policy APIs:

# สำหรับการจัดการสิทธิ์
GET    /api/v1/permissions                        # ดึงรายการสิทธิ์ทั้งหมด
POST   /api/v1/systems/{systemId}/validate-access # ตรวจสอบสิทธิ์การเข้าถึง
GET    /api/v1/systems/{systemId}/user-permissions/{userId} # ดึงสิทธิ์ผู้ใช้งาน
PUT    /api/v1/systems/{systemId}/sync-users      # ซิงค์ข้อมูลผู้ใช้งาน

# สำหรับการจัดการนโยบาย
GET    /api/v1/policies                           # ดึงรายการนโยบาย
POST   /api/v1/policies                           # สร้างนโยบายใหม่
GET    /api/v1/policies/{policyId}                # ดึงข้อมูลนโยบาย
PUT    /api/v1/policies/{policyId}                # อัปเดตนโยบาย
POST   /api/v1/policies/{policyId}/evaluate       # ประเมินนโยบาย

10.2.2 System Integration APIs

Medical Records Integration (1.2.1):

# การเชื่อมต่อกับระบบเวชระเบียน
GET    /api/v1/medical-records/permissions/{patientId}  # สิทธิ์เข้าถึงข้อมูลผู้ป่วย
POST   /api/v1/medical-records/access-log              # บันทึกการเข้าถึง
GET    /api/v1/medical-records/users                   # ดึงรายชื่อผู้ใช้งาน
PUT    /api/v1/medical-records/users/{userId}/sync     # ซิงค์ข้อมูลผู้ใช้งาน

Pharmacy Integration (1.2.13):

# การเชื่อมต่อกับระบบเภสัชกรรม
GET    /api/v1/pharmacy/prescribe-rights/{userId}      # สิทธิ์การสั่งจ่ายยา
GET    /api/v1/pharmacy/drug-restrictions              # ข้อจำกัดการใช้ยา
POST   /api/v1/pharmacy/controlled-access              # การเข้าถึงยาควบคุม
PUT    /api/v1/pharmacy/master-data/sync               # ซิงค์ข้อมูลยา

Financial Integration (1.2.14):

# การเชื่อมต่อกับระบบการเงิน
GET    /api/v1/financial/billing-access/{userId}       # สิทธิ์การเข้าถึงข้อมูลการเงิน
GET    /api/v1/financial/payment-approval/{userId}     # สิทธิ์อนุมัติการชำระเงิน
POST   /api/v1/financial/transaction-log               # บันทึกการทำธุรกรรม

10.2.3 Emergency and Broadcasting APIs

Emergency Management:

# การจัดการสถานการณ์ฉุกเฉิน
POST   /api/v1/emergency/broadcast                     # ส่งข้อความฉุกเฉิน
GET    /api/v1/emergency/active-incidents             # เหตุการณ์ฉุกเฉินที่กำลังเกิด
PUT    /api/v1/emergency/{incidentId}/escalate        # เพิ่มระดับความร้ายแรง
POST   /api/v1/emergency/system-lockdown              # ล็อกระบบฉุกเฉิน
GET    /api/v1/emergency/response-status              # สถานะการตอบสนอง

Notification System:

# ระบบแจ้งเตือน
POST   /api/v1/notifications/send                     # ส่งการแจ้งเตือน
GET    /api/v1/notifications/{userId}                 # ดึงการแจ้งเตือนของผู้ใช้งาน
PUT    /api/v1/notifications/{notificationId}/read   # ทำเครื่องหมายอ่านแล้ว
DELETE /api/v1/notifications/{notificationId}        # ลบการแจ้งเตือน

10.3 Authentication & Security Flow

sequenceDiagram
    participant Client
    participant Gateway as API Gateway
    participant Auth as Auth Service
    participant IAM as IAM Engine
    participant Target as Target System
    participant Audit as Audit Service

    Client->>Gateway: API Request + JWT Token
    Gateway->>Auth: Validate Token
    Auth->>Auth: Verify Token Signature
    Auth->>IAM: Check User Permissions
    IAM->>IAM: Evaluate Policies
    IAM-->>Auth: Permission Result
    Auth-->>Gateway: Authentication Result

    alt Authentication Success
        Gateway->>Target: Forward Request
        Target-->>Gateway: Response
        Gateway-->>Client: API Response
        Gateway->>Audit: Log Access Success
    else Authentication Failed
        Gateway-->>Client: 401/403 Error
        Gateway->>Audit: Log Access Denied
    end

10.4 Data Synchronization Flow

graph TD
    subgraph "🔄 Master Data Sync Process"
        TRIGGER[Data Change Trigger]
        QUEUE[Sync Queue]
        PROCESSOR[Sync Processor]
        VALIDATOR[Data Validator]
        DISTRIBUTOR[Data Distributor]
    end

    subgraph "🎯 Target Systems"
        SYS1[ระบบเวชระเบียน]
        SYS2[ระบบเภสัชกรรม]
        SYS3[ระบบการเงิน]
        SYS4[ระบบอื่นๆ...]
    end

    subgraph "📊 Monitoring & Control"
        MONITOR[Sync Monitor]
        ROLLBACK[Rollback Service]
        CONFLICT[Conflict Resolver]
    end

    TRIGGER --> QUEUE
    QUEUE --> PROCESSOR
    PROCESSOR --> VALIDATOR
    VALIDATOR --> DISTRIBUTOR

    DISTRIBUTOR -.->|Sync Data| SYS1
    DISTRIBUTOR -.->|Sync Data| SYS2
    DISTRIBUTOR -.->|Sync Data| SYS3
    DISTRIBUTOR -.->|Sync Data| SYS4

    PROCESSOR --> MONITOR
    MONITOR --> CONFLICT
    CONFLICT --> ROLLBACK

    SYS1 -.->|Status Update| MONITOR
    SYS2 -.->|Status Update| MONITOR
    SYS3 -.->|Status Update| MONITOR
    SYS4 -.->|Status Update| MONITOR

    classDef syncProcess fill:#e1f5fe,stroke:#0277bd,stroke-width:2px
    classDef targetSys fill:#e8f5e8,stroke:#2e7d32,stroke-width:2px
    classDef monitoring fill:#fff3e0,stroke:#e65100,stroke-width:2px

    class TRIGGER,QUEUE,PROCESSOR,VALIDATOR,DISTRIBUTOR syncProcess
    class SYS1,SYS2,SYS3,SYS4 targetSys
    class MONITOR,ROLLBACK,CONFLICT monitoring

10.5 Error Handling และ Rate Limiting

Error Response Format:

{
  "error": {
    "code": "AUTH_001",
    "message": "Invalid authentication credentials",
    "details": "JWT token has expired",
    "timestamp": "2025-10-08T10:30:00Z",
    "requestId": "req_1234567890"
  }
}

Rate Limiting Rules:

Rate_Limits:
  Authentication_APIs:
    limit: 100
    window: "1 minute"
    burst: 10

  User_Management_APIs:
    limit: 1000
    window: "1 minute"
    burst: 50

  Data_Sync_APIs:
    limit: 500
    window: "1 minute"
    burst: 20

  Emergency_APIs:
    limit: 1000
    window: "1 minute"
    burst: 100  # Higher burst for emergency