Pneumocystis (jirovecii) Pneumonia
PJP = host-defined opportunistic Bayesian rule-in engine. §5.5.2 wired: pretest set by host class (HIV CD4 band vs non-HIV iatrogenic substrate) in FRAME/CONTEXT; sequential test LRs (serum β-D-glucan sens ~91%/spec ~79% PMID 32479781, BAL immunofluorescence specific vs quantitative PCR sensitive, LDH sensitive/non-specific, HRCT ground-glass with high NPV if normal); confirm → empiric TMP-SMX → adjunctive-steroid threshold (PaO2 <70 / A-a >35 / SpO2 <92%) → immune reconstitution. HIV-vs-non-HIV is the dominant axis (tempo, burden, β-D-glucan NPV, steroid-evidence strength, mortality). Two conditional dependencies explicitly modeled and flagged do-not-read-in-isolation: (1) β-D-glucan post-test probability | host pretest band — a negative test rules out only at low-intermediate prior (non-HIV ≤20%, HIV ≤50%) (severity_trigger beta_d_glucan_negative_conditional_on_host_band; INITIAL_WORKUP phase logic; Del Corpo CMI 2020 PMID 32479781, Li 2015 PMID 26793343); (2) BAL-PCR positivity | colonization vs invasive disease — a low-burden positive PCR may reflect colonization, interpreted jointly with IF stain + HRCT + host (severity_trigger bal_pcr_positive_low_burden_colonization_vs_disease). Effect sizes wired with PMIDs (≥5): Bozzette/California Collaborative (PMID 2233917) 31-d respiratory failure 0.14 vs 0.30 (P=0.004), death 0.11 vs 0.23 (P=0.009), 84-d death 0.16 vs 0.26 (P=0.026); Gagnon/Consensus (PMID 2233916) survival 75% vs 18% (P<0.008); Del Corpo β-D-glucan (PMID 32479781) sens 91%/spec 79%, HIV 94% vs non-HIV 86%; Li (PMID 26793343) sens 0.91/spec 0.75; Cilloniz (PMID 31550942) HIV ~15% vs non-HIV ~50% in-hospital mortality; Feng (PMID 35313548) non-HIV nomogram AUC 0.865 / HIV C-index 0.904; Zolopa ACTG A5164 (PMID 19440326) early-ART AIDS progression/death OR 0.51 (95% CI 0.27-0.94), HR 0.53; Safrin ACTG 108 (PMID 8610948) TMP-SMX ≈ dapsone-TMP ≈ clinda-primaquine mild-moderate. Cross-dossier routing via workups[].branches_to + sibling_differentiation[].sibling_engine_id using real engine_ids confirmed by grep of src/lib/dossiers/: pulm.cap.core.v1, pulm.tuberculosis.v1, id.sepsis.core.v1, pulm.ards.core.v1, id.cmv-immunocompromised.core.v1, id.hiv-initial.chronic.v1, id.opportunistic-infection.hiv-transplant.v1. Differential pivots authored as sibling feature rows + DIFFERENTIAL/BRANCHING phase logic: PJP vs bacterial CAP vs CMV vs viral (flu/COVID) vs TB vs invasive fungal vs lymphangitic carcinomatosis vs drug-induced pneumonitis vs IRIS. Special populations: HIV (CD4 band prior, strong steroid RCT evidence, early ART per Zolopa ACTG A5164, secondary prophylaxis stop at CD4 >200 ×3 mo) vs non-HIV (iatrogenic substrate, fulminant/higher-mortality, lower diagnostic yield → earlier BAL, weaker steroid evidence at same threshold, immunosuppressant minimization) as DISTINCT branches; transplant/biologic/chemo (route id.opportunistic-infection.hiv-transplant.v1); pregnancy (TMP-SMX still first-line + folate + delivery-timing for neonatal kernicterus, avoid primaquine); G6PD (screen before dapsone/primaquine — absolute contraindication); severe sulfa allergy (alternatives vs desensitization for non-severe only); renal/hepatic dose-adjust per drug in contraindication_rules. Regimen axis: TMP-SMX 15-20 mg/kg/day TMP weight-based (mild PO / moderate-severe IV) + Bozzette adjunctive steroid taper (40 BID×5d → 40 daily×5d → 20 daily×11d) + alternatives by sulfa-allergy/G6PD/severity (clindamycin+primaquine, atovaquone mild, IV pentamidine severe, dapsone-TMP, sulfa desensitization for non-severe reactions) + duration HIV 21 d / non-HIV 14-21 d + secondary prophylaxis with explicit stop criteria (CD4 >200 ×3 mo HIV; immunosuppression resolved non-HIV) + deprescribing + explicit leucovorin-AVOID rule. Matches pulm.cap.core.v1 / pulm.pe.core.v1 regimen depth. RxCUI sanity-check vs RxNav REST /rxcui/{cui}/properties.json 2026-05-16 — THREE SAFETY-CRITICAL CORRECTIONS: (a) TMP-SMX combination 10180 (=sulfamethoxazole single-ingredient IN) / 10829 (=trimethoprim single-ingredient IN) → 10831 = sulfamethoxazole/trimethoprim (MIN); (b) the prior dossier notes mapped dapsone→3008 (=cyclosporine), primaquine→8745 (=promethazine), pentamidine→8167 (=phenylhydrazine) — all WRONG; corrected to dapsone 3108 (IN), primaquine 8687 (IN), pentamidine 7994 (IN), clindamycin 2582 (IN), all RxNav-verified. Confirmed-correct unchanged: atovaquone 60212 (IN), prednisone 8640 (IN), methylprednisolone 6902 (IN), oxygen 7806 (IN); added caspofungin 140108 (IN), leucovorin 6313 (IN). No hand-authored CUIs — every CUI WebSearch/RxNav-confirmed. Run npm run research:rxnav:validate for dose-specific SCD/SBD resolution. SCHEMA-GAP NOTES: (1) _types.ts has no first-class field for Bayesian pretest/LR/post-test/decision-threshold or a host-conditional graph — encoded in severity_triggers, phase purpose/advance_when, calculator guideline_basis, regimen rationale, and the .depth.md LR table; (2) RequiredCalculator.drives lacks diagnostic_gate — A-a/host bands reuse severity_classification; (3) no pretest-prevalence field — captured in calc.aa_gradient guideline_basis + .depth.md; (4) no co-infection/overlap field — CMV/TB co-infection encoded via severity_triggers + workups branches_to + BRANCHING phase logic; (5) no host-class enum (HIV vs non-HIV) — modeled in FRAME phase + non_hiv_pjp_fulminant_high_mortality trigger + sibling feature rows. PRODUCTION blockers: (1) all RxCUIs RxNav-verified this pass but run npm run research:rxnav:validate before dosing automation (SCD/SBD); (2) calc.aa_gradient / calc.ckd_epi_2021 not confirmed individually in clinical-tools-registry this scope (reused existing pcp_pneumonia workup adapter id only — no registry edits); (3) no engine-specific test file under tests/ beyond the shared contract test; (4) no _design-brief.md inside the package path (separate from the in-scope _briefs/ deliverables authored this pass); (5) package path pneumocystis-jirovecii-pneumonia/ unchanged (manifest/package pointers out of scope, not touched).
Entry points (5)
- symptomSubacute progressive dyspnea + dry non-productive cough ± low-grade fever, often with marked exertional desaturation, in an immunocompromised host (NIH/CDC OI 2025)subacute_dyspnea_dry_cough
- imagingBilateral perihilar / diffuse ground-glass opacities on HRCT (HRCT GGO LR+ high in the right host; near-perfect negative predictive value if HRCT normal) (NIH/CDC OI 2025)bilateral_perihilar_ground_glass
- lab_abnormalityElevated LDH (often >500 U/L) — sensitive but non-specific; tracks burden/response (NIH/CDC OI 2025)ldh_elevated
- lab_abnormalityElevated serum (1→3)-β-D-glucan in an immunocompromised host (sens ~91%; interpret post-test conditional on host pretest band — Del Corpo CMI 2020 PMID 32479781)beta_d_glucan_elevated
- problem_listHIV CD4 <200 (esp. <100), solid-organ/HSCT transplant, prednisone ≥20 mg/day ≥4 wk, B-cell-depleting/anti-TNF/calcineurin/chemo immunosuppression, primary immunodeficiency (NIH/CDC OI 2025)immunocompromised
Required inputs (20)
- agerequireddemographic • used at CONTEXTAdult dosing of TMP-SMX; pediatric PJP routes to pediatric OI guidance (out of scope here) (NIH/CDC OI 2025)
- weightrequireddemographic • used at TREATMENTWeight-based TMP-SMX dosing 15-20 mg/kg/day of the TMP component ÷ q6-8h (NIH/CDC OI 2025)
- spo2requiredvital • used at CONTEXTResting room-air SpO2 <92% is a guideline adjunctive-steroid trigger and the bedside surrogate for the PaO2/A-a threshold (NIH/CDC OI 2025; Bozzette NEJM 1990 PMID 2233917)
- rrrequiredvital • used at CONTEXTTachypnea + work of breathing — severity grading and respiratory-failure screen (NIH/CDC OI 2025)
- sbpvital • used at CONTEXTSeptic shock / concurrent bacterial sepsis screen (route → id.sepsis.core.v1) (SSC 2026)
- hiv_or_immunosuppressionrequiredhistory • used at CONTEXTSets the Bayesian PRIOR — HIV CD4 band vs non-HIV iatrogenic substrate; the HIV-vs-non-HIV axis governs presentation tempo, β-D-glucan NPV, steroid-evidence strength, and mortality (Cilloniz 2019 PMID 31550942)
- cd4_countlab • used at CONTEXTHIV pretest band: CD4 <200 (esp. <100) → high PJP prior; CD4 >200 makes HIV-PJP unlikely and shifts the differential (NIH/CDC OI 2025)
- immunosuppressant_regimenhistory • used at CONTEXTNon-HIV substrate weighting: chronic steroid ≥20 mg pred ≥4 wk, rituximab/anti-CD20, anti-TNF, calcineurin inhibitor, alkylator/fludarabine, transplant — most non-HIV PJP occurs when NOT on prophylaxis (NIH/CDC OI 2025)
- sulfa_allergyrequiredhistory • used at CONTEXTDrives alternative-agent selection and the desensitization-vs-alternative decision if sulfa-allergic (NIH/CDC OI 2025)
- g6pd_statushistory • used at CONTEXTG6PD deficiency contraindicates dapsone and primaquine (hemolysis) — screen before either; do not delay treatment waiting for the assay if alternatives exist (NIH/CDC OI 2025)
- pregnancyhistory • used at CONTEXTTMP-SMX still first-line in pregnancy (folate supplementation; neonatal kernicterus risk near term — coordinate timing); avoid primaquine; weigh dapsone (NIH/CDC OI 2025)
- on_PCP_prophylaxishistory • used at CONTEXTBreakthrough PJP on adherent TMP-SMX prophylaxis is rare and lowers the prior — re-examine adherence, dose, alternative pathogens, resistant organism (NIH/CDC OI 2025)
- ldhlab • used at INITIAL_WORKUPElevated LDH supports PJP (sensitive, non-specific); tracks treatment response and prognosis (NIH/CDC OI 2025)
- beta_d_glucanlab • used at INITIAL_WORKUPSerum (1→3)-β-D-glucan: pooled sens ~91% / spec ~79%; a NEGATIVE test rules out only at LOW-intermediate pretest (non-HIV ≤20%, HIV ≤50%) — post-test probability is CONDITIONAL on the host band, do not read in isolation (Del Corpo CMI 2020 PMID 32479781; Li 2015 PMID 26793343)
- creatininerequiredlab • used at CONTEXTRenal dose-adjust TMP-SMX (CrCl <30 → reduce/avoid), pentamidine nephrotoxicity, dapsone; baseline before nephrotoxic alternatives (NIH/CDC OI 2025)
- pao2lab • used at CONTEXTRoom-air PaO2 <70 mmHg OR A-a gradient >35 → adjunctive corticosteroids within 72 h of anti-PCP therapy (Bozzette NEJM 1990 PMID 2233917)
- cxrimaging • used at INITIAL_WORKUPMay be normal early; classically bilateral perihilar interstitial pattern — a normal CXR does NOT exclude PJP (HRCT more sensitive) (NIH/CDC OI 2025)
- hrct_chestimaging • used at INITIAL_WORKUPDiffuse/perihilar ground-glass opacities; a NORMAL HRCT has high negative predictive value and argues strongly against PJP (NIH/CDC OI 2025)
- pcp_PCR_or_silver_stainlab • used at INITIAL_WORKUPDefinitive: immunofluorescence/silver/Giemsa stain (specific, organism = disease) vs quantitative PCR (more sensitive but a positive low-burden PCR may reflect COLONIZATION not invasive disease — interpret conditional on host + clinical-radiologic gestalt) on induced sputum or BAL (NIH/CDC OI 2025)
- cmv_pcr_or_culturelab • used at BRANCHING_WORKUPCMV co-infection is a major non-HIV PJP mortality driver and a key differential — quantitative CMV PCR / BAL shell-vial (route → id.cmv-immunocompromised.core.v1) (Feng 2022 PMID 35313548)
12-phase flow (12)
- 1FRAMEEstablish the immunocompromised substrate and a PJP-compatible subacute illness pattern; assign the host CLASS (HIV CD4 band vs non-HIV iatrogenic) — this sets the Bayesian prior and selects the HIV-vs-non-HIV management branch (NIH/CDC OI 2025; Cilloniz 2019 PMID 31550942)inputs: hiv_or_immunosuppressionadvance: Immune substrate + host class (HIV vs non-HIV) confirmed
- 2ENTRYTriggered by subacute dyspnea + dry cough with exertional desaturation, diffuse ground-glass on HRCT, or LDH/β-D-glucan elevation in an immunocompromised host (NIH/CDC OI 2025)inputs: ageadvance: Entry trigger present
- 3CONTEXTQuantify the prior: HIV CD4 (<100 vs 100-200 vs >200), non-HIV regimen (steroid dose/duration, rituximab/anti-TNF/CNI/alkylator, transplant), prophylaxis status/adherence, sulfa allergy severity, G6PD, pregnancy, renal function, SpO2/PaO2/A-a (NIH/CDC OI 2025)inputs: spo2, rr, sbp, hiv_or_immunosuppression, cd4_count, immunosuppressant_regimen, sulfa_allergy, g6pd_status, pregnancy, on_PCP_prophylaxis, creatinine, pao2advance: Host pretest band + steroid-threshold inputs + allergy/G6PD captured
- 4RED_FLAGSSevere hypoxemic respiratory failure, ARDS physiology, spontaneous pneumothorax (PJP-classic), septic shock — escalate O2/ventilation and ICU; non-HIV PJP is more fulminant with higher mortality (NIH/CDC OI 2025; Cilloniz 2019 PMID 31550942)inputs: spo2, rr, sbpadvance: No emergent escalation needed OR ICU pathway activated
- 5INITIAL_WORKUPBayesian gate: HRCT (normal HRCT → PJP unlikely, pivot differential), ABG → PaO2/A-a, LDH, serum β-D-glucan (post-test CONDITIONAL on host band — negative rules out only at low-intermediate pretest), and the definitive specimen — induced sputum or BAL with immunofluorescence + quantitative PCR. Do NOT delay empiric TMP-SMX awaiting the specimen in moderate-severe disease (organisms persist days into therapy) (NIH/CDC OI 2025; Del Corpo CMI 2020 PMID 32479781)inputs: ldh, beta_d_glucan, cxr, hrct_chest, pao2, pcp_PCR_or_silver_stainactions: pcp_pneumoniaadvance: Definitive specimen sent AND empiric therapy started if moderate-severe
- 6BRANCHING_WORKUPBronchoscopy + BAL if induced sputum negative but pretest remains high; co-pathogen panel — CMV (PCR/shell-vial → id.cmv-immunocompromised.core.v1), TB (route → pulm.tuberculosis.v1), invasive fungal (galactomannan/culture), bacterial; reconcile a positive low-burden PCR against colonization (NIH/CDC OI 2025; Feng 2022 PMID 35313548)inputs: cmv_pcr_or_culture, hrct_chestactions: pcp_pneumoniaadvance: Definitive specimen obtained when needed AND co-pathogens addressed
- 7DIFFERENTIALPJP vs bacterial CAP vs viral pneumonia (CMV/influenza/COVID/RSV) vs TB vs invasive fungal vs lymphangitic carcinomatosis vs drug-induced pneumonitis vs IRIS — pivots on host band, β-D-glucan post-test, BAL IF-vs-PCR, LDH, HRCT pattern. HIV-vs-non-HIV is a key axis (tempo, burden, β-D-glucan NPV, mortality) (NIH/CDC OI 2025; Cilloniz 2019 PMID 31550942)advance: Working diagnosis + co-existence assessed
- 8RISK_STRATIFICATIONSeverity tier: mild (PaO2 ≥70, A-a <35, SpO2 ≥92% RA) vs moderate-severe (PaO2 <70 OR A-a >35 OR SpO2 <92% RA OR mechanical ventilation). HIV vs non-HIV stratifies steroid-evidence strength (strong RCT in HIV; weaker/observational in non-HIV) and mortality (HIV ~10-20% vs non-HIV up to ~30-50%); non-HIV adverse markers: pneumothorax, CD4 ≤100 surrogate, CMV co-infection (Bozzette NEJM 1990 PMID 2233917; Feng 2022 PMID 35313548)inputs: pao2, spo2advance: Severity tier + host class + steroid candidacy documented
- 9TREATMENTFirst-line TMP-SMX 15-20 mg/kg/day of TMP ÷ q6-8h IV (moderate-severe) or PO (mild); duration 21 d HIV, 14-21 d non-HIV. Adjunctive corticosteroids (prednisone 40 mg BID ×5 d → 40 mg daily ×5 d → 20 mg daily ×11 d, or IV methylprednisolone equivalent) if PaO2 <70 OR A-a >35 OR SpO2 <92% RA, started within 72 h — strong HIV evidence (Bozzette PMID 2233917), weaker in non-HIV. Sulfa allergy/G6PD/intolerance → primaquine+clindamycin, atovaquone (mild), IV pentamidine (severe), dapsone-TMP (mild-moderate, G6PD-permitting); consider sulfa desensitization if no severe reaction history. Renal/hepatic dose-adjust per drug (NIH/CDC OI 2025; Safrin ACTG 108 PMID 8610948)inputs: pao2, creatinine, weight, sulfa_allergy, g6pd_status, pregnancyadvance: Anti-PCP regimen + steroid decision + duration documented
- 10DISPOSITIONMost admit; ICU for respiratory failure / refractory hypoxia / pneumothorax / shock; outpatient oral therapy only for mild HIV-PCP with social support and reliable follow-up; non-HIV PJP has a low threshold for ICU given fulminant course (NIH/CDC OI 2025; Cilloniz 2019 PMID 31550942)advance: Disposition decided
- 11MONITORINGExpect paradoxical clinical worsening days 3-5 (inflammatory; do NOT switch antibiotic empirically); LDH/oxygenation trend; CBC/BMP q48h on TMP-SMX (cytopenias, hyperkalemia, AKI); methemoglobin if dapsone/primaquine; glucose if pentamidine/steroid; true treatment failure assessed at ~7-10 d → bronchoscopy + co-infection workup + agent switch (NIH/CDC OI 2025)advance: Response trend documented and true-failure logic applied
- 12FOLLOWUPSecondary prophylaxis (TMP-SMX SS daily) until immune reconstitution — HIV: CD4 >200 ×3 mo on ART (consider stop at CD4 100-200 if VL suppressed ≥3-6 mo); non-HIV: until immunosuppression resolved. Initiate/optimize ART within 2 weeks of PJP treatment in HIV (early ART reduces progression/death — Zolopa ACTG A5164 PMID 19440326); monitor IRIS; minimize/taper the iatrogenic immunosuppressant where feasible (NIH/CDC OI 2025)advance: Prophylaxis + immune-recovery + ART/immunosuppression plan in place