feat(seed,agents): enforce single Dr. Demo on installation and add HMS core skills & rules
This commit is contained in:
parent
565586aa6e
commit
47b64f7bf6
51
.agents/rules/hms_billing_standards.md
Normal file
51
.agents/rules/hms_billing_standards.md
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
# HMS Billing & Revenue Standards
|
||||
|
||||
This document defines the architectural and database rules for all OPD, IPD, Diagnostics, and Pharmacy billing in the E-Atria HMS.
|
||||
|
||||
---
|
||||
|
||||
## 1. Core Billing Table Schema & Roles
|
||||
|
||||
| Table Name | Primary Role | Key Columns |
|
||||
| :--- | :--- | :--- |
|
||||
| `invoice_master` | Master bill/invoice record for OPD, IPD, and Lab visits | `id`, `invoice_no`, `patient_id`, `doctor_id`, `total_amount`, `discount_amount`, `tax_amount`, `net_amount`, `paid_amount`, `balance_amount`, `status`, `payment_mode`, `created_date` |
|
||||
| `invoice_item` | Line items for services, doctor visits, procedures, lab investigations | `id`, `invoice_id`, `item_type`, `item_id`, `item_name`, `item_rate`, `qty`, `amount`, `discount`, `net_amount`, `doctor_id`, `created_at` |
|
||||
| `payment_history` | Multi-tender transaction log (Cash, UPI, Card, NetBanking, Cheque) | `id`, `invoice_id`, `patient_id`, `amount`, `payment_mode`, `transaction_ref`, `bank_source_id`, `received_by`, `payment_date` |
|
||||
| `ipd_invoice_item` | Dynamic daily IPD charges (room rent, nursing, doctor rounds, procedures) | `id`, `ipd_id`, `item_type`, `item_id`, `item_name`, `item_rate`, `item_qty`, `item_amount`, `doc_id`, `doc_name`, `date_item` |
|
||||
| `doc_opd_fee` | OPD consultation fee slab configured per doctor | `id`, `doc_id`, `doc_fee_type`, `doc_fee_desc`, `amount` |
|
||||
| `doc_ipd_fee` | IPD visit fee slab configured per doctor | `id`, `doc_id`, `doc_fee_type`, `doc_fee_desc`, `amount`, `isdelete` |
|
||||
| `sales_master` | Pharmacy sales invoice master | `id`, `bill_no`, `patient_id`, `opd_id`, `ipd_id`, `total`, `discount`, `net_amount`, `paid_amount`, `created_at` |
|
||||
|
||||
---
|
||||
|
||||
## 2. Inviolable Financial Integrity Rules
|
||||
|
||||
1. **Balance Equation Strictness**:
|
||||
For every invoice in `invoice_master`:
|
||||
$$\text{net\_amount} = \text{total\_amount} - \text{discount\_amount} + \text{tax\_amount}$$
|
||||
$$\text{balance\_amount} = \text{net\_amount} - \text{paid\_amount}$$
|
||||
- Any transaction modifying line items or applying discounts MUST atomically update `invoice_master.net_amount` and `invoice_master.balance_amount`.
|
||||
|
||||
2. **Every Receipt Must Have a Ledger Entry**:
|
||||
- Whenever money is collected (cash, UPI, card, bank transfer, advance), an entry MUST be inserted into `payment_history`.
|
||||
- Never update `invoice_master.paid_amount` without inserting a corresponding row in `payment_history`.
|
||||
- The sum of payments in `payment_history` for an `invoice_id` must always equal `invoice_master.paid_amount`.
|
||||
|
||||
3. **Status Transitions**:
|
||||
- `UNPAID`: $\text{paid\_amount} = 0$
|
||||
- `PARTIAL`: $0 < \text{paid\_amount} < \text{net\_amount}$
|
||||
- `PAID`: $\text{paid\_amount} \ge \text{net\_amount}$
|
||||
- `CANCELLED`: Only permitted when reversed with reason log and audit user ID.
|
||||
|
||||
4. **IPD Running Charges to Final Invoice**:
|
||||
- IPD patients accumulate daily charges in `ipd_invoice_item` (room tariff, daily doctor rounds, medication, nursing care).
|
||||
- Upon discharge billing, all unbilled items from `ipd_invoice_item` and approved advances from `payment_history` are aggregated into the final settlement invoice in `invoice_master`.
|
||||
- Once finalized, items in `ipd_invoice_item` must be marked as billed/settled to prevent double billing.
|
||||
|
||||
5. **Discount Governance**:
|
||||
- Any discount greater than zero requires `discount_reason` and must be authorized by an authorized user (`discount_approved_by`).
|
||||
- Doctors or cashiers cannot grant unauthorized ad-hoc discounts without an audit trail.
|
||||
|
||||
6. **Patient Full Name Standard**:
|
||||
- In invoices and receipts, the patient's name MUST be fetched from `patient_master.p_fname`.
|
||||
- Never query or write to `patient_master.p_lname` (permanently dropped).
|
||||
53
.agents/rules/hms_clinical_standards.md
Normal file
53
.agents/rules/hms_clinical_standards.md
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
# HMS Clinical & Medical Record Standards
|
||||
|
||||
This document defines the clinical data model, doctor naming conventions, laboratory reporting, radiology reporting, and electronic medical record (EMR) rules for the E-Atria HMS.
|
||||
|
||||
---
|
||||
|
||||
## 1. Demographic & Clinical Name Rules
|
||||
|
||||
1. **Patient Full Name Standard (`patient_master.p_fname`)**:
|
||||
- The patient's full name is stored strictly and exclusively in `patient_master.p_fname`.
|
||||
- The column `patient_master.p_lname` has been permanently dropped from the database.
|
||||
- **NEVER** use, select, insert, update, or reference `patient_master.p_lname` anywhere in controllers, models, views, or queries.
|
||||
|
||||
2. **Doctor Name Standard (`doctor_master`)**:
|
||||
- For doctors, the database retains multi-part names: `p_title`, `p_fname`, `p_mname`, `p_lname`.
|
||||
- When displaying a doctor's full name on UI, prescription prints, or reports:
|
||||
```php
|
||||
$doctorFullName = trim(($doctor->p_title ?? 'Dr.') . ' ' . trim(($doctor->p_fname ?? '') . ' ' . ($doctor->p_mname ?? '') . ' ' . ($doctor->p_lname ?? '')));
|
||||
```
|
||||
- Always display qualification (`doc_sign`) and medical council registration number (`doctor_reg_no`) on all prescription and diagnostic report footers.
|
||||
|
||||
---
|
||||
|
||||
## 2. Clinical Terminology & Code Mappings
|
||||
|
||||
1. **SNOMED CT Coding**:
|
||||
- All chief complaints, physical findings, and diagnoses recorded in OPD consultation must link to SNOMED CT Concept IDs whenever available.
|
||||
- The local CSNOTK bridge is configured at `snomed.csnotk.baseUrl` in `.env`.
|
||||
|
||||
2. **LOINC Coding for Pathology**:
|
||||
- All tests in `lab_tests` should have corresponding LOINC codes mapped in `lab_tests.loinc_num` or `lab_tests.loinc_code`.
|
||||
- When generating NRCeS FHIR Document Bundles (DiagnosticReport), LOINC is the mandatory primary coding system.
|
||||
|
||||
3. **Ayushman Bharat & TPA Packages**:
|
||||
- Standard package procedures must map to `ayushman_package_master` (1,401 standardized PM-JAY packages).
|
||||
|
||||
---
|
||||
|
||||
## 3. Diagnostic & Imaging Workflow Integrity
|
||||
|
||||
1. **Pathology Lifecycle**:
|
||||
$$\text{Test Prescribed} \longrightarrow \text{Sample Collected} \longrightarrow \text{Accession/Barcode} \longrightarrow \text{Result Entry} \longrightarrow \text{Doctor Verification} \longrightarrow \text{Published Report}$$
|
||||
- No diagnostic report can be released to a patient portal or ABDM bridge without formal verification (`verified_by` / `doctor_sign`).
|
||||
- Out-of-range critical/panic values must be visually highlighted in bold red with critical alert indicators.
|
||||
|
||||
2. **Radiology Lifecycle**:
|
||||
$$\text{Scan Ordered} \longrightarrow \text{Procedure Completed} \longrightarrow \text{Drafting Findings} \longrightarrow \text{Impression} \longrightarrow \text{Radiologist Sign-off}$$
|
||||
- Templates stored in `doc_print_templates` / `radiology_ultrasound_template` must preserve standardized headings:
|
||||
1. Clinical Indication / History
|
||||
2. Modality & Protocol
|
||||
3. Observations / Findings
|
||||
4. Impression / Conclusion
|
||||
5. Advice / Recommendations
|
||||
56
.agents/rules/nabh_compliance_rules.md
Normal file
56
.agents/rules/nabh_compliance_rules.md
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
# NABH Hospital Accreditation Compliance Rules
|
||||
|
||||
This document specifies the NABH (National Accreditation Board for Hospitals & Healthcare Providers, 5th Edition) standards embedded in the E-Atria HMS architecture.
|
||||
|
||||
---
|
||||
|
||||
## 1. 13 Mandatory Statutory Consent Forms
|
||||
|
||||
All IPD admissions and specialized clinical procedures must record explicit, informed patient consent before interventions:
|
||||
|
||||
| Consent Form ID | Title | Key Mandatory Requirement |
|
||||
| :--- | :--- | :--- |
|
||||
| `NABH-IPD-01` | Admission Request & Initial Assessment Form | Demographics, provisional diagnosis, treating consultant, signature within 24h |
|
||||
| `NABH-IPD-02` | General Informed Consent for Medical Treatment | Risks, benefits, hospital policies, patient/attendant signature |
|
||||
| `NABH-IPD-03` | Informed Consent for Surgical Procedure / Operation | Operating surgeon, specific procedure name, alternatives, anesthesia type |
|
||||
| `NABH-IPD-04` | Informed Consent for Administration of Anesthesia | General / Spinal / Epidural / Regional, fasting status, ASA grade |
|
||||
| `NABH-IPD-05` | High-Risk Informed Consent | Explicit documentation of mortality risk, ICU requirement, signed by 2 attendants |
|
||||
| `NABH-IPD-06` | Blood & Blood Component Transfusion Consent | PRBC, FFP, Platelets, adverse reaction warning, refusal rights |
|
||||
| `NABH-IPD-07` | ICU / HDU Admission Informed Consent | Critical care protocols, invasive monitoring, ventilator consent |
|
||||
| `NABH-IPD-08` | Discharge Against Medical Advice (DAMA / LAMA) | Declaration of voluntary discharge against advice, liability waiver |
|
||||
| `NABH-IPD-09` | Consent for Invasive Diagnostic / Bedside Procedure | Endoscopy, Lumbar puncture, CVC, Pleural tap |
|
||||
| `NABH-IPD-10` | Refusal of Medical Treatment / Procedure Consent | Explicit informed refusal documenting medical risks of refusal |
|
||||
| `NABH-IPD-11` | Chemotherapy / Dialysis Specialized Consent | Specific drug protocols, cumulative toxicity risks |
|
||||
| `NABH-IPD-12` | Restraint Application Consent | Physical/chemical restraint reason, alternative trials, periodic review |
|
||||
| `NABH-IPD-13` | Release of Medical Records / Photography Consent | Confidentiality waiver, medico-legal or insurance release |
|
||||
|
||||
---
|
||||
|
||||
## 2. Inpatient Clinical Timelines & Standards
|
||||
|
||||
1. **Initial Assessment Timeline**:
|
||||
- Initial Medical Assessment by doctor must be completed within **24 hours of admission** (or immediately for emergency/ICU admissions).
|
||||
- Initial Nursing Assessment must be completed within **2 to 4 hours of admission**.
|
||||
|
||||
2. **Daily Clinical Progress Notes (SOAP Format)**:
|
||||
- Every inpatient must have daily dated and timed notes adhering to:
|
||||
- **S (Subjective)**: Patient complaints, comfort, pain score (1-10).
|
||||
- **O (Objective)**: Vitals (BP, PR, RR, SpO2, Temp), systemic physical examination, lab/imaging review.
|
||||
- **A (Assessment)**: Current clinical status and diagnosis evolution.
|
||||
- **P (Plan)**: Medication changes, investigations ordered, diet, discharge planning.
|
||||
|
||||
3. **Discharge Summary Mandatory Criteria**:
|
||||
- Under NABH, a discharge summary MUST contain:
|
||||
1. Admission & Discharge Dates & Times.
|
||||
2. Primary & Secondary Final Diagnoses (with ICD-10 codes).
|
||||
3. Significant Clinical History & Physical Findings on admission.
|
||||
4. Results of Significant Diagnostic Tests & Interventions.
|
||||
5. Summary of Hospital Course & Treatment Provided.
|
||||
6. Condition of the Patient at Discharge.
|
||||
7. Discharge Medications (generic name, strength, dosage, route, frequency, duration).
|
||||
8. Urgent Warning Signs / Red Flags necessitating immediate emergency return.
|
||||
9. Specific Follow-up Date and Consulting Doctor Name.
|
||||
|
||||
4. **Digital Scanning & Retention (`nabh_ipd_scans`)**:
|
||||
- Physical paper consent forms and bedside charts scanned into the system are stored in `nabh_ipd_scans` with proper categorization (`NABH-IPD-01` to `13`).
|
||||
- Scanned records must be retained in accordance with the hospital's medico-legal retention period (minimum 3 years for adult IPD, till age of majority + 3 years for pediatric cases).
|
||||
78
.agents/skills/hms-billing/SKILL.md
Normal file
78
.agents/skills/hms-billing/SKILL.md
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
---
|
||||
name: hms-billing
|
||||
description: Use when building, debugging, modifying, or testing HMS billing workflows, including OPD consultation fees, IPD running charges, final discharge settlement, lab and radiology billing, pharmacy sales, multi-tender payments, and package management.
|
||||
---
|
||||
|
||||
# HMS Billing & Financial Management Skill
|
||||
|
||||
This skill guides the agent through the complete billing workflows, ledger integrity, database structures, and calculation formulas in E-Atria HMS.
|
||||
|
||||
---
|
||||
|
||||
## 1. Overview of Billing Workflows
|
||||
|
||||
E-Atria HMS manages four distinct revenue streams:
|
||||
1. **OPD Billing**: Doctor consultation fees, registration charges, minor OPD procedures, emergency day care.
|
||||
2. **IPD Billing**: Bed charges, nursing fees, doctor daily rounds, ICU monitoring, OT/Surgery fees, package tariffs, final discharge settlement.
|
||||
3. **Diagnostics Billing**: Laboratory pathology investigations, radiology imaging procedures.
|
||||
4. **Pharmacy Sales**: Inpatient and outpatient drug dispensing, prescription fulfillment.
|
||||
|
||||
---
|
||||
|
||||
## 2. Key Database Tables
|
||||
|
||||
### Master & Transactional Tables
|
||||
- `invoice_master`: Central invoice header containing patient reference, dates, totals, discounts, taxes, paid amount, and outstanding balance.
|
||||
- `invoice_item`: Line items for services billed under an `invoice_master` record (`item_type`: 1=Consultation, 2=Procedure, 3=Lab, 4=Radiology, 5=Nursing, etc.).
|
||||
- `payment_history`: Ledger recording every monetary transaction (Cash, UPI, Credit/Debit Card, NetBanking, Cheque, Advance Deposit).
|
||||
- `ipd_invoice_item`: Running IPD ledger updated dynamically as daily nursing charges, doctor visits, and medications are consumed.
|
||||
- `doc_opd_fee`: Doctor consultation fee schedule by fee type (`1`=New Patient, `2`=Revisit, `3`=Running, `4`=Emergency, `5`=Night/Off-time).
|
||||
- `doc_ipd_fee`: Doctor IPD visit fee schedule (`1`=Regular Ward Visit, `2`=ICU Visit, etc.).
|
||||
- `doc_fee_type`: Descriptive lookup for fee categories.
|
||||
- `hospital_bank_payment_source`: Configured bank accounts / POS machines / UPI QR accounts for financial auditing.
|
||||
- `ayushman_package_master`: Standard PM-JAY package procedure pricing.
|
||||
|
||||
---
|
||||
|
||||
## 3. OPD Consultation Billing Workflow
|
||||
|
||||
1. **Patient Lookup / Registration**:
|
||||
- Check if patient exists via `patient_master.p_fname`, `mphone1`, or ABHA ID.
|
||||
- If new, insert into `patient_master` (storing full name strictly in `p_fname`).
|
||||
2. **Doctor & Fee Selection**:
|
||||
- Select doctor from `doctor_master`.
|
||||
- Fetch active consultation fee from `doc_opd_fee` for selected `doc_fee_type` (e.g. New Patient = ₹500, Revisit = ₹300).
|
||||
3. **Invoice Generation**:
|
||||
- Insert invoice in `invoice_master` with `status = 'PAID'` (or `'PARTIAL'`).
|
||||
- Insert corresponding item row into `invoice_item`.
|
||||
4. **Payment Recording**:
|
||||
- Insert transaction row in `payment_history` with `payment_mode`, `amount`, and `received_by`.
|
||||
5. **OPD Token / Receipt Printing**:
|
||||
- Generate thermal or A4 receipt with hospital header, UHID, Doctor Name (`Dr. {p_fname}`), Token No, and QR code.
|
||||
|
||||
---
|
||||
|
||||
## 4. IPD Running Charges to Final Settlement
|
||||
|
||||
1. **Daily Accumulation**:
|
||||
- Nursing staff and ward managers post daily items into `ipd_invoice_item`:
|
||||
- Room/Bed tariff (based on `bed_master.bed_category_id`).
|
||||
- Daily doctor visit charges (from `doc_ipd_fee`).
|
||||
- Bedside monitoring, injections, consumables (`nursing_ipd_charges`).
|
||||
2. **Advance Payments**:
|
||||
- Inpatients make advance deposits during hospital stay.
|
||||
- Advances are logged in `payment_history` linked to the patient's `ipd_id`.
|
||||
3. **Discharge Settlement**:
|
||||
- Upon discharge approval, the billing clerk generates the final settlement:
|
||||
$$\text{Gross Total} = \sum \text{ipd\_invoice\_item.item\_amount}$$
|
||||
$$\text{Net Due} = \text{Gross Total} - \text{Approved Discount} + \text{Taxes} - \sum \text{Advance Payments}$$
|
||||
- The final invoice is created in `invoice_master`, and remaining balance is collected via `payment_history`.
|
||||
- The `ipd_master.discharge_date` and `ipd_master.status = 'discharged'` are marked.
|
||||
|
||||
---
|
||||
|
||||
## 5. Safe Modification & Debugging Rules
|
||||
|
||||
- **Zero-Sum Balance Rule**: Never update `invoice_master.paid_amount` or `balance_amount` manually without validating that $\sum \text{payment\_history.amount} == \text{invoice\_master.paid\_amount}$.
|
||||
- **Patient Name**: Always select `patient_master.p_fname`. Column `patient_master.p_lname` does not exist.
|
||||
- **Doctor Share**: Doctor commission calculations must be derived from `invoice_item.doctor_id` and verified against active `finance_doctor_agreements`.
|
||||
73
.agents/skills/hms-ipd/SKILL.md
Normal file
73
.agents/skills/hms-ipd/SKILL.md
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
---
|
||||
name: hms-ipd
|
||||
description: Use when building, modifying, or testing Inpatient Department (IPD) features, including bed management, admission lifecycle, daily doctor rounds (SOAP), nursing care charting, vital signs monitoring, medication administration, OT/surgery documentation, and discharge workflows.
|
||||
---
|
||||
|
||||
# HMS IPD (Inpatient Department) Management Skill
|
||||
|
||||
This skill guides the agent through the complete Inpatient care lifecycle from admission, ward/bed management, clinical care, nursing charts, to discharge processing in E-Atria HMS.
|
||||
|
||||
---
|
||||
|
||||
## 1. IPD Lifecycle Overview
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
A[Patient Recommended for Admission in OPD/Emergency] --> B[IPD Registration: Bed Allocation & Category Selection]
|
||||
B --> C[Initial Medical Assessment within 24h & Nursing Assessment within 4h]
|
||||
C --> D[Daily Inpatient Care: Rounds, SOAP Notes, Nursing Vitals]
|
||||
D --> E[Procedures / OT Surgery / Diagnostic Orders]
|
||||
E --> F[Accumulation of Daily Inpatient Charges]
|
||||
F --> G[Doctor Approves Discharge & Prepares Discharge Summary]
|
||||
G --> H[Billing Settlement: Final Bill & Clearance]
|
||||
H --> I[Bed Vacated & Cleaned for Next Admission]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. IPD Database Architecture
|
||||
|
||||
| Table Name | Purpose | Key Columns |
|
||||
| :--- | :--- | :--- |
|
||||
| `ipd_master` | Inpatient admission record | `id`, `ipd_no`, `patient_id`, `admission_date`, `admission_time`, `r_doc_id` (admitting consultant), `bed_id`, `department_id`, `status` (`admitted`, `discharged`, `transferred`, `expired`), `discharge_date`, `discharge_time` |
|
||||
| `bed_master` | Hospital bed master | `id`, `bed_name`, `bed_category_id`, `ward_id`, `is_occupied`, `daily_rate` |
|
||||
| `ward_master` | Wards / departments | `id`, `ward_name`, `floor`, `total_beds` |
|
||||
| `bed_assignment_history` | Bed allocation and transfer history | `id`, `ipd_id`, `patient_id`, `bed_id`, `assigned_at`, `released_at`, `transferred_reason` |
|
||||
| `ipd_master_doc_list` | Multiple attending / visiting doctors assigned to an IPD case | `id`, `ipd_id`, `doc_id`, `doc_type` (`primary`, `surgeon`, `anesthetist`, `consultant`) |
|
||||
| `ipd_nursing_entries` | Bedside nursing charts, TPR (Temp, Pulse, Resp), BP, SpO2, I/O chart | `id`, `ipd_id`, `nurse_id`, `entry_time`, `temp`, `pulse`, `resp_rate`, `bp_systolic`, `bp_diastolic`, `spo2`, `blood_sugar`, `intake_oral`, `intake_iv`, `output_urine`, `remarks` |
|
||||
| `nursing_ipd_charges` | Inpatient consumables, nursing procedures, injections, dressing charges | `id`, `ipd_id`, `charge_name`, `qty`, `rate`, `amount`, `charged_at` |
|
||||
| `ipd_discharge` | Master discharge document and final condition | `id`, `ipd_id`, `patient_id`, `discharge_type` (`normal`, `lama`, `referred`, `expired`), `discharge_status`, `follow_up_date` |
|
||||
| `ipd_discharge_templates` | 7 NABH Specialty discharge summary narratives | `id`, `template_name`, `specialty`, `content_structure` |
|
||||
|
||||
---
|
||||
|
||||
## 3. Daily Clinical Rounds & Documentation (SOAP Notes)
|
||||
|
||||
- Every admitted patient requires at least one daily progress note by the attending doctor using the **SOAP Format**:
|
||||
- **S (Subjective)**: Patient symptoms, pain score, oral intake tolerance, night sleep.
|
||||
- **O (Objective)**: Vitals review, physical examination, wound inspection, drain output, lab results.
|
||||
- **A (Assessment)**: Clinical progress (improving, stable, deteriorating), revised differential diagnosis.
|
||||
- **P (Plan)**: Medication orders, IV fluids, lab investigation advice, discharge timeline.
|
||||
- Stored in `ipd_document_templates` / `ipd_discharge_course`.
|
||||
|
||||
---
|
||||
|
||||
## 4. Bed Allocation & Ward Transfers
|
||||
|
||||
- **Atomic Status**: When a bed is assigned in `ipd_master`, `bed_master.is_occupied = 1` must be updated atomically within a database transaction.
|
||||
- **Transfers**: When transferring a patient to another ward/bed (e.g. Ward -> ICU -> Post-Op):
|
||||
- Record release time in `bed_assignment_history` for the old bed (`bed_master.is_occupied = 0`).
|
||||
- Create a new row in `bed_assignment_history` for the new bed (`bed_master.is_occupied = 1`).
|
||||
- Update `ipd_master.bed_id` to the new bed.
|
||||
- Update room tariff in `ipd_invoice_item` starting from the transfer timestamp.
|
||||
|
||||
---
|
||||
|
||||
## 5. Discharge Workflow & Clearance
|
||||
|
||||
1. **Medical Discharge**: Treating doctor drafts and approves the Discharge Summary in `ipd_discharge`.
|
||||
2. **Medication on Discharge**: Prescribe discharge medications with duration and explicit timing.
|
||||
3. **Nursing Clearance**: Removal of IV lines, catheter, surgical dressings, return of unused pharmacy items.
|
||||
4. **Billing Settlement**: Final bill audit, advance adjustment, receipt issuance (`invoice_master`).
|
||||
5. **Gate Pass / Discharge Slip**: Printed with follow-up instructions and emergency contact numbers.
|
||||
6. **Bed Release**: Bed marked as `is_occupied = 0` and flagged for housekeeping sanitization.
|
||||
75
.agents/skills/hms-nabh-compliance/SKILL.md
Normal file
75
.agents/skills/hms-nabh-compliance/SKILL.md
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
---
|
||||
name: hms-nabh-compliance
|
||||
description: Use when building, testing, or auditing hospital workflows for NABH (National Accreditation Board for Hospitals & Healthcare Providers) compliance, including the 13 statutory informed consent forms, initial medical/nursing assessments, clinical audit criteria, SBAR nursing handovers, and discharge summary quality checks.
|
||||
---
|
||||
|
||||
# HMS NABH Accreditation & Clinical Governance Skill
|
||||
|
||||
This skill guides the agent through implementing, maintaining, and auditing hospital processes against **NABH (5th Edition)** hospital accreditation standards in E-Atria HMS.
|
||||
|
||||
---
|
||||
|
||||
## 1. 13 Statutory Informed Consent Templates
|
||||
|
||||
NABH mandates that all procedures, admissions, high-risk interventions, and surgical operations have documented informed consent signed by the patient (or legal guardian) and doctor.
|
||||
|
||||
The 13 statutory templates are seeded in the database via `App\Database\Seeds\Data\IpdDocumentSeedData`:
|
||||
|
||||
| Code | Template Title | Key NABH Mandatory Fields |
|
||||
| :--- | :--- | :--- |
|
||||
| `NABH-IPD-01` | Admission Request & Initial Assessment Form | Provisional diagnosis, primary consultant, vitals, allergy history, patient/attendant declaration |
|
||||
| `NABH-IPD-02` | General Informed Consent for Medical Treatment | Explanation of treatment plan, potential risks, rights of patient, attendant signature |
|
||||
| `NABH-IPD-03` | Informed Consent for Surgical Procedure / Operation | Named procedure, operating surgeon, alternative therapies explained, possibility of conversion/extension |
|
||||
| `NABH-IPD-04` | Informed Consent for Administration of Anesthesia | General / Spinal / Epidural / Regional / Sedation, ASA physical status grade, fasting hours confirmed |
|
||||
| `NABH-IPD-05` | High-Risk Informed Consent | Documented severe comorbidities, ICU requirement, explicit mortality risk disclosure, two witness signatures |
|
||||
| `NABH-IPD-06` | Blood & Blood Component Transfusion Consent | PRBC / FFP / Platelets / Cryoprecipitate, adverse reaction disclosure, right to refuse |
|
||||
| `NABH-IPD-07` | ICU / HDU Admission Informed Consent | Critical care management, central venous line, invasive arterial monitoring, mechanical ventilation |
|
||||
| `NABH-IPD-08` | Discharge Against Medical Advice (DAMA / LAMA) | Declaration acknowledging refusal of medical advice, clinical risks of premature discharge, legal indemnity waiver |
|
||||
| `NABH-IPD-09` | Consent for Bedside / Invasive Diagnostic Procedure | Pleural tap, Ascitic tap, Lumbar puncture, Endoscopy, Bone marrow biopsy |
|
||||
| `NABH-IPD-10` | Refusal of Treatment / Specific Procedure Consent | Informed refusal documentation detailing potential health deterioration resulting from refusal |
|
||||
| `NABH-IPD-11` | Chemotherapy / Specialized Medical Therapy Consent | Chemotherapeutic agents, cycle number, cumulative toxicity, extravasation risk |
|
||||
| `NABH-IPD-12` | Restraint Application Consent | Physical / chemical restraint indication, patient safety rationale, alternative interventions attempted |
|
||||
| `NABH-IPD-13` | Release of Medical Information / Records Consent | Third-party insurance / TPA disclosure authorization, medico-legal release |
|
||||
|
||||
---
|
||||
|
||||
## 2. Inpatient Clinical Care Standards (COP - Care of Patients)
|
||||
|
||||
1. **Initial Assessment Timelines**:
|
||||
- **Doctor Assessment**: Must be completed within **24 hours** of admission (or immediately in Emergency/ICU). Contains past history, allergies, personal history, systemic examination, provisional diagnosis, and initial care plan.
|
||||
- **Nursing Assessment**: Must be completed within **2 to 4 hours** of admission. Contains nutritional screening, fall risk assessment (Morse Fall Scale / Hendrich II), pressure ulcer risk assessment (Braden Scale), and pain assessment.
|
||||
2. **Nursing Handover Protocol (SBAR)**:
|
||||
- Shift handovers must adhere to the **SBAR Framework**:
|
||||
- **S (Situation)**: Patient name, age, bed no, admitting consultant, current diagnosis.
|
||||
- **B (Background)**: Admission date, surgical history, known allergies, baseline vitals.
|
||||
- **A (Assessment)**: Current shift vitals, pain status, abnormal lab values, pending reports.
|
||||
- **R (Recommendation)**: Pending doctor orders, next medication doses, scheduled scans.
|
||||
3. **Medication Administration & Safety (MOM)**:
|
||||
- High-alert medications (e.g. Concentrated Electrolytes, Insulins, Anticoagulants, Chemotherapy) must require **double-nursing check** before administration.
|
||||
- Look-Alike Sound-Alike (LASA) drugs must be segregated with tall-man lettering.
|
||||
|
||||
---
|
||||
|
||||
## 3. Discharge Summary Quality Standard (AAC - Access, Assessment & Continuity of Care)
|
||||
|
||||
Under NABH, a discharge summary is a medico-legal document. It must be handed over to the patient at the time of discharge and contain:
|
||||
1. Hospital UHID, IPD Number, Admission Date & Time, Discharge Date & Time.
|
||||
2. Admitting Consultant, Department, and Operating Surgeon (if surgical).
|
||||
3. Primary & Secondary Final Diagnoses with ICD-10 codes.
|
||||
4. Reason for Admission & Brief Clinical History.
|
||||
5. Key Physical Findings on Admission.
|
||||
6. Summary of Pertinent Laboratory, Imaging & Diagnostic Reports.
|
||||
7. Detailed Hospital Course, Surgical Procedures with Operative Findings.
|
||||
8. Patient's Condition at Discharge (Vitals, Wound Status, Ambulation).
|
||||
9. Discharge Medication Chart (Generic Name, Strength, Dosage, Route, Frequency, Duration).
|
||||
10. Urgent Warning Signs / Emergency Red Flags (e.g., severe chest pain, breathlessness, sudden high fever, wound bleeding).
|
||||
11. Scheduled Follow-up Date, Time, and OPD Room / Consultant Name.
|
||||
12. Treating Consultant Doctor's Name, Qualifications, and Signature.
|
||||
|
||||
---
|
||||
|
||||
## 4. Digital Scans & Document Archiving (`nabh_ipd_scans`)
|
||||
|
||||
- Physical signed consent forms, outside lab reports, and signed anesthetic fitness sheets uploaded via `DoctorDocument.php` are stored in `nabh_ipd_scans`.
|
||||
- Categorized strictly by standard NABH code (`NABH-IPD-01` to `13`).
|
||||
- Linked to `ipd_id`, `patient_id`, `uploaded_by`, and timestamped for clinical audit trail.
|
||||
71
.agents/skills/hms-pathology/SKILL.md
Normal file
71
.agents/skills/hms-pathology/SKILL.md
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
---
|
||||
name: hms-pathology
|
||||
description: Use when working on laboratory investigations, pathology test masters, panels/profiles, normal reference intervals, LOINC coding, sample collection workflows, barcode tracking, result entry, pathologist authorization, and lab report generation.
|
||||
---
|
||||
|
||||
# HMS Pathology & Laboratory Management Skill
|
||||
|
||||
This skill guides the agent through managing clinical pathology test masters, multi-parameter panels, specimen collection, result verification, and report publication in E-Atria HMS.
|
||||
|
||||
---
|
||||
|
||||
## 1. Laboratory Data Model
|
||||
|
||||
| Table Name | Description | Key Fields |
|
||||
| :--- | :--- | :--- |
|
||||
| `investigation` | Master catalog of single lab tests and investigation profiles | `id`, `name`, `cat`, `rate`, `normal_range`, `unit`, `method`, `loinc_code`, `status` |
|
||||
| `invprofiles` | Multi-test profiles (e.g., CBC, LFT, KFT, Lipid Profile, Thyroid Panel) | `id`, `profile_name`, `profile_code`, `total_rate`, `category_id` |
|
||||
| `lab_tests` | Specific test parameters within a profile/department | `id`, `test_name`, `group_id`, `default_unit`, `male_min`, `male_max`, `female_min`, `female_max`, `child_min`, `child_max`, `loinc_num` |
|
||||
| `lab_rgroups` | Report groups / sub-headings (e.g., Differential Leukocyte Count in CBC) | `id`, `group_name`, `dept_id`, `display_order` |
|
||||
| `lab_request` | Patient lab order requisition generated from OPD/IPD | `id`, `patient_id`, `doctor_id`, `opd_id`, `ipd_id`, `order_date`, `status`, `barcode_no` |
|
||||
| `lab_request_item` | Individual investigations ordered in a `lab_request` | `id`, `lab_request_id`, `investigation_id`, `status` (`pending`, `collected`, `reported`, `approved`) |
|
||||
| `lab_repo` | Published test report header | `id`, `lab_request_id`, `patient_id`, `approved_by`, `report_date`, `verified_status` |
|
||||
| `lab_repotests` | Recorded numerical or textual values for each parameter | `id`, `lab_repo_id`, `test_id`, `result_value`, `unit`, `reference_range`, `is_abnormal` |
|
||||
|
||||
---
|
||||
|
||||
## 2. Standard Pathology Workflow
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
A[Doctor Prescribes Lab Test in OPD/IPD] --> B[Billing / Lab Cashier Generates Invoice & Barcode]
|
||||
B --> C[Phlebotomy: Sample Collection & Specimen Labeling]
|
||||
C --> D[Laboratory Processing / Machine Analyzer Run]
|
||||
D --> E[Technologist Result Entry in HMS]
|
||||
E --> F{Values within Normal Limits?}
|
||||
F -->|Out of Range| G[Flag Critical / Panic Values in Red]
|
||||
F -->|Normal| H[Standard Value Presentation]
|
||||
G --> I[Pathologist Review & Digital Signature]
|
||||
H --> I
|
||||
I --> J[Final PDF Report Published & Synced to ABDM/PHR]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. Reference Ranges & Critical Values
|
||||
|
||||
1. **Demographic Range Splitting**:
|
||||
- Reference ranges vary by patient age and gender.
|
||||
- For CBC (Hemoglobin):
|
||||
- Adult Male: 13.0 – 17.0 g/dL
|
||||
- Adult Female: 12.0 – 15.0 g/dL
|
||||
- Infant / Child: 11.0 – 14.0 g/dL
|
||||
2. **Panic / Critical Limit Alerts**:
|
||||
- Panic values (e.g. Potassium < 2.5 or > 6.5 mmol/L, Platelets < 20,000 /µL, Blood Sugar < 50 or > 450 mg/dL) must trigger immediate verbal notification to the treating physician and be flagged on the report.
|
||||
|
||||
---
|
||||
|
||||
## 4. LOINC & ABDM Diagnostics Standards
|
||||
|
||||
- Every test in `lab_tests` must be linked to its NRCeS/LOINC identifier (e.g., CBC Profile: `58410-2`, Fasting Blood Sugar: `1558-6`, Serum Creatinine: `2160-0`).
|
||||
- Generated FHIR bundles must use `DiagnosticReport` profile:
|
||||
- `https://nrces.in/ndhm/fhir/r4/StructureDefinition/DiagnosticReportLab`
|
||||
- Observation resources for each component parameter must include LOINC coding and UCUM units (`mg/dL`, `g/dL`, `mmol/L`, `/uL`).
|
||||
|
||||
---
|
||||
|
||||
## 5. Report Header, Signatures & Printing
|
||||
|
||||
- Report headers must display Hospital Name, Accreditation logos (NABH/NABL if applicable), Barcode, Sample Collected Date/Time, and Report Authorized Date/Time.
|
||||
- The reporting pathologist's digital signature, qualifications (MBBS, MD Path), and council registration number must appear at the bottom right.
|
||||
- Patient full name must be fetched from `patient_master.p_fname`.
|
||||
58
.agents/skills/hms-radiology/SKILL.md
Normal file
58
.agents/skills/hms-radiology/SKILL.md
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
---
|
||||
name: hms-radiology
|
||||
description: Use when building, modifying, or testing radiology reporting, modality configurations (USG, X-Ray, CT, MRI, ECHO), structured clinical templates, findings, impressions, DICOM/PACS attachments, and radiologist sign-off workflows.
|
||||
---
|
||||
|
||||
# HMS Radiology & Diagnostic Imaging Management Skill
|
||||
|
||||
This skill guides the agent through managing radiology reporting templates, imaging modalities, structured clinical findings, impressions, and report printing in E-Atria HMS.
|
||||
|
||||
---
|
||||
|
||||
## 1. Radiology Architecture & Modalities
|
||||
|
||||
The HMS categorizes diagnostic imaging under `radiology_modality` and structured templates in `opd_clinical_templates` / `doc_print_templates`:
|
||||
|
||||
| Modality Code | Modality Name | Common Procedures | Template Pattern |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| `USG` | Ultrasonography | Whole Abdomen, KUB, Pelvis, Obstetrics / Antenatal, Thyroid, Scrotum | Organ-by-organ evaluation (Liver, Gall Bladder, Spleen, Pancreas, Kidneys, Bladder, Uterus) |
|
||||
| `XR` | Digital X-Ray | Chest PA, Spine (Cervical, Lumbar, Dorsal), Extremities, Skull | Bony cage, lung parenchyma, mediastinum, cardiothoracic ratio, soft tissues |
|
||||
| `CT` | Computed Tomography | NCCT/CECT Head, CECT Abdomen & Pelvis, HRCT Chest, CT Angiography | Protocol, slice thickness, attenuation, parenchymal findings, 3D reconstructions |
|
||||
| `MRI` | Magnetic Resonance | MRI Brain, MRI Spine (C/D/L), Musculoskeletal Joints (Knee, Shoulder) | Sequences (T1, T2, FLAIR, DWI), signal intensity, disc bulges, cord signals |
|
||||
| `ECHO` | 2D Echocardiography | 2D Echo with Doppler | Chamber dimensions, ejection fraction (EF%), valve morphology, wall motion analysis |
|
||||
|
||||
---
|
||||
|
||||
## 2. Standard 5-Section Reporting Structure
|
||||
|
||||
Every radiology report generated in the HMS must follow a standard structured clinical format:
|
||||
|
||||
1. **Clinical History & Indication**:
|
||||
- Reason for scan (e.g. "Acute right lower quadrant pain, rule out appendicitis", "Dry cough with fever x 2 weeks").
|
||||
2. **Technique / Protocol**:
|
||||
- Modality details (e.g. "Real-time high-resolution gray scale and color Doppler examination performed using 3.5 MHz convex and 7.5 MHz linear probes").
|
||||
3. **Observations & Findings**:
|
||||
- Systematic description of all evaluated structures.
|
||||
- Normal organs must have standard negative findings (e.g. "Liver is normal in size and acoustic texture. No focal mass lesion or intrahepatic biliary radicle dilatation").
|
||||
- Pathological lesions must state exact anatomical location, size (in mm/cm), margins, echogenicity/attenuation, and vascularity.
|
||||
4. **Impression / Conclusion**:
|
||||
- Concise diagnostic synthesis (e.g. "Ultrasonographic features suggestive of Acute Calculous Cholecystitis with mild pericholecystic fluid").
|
||||
5. **Recommendations / Follow-up**:
|
||||
- Further clinical advice (e.g. "Clinical and surgical correlation suggested. MRCP recommended if common bile duct stone is suspected").
|
||||
|
||||
---
|
||||
|
||||
## 3. Database Tables & Template Storage
|
||||
|
||||
- `radiology_modality`: Modality master (`id`, `modality_code`, `modality_name`, `is_active`).
|
||||
- `radiology_ultrasound_template`: Built-in organ narrative templates for rapid reporting.
|
||||
- `opd_clinical_templates`: Customizable rich-text templates with placeholders (`{{PATIENT_NAME}}`, `{{AGE}}`, `{{GENDER}}`, `{{DATE}}`, `{{REFERRING_DOCTOR}}`).
|
||||
- `doc_print_templates`: Printable formats with letterhead/plain paper configurations.
|
||||
|
||||
---
|
||||
|
||||
## 4. Radiologist Digital Authorization & Sign-off
|
||||
|
||||
- Draft reports are saved with `status = 'draft'` and editable by resident doctors / technicians.
|
||||
- Only registered Radiologists (`doctor_master` with specialization in Radiology / Radio-diagnosis) can approve and publish (`status = 'final'`).
|
||||
- The final PDF includes the Radiologist's name, qualifications (MD Radio-diagnosis / DMRD), Medical Council Registration Number, and digital signature watermark.
|
||||
14
AGENTS.md
14
AGENTS.md
|
|
@ -16,3 +16,17 @@ For all ABDM (Ayushman Bharat Digital Mission) development, linking, Care Contex
|
|||
- **DO NOT** use, select, update, or reference `patient_master.p_lname` anywhere in the application.
|
||||
- Note: For doctors, `doctor_master` continues to use `p_fname`, `p_mname`, and `p_lname`.
|
||||
|
||||
## HMS Core & Clinical Standards
|
||||
For all Hospital Management System (HMS) development, billing, diagnostics, inpatient care, and NABH compliance:
|
||||
- **Billing Standards**: Follow [.agents/rules/hms_billing_standards.md](file:///d:/Workplace/HMS_CI4_OLD/.agents/rules/hms_billing_standards.md) (Net = Total - Discount + Tax; Paid must equal sum of `payment_history`).
|
||||
- **Clinical Standards**: Follow [.agents/rules/hms_clinical_standards.md](file:///d:/Workplace/HMS_CI4_OLD/.agents/rules/hms_clinical_standards.md) (LOINC for pathology, SNOMED CT for OPD, 5-section radiology structure).
|
||||
- **NABH Standards**: Follow [.agents/rules/nabh_compliance_rules.md](file:///d:/Workplace/HMS_CI4_OLD/.agents/rules/nabh_compliance_rules.md) (13 statutory consent forms `NABH-IPD-01` to `13`, 24h initial assessment, SOAP daily rounds, 11-point discharge summary checklist).
|
||||
|
||||
### HMS Module Skills Available:
|
||||
- [`hms-billing`](file:///d:/Workplace/HMS_CI4_OLD/.agents/skills/hms-billing/SKILL.md) — OPD, IPD, Diagnostics, Pharmacy billing and ledger integrity.
|
||||
- [`hms-pathology`](file:///d:/Workplace/HMS_CI4_OLD/.agents/skills/hms-pathology/SKILL.md) — Lab tests, panels, reference ranges, barcode workflow, and report publishing.
|
||||
- [`hms-radiology`](file:///d:/Workplace/HMS_CI4_OLD/.agents/skills/hms-radiology/SKILL.md) — Imaging modalities, structured reporting, findings, and impressions.
|
||||
- [`hms-ipd`](file:///d:/Workplace/HMS_CI4_OLD/.agents/skills/hms-ipd/SKILL.md) — Inpatient admission, bed management, SOAP notes, and discharge workflows.
|
||||
- [`hms-nabh-compliance`](file:///d:/Workplace/HMS_CI4_OLD/.agents/skills/hms-nabh-compliance/SKILL.md) — NABH 5th edition consent forms, nursing handovers, and clinical governance.
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,11 @@ class HmsInstall extends BaseCommand
|
|||
CLI::write("Medical templates seeding notice: " . $e->getMessage(), 'yellow');
|
||||
}
|
||||
|
||||
// 8. Success Banner
|
||||
// 8. Ensure Single Doctor ('Dr. Demo')
|
||||
CLI::write("Configuring Single Doctor ('Dr. Demo')...", 'yellow');
|
||||
$this->ensureSingleDemoDoctor($db);
|
||||
|
||||
// 9. Success Banner
|
||||
CLI::write("\n==================================================", 'green');
|
||||
CLI::write(" HMS Installation Completed! ", 'green');
|
||||
CLI::write("==================================================", 'green');
|
||||
|
|
@ -366,4 +370,79 @@ class HmsInstall extends BaseCommand
|
|||
$db->table('hospital_setting')->insert(['s_name' => $key, 's_value' => $value]);
|
||||
}
|
||||
}
|
||||
|
||||
private function ensureSingleDemoDoctor($db): void
|
||||
{
|
||||
try {
|
||||
if (! $db->tableExists('doctor_master')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove any extra doctors (keep only ID 1)
|
||||
$db->table('doctor_master')->where('id >', 1)->delete();
|
||||
|
||||
if ($db->tableExists('doc_spec')) {
|
||||
$db->table('doc_spec')->where('doc_id >', 1)->delete();
|
||||
}
|
||||
if ($db->tableExists('doc_opd_fee')) {
|
||||
$db->table('doc_opd_fee')->where('doc_id >', 1)->delete();
|
||||
}
|
||||
if ($db->tableExists('doc_ipd_fee')) {
|
||||
$db->table('doc_ipd_fee')->where('doc_id >', 1)->delete();
|
||||
}
|
||||
if ($db->tableExists('finance_doctor_agreements')) {
|
||||
$db->table('finance_doctor_agreements')->emptyTable();
|
||||
}
|
||||
|
||||
// Ensure Doctor ID 1 is configured with Name 'Dr. Demo'
|
||||
$doc1 = $db->table('doctor_master')->where('id', 1)->get()->getRowArray();
|
||||
if ($doc1) {
|
||||
$db->table('doctor_master')->where('id', 1)->update([
|
||||
'p_title' => 'Dr.',
|
||||
'p_fname' => 'Demo',
|
||||
'p_mname' => null,
|
||||
'p_lname' => null,
|
||||
'doc_sign' => 'MBBS, MD',
|
||||
'active' => '1',
|
||||
]);
|
||||
} else {
|
||||
$db->table('doctor_master')->insert([
|
||||
'id' => 1,
|
||||
'p_code' => 0,
|
||||
'p_title' => 'Dr.',
|
||||
'p_fname' => 'Demo',
|
||||
'p_mname' => null,
|
||||
'p_lname' => null,
|
||||
'doc_sign' => 'MBBS, MD',
|
||||
'mphone1' => '9876543210',
|
||||
'doctor_reg_no' => 'REG12345',
|
||||
'gender' => '1',
|
||||
'dob' => '1980-01-01',
|
||||
'email1' => 'demo@e-atria.com',
|
||||
'active' => '1',
|
||||
'login_pin' => '1234',
|
||||
'profile_photo' => '1',
|
||||
'opd_print_format' => 'printonletterhead',
|
||||
'opd_blank_print' => 'printonletterhead',
|
||||
'opd_valid_no_days'=> 5,
|
||||
'device_code' => '974852',
|
||||
]);
|
||||
}
|
||||
|
||||
// Ensure valid medical speciality for Doctor 1
|
||||
if ($db->tableExists('doc_spec')) {
|
||||
$specCount = $db->table('doc_spec')->where('doc_id', 1)->countAllResults();
|
||||
if ($specCount === 0) {
|
||||
$db->table('doc_spec')->insert([
|
||||
'doc_id' => 1,
|
||||
'med_spec_id' => 61,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
CLI::write("Single doctor 'Dr. Demo' (ID: 1) successfully configured.", 'green');
|
||||
} catch (\Throwable $e) {
|
||||
CLI::write("Demo doctor configuration notice: " . $e->getMessage(), 'yellow');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Loading…
Reference in New Issue
Block a user