Cookbook 328: Offline Clinical Anesthesiology Malignant Hyperthermia Larach Scale & Dantrolene Engine

This cookbook details how to deploy a localized, containerized anesthesiology, perioperative critical care, and operating room crisis decision-support engine for hospital surgical suites, ambulatory surgery centers, and trauma ORs to ingest real-time end-tidal $\text{CO}_2$ ($\text{EtCO}_2$), minute ventilation, core temperature kinetics, masseter muscle tone, arterial blood gas telemetry, and serum biochemistry, calculate the Larach Clinical Grading Scale ($0 - 78+\text{ points}$), stratify MH clinical probability (Rank 1: Almost Never to Rank 6: Almost Certain), execute the MHAUS Emergency Action Sequence (immediate cessation of halogenated volatile anesthetics and succinylcholine, $100\%\text{ O}_2$ hyperventilation at $10 - 15\text{ L/min}$ with charcoal vapor filters), guide Intravenous Dantrolene Sodium Reconstitution and Weight-Based Pharmacokinetics ($2.5\text{ mg/kg}$ initial push up to $10\text{ mg/kg}$ cumulative), and enforce Dantrolene-Calcium Channel Blocker (CCB) Fatal Myocardial Collapse Sentinels according to Malignant Hyperthermia Association of the United States ($\text{MHAUS}$), American Society of Anesthesiologists ($\text{ASA}$), and European Malignant Hyperthermia Group ($\text{EMHG}$) consensus guidelines without external cloud API reliance.


1. Clinical Background & Hypermetabolic Crisis Architecture

Malignant Hyperthermia ($\text{MH}$) is a pharmacogenetic, life-threatening hypermetabolic crisis of skeletal muscle triggered in genetically susceptible individuals (principally mutations in the RYR1 ryanodine receptor or CACNA1S voltage-gated calcium channel subunit) by halogenated volatile inhalational anesthetics (sevoflurane, desflurane, isoflurane) and depolarizing neuromuscular blockers (succinylcholine):


2. Pipeline & Workflow Architecture

[OR Telemetry: EtCO2, Minute Vent, Core Temp Kinetics, Muscle Tone, ABG, CK, K+]
                                         │
                                         ▼
   [Larach Scale Evaluator: Rigidity, Breakdown, Acidosis, Temp, Cardiac, Other -> 0-78+]
                                         │
                                         ▼
     [MHAUS Probability Triage: Rank 1 (Almost Never) to Rank 6 (Almost Certain >= 50)]
                                         │
                                         ▼
   [Trigger Cessation Gate: STAT Vaporizer Off + 100% O2 Hyperventilation 10-15 L/min]
                                         │
                                         ▼
   [Dantrolene Titrator: 2.5 mg/kg Initial Push -> Titrate to 10 mg/kg -> ICU Infusion]
                                         │
                                         ▼
   [Active Cooling (<38.5C Stop) + Calcium Channel Blocker Fatal Collapse Sentinel]

3. Environment & Prerequisites

Install required scientific Python and critical perioperative modeling packages:

pip install numpy scipy pandas torch torchvision matplotlib

4. Complete Offline Python / PyTorch Implementation

