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

โครงสร้างข้อมูลระบบเภสัชกรรม (Pharmacy Data Structures)

📋 สารบัญ


ภาพรวม

ระบบเภสัชกรรมใช้ JSON files เป็น mock data โดยมีไฟล์หลักดังนี้:

ไฟล์ คำอธิบาย จำนวนรายการ
medications-master.json รายการยาทั้งหมด (Item Master) ~100 รายการ
master-drug-dropdown.json Dropdown data (frequency, route, etc.) ~50 options
medication-templates.json ชุดยาแพทย์ (Shared) ~10 templates
drug-interactions.json ปฏิกิริยาระหว่างยา ~30 interactions
prescription-history.json ประวัติการสั่งยา ~50 prescriptions
pharmacy-opd-queue.json คิวจ่ายยา OPD ~15 คิว
pharmacy-ipd-orders.json คำสั่งยา IPD ~20 orders
pharmacy-return-history.json ประวัติคืนยา ~5 รายการ

Medication Master

ไฟล์: data/medications-master.json

โครงสร้างหลัก

interface MedicationMaster {
  // === Identification ===
  id: string;                      // "MED001"
  tmtCode: string;                 // TMT Code (Thailand)
  tpuCode: string;                 // TPU Code
  gfmisCode: string;               // GFMIS Code (24 หลัก)
  code24Digit: string;             // Same as gfmisCode
  gpoCode: string;                 // GPO Code
  invCode: string;                 // Inventory Code

  // === Names ===
  drugName: string;                // "Paracetamol 500 mg Tablet"
  genericName: string;             // "Paracetamol"
  englishName: string;             // English name
  tradeName: string;               // "Tylenol"
  listedName: string;              // ชื่อภาษาไทย
  stickerShortName: string;        // ชื่อย่อบนฉลาก "พารา"

  // === Classification ===
  drugCategory: "ANAP"|"ANTI"|"CARD"|"DIAB"|"RESP"|"GAST"|...; // หมวดยา
  drugGroup: string;               // "acetaminophen"
  therapeuticGroup: string;        // กลุ่มการรักษา

  // === Dosage Form ===
  strength: string;                // "500"
  unit: string;                    // "mg"
  dosageForm: "TABL"|"CAPS"|"SYRU"|"INJE"|"CREA"|...;
  dose: string;                    // "1 เม็ด"
  doseUnit: string;                // "TABL"

  // === Packaging ===
  contValue: number;               // จำนวนต่อหน่วย
  contUnit: string;                // หน่วย
  unitsPerPack: number;            // จำนวนต่อแพ็ค
  dispUnit: string;                // หน่วยจ่าย "TABL"
  dispenseUnitSize: string;        // "T10P" (10 tablets/pack)

  // === Pricing ===
  costPrice: number;               // ต้นทุน
  standardPrice: number;           // ราคามาตรฐาน
  opdPrice: number;                // ราคา OPD
  ipdPrice: number;                // ราคา IPD
  priceUnit: string;               // หน่วยราคา
  lockDiscount: boolean;           // ล็อคส่วนลด
  lockEditPrice: boolean;          // ล็อคแก้ไขราคา

  // === Usage ===
  usageMode: ("OPD"|"IPD")[];      // ใช้ได้ใน OPD/IPD
  usageMethod: string;             // "POAM" (ทางปาก)
  frequency: string;               // "TIDU" (3 times a day)
  timing: string;                  // "MONE" (หลังอาหาร)
  labelHelper: string;             // คำแนะนำบนฉลาก

  // === Therapeutic Info ===
  indication: string;              // ข้อบ่งใช้
  contraindication: string;        // ข้อห้าม
  sideEffects: string;             // ผลข้างเคียง
  therapeuticUseTh: string;        // การใช้ทางการแพทย์ (ไทย)
  therapeuticUseEng: string;       // การใช้ทางการแพทย์ (Eng)

  // === Safety Warnings ===
  showPregnancyWarning: boolean;   // แสดงคำเตือนหญิงตั้งครรภ์
  pregnancyCategory: "A"|"B"|"C"|"D"|"X";
  pregnancyAdvice: string;

  showLactationWarning: boolean;   // แสดงคำเตือนหญิงให้นมบุตร
  lactationSafe: boolean;
  lactationAdvice: string;

  showChildWarning: boolean;       // แสดงคำเตือนเด็ก
  childAgeStart: number;
  childAgeEnd: number;
  childAdvice: string;
  pediatricSafe: boolean;

