This cookbook details how to deploy a localized, containerized emergency medicine, trauma surgery, and critical resuscitation decision-support engine for level-1 trauma centers, emergency departments, and battlefield triage units to ingest real-time vital signs, Glasgow Coma Scale ($\text{GCS}$), Focused Assessment with Sonography for Trauma ($\text{FAST}$) ultrasound findings, arterial blood gas telemetry, and Thromboelastography ($\text{TEG}$) viscoelastic tracings, calculate the Shock Index ($\text{SI} = \text{HR} / \text{SBP}$), Shock Index Pediatric Adjusted for Age ($\text{SIPA}$), and Reverse Shock Index multiplied by GCS ($\text{rSIG}$), evaluate the Assessment of Blood Consumption ($\text{ABC}$) Score ($\ge 2\text{ points}$), gate Massive Transfusion Protocol ($\text{MTP}$) $1:1:1$ Balanced Hemostatic Resuscitation ($\text{pRBC} : \text{FFP} : \text{Platelets}$), enforce the CRASH-2 Tranexamic Acid ($\text{TXA}$) 3-Hour Golden Window, and monitor Trauma Lethal Triad (Hypothermia, Acidosis, Hypocalcemia) safety sentinels according to American College of Surgeons Committee on Trauma ($\text{ACS-COT}$), ATLS 10th Edition, and EAST consensus guidelines without external cloud API reliance.
Exsanguinating hemorrhage is the leading cause of potentially preventable death in trauma patients. Early recognition of occult shock before overt hypotension ($\text{SBP} < 90\text{ mmHg}$) occurs is essential to prevent trauma-induced coagulopathy ($\text{TIC}$) and multi-organ failure:
[Trauma Telemetry: Age, HR, SBP, GCS, FAST Ultrasound, Mechanism, Labs, TEG]
│
▼
[Shock Index Engine: Adult SI, Pediatric SIPA & Neuro-Hemodynamic rSIG Index]
│
▼
[ABC Score Evaluator: Penetrating + SBP<=90 + HR>=120 + FAST+ -> Score >= 2]
│
▼
[MTP Activation Gatekeeper: Release 1:1:1 Ratio (6 pRBC : 6 FFP : 1 Plt)]
│
▼
[CRASH-2 TXA 3h Window Engine & TEG Viscoelastic Hemostatic Component Titrator]
│
▼
[Lethal Triad Sentinels: Hypothermia (<35C), Acidosis (pH<7.2), Hypocalcemia (iCa<1.0)]
Install required scientific Python and critical resuscitation modeling packages:
pip install numpy scipy pandas torch torchvision matplotlib
"""
Cookbook 327: Offline Emergency Medicine Shock Index, SIPA & Massive Transfusion Engine
OpenPHR Clinical AI Working Group (https://openphr.org)
"""
import math
import numpy as np
import pandas as pd
from typing import Dict, List, Tuple, Optional
from dataclasses import dataclass
@dataclass
class TraumaPatientTelemetry:
patient_id: str
age_years: float = 34.0
heart_rate_bpm: float = 128.0 # bpm
systolic_bp_mmhg: float = 86.0 # mmHg
glasgow_coma_scale: int = 13 # GCS 3-15
# ABC Score Parameters
is_penetrating_mechanism: bool = True # Gunshot, stab wound
is_fast_ultrasound_positive: bool = True # Free fluid in abdomen/pelvis
# Time Since Injury Telemetry
hours_since_injury: float = 1.2 # hours (<= 3.0h = CRASH-2 TXA window)
# Arterial Blood Gas & Electrolyte Telemetry
blood_ph: float = 7.18 # Normal 7.35 - 7.45 (< 7.20 = Severe Acidosis)
base_deficit_mmol_l: float = -8.5 # mmol/L (< -6 = Severe hypoperfusion)
core_body_temperature_c: float = 34.4 # C (< 35.0 C = Hypothermia)
ionized_calcium_mmol_l: float = 0.88 # mmol/L (< 1.0 = Severe Hypocalcemia)
serum_lactate_mmol_l: float = 5.2 # mmol/L
# Thromboelastography (TEG) Telemetry
teg_r_time_minutes: float = 11.2 # Normal 5 - 10 min (> 10 = Factor deficiency -> FFP)
teg_alpha_angle_degrees: float = 52.0 # Normal 60 - 75 deg (< 60 = Fibrinogen -> Cryo)
teg_maximum_amplitude_mm: float = 46.0 # Normal 55 - 70 mm (< 55 = Platelets -> Plt)
teg_ly30_percent: float = 6.4 # Normal 0 - 3% (> 3% = Hyperfibrinolysis -> TXA)
@dataclass
class TraumaResuscitationReport:
patient_id: str
shock_index_value: float
shock_index_interpretation: str
rsig_value: float
rsig_interpretation: str
abc_total_score: int # 0 - 4
mtp_activation_status: str # "🚨 STAT MASSIVE TRANSFUSION PROTOCOL (MTP) ACTIVATED", "MTP Not Triggered"
hemostatic_blood_product_orders: List[str]
crash2_txa_protocol: List[str]
teg_guided_component_therapy: List[str]
lethal_triad_safety_sentinels: List[str]
clinical_acscot_atls_directive: str
class TraumaResuscitationDecisionEngine:
"""
Offline clinical engine for Shock Index / SIPA / rSIG evaluation, ABC score calculation,
1:1:1 Massive Transfusion Protocol activation, and TEG-directed hemostatic resuscitation.
"""
def calculate_shock_indices(self, d: TraumaPatientTelemetry) -> Tuple[float, str, float, str]:
# Adult Shock Index: HR / SBP
si = round(d.heart_rate_bpm / max(d.systolic_bp_mmhg, 30.0), 2)
# Pediatric Age-Adjusted Shock Index (SIPA) if < 17 years old
if d.age_years < 17.0:
if d.age_years <= 6.0:
sipa_cutoff = 1.22
elif d.age_years <= 12.0:
sipa_cutoff = 1.00
else:
sipa_cutoff = 0.90
if si > sipa_cutoff:
si_interp = f"ELEVATED SIPA ({si:.2f} > {sipa_cutoff:.2f} age-specific cutoff for {d.age_years:.0f}yo) -> High risk of uncompensated pediatric shock."
else:
si_interp = f"Normal SIPA ({si:.2f} <= {sipa_cutoff:.2f} cutoff)."
else:
if si >= 1.3:
si_interp = f"CRITICAL SHOCK INDEX ({si:.2f} >= 1.3) -> Impending cardiovascular collapse; severe hemorrhage (>40% blood loss)."
elif si >= 0.9:
si_interp = f"HIGH SHOCK INDEX ({si:.2f} >= 0.9) -> Uncompensated hemorrhagic shock; high likelihood of transfusion & ICU admission."
elif si >= 0.7:
si_interp = f"MILD / OCCULT SHOCK ({si:.2f} between 0.7-0.9) -> Compensated shock."
else:
si_interp = f"Normal Shock Index ({si:.2f} between 0.5-0.7)."
# Reverse Shock Index x GCS (rSIG) = (SBP / HR) * GCS
rsig = round((d.systolic_bp_mmhg / max(d.heart_rate_bpm, 30.0)) * d.glasgow_coma_scale, 2)
if rsig < 7.8:
rsig_interp = f"CRITICAL rSIG ({rsig:.2f} < 7.8 cutoff) -> High mortality risk; powerful predictor of massive transfusion and emergent surgical/angio intervention."
else:
rsig_interp = f"Non-Critical rSIG ({rsig:.2f} >= 7.8)."
return si, si_interp, rsig, rsig_interp
def calculate_abc_score(self, d: TraumaPatientTelemetry) -> Tuple[int, str]:
score = 0
if d.is_penetrating_mechanism: score += 1
if d.systolic_bp_mmhg <= 90.0: score += 1
if d.heart_rate_bpm >= 120.0: score += 1
if d.is_fast_ultrasound_positive: score += 1
status = "🚨 STAT MASSIVE TRANSFUSION PROTOCOL (MTP) ACTIVATED (ABC Score >= 2)" if score >= 2 else f"MTP Not Immediately Triggered (ABC Score {score}/4 < 2)"
return score, status
def generate_resuscitation_protocols(self, is_mtp: bool, d: TraumaPatientTelemetry) -> Tuple[List[str], List[str], List[str], List[str]]:
blood_orders = []
txa_plan = []
teg_plan = []
sentinels = []
# 1. Balanced 1:1:1 Blood Product Protocol
if is_mtp:
blood_orders.append("1. STAT MTP COOLER PACK 1 (1:1:1 Ratio):")
blood_orders.append(" • 6 Units Packed Red Blood Cells (pRBC) (O-negative for women of childbearing age; O-positive for males/older females).")
blood_orders.append(" • 6 Units Fresh Frozen Plasma (FFP) (or Thawed Plasma).")
blood_orders.append(" • 1 Apheresis Unit Single-Donor Platelets (or 6-pack pooled).")
blood_orders.append("2. RESTRICT CRYSTALLOIDS: Limit crystalloid boluses (< 1.0 L total) to prevent dilutional coagulopathy, hypothermia, and worsening acidosis.")
else:
blood_orders.append("1. Type & Crossmatch 2-4 units pRBC; maintain hemostatic readiness.")
# 2. CRASH-2 Tranexamic Acid (TXA) Protocol
if d.hours_since_injury <= 3.0:
txa_plan.append(f"1. STAT TXA LOADING DOSE (Golden Window {d.hours_since_injury:.1f}h <= 3.0h): Administer Tranexamic Acid 1.0 g IV in 100 mL NS over 10 minutes.")
txa_plan.append("2. TXA MAINTENANCE INFUSION: Follow immediately with Tranexamic Acid 1.0 g IV continuous infusion in 250-500 mL NS over 8 hours.")
else:
txa_plan.append(f"⛔ TXA CONTRAINDICATED (> 3.0h from injury: {d.hours_since_injury:.1f}h). CRASH-2 trial demonstrates increased thrombotic mortality if given after 3 hours.")
# 3. Viscoelastic TEG-Guided Component Resuscitation
if d.teg_r_time_minutes > 10.0:
teg_plan.append(f"• Prolonged R-Time ({d.teg_r_time_minutes:.1f} min > 10 min) -> Clotting factor deficiency: Transfuse 2-4 Units FFP or 4-Factor PCC.")
if d.teg_alpha_angle_degrees < 60.0:
teg_plan.append(f"• Decreased Alpha Angle ({d.teg_alpha_angle_degrees:.1f} deg < 60 deg) -> Impaired fibrin kinetics: Transfuse 10-20 Units Cryoprecipitate (Target Fibrinogen >= 150-200 mg/dL).")
if d.teg_maximum_amplitude_mm < 55.0:
teg_plan.append(f"• Decreased Maximum Amplitude ({d.teg_maximum_amplitude_mm:.1f} mm < 55 mm) -> Platelet deficiency/dysfunction: Transfuse 1 Apheresis Unit Platelets.")
if d.teg_ly30_percent > 3.0:
teg_plan.append(f"• Elevated LY30 ({d.teg_ly30_percent:.1f}% > 3.0%) -> Severe hyperfibrinolysis: Ensure full TXA dosing and repeat TEG in 30 min.")
# 4. Lethal Triad Sentinels
if d.core_body_temperature_c < 35.0:
sentinels.append(f"HYPOTHERMIA SENTINEL (Temp {d.core_body_temperature_c:.1f} C < 35.0 C): Causes severe enzymatic clotting dysfunction. Initiate active forced-air rewarming and rapid fluid warming (Belmont/Level 1 at 42 C).")
if d.blood_ph < 7.20 or d.base_deficit_mmol_l < -6.0:
sentinels.append(f"SEVERE ACIDOSIS SENTINEL (pH {d.blood_ph:.2f}, Base Deficit {d.base_deficit_mmol_l:.1f} mmol/L): Profound tissue hypoperfusion. Prioritize surgical damage-control hemostasis and volume restoration over sodium bicarbonate.")
if d.ionized_calcium_mmol_l < 1.0:
sentinels.append(f"HYPOCALCEMIA CITRATE SENTINEL (iCa {d.ionized_calcium_mmol_l:.2f} mmol/L < 1.0 mmol/L): Banked blood citrate causes severe hypocalcemia leading to myocardial depression and coagulopathy. STAT administer 1.0 - 2.0 g Calcium Chloride IV per 4 units pRBC transfused.")
return blood_orders, txa_plan, teg_plan, sentinels
def evaluate_case(self, data: TraumaPatientTelemetry) -> TraumaResuscitationReport:
si_val, si_desc, rsig_val, rsig_desc = self.calculate_shock_indices(data)
abc_score, mtp_status = self.calculate_abc_score(data)
is_mtp = "ACTIVATED" in mtp_status
blood_plan, txa_plan, teg_plan, sentinels = self.generate_resuscitation_protocols(is_mtp, data)
directives = []
directives.append(f"SHOCK INDEX: {si_val} ({si_desc}).")
directives.append(f"rSIG: {rsig_val} ({rsig_desc}).")
directives.append(f"ABC SCORE: {abc_score}/4 -> {mtp_status}.")
return TraumaResuscitationReport(
patient_id=data.patient_id,
shock_index_value=si_val,
shock_index_interpretation=si_desc,
rsig_value=rsig_val,
rsig_interpretation=rsig_desc,
abc_total_score=abc_score,
mtp_activation_status=mtp_status,
hemostatic_blood_product_orders=blood_plan,
crash2_txa_protocol=txa_plan,
teg_guided_component_therapy=teg_plan,
lethal_triad_safety_sentinels=sentinels,
clinical_acscot_atls_directive=" ".join(directives)
)
# Example Execution & Verification
if __name__ == "__main__":
engine = TraumaResuscitationDecisionEngine()
print("=" * 80)
print("OpenPHR Clinical Emergency Medicine Shock Index & Massive Transfusion Engine")
print("=" * 80)
# Test Case 1: 34-year-old male with penetrating gunshot wound to abdomen.
# HR: 128 bpm, SBP: 86 mmHg, GCS: 13, Positive FAST. Time from injury: 1.2h.
# SI: 1.49 (Critical Shock), rSIG: 8.73, ABC Score: 4/4 -> STAT MTP 1:1:1 Activation!
# TEG: R-time 11.2 min (FFP), alpha 52 deg (Cryo), MA 46 mm (Plt), LY30 6.4% (TXA).
# Lethal Triad: Temp 34.4 C, pH 7.18, iCa 0.88 mmol/L -> Active warming & CaCl2 sentinels!
trauma1 = TraumaPatientTelemetry(
patient_id="TRAUMA-EM-8801",
age_years=34.0,
heart_rate_bpm=128.0,
systolic_bp_mmhg=86.0,
glasgow_coma_scale=13,
is_penetrating_mechanism=True,
is_fast_ultrasound_positive=True,
hours_since_injury=1.2,
blood_ph=7.18,
base_deficit_mmol_l=-8.5,
core_body_temperature_c=34.4,
ionized_calcium_mmol_l=0.88,
serum_lactate_mmol_l=5.2,
teg_r_time_minutes=11.2,
teg_alpha_angle_degrees=52.0,
teg_maximum_amplitude_mm=46.0,
teg_ly30_percent=6.4
)
rep1 = engine.evaluate_case(trauma1)
print(f"\n[Patient {rep1.patient_id} - Trauma Bay Resuscitation Assessment]")
print(f"Shock Index: {rep1.shock_index_value:.2f} — {rep1.shock_index_interpretation}")
print(f"rSIG Index: {rep1.rsig_value:.2f} — {rep1.rsig_interpretation}")
print(f"ABC Score: {rep1.abc_total_score}/4 — {rep1.mtp_activation_status}")
print("\nHemostatic Blood Product Orders (1:1:1 MTP):")
for b in rep1.hemostatic_blood_product_orders:
print(f" {b}")
print("\nCRASH-2 Tranexamic Acid (TXA) Orders:")
for txa in rep1.crash2_txa_protocol:
print(f" {txa}")
print("\nTEG-Guided Targeted Component Resuscitation:")
for teg in rep1.teg_guided_component_therapy:
print(f" {teg}")
if rep1.lethal_triad_safety_sentinels:
print("\nTrauma Lethal Triad Safety Sentinels:")
for s in rep1.lethal_triad_safety_sentinels:
print(f" 🚨 {s}")
print(f"\nACS-COT / ATLS Directive:\n{rep1.clinical_acscot_atls_directive}")