Clinical Workflows

Clinical Workflows & Emergency Care Specifications

1. Outpatient Department (OPD) Workflows

The Outpatient Department operates as a high-throughput, distributed queueing environment. The system models the outpatient lifecycle using an explicit state machine attached to the Encounter domain object.

1.1 The Outpatient State Machine

Rendering Chart

1.2 Triage & Clinical Risk Stratification

The triage module requires the collection of fundamental physiological markers. The system evaluates these markers in real time to calculate an automated Modified Early Warning Score (MEWS), which determines queue prioritization over a standard First-In-First-Out (FIFO) approach.

ParameterCritical Low (+3)Moderate Low (+2)Mild Low (+1)Normal (0)Mild High (+1)Moderate High (+2)Critical High (+3)
Systolic BP≤7071−8081−100101−199N/A≥200N/A
Heart RateN/A≤4041−5051−100101−110111−129≥130
Resp RateN/A≤8N/A9−1415−2021−29≥30
Temp (°C)N/A≤35.0N/A35.1−37.537.6−38.4≥38.5N/A

System Action Guardrail: Any encounter yielding a total aggregated MEWS score >5 trigger an immediate visual flash on all active nursing monitors, an audio alert at the nursing station, and automatically bumps the patient to position #1 in the clinician's consultation queue with an EMERGENCY_PRIORITY flag.

2. Inpatient Department (IPD) Workflows

The transition to the Inpatient Department moves the patient from a transactional encounter model to a continuous monitoring environment.

2.1 Admission, Bed Allocation, and Transfers

An admission request from an outpatient clinician creates an entry in the Central Bed Tracker.

  • Ward Allocation: Wards are categorized structurally (e.g., Male Medical, Female Surgical, Paediatric, Maternity, Isolation).
  • Bed Lock Mechanism: When an inpatient nurse clicks "Allocate Bed," a Redis key lock is established with a 15-minute TTL: lock🛏ward_id:bed_num. This prevents multiple ward teams from assigning different patients to the same physical asset during emergencies.
  • Financial State Shift: Upon bed confirmation, the billing framework switches the financial session's parameters. Daily bed charges, standard nursing procedure levies, and continuous medication consumption models are activated automatically.

2.2 Continuous Inpatient Monitoring Loops

The active inpatient record is anchored around the electronic Medication Administration Record (eMAR) and fluid balance sheets.

(To be reviewed)

eMAR Validation Loop: Medication administration requires a three-point barcode match scanned at the bedside:

1.Patient Wristband Barcode (Validates patient_id).
2.Nurse ID Badge Barcode (Validates user_id permissions).
3.Unit-Dose Medication Wrap Barcode (Validates item_batch_id and dosage matching the active order).

Fluid Balance Tracking: The system enforces strict fluid intake (intravenous lines, oral fluids, nasogastric inputs) versus output tracking (urine volume, surgical drains, emesis) for specialized cases like renal failure or post-abdominal operations.

3. High-Intensity Care: ICU & HDU State Engines

The Intensive Care Unit (ICU) and High Dependency Unit (HDU) represent the highest density of clinical data ingestion within the HMIS architecture.

Rendering Chart

3.1 Automated SOFA Scoring Execution

Every 24 hours at exactly 23:59 hours, the system triggers a background cron job for all active ICU/HDU billing sessions to calculate the Sequential Organ Failure Assessment (SOFA) score based on structured laboratory inputs and vital statistics:

  • Respiratory System: $PaO_2 / FiO_2$ ratio extracted from blood gas lab parameters.
  • Cardiovascular System: Mean Arterial Pressure (MAP) and active vasopressor dosage rates (Dopamine, Epinephrine, Norepinephrine) pulled from the eMAR records.
  • Hepatic/Renal: Bilirubin and Creatinine values gathered directly from the chemistry analyzer network interface.

4. Emergency Room (ER) & Code Red Integration

The Emergency Room breaks traditional front-office registration boundaries to preserve life.

4.1 The "John Doe / Jane Doe" Protocol

When a patient arrives unconscious or without identification documents during a trauma event, the ER clerk or triage nurse can activate the Emergency Bypass Protocol:

import uuid
from datetime import datetime

def initialize_emergency_anonymous_patient(assigned_gender: str, approximate_age: int) -> dict:
    """
    Creates an emergency pseudo-identity record allowing clinical ordering 
    to proceed instantly before demographic verification occurs.
    """
    unique_trauma_token = f"TRM-{datetime.now().strftime('%Y%m%d')}-{uuid.uuid4().hex[:6].upper()}"
    
    emergency_patient = {
        "mpi_id": str(uuid.uuid4()),
        "is_anonymous": True,
        "first_name": "Unknown",
        "last_name": unique_trauma_token,
        "gender": assigned_gender,
        "estimated_age": approximate_age,
        "created_at": datetime.now().isoformat(),
        "billing_override": "EMERGENCY_ECCIF_ELIGIBLE"
    }
    
    # Save to database and instantly broadcast to Lab, Radiology, and Blood Bank queues
    save_to_db(emergency_patient)
    initialize_emergency_billing_session(emergency_patient["mpi_id"])
    return emergency_patient

4.2 Financial Suspension Boundaries during Trauma

When the code red flag is active on an encounter:

  • All validation check gates inside the Laboratory Information System (LIS) and Radiology Information System (RIS) are bypassed.
  • Blood unit matches can be signed out with zero upfront verification of payment or insurance state.
  • The system logs all accrued liabilities to an automated background holding ledger labeled under the Emergency, Chronic, and Critical Illness Fund (ECCIF) framework for retrospective reconciliation once the patient is stabilized or identified.

5. Medical Standards Compliance

To enable long-term statutory compliance and semantic interoperability with national systems, data structures are strict and validated at the API layer.

5.1 WHO ICD-11 Integration Blueprint

Free-text diagnostic entry is prohibited within clinician consultation logs. The diagnostics interface utilizes a typeahead lookup integrated into the official WHO ICD-11 linearizations:

{
  "encounter_id": "enc_334102941",
  "diagnosis_type": "PRIMARY",
  "icd11_code": "1B10",
  "icd11_uri": "http://id.who.int/icd/entity/578689142",
  "title": "Tuberculosis of respiratory system",
  "confirmed_by_clinician": true,
  "mapping_metadata": {
    "legacy_icd10_fallback": "A16.2",
    "moh_711_category": "Tuberculosis_Cases"
  }
}

5.2 HL7 FHIR Observation Profile Mapping

Every recorded clinical vital sign map dynamically to an HL7 FHIR Observation resource type before state serialization:JSON{

{
  "resourceType": "Observation",
  "id": "obs_vitals_9921",
  "status": "final",
  "category": [
    {
      "coding": [
        {
          "system": "http://terminology.hl7.org/CodeSystem/observation-category",
          "code": "vital-signs",
          "display": "Vital Signs"
        }
      ]
    }
  ],
  "code": {
    "coding": [
      {
        "system": "http://loinc.org",
        "code": "8867-4",
        "display": "Heart rate"
      }
    ]
  },
  "subject": {
    "reference": "Patient/pat_019234812_mpi"
  },
  "effectiveDateTime": "2026-06-21T21:45:00+03:00",
  "valueQuantity": {
    "value": 78,
    "unit": "beats/minute",
    "system": "http://unitsofmeasure.org",
    "code": "/min"
  }
}
Author: Ian Wataka - Backend Developer
Target Scope: Level 4 Hospital Production Infrastructure