Offline Clinical Pulmonology & Critical Care Acute Massive & Submassive Pulmonary Embolism (PE) ESC 2019/2024 Staging, Bova Risk Score, Dynamic Systemic Thrombolysis (Alteplase) & Catheter-Directed Thrombectomy Titrator

An enterprise-ready, offline-first Python clinical decision support engine for emergency and intensive care resuscitation of acute pulmonary embolism (PE). Evaluates hemodynamic stability, calculates the Simplified PESI (sPESI) and Bova Stage (I-III), analyzes right ventricular (RV) overload indices, gates systemic Alteplase ($100\text{ mg}$ full-dose vs. $50\text{ mg}$ half-dose) against absolute intracranial hemorrhage contraindications, and triggers catheter-directed mechanical thrombectomy / VA-ECMO escalation.


Clinical Architecture & Multimodal Risk Triage

Acute pulmonary embolism displays a bimodal mortality curve driven by acute right ventricular failure, severe RV-LV ventricular interdependence, and obstructive cardiogenic shock:

[ Acute Pulmonary Embolism Confirmed ]
                  |
     [ Hemodynamic Stability Sieve ]
                  |
       +----------+----------+
       |                     |
[ Hemodynamically Unstable ]  [ Hemodynamically Stable ]
(SBP < 90, Shock, Arrest)           |
       |                     [ sPESI Risk Calculation ]
[ High-Risk / Massive PE ]          |
       |               +-----+-----+
[ Immediate Resuscitation ]   |           |
- UFH Bolus 80 U/kg IV    [ sPESI = 0 ]  [ sPESI >= 1 ]
- Full-Dose Alteplase        |            |
  100 mg IV over 2 hr     [ Low Risk ]   [ RV Strain + Biomarkers? ]
(or 50 mg in Cardiac Arrest)              |
       |                     +------------+------------+
[ Bleeding Contraindication? ]|                         |
If Absolute Contraindicated: [ Both RV+ and Trop+ ]   [ Either or Neither ]
-> Emergent Catheter/Surg     |                         |
   Embolectomy or VA-ECMO     [ Intermediate-High ]     [ Intermediate-Low ]
                              (Bova Stage I, II, III)   (Hospital Ward / DOAC)
                              - ICU Monitoring
                              - Immediate UFH Infusion
                              - Rescue Thrombolysis Trigger

1. ESC 2019/2024 & CHEST Clinical Triage Categories

2. The Bova Intermediate-High Risk Score

The Bova scoring system identifies normotensive submassive PE patients at highest risk of decompensation:

Bova Stage Total Score 30-Day PE Complication Rate Clinical Disposition
Stage I $0 - 2$ points $4.4\%$ Monitored step-down telemetry
Stage II $3 - 4$ points $18.0\%$ Intensive Care Unit (ICU) admission
Stage III $5 - 7$ points $42.0\%$ Dedicated ICU + Perfusion Alert / CDT team standby

Production Python Implementation

"""
OpenPHR Cookbook 403: Acute Massive & Submassive PE ESC/Bova Titrator
Clinical Standards: ESC 2019/2024 Guidelines on Acute Pulmonary Embolism & CHEST 2021
Execution: Deterministic, Zero External Dependencies, Offline Edge Verified
"""

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


class HemodynamicStatus(Enum):
    CARDIAC_ARREST = "Cardiac Arrest (PEA / Asystole from suspected/proven massive PE)"
    OBSTRUCTIVE_SHOCK = "Obstructive Shock (Systolic BP < 90 mmHg or vasopressor requirement with end-organ hypoperfusion)"
    PERSISTENT_HYPOTENSION = "Persistent Hypotension (Systolic BP < 90 mmHg or SBP drop >= 40 mmHg for > 15 min)"
    HEMODYNAMICALLY_STABLE = "Hemodynamically Stable (Systolic BP >= 90 mmHg without inotropes/vasopressors)"


class ESCPETriageTier(Enum):
    HIGH_RISK_MASSIVE = "High-Risk (Massive) PE - Emergent Reperfusion Mandated"
    INTERMEDIATE_HIGH_SUBMASSIVE = "Intermediate-High Risk (Submassive) PE - ICU Monitoring & Reperfusion Standby"
    INTERMEDIATE_LOW = "Intermediate-Low Risk PE - Inpatient Monitoring & Anticoagulation"
    LOW_RISK = "Low-Risk PE - Favorable Prognosis / Early Discharge Candidate"


class ReperfusionStrategy(Enum):
    FULL_DOSE_SYSTEMIC_THROMBOLYSIS = "Full-Dose Systemic Thrombolysis (Alteplase 100 mg IV over 2 hours)"
    ACCELERATED_CARDIAC_ARREST_BOLUS = "Accelerated Thrombolysis (Alteplase 50 mg IV bolus over 2 minutes)"
    HALF_DOSE_SYSTEMIC_THROMBOLYSIS = "Half-Dose 'Safe PE' Thrombolysis (Alteplase 50 mg IV over 2 hours)"
    CATHETER_DIRECTED_THERAPY_OR_EMBOLECTOMY = "Catheter-Directed Therapy (CDT) / Surgical Embolectomy (Thrombolysis Contraindicated)"
    PRIMARY_ANTICOAGULATION_ONLY = "Therapeutic Anticoagulation Only (Reperfusion Withheld Unless Hemodynamic Collapse)"


@dataclass
class PatientPEProfile:
    age_years: float
    weight_kg: float
    is_male: bool
    heart_rate_bpm: float
    systolic_bp_mmhg: float
    arterial_o2_sat_percent: float
    has_history_of_cancer: bool = False
    has_chronic_heart_failure: bool = False
    has_chronic_pulmonary_disease: bool = False
    rv_lv_ratio_ct_or_echo: float = 0.8
    tapse_mm: float = 20.0
    troponin_positive: bool = False
    nt_probnp_elevated: bool = False
    hemodynamic_state: HemodynamicStatus = HemodynamicStatus.HEMODYNAMICALLY_STABLE
    # Bleeding Risk & Contraindication Flags
    has_prior_intracranial_hemorrhage: bool = False
    has_ischemic_stroke_within_6_months: bool = False
    has_active_bleeding_or_cns_neoplasm: bool = False
    has_major_surgery_trauma_within_3_weeks: bool = False


@dataclass
class SPESIResult:
    score: int
    is_high_risk: bool
    risk_factors: List[str]


@dataclass
class BovaResult:
    score: int
    stage: str
    thirty_day_complication_risk_pct: float
    rationale: str


@dataclass
class HeparinAnticoagulationRegimen:
    bolus_dose_units: float
    initial_infusion_rate_units_per_hr: float
    infusion_ml_per_hr_at_50_u_ml: float
    target_aptt_seconds: str
    titration_rules: str


@dataclass
class ReperfusionGuidance:
    tier: ESCPETriageTier
    strategy: ReperfusionStrategy
    indicated_drug: str
    dosing_schedule: str
    bleeding_contraindication_present: bool
    absolute_contraindications: List[str]
    clinical_rationale: str


@dataclass
class ComprehensivePEAssessment:
    patient_summary: Dict[str, str]
    spesi: SPESIResult
    bova: Optional[BovaResult]
    heparin: HeparinAnticoagulationRegimen
    reperfusion: ReperfusionGuidance
    critical_sentinels: List[str]


class AcutePulmonaryEmbolismEngine:
    """
    Offline Clinical Decision Engine for Acute PE Resuscitation & Thrombolytic Titration.
    Conforms to ESC 2019/2024 Guidelines and CHEST 2021 Criteria.
    """

    @classmethod
    def calculate_spesi(cls, patient: PatientPEProfile) -> SPESIResult:
        """
        Calculates Simplified PESI (sPESI) score (0 = low risk, >= 1 = high 30-day mortality risk).
        """
        score = 0
        factors: List[str] = []

        if patient.age_years > 80:
            score += 1
            factors.append("Age > 80 years (+1)")
        if patient.has_history_of_cancer:
            score += 1
            factors.append("History of malignancy (+1)")
        if patient.has_chronic_heart_failure or patient.has_chronic_pulmonary_disease:
            score += 1
            factors.append("Chronic cardiopulmonary disease (+1)")
        if patient.heart_rate_bpm >= 110:
            score += 1
            factors.append("Heart rate >= 110 bpm (+1)")
        if patient.systolic_bp_mmhg < 100:
            score += 1
            factors.append("Systolic BP < 100 mmHg (+1)")
        if patient.arterial_o2_sat_percent < 90:
            score += 1
            factors.append("Arterial SaO2 < 90% (+1)")

        return SPESIResult(
            score=score,
            is_high_risk=score >= 1,
            risk_factors=factors,
        )

    @classmethod
    def calculate_bova(cls, patient: PatientPEProfile, rv_dysfunction: bool) -> BovaResult:
        """
        Calculates Bova Stage for normotensive intermediate-risk patients.
        Points: SBP 90-100 (+2), HR >= 110 (+1), Troponin+ (+2), RV dysfunction (+2).
        """
        score = 0
        reasons: List[str] = []

        if 90.0 <= patient.systolic_bp_mmhg <= 100.0:
            score += 2
            reasons.append("Borderline SBP 90-100 mmHg (+2)")
        if patient.heart_rate_bpm >= 110.0:
            score += 1
            reasons.append("Tachycardia HR >= 110 bpm (+1)")
        if patient.troponin_positive:
            score += 2
            reasons.append("Cardiac Troponin Elevated (+2)")
        if rv_dysfunction:
            score += 2
            reasons.append("RV Dysfunction (RV/LV > 0.9 or TAPSE < 16 mm) (+2)")

        if score <= 2:
            stage = "Stage I (Low-Intermediate Risk)"
            pct = 4.4
        elif score <= 4:
            stage = "Stage II (Moderate-Intermediate Risk)"
            pct = 18.0
        else:
            stage = "Stage III (High-Intermediate Risk)"
            pct = 42.0

        return BovaResult(
            score=score,
            stage=stage,
            thirty_day_complication_risk_pct=pct,
            rationale="; ".join(reasons) if reasons else "No risk points identified.",
        )

    @classmethod
    def evaluate_rv_dysfunction(cls, patient: PatientPEProfile) -> bool:
        """
        Detects significant right ventricular strain / failure.
        """
        return (
            patient.rv_lv_ratio_ct_or_echo > 0.9
            or patient.tapse_mm < 16.0
            or patient.nt_probnp_elevated
        )

    @classmethod
    def evaluate_bleeding_contraindications(cls, patient: PatientPEProfile) -> Tuple[bool, List[str]]:
        """
        Screens for absolute contraindications to systemic thrombolytic therapy.
        """
        contraindications: List[str] = []
        if patient.has_prior_intracranial_hemorrhage:
            contraindications.append("Prior hemorrhagic stroke or intracranial hemorrhage of any etiology (ABSOLUTE)")
        if patient.has_ischemic_stroke_within_6_months:
            contraindications.append("Known ischemic stroke within previous 6 months (ABSOLUTE)")
        if patient.has_active_bleeding_or_cns_neoplasm:
            contraindications.append("Active internal bleeding or known central nervous system neoplasm/AVM (ABSOLUTE)")
        if patient.has_major_surgery_trauma_within_3_weeks:
            contraindications.append("Major surgery, severe head/spine trauma, or obstetrical delivery within 3 weeks (ABSOLUTE)")

        return (len(contraindications) > 0, contraindications)

    @classmethod
    def generate_heparin_infusion_protocol(cls, weight_kg: float) -> HeparinAnticoagulationRegimen:
        """
        Generates standard weight-based Unfractionated Heparin (UFH) dosing for acute PE.
        """
        # 80 units/kg bolus (capped at 10,000 units), then 18 units/kg/hr
        bolus = min(10000.0, round(weight_kg * 80.0, 0))
        rate_units = round(weight_kg * 18.0, 0)
        # Assuming standard concentration of 25,000 units / 500 mL (50 units/mL)
        rate_ml_hr = round(rate_units / 50.0, 1)

        return HeparinAnticoagulationRegimen(
            bolus_dose_units=bolus,
            initial_infusion_rate_units_per_hr=rate_units,
            infusion_ml_per_hr_at_50_u_ml=rate_ml_hr,
            target_aptt_seconds="60 - 80 seconds (or anti-Xa 0.3 - 0.7 IU/mL)",
            titration_rules=(
                "Recheck aPTT every 6 hours after rate changes. In massive PE receiving Alteplase, "
                "withhold UFH during the 2-hour Alteplase infusion, then resume UFH without bolus "
                "when aPTT falls below 2x baseline (typically < 80 seconds)."
            ),
        )

    @classmethod
    def determine_triage_and_reperfusion(
        cls,
        patient: PatientPEProfile,
        spesi: SPESIResult,
        rv_strain: bool,
        bleeding_contraindicated: bool,
        contraindications: List[str],
    ) -> ReperfusionGuidance:
        """
        Determines ESC risk tier and exact reperfusion pharmacotherapy regimen.
        """
        # Tier 1: High-Risk (Massive PE)
        if patient.hemodynamic_state in (
            HemodynamicStatus.CARDIAC_ARREST,
            HemodynamicStatus.OBSTRUCTIVE_SHOCK,
            HemodynamicStatus.PERSISTENT_HYPOTENSION,
        ):
            tier = ESCPETriageTier.HIGH_RISK_MASSIVE

            if bleeding_contraindicated:
                strategy = ReperfusionStrategy.CATHETER_DIRECTED_THERAPY_OR_EMBOLECTOMY
                drug = "None (Systemic Thrombolysis Strictly Proscribed)"
                dosing = "Urgent Catheter-Directed Mechanical Thrombectomy / Surgical Pulmonary Embolectomy or VA-ECMO"
                rationale = (
                    "Patient is in life-threatening massive PE with cardiogenic shock, but has ABSOLUTE "
                    f"contraindications to systemic thrombolysis ({', '.join(contraindications)}). "
                    "Proceed immediately to catheter thrombectomy, surgical embolectomy, or VA-ECMO rescue."
                )
            elif patient.hemodynamic_state == HemodynamicStatus.CARDIAC_ARREST:
                strategy = ReperfusionStrategy.ACCELERATED_CARDIAC_ARREST_BOLUS
                drug = "Alteplase (recombinant tissue plasminogen activator, rtPA)"
                dosing = "50 mg IV push over 2 minutes; continue CPR for minimum 30 minutes to allow drug distribution."
                rationale = "Arrest secondary to PE requires rapid-push bolus thrombolysis and prolonged resuscitation."
            else:
                strategy = ReperfusionStrategy.FULL_DOSE_SYSTEMIC_THROMBOLYSIS
                drug = "Alteplase (rtPA)"
                dosing = "100 mg IV continuous infusion over 2 hours (or 0.6 mg/kg up to max 50 mg over 15 minutes if rapidly crashing)."
                rationale = "ESC Grade 1A indication for immediate full-dose systemic thrombolysis to relieve RV outflow obstruction."

            return ReperfusionGuidance(
                tier=tier,
                strategy=strategy,
                indicated_drug=drug,
                dosing_schedule=dosing,
                bleeding_contraindication_present=bleeding_contraindicated,
                absolute_contraindications=contraindications,
                clinical_rationale=rationale,
            )

        # Tier 2: Intermediate-Risk PE
        has_myocardial_injury = patient.troponin_positive or patient.nt_probnp_elevated

        if rv_strain and has_myocardial_injury:
            tier = ESCPETriageTier.INTERMEDIATE_HIGH_SUBMASSIVE
            strategy = ReperfusionStrategy.PRIMARY_ANTICOAGULATION_ONLY
            drug = "Unfractionated Heparin (UFH) Continuous Infusion + Rescue Standby"
            dosing = "Therapeutic UFH infusion. Prepare Alteplase (100 mg full-dose or 50 mg half-dose) at bedside."
            rationale = (
                "Intermediate-High Risk PE (both RV strain and elevated biomarkers present). Primary systemic thrombolysis "
                "is NOT recommended upfront due to 2-3% intracranial hemorrhage risk (PEITHO trial), BUT close ICU telemetry "
                "is mandatory. Trigger immediate rescue reperfusion if systolic BP drops < 90 mmHg or tissue perfusion fails."
            )
        elif rv_strain or has_myocardial_injury or spesi.is_high_risk:
            tier = ESCPETriageTier.INTERMEDIATE_LOW
            strategy = ReperfusionStrategy.PRIMARY_ANTICOAGULATION_ONLY
            drug = "Low-Molecular-Weight Heparin (LMWH) or DOAC (Apixaban / Rivaroxaban)"
            dosing = "Enoxaparin 1 mg/kg SC q12h or Fondaparinux; transition to oral Factor Xa inhibitor when stable."
            rationale = "Intermediate-Low Risk PE. Inpatient monitored step-down bed; low risk of rapid decompensation."
        else:
            tier = ESCPETriageTier.LOW_RISK
            strategy = ReperfusionStrategy.PRIMARY_ANTICOAGULATION_ONLY
            drug = "Oral Direct Oral Anticoagulant (DOAC: Apixaban 10 mg BID x7d or Rivaroxaban 15 mg BID x21d)"
            dosing = "Initiate oral DOAC upfront; assess for early home discharge within 24 hours under Hestia / PESI criteria."
            rationale = "Low-Risk PE with sPESI 0, normal RV anatomy, and negative biomarkers. Excellent prognosis."

        return ReperfusionGuidance(
            tier=tier,
            strategy=strategy,
            indicated_drug=drug,
            dosing_schedule=dosing,
            bleeding_contraindication_present=bleeding_contraindicated,
            absolute_contraindications=contraindications,
            clinical_rationale=rationale,
        )

    @classmethod
    def run_assessment(cls, patient: PatientPEProfile) -> ComprehensivePEAssessment:
        """
        Executes end-to-end multimodal risk triage and generates resuscitation prescriptions.
        """
        spesi = cls.calculate_spesi(patient)
        rv_strain = cls.evaluate_rv_dysfunction(patient)
        bleeding_flag, contraindications = cls.evaluate_bleeding_contraindications(patient)

        # Calculate Bova if patient is normotensive and has intermediate-risk features
        is_normotensive = patient.hemodynamic_state == HemodynamicStatus.HEMODYNAMICALLY_STABLE
        bova = cls.calculate_bova(patient, rv_strain) if is_normotensive else None

        heparin = cls.generate_heparin_infusion_protocol(patient.weight_kg)
        reperfusion = cls.determine_triage_and_reperfusion(
            patient, spesi, rv_strain, bleeding_flag, contraindications
        )

        sentinels: List[str] = []
        if reperfusion.tier == ESCPETriageTier.HIGH_RISK_MASSIVE:
            sentinels.append(
                "MASSIVE PE RESUSCITATION SENTINEL: Restrict aggressive crystalloid boluses! "
                "Over-infusion (> 500 mL) severely worsens right ventricular dilatation, precipitates leftward "
                "interventricular septal bowing, decreases LV stroke volume, and causes circulatory collapse."
            )
            sentinels.append(
                "FIRST-LINE VASOPRESSOR: Norepinephrine is the pressor of choice (restores systemic perfusion "
                "pressure and RV coronary perfusion without disproportionate pulmonary vasoconstriction)."
            )
        if reperfusion.tier == ESCPETriageTier.INTERMEDIATE_HIGH_SUBMASSIVE:
            sentinels.append(
                f"PEITHO RESCUE TRIGGER ALERT: Bova {bova.stage if bova else 'Submassive'} indicates high risk "
                f"({bova.thirty_day_complication_risk_pct if bova else 'elevated'}% 30-day collapse). Maintain bedside "
                "Alteplase or alert Catheter Embolectomy team immediately if hemodynamics deteriorate."
            )

        summary = {
            "Presentation": f"{patient.age_years:.0f}yo {'M' if patient.is_male else 'F'}, {patient.weight_kg:.1f} kg",
            "Hemodynamics": f"SBP {patient.systolic_bp_mmhg:.0f} mmHg, HR {patient.heart_rate_bpm:.0f} bpm, SaO2 {patient.arterial_o2_sat_percent:.0f}%",
            "Hemodynamic Classification": patient.hemodynamic_state.value,
            "sPESI Risk Score": f"{spesi.score} ({'High Risk (30-day mortality)' if spesi.is_high_risk else 'Low Risk'})",
            "Right Ventricular Strain": f"RV/LV ratio {patient.rv_lv_ratio_ct_or_echo:.2f}, TAPSE {patient.tapse_mm:.1f} mm -> {'Positive RV Strain' if rv_strain else 'Normal'}",
            "Biomarkers": f"Troponin {'POSITIVE' if patient.troponin_positive else 'Negative'}, NT-proBNP {'Elevated' if patient.nt_probnp_elevated else 'Normal'}",
            "ESC Triage Tier": reperfusion.tier.value,
        }

        return ComprehensivePEAssessment(
            patient_summary=summary,
            spesi=spesi,
            bova=bova,
            heparin=heparin,
            reperfusion=reperfusion,
            critical_sentinels=sentinels,
        )


# ==============================================================================
# Clinical Verification & Validation Suite
# ==============================================================================

def verify_clinical_scenarios():
    print("=" * 80)
    print("OpenPHR Cookbook 403: Acute Massive & Submassive PE Multimodal Titrator")
    print("=" * 80)

    # Scenario 1: Acute Massive PE in Obstructive Shock (Systolic BP 74, RV/LV 1.4, Troponin+)
    p1 = PatientPEProfile(
        age_years=64.0,
        weight_kg=82.0,
        is_male=True,
        heart_rate_bpm=128.0,
        systolic_bp_mmhg=74.0,
        arterial_o2_sat_percent=86.0,
        rv_lv_ratio_ct_or_echo=1.45,
        tapse_mm=11.0,
        troponin_positive=True,
        nt_probnp_elevated=True,
        hemodynamic_state=HemodynamicStatus.OBSTRUCTIVE_SHOCK,
    )
    res1 = AcutePulmonaryEmbolismEngine.run_assessment(p1)

    assert res1.reperfusion.tier == ESCPETriageTier.HIGH_RISK_MASSIVE
    assert res1.reperfusion.strategy == ReperfusionStrategy.FULL_DOSE_SYSTEMIC_THROMBOLYSIS
    assert "100 mg IV continuous infusion" in res1.reperfusion.dosing_schedule
    assert res1.heparin.bolus_dose_units == 6560.0  # 82 * 80
    assert any("MASSIVE PE RESUSCITATION SENTINEL" in s for s in res1.critical_sentinels)

    print("[*] Test Case 1 (High-Risk Massive PE with Obstructive Shock) PASSED")
    print(f"    - ESC Tier: {res1.reperfusion.tier.value}")
    print(f"    - Strategy: {res1.reperfusion.strategy.value}")
    print(f"    - Dosing: {res1.reperfusion.dosing_schedule}")
    print(f"    - Heparin Load: {res1.heparin.bolus_dose_units} units bolus, then {res1.heparin.initial_infusion_rate_units_per_hr} units/hr")

    # Scenario 2: Intermediate-High Risk Submassive PE (Normotensive SBP 112, RV Strain, Troponin+, Bova III)
    p2 = PatientPEProfile(
        age_years=71.0,
        weight_kg=75.0,
        is_male=False,
        heart_rate_bpm=114.0,
        systolic_bp_mmhg=98.0,  # SBP 90-100 gives +2 on Bova
        arterial_o2_sat_percent=92.0,
        rv_lv_ratio_ct_or_echo=1.2,
        tapse_mm=13.5,
        troponin_positive=True,
        hemodynamic_state=HemodynamicStatus.HEMODYNAMICALLY_STABLE,
    )
    res2 = AcutePulmonaryEmbolismEngine.run_assessment(p2)

    assert res2.reperfusion.tier == ESCPETriageTier.INTERMEDIATE_HIGH_SUBMASSIVE
    assert res2.bova is not None
    assert res2.bova.score >= 5  # HR 114 (+1), SBP 98 (+2), Trop+ (+2), RV+ (+2) = 7 pts (Stage III)
    assert "Stage III" in res2.bova.stage
    assert res2.bova.thirty_day_complication_risk_pct == 42.0
    assert res2.reperfusion.strategy == ReperfusionStrategy.PRIMARY_ANTICOAGULATION_ONLY
    assert any("PEITHO RESCUE TRIGGER" in s for s in res2.critical_sentinels)

    print("\n[*] Test Case 2 (Intermediate-High Risk Submassive PE / Bova Stage III) PASSED")
    print(f"    - ESC Tier: {res2.reperfusion.tier.value}")
    print(f"    - Bova Score: {res2.bova.score} points -> {res2.bova.stage} ({res2.bova.thirty_day_complication_risk_pct}% 30-day collapse risk)")
    print(f"    - Primary Strategy: {res2.reperfusion.strategy.value}")

    # Scenario 3: Massive PE with Absolute Bleeding Contraindication (Prior Intracranial Hemorrhage)
    p3 = PatientPEProfile(
        age_years=58.0,
        weight_kg=70.0,
        is_male=True,
        heart_rate_bpm=122.0,
        systolic_bp_mmhg=80.0,
        arterial_o2_sat_percent=88.0,
        hemodynamic_state=HemodynamicStatus.OBSTRUCTIVE_SHOCK,
        has_prior_intracranial_hemorrhage=True,
    )
    res3 = AcutePulmonaryEmbolismEngine.run_assessment(p3)

    assert res3.reperfusion.tier == ESCPETriageTier.HIGH_RISK_MASSIVE
    assert res3.reperfusion.strategy == ReperfusionStrategy.CATHETER_DIRECTED_THERAPY_OR_EMBOLECTOMY
    assert res3.reperfusion.bleeding_contraindication_present is True
    assert "Catheter-Directed Mechanical Thrombectomy" in res3.reperfusion.dosing_schedule

    print("\n[*] Test Case 3 (Massive PE with Intracranial Hemorrhage Contraindication) PASSED")
    print(f"    - Bleeding Flag: {res3.reperfusion.bleeding_contraindication_present}")
    print(f"    - Strategy: {res3.reperfusion.strategy.value}")
    print(f"    - Regimen: {res3.reperfusion.dosing_schedule}")

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


if __name__ == "__main__":
    verify_clinical_scenarios()

Clinical Safety Sentinels & Practical Rules

  1. Fluid Restriction in Acute Cor Pulmonale: Excessive fluid loading ($> 500\text{ mL}$) in massive PE elevates right ventricular end-diastolic pressure, worsens ischemia of the stretched RV free wall, induces interventricular septal flattening, and reduces left ventricular preload, precipitating sudden pulseless electrical activity (PEA) arrest. Fluid administration should be modest ($< 250 - 500\text{ mL}$ of balanced crystalloid) only if hypovolemia is evident.
  2. First-Choice Pressor: Norepinephrine: Norepinephrine is preferred over phenylephrine or dopamine. It restores systemic blood pressure and right coronary artery perfusion pressure while stimulating myocardial inotropy, without causing disproportionate pulmonary vascular resistance increases.
  3. PEITHO Trial Principle in Submassive PE: In intermediate-high risk (normotensive submassive) PE, routine upfront systemic thrombolysis reduces hemodynamic collapse but increases major non-intracranial and intracranial hemorrhage from $0.2\%$ to $2.0\%$. Anticoagulate with therapeutic Unfractionated Heparin (UFH) in an intensive care setting, reserving systemic thrombolysis, half-dose Alteplase ($50\text{ mg}$), or catheter-directed therapy (CDT) for clinical decompensation.
  4. Immediate Cardiac Arrest Dose: When acute PE induces cardiac arrest, administer Alteplase $50\text{ mg}$ IV push over 2 minutes, and maintain closed-chest CPR for at least 30 minutes following administration to ensure pulmonary vascular thrombolytic circulation.

Quality Assurance & Verification

Verified Offline Clinical Architecture

Clinical Execution Complete

Explore peer algorithms across acute neurology, critical care, and cardiology.

📖 All 418 Cookbooks Explore 737 Assets →
CRITICAL CARE / ICU
Septic Shock Sepsis-3 SOFA & Surviving Sepsis Bundle Engine

Automated 6-organ SOFA scoring, 30 mL/kg fluid resuscitation, and multi-tier vasopressor escalation.

NEUROLOGY / STROKE
Stroke EVT DAWN & DEFUSE 3 Perfusion Mismatch Engine

10-point ASPECTS score, CT perfusion core/penumbra ratio, and post-revascularization TICI hemodynamics.

CARDIOLOGY / RESUSCITATION
Post-Cardiac Arrest TTM2 & Neuroprognostication

Targeted Temperature Management (37.5°C ceiling), SSEP, and multi-modal neurological recovery staging.

OpenPHR AI Student Fellowship

Build Publication-Ready Clinical AI with Penn & MIT Mentors

Work on open-source medical foundation models, DICOM/FHIR architectures, and clinical CDS engines.

Apply for Fellowship →