Digital Twin Documentation

Digital Twin is an AI-driven clinical simulation engine — Train on Digital Twins. It creates a dynamic, physiology-based virtual replica of a patient. This wiki covers everything you need to understand how the system works.

Content managed via CMS Dashboard

01 Overview

The Real-Time Patient Digital Twin Generator is an AI-driven clinical simulation engine that creates a dynamic, physiology-based virtual replica of a patient.

RT-PDTG is designed for medical education — students, residents, and healthcare professionals can practice clinical decision-making in a safe, interactive environment. Unlike text-based case studies, the system simulates real-time physiological responses to disease progression and clinical interventions.

Key Principle

This is not a chatbot case generator. The system behaves causally — outputs are derived from modeled physiology rather than static scripts. Every vital sign, lab value, and system status is computed from interconnected physiological equations.

The platform covers 7 medical specialties with 90+ enriched patient cases, simulates 13 real-time vitals with live trend charts, tracks 5 physiological systems, renders 15 dynamic ECG waveform patterns, and provides comprehensive post-simulation evaluation with in-app adaptive learning.

02 How It Works

The simulation engine operates on a continuous 1-second tick cycle. Each tick, the physiology engine:

  1. Calculates disease progression — the underlying condition advances based on time and severity
  2. Applies intervention effects — any medications, fluids, or procedures modify physiological variables
  3. Computes interdependencies — changes cascade across interconnected systems (e.g., hypotension → renal failure)
  4. Updates vitals — all 13 monitored parameters are recalculated and displayed
  5. Evaluates system status — each of the 5 physiological systems is classified as Normal, Stressed, or Critical

Simulation Speed

The simulation runs in real-time by default (1 second = 1 simulated second). You can activate 5x fast-forward mode to accelerate disease progression and see the effects of your interventions more quickly.

03 User Flow

1Sign In / RegisterCreate an account or sign in. Guest access available for quick exploration
2Select SpecialtyChoose from 7 medical specialties and set difficulty level
3Select PatientBrowse official, custom, or shared cases. Review full patient history
4Monitor & TreatAdminister meds, order labs, apply procedures while monitoring live vitals
5Get EvaluatedReceive a debrief with score, reasoning analysis, and evidence-based feedback
6ImproveAccess personalized MCQs, flashcards, and clinical notes

04 Physiology Engine

The physiology engine is the heart of RT-PDTG. It uses a deterministic + probabilistic modeling approach, functioning as a state machine where each patient state is computed from the previous state plus environmental changes.

  • Structured Patient State Object — All data stored in a JSON-based state object with vitals, system statuses, active medications, and history
  • Parametrized Disease Models — Each specialty case has modeled progression rates, severity curves, and expected physiological impacts
  • Continuous Time Simulation — 1-second simulation ticks ensure smooth, realistic vital sign changes
  • Event-Driven Architecture — State changes emit events that trigger UI updates, log entries, and cascade effects

05 Vitals & Parameters

The system monitors 13 physiological parameters in real time:

VitalKeyUnitDescription
Heart RatehrbpmCardiac rhythm frequency
Blood Pressuresbp/dbpmmHgSystolic/diastolic arterial pressure
Mean Arterial PressuremapmmHgAverage pressure during cardiac cycle
Cardiac OutputcoL/minVolume of blood pumped per minute
SpO₂spo2%Peripheral oxygen saturation
PaO₂pao2mmHgPartial pressure of arterial oxygen
PaCO₂paco2mmHgPartial pressure of arterial CO₂
Respiratory Raterr/minBreaths per minute
Temperaturetemp°CCore body temperature
GCSgcs3–15Glasgow Coma Scale
Lactatelactatemmol/LTissue hypoperfusion marker
Creatininecreatininemg/dLRenal function marker
Glucoseglucosemg/dLBlood glucose level

06 Interdependency Modeling

The engine models causal relationships between physiological variables. When one parameter changes, it cascades to affect others:

  • Hypotension → Renal Failure — MAP below 65 mmHg reduces renal perfusion, causing creatinine to rise
  • Hypoxia → Tachycardia — SpO₂ below 90% triggers compensatory heart rate increase and metabolic acidosis
  • Insulin → Glucose + Potassium — Insulin administration drops glucose and shifts potassium intracellularly
  • Rising Creatinine → Hyperkalemia — Renal failure prevents potassium excretion
  • Low GCS → Respiratory Instability — Decreased consciousness impairs respiratory drive

Clinical Significance

These cascades mirror real clinical scenarios. For example, in sepsis: infection → vasodilation → hypotension → renal hypoperfusion → rising lactate + creatinine → multi-organ dysfunction.

07 Physiological Systems

Five organ systems are continuously monitored and classified into three states:

  • 🟢 Normal — Parameters within acceptable range
  • 🟡 Stressed — Compensatory mechanisms active, early warning
  • 🔴 Critical — System failure imminent, requires immediate intervention

Cardiovascular

Monitors HR, BP, MAP, and cardiac output. Detects arrhythmias, shock states, and hemodynamic instability.

Respiratory

Tracks SpO₂, PaO₂, PaCO₂, and RR. Detects hypoxemia, hypercapnia, and respiratory failure.

Renal

Monitors creatinine and urine output. Detects acute kidney injury and electrolyte disturbances.

Endocrine

Tracks glucose and metabolic markers. Detects DKA, hypoglycemia, and metabolic derangements.

Neurological

Monitors GCS and mental status. Detects altered consciousness, seizure risk, and herniation.

08 Medical Specialties

Each specialty features unique case presentations, pathology models, and expected management protocols:

Emergency MedicineCardiologyPulmonologyEndocrinologyNeurologyNephrologySepsis / Infectious Disease

Example Cases

  • Cardiology — STEMI: ST-elevation MI with chest pain, ECG changes, troponin elevation
  • Pulmonology — Pulmonary Embolism: Acute dyspnea, hypoxemia, tachycardia
  • Endocrinology — DKA: Diabetic ketoacidosis with hyperglycemia, metabolic acidosis
  • Sepsis — Septic Shock: Systemic infection with SIRS criteria, organ dysfunction cascade
  • Emergency — Hemorrhagic Shock: Trauma with blood loss, tachycardia, hypotension
  • Neurology — Stroke: Acute focal deficit with altered GCS, BP management
  • Nephrology — AKI: Acute kidney injury with rising creatinine, hyperkalemia

09 Intervention Engine

The intervention engine allows users to manage the virtual patient through 6 categories:

  • Medications — Dose-based drugs with onset delay, peak effects, and duration
  • IV Fluids — Crystalloids and colloids affecting intravascular volume
  • Procedures — Intubation, chest tube, CPR, defibrillation
  • Oxygen Therapy — Nasal cannula, face mask, non-rebreather, BiPAP
  • Imaging — X-Ray, CT, MRI, Ultrasound with case-specific findings
  • Lab Orders — CBC, BMP, ABG, Troponin, Blood Culture, etc.

10 Medications

Each medication has a modeled pharmacological profile:

MedicationRoutePrimary EffectKey Consideration
AspirinPOAntiplatelet, reduces clot propagationFirst-line for ACS
NitroglycerinSLVasodilation, reduces BP and preloadContraindicated in RV infarct
MorphineIVAnalgesic, reduces HR and preloadRisk of respiratory depression
HeparinIVAnticoagulationDose-dependent bleeding risk
Insulin RegularIVGlucose reduction, K⁺ shiftRisk of hypoglycemia
EpinephrineIVVasopressor, increases HR/BPArrhythmia risk at high doses
AtropineIVIncreases heart rate (vagolytic)First-line for bradycardia
AmiodaroneIVAnti-arrhythmicRisk of hypotension with bolus

11 Adverse Events

The system simulates adverse events when medications are mismanaged:

  • Morphine Overdose — Respiratory depression (RR drops significantly, SpO₂ falls)
  • Insulin-Induced Hypoglycemia — Glucose drops below 60 mg/dL, altered consciousness
  • Epinephrine Arrhythmia — Excessive catecholamine causes tachyarrhythmia
  • Nitroglycerin Hypotension — Over-vasodilation causing dangerous BP drop
  • Heparin Bleeding — Excessive anticoagulation risk

Learning Opportunity

Adverse events are displayed as red overlay alerts. They teach students about medication safety, dose-response relationships, and the consequences of clinical errors — all without harming real patients.

12 Lab & Imaging Orders

Users can order diagnostic tests that produce case-specific results after a realistic processing delay:

Laboratory Tests

  • CBC — Complete Blood Count (WBC, Hgb, Platelets)
  • BMP — Basic Metabolic Panel (Na, K, BUN, Creatinine, Glucose)
  • Troponin — Cardiac biomarker (elevated in MI)
  • ABG — Arterial Blood Gas (pH, PaO₂, PaCO₂, HCO₃⁻)
  • D-Dimer — Coagulation marker (elevated in PE, DVT)
  • Blood Culture — Microbiological culture for sepsis workup

Imaging Studies

  • Chest X-Ray — PA & lateral views for pulmonary/cardiac pathology
  • CT Scan — Computed tomography for detailed cross-sectional imaging
  • CT Pulmonary Angiography — CTPA for pulmonary embolism diagnosis
  • MRI — Magnetic resonance for soft tissue detail
  • Ultrasound / FAST — Focused assessment for trauma and effusions
  • 12-Lead ECG — Electrocardiogram for rhythm and ischemia analysis

13 Dynamic ECG Monitor

The ECG monitor renders diagnosis-specific waveforms in real time using Gaussian pulse synthesis. Each patient case has a mapped ECG pattern.

ECG Pattern Types (15 total)

PatternConditionKey Visual Features
Normal SinusHealthy rhythmRegular P-QRS-T complexes
STEMI (Inferior)Inferior MIST elevation leads II, III, aVF
STEMI (Anterior)Anterior MILarge ST elevation V1-V4
ST DepressionNSTEMI / IschemiaDownsloping ST depression
Atrial FibrillationAF with RVRNo P waves, irregular R-R intervals
Ventricular FibrillationCardiac arrestChaotic, no identifiable waves
LBBBSTEMI equivalentWide QRS, inverted T wave
Ventricular TachycardiaWide complex tachyWide bizarre QRS, regular
Atrial FlutterSawtooth patternSawtooth baseline, regular QRS
Diffuse ST ElevationPericarditisConcave-up ST in all leads

Dynamic Features

  • Heart Rate Response — Waveform speed scales with live HR
  • R-R Irregularity — AFib shows truly irregular beat spacing (35% variability)
  • Baseline Wander — VFib/AFib patterns include fibrillatory noise
  • QRS Width Variation — LBBB and VT patterns show widened QRS complexes
  • Leading Dot Glow — Green glow dot follows the current trace position

The dashboard includes real-time trend charts for four critical vitals, rendered using HTML Canvas:

  • Heart Rate (HR) — Red line chart with alert zones at <50 and >120 bpm
  • Blood Pressure (BP) — Dual orange lines showing systolic + diastolic
  • SpO₂ — Cyan line chart with alert zone below 92%
  • Respiratory Rate (RR) — Green line chart with alert zones at <10 or >28/min

Technical Details

  • Rolling Window — Shows the last 60 data points
  • Gradient Fill — Translucent gradient beneath each line
  • Threshold Zones — Dashed red lines mark danger thresholds
  • High-DPI Rendering — Canvas scales to device pixel ratio

15 AI Clinical Assistant

The floating AI assistant provides context-aware clinical support during simulations:

  • "What is the diagnosis?" — Provides differential diagnosis based on current vitals
  • "Treatment guidelines" — Evidence-based management protocols (ACC/AHA, GOLD, ADA, etc.)
  • "Current vitals" — Summarizes the patient's current physiological state
  • "Explain the pathophysiology" — Describes the mechanism of disease
  • "How are the organ systems?" — Reports status of all 5 physiological systems

AI Design Principle

The LLM does not generate physiology freely — it reads from structured patient state variables. This ensures accuracy and prevents hallucination.

16 Evaluation & Clinical Reasoning

After ending a simulation, users receive a comprehensive Simulation Debrief:

Management Score

A 0–100 score with letter grade (A+ through F) based on clinical actions, timing, and appropriateness.

Actions Timeline

Chronological listing of every medication, procedure, and order with timestamps.

Clinical Feedback

Item-by-item assessment — marked as correct (✓), incorrect (✗), or cautionary (⚠). Each item explains why.

Clinical Reasoning Analysis

  • Reasoning Score — Measures diagnostic thinking quality
  • Time to First Intervention — How quickly the student began treating
  • Diagnosis Identified — Whether the student's actions suggest correct diagnosis
  • Physiological Outcome — Start vs. end vital comparison
  • Evidence-Based Guidelines — Links actions to published clinical practice guidelines

Patient Cases — Field Reference Guide

Complete reference for every field in the Patient Cases collection. Explains what each field means, what values it expects, and how it affects the simulation.

📋 Patient Cases — Field Reference Guide

This guide explains every field in the Patient Cases collection, what values are expected, and how they affect the simulation.


🔹 Identification Fields

FieldTypeRequiredExample ValueWhat It Means
caseId Text ✅ Yes card_b1 Unique identifier for the case. Convention: {specialty_prefix}_{difficulty_letter}{number}. Prefixes: card=Cardiology, emr=Emergency, pulm=Pulmonology, neuro=Neurology, neph=Nephrology. Difficulty: b=beginner, i=intermediate, a=advanced.
specialty Relationship ✅ Yes cardiology Links to the Specialties collection. Available slugs: cardiology, emergency, pulmonology, neurology, nephrology, surgery, pediatrics.
difficulty Select ✅ Yes intermediate Case difficulty level. Options: beginner (straightforward presentation, clear diagnosis), intermediate (requires clinical reasoning), advanced (complex, multi-system, time-critical).

🔹 Patient Demographics

FieldTypeRequiredExample ValueWhat It Means
name Text ✅ Yes Samira Haque Patient's full name displayed on the simulator dashboard.
age Number ✅ Yes 55 Patient's age in years. Affects clinical context and differential diagnosis.
sex Select ✅ Yes Female Patient's sex. Options: Male or Female.
avatar Text No 👩 Emoji avatar shown on the patient card. Default: 👤
weight Number No 65 Weight in kilograms. Used for weight-based drug dosing calculations. Default: 70 kg.

🔹 Clinical Presentation

FieldTypeRequiredExample ValueWhat It Means
complaint Text ✅ Yes Crushing substernal chest pain radiating to left arm, diaphoresis The chief complaint — what the patient presents with. This is shown to the trainee at the start of the simulation.
diagnosis Text ✅ Yes Acute Inferior STEMI The actual diagnosis. Not shown to the trainee during simulation — revealed in the evaluation.
acuity Select ✅ Yes CRITICAL How urgent is this patient? Options: LOW (stable, can wait), MODERATE (needs attention), HIGH (urgent), CRITICAL (immediate life threat).
severityMultiplier Number ✅ Yes 1.2 Controls how fast the disease progresses. 0.5 = half speed (easier), 1.0 = normal, 1.5 = faster (harder). Used to tune difficulty.
comorbidities Array No Hypertension; Diabetes Type 2; Smoking List of existing conditions. Each will be a separate entry. In Excel: use semicolons to separate (e.g., Hypertension; Diabetes).

🔹 Baseline Vitals (JSON)

This is the most important field. It defines the patient's vital signs at the start of the simulation. Must be a valid JSON object.

Vital KeyFull NameNormal RangeExample (STEMI)Unit
hrHeart Rate60-10098bpm
sbpSystolic Blood Pressure90-140105mmHg
dbpDiastolic Blood Pressure60-9065mmHg
mapMean Arterial Pressure70-10578mmHg
spo2Oxygen Saturation95-10094%
rrRespiratory Rate12-2022breaths/min
tempTemperature36.5-37.537.1°C
gcsGlasgow Coma Scale15153-15
coCardiac Output4-84.5L/min
pao2Partial Pressure O₂80-10085mmHg
paco2Partial Pressure CO₂35-4538mmHg
glucoseBlood Glucose70-100110mg/dL
potassiumPotassium3.5-5.04.2mEq/L
lactateLactate0.5-2.02.1mmol/L
creatinineCreatinine0.6-1.21.0mg/dL
bicarbBicarbonate22-2822mEq/L

Example JSON:

{"hr":98,"sbp":105,"dbp":65,"map":78,"spo2":94,"rr":22,"temp":37.1,"gcs":15,"co":4.5,"pao2":85,"paco2":38,"glucose":110,"potassium":4.2,"lactate":2.1,"creatinine":1.0,"bicarb":22}

🔹 Drift Rates (JSON)

How fast each vital sign changes per simulation tick without any intervention. Positive = increasing, negative = decreasing. These represent the natural disease progression.

KeySTEMI ExampleMeaning
hr: 0.3Heart rate risingCompensatory tachycardia as cardiac output drops
sbp: -0.5BP fallingCardiogenic shock developing
spo2: -0.1O₂ sat droppingPulmonary congestion from LV failure
co: -0.02Cardiac output fallingMyocardial muscle dying, pump failure
lactate: 0.03Lactate risingTissue hypoperfusion producing anaerobic metabolism

Example JSON:

{"hr":0.3,"sbp":-0.5,"dbp":-0.3,"spo2":-0.1,"rr":0.1,"temp":0,"gcs":-0.05,"co":-0.02,"pao2":-0.1,"glucose":0,"potassium":0.01,"lactate":0.03,"creatinine":0,"bicarb":-0.02}

Tip: Set unused vitals to 0. Only set non-zero values for vitals that are clinically relevant to the disease.


🔹 Disease Progression

FieldTypeDefaultWhat It Means
decompensationTime Number (seconds) 300 (5 min) When the body's compensation mechanisms start to fail. Before this time, drift rates are moderate. After this, they accelerate.
irreversibleTime Number (seconds) 900 (15 min) Point of no return without intervention. After this, organ failure sets in rapidly.
progressionPhases JSON Array Empty Optional advanced 3-phase model with different drift rates per phase: compensateddecompensatedirreversible. Each phase has its own startTime, endTime, driftRates, and description.

🔹 ECG & Diagnostics

FieldTypeExampleWhat It Means
ecgPattern Relationship stemi_inferior Links to ECG Patterns collection by slug. This controls the waveform rendered on the monitor. Available: normal_sinus, sinus_tachycardia, sinus_bradycardia, stemi_inferior, stemi_anterior, st_depression, atrial_fibrillation, ventricular_fibrillation, lbbb, vt_monomorphic, atrial_flutter, asystole, hyperkalemia, etc.
ecgRhythm Text ST-Elevation (Inferior leads II, III, aVF) Human-readable ECG interpretation text shown in the 12-lead readout.
labs JSON See below Case-specific lab results. Each lab has val (display value), ref (reference range), and status (normal, high, low, critical).

Labs JSON example:

{
  "troponin": {"val": "2.1 ng/mL", "ref": "<0.04", "status": "critical"},
  "wbc": {"val": "12.4 ×10³/µL", "ref": "4.5-11.0", "status": "high"},
  "glucose": {"val": "195 mg/dL", "ref": "70-100", "status": "high"},
  "potassium": {"val": "5.8 mEq/L", "ref": "3.5-5.0", "status": "critical"},
  "creatinine": {"val": "1.0 mg/dL", "ref": "0.6-1.2", "status": "normal"}
}

Available lab keys: troponin, wbc, hgb, glucose, potassium, creatinine, bun, ph, abg_po2, abg_pco2, bicarb, lactate, d_dimer


🔹 Expected Actions

FieldTypeExampleWhat It Means
expectedActions Relationship (many) aspirin; heparin; nitroglycerin Which medications/interventions the trainee should perform. Used for scoring. In Excel: semicolon-separated medIds. Available medIds: aspirin, nitroglycerin, morphine, heparin, insulin, epinephrine, atropine, amiodarone, ns, lr, d5w, kcl, intubation, chest-tube, cpr, defibrillation, nasal-cannula, face-mask, nrb, bipap, prbc, ffp, platelets, cryo, blood-culture.

🔹 Patient History

FieldTypeExampleWhat It Means
hpi Textarea 55-year-old female presents with 2 hours of crushing substernal chest pain... History of Present Illness — a paragraph telling the patient's story. Shown when the trainee clicks "History" tab.
pmh Textarea Hypertension (10 years), Type 2 Diabetes (5 years), Ex-smoker Past Medical History. Include chronic conditions, surgeries, and relevant medical history.
currentMedications Array Aspirin 81mg daily; Lisinopril 10mg daily; Metformin 500mg BID Medications the patient was taking before arriving. In Excel: semicolon-separated.
allergies Text NKDA Drug/food allergies. Use "NKDA" (No Known Drug Allergies) if none.
socialHistory Text Non-smoker, occasional alcohol, school teacher, lives with family Smoking, alcohol, occupation, living situation.
familyHistory Text Father: MI at 60. Mother: Diabetes. No cancer history. Relevant family medical history.
guidelines Textarea ACC/AHA STEMI Guidelines: Aspirin 325mg, dual antiplatelet, heparin bolus, PCI within 90 min of first medical contact... Evidence-based clinical guidelines for managing this case. Shown in the post-simulation evaluation.