Cookbook 383: Offline Clinical Endocrinology & Critical Care Acute Myxedema Coma Popoveniuc Diagnostic Staging, Stress Hydrocortisone Co-Administration Sentinel, IV Levothyroxine (T4) / Liothyronine (T3) Titrator & Passive Rewarming Protocol

Executive Clinical Overview

Myxedema Coma is a rare, life-threatening decompensation of severe, longstanding hypothyroidism characterized by profound multisystem organ failure: hypothermia, severe altered mental status (lethargy, stupor, delirium, or coma), hypoventilation with hypercapnic respiratory acidosis, bradycardia, hypotension, and generalized non-pitting myxedematous edema. Despite modern intensive care capabilities, myxedema coma carries an alarming mortality rate of $25\% - 60\%$, overwhelmingly driven by delayed clinical diagnosis, cardiovascular collapse, and respiratory failure.

The term “myxedema coma” is clinically misleading: frank coma is present in less than $50\%$ of patients at initial presentation; the vast majority exhibit progressive lethargy, confusion, hallucinations (“myxedema madness”), or cognitive slowing. Precipitants include sepsis/pneumonia, exposure to cold environments, acute myocardial infarction, cerebrovascular accidents, trauma, congestive heart failure, or medication non-adherence / sedative administration.

Authoritative guidelines from the American Thyroid Association (ATA), the Endocrine Society, and the European Thyroid Association (ETA) emphasize five life-critical clinical imperatives:

  1. The Mandatory Adrenal Insufficiency Sentinel: Administering thyroid hormone without concurrent or prior glucocorticoid coverage in a patient with coexisting adrenal insufficiency (common in Schmidt syndrome / polyglandular autoimmune syndrome type 2 or central panhypopituitarism) dramatically accelerates metabolic clearance of cortisol, precipitating fatal acute adrenal crisis. Stress-dose Hydrocortisone ($100\text{ mg}$ IV q8h) must be given prior to or concurrently with thyroid hormone.
  2. Active External Rewarming Proscription: Vigorous active external rewarming (warming blankets, heating lamps) causes sudden peripheral vasodilation in vasoconstricted patients, shifting blood away from core vital organs and precipitating fatal cardiovascular collapse and refractory shock. Rewarming must be strictly passive (ordinary blankets, ambient room temperature warming).
  3. Hypercapnic Hypoventilation & Delayed Weaning: Severe hypothyroidism impairs central ventilatory responses to both hypercapnia and hypoxia while inducing diaphragmatic myopathy and macroglossia. Over $80\%$ of patients require proactive endotracheal intubation and mechanical ventilation.
  4. Intravenous Route Requirement: Severe gastrointestinal mucosal edema dramatically impairs oral absorption of levothyroxine. Initial therapy must be administered intravenously.
  5. Popoveniuc Diagnostic Scoring System: Developed in 2014, the Popoveniuc scoring system operationalizes clinical diagnostic thresholds across 6 organ domains: Thermoregulation, Central Nervous System, Gastrointestinal, Cardiovascular, Metabolic, and Precipitating Factors. A score of $\ge 60\text{ points}$ is diagnostic of myxedema coma.
+---------------------------------------------------------------------------------------------------------+
|                         ACUTE MYXEDEMA COMA DIAGNOSTIC & RESUSCITATION CASCADE                          |
+---------------------------------------------------------------------------------------------------------+
| 1. POPOVENIUC DIAGNOSTIC SCORING GATING (>= 60 POINTS = DIAGNOSTIC OF MYXEDEMA COMA)                   |
|    - Thermoregulatory Dysfunction: Severe Hypothermia (Core Temp < 32.0 C [+30], 32.0-35.0 C [+20])     |
|    - Central Nervous System: Lethargy/Stupor (+20), Obtundation (+25), Frank Coma (+30)                |
|    - Cardiovascular: Severe Bradycardia (HR < 50 bpm [+10]), Hypotension (SBP < 90 [+20]), Low Voltage  |
|    - Gastrointestinal: Anorexia/Constipation (+10), Paralytic Ileus / Megacolon (+20)                   |
|    - Metabolic: Hyponatremia (Na < 130 [+10]), Hypoglycemia (Glucose < 70 [+10]), Hypoxemia/Hypercapnia |
|    - Precipitating Event: Sepsis, MI, Trauma, Cold Exposure, Sedative Administration (+10)              |
|    - SCORE >= 60: DIAGNOSTIC OF MYXEDEMA COMA (Initiate ICU Resuscitation Immediately).                 |
+---------------------------------------------------------------------------------------------------------+
                                                     |
                                                     v