"""
Cookbook 328: Offline Anesthesiology Malignant Hyperthermia Larach Scale & Dantrolene 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 IntraoperativeMHTelemetry:
    patient_id: str
    patient_weight_kg: float = 78.0 # kg
    # Trigger Anesthetic Agents
    active_volatile_anesthetic: str = "Sevoflurane 2.0%" # "Sevoflurane", "Desflurane", "Isoflurane", "None"
    succinylcholine_administered: bool = True
    # Respiratory & Capnography Telemetry
    end_tidal_co2_mmhg: float = 68.0 # mmHg (> 55 mmHg = severe hypercarbia)
    minute_ventilation_l_min: float = 12.0 # L/min (Baseline was 5.5 L/min -> >2x baseline)
    is_spontaneous_breathing: bool = False
    # Temperature Kinetics Telemetry
    core_body_temperature_c: float = 39.4 # C (> 38.8 C = marked hyperthermia)
    temperature_rise_rate_c_per_15min: float = 0.8 # C / 15 min (> 0.5 C/15min = rapid)
    # Neuromuscular Tone Telemetry
    masseter_muscle_rigidity_present: bool = True # "Jaw of steel" post-succinylcholine
    generalized_lead_pipe_rigidity: bool = True # Generalized stiffness
    # Cardiac & Hemodynamic Telemetry
    heart_rate_bpm: float = 138.0 # Sinus tachycardia
    ventricular_arrhythmias_present: bool = True # Ventricular ectopy / VT
    # Arterial Blood Gas & Serum Biochemistry Telemetry
    arterial_ph: float = 7.12 # Severe acidosis (< 7.25)
    arterial_paco2_mmhg: float = 74.0 # Severe hypercapnia (> 60 mmHg)
    arterial_base_deficit_meq_l: float = -11.5 # Marked base deficit (< -8 mEq/L)
    serum_potassium_meq_l: float = 6.4 # Severe hyperkalemia (> 6.0 mEq/L)
    serum_creatine_kinase_iu_l: float = 24500.0 # Extreme rhabdomyolysis (> 20,000 IU/L)
    cola_colored_urine_present: bool = True # Myoglobinuria
    # Current Active Pharmacotherapy
    active_calcium_channel_blocker: bool = True # 🚨 FATAL INTERACTION CONTRAINDICATION!

@dataclass
class MHEvaluationReport:
    patient_id: str
    larach_total_score: int # 0 - 78+
    larach_probability_rank: str # "Rank 6: Almost Certain (>= 50 points)", "Rank 5: Very Likely", etc.
    domain_score_breakdown: List[str]
    immediate_mhaus_action_orders: List[str]
    dantrolene_dosing_protocol: List[str]
    active_cooling_protocol: List[str]
    safety_sentinels: List[str]
    clinical_mhaus_asa_directive: str

class MalignantHyperthermiaDecisionEngine:
    """
    Offline clinical engine for Larach Clinical Grading Scale scoring, MHAUS crisis action sequencing,
    IV Dantrolene Sodium reconstitution and titration, and fatal CCB interaction prevention.
    """

    def calculate_larach_scale(self, d: IntraoperativeMHTelemetry) -> Tuple[int, str, List[str]]:
        total_score = 0
        breakdown = []

        # Domain 1: Muscle Rigidity (Max 15 pts)
        d1 = 0
        if d.generalized_lead_pipe_rigidity or d.masseter_muscle_rigidity_present:
            d1 = 15
            desc = "Generalized lead-pipe rigidity and/or Masseter Muscle Rigidity (MMR)"
            breakdown.append(f"Domain 1: Muscle Rigidity (15 pts) -> {desc}.")
        else:
            breakdown.append("Domain 1: Muscle Rigidity (0 pts) -> Normal muscle tone.")
        total_score += d1

        # Domain 2: Muscle Breakdown (Max 15 pts)
        d2 = 0
        if d.serum_creatine_kinase_iu_l > 20000.0:
            d2 = 15
            desc = f"Serum CK {d.serum_creatine_kinase_iu_l:.0f} IU/L (> 20,000 IU/L)"
        elif d.cola_colored_urine_present:
            d2 = 10
            desc = "Cola-colored urine / myoglobinuria"
        elif d.serum_potassium_meq_l > 6.0:
            d2 = 3
            desc = f"Serum K+ {d.serum_potassium_meq_l:.1f} mEq/L (> 6.0 mEq/L)"
        else:
            desc = "No muscle breakdown"

        breakdown.append(f"Domain 2: Muscle Breakdown ({d2} pts) -> {desc}.")
        total_score += d2

        # Domain 3: Respiratory Acidosis (Max 15 pts)
        d3 = 0
        if d.end_tidal_co2_mmhg > 55.0 or d.arterial_paco2_mmhg > 60.0:
            d3 = 15
            desc = f"EtCO2 {d.end_tidal_co2_mmhg:.0f} mmHg / PaCO2 {d.arterial_paco2_mmhg:.0f} mmHg"
        elif d.minute_ventilation_l_min >= 10.0:
            d3 = 10
            desc = f"Inappropriately high minute ventilation ({d.minute_ventilation_l_min:.1f} L/min)"
        else:
            desc = "Normal ventilation and EtCO2"

        breakdown.append(f"Domain 3: Respiratory Acidosis ({d3} pts) -> {desc}.")
        total_score += d3

        # Domain 4: Temperature Increase (Max 15 pts)
        d4 = 0
        if d.temperature_rise_rate_c_per_15min >= 0.5:
            d4 = 15
            desc = f"Rapid rise rate {d.temperature_rise_rate_c_per_15min:.1f} C / 15 min (>= 0.5 C)"
        elif d.core_body_temperature_c > 38.8:
            d4 = 10
            desc = f"Elevated temperature {d.core_body_temperature_c:.1f} C (> 38.8 C)"
        else:
            desc = "Normal temperature kinetics"

        breakdown.append(f"Domain 4: Temperature Increase ({d4} pts) -> {desc}.")
        total_score += d4

        # Domain 5: Cardiac Involvement (Max 3 pts)
        d5 = 0
        if d.ventricular_arrhythmias_present or d.heart_rate_bpm > 120.0:
            d5 = 3
            desc = f"Unexplained tachycardia ({d.heart_rate_bpm:.0f} bpm) and/or ventricular arrhythmias"
            breakdown.append(f"Domain 5: Cardiac Involvement (3 pts) -> {desc}.")
        else:
            breakdown.append("Domain 5: Cardiac Involvement (0 pts) -> Stable cardiac rhythm.")
        total_score += d5

        # Domain 6: Other Indicators / Acid-Base (Max 15 pts)
        d6 = 0
        if d.arterial_base_deficit_meq_l < -8.0 or d.arterial_ph < 7.25:
            d6 = 10
            desc = f"Arterial pH {d.arterial_ph:.2f} (< 7.25) or Base Deficit {d.arterial_base_deficit_meq_l:.1f} mEq/L"
            breakdown.append(f"Domain 6: Acid-Base Indicators (10 pts) -> {desc}.")
        else:
            breakdown.append("Domain 6: Acid-Base Indicators (0 pts) -> Normal acid-base balance.")
        total_score += d6

        # Probability Ranking
        if total_score >= 50:
            rank = "Rank 6: Almost Certain (Score >= 50 points, >95% MH Probability)"
        elif total_score >= 35:
            rank = "Rank 5: Very Likely (Score 35-49 points)"
        elif total_score >= 20:
            rank = "Rank 4: Somewhat Greater Than Likely (Score 20-34 points)"
        elif total_score >= 10:
            rank = "Rank 3: Somewhat Less Than Likely (Score 10-19 points)"
        elif total_score >= 3:
            rank = "Rank 2: Unlikely (Score 3-9 points)"
        else:
            rank = "Rank 1: Almost Never (Score 0 points)"

        return total_score, rank, breakdown

    def generate_mhaus_crisis_protocol(self, score: int, rank: str, d: IntraoperativeMHTelemetry) -> Tuple[List[str], List[str], List[str], List[str]]:
        actions = []
        dantrolene = []
        cooling = []
        sentinels = []

        if score < 10:
            actions.append("1. LOW MH PROBABILITY: Maintain standard monitoring; consider alternative causes for tachycardia/fever.")
            return actions, dantrolene, cooling, sentinels

        # High/Very Likely MH Emergency Sequence
        actions.append("1. STAT DISCONTINUE ALL TRIGGER AGENTS: Turn off volatile anesthetic vaporizers immediately; discontinue succinylcholine.")
        actions.append("2. HYPERVENTILATE WITH 100% O2: Increase fresh gas flows to 10 - 15 L/min; hyperventilate at 2-4x normal minute ventilation.")
        actions.append("3. CHARCOAL VAPOR FILTERS: Attach activated charcoal filters to inspiratory and expiratory limbs of breathing circuit.")
        actions.append("4. DECLARE MH EMERGENCY: Call for the Malignant Hyperthermia Cart and dial MHAUS 24/7 Hotline: 1-800-MH-HYPER (1-800-644-9737).")
        actions.append("5. TERMINATE / EXPEDITE SURGERY: Conclude procedure as rapidly as possible under non-trigger total IV anesthesia (Propofol/Opioids).")

        # Dantrolene Dosing Calculations
        init_dose_mg = round(d.patient_weight_kg * 2.5, 1)
        max_dose_mg = round(d.patient_weight_kg * 10.0, 1)

        dantrolene.append(f"1. INITIAL RAPID IV PUSH: Administer Dantrolene Sodium 2.5 mg/kg ({init_dose_mg:.0f} mg IV) immediately.")
        dantrolene.append("   • Reconstitution (Standard Dantrium/Revonto): Reconstitute each 20 mg vial with 60 mL sterile water without preservative.")
        dantrolene.append("   • Reconstitution (Ryanodex): Reconstitute 250 mg vial with only 5 mL sterile water.")
        dantrolene.append(f"2. ESCALATION PROTOCOL: Repeat 1.0 - 2.5 mg/kg IV every 5-10 minutes until hypercarbia, tachycardia, and rigidity resolve (Cumulative maximum: {max_dose_mg:.0f} mg).")
        dantrolene.append(f"3. POST-CRISIS MAINTENANCE (ICU): Continue Dantrolene 1.0 mg/kg IV q4-6h ({d.patient_weight_kg * 1.0:.0f} mg) or continuous infusion 0.25 mg/kg/h for 24 - 48 hours to prevent recrudescence.")

        # Active Cooling Protocol
        cooling.append("1. ADMINISTER COLD IV CRYSTALLOIDS: Infuse cold normal saline (4 C) up to 1000 mL over 30 minutes.")
        cooling.append("2. SURFACE COOLING: Apply ice packs to axillae, groin, and neck; perform cold gastric/bladder irrigation.")
        cooling.append("3. ⚠️ COOLING OVERSHOOT SENTINEL: Cease all active cooling measures when core temperature reaches 38.5 C (101.3 F) to prevent hypothermic coagulopathy.")

        # Safety Sentinels
        if d.active_calcium_channel_blocker:
            sentinels.append("🚨 FATAL CALCIUM CHANNEL BLOCKER INTERACTION: Verapamil / Diltiazem must NEVER be administered with Dantrolene. Concurrent use precipitates severe hyperkalemia, profound myocardial depression, and fatal cardiovascular collapse. STAT DISCONTINUE CCB!")

        if d.serum_potassium_meq_l > 6.0:
            sentinels.append(f"HYPERKALEMIA EMERGENCY (K+ {d.serum_potassium_meq_l:.1f} mEq/L): STAT administer 10 units Regular Insulin IV + 50 mL D50W, Calcium Chloride 1.0 g IV, and Sodium Bicarbonate 50-100 mEq IV.")

        sentinels.append("RHABDOMYOLYSIS & RENAL PROTECTION: Maintain urine output >= 1-2 mL/kg/h with IV fluids and Mannitol/Furosemide; alkalinize urine to prevent myoglobinuric acute tubular necrosis.")

        return actions, dantrolene, cooling, sentinels

    def evaluate_case(self, data: IntraoperativeMHTelemetry) -> MHEvaluationReport:
        score, rank, breakdown = self.calculate_larach_scale(data)
        actions, dantrolene_plan, cooling_plan, sentinels = self.generate_mhaus_crisis_protocol(score, rank, data)

        directives = []
        directives.append(f"LARACH SCALE: {score}/78+ ({rank}).")
        directives.append("STAT INTERVENTION: Immediate trigger cessation, 100% O2 hyperventilation, and IV Dantrolene 2.5 mg/kg push.")

        return MHEvaluationReport(
            patient_id=data.patient_id,
            larach_total_score=score,
            larach_probability_rank=rank,
            domain_score_breakdown=breakdown,
            immediate_mhaus_action_orders=actions,
            dantrolene_dosing_protocol=dantrolene_plan,
            active_cooling_protocol=cooling_plan,
            safety_sentinels=sentinels,
            clinical_mhaus_asa_directive=" ".join(directives)
        )

# Example Execution & Verification
if __name__ == "__main__":
    engine = MalignantHyperthermiaDecisionEngine()

    print("=" * 80)
    print("OpenPHR Clinical Anesthesiology Malignant Hyperthermia & Dantrolene Engine")
    print("=" * 80)

    # Test Case 1: 78 kg adult under Sevoflurane and Succinylcholine for emergency laparotomy.
    # Develops Masseter Muscle Rigidity (MMR) (15 pts), EtCO2 68 mmHg (15 pts), Temp 39.4 C (15 pts),
    # Sinus Tachycardia 138 bpm (3 pts), Arterial pH 7.12 / Base Deficit -11.5 (10 pts), CK 24,500 (15 pts).
    # Larach Score: 73/78+ -> Rank 6: Almost Certain (>95% MH)!
    # Active CCB detected -> STAT CCB Contraindication Sentinel!
    mh1 = IntraoperativeMHTelemetry(
        patient_id="ANESTH-MH-9904",
        patient_weight_kg=78.0,
        active_volatile_anesthetic="Sevoflurane 2.0%",
        succinylcholine_administered=True,
        end_tidal_co2_mmhg=68.0,
        minute_ventilation_l_min=12.0,
        core_body_temperature_c=39.4,
        temperature_rise_rate_c_per_15min=0.8,
        masseter_muscle_rigidity_present=True,
        generalized_lead_pipe_rigidity=True,
        heart_rate_bpm=138.0,
        ventricular_arrhythmias_present=True,
        arterial_ph=7.12,
        arterial_paco2_mmhg=74.0,
        arterial_base_deficit_meq_l=-11.5,
        serum_potassium_meq_l=6.4,
        serum_creatine_kinase_iu_l=24500.0,
        cola_colored_urine_present=True,
        active_calcium_channel_blocker=True
    )

    rep1 = engine.evaluate_case(mh1)

    print(f"\n[Patient {rep1.patient_id} - Intraoperative MH Crisis Assessment]")
    print(f"Larach Scale Total Score: {rep1.larach_total_score}/78+ ({rep1.larach_probability_rank})")
    print("\nLarach Scale Domain Breakdown:")
    for b in rep1.domain_score_breakdown:
        print(f"  • {b}")
    print("\nImmediate MHAUS Action Sequence:")
    for a in rep1.immediate_mhaus_action_orders:
        print(f"  {a}")
    print("\nIV Dantrolene Sodium Dosing Protocol:")
    for dtx in rep1.dantrolene_dosing_protocol:
        print(f"  {dtx}")
    print("\nActive Cooling Protocols:")
    for c in rep1.active_cooling_protocol:
        print(f"  {c}")
    if rep1.safety_sentinels:
        print("\nPerioperative Safety Sentinels:")
        for s in rep1.safety_sentinels:
            print(f"  🚨 {s}")
    print(f"\nMHAUS / ASA Consensus Directive:\n{rep1.clinical_mhaus_asa_directive}")

5. Clinical Verification & Guideline Conformance


6. References