  showGenderWarning: boolean;      // แสดงคำเตือนเฉพาะเพศ
  gender: "MALE"|"FEMA"|"ALLG";
  genderAdvice: string;

  showG6PDWarning: boolean;        // แสดงคำเตือน G6PD
  g6pdAdvice: string;

  // === Dosage Regimen Examples ===
  mode1DosageRegimen: string;      // "1 เม็ด ทุก 6 ชั่วโมง หลังอาหาร"
  mode2DosageRegimen: string;      // "2 เม็ด ทุก 8 ชั่วโมง เมื่อมีไข้"
  maxDailyDose: string;            // "4000 mg"

  // === Drug Control ===
  narcoticType: "NONA"|"N1"|"N2"|"N3"|"N4"|"N5"; // ยาเสพติด
  psychotropicSubstance: "NPSY"|"PSY1"|"PSY2"|...; // ยาจิตเวช
  requiresSpecialist: boolean;     // ต้องการแพทย์เฉพาะทาง
  requiredAuthority: string|null;  // หน่วยงานที่ต้องอนุมัติ

  // === Metadata ===
  manufacturer: string;            // ผู้ผลิต
  searchKeywords: string;          // Keywords สำหรับค้นหา
  remark: string;                  // หมายเหตุ
  systemNote: string;              // Note ของระบบ
}

ตัวอย่าง

{
  "id": "MED001",
  "tmtCode": "TMT0000000001",
  "drugName": "Paracetamol 500 mg Tablet",
  "genericName": "Paracetamol",
  "tradeName": "Tylenol",
  "listedName": "ยาพาราเซตามอล 500 มก. ชนิดเม็ด",
  "strength": "500",
  "unit": "mg",
  "dosageForm": "TABL",
  "drugCategory": "ANAP",
  "costPrice": 0.25,
  "opdPrice": 0.5,
  "ipdPrice": 0.45,
  "indication": "ลดไข้ แก้ปวด",
  "contraindication": "แพ้ยา, ตับวาย",
  "sideEffects": "คลื่นไส้, ผื่นแพ้",
  "maxDailyDose": "4000 mg",
  "pregnancyCategory": "B",
  "lactationSafe": true,
  "pediatricSafe": true
}

Master Dropdowns

ไฟล์: data/master-drug-dropdown.json

โครงสร้าง

interface MasterDropdown {
  frequency: DropdownOption[];      // ความถี่
  timing: DropdownOption[];         // เวลา
  route: DropdownOption[];          // เส้นทาง
  usageMethod: DropdownOption[];    // วิธีใช้
  duration: DropdownOption[];       // ระยะเวลา
  dosageForm: DropdownOption[];     // รูปแบบยา
  unit: DropdownOption[];           // หน่วย
}

interface DropdownOption {
  code: string;          // รหัส
  nameTh: string;        // ชื่อภาษาไทย
  nameEn: string;        // ชื่อภาษาอังกฤษ
  abbr?: string;         // ตัวย่อ
  timesPerDay?: number;  // จำนวนครั้งต่อวัน (สำหรับ frequency)
  description?: string;  // คำอธิบาย
}

ตัวอย่าง Frequency

{
  "frequency": [
    {
      "code": "OD",
      "nameTh": "วันละ 1 ครั้ง",
      "nameEn": "Once daily",
      "abbr": "od",
      "timesPerDay": 1
    },
    {
      "code": "BID",
      "nameTh": "วันละ 2 ครั้ง",
      "nameEn": "Twice daily",
      "abbr": "bid",
      "timesPerDay": 2
    },
    {
      "code": "TID",
      "nameTh": "วันละ 3 ครั้ง",
      "nameEn": "Three times daily",
      "abbr": "tid",
      "timesPerDay": 3
    },
    {
      "code": "QID",
      "nameTh": "วันละ 4 ครั้ง",
      "nameEn": "Four times daily",
      "abbr": "qid",
      "timesPerDay": 4
    },
    {
      "code": "Q4H",
      "nameTh": "ทุก 4 ชั่วโมง",
      "nameEn": "Every 4 hours",
      "abbr": "q4h",
      "timesPerDay": 6
    },
    {
      "code": "PRN",
      "nameTh": "เมื่อจำเป็น",
      "nameEn": "As needed",
      "abbr": "prn",
      "timesPerDay": 0
    }
  ]
}

ตัวอย่าง Timing