+---------------------------------------------------------------------------------------------------------+
| 2. MANDATORY FIRST STEP: ADRENAL SAFETY SENTINEL (ZERO DELAY FOR CORTISOL LABS)                         |
|    - Draw baseline serum Cortisol & TSH/Free T4/Free T3 tube immediately.                               |
|    - ADMINISTER HYDROCORTISONE SODIUM SUCCINATE 100 mg IV STAT FIRST (or concurrently).                 |
|    - Continue Hydrocortisone 50 to 100 mg IV every 8 hours until adrenal insufficiency is ruled out.   |
|    - CRITICAL WARNING: Giving thyroid hormone alone accelerates hepatic cortisol clearance, triggering |
|      fatal circulatory collapse if secondary AI or Schmidt syndrome is present.                         |
+---------------------------------------------------------------------------------------------------------+
                                                     |
                                                     v
+---------------------------------------------------------------------------------------------------------+
| 3. INTRAVENOUS THYROID HORMONE REPLACEMENT TITRATION                                                    |
|    - IV LEVOTHYROXINE (T4) ALONE OR DUAL THERAPY (T4 + T3):                                             |
|      * ATA Preferred Dual Therapy:                                                                      |
|        - IV Levothyroxine (T4) Loading: 200 - 400 mcg IV over 30 min (lower in elderly / CAD [200 mcg])  |
|          Maintenance: 1.6 mcg/kg/day IV (or 50-100 mcg IV daily)                                        |
|        - PLUS IV Liothyronine (T3) Loading: 5 - 20 mcg IV (lower in CAD [2.5-5 mcg])                    |
|          Maintenance: 2.5 - 10 mcg IV every 8 hours until patient is conscious and extubated.          |
+---------------------------------------------------------------------------------------------------------+
                                                     |
                                                     v
+---------------------------------------------------------------------------------------------------------+
| 4. RESUSCITATION & PROCEDURAL SENTINELS                                                                 |
|    - PASSIVE REWARMING ONLY: Ordinary blankets; warm room. Avoid active electric/forced-air warming     |
|      blankets (provokes fatal peripheral vasodilation and shock).                                       |
|    - Respiratory: Low threshold for intubation. Severe blunted hypercapnic drive and macroglossia.      |
|    - Hyponatremia Management: Fluid restriction (1000 mL/day). Reserve 3% hypertonic saline for seizures|
|      or Na < 120 mEq/L (correct slowly < 8 mEq/L/24h to avoid osmotic demyelination syndrome).          |
+---------------------------------------------------------------------------------------------------------+

Popoveniuc Diagnostic Point Scoring Framework

The Popoveniuc Scoring Scale (Endocrine Practice, 2014) stratifies the probability of myxedema coma based on clinical signs across 6 organ systems:

System Domain Clinical Findings Assigned Points
1. Thermoregulatory Dysfunction Core Temp $> 35.0^{\circ}\text{C}$ ($> 95.0^{\circ}\text{F}$) $0$
  Core Temp $33.3 - 35.0^{\circ}\text{C}$ ($92.0 - 95.0^{\circ}\text{F}$) $+10$
  Core Temp $32.0 - 33.2^{\circ}\text{C}$ ($89.6 - 91.9^{\circ}\text{F}$) $+20$
  Core Temp $< 32.0^{\circ}\text{C}$ ($< 89.6^{\circ}\text{F}$) $+30$
2. Central Nervous System Absent (Normal alertness) $0$
  Somnolence, lethargy, slow mentation $+10$
  Stupor, moderate-to-severe delirium, confusion $+20$
  Obtundation $+25$
  Frank coma, unresponsiveness $+30$
3. Gastrointestinal Effects Anorexia, severe constipation, abdominal fullness $+5$
  Decreased bowel sounds, abdominal distension $+10$
  Paralytic ileus, toxic megacolon $+15$
4. Cardiovascular Dysfunction Bradycardia ($ ext{HR } 50 - 59\text{ bpm}$) $+10$
  Severe Bradycardia ($ ext{HR } < 50\text{ bpm}$) $+20$
  Hypotension ($ ext{SBP } 90 - 99\text{ mmHg}$) $+10$
  Severe Hypotension ($ ext{SBP } < 90\text{ mmHg}$) $+20$
  Pericardial effusion / Low ECG voltage / Cardiomegaly $+10$
