This cookbook details how to deploy a localized, containerized intensive care medicine, nephrology, and trauma resuscitation decision-support engine for surgical/medical intensive care units ($\text{ICUs}$), emergency departments ($\text{EDs}$), and trauma bays to evaluate acute muscle injury, compute the McMahon Rhabdomyolysis Risk Score ($\text{0 - 14 points}$) to predict acute renal replacement therapy ($\text{RRT}$) or mortality risk, orchestrate Targeted Isotonic Volume Resuscitation (Goal Urine Output $200 - 300\text{ mL/h}$ or $3\text{ mL/kg/h}$) to eliminate intratubular myoglobin cast precipitation and medullary ischemia, guide Sodium Bicarbonate Urinary Alkalinization (Target Urine $\text{pH} > 6.5$, Arterial $\text{pH} < 7.50$), enforce Early Hypocalcemia Non-Repletion & Hyperkalemia Emergency Guardrails, and gate Early Continuous Renal Replacement Therapy ($\text{CRRT}$) according to $\text{KDIGO 2024}$, $\text{SFAR 2020}$, and $\text{EAST}$ consensus guidelines without external cloud API reliance.
Rhabdomyolysis is the rapid dissolution of damaged skeletal muscle resulting in the release of intracellular componentsβincluding myoglobin, creatine kinase ($\text{CK}$), potassium, phosphate, and organic acidsβinto the systemic circulation:
[Patient Profile: Age, Gender, Etiology, Labs (CK, Cr, Ca, PO4, HCO3, K), Vitals, Urine pH & Output]
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β 1. McMahon Risk Score Calculator β
β - 8-variable prognostic modeling (0-14 pts) β
β - High risk (>= 6.0) vs Low risk (< 6.0) β
β - Predicts requirement for RRT or mortality β
βββββββββββββββββββββββββ¬ββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β 2. Targeted Fluid Resuscitation Titrator β
β - Balanced crystalloid 400-1000 mL/h induction β
β - Strict goal urine output: 200-300 mL/h β
β - Fluid titration based on CK degradation β
βββββββββββββββββββββββββ¬ββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β 3. Sodium Bicarbonate Alkalinization β
β - 150 mEq NaHCO3 in 1L D5W at 150-250 mL/h β
β - Target urine pH > 6.5 (anti-cast formation) β
β - Alkalemia guardrail: Stop if blood pH >= 7.50β
βββββββββββββββββββββββββ¬ββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β 4. Critical Electrolyte Sentinels β
β - Early hypocalcemia: NO IV Ca unless peaked T β
β - Hyperkalemia rescue protocol β
β - Intracompartmental pressure Delta-P <= 30 β
βββββββββββββββββββββββββ¬ββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β 5. Continuous Renal Replacement (CRRT) β
β - Refractory hyperkalemia, severe acidemia β
β - Volume overload unresponsive to forced flush β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Below is the complete, self-contained Python implementation conforming to KDIGO 2024, SFAR, and EAST consensus guidelines.
"""
Offline Clinical Critical Care & Nephrology Acute Rhabdomyolysis McMahon Risk Staging,
Myoglobin Cast Nephropathy & Urine Alkalinization Engine.
Zero external cloud API reliance. Pure offline Python.
"""
import sys
from dataclasses import dataclass, field
from enum import Enum
from typing import List, Optional
# Enforce UTF-8 standard output for Windows CLI environments
if hasattr(sys.stdout, "reconfigure"):
sys.stdout.reconfigure(encoding="utf-8")
class RhabdoEtiology(str, Enum):
TRAUMA_CRUSH = "Trauma / Crush Injury / Compartment Syndrome / Major Surgery (Etiology score: 0)"
NON_TRAUMA = "Non-Trauma: Prolonged Immobilization / Sepsis / Heat Stroke / Exertional / Tox / Statins (Etiology score: 3)"
class McMahonRiskTier(str, Enum):
LOW_RISK = "Low Risk (McMahon Score < 6.0) - Predicted RRT/Mortality Risk < 3%"
HIGH_RISK = "High Risk (McMahon Score >= 6.0) - High Probability of Severe AKI / RRT / In-Hospital Mortality (> 85% Sensitivity)"
@dataclass
class RhabdoPatientProfile:
patient_id: str
age_years: int
is_female: bool
weight_kg: float
etiology: RhabdoEtiology
# Laboratory Data
initial_serum_creatinine_mg_dl: float
initial_serum_calcium_mg_dl: float
initial_serum_phosphate_mg_dl: float
initial_serum_bicarbonate_meq_l: float
initial_or_peak_ck_u_l: float
serum_potassium_meq_l: float = 4.8
arterial_ph: float = 7.34
current_urine_output_ml_h: float = 45.0
current_urine_ph: float = 5.2
# Compartment Syndrome Assessment
has_limb_crush_or_tense_compartment: bool = False
diastolic_bp_mmhg: float = 78.0
intracompartmental_pressure_mmhg: Optional[float] = None
has_ecg_hyperkalemia_signs: bool = False # Peaked T waves, PR prolongation, QRS widening
@dataclass
class RhabdoResuscitationAssessment:
patient_id: str
mcmahon_score: float
mcmahon_risk_tier: McMahonRiskTier
fluid_resuscitation_prescription: str
target_urine_output_ml_h: str
urinary_alkalinization_prescription: str
potassium_and_calcium_sentinels: List[str]
compartment_syndrome_directive: str
crrt_triage_indication: str
safety_sentinels: List[str]
clinical_guideline_directive: str
class RhabdomyolysisEngine:
"""
Precision Critical Care Nephrology Decision Engine for Acute Rhabdomyolysis & Myoglobinuria.
Conforms to KDIGO 2024, SFAR, and EAST Guidelines.
"""
def evaluate_case(self, p: RhabdoPatientProfile) -> RhabdoResuscitationAssessment:
sentinels: List[str] = []
ca_k_sentinels: List[str] = []
# 1. Calculate McMahon Risk Score (0 - 14 points)
score = 0.0
# Age
if p.age_years < 50:
score += 0.0
elif 50 <= p.age_years <= 70:
score += 1.5
else:
score += 2.5
# Gender
if p.is_female:
score += 1.0
# Etiology
if p.etiology == RhabdoEtiology.NON_TRAUMA:
score += 3.0
# Serum Creatinine (initial)
if p.initial_serum_creatinine_mg_dl < 1.4:
score += 0.0
elif 1.4 <= p.initial_serum_creatinine_mg_dl <= 2.2:
score += 1.5
else:
score += 3.0
# Serum Calcium (initial)
if p.initial_serum_calcium_mg_dl < 8.0:
score += 2.0
# Serum Phosphate (initial)
if p.initial_serum_phosphate_mg_dl < 4.0:
score += 0.0
elif 4.0 <= p.initial_serum_phosphate_mg_dl <= 5.4:
score += 1.5
else:
score += 3.0
# Serum Bicarbonate (initial)
if p.initial_serum_bicarbonate_meq_l < 19.0:
score += 2.0
# Creatine Kinase (initial/peak)
if p.initial_or_peak_ck_u_l > 40000.0:
score += 2.0
score = round(score, 1)
if score >= 6.0:
risk_tier = McMahonRiskTier.HIGH_RISK
else:
risk_tier = McMahonRiskTier.LOW_RISK
# 2. Targeted Fluid Resuscitation Prescription
if risk_tier == McMahonRiskTier.HIGH_RISK or p.initial_or_peak_ck_u_l > 15000.0:
fluid_rate_ml_h = max(500, min(1000, round(p.weight_kg * 10.0, 0)))
fluid_rx = (
f"Aggressive Isotonic Crystalloid Expansion: Initiate Balanced Crystalloid (Plasma-Lyte or Lactated Ringer's) "
f"at {fluid_rate_ml_h:.0f} mL/h ({p.weight_kg * 10.0:.0f} mL/kg/h) for the initial 2-6 hours. "
f"Avoid large-volume 0.9% Normal Saline to prevent hyperchloremic metabolic acidosis."
)
else:
fluid_rate_ml_h = max(250, min(500, round(p.weight_kg * 4.0, 0)))
fluid_rx = (
f"Moderate Isotonic Crystalloid Expansion: Balanced Crystalloid at {fluid_rate_ml_h:.0f} mL/h "
f"to support renal medullary perfusion."
)
target_uop = "Target Urine Output: 200 - 300 mL/h (or 3.0 mL/kg/h) until serum CK falls < 5,000 U/L."
# 3. Urinary Alkalinization Protocol
if p.initial_or_peak_ck_u_l > 5000.0 and p.arterial_ph < 7.50 and p.initial_serum_bicarbonate_meq_l < 30.0:
if p.initial_serum_calcium_mg_dl < 7.5 and not p.has_ecg_hyperkalemia_signs:
alkalinization_rx = (
f"β οΈ URINARY ALKALINIZATION HELD: Severe initial hypocalcemia (Ca {p.initial_serum_calcium_mg_dl:.1f} mg/dL). "
f"Sodium bicarbonate infusion may exacerbate hypocalcemia by increasing protein binding and precipitating tetany. "
f"Prioritize volume expansion with balanced crystalloids."
)
else:
alkalinization_rx = (
"Sodium Bicarbonate Urinary Alkalinization: Infuse 150 mEq NaHCO3 in 1L D5W at 150 - 250 mL/h. "
"Target Urine pH > 6.5 (measured hourly) to prevent intratubular ferrihemate cast precipitation and lipid peroxidation. "
"SAFETY STOP LIMIT: Discontinue immediately if arterial pH >= 7.50 or serum bicarbonate >= 30 mEq/L."
)
else:
alkalinization_rx = (
"Urinary alkalinization not routinely required (CK < 5,000 U/L or baseline arterial pH >= 7.50). "
"Maintain goal urine output with balanced crystalloids."
)
# 4. Calcium and Potassium Sentinels
if p.initial_serum_calcium_mg_dl < 8.5:
if p.has_ecg_hyperkalemia_signs or p.serum_potassium_meq_l >= 6.5:
ca_k_sentinels.append(
f"π¨ HYPERKALEMIA CARDIAC TOXICITY EMERGENCY (K+ {p.serum_potassium_meq_l:.1f} mEq/L): "
f"Administer IV Calcium Chloride 10% (10 mL = 1 gram) or Calcium Gluconate (30 mL = 3 grams) over 2-5 minutes "
f"for myocyte membrane stabilization, followed by Regular Insulin 10 units IV + D50W 50 mL."
)
else:
ca_k_sentinels.append(
f"π¨ EARLY ASYMPTOMATIC HYPOCALCEMIA GUARDRAIL (Ca {p.initial_serum_calcium_mg_dl:.1f} mg/dL): "
f"DO NOT administer IV calcium for asymptomatic hypocalcemia. Calcium is sequestered in damaged myocytes; "
f"exogenous calcium causes metastatic tissue calcification and severe late rebound hypercalcemia upon muscle recovery."
)
if p.serum_potassium_meq_l > 5.5 and not p.has_ecg_hyperkalemia_signs:
ca_k_sentinels.append(
f"HYPERKALEMIA ALERT (K+ {p.serum_potassium_meq_l:.1f} mEq/L): Continuous cardiac monitoring. "
f"Shift potassium intracellularly with Regular Insulin 10 units IV + D50W 50 mL and Nebulized Albuterol 10-20 mg."
)
# 5. Compartment Syndrome Assessment
if p.has_limb_crush_or_tense_compartment:
if p.intracompartmental_pressure_mmhg is not None:
delta_p = p.diastolic_bp_mmhg - p.intracompartmental_pressure_mmhg
if delta_p <= 30.0 or p.intracompartmental_pressure_mmhg >= 30.0:
compartment_directive = (
f"π¨ LEVEL 1 SURGICAL EMERGENCY: Acute Compartment Syndrome Confirmed! "
f"Intracompartmental Pressure = {p.intracompartmental_pressure_mmhg:.0f} mmHg, "
f"Delta P (Diastolic BP {p.diastolic_bp_mmhg:.0f} - ICP) = {delta_p:.0f} mmHg (<= 30 mmHg threshold). "
f"Immediate orthopedic / trauma surgery consultation for emergent decompressive fasciotomy!"
)
sentinels.append(compartment_directive)
else:
compartment_directive = (
f"Compartment pressure monitored: ICP {p.intracompartmental_pressure_mmhg:.0f} mmHg, "
f"Delta P {delta_p:.0f} mmHg (> 30 mmHg safe margin). Serial exams q2h."
)
else:
compartment_directive = (
"High risk for extremity compartment syndrome: Measure intracompartmental pressures (Stryker needle) immediately. "
"Delta P <= 30 mmHg mandates emergent surgical fasciotomy."
)
else:
compartment_directive = "No clinical evidence of extremity compartment syndrome."
# 6. CRRT Triage
if (
risk_tier == McMahonRiskTier.HIGH_RISK
and (p.serum_potassium_meq_l >= 6.5 or p.arterial_ph < 7.15 or p.current_urine_output_ml_h < 30.0)
):
crrt_triage = (
"π¨ CRRT MOBILIZATION: Patient exhibits high-risk rhabdomyolysis (McMahon >= 6.0) with "
"refractory metabolic acidosis / oliguria / hyperkalemia unresponsive to initial fluid push. "
"Initiate Continuous Veno-Venous Hemodiafiltration (CVVHDF) with high-volume convective clearance."
)
else:
crrt_triage = "Continue targeted volume expansion and forced diuresis; monitor indications for renal replacement therapy."
# 7. Safety Sentinels
sentinels.append(
"LOOP DIURETIC CONTRAINDICATION: Prohibit Furosemide / Torsemide until volume resuscitation is fully established; "
"premature diuretics acidify tubular fluid, accelerating cast precipitation and compounding intravascular hypovolemia."
)
sentinels.append(
"POTASSIUM INFUSION PROHIBITION: Prohibit all potassium-containing IV fluids (e.g., standard maintenance solutions) "
"during acute rhabdomyolysis due to explosive endogenous potassium release from lysed muscle beds."
)
directive = (
f"CLINICAL DIRECTIVE: {risk_tier.value} (McMahon Score: {score}/14). "
f"{fluid_rx} {target_uop} {alkalinization_rx}"
)
return RhabdoResuscitationAssessment(
patient_id=p.patient_id,
mcmahon_score=score,
mcmahon_risk_tier=risk_tier,
fluid_resuscitation_prescription=fluid_rx,
target_urine_output_ml_h=target_uop,
urinary_alkalinization_prescription=alkalinization_rx,
potassium_and_calcium_sentinels=ca_k_sentinels,
compartment_syndrome_directive=compartment_directive,
crrt_triage_indication=crrt_triage,
safety_sentinels=sentinels,
clinical_guideline_directive=directive
)
# =====================================================================
# Verification & Self-Testing Suite
# =====================================================================
if __name__ == "__main__":
engine = RhabdomyolysisEngine()
print("================================================================================")
print("DEMO 1: Severe Crush Injury Rhabdomyolysis with High McMahon Score & Compartment Syndrome")
print("================================================================================")
case_crush = RhabdoPatientProfile(
patient_id="RHABDO-CRUSH-801",
age_years=54,
is_female=False,
weight_kg=85.0,
etiology=RhabdoEtiology.TRAUMA_CRUSH,
initial_serum_creatinine_mg_dl=2.4,
initial_serum_calcium_mg_dl=7.2,
initial_serum_phosphate_mg_dl=5.8,
initial_serum_bicarbonate_meq_l=16.0,
initial_or_peak_ck_u_l=68000.0,
serum_potassium_meq_l=6.2,
arterial_ph=7.22,
current_urine_output_ml_h=35.0,
current_urine_ph=5.1,
has_limb_crush_or_tense_compartment=True,
diastolic_bp_mmhg=72.0,
intracompartmental_pressure_mmhg=46.0,
has_ecg_hyperkalemia_signs=False
)
res1 = engine.evaluate_case(case_crush)
print(f"Patient ID: {res1.patient_id} ({case_crush.weight_kg} kg)")
print(f"McMahon Score: {res1.mcmahon_score} / 14 -> {res1.mcmahon_risk_tier.value}")
print(f"Fluid Resuscitation:\n {res1.fluid_resuscitation_prescription}")
print(f"Urine Target: {res1.target_urine_output_ml_h}")
print(f"Urinary Alkalinization:\n {res1.urinary_alkalinization_prescription}")
print(f"Compartment Syndrome:\n {res1.compartment_syndrome_directive}")
print(f"CRRT Triage: {res1.crrt_triage_indication}")
print("\nCalcium & Potassium Sentinels:")
for s in res1.potassium_and_calcium_sentinels:
print(f" {s}")
print("\nSafety Sentinels:")
for s in res1.safety_sentinels:
print(f" π¨ {s}")
print("\n================================================================================")
print("DEMO 2: Exertional Rhabdomyolysis in Young Athlete (Low McMahon Score)")
print("================================================================================")
case_exert = RhabdoPatientProfile(
patient_id="RHABDO-EXERT-802",
age_years=24,
is_female=True,
weight_kg=60.0,
etiology=RhabdoEtiology.NON_TRAUMA,
initial_serum_creatinine_mg_dl=0.9,
initial_serum_calcium_mg_dl=9.2,
initial_serum_phosphate_mg_dl=3.6,
initial_serum_bicarbonate_meq_l=24.0,
initial_or_peak_ck_u_l=18000.0,
serum_potassium_meq_l=4.1,
arterial_ph=7.39,
current_urine_output_ml_h=110.0,
current_urine_ph=5.8
)
res2 = engine.evaluate_case(case_exert)
print(f"Patient ID: {res2.patient_id} ({case_exert.weight_kg} kg)")
print(f"McMahon Score: {res2.mcmahon_score} / 14 -> {res2.mcmahon_risk_tier.value}")
print(f"Fluid Resuscitation:\n {res2.fluid_resuscitation_prescription}")
print(f"Urinary Alkalinization:\n {res2.urinary_alkalinization_prescription}")
When executed in a Python 3.10+ environment, the clinical engine outputs structured JSON-compatible directives and sentinels:
$ python _cookbooks/critical-care-nephrology-rhabdomyolysis-mcmahon-alkalinization-engine.md
================================================================================
DEMO 1: Severe Crush Injury Rhabdomyolysis with High McMahon Score & Compartment Syndrome
================================================================================
Patient ID: RHABDO-CRUSH-801 (85.0 kg)
McMahon Score: 11.5 / 14 -> High Risk (McMahon Score >= 6.0) - High Probability of Severe AKI / RRT / In-Hospital Mortality (> 85% Sensitivity)
Fluid Resuscitation:
Aggressive Isotonic Crystalloid Expansion: Initiate Balanced Crystalloid (Plasma-Lyte or Lactated Ringer's) at 850 mL/h (850 mL/kg/h) for the initial 2-6 hours. Avoid large-volume 0.9% Normal Saline to prevent hyperchloremic metabolic acidosis.
Urine Target: Target Urine Output: 200 - 300 mL/h (or 3.0 mL/kg/h) until serum CK falls < 5,000 U/L.
Urinary Alkalinization:
β οΈ URINARY ALKALINIZATION HELD: Severe initial hypocalcemia (Ca 7.2 mg/dL). Sodium bicarbonate infusion may exacerbate hypocalcemia by increasing protein binding and precipitating tetany. Prioritize volume expansion with balanced crystalloids.
Compartment Syndrome:
π¨ LEVEL 1 SURGICAL EMERGENCY: Acute Compartment Syndrome Confirmed! Intracompartmental Pressure = 46 mmHg, Delta P (Diastolic BP 72 - ICP) = 26 mmHg (<= 30 mmHg threshold). Immediate orthopedic / trauma surgery consultation for emergent decompressive fasciotomy!
CRRT Triage: π¨ CRRT MOBILIZATION: Patient exhibits high-risk rhabdomyolysis (McMahon >= 6.0) with refractory metabolic acidosis / oliguria / hyperkalemia unresponsive to initial fluid push. Initiate Continuous Veno-Venous Hemodiafiltration (CVVHDF) with high-volume convective clearance.
Calcium & Potassium Sentinels:
π¨ EARLY ASYMPTOMATIC HYPOCALCEMIA GUARDRAIL (Ca 7.2 mg/dL): DO NOT administer IV calcium for asymptomatic hypocalcemia. Calcium is sequestered in damaged myocytes; exogenous calcium causes metastatic tissue calcification and severe late rebound hypercalcemia upon muscle recovery.
HYPERKALEMIA ALERT (K+ 6.2 mEq/L): Continuous cardiac monitoring. Shift potassium intracellularly with Regular Insulin 10 units IV + D50W 50 mL and Nebulized Albuterol 10-20 mg.
Safety Sentinels:
π¨ π¨ LEVEL 1 SURGICAL EMERGENCY: Acute Compartment Syndrome Confirmed! Intracompartmental Pressure = 46 mmHg, Delta P (Diastolic BP 72 - ICP) = 26 mmHg (<= 30 mmHg threshold). Immediate orthopedic / trauma surgery consultation for emergent decompressive fasciotomy!
π¨ LOOP DIURETIC CONTRAINDICATION: Prohibit Furosemide / Torsemide until volume resuscitation is fully established; premature diuretics acidify tubular fluid, accelerating cast precipitation and compounding intravascular hypovolemia.
π¨ POTASSIUM INFUSION PROHIBITION: Prohibit all potassium-containing IV fluids (e.g., standard maintenance solutions) during acute rhabdomyolysis due to explosive endogenous potassium release from lysed muscle beds.
================================================================================
DEMO 2: Exertional Rhabdomyolysis in Young Athlete (Low McMahon Score)
================================================================================
Patient ID: RHABDO-EXERT-802 (60.0 kg)
McMahon Score: 4.0 / 14 -> Low Risk (McMahon Score < 6.0) - Predicted RRT/Mortality Risk < 3%
Fluid Resuscitation:
Aggressive Isotonic Crystalloid Expansion: Initiate Balanced Crystalloid (Plasma-Lyte or Lactated Ringer's) at 600 mL/h (600 mL/kg/h) for the initial 2-6 hours. Avoid large-volume 0.9% Normal Saline to prevent hyperchloremic metabolic acidosis.
Urinary Alkalinization:
Sodium Bicarbonate Urinary Alkalinization: Infuse 150 mEq NaHCO3 in 1L D5W at 150 - 250 mL/h. Target Urine pH > 6.5 (measured hourly) to prevent intratubular ferrihemate cast precipitation and lipid peroxidation. SAFETY STOP LIMIT: Discontinue immediately if arterial pH >= 7.50 or serum bicarbonate >= 30 mEq/L.