{
  "timing": [
    {
      "code": "AC",
      "nameTh": "ก่อนอาหาร",
      "nameEn": "Before meals",
      "description": "30-60 นาทีก่อนอาหาร"
    },
    {
      "code": "PC",
      "nameTh": "หลังอาหาร",
      "nameEn": "After meals",
      "description": "ภายใน 30 นาทีหลังอาหาร"
    },
    {
      "code": "HS",
      "nameTh": "ก่อนนอน",
      "nameEn": "At bedtime"
    }
  ]
}

Prescription Data

ไฟล์: data/prescription-history.json

โครงสร้าง

interface PrescriptionHistory {
  prescriptions: Prescription[];
}

interface Prescription {
  id: string;                // "RX2024123"
  hn: string;                // "HN000123"
  patientName: string;
  vn: string;                // Visit Number
  visitDate: string;         // "2024-11-15"
  visitType: "OPD"|"IPD";
  clinicId: string;
  clinicName: string;
  doctorId: string;
  doctorName: string;

  diagnosis: Diagnosis[];
  medications: PrescriptionMedication[];

  prescribedBy: string;
  prescribedAt: string;
  dispensedBy?: string;
  dispensedAt?: string;
  status: "ordered"|"dispensed"|"cancelled";
}

interface Diagnosis {
  icd10: string;             // "J06.9"
  diagnosisName: string;
}

interface PrescriptionMedication {
  id: string;
  medicationId: string;
  medicationCode: string;
  medicationName: string;
  genericName: string;
  dosageForm: string;
  strength: string;

  dosage: string;            // "1-2 tab"
  frequency: string;         // "q4-6h"
  route: string;             // "oral"
  quantity: number;
  duration: number;          // วัน
  unit: string;

  indication: string;
  note: string;
}

OPD Queue

ไฟล์: data/pharmacy-opd-queue.json

โครงสร้าง

interface OPDQueue {
  prescriptionId: string;    // "OPD-Q-001"
  type: "OPD";
  visitId: string;
  hn: string;
  patientName: string;
  clinic: string;
  doctor: string;
  doctorId: string;
  prescriptionDate: string;  // ISO datetime

  status: "waiting_prepare"|"waiting_payment"|"ready_to_dispense"|"dispensed"|"cancelled";

  items: OPDMedicationItem[];

  totalCost: number;
  copay?: number;            // ค่าใช้จ่ายผู้ป่วย
  insuranceCovered?: number; // ประกันจ่าย
}

interface OPDMedicationItem {
  itemId: string;
  drugCode: string;
  tradeName: string;
  genericName: string;
  strength: string;
  dosageForm: string;

  quantity: number;
  unit: string;
  unitPrice: number;

  dosage: string;
  frequency: string;
  duration: string;
  route: string;
  instruction: string;

  isSelected: boolean;       // เลือกจ่ายหรือไม่
  isPrinted: boolean;        // พิมพ์ฉลากแล้วหรือยัง
}

IPD Orders

ไฟล์: data/pharmacy-ipd-orders.json

โครงสร้าง

interface IPDOrder {
  prescriptionId: string;    // "IPD-ORD-001"
  type: "IPD";
  orderType: "continue"|"stat"|"prn"|"one_day"|"discharge";

  an: string;                // Admission Number
  hn: string;
  patientName: string;
  ward: string;              // "Medical Ward"
  bed: string;               // "M301-1"
  doctor: string;
  doctorId: string;

  prescriptionDate: string;
  startDate: string;         // สำหรับ continue order
  stopDate?: string;

  status: "pending"|"active"|"completed"|"discontinued"|"cancelled";
  workflowStatus: "pending"|"prepared"|"sent"|"received"|"given";

  items: IPDMedicationItem[];

  urgency?: "routine"|"urgent"|"critical"; // สำหรับ STAT
  prnCondition?: string;     // สำหรับ PRN "เมื่อมีไข้ >38°C"
}

interface IPDMedicationItem {
  itemId: string;
  drugCode: string;
  tradeName: string;
  genericName: string;
  strength: string;
  dosageForm: string;

  quantity: number;
  unit: string;
  unitPrice: number;

  dosage: string;
  frequency: string;
  administrationTime: string[]; // ["06:00", "18:00"]
  route: string;
  instruction: string;

  isPrinted: boolean;
  status: "active"|"given"|"missed"|"discontinued";

  mar?: MARRecord[];         // Medication Administration Record
}

interface MARRecord {
  date: string;
  time: string;
  scheduledTime: string;
  actualTime: string;
  administeredBy: string;
  administeredByName: string;
  status: "given"|"missed"|"refused"|"held"|"na";
  remarks: string;
}

Drug Interactions

ไฟล์: data/drug-interactions.json

โครงสร้าง

interface DrugInteraction {
  id: string;
  drug1Code: string;
  drug1Name: string;
  drug2Code: string;
  drug2Name: string;

  severity: "major"|"moderate"|"minor";

  description: string;       // คำอธิบายปฏิกิริยา
  mechanism: string;         // กลไก
  effect: string;            // ผลที่เกิดขึ้น
  management: string;        // การจัดการ

  references: string[];      // แหล่งอ้างอิง

  clinicalSignificance: string;
  timeToOnset: string;       // "Rapid"|"Delayed"
  documentationLevel: string; // "Excellent"|"Good"|"Fair"
}

ตัวอย่าง

{
  "id": "INT001",
  "drug1Code": "MED020",
  "drug1Name": "Warfarin",
  "drug2Code": "MED002",
  "drug2Name": "Aspirin",
  "severity": "major",
  "description": "เพิ่มความเสี่ยงเลือดออกอย่างมาก",
  "mechanism": "Warfarin และ Aspirin ต่างก็ยับยั้งการแข็งตัวของเลือด เมื่อใช้ร่วมกันจะเพิ่มฤทธิ์กัน",
  "effect": "เลือดออกในทางเดินอาหาร เลือดออกในสมอง",
  "management": "หลีกเลี่ยงการใช้ร่วมกัน พิจารณาเปลี่ยนเป็น Clopidogrel หรือตรวจ INR ทุก 3-5 วัน",
  "references": ["Micromedex", "UpToDate"],
  "clinicalSignificance": "High",
  "timeToOnset": "Rapid",
  "documentationLevel": "Excellent"
}

Templates

ไฟล์: data/medication-templates.json

โครงสร้าง

interface MedicationTemplate {
  id: string;
  name: string;
  type: "personal"|"shared";

  doctorId?: string;         // สำหรับ personal
  doctorName?: string;

  category?: string;         // สำหรับ shared
  disease: string;
  guidelines?: string;       // "CPG Thailand 2023"

  medications: TemplateMedication[];

  createdBy: string;
  createdAt: string;
  approvedBy?: string;       // สำหรับ shared
  updatedAt?: string;
}

interface TemplateMedication {
  drugCode: string;
  tradeName: string;
  genericName: string;
  dosageForm: string;
  strength: string;

  dosage: string;
  frequency: string;
  timing?: string;
  route: string;
  duration?: string;

  instruction?: string;
  note?: string;
}

ตัวอย่าง

{
  "id": "TPL-SHARED-001",
  "name": "ชุดรักษาความดันโลหิตสูง",
  "type": "shared",
  "category": "cardiovascular",
  "disease": "Hypertension",
  "guidelines": "CPG Thailand 2023",
  "medications": [
    {
      "drugCode": "MED030",
      "tradeName": "Amlodipine 5mg",
      "genericName": "Amlodipine",
      "dosageForm": "tablet",
      "strength": "5mg",
      "dosage": "1 tab",
      "frequency": "od",
      "timing": "hs",
      "route": "oral"
    }
  ],
  "createdBy": "ADMIN",
  "createdAt": "2025-01-01T00:00:00Z",
  "approvedBy": "คณะกรรมการเภสัชกรรมและการบำบัด"
}

สรุป Code Mapping

Dosage Form Codes

TABL = Tablet (เม็ด)
CAPS = Capsule (แคปซูล)
SYRU = Syrup (น้ำยา)
INJE = Injection (ฉีด)
CREA = Cream (ครีม)
OINT = Ointment (ขี้ผึ้ง)
DROP = Drops (หยด)
SUSP = Suspension (น้ำยาแขวนลอย)

Frequency Codes

OD = Once daily
BID = Twice daily
TID = Three times daily
QID = Four times daily
Q4H = Every 4 hours
Q6H = Every 6 hours
PRN = As needed
STAT = Immediately

Route Codes

POAM = Per oral (ทางปาก)
IV = Intravenous (เส้นเลือดดำ)
IM = Intramuscular (ฉีดกล้ามเนื้อ)
SC = Subcutaneous (ใต้ผิวหนัง)
TOPICAL = ทาภายนอก
INHALATION = สูดดม

อัปเดตล่าสุด: 6 มกราคม 2026
หมายเหตุ: โครงสร้างนี้เป็น Mock Data อาจมีการปรับเปลี่ยนตามความต้องการ