5. Metabolic Abnormalities Hyponatremia ($ ext{Na } 130 - 134\text{ mEq/L}$) $+5$
  Severe Hyponatremia ($ ext{Na } < 130\text{ mEq/L}$) $+10$
  Hypoglycemia ($ ext{Glucose } < 70\text{ mg/dL}$) $+10$
  Hypoxemia ($ ext{PaO}_2 < 60\text{ mmHg}$) or Hypercapnia ($ ext{PaCO}_2 > 50\text{ mmHg}$) $+10$
6. Precipitating Factors Documented acute infection, MI, trauma, cold exposure, sedatives $+10$
\[\text{Total Popoveniuc Score} = \sum_{i=1}^{6} \text{Points}_i\] \[\text{Diagnostic Probability} = \begin{cases} \ge 60\ \text{Points}, & \textbf{Diagnostic of Myxedema Coma (Immediate ICU Protocol)} \\ 25 - 59\ \text{Points}, & \text{Impending / High Risk for Myxedema Decompensation} \\ < 25\ \text{Points}, & \text{Unlikely Myxedema Coma} \end{cases}\]

Thyroid Hormone Pharmacology: T4 vs. T3 Kinetics in Severe Illness

In critically ill patients with severe hypothyroidism, peripheral $5’$-deiodinase activity is markedly impaired (the “euthyroid sick / non-thyroidal illness” defect), which severely suppresses the extrathyroidal conversion of Levothyroxine (T4) into the biologically active hormone Liothyronine (T3). Consequently, monotherapy with T4 may yield delayed clinical recovery.

\[\begin{array}{lcccc} \hline \textbf{Parameter} & \textbf{Levothyroxine (T4)} & \textbf{Liothyronine (T3)} \\ \hline \text{Biological Activity} & \text{Pro-hormone} & \text{Active hormone (3-5x potency)} \\ \text{Onset of Action} & 6 - 12\text{ hours} & 2 - 4\text{ hours} \\ \text{Peak Metabolic Effect} & 24 - 48\text{ hours} & 6 - 12\text{ hours} \\ \text{Serum Half-Life} & 7\text{ days} & 1\text{ day} \\ \text{Loading Dose (Adult)} & 200 - 400\ \mu\text{g IV} & 5 - 20\ \mu\text{g IV} \\ \text{Maintenance Dose} & 1.6\ \mu\text{g/kg/day IV} & 2.5 - 10\ \mu\text{g q8h IV} \\ \text{Cardiovascular Risk} & \text{Moderate} & \text{High (arrhythmias, ischemia)} \\ \hline \end{array}\]

ATA Consensus Recommendation: Combine IV Levothyroxine ($200-400\ \mu ext{g}$ loading) with low-dose IV Liothyronine ($5-10\ \mu ext{g}$ loading), reducing doses by $50\%$ in elderly patients or those with coronary artery disease (CAD) to avoid fatal tachyarrhythmias.


Production Python Implementation

The following complete, zero-dependency Python clinical decision-support engine evaluates the Popoveniuc Diagnostic Score, enforces the mandatory Hydrocortisone sentinel, calculates weight-tiered and CAD-adjusted T4/T3 regimens, and provides passive rewarming protocols.

#!/usr/bin/env python3
"""
OpenPHR Cookbook 383: Offline Clinical Endocrinology & Critical Care Engine
Acute Myxedema Coma Popoveniuc Diagnostic Staging, Stress Hydrocortisone Sentinel,
IV Levothyroxine/Liothyronine Titrator & Passive Rewarming Protocol.

Dependencies: Python 3.8+ (Standard Library Only).
"""

from dataclasses import dataclass, field
from enum import Enum
from typing import Dict, List, Optional, Tuple, Union


class PopoveniucRiskTier(Enum):
    DIAGNOSTIC_MYXEDEMA_COMA = "Diagnostic of Myxedema Coma (Score >= 60) - Immediate ICU Emergency Protocol"
    IMPENDING_DECOMPENSATION = "Impending / Intermediate Risk (Score 25 - 59) - Close ICU/Step-Down Monitoring"
    UNLIKELY = "Unlikely Myxedema Coma (Score < 25)"


class ThyroidReplacementStrategy(Enum):
    DUAL_T4_T3_STANDARD = "Dual Therapy: IV Levothyroxine (T4) + IV Liothyronine (T3) - Preferred ATA Strategy"
    DUAL_T4_T3_CORONARY_SPARING = "Coronary-Sparing Dual Therapy (Elderly / Known CAD / Arrhythmia Risk)"
    T4_MONOTHERAPY = "IV Levothyroxine (T4) Monotherapy (Where IV T3 is Unavailable or Severe Ischemia)"


@dataclass
class MyxedemaPatientPresentation:
    # Patient demographics
    age_years: float
    weight_kg: float
    is_adult: bool
    known_coronary_artery_disease_or_elderly: bool = False
    # Domain 1: Thermoregulation (Core Temperature)
    core_temperature_celsius: float = 34.0
    # Domain 2: Central Nervous System
    cns_status: str = "Stupor"  # "Normal", "Lethargy", "Stupor", "Obtundation", "Coma"
    # Domain 3: Gastrointestinal
    gi_manifestations: str = "Decreased Sounds"  # "Normal", "Anorexia", "Decreased Sounds", "Paralytic Ileus"
    # Domain 4: Cardiovascular
    heart_rate_bpm: int = 44
    systolic_bp_mmhg: int = 82
    diastolic_bp_mmhg: int = 50
    has_pericardial_effusion_or_low_voltage: bool = True
    # Domain 5: Metabolic parameters
    serum_sodium_meq_l: float = 124.0
    serum_glucose_mg_dl: float = 62.0
    pao2_mmhg: float = 54.0
    paco2_mmhg: float = 56.0
    # Domain 6: Precipitating Factors
    has_acute_precipitant: bool = True  # Infection, MI, cold exposure, surgery
    precipitant_description: str = "Severe Sepsis (Community-Acquired Pneumonia) & Cold Exposure"
    # Endocrine lab history
    known_prior_hypothyroidism: bool = True
    baseline_cortisol_ug_dl: Optional[float] = None
    baseline_tsh_miu_l: Optional[float] = None
    baseline_free_t4_ng_dl: Optional[float] = None


@dataclass
class PopoveniucScoreResult:
    total_score: int
    risk_tier: PopoveniucRiskTier
    is_diagnostic: bool
    score_breakdown: Dict[str, int]
    clinical_interpretation: str


@dataclass
class ThyroidDosingProtocol:
    strategy: ThyroidReplacementStrategy
    iv_levothyroxine_t4_loading_mcg: float
    iv_levothyroxine_t4_maintenance_mcg_daily: float
    iv_liothyronine_t3_loading_mcg: Optional[float]
    iv_liothyronine_t3_maintenance_mcg_q8h: Optional[float]
    clinical_instructions: str


@dataclass
class MyxedemaDecisionReport:
    popoveniuc_result: PopoveniucScoreResult
    adrenal_safety_sentinel: Dict[str, str]
    thyroid_pharmacotherapy: ThyroidDosingProtocol
    passive_rewarming_protocol: Dict[str, str]
    respiratory_and_airway_sentinel: Dict[str, str]
    hyponatremia_aquaresis_protocol: Dict[str, str]


class AcuteMyxedemaComaEngine:
    """
    Clinical Decision Support Engine for Acute Myxedema Coma Staging,
    Popoveniuc Scoring, Adrenal Safety Gating, and T4/T3 Hormone Replacement.
    """

    @classmethod
    def calculate_popoveniuc_score(
        cls, p: MyxedemaPatientPresentation
    ) -> PopoveniucScoreResult:
        """
        Calculates the Popoveniuc Diagnostic Point Score across 6 domains:
        1. Thermoregulation (0 - 30 pts)
        2. Central Nervous System (0 - 30 pts)
        3. Gastrointestinal (0 - 15 pts)
        4. Cardiovascular (0 - 40 pts)
        5. Metabolic (0 - 30 pts)
        6. Precipitating Factor (0 - 10 pts)
        """
        breakdown = {}
        total = 0

        # Domain 1: Thermoregulation
        temp = p.core_temperature_celsius
        if temp < 32.0:
            breakdown["Severe Hypothermia (< 32.0 °C)"] = 30
            total += 30
        elif temp <= 33.2:
            breakdown["Moderate Hypothermia (32.0 - 33.2 °C)"] = 20
            total += 20
        elif temp <= 35.0:
            breakdown["Mild Hypothermia (33.3 - 35.0 °C)"] = 10
            total += 10

        # Domain 2: CNS
        cns_lower = p.cns_status.lower()
        if "coma" in cns_lower:
            breakdown["CNS: Frank Coma"] = 30
            total += 30
        elif "obtund" in cns_lower:
            breakdown["CNS: Obtundation"] = 25
            total += 25
        elif "stupor" in cns_lower or "delirium" in cns_lower:
            breakdown["CNS: Stupor / Delirium"] = 20
            total += 20
        elif "letharg" in cns_lower or "somnol" in cns_lower:
            breakdown["CNS: Lethargy / Somnolence"] = 10
            total += 10

        # Domain 3: GI
        gi_lower = p.gi_manifestations.lower()
        if "ileus" in gi_lower or "megacolon" in gi_lower:
            breakdown["GI: Paralytic Ileus / Megacolon"] = 15
            total += 15
        elif "decreased" in gi_lower or "distension" in gi_lower:
            breakdown["GI: Decreased Bowel Sounds / Distension"] = 10
            total += 10
        elif "anorexia" in gi_lower or "constipat" in gi_lower:
            breakdown["GI: Anorexia / Constipation"] = 5
            total += 5

        # Domain 4: Cardiovascular
        if p.heart_rate_bpm < 50:
            breakdown["Severe Bradycardia (HR < 50 bpm)"] = 20
            total += 20
        elif p.heart_rate_bpm < 60:
            breakdown["Bradycardia (HR 50 - 59 bpm)"] = 10
            total += 10

        if p.systolic_bp_mmhg < 90:
            breakdown["Severe Hypotension (SBP < 90 mmHg)"] = 20
            total += 20
        elif p.systolic_bp_mmhg < 100:
            breakdown["Hypotension (SBP 90 - 99 mmHg)"] = 10
            total += 10

        if p.has_pericardial_effusion_or_low_voltage:
            breakdown["Pericardial Effusion / Low ECG Voltage"] = 10
            total += 10

        # Domain 5: Metabolic
        if p.serum_sodium_meq_l < 130.0:
            breakdown["Severe Hyponatremia (Na < 130 mEq/L)"] = 10
            total += 10
        elif p.serum_sodium_meq_l < 135.0:
            breakdown["Hyponatremia (Na 130 - 134 mEq/L)"] = 5
            total += 5

        if p.serum_glucose_mg_dl < 70.0:
            breakdown["Hypoglycemia (Glucose < 70 mg/dL)"] = 10
            total += 10

        if p.pao2_mmhg < 60.0 or p.paco2_mmhg > 50.0:
            breakdown["Hypoxemia (PaO2 < 60) or Hypercapnia (PaCO2 > 50 mmHg)"] = 10
            total += 10

        # Domain 6: Precipitating Factors
        if p.has_acute_precipitant:
            breakdown["Precipitating Event (Infection/MI/Cold)"] = 10
            total += 10

        if total >= 60:
            tier = PopoveniucRiskTier.DIAGNOSTIC_MYXEDEMA_COMA
            is_diag = True
            interp = (
                f"Popoveniuc Score: {total} points -> DIAGNOSTIC OF MYXEDEMA COMA (Threshold >= 60). "
                "Initiate immediate emergency ICU protocol: IV Hydrocortisone STAT, IV Levothyroxine + Liothyronine, "
                "passive rewarming, and mechanical ventilation support."
            )
        elif total >= 25:
            tier = PopoveniucRiskTier.IMPENDING_DECOMPENSATION
            is_diag = False
            interp = (
                f"Popoveniuc Score: {total} points -> IMPENDING DECOMPENSATION (Score 25-59). "
                "High risk of transitioning to overt coma. ICU admission and rapid treatment indicated."
            )
        else:
            tier = PopoveniucRiskTier.UNLIKELY
            is_diag = False
            interp = f"Popoveniuc Score: {total} points -> Unlikely Myxedema Coma (Score < 25)."

        return PopoveniucScoreResult(
            total_score=total,
            risk_tier=tier,
            is_diagnostic=is_diag,
            score_breakdown=breakdown,
            clinical_interpretation=interp,
        )

    @staticmethod
    def generate_adrenal_safety_sentinel() -> Dict[str, str]:
        """
        Generates the mandatory Adrenal Insufficiency co-administration guardrail.
        """
        return {
            "sentinel_status": "MANDATORY FIRST STEP: ADMINISTER HYDROCORTISONE FIRST",
            "clinical_rule": (
                "DO NOT ADMINISTER THYROID HORMONE WITHOUT PRIOR OR CONCURRENT GLUCOCORTICOID COVERAGE. "
                "Thyroid hormone dramatically up-regulates hepatic corticosteroid-metabolizing enzymes and "
                "increases peripheral tissue cortisol consumption. In patients with unrecognized primary "
                "(Schmidt syndrome) or central adrenal insufficiency, thyroid hormone administration precipitates "
                "fatal acute adrenal crisis and refractory shock."
            ),
            "emergency_dosing": "Hydrocortisone Sodium Succinate 100 mg IV STAT bolus, followed by 50 to 100 mg IV every 8 hours.",
            "diagnostic_order": "Draw serum cortisol tube immediately before hydrocortisone injection. Do NOT delay injection for laboratory results.",
        }

    @staticmethod
    def calculate_thyroid_hormone_dosing(
        weight_kg: float, is_coronary_or_elderly: bool
    ) -> ThyroidDosingProtocol:
        """
        Calculates ATA-guideline concordant IV Levothyroxine (T4) and Liothyronine (T3) replacement:
        - Standard Adult:
          * IV T4 Load: 300 to 400 mcg IV over 30 min, then 1.6 mcg/kg/day IV (or 100 mcg daily).
          * IV T3 Load: 10 to 20 mcg IV, then 5 to 10 mcg IV every 8 hours.
        - Coronary-Sparing / Elderly (> 65yo or CAD / Arrhythmias):
          * IV T4 Load: 200 mcg IV over 30 min, then 50 to 75 mcg daily IV.
          * IV T3 Load: 2.5 to 5 mcg IV, then 2.5 mcg IV every 8 hours (or omit T3).
        """
        if is_coronary_or_elderly:
            strategy = ThyroidReplacementStrategy.DUAL_T4_T3_CORONARY_SPARING
            t4_load = 200.0
            t4_maint = 75.0
            t3_load = 5.0
            t3_maint = 2.5
            instructions = (
                "Coronary-Sparing Protocol: Administer Levothyroxine 200 mcg IV loading dose slowly over 30 min. "
                "Administer Liothyronine 5 mcg IV loading dose. Maintain T4 at 75 mcg IV daily and T3 at 2.5 mcg IV q8h. "
                "Monitor continuous 12-lead telemetry for myocardial ischemia or tachyarrhythmias."
            )
        else:
            strategy = ThyroidReplacementStrategy.DUAL_T4_T3_STANDARD
            t4_load = 300.0
            t4_maint = round(min(125.0, weight_kg * 1.6), 0)
            t3_load = 10.0
            t3_maint = 5.0
            instructions = (
                f"Standard ATA Dual-Therapy: Administer Levothyroxine 300 mcg IV loading dose over 30 min. "
                f"Administer Liothyronine 10 mcg IV loading dose. Continue T4 at {t4_maint:.0f} mcg IV daily "
                "and T3 at 5 mcg IV every 8 hours until clinical improvement and extubation."
            )

        return ThyroidDosingProtocol(
            strategy=strategy,
            iv_levothyroxine_t4_loading_mcg=t4_load,
            iv_levothyroxine_t4_maintenance_mcg_daily=t4_maint,
            iv_liothyronine_t3_loading_mcg=t3_load,
            iv_liothyronine_t3_maintenance_mcg_q8h=t3_maint,
            clinical_instructions=instructions,
        )

    @staticmethod
    def generate_passive_rewarming_protocol() -> Dict[str, str]:
        """
        Generates passive rewarming protocol and active rewarming contraindications.
        """
        return {
            "protocol_name": "Passive External Rewarming Protocol",
            "method": (
                "Use ordinary hospital blankets and maintain warm ambient room temperature (22 - 24 °C). "
                "Allow core temperature to rise slowly (no faster than 0.5 - 1.0 °C per hour)."
            ),
            "contraindication_sentinel": (
                "STRICTLY FORBID ACTIVE EXTERNAL REWARMING (electric warming blankets, Bear Hugger forced-air units, "
                "immersion baths). Rapid external warming produces sudden, profound peripheral cutaneous vasodilation "
                "in a patient with depressed cardiac output, triggering catastrophic circulatory collapse and irreversible shock."
            ),
        }

    @staticmethod
    def generate_respiratory_and_fluid_sentinels(
        p: MyxedemaPatientPresentation,
    ) -> Tuple[Dict[str, str], Dict[str, str]]:
        """
        Generates respiratory mechanical ventilation sentinels and hyponatremia protocols.
        """
        resp_sentinel = {
            "airway_status": (
                f"Respiratory Acidosis / Hypercapnia Alert: PaCO2 is {p.paco2_mmhg} mmHg (Threshold > 50). "
                "Severely depressed central hypercapnic and hypoxic respiratory drive. Diaphragmatic myopathy "
                "and oropharyngeal myxedema (macroglossia) are present. IMMEDIATE ENDOTRACHEAL INTUBATION "
                "and mechanical ventilation indicated. Prepare for difficult airway."
                if p.paco2_mmhg > 50.0 or p.pao2_mmhg < 60.0
                else "Respiratory drive stable; monitor serial blood gases every 4-6 hours."
            ),
            "extubation_warning": "Weaning from mechanical ventilation is frequently prolonged (requires days of thyroid hormone therapy).",
        }

        hyponatremia_sentinel = {
            "sodium_level": f"Serum Sodium: {p.serum_sodium_meq_l} mEq/L",
            "mechanism": "Driven by impaired free-water excretion from elevated non-osmotic ADH (vasopressin) and low GFR.",
            "management_protocol": (
                "Strict fluid restriction (1000 mL/day isotonic crystalloid). DO NOT give hypotonic fluids (D5W). "
                + (
                    "CRITICAL HYPONATREMIA (< 120 mEq/L or seizures): Administer 3% Hypertonic Saline 100 mL IV bolus "
                    "over 10-20 minutes. Correct sodium cautiously (< 6 to 8 mEq/L in 24 hours) to avoid central pontine myelinolysis."
                    if p.serum_sodium_meq_l < 120.0
                    else "Thyroid hormone and hydrocortisone will prompt spontaneous aquaresis and normalize sodium."
                )
            ),
        }

        return resp_sentinel, hyponatremia_sentinel

    @classmethod
    def run_clinical_assessment(
        cls, p: MyxedemaPatientPresentation
    ) -> MyxedemaDecisionReport:
        """
        Runs the comprehensive end-to-end clinical assessment.
        """
        popoveniuc = cls.calculate_popoveniuc_score(p)
        adrenal = cls.generate_adrenal_safety_sentinel()
        thyroid = cls.calculate_thyroid_hormone_dosing(
            p.weight_kg, p.known_coronary_artery_disease_or_elderly or p.age_years >= 65.0
        )
        rewarming = cls.generate_passive_rewarming_protocol()
        resp, hyponatremia = cls.generate_respiratory_and_fluid_sentinels(p)

        return MyxedemaDecisionReport(
            popoveniuc_result=popoveniuc,
            adrenal_safety_sentinel=adrenal,
            thyroid_pharmacotherapy=thyroid,
            passive_rewarming_protocol=rewarming,
            respiratory_and_airway_sentinel=resp,
            hyponatremia_aquaresis_protocol=hyponatremia,
        )


# =====================================================================
# SELF-CONTAINED CLINICAL VALIDATION SUITE
# =====================================================================

def verify_clinical_scenarios():
    print("=" * 80)
    print("OpenPHR Cookbook 383: Acute Myxedema Coma Popoveniuc & Hormone Titrator Suite")
    print("=" * 80)

    # Test Case 1: Severe Classic Myxedema Coma (Temp 31.8 C, Coma, HR 38, Na 122, PaCO2 58)
    pt_classic = MyxedemaPatientPresentation(
        age_years=58.0,
        weight_kg=72.0,
        is_adult=True,
        known_coronary_artery_disease_or_elderly=False,
        core_temperature_celsius=31.8,  # Severe hypothermia (+30)
        cns_status="Coma",  # Frank coma (+30)
        gi_manifestations="Paralytic Ileus",  # Ileus (+15)
        heart_rate_bpm=38,  # Severe bradycardia (+20)
        systolic_bp_mmhg=78,  # Severe hypotension (+20)
        diastolic_bp_mmhg=44,
        has_pericardial_effusion_or_low_voltage=True,  # (+10)
        serum_sodium_meq_l=122.0,  # Severe hyponatremia (+10)
        serum_glucose_mg_dl=58.0,  # Hypoglycemia (+10)
        pao2_mmhg=52.0,  # Hypoxemia / Hypercapnia (+10)
        paco2_mmhg=58.0,
        has_acute_precipitant=True,  # Sepsis (+10)
    )

    rep1 = AcuteMyxedemaComaEngine.run_clinical_assessment(pt_classic)

    assert rep1.popoveniuc_result.total_score >= 60, f"Must be >= 60 (got {rep1.popoveniuc_result.total_score})"
    assert rep1.popoveniuc_result.is_diagnostic is True
    assert rep1.popoveniuc_result.risk_tier == PopoveniucRiskTier.DIAGNOSTIC_MYXEDEMA_COMA
    assert rep1.thyroid_pharmacotherapy.strategy == ThyroidReplacementStrategy.DUAL_T4_T3_STANDARD
    assert rep1.thyroid_pharmacotherapy.iv_levothyroxine_t4_loading_mcg == 300.0
    assert "ADMINISTER HYDROCORTISONE FIRST" in rep1.adrenal_safety_sentinel["sentinel_status"]

    print("[*] Test Case 1 (Severe Classic Myxedema Coma - Score >= 60) PASSED")
    print(f"    - Popoveniuc Score: {rep1.popoveniuc_result.total_score} points -> {rep1.popoveniuc_result.risk_tier.value}")
    print(f"    - Adrenal Sentinel: {rep1.adrenal_safety_sentinel['sentinel_status']}")
    print(f"    - Thyroid Regimen: T4 Load {rep1.thyroid_pharmacotherapy.iv_levothyroxine_t4_loading_mcg} mcg + T3 Load {rep1.thyroid_pharmacotherapy.iv_liothyronine_t3_loading_mcg} mcg")
    print(f"    - Rewarming Sentinel: {rep1.passive_rewarming_protocol['contraindication_sentinel'][:75]}...")

    # Test Case 2: Elderly Patient with Known CAD (Age 76, Temp 33.8 C, Stupor, Coronary-Sparing)
    pt_cad = MyxedemaPatientPresentation(
        age_years=76.0,
        weight_kg=64.0,
        is_adult=True,
        known_coronary_artery_disease_or_elderly=True,
        core_temperature_celsius=33.8,  # (+10)
        cns_status="Stupor",  # (+20)
        gi_manifestations="Decreased Sounds",  # (+10)
        heart_rate_bpm=48,  # (+20)
        systolic_bp_mmhg=88,  # (+20)
        has_pericardial_effusion_or_low_voltage=True,  # (+10)
        serum_sodium_meq_l=128.0,  # (+10)
        serum_glucose_mg_dl=68.0,  # (+10)
        pao2_mmhg=58.0,
        paco2_mmhg=52.0,  # (+10)
        has_acute_precipitant=True,  # (+10)
    )

    rep2 = AcuteMyxedemaComaEngine.run_clinical_assessment(pt_cad)

    assert rep2.popoveniuc_result.total_score >= 60
    assert rep2.thyroid_pharmacotherapy.strategy == ThyroidReplacementStrategy.DUAL_T4_T3_CORONARY_SPARING
    assert rep2.thyroid_pharmacotherapy.iv_levothyroxine_t4_loading_mcg == 200.0, "CAD patient receives 200 mcg load"
    assert rep2.thyroid_pharmacotherapy.iv_liothyronine_t3_loading_mcg == 5.0

    print("\n[*] Test Case 2 (Elderly Patient with CAD - Coronary-Sparing Protocol) PASSED")
    print(f"    - Strategy: {rep2.thyroid_pharmacotherapy.strategy.value}")
    print(f"    - Reduced T4 Load: {rep2.thyroid_pharmacotherapy.iv_levothyroxine_t4_loading_mcg} mcg (Maintenance: {rep2.thyroid_pharmacotherapy.iv_levothyroxine_t4_maintenance_mcg_daily} mcg/day)")
    print(f"    - Reduced T3 Load: {rep2.thyroid_pharmacotherapy.iv_liothyronine_t3_loading_mcg} mcg")

    print("\n>>> ALL CLINICAL VERIFICATION TESTS PASSED (100% CONCORDANCE) <<<")


if __name__ == "__main__":
    verify_clinical_scenarios()

Clinical Safety Sentinels & Practical Prescribing Rules

  1. Mandatory Hydrocortisone Prior to Thyroid Hormones: Thyroid hormone replacement increases metabolic rate, up-regulates hepatic clearance of cortisol, and accelerates adrenal cortisol consumption. If underlying primary or secondary adrenal insufficiency is present, thyroid hormone administration without glucocorticoid coverage precipitates catastrophic, fatal adrenal crisis. Always administer Hydrocortisone $100\text{ mg}$ IV STAT first.
  2. Proscription of Active External Rewarming: Never use active external warming (forced-air warmers, heating blankets) in hypothermic myxedema coma. Peripheral vasoconstriction maintains core perfusion; sudden active warming triggers massive peripheral vasodilation, precipitating profound hypovolemic shock and cardiac arrest. Rely strictly on passive rewarming (ordinary blankets).
  3. Coronary-Sparing Dosing in CAD and Elderly Patients: T3 increases myocardial oxygen demand and irritability. In patients with known coronary artery disease, history of myocardial infarction, or age $\ge 65$, reduce IV Levothyroxine loading to $200\ \mu\text{g}$ and Liothyronine loading to $2.5 - 5\ \mu\text{g}$ under continuous 12-lead ECG telemetry.
  4. Delayed Mechanical Ventilation Weaning: Hypothyroid respiratory failure results from both blunted central respiratory drive and diaphragmatic myopathy. Ventilatory weaning is prolonged and should not be attempted until thyroid hormone therapy has produced measurable hemodynamic and core temperature improvement.

Quality Assurance & Verification