AI in health care

Searching the Web

AI in healthcare 2025 2026 latest developments clinical applications

Searching PubMed

"artificial intelligence"[MeSH Terms] AND "delivery of health care"[MeSH Terms]

Here is a structured overview of AI in healthcare as of mid-2026, drawing on recent peer-reviewed evidence and current developments:

AI in Healthcare: A Current Overview

1. Clinical Documentation - AI Scribes

One of the fastest-adopted applications is ambient AI scribing - AI listens to clinician-patient conversations and auto-generates clinical notes. A 2025 systematic review in Applied Clinical Informatics (PMID: 40306686) found that AI scribes reduce documentation burden and physician burnout, though integration challenges and accuracy concerns in complex cases remain. Major platforms include Nuance DAX, Suki, and Ambience Healthcare.

2. Large Language Models (LLMs) in Clinical Practice

A JAMA 2025 systematic review (PMID: 39405325) evaluated LLM applications across healthcare and found strong performance in clinical question-answering, medical education, and patient communication - but flagged inconsistent accuracy, hallucinations, and lack of real-world validation as key concerns. An umbrella review in Journal of Biomedical Science (PMID: 40335969) confirmed ChatGPT and similar models are being studied for diagnosis support, health education, mental health triaging, and coding/billing.

3. Medical Imaging & Diagnostics

AI in radiology, pathology, and ophthalmology is arguably the most mature area:
  • Radiology: AI tools detect lung nodules, fractures, intracranial hemorrhage, and breast cancer on mammography with performance rivaling radiologists in controlled studies.
  • Pathology: Digital pathology AI can classify tumors and predict molecular subtypes from histology slides.
  • Ophthalmology: FDA-cleared AI (e.g., IDx-DR) autonomously screens for diabetic retinopathy without a specialist.
  • GE HealthCare (June 2026) is actively expanding AI-enabled nuclear medicine workflows at the SNMMI Annual Meeting, integrating AI with PET imaging and theranostics.

4. Chronic Disease Management & Chatbots

A 2024 systematic review (PMID: 38466897) found AI-powered chatbots improve self-management behaviors in chronic diseases (diabetes, hypertension, COPD) by delivering personalized coaching, medication reminders, and symptom monitoring. Limitations include engagement drop-off and lack of long-term outcome data.

5. Nursing & Patient Outcomes

A 2025 systematic review in Journal of Nursing Scholarship (PMID: 40836587) found AI applications in nursing - predictive sepsis alerts, fall risk scoring, pressure injury detection - are associated with improved patient safety outcomes, though nurse training and workflow integration remain barriers.

6. Drug Discovery & Development

AI is dramatically shortening the drug discovery pipeline:
  • AlphaFold (DeepMind) has predicted structures for virtually every known protein, transforming target identification.
  • AI-designed molecules have entered clinical trials (e.g., Insilico Medicine's INS018_055 for IPF is in Phase II).
  • IQVIA and other CROs are embedding "Healthcare-grade AI" into clinical trial design, patient recruitment, and pharmacovigilance.

7. Administrative AI

  • Revenue cycle management: AI automates prior authorizations, coding, and claim denials. A KLAS 2026 report notes that while AI-driven clinical decision support is increasingly discussed, only ~40% of deep adopters are actively using archived data for AI-driven analytics in real production workflows.
  • Scheduling & triage: NLP tools route patient messages and prioritize callbacks.

Key Challenges

ChallengeDetail
Bias & equityModels trained on non-representative data can perform worse for minority populations
HallucinationsLLMs generate plausible but incorrect clinical information
RegulatoryFDA 510(k)/De Novo pathways for AI/ML-based SaMD (Software as Medical Device) are evolving
PrivacyHIPAA compliance, data governance, and de-identification requirements
Workflow integrationEHR interoperability and clinician adoption remain practical barriers
AccountabilityLiability when AI contributes to a diagnostic or treatment error

Bottom Line

AI in healthcare is no longer experimental in many domains - it is actively deployed in documentation, imaging, risk scoring, and patient engagement. The highest-quality recent evidence (JAMA 2025, JNSP 2025) supports real benefit but emphasizes the need for rigorous real-world validation, equity audits, and transparent regulatory frameworks before broader clinical reliance. The next 2-3 years will likely see AI move from assistive to more autonomous roles in narrow, well-defined tasks.

Make a presentation on “hypersensitivity pneumonitis” for young budding pulmologists

Reading File
Reading File
Reading File
Finding Sources
Searching PubMed

"hypersensitivity pneumonitis"[MeSH Terms] AND diagnosis

Reading File
Reading File
Reading File
Searching PubMed

"hypersensitivity pneumonitis" AND "guidelines"

Reading File
Reading File
Reading File
Finding Sources
Running Command

ls /home/daytona/workspace/ 2>/dev/null && echo "---" && node -e "require('pptxgenjs'); console.log('pptxgenjs ok')"

Running Command

mkdir -p /home/daytona/workspace/hp-presentation

Writing File

~/hp-presentation/build.js

const pptxgen = require("pptxgenjs");
const { execSync } = require("child_process");

// ── Fetch images ──────────────────────────────────────────────────────────────
const imageUrls = [
  "https://cdn.orris.care/cdss_images/4cbf3e40cfeca1d676b99941ed523c302ddaa0049dbd1ed7f4f9efaae5e4e567.png", // Diagnostic flowchart
  "https://cdn.orris.care/cdss_images/3d8594fc54984e5ddfa52b10416171ab5e1f193f1af29fcf8d096368096b40d2.png", // Management flowchart
];

let imgDiag = null, imgMgmt = null;
try {
  const result = JSON.parse(
    execSync(
      `node /home/daytona/skills/shared/scripts/fetch_images.js "${imageUrls[0]}" "${imageUrls[1]}"`,
      { timeout: 30000 }
    ).toString()
  );
  if (result[0] && !result[0].error) imgDiag = result[0].base64;
  if (result[1] && !result[1].error) imgMgmt = result[1].base64;
} catch (e) {
  console.warn("Image fetch failed:", e.message);
}

// ── Color palette ─────────────────────────────────────────────────────────────
const C = {
  navy:    "0A1628",  // dominant dark
  teal:    "0D7377",  // accent / section bar
  sky:     "14BDCC",  // light accent
  white:   "FFFFFF",
  offwhite:"F0F4F8",
  slate:   "2D4059",
  amber:   "F5A623",  // warning / highlight
  red:     "C0392B",
  green:   "1E8449",
  gray:    "6B7C93",
  lightgray:"D6DCE5",
};

// ── Helpers ───────────────────────────────────────────────────────────────────
function titleSlide(pres, title, subtitle) {
  const s = pres.addSlide();
  // full dark background
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: C.navy } });
  // teal accent bar
  s.addShape(pres.ShapeType.rect, { x: 0, y: 3.6, w: 10, h: 0.18, fill: { color: C.teal } });
  // glow circle
  s.addShape(pres.ShapeType.ellipse, { x: 7.2, y: -1.0, w: 4.5, h: 4.5,
    fill: { color: C.teal, transparency: 80 }, line: { color: C.teal, transparency: 80 } });
  s.addText(title, {
    x: 0.6, y: 1.1, w: 8.8, h: 1.8,
    fontSize: 38, bold: true, color: C.white, fontFace: "Calibri",
    align: "left", valign: "middle", margin: 0,
  });
  s.addText(subtitle, {
    x: 0.6, y: 3.0, w: 7.5, h: 0.5,
    fontSize: 16, color: C.sky, fontFace: "Calibri", align: "left", margin: 0,
  });
  s.addText("Murray & Nadel's Respiratory Medicine | Robbins Pathology | Grainger & Allison's Radiology", {
    x: 0.6, y: 5.1, w: 8.8, h: 0.35,
    fontSize: 9, color: C.gray, fontFace: "Calibri", align: "left", margin: 0,
  });
  return s;
}

function sectionDivider(pres, title, subtitle) {
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: C.slate } });
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.18, h: 5.625, fill: { color: C.teal } });
  s.addShape(pres.ShapeType.ellipse, { x: 6.5, y: 2.5, w: 5, h: 5,
    fill: { color: C.teal, transparency: 88 }, line: { color: C.teal, transparency: 88 } });
  s.addText(title, {
    x: 0.55, y: 1.6, w: 8.5, h: 1.5,
    fontSize: 34, bold: true, color: C.white, fontFace: "Calibri", align: "left", margin: 0,
  });
  if (subtitle) {
    s.addText(subtitle, {
      x: 0.55, y: 3.1, w: 7.5, h: 0.55,
      fontSize: 15, color: C.sky, fontFace: "Calibri", align: "left", margin: 0,
    });
  }
  return s;
}

function contentSlide(pres, heading, bullets, opts = {}) {
  const s = pres.addSlide();
  // off-white bg
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: C.offwhite } });
  // heading bar
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 1.05, fill: { color: C.navy } });
  s.addShape(pres.ShapeType.rect, { x: 0, y: 1.05, w: 10, h: 0.07, fill: { color: C.teal } });
  s.addText(heading, {
    x: 0.35, y: 0.05, w: 9.4, h: 0.95,
    fontSize: 22, bold: true, color: C.white, fontFace: "Calibri",
    align: "left", valign: "middle", margin: 0,
  });
  // bullet content
  const items = bullets.map((b, i) => {
    if (b.type === "header") {
      return [
        { text: b.text, options: { bold: true, color: C.teal, fontSize: b.fontSize || 14, breakLine: true } }
      ];
    }
    if (b.type === "bullet2") {
      return [
        { text: "    \u2013 " + b.text, options: { color: C.slate, fontSize: 11.5, breakLine: true } }
      ];
    }
    // default bullet
    return [
      { text: "\u25CF  " + b.text, options: { color: C.navy, fontSize: b.fontSize || 13, bold: b.bold || false, breakLine: true } }
    ];
  });
  const flat = items.flat();
  // remove last breakLine
  if (flat.length > 0) flat[flat.length - 1].options.breakLine = false;
  s.addText(flat, {
    x: opts.x || 0.35, y: opts.y || 1.25,
    w: opts.w || 9.3, h: opts.h || 4.1,
    fontFace: "Calibri", valign: "top", margin: 6,
  });
  // optional footnote
  if (opts.footnote) {
    s.addText(opts.footnote, {
      x: 0.35, y: 5.3, w: 9.3, h: 0.28,
      fontSize: 8, color: C.gray, fontFace: "Calibri", align: "left", margin: 0,
    });
  }
  return s;
}

function twoColSlide(pres, heading, leftBullets, rightBullets, opts = {}) {
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: C.offwhite } });
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 1.05, fill: { color: C.navy } });
  s.addShape(pres.ShapeType.rect, { x: 0, y: 1.05, w: 10, h: 0.07, fill: { color: C.teal } });
  // divider
  s.addShape(pres.ShapeType.line, { x: 5.1, y: 1.2, w: 0, h: 4.2, line: { color: C.lightgray, width: 1.5 } });
  s.addText(heading, {
    x: 0.35, y: 0.05, w: 9.4, h: 0.95,
    fontSize: 22, bold: true, color: C.white, fontFace: "Calibri", align: "left", valign: "middle", margin: 0,
  });
  // left
  if (opts.leftTitle) {
    s.addText(opts.leftTitle, { x: 0.35, y: 1.18, w: 4.5, h: 0.35, fontSize: 13, bold: true, color: C.teal, fontFace: "Calibri", margin: 0 });
  }
  const leftItems = leftBullets.map(b => ({
    text: "\u25CF  " + b, options: { color: C.navy, fontSize: 12.5, breakLine: true }
  }));
  if (leftItems.length) leftItems[leftItems.length - 1].options.breakLine = false;
  s.addText(leftItems, { x: 0.35, y: opts.leftTitle ? 1.58 : 1.25, w: 4.6, h: 3.8, fontFace: "Calibri", valign: "top", margin: 4 });
  // right
  if (opts.rightTitle) {
    s.addText(opts.rightTitle, { x: 5.25, y: 1.18, w: 4.5, h: 0.35, fontSize: 13, bold: true, color: C.teal, fontFace: "Calibri", margin: 0 });
  }
  const rightItems = rightBullets.map(b => ({
    text: "\u25CF  " + b, options: { color: C.navy, fontSize: 12.5, breakLine: true }
  }));
  if (rightItems.length) rightItems[rightItems.length - 1].options.breakLine = false;
  s.addText(rightItems, { x: 5.25, y: opts.rightTitle ? 1.58 : 1.25, w: 4.45, h: 3.8, fontFace: "Calibri", valign: "top", margin: 4 });
  return s;
}

function imageSlide(pres, heading, imageData, caption, opts = {}) {
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: C.offwhite } });
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 1.05, fill: { color: C.navy } });
  s.addShape(pres.ShapeType.rect, { x: 0, y: 1.05, w: 10, h: 0.07, fill: { color: C.teal } });
  s.addText(heading, {
    x: 0.35, y: 0.05, w: 9.4, h: 0.95,
    fontSize: 22, bold: true, color: C.white, fontFace: "Calibri", align: "left", valign: "middle", margin: 0,
  });
  if (imageData) {
    s.addImage({ data: imageData, x: opts.ix || 0.4, y: opts.iy || 1.18, w: opts.iw || 9.2, h: opts.ih || 3.9 });
  }
  if (caption) {
    s.addText(caption, {
      x: 0.35, y: opts.cy || 5.2, w: 9.3, h: 0.38,
      fontSize: 8.5, color: C.gray, fontFace: "Calibri", italic: true, align: "center", margin: 0,
    });
  }
  return s;
}

function tableSlide(pres, heading, rows, colWidths, headerColor) {
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: C.offwhite } });
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 1.05, fill: { color: C.navy } });
  s.addShape(pres.ShapeType.rect, { x: 0, y: 1.05, w: 10, h: 0.07, fill: { color: C.teal } });
  s.addText(heading, {
    x: 0.35, y: 0.05, w: 9.4, h: 0.95,
    fontSize: 22, bold: true, color: C.white, fontFace: "Calibri", align: "left", valign: "middle", margin: 0,
  });
  s.addTable(rows, {
    x: 0.3, y: 1.22, w: 9.4, h: 4.15,
    colW: colWidths,
    fontFace: "Calibri", fontSize: 11.5,
    border: { pt: 0.5, color: C.lightgray },
    fill: { color: C.white },
  });
  return s;
}

// ═══════════════════════════════════════════════════════════════
// BUILD PRESENTATION
// ═══════════════════════════════════════════════════════════════
const pres = new pptxgen();
pres.layout = "LAYOUT_16x9";
pres.title = "Hypersensitivity Pneumonitis";
pres.author = "Pulmonology Education";

// ── SLIDE 1: Title ────────────────────────────────────────────
titleSlide(pres,
  "Hypersensitivity\nPneumonitis",
  "A Comprehensive Guide for Budding Pulmonologists  |  2026"
);

// ── SLIDE 2: Section – Overview ───────────────────────────────
sectionDivider(pres, "01  Overview & Classification", "What is HP and how do we classify it?");

// ── SLIDE 3: Definition ───────────────────────────────────────
contentSlide(pres, "What is Hypersensitivity Pneumonitis?", [
  { type: "bullet", text: "Complex inflammatory and/or fibrotic interstitial lung disease (ILD) in susceptible individuals" },
  { type: "bullet", text: "Caused by immunologically mediated reaction to inhaled organic or low-molecular-weight antigens" },
  { type: "bullet", text: "Also called Extrinsic Allergic Alveolitis (EAA)" },
  { type: "bullet", text: "Exposures: occupational, avocational, residential, or environmental settings" },
  { type: "bullet", text: "Overlap with other ILDs makes diagnosis and management challenging" },
  { type: "bullet", text: "High index of suspicion required — always consider HP in any ILD workup" },
  { type: "header", text: "KEY CONCEPT" },
  { type: "bullet", text: "HP is diagnosed by integration of clinical + radiologic + histopathologic findings in Multidisciplinary Discussion (MDD)" },
], { footnote: "Murray & Nadel's Textbook of Respiratory Medicine, Chapter 91" });

// ── SLIDE 4: Classification ───────────────────────────────────
twoColSlide(pres,
  "Current Classification: Nonfibrotic vs Fibrotic HP",
  [
    "Nonfibrotic HP (= Acute/Subacute HP)",
    "Predominantly inflammatory pattern",
    "Reversible with antigen avoidance",
    "Ground-glass opacity, centrilobular nodules on HRCT",
    "Better prognosis",
    "Responds to corticosteroids",
    "Cluster analysis shows majority of HP fits this two-cluster model",
  ],
  [
    "Fibrotic HP (= Chronic HP)",
    "Irreversible fibrosis present",
    "May mimic UIP or NSIP pattern on HRCT",
    "Higher mortality rate",
    "Antigen identification may be impossible in up to 50% of cases",
    "Can progress even after antigen removal",
    "May require antifibrotics or transplant evaluation",
  ],
  { leftTitle: "NONFIBROTIC (Inflammatory)", rightTitle: "FIBROTIC (Chronic)" }
);

// ── SLIDE 5: Section – Etiology ───────────────────────────────
sectionDivider(pres, "02  Etiology & Antigens", "Know your triggers — >200 sources implicated");

// ── SLIDE 6: Antigen Table ────────────────────────────────────
const hdrStyle = { bold: true, color: C.white, fill: { color: C.slate }, align: "center" };
tableSlide(pres,
  "Common Causes of Hypersensitivity Pneumonitis",
  [
    [
      { text: "Disease Name", options: hdrStyle },
      { text: "Source of Antigen", options: hdrStyle },
      { text: "Antigen", options: hdrStyle },
    ],
    [{ text: "Farmer's Lung" }, { text: "Moldy hay / grain (thermophilic actinomycetes)" }, { text: "Saccharopolyspora rectivirgula" }],
    [{ text: "Bird Breeder's Lung" }, { text: "Pigeons, doves, parakeets (feathers, droppings)" }, { text: "Avian proteins, IgA" }],
    [{ text: "Hot Tub Lung" }, { text: "Contaminated hot tubs / saunas" }, { text: "Mycobacterium avium complex (MAC)" }],
    [{ text: "Humidifier Lung" }, { text: "Contaminated water in humidifiers, HVAC" }, { text: "Fungi, bacteria, protozoa" }],
    [{ text: "Cheese Washer's Lung" }, { text: "Moldy cheese rinds" }, { text: "Penicillium casei" }],
    [{ text: "Metalworking Fluid HP" }, { text: "Contaminated metalworking fluids" }, { text: "MAC, fungi" }],
    [{ text: "Chemical HP" }, { text: "Auto-painting, spray foam insulation" }, { text: "Isocyanates (TDI, MDI)" }],
    [{ text: "Summer-type HP (Japan)" }, { text: "Seasonal, humid environments" }, { text: "Trichosporon species" }],
  ],
  [2.5, 4.0, 2.9],
  C.slate
);

// ── SLIDE 7: Section – Immunopathogenesis ─────────────────────
sectionDivider(pres, "03  Immunopathogenesis", "Type III and IV hypersensitivity — a dual mechanism");

// ── SLIDE 8: Pathogenesis ─────────────────────────────────────
twoColSlide(pres,
  "Immunopathogenesis: Dual Mechanism",
  [
    "Type III (Immune Complex-mediated)",
    "Inhaled antigens → serum IgG precipitins formed",
    "Antigen-antibody immune complexes deposit in alveolar walls",
    "Complement activation → acute inflammation",
    "Occurs within hours of exposure",
    "Explains acute febrile illness pattern",
  ],
  [
    "Type IV (Cell-mediated / Delayed)",
    "T-lymphocyte sensitization to inhaled antigens",
    "CD4+ and CD8+ T cells infiltrate lung",
    "BAL shows markedly elevated CD8+ (low CD4:CD8 ratio)",
    "Granuloma formation — epithelioid macrophages + giant cells",
    "Explains chronic progressive fibrotic disease",
  ],
  { leftTitle: "TYPE III — Immune Complex", rightTitle: "TYPE IV — Cell-Mediated" }
);

// ── SLIDE 9: Histopathology ───────────────────────────────────
contentSlide(pres, "Histopathology", [
  { type: "header", text: "CLASSIC TRIAD (nonfibrotic HP)" },
  { type: "bullet", text: "1.  Peribronchiolar mononuclear cell infiltrate (lymphocytes predominate)" },
  { type: "bullet", text: "2.  Poorly formed (noncohesive) noncaseating granulomas — 2/3 of cases, peribronchiolar" },
  { type: "bullet", text: "3.  Cellular bronchiolitis" },
  { type: "header", text: "GRANULOMA FEATURES" },
  { type: "bullet", text: "Epithelioid macrophages + multinucleated giant cells" },
  { type: "bullet", text: "Giant cells may contain cholesterol clefts (Schaumann bodies)" },
  { type: "bullet", text: "Bronchiolocentric distribution — key to distinguishing from sarcoid" },
  { type: "header", text: "FIBROTIC HP" },
  { type: "bullet", text: "Bilateral upper-lobe-dominant interstitial fibrosis (UIP pattern in advanced cases)" },
  { type: "bullet", text: "May overlap with NSIP or UIP — bronchiolocentric accentuation helpful clue" },
], { footnote: "Murray & Nadel's Respiratory Medicine; Robbins & Kumar Basic Pathology" });

// ── SLIDE 10: Section – Diagnosis ────────────────────────────
sectionDivider(pres, "04  Clinical Features & Diagnosis", "Recognize the syndrome, find the antigen");

// ── SLIDE 11: Clinical Features ───────────────────────────────
twoColSlide(pres,
  "Clinical Presentations",
  [
    "Nonfibrotic / Acute HP",
    "Onset 4–8 hours after antigen exposure",
    "Fever, chills, myalgia",
    "Cough and dyspnea",
    "No eosinophilia; wheeze uncommon",
    "Resolves days after antigen removal",
    "Temporal relationship to exposure is diagnostic clue",
  ],
  [
    "Fibrotic / Chronic HP",
    "Insidious onset — weeks to months",
    "Progressive dyspnea, dry cough",
    "Malaise, weight loss",
    "Bibasilar crackles on auscultation",
    "Clubbing (in ~50% of fibrotic cases)",
    "Irreversible if antigen not removed early",
    "May progress even with antigen avoidance",
  ],
  { leftTitle: "NONFIBROTIC (Acute/Subacute)", rightTitle: "FIBROTIC (Chronic)" }
);

// ── SLIDE 12: HRCT Findings ───────────────────────────────────
contentSlide(pres, "HRCT Findings", [
  { type: "header", text: "NONFIBROTIC / SUBACUTE HP" },
  { type: "bullet", text: "Centrilobular poorly-defined nodules (~5 mm) — mid/lower zones" },
  { type: "bullet", text: "Ground-glass opacity (GGO) — especially with ongoing exposure" },
  { type: "bullet", text: "Mosaic attenuation + air trapping on expiratory CT (lobular air trapping = coexisting bronchiolitis)" },
  { type: "bullet", text: "Thin-walled cysts (3–25 mm) in subacute phase" },
  { type: "header", text: "FIBROTIC / CHRONIC HP" },
  { type: "bullet", text: "Intralobular and interlobular septal thickening" },
  { type: "bullet", text: "Traction bronchiectasis, honeycombing" },
  { type: "bullet", text: "Mid-zone or upper-lobe predominance (vs lower-zone in IPF)" },
  { type: "header", text: "HP vs IPF on HRCT — Features Favoring HP" },
  { type: "bullet", text: "Upper/mid-zone predominance, GGO, centrilobular nodules, bronchocentric distribution, air trapping" },
], { footnote: "Grainger & Allison's Diagnostic Radiology; Semin Roentgenol 2026 PMID:41513513" });

// ── SLIDE 13: Diagnostic Flowchart ───────────────────────────
if (imgDiag) {
  imageSlide(pres,
    "Diagnostic Approach to HP",
    imgDiag,
    "Fig 91.2 — Approach to HP diagnosis: exposure assessment → HRCT pattern → diagnostic certainty → MDD. (Murray & Nadel's Respiratory Medicine)",
    { iy: 1.18, ih: 3.9, cy: 5.18 }
  );
} else {
  contentSlide(pres, "Diagnostic Approach to HP", [
    { type: "header", text: "STEP 1 — Exposure Assessment" },
    { type: "bullet", text: "Comprehensive occupational, residential & avocational history" },
    { type: "bullet", text: "Consider referral to occupational medicine / industrial hygienist" },
    { type: "header", text: "STEP 2 — HRCT Pattern" },
    { type: "bullet", text: "Nonfibrotic (typical HP pattern) vs fibrotic (UIP-like/NSIP-like)" },
    { type: "bullet", text: "Air trapping on expiratory HRCT is a key clue" },
    { type: "header", text: "STEP 3 — Diagnostic Certainty" },
    { type: "bullet", text: "Confident diagnosis → exposure + typical HRCT + known antigen" },
    { type: "bullet", text: "Working diagnosis → BAL ± transbronchial biopsy considered" },
    { type: "bullet", text: "Surgical lung biopsy when diagnosis remains uncertain after MDD" },
  ]);
}

// ── SLIDE 14: Diagnostic Tests ────────────────────────────────
contentSlide(pres, "Investigations in HP", [
  { type: "header", text: "PULMONARY FUNCTION TESTS" },
  { type: "bullet", text: "Predominantly restrictive pattern (reduced TLC, FVC, compliance)" },
  { type: "bullet", text: "Reduced DLCO — important marker of severity and prognosis" },
  { type: "bullet", text: "Airflow obstruction may be present in smokers / chronic forms" },
  { type: "header", text: "SEROLOGY — Serum Precipitins / Specific IgG" },
  { type: "bullet", text: "Neither sensitive nor specific — high false-positive rate in exposed, asymptomatic individuals" },
  { type: "bullet", text: "92% of bird breeder HP had positive antibodies BUT so did 87% of asymptomatic controls" },
  { type: "bullet", text: "Can wane over time with reduced exposure" },
  { type: "header", text: "BAL" },
  { type: "bullet", text: "Lymphocytosis (>30%) with low CD4:CD8 ratio (<1) — classic finding" },
  { type: "bullet", text: "Most sensitive test but not diagnostic alone" },
  { type: "header", text: "BIOPSY" },
  { type: "bullet", text: "Transbronchial biopsy may suffice for nonfibrotic HP" },
  { type: "bullet", text: "Surgical lung biopsy (VATS) for indeterminate cases" },
], { footnote: "Murray & Nadel's Respiratory Medicine, Chapter 91" });

// ── SLIDE 15: Prognostic Factors ──────────────────────────────
tableSlide(pres,
  "Prognostic Indicators of Mortality in HP",
  [
    [
      { text: "Domain", options: { bold: true, color: C.white, fill: { color: C.slate }, align: "center" } },
      { text: "Adverse Prognostic Factors", options: { bold: true, color: C.white, fill: { color: C.slate }, align: "center" } },
    ],
    [{ text: "Demographics" }, { text: "Male sex, older age" }],
    [{ text: "Physical Exam" }, { text: "Auscultatory crackles" }],
    [{ text: "Lung Function" }, { text: "Low FVC%, low DLCO%" }],
    [{ text: "HRCT" }, { text: "Increased fibrosis, honeycombing, traction bronchiectasis, mosaic attenuation, increased PA:Ao ratio" }],
    [{ text: "Histology" }, { text: "Increased fibrosis, fibroblast foci" }],
    [{ text: "Genetics" }, { text: "MUC5B rs35705950 SNP, shorter telomere length (<10th percentile)" }],
    [{ text: "Composite" }, { text: "Abnormal ILD-GAP index" }],
    [{ text: "Other" }, { text: "No identified antigen, smoking, acute exacerbation, pulmonary hypertension" }],
  ],
  [2.8, 6.6],
  C.slate
);

// ── SLIDE 16: Section – Management ───────────────────────────
sectionDivider(pres, "05  Management", "Antigen avoidance is the cornerstone of treatment");

// ── SLIDE 17: Management Overview ────────────────────────────
contentSlide(pres, "Management: Key Pillars", [
  { type: "header", text: "1.  ANTIGEN AVOIDANCE (Most Important)" },
  { type: "bullet", text: "Complete removal from exposure environment is first-line treatment" },
  { type: "bullet", text: "Even partial reduction of exposure may slow progression" },
  { type: "bullet", text: "Environmental remediation (HEPA filtration, dehumidification) where relocation is not possible" },
  { type: "bullet", text: "Occupational counselling — may require change of occupation" },
  { type: "header", text: "2.  PHARMACOLOGIC THERAPY" },
  { type: "bullet", text: "Initiated when clinically significant disease progression despite antigen avoidance" },
  { type: "bullet", text: "Systemic corticosteroids (Prednisone) — initial treatment, tapering schedule" },
  { type: "bullet", text: "Corticosteroid-sparing agents: Azathioprine (AZA), Mycophenolate mofetil (MMF)" },
  { type: "bullet", text: "Antifibrotic therapy (Nintedanib) — emerging role in fibrotic HP progression" },
  { type: "header", text: "3.  SUPPORTIVE CARE" },
  { type: "bullet", text: "Supplemental O2, pulmonary rehabilitation, smoking cessation, vaccinations" },
], { footnote: "Murray & Nadel's Respiratory Medicine, Chapter 91 | German S2k Guideline 2025 (PMID:39870058)" });

// ── SLIDE 18: Management Flowchart ───────────────────────────
if (imgMgmt) {
  imageSlide(pres,
    "Management Algorithm for HP",
    imgMgmt,
    "Fig 91.6 — HP management approach: antigen avoidance → steroid response assessment → corticosteroid-sparing / antifibrotic agents → lung transplant evaluation. (Murray & Nadel's Respiratory Medicine)",
    { iy: 1.18, ih: 3.9, cy: 5.18 }
  );
} else {
  contentSlide(pres, "Management Algorithm", [
    { type: "bullet", text: "Antigen avoidance → monitor for response at 6–12 weeks" },
    { type: "bullet", text: "Ongoing symptoms/progression → add systemic steroids" },
    { type: "bullet", text: "Steroid response? → Taper and monitor" },
    { type: "bullet", text: "No response / steroid-dependent → AZA or MMF" },
    { type: "bullet", text: "Fibrotic HP progression → consider nintedanib" },
    { type: "bullet", text: "End-stage disease → lung transplant evaluation" },
  ]);
}

// ── SLIDE 19: Lung Transplant ─────────────────────────────────
contentSlide(pres, "Advanced Disease & Lung Transplantation", [
  { type: "header", text: "WHEN TO CONSIDER TRANSPLANT EVALUATION" },
  { type: "bullet", text: "Continued disease progression despite antigen avoidance + pharmacotherapy" },
  { type: "bullet", text: "FVC <50% predicted or DLCO <40% predicted" },
  { type: "bullet", text: "Resting or exertional hypoxemia" },
  { type: "bullet", text: "6MWT distance <250 m or >50 m decline in 12 months" },
  { type: "header", text: "OUTCOMES" },
  { type: "bullet", text: "HP mortality increases with age — age-adjusted mortality rose from 0.1 → 0.7 per million (1988–2016)" },
  { type: "bullet", text: "Average annual percentage increase in mortality: 5.6%" },
  { type: "bullet", text: "Fibrotic HP: 56–68% of HP cases; prevalence 0.9–1.7 per 100,000" },
  { type: "bullet", text: "Acute exacerbations of fibrotic HP carry high mortality — early recognition essential" },
  { type: "header", text: "PREVENTION" },
  { type: "bullet", text: "Occupational health monitoring, protective equipment, engineering controls" },
  { type: "bullet", text: "Outbreak investigation when occupational cluster is identified" },
], { footnote: "Murray & Nadel's Respiratory Medicine, Chapter 91" });

// ── SLIDE 20: Section – Differentials ────────────────────────
sectionDivider(pres, "06  Differential Diagnosis", "HP mimics — don't be fooled");

// ── SLIDE 21: Differentials ───────────────────────────────────
twoColSlide(pres,
  "Differential Diagnosis",
  [
    "Idiopathic Pulmonary Fibrosis (IPF)",
    "Lower-lobe honeycomb dominant UIP",
    "No causative antigen",
    "No GGO, no air trapping",
    "MUC5B SNP association similar",
    "Sarcoidosis",
    "Well-formed granulomas (vs HP: poorly-formed)",
    "Lymphangitic distribution on HRCT",
    "Bilateral hilar adenopathy",
  ],
  [
    "NSIP (Nonspecific Interstitial Pneumonia)",
    "Bilateral symmetric GGO with basal predominance",
    "May occur in CTD — check ANA, anti-Scl70",
    "RB-ILD / DIP",
    "Smoking history key differentiator",
    "Centrilobular GGO similar to HP",
    "Acute Eosinophilic Pneumonia",
    "Peripheral eosinophilia present (unlike HP)",
    "Responds rapidly to steroids",
  ],
  { leftTitle: "KEY DIFFERENTIALS — LEFT", rightTitle: "KEY DIFFERENTIALS — RIGHT" }
);

// ── SLIDE 22: Mnemonics / Pearls ──────────────────────────────
contentSlide(pres, "Clinical Pearls for the Pulmonologist", [
  { type: "header", text: "DIAGNOSIS PEARLS" },
  { type: "bullet", text: "Always take a detailed exposure history — occupational, home, hobbies (birds, hot tubs, farming)" },
  { type: "bullet", text: "Air trapping on expiratory HRCT + GGO = HP until proven otherwise" },
  { type: "bullet", text: "BAL lymphocytosis with CD4:CD8 < 1 strongly suggests HP" },
  { type: "bullet", text: "Positive serum precipitins = exposure, NOT disease — must correlate clinically" },
  { type: "bullet", text: "In 50% of chronic HP — no antigen ever found" },
  { type: "header", text: "MANAGEMENT PEARLS" },
  { type: "bullet", text: "Antigen removal FIRST — steroids are adjunctive, not primary" },
  { type: "bullet", text: "Fibrotic HP progresses like IPF — consider antifibrotics if rapid decline" },
  { type: "bullet", text: "Refer early for lung transplant in deteriorating fibrotic HP" },
  { type: "bullet", text: "MUC5B SNP and telomere shortening = poor prognosis markers" },
  { type: "header", text: "DO NOT MISS" },
  { type: "bullet", text: "Acute exacerbation of fibrotic HP = medical emergency — high mortality" },
], { footnote: "Murray & Nadel's Respiratory Medicine; German S2k Guideline 2025; Am J Respir Crit Care Med 2025" });

// ── SLIDE 23: Key References ──────────────────────────────────
contentSlide(pres, "Key References", [
  { type: "bullet", text: "Murray & Nadel's Textbook of Respiratory Medicine, 7th Ed. — Chapter 91 (Johannson & Fernandez Perez)" },
  { type: "bullet", text: "Robbins & Kumar Basic Pathology, 11th Ed. — Chapter 11" },
  { type: "bullet", text: "Grainger & Allison's Diagnostic Radiology — Chapter 9" },
  { type: "bullet", text: "Koschel D et al. Diagnosis and Treatment of HP: S2k Guideline (German Respiratory Society). Respiration 2025. PMID: 39870058" },
  { type: "bullet", text: "Ryerson CJ et al. Outcomes of Atypical Fibrotic HP Pattern on CT. Am J Respir Crit Care Med 2025. PMID: 40505139" },
  { type: "bullet", text: "Sellers T et al. HP: Imaging Findings and Patterns. Semin Roentgenol 2026. PMID: 41513513" },
  { type: "bullet", text: "Carroll MB et al. Update on Interstitial Pneumonias. Clin Chest Med 2024. PMID: 38816097" },
  { type: "header", text: "INTERNATIONAL GUIDELINES" },
  { type: "bullet", text: "ATS/JRS/ALAT Clinical Practice Guidelines for HP Diagnosis (2020) — Raghu G et al. Am J Respir Crit Care Med" },
  { type: "bullet", text: "Fernandez Perez ER et al. Diagnosis and Evaluation of HP. CHEST Guideline 2021" },
], { footnote: "Prepared for: Pulmonology Residency Education | July 2026" });

// ── SLIDE 24: Closing ─────────────────────────────────────────
const closing = pres.addSlide();
closing.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: C.navy } });
closing.addShape(pres.ShapeType.rect, { x: 0, y: 2.5, w: 10, h: 0.12, fill: { color: C.teal } });
closing.addShape(pres.ShapeType.ellipse, { x: -1, y: 3.5, w: 5, h: 5,
  fill: { color: C.teal, transparency: 88 }, line: { color: C.teal, transparency: 88 } });
closing.addText("Key Take-Home Message", {
  x: 1.0, y: 0.7, w: 8, h: 0.6,
  fontSize: 18, color: C.sky, fontFace: "Calibri", align: "center", bold: true, margin: 0,
});
closing.addText([
  { text: "Hypersensitivity Pneumonitis is a clinician's diagnosis.\n", options: { bold: true, color: C.white, fontSize: 22, breakLine: true } },
  { text: "Ask about the environment. Find the antigen. Remove it early.\n", options: { color: C.sky, fontSize: 17, breakLine: true } },
  { text: "When fibrosis sets in, act fast — the window is narrow.", options: { color: C.lightgray, fontSize: 15 } },
], {
  x: 0.8, y: 2.8, w: 8.4, h: 2.3,
  fontFace: "Calibri", align: "center", valign: "middle", margin: 0,
});
closing.addText("Based on Murray & Nadel's Respiratory Medicine | Robbins Pathology | Current Guidelines 2025–2026", {
  x: 0.5, y: 5.28, w: 9, h: 0.28,
  fontSize: 8, color: C.gray, fontFace: "Calibri", align: "center", margin: 0,
});

// ── WRITE FILE ────────────────────────────────────────────────
const outPath = "/home/daytona/workspace/hp-presentation/Hypersensitivity_Pneumonitis.pptx";
pres.writeFile({ fileName: outPath }).then(() => {
  console.log("SUCCESS:", outPath);
}).catch(e => {
  console.error("ERROR:", e.message);
  process.exit(1);
});
Running Command

cd /home/daytona/workspace/hp-presentation && node build.js 2>&1

Running Command

ls -lh /home/daytona/workspace/hp-presentation/Hypersensitivity_Pneumonitis.pptx

Your presentation is ready (933 KB, 24 slides):

Hypersensitivity Pneumonitis

Presentation · PPTX


What's Inside (24 Slides)

The deck is built with a navy/teal/sky-blue palette on a dark-background design, targeted squarely at residents and fellows. Here's the structure:
#SlideContent
1TitleBold opening slide with accent design
2Section dividerOverview & Classification
3DefinitionHP as a complex ILD, extrinsic allergic alveolitis, MDD cornerstone
4ClassificationTwo-column: Nonfibrotic (acute) vs Fibrotic (chronic) HP
5Section dividerEtiology & Antigens
6Antigen Table9 named diseases — Farmer's Lung, Bird Breeder's, Hot Tub Lung, Metalworker's, Isocyanates, etc.
7Section dividerImmunopathogenesis
8PathogenesisTwo-column: Type III immune complex vs Type IV cell-mediated
9HistopathologyClassic triad, granuloma features, Schaumann bodies, fibrotic changes
10Section dividerClinical Features & Diagnosis
11Clinical PresentationsNonfibrotic vs fibrotic side-by-side
12HRCT FindingsCentrilobular nodules, GGO, air trapping, traction bronchiectasis, HP vs IPF clues
13Diagnostic FlowchartEmbedded Murray & Nadel Fig 91.2 flowchart image
14InvestigationsPFTs, serology limitations, BAL CD4:CD8 ratio, biopsy indications
15Prognostic Factors Table8 domains from Murray & Nadel Table 91.1 (demographics → genetics)
16Section dividerManagement
17Management PillarsAntigen avoidance → steroids → steroid-sparing → antifibrotics
18Management AlgorithmEmbedded Murray & Nadel Fig 91.6 flowchart image
19Advanced DiseaseTransplant indications, mortality trends, acute exacerbation
20Section dividerDifferential Diagnosis
21DifferentialsIPF, Sarcoidosis, NSIP, RB-ILD, AEP — with distinguishing features
22Clinical PearlsDiagnosis + management pearls + "do not miss"
23ReferencesMurray & Nadel, Robbins, Radiology text, 2025-2026 guidelines (PMIDs included)
24ClosingTake-home message slide

Create a 1-page cheat sheet / quick reference guide on HP diagnosis criteria

Reading File
Finding Sources
Searching PubMed

"hypersensitivity pneumonitis" AND "diagnostic criteria"

Reading File
Finding Sources
Reading File
Writing File

~/hp-presentation/hp_cheatsheet.py

#!/usr/bin/env python3
"""
HP Diagnosis Criteria – 1-Page Cheat Sheet
Uses ReportLab for precise, dense, colour-coded layout.
"""
from reportlab.lib.pagesizes import A4
from reportlab.lib.units import mm
from reportlab.lib import colors
from reportlab.platypus import (
    SimpleDocTemplate, Table, TableStyle, Paragraph, Spacer, HRFlowable
)
from reportlab.lib.styles import ParagraphStyle
from reportlab.lib.enums import TA_LEFT, TA_CENTER
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont

# ── Colours ───────────────────────────────────────────────────────────────────
NAVY    = colors.HexColor("#0A1628")
TEAL    = colors.HexColor("#0D7377")
SKY     = colors.HexColor("#14BDCC")
AMBER   = colors.HexColor("#E67E22")
RED     = colors.HexColor("#C0392B")
GREEN   = colors.HexColor("#1E8449")
WHITE   = colors.white
OFFWHT  = colors.HexColor("#F5F8FA")
LGRAY   = colors.HexColor("#D6DCE5")
DGRAY   = colors.HexColor("#4A5568")
SLATE   = colors.HexColor("#2D4059")
YELLOW  = colors.HexColor("#FFF3CD")
YELBORD = colors.HexColor("#F5A623")

# ── Styles ────────────────────────────────────────────────────────────────────
def S(name, **kw):
    defaults = dict(fontName="Helvetica", fontSize=7.5, leading=10,
                    textColor=NAVY, spaceAfter=0, spaceBefore=0)
    defaults.update(kw)
    return ParagraphStyle(name, **defaults)

TITLE   = S("title", fontName="Helvetica-Bold", fontSize=16, leading=20,
            textColor=WHITE, alignment=TA_CENTER, spaceAfter=0)
SHEAD   = S("shead", fontName="Helvetica-Bold", fontSize=7.8, leading=10,
            textColor=WHITE, alignment=TA_CENTER)
LABEL   = S("label", fontName="Helvetica-Bold", fontSize=7, leading=9,
            textColor=NAVY)
BODY    = S("body", fontName="Helvetica", fontSize=7, leading=9.5,
            textColor=NAVY)
BODY_WH = S("body_wh", fontName="Helvetica", fontSize=7, leading=9.5,
            textColor=WHITE)
BOLD_WH = S("bold_wh", fontName="Helvetica-Bold", fontSize=7, leading=9.5,
            textColor=WHITE)
SMALL   = S("small", fontName="Helvetica", fontSize=5.8, leading=7.5,
            textColor=DGRAY)
SMALL_C = S("small_c", fontName="Helvetica", fontSize=5.8, leading=7.5,
            textColor=DGRAY, alignment=TA_CENTER)
FOOT    = S("foot", fontName="Helvetica-Oblique", fontSize=5.5, leading=7,
            textColor=DGRAY, alignment=TA_CENTER)
ALERT   = S("alert", fontName="Helvetica-Bold", fontSize=7.2, leading=9.5,
            textColor=colors.HexColor("#7D3C00"))

# helper: cell with a Paragraph
def P(text, style=None):
    if style is None: style = BODY
    return Paragraph(text, style)

def PB(text, col=None):
    c = col or NAVY
    st = S("pb", fontName="Helvetica-Bold", fontSize=7, leading=9.5, textColor=c)
    return Paragraph(text, st)

def bullet(text, indent=0, bold_start=None):
    prefix = "&nbsp;" * (indent * 4) + "• "
    if bold_start:
        return P(f"{prefix}<b>{bold_start}</b> {text}")
    return P(prefix + text)

W = A4[0]  # page width = 210 mm
H = A4[1]

OUT = "/home/daytona/workspace/hp-presentation/HP_Diagnosis_Cheatsheet.pdf"

doc = SimpleDocTemplate(
    OUT,
    pagesize=A4,
    topMargin=6*mm,
    bottomMargin=5*mm,
    leftMargin=7*mm,
    rightMargin=7*mm,
)

PW = doc.width  # usable width

# ═══════════════════════════════════════════════════════════════
# HEADER ROW
# ═══════════════════════════════════════════════════════════════
header_data = [[
    P("<b><font size=15 color='#FFFFFF'>Hypersensitivity Pneumonitis</font></b> "
      "<font size=9 color='#14BDCC'> — Diagnosis Quick Reference</font>",
      S("hdr", fontName="Helvetica-Bold", fontSize=15, leading=18, textColor=WHITE)),
    P("<font color='#14BDCC'><b>ATS/JRS/ALAT 2020 · Murray &amp; Nadel 7e · S2k Guideline 2025</b></font>",
      S("hdr2", fontName="Helvetica", fontSize=7, leading=9, textColor=WHITE,
        alignment=TA_CENTER)),
    P("<font color='#AAAAAA'>Pulmonology Quick Ref | July 2026</font>",
      S("hdr3", fontName="Helvetica-Oblique", fontSize=6.5, leading=8,
        textColor=DGRAY, alignment=TA_CENTER)),
]]
header_tbl = Table(header_data, colWidths=[PW*0.55, PW*0.28, PW*0.17])
header_tbl.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,-1), NAVY),
    ("ROWBACKGROUNDS", (0,0), (-1,-1), [NAVY]),
    ("VALIGN", (0,0), (-1,-1), "MIDDLE"),
    ("LEFTPADDING",  (0,0), (-1,-1), 6),
    ("RIGHTPADDING", (0,0), (-1,-1), 4),
    ("TOPPADDING",   (0,0), (-1,-1), 5),
    ("BOTTOMPADDING",(0,0), (-1,-1), 5),
]))

# ═══════════════════════════════════════════════════════════════
# SECTION HEADER helper
# ═══════════════════════════════════════════════════════════════
def sec_hdr(text, bg=TEAL, fg=WHITE, size=8):
    st = S("sh", fontName="Helvetica-Bold", fontSize=size, leading=11,
           textColor=fg, alignment=TA_CENTER)
    t = Table([[P(text, st)]], colWidths=[PW])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0),(-1,-1), bg),
        ("TOPPADDING",    (0,0),(-1,-1), 3),
        ("BOTTOMPADDING", (0,0),(-1,-1), 3),
        ("LEFTPADDING",   (0,0),(-1,-1), 4),
        ("RIGHTPADDING",  (0,0),(-1,-1), 4),
    ]))
    return t

def mini_hdr(text, bg=SLATE, w=None):
    cw = [w or PW]
    st = S("mh", fontName="Helvetica-Bold", fontSize=7, leading=9,
           textColor=WHITE, alignment=TA_CENTER)
    t = Table([[P(text, st)]], colWidths=cw)
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0),(-1,-1), bg),
        ("TOPPADDING",    (0,0),(-1,-1), 2),
        ("BOTTOMPADDING", (0,0),(-1,-1), 2),
        ("LEFTPADDING",   (0,0),(-1,-1), 4),
        ("RIGHTPADDING",  (0,0),(-1,-1), 4),
    ]))
    return t

# ─────────────────────────────────────────────────────────────────────────────
# ROW 1: Classification | Diagnostic Certainty
# ─────────────────────────────────────────────────────────────────────────────
CW1 = PW * 0.38
CW2 = PW * 0.62

classif_rows = [
    [P("<b>NONFIBROTIC HP</b> (Acute/Subacute)", S("c1", fontName="Helvetica-Bold",
       fontSize=7.5, leading=9.5, textColor=WHITE)),
     P("<b>FIBROTIC HP</b> (Chronic)", S("c2", fontName="Helvetica-Bold",
       fontSize=7.5, leading=9.5, textColor=WHITE))],
    [bullet("Acute onset 4–8 h post-exposure"),
     bullet("Insidious, progressive dyspnea/cough")],
    [bullet("Fever, chills, myalgia, cough"),
     bullet("Velcro crackles ± clubbing (~50%)")],
    [bullet("Resolves with antigen removal"),
     bullet("May progress despite removal")],
    [bullet("HRCT: GGO + centrilobular nodules + air trapping"),
     bullet("HRCT: Fibrosis, traction bronchiectasis, honeycombing")],
    [bullet("BAL: lymphocytosis >50% typical"),
     bullet("BAL: lymphocytosis less prominent (often 20–40%)")],
    [bullet("Histology: poorly-formed granulomas + bronchiolitis"),
     bullet("Histology: fibrosis ± granulomas; may mimic UIP/NSIP")],
]
classif_tbl = Table(classif_rows, colWidths=[PW/2, PW/2])
classif_tbl.setStyle(TableStyle([
    ("BACKGROUND", (0,0),(0,0), TEAL),
    ("BACKGROUND", (1,0),(1,0), SLATE),
    ("BACKGROUND", (0,1),(-1,-1), OFFWHT),
    ("ROWBACKGROUNDS", (0,1),(-1,-1), [OFFWHT, WHITE]),
    ("GRID",       (0,0),(-1,-1), 0.3, LGRAY),
    ("VALIGN",     (0,0),(-1,-1), "TOP"),
    ("LEFTPADDING",  (0,0),(-1,-1), 4),
    ("RIGHTPADDING", (0,0),(-1,-1), 4),
    ("TOPPADDING",   (0,0),(-1,-1), 2),
    ("BOTTOMPADDING",(0,0),(-1,-1), 2),
]))

# ─────────────────────────────────────────────────────────────────────────────
# ROW 2: Diagnostic Certainty (ATS 2020 framework)
# ─────────────────────────────────────────────────────────────────────────────
cert_data = [
    [P("<b>CONFIDENT DIAGNOSIS</b>", S("cd", fontName="Helvetica-Bold", fontSize=7,
       textColor=GREEN)),
     P("<b>WORKING DIAGNOSIS</b>", S("wd", fontName="Helvetica-Bold", fontSize=7,
       textColor=AMBER)),
     P("<b>UNLIKELY HP</b>", S("ud", fontName="Helvetica-Bold", fontSize=7,
       textColor=RED))],
    [P("✓ Known antigen exposure<br/>"
       "✓ Typical HRCT for HP<br/>"
       "✓ Consistent exposure history<br/>"
       "→ <i>MDD can diagnose without biopsy</i>", BODY),
     P("✓ Suspected but unconfirmed antigen<br/>"
       "✓ Atypical HRCT features<br/>"
       "→ <i>BAL / TBBx / SLB may be needed</i><br/>"
       "→ <i>MDD review required</i>", BODY),
     P("✗ No antigen identified<br/>"
       "✗ HRCT strongly favours alternative<br/>"
       "✗ Histology inconsistent<br/>"
       "→ <i>Reconsider alternative ILD</i>", BODY)],
]
cert_tbl = Table(cert_data, colWidths=[PW/3, PW/3, PW/3])
cert_tbl.setStyle(TableStyle([
    ("BACKGROUND", (0,0),(0,0), colors.HexColor("#D5F5E3")),
    ("BACKGROUND", (1,0),(1,0), colors.HexColor("#FEF9E7")),
    ("BACKGROUND", (2,0),(2,0), colors.HexColor("#FADBD8")),
    ("BACKGROUND", (0,1),(0,1), colors.HexColor("#EAFAF1")),
    ("BACKGROUND", (1,1),(1,1), colors.HexColor("#FDFEFE")),
    ("BACKGROUND", (2,1),(2,1), colors.HexColor("#FDEDEC")),
    ("GRID",       (0,0),(-1,-1), 0.4, LGRAY),
    ("VALIGN",     (0,0),(-1,-1), "TOP"),
    ("LEFTPADDING",  (0,0),(-1,-1), 5),
    ("RIGHTPADDING", (0,0),(-1,-1), 4),
    ("TOPPADDING",   (0,0),(-1,-1), 3),
    ("BOTTOMPADDING",(0,0),(-1,-1), 3),
]))

# ─────────────────────────────────────────────────────────────────────────────
# ROW 3: HRCT criteria | BAL | Histology  (3 columns)
# ─────────────────────────────────────────────────────────────────────────────
C3 = PW / 3

hrct_rows = [
    [P("<b>NONFIBROTIC HRCT</b>", S("h1", fontName="Helvetica-Bold", fontSize=7,
       textColor=TEAL)), P("<b>FIBROTIC HRCT</b>", S("h2", fontName="Helvetica-Bold",
       fontSize=7, textColor=SLATE))],
    [bullet("Centrilobular nodules (≤5 mm, GGO halo)"),
     bullet("Reticulation + traction bronchiectasis")],
    [bullet("Diffuse GGO — bilateral, mid-lower zones"),
     bullet("Honeycombing (HP vs UIP overlap)")],
    [bullet("Mosaic attenuation (lobular)"),
     bullet("Mid/upper zone predominance (vs IPF: lower)")],
    [bullet("Air trapping on expiratory CT ← KEY"),
     bullet("Coexisting GGO + air trapping = strong clue")],
    [bullet('"Headcheese sign": mixed GGO + mosaic'),
     bullet("Increased PA:Ao ratio if PH present")],
    [P("<i>Typical HP HRCT = GGO + centrilobular nodules + air trapping</i>",
       S("tip", fontName="Helvetica-Oblique", fontSize=6.5, textColor=TEAL)),
     P("<i>Upper/mid-zone + GGO + air trapping favours HP over IPF</i>",
       S("tip2", fontName="Helvetica-Oblique", fontSize=6.5, textColor=SLATE))],
]
hrct_tbl = Table(hrct_rows, colWidths=[C3, C3])
hrct_tbl.setStyle(TableStyle([
    ("BACKGROUND", (0,0),(0,0), colors.HexColor("#E8F8F5")),
    ("BACKGROUND", (1,0),(1,0), colors.HexColor("#EBF5FB")),
    ("ROWBACKGROUNDS", (0,1),(-1,-1), [colors.HexColor("#F5FFFD"), WHITE]),
    ("GRID",       (0,0),(-1,-1), 0.3, LGRAY),
    ("VALIGN",     (0,0),(-1,-1), "TOP"),
    ("LEFTPADDING",  (0,0),(-1,-1), 4),
    ("RIGHTPADDING", (0,0),(-1,-1), 4),
    ("TOPPADDING",   (0,0),(-1,-1), 2),
    ("BOTTOMPADDING",(0,0),(-1,-1), 2),
]))

bal_rows = [
    [P("<b>BAL FINDINGS</b>", S("bh", fontName="Helvetica-Bold", fontSize=7,
       textColor=TEAL))],
    [bullet("Lymphocytosis >20% supports HP")],
    [bullet(">50% lymphocytes: highly suggestive")],
    [bullet("CD4:CD8 ratio <1 (reversed) — classic")],
    [bullet("Fibrotic HP: lymphocyte % lower (median ~24%)")],
    [bullet("BAL lymphocytosis also in: COP, NSIP, sarcoid")],
    [bullet("Normal BAL does NOT exclude HP")],
    [P("<i>Optimal threshold >20%; Sn 68%, Sp 65%</i>",
       S("t", fontName="Helvetica-Oblique", fontSize=6.5, textColor=TEAL))],
]
bal_tbl = Table(bal_rows, colWidths=[C3])
bal_tbl.setStyle(TableStyle([
    ("BACKGROUND", (0,0),(0,0), colors.HexColor("#E8F8F5")),
    ("ROWBACKGROUNDS", (0,1),(-1,-1), [colors.HexColor("#F5FFFD"), WHITE]),
    ("GRID",       (0,0),(-1,-1), 0.3, LGRAY),
    ("VALIGN",     (0,0),(-1,-1), "TOP"),
    ("LEFTPADDING",  (0,0),(-1,-1), 4),
    ("RIGHTPADDING", (0,0),(-1,-1), 4),
    ("TOPPADDING",   (0,0),(-1,-1), 2),
    ("BOTTOMPADDING",(0,0),(-1,-1), 2),
]))

histo_rows = [
    [P("<b>HISTOPATHOLOGY</b>", S("hh", fontName="Helvetica-Bold", fontSize=7,
       textColor=TEAL))],
    [bullet("Bronchiolocentric mononuclear infiltrate")],
    [bullet("Poorly-formed noncaseating granulomas (2/3 cases)")],
    [bullet("Lymphocytic bronchiolitis")],
    [bullet("Giant cells: cholesterol clefts, Schaumann bodies")],
    [bullet("Fibrotic HP: UIP or NSIP-like pattern")],
    [bullet("Bronchiolocentric fibrosis = key HP clue vs IPF")],
    [P("<i>SLB required if MDD indeterminate after BAL</i>",
       S("t2", fontName="Helvetica-Oblique", fontSize=6.5, textColor=TEAL))],
]
histo_tbl = Table(histo_rows, colWidths=[C3])
histo_tbl.setStyle(TableStyle([
    ("BACKGROUND", (0,0),(0,0), colors.HexColor("#E8F8F5")),
    ("ROWBACKGROUNDS", (0,1),(-1,-1), [colors.HexColor("#F5FFFD"), WHITE]),
    ("GRID",       (0,0),(-1,-1), 0.3, LGRAY),
    ("VALIGN",     (0,0),(-1,-1), "TOP"),
    ("LEFTPADDING",  (0,0),(-1,-1), 4),
    ("RIGHTPADDING", (0,0),(-1,-1), 4),
    ("TOPPADDING",   (0,0),(-1,-1), 2),
    ("BOTTOMPADDING",(0,0),(-1,-1), 2),
]))

# combine BAL + histo side by side with HRCT
row3_data = [[hrct_tbl, bal_tbl, histo_tbl]]
row3_tbl = Table(row3_data, colWidths=[C3, C3, C3])
row3_tbl.setStyle(TableStyle([
    ("VALIGN", (0,0),(-1,-1), "TOP"),
    ("LEFTPADDING",  (0,0),(-1,-1), 0),
    ("RIGHTPADDING", (0,0),(-1,-1), 0),
    ("TOPPADDING",   (0,0),(-1,-1), 0),
    ("BOTTOMPADDING",(0,0),(-1,-1), 0),
]))

# ─────────────────────────────────────────────────────────────────────────────
# ROW 4: Exposure Assessment | Serology | Investigations
# ─────────────────────────────────────────────────────────────────────────────
C4a = PW * 0.38
C4b = PW * 0.32
C4c = PW * 0.30

exp_rows = [
    [P("<b>ASK ABOUT (Exposure History)</b>", S("ea", fontName="Helvetica-Bold",
       fontSize=7, textColor=NAVY)), ""],
    [bullet("Birds — pigeons, parakeets, doves; down bedding"), ""],
    [bullet("Occupation — farmers, metalworkers, painters, cheese"), ""],
    [bullet("Home — mold, musty odors, water damage, humidifiers"), ""],
    [bullet("Hobbies — woodworking, spray painting, hot tubs"), ""],
    [bullet("Summer-type HP (Japan) — Trichosporon spp."), ""],
    [P("<b>⚠ No identified antigen does NOT rule out HP</b>",
       S("warn", fontName="Helvetica-Bold", fontSize=6.5,
         textColor=colors.HexColor("#7D3C00"))), ""],
    [P("<i>(50% of chronic HP: antigen never found)</i>",
       S("wi", fontName="Helvetica-Oblique", fontSize=6.5,
         textColor=colors.HexColor("#7D3C00"))), ""],
]
exp_tbl = Table(exp_rows, colWidths=[C4a, 0.1])
exp_tbl.setStyle(TableStyle([
    ("SPAN",       (0,0),(1,0)),
    ("SPAN",       (0,6),(1,6)),
    ("SPAN",       (0,7),(1,7)),
    ("BACKGROUND", (0,0),(1,0), colors.HexColor("#EBF5FB")),
    ("ROWBACKGROUNDS", (0,1),(-1,-1), [WHITE, colors.HexColor("#F8FAFC")]),
    ("GRID",       (0,0),(-1,-1), 0.3, LGRAY),
    ("VALIGN",     (0,0),(-1,-1), "TOP"),
    ("LEFTPADDING",  (0,0),(-1,-1), 4),
    ("RIGHTPADDING", (0,0),(-1,-1), 4),
    ("TOPPADDING",   (0,0),(-1,-1), 2),
    ("BOTTOMPADDING",(0,0),(-1,-1), 2),
]))

sero_rows = [
    [P("<b>SEROLOGY — Specific IgG</b>", S("se", fontName="Helvetica-Bold",
       fontSize=7, textColor=NAVY))],
    [bullet("Qualitative: double diffusion (precipitins)")],
    [bullet("Quantitative: ELISA (preferred)")],
    [bullet("Positive = exposure, NOT disease causation")],
    [bullet("False-positive rate very high (87% controls)")],
    [bullet("Can wane with reduced exposure")],
    [P("<b>NOT recommended as screening test</b>",
       S("ns", fontName="Helvetica-Bold", fontSize=6.5,
         textColor=RED))],
    [P("Inhalational challenge (SIC): rarely available;<br/>not routinely recommended",
       S("sic", fontName="Helvetica", fontSize=6.3, leading=8, textColor=DGRAY))],
]
sero_tbl = Table(sero_rows, colWidths=[C4b])
sero_tbl.setStyle(TableStyle([
    ("BACKGROUND", (0,0),(0,0), colors.HexColor("#EBF5FB")),
    ("ROWBACKGROUNDS", (0,1),(-1,-1), [WHITE, colors.HexColor("#F8FAFC")]),
    ("GRID",       (0,0),(-1,-1), 0.3, LGRAY),
    ("VALIGN",     (0,0),(-1,-1), "TOP"),
    ("LEFTPADDING",  (0,0),(-1,-1), 4),
    ("RIGHTPADDING", (0,0),(-1,-1), 4),
    ("TOPPADDING",   (0,0),(-1,-1), 2),
    ("BOTTOMPADDING",(0,0),(-1,-1), 2),
]))

inv_rows = [
    [P("<b>PFTs / OTHER TESTS</b>", S("pf", fontName="Helvetica-Bold",
       fontSize=7, textColor=NAVY))],
    [bullet("PFTs: restrictive pattern (reduced TLC, FVC)")],
    [bullet("DLCO: reduced — correlates with severity/prognosis")],
    [bullet("Mixed obstructive-restrictive in some")],
    [bullet("Isolated low DLCO (early disease)")],
    [bullet("Exercise SpO₂: may desaturate on exertion only")],
    [bullet("Methacholine challenge: non-specific BHR possible")],
    [P("<i>Serial PFTs every 3–6 months to track progression</i>",
       S("sp", fontName="Helvetica-Oblique", fontSize=6.3, textColor=TEAL))],
]
inv_tbl = Table(inv_rows, colWidths=[C4c])
inv_tbl.setStyle(TableStyle([
    ("BACKGROUND", (0,0),(0,0), colors.HexColor("#EBF5FB")),
    ("ROWBACKGROUNDS", (0,1),(-1,-1), [WHITE, colors.HexColor("#F8FAFC")]),
    ("GRID",       (0,0),(-1,-1), 0.3, LGRAY),
    ("VALIGN",     (0,0),(-1,-1), "TOP"),
    ("LEFTPADDING",  (0,0),(-1,-1), 4),
    ("RIGHTPADDING", (0,0),(-1,-1), 4),
    ("TOPPADDING",   (0,0),(-1,-1), 2),
    ("BOTTOMPADDING",(0,0),(-1,-1), 2),
]))

row4_data = [[exp_tbl, sero_tbl, inv_tbl]]
row4_tbl = Table(row4_data, colWidths=[C4a + 0.1, C4b, C4c])
row4_tbl.setStyle(TableStyle([
    ("VALIGN", (0,0),(-1,-1), "TOP"),
    ("LEFTPADDING",  (0,0),(-1,-1), 0),
    ("RIGHTPADDING", (0,0),(-1,-1), 0),
    ("TOPPADDING",   (0,0),(-1,-1), 0),
    ("BOTTOMPADDING",(0,0),(-1,-1), 0),
]))

# ─────────────────────────────────────────────────────────────────────────────
# ROW 5: Differential Diagnosis | Prognosis red flags | Pearls
# ─────────────────────────────────────────────────────────────────────────────
C5a = PW * 0.36
C5b = PW * 0.32
C5c = PW * 0.32

diff_rows = [
    [P("<b>DIFFERENTIAL DIAGNOSIS</b>", S("dd", fontName="Helvetica-Bold",
       fontSize=7, textColor=NAVY)), ""],
    [P("<b>IPF/UIP</b> — lower zone honeycombing, no GGO, no air trapping, older male", BODY), ""],
    [P("<b>Sarcoidosis</b> — well-formed granulomas, bilat hilar LAD, lymphangitic distribution", BODY), ""],
    [P("<b>NSIP</b> — bilateral subpleural GGO, CTD association (check ANA/anti-Scl70)", BODY), ""],
    [P("<b>COP</b> — BAL lymphocytosis similar; consolidation pattern on CT", BODY), ""],
    [P("<b>RB-ILD/DIP</b> — smoking history; centrilobular GGO overlaps with HP", BODY), ""],
    [P("<b>Eosinophilic pneumonia</b> — eosinophilia present; prompt steroid response", BODY), ""],
]
diff_tbl = Table(diff_rows, colWidths=[C5a, 0.1])
diff_tbl.setStyle(TableStyle([
    ("SPAN",       (0,0),(1,0)),
    ("BACKGROUND", (0,0),(1,0), colors.HexColor("#FDFEFE")),
    ("BACKGROUND", (0,1),(-1,1), colors.HexColor("#FDEDEC")),
    ("BACKGROUND", (0,2),(-1,2), colors.HexColor("#FEF9E7")),
    ("BACKGROUND", (0,3),(-1,3), colors.HexColor("#EBF5FB")),
    ("BACKGROUND", (0,4),(-1,4), colors.HexColor("#F0FFF4")),
    ("BACKGROUND", (0,5),(-1,5), colors.HexColor("#F5EEF8")),
    ("BACKGROUND", (0,6),(-1,6), colors.HexColor("#FFF9F0")),
    ("GRID",       (0,0),(-1,-1), 0.3, LGRAY),
    ("VALIGN",     (0,0),(-1,-1), "TOP"),
    ("LEFTPADDING",  (0,0),(-1,-1), 4),
    ("RIGHTPADDING", (0,0),(-1,-1), 4),
    ("TOPPADDING",   (0,0),(-1,-1), 2),
    ("BOTTOMPADDING",(0,0),(-1,-1), 2),
]))

prog_rows = [
    [P("<b>POOR PROGNOSIS FLAGS ⚠</b>", S("pp", fontName="Helvetica-Bold",
       fontSize=7, textColor=RED))],
    [bullet("Male sex, older age")],
    [bullet("Low FVC% or DLCO% at baseline")],
    [bullet("Honeycombing / traction bronchiectasis on HRCT")],
    [bullet("Pulmonary hypertension (PA:Ao ratio ↑)")],
    [bullet("Fibroblast foci on histology")],
    [bullet("MUC5B rs35705950 SNP / telomere shortening")],
    [bullet("No identified antigen; active smoking")],
    [bullet("Acute exacerbation — VERY high mortality")],
]
prog_tbl = Table(prog_rows, colWidths=[C5b])
prog_tbl.setStyle(TableStyle([
    ("BACKGROUND", (0,0),(0,0), colors.HexColor("#FADBD8")),
    ("ROWBACKGROUNDS", (0,1),(-1,-1), [colors.HexColor("#FEF0EE"), WHITE]),
    ("GRID",       (0,0),(-1,-1), 0.3, LGRAY),
    ("VALIGN",     (0,0),(-1,-1), "TOP"),
    ("LEFTPADDING",  (0,0),(-1,-1), 4),
    ("RIGHTPADDING", (0,0),(-1,-1), 4),
    ("TOPPADDING",   (0,0),(-1,-1), 2),
    ("BOTTOMPADDING",(0,0),(-1,-1), 2),
]))

pearl_rows = [
    [P("<b>CLINICAL PEARLS ★</b>", S("cp", fontName="Helvetica-Bold",
       fontSize=7, textColor=colors.HexColor("#7D6608")))],
    [P("Temporal exposure-symptom link = biggest clue", BODY)],
    [P("Air trapping on expiratory CT = classic HP sign", BODY)],
    [P("CD4:CD8 &lt;1 on BAL — reversed ratio typical", BODY)],
    [P("Precipitins = exposure, not disease. Don't over-interpret.", BODY)],
    [P("Normal BAL/CXR does NOT exclude HP", BODY)],
    [P("Fibrotic HP: manage like IPF if rapid decline", BODY)],
    [P("Refer for transplant: FVC &lt;50% or DLCO &lt;40%", BODY)],
    [P("Acute exacerbation = emergency. Act fast.", 
       S("ae", fontName="Helvetica-Bold", fontSize=6.8, textColor=RED))],
]
pearl_tbl = Table(pearl_rows, colWidths=[C5c])
pearl_tbl.setStyle(TableStyle([
    ("BACKGROUND", (0,0),(0,0), colors.HexColor("#FEF9E7")),
    ("ROWBACKGROUNDS", (0,1),(-1,-1), [colors.HexColor("#FEFDF5"), WHITE]),
    ("GRID",       (0,0),(-1,-1), 0.3, LGRAY),
    ("VALIGN",     (0,0),(-1,-1), "TOP"),
    ("LEFTPADDING",  (0,0),(-1,-1), 4),
    ("RIGHTPADDING", (0,0),(-1,-1), 4),
    ("TOPPADDING",   (0,0),(-1,-1), 2),
    ("BOTTOMPADDING",(0,0),(-1,-1), 2),
]))

row5_data = [[diff_tbl, prog_tbl, pearl_tbl]]
row5_tbl = Table(row5_data, colWidths=[C5a + 0.1, C5b, C5c])
row5_tbl.setStyle(TableStyle([
    ("VALIGN", (0,0),(-1,-1), "TOP"),
    ("LEFTPADDING",  (0,0),(-1,-1), 0),
    ("RIGHTPADDING", (0,0),(-1,-1), 0),
    ("TOPPADDING",   (0,0),(-1,-1), 0),
    ("BOTTOMPADDING",(0,0),(-1,-1), 0),
]))

# ─────────────────────────────────────────────────────────────────────────────
# FOOTER
# ─────────────────────────────────────────────────────────────────────────────
footer = Table(
    [[P("Sources: Murray &amp; Nadel's Textbook of Respiratory Medicine 7e (Ch.91) · "
        "Robbins &amp; Kumar Basic Pathology · Grainger &amp; Allison's Diagnostic Radiology · "
        "ATS/JRS/ALAT HP Guideline 2020 (Am J Respir Crit Care Med) · "
        "S2k Guideline German Respiratory Society 2025 (PMID:39870058) · "
        "Semin Roentgenol 2026 (PMID:41513513)",
        FOOT)]],
    colWidths=[PW]
)
footer.setStyle(TableStyle([
    ("BACKGROUND", (0,0),(-1,-1), NAVY),
    ("TOPPADDING",    (0,0),(-1,-1), 3),
    ("BOTTOMPADDING", (0,0),(-1,-1), 3),
    ("LEFTPADDING",   (0,0),(-1,-1), 6),
    ("RIGHTPADDING",  (0,0),(-1,-1), 6),
]))

# ─────────────────────────────────────────────────────────────────────────────
# ASSEMBLE
# ─────────────────────────────────────────────────────────────────────────────
SP = lambda h: Spacer(1, h*mm)

story = [
    header_tbl,
    SP(0.8),
    sec_hdr("CLASSIFICATION"),
    classif_tbl,
    SP(0.8),
    sec_hdr("DIAGNOSTIC CERTAINTY (ATS/JRS/ALAT 2020 Framework)"),
    cert_tbl,
    SP(0.8),
    sec_hdr("HRCT CRITERIA                    BAL ANALYSIS                    HISTOPATHOLOGY"),
    row3_tbl,
    SP(0.8),
    sec_hdr("EXPOSURE HISTORY                                                  SEROLOGY                    PFTs"),
    row4_tbl,
    SP(0.8),
    sec_hdr("DIFFERENTIAL DIAGNOSIS                    POOR PROGNOSIS FLAGS                    CLINICAL PEARLS"),
    row5_tbl,
    SP(0.8),
    footer,
]

doc.build(story)
print(f"PDF created: {OUT}")
Running Command

cd /home/daytona/workspace/hp-presentation && python3 hp_cheatsheet.py 2>&1

Running Command

ls -lh /home/daytona/workspace/hp-presentation/HP_Diagnosis_Cheatsheet.pdf

Your 1-page cheat sheet is ready:

HP Diagnosis Cheatsheet

PDF Document · PDF


Here's what's packed onto the single A4 page, in a colour-coded, multi-panel layout:
SectionWhat's covered
HeaderTitle + guideline sources (ATS 2020, Murray & Nadel 7e, S2k 2025)
ClassificationSide-by-side: Nonfibrotic vs Fibrotic HP — symptoms, HRCT, BAL, histology
Diagnostic Certainty3-column traffic-light: Confident / Working / Unlikely — criteria for each, when MDD alone suffices vs when biopsy is needed
HRCT CriteriaNonfibrotic (centrilobular nodules, GGO, "headcheese sign," air trapping) vs Fibrotic (reticulation, traction bronchiectasis, honeycombing, mid/upper zone clue vs IPF)
BAL AnalysisLymphocytosis thresholds (>20%, >50%), reversed CD4:CD8 <1, sensitivity/specificity at optimal cutoff, caveats
HistopathologyClassic triad, Schaumann bodies, bronchiolocentric pattern, UIP/NSIP overlap
Exposure HistoryStructured triggers: birds, occupation, home mold, hobbies; "no antigen ≠ no HP" warning
SerologyIgG precipitins vs ELISA; false-positive pitfall; not a screening test
PFTsRestrictive + low DLCO, isolated DLCO reduction, exercise desaturation, serial monitoring
Differential DiagnosisIPF, Sarcoidosis, NSIP, COP, RB-ILD, Eosinophilic Pneumonia — key distinguishing features
Poor Prognosis Flags9 red-flag markers (MUC5B SNP, telomere length, PA:Ao ratio, acute exacerbation)
Clinical Pearls8 quick-fire reminders including transplant referral thresholds
FooterFull source citations with PMIDs

Now make a similar power point presentation for senior pulmonologists including the recent advances from the latest research articles and open evidence

Searching PubMed

"hypersensitivity pneumonitis" AND nintedanib

Searching PubMed

"hypersensitivity pneumonitis" AND (biomarkers OR "genomic" OR "telomere" OR "MUC5B")

Searching PubMed

"hypersensitivity pneumonitis" AND ("machine learning" OR "artificial intelligence" OR "deep learning")

Searching the Web

hypersensitivity pneumonitis 2025 2026 new research antifibrotic treatment clinical trial advances

Searching PubMed

"hypersensitivity pneumonitis" AND ("acute exacerbation" OR "progressive" OR "prognosis")

Searching PubMed

"hypersensitivity pneumonitis" AND ("single cell" OR "transcriptomic" OR "immunology" OR "pathogenesis")

Reading Web Page

https://pmc.ncbi.nlm.nih.gov/articles/PMC12689064

Reading Article

PMID: 38924775

Reading Article

PMID: 40754799

Reading Article

PMID: 40505139

Reading Article

PMID: 37591536

Finding Sources
Writing File

~/hp-presentation/build_senior.js

const pptxgen = require("pptxgenjs");
const { execSync } = require("child_process");

// ── Fetch textbook images ────────────────────────────────────────────────────
const imageUrls = [
  "https://cdn.orris.care/cdss_images/4cbf3e40cfeca1d676b99941ed523c302ddaa0049dbd1ed7f4f9efaae5e4e567.png", // Dx flowchart
  "https://cdn.orris.care/cdss_images/3d8594fc54984e5ddfa52b10416171ab5e1f193f1af29fcf8d096368096b40d2.png", // Mgmt flowchart
];
let imgDiag = null, imgMgmt = null;
try {
  const r = JSON.parse(execSync(`node /home/daytona/skills/shared/scripts/fetch_images.js "${imageUrls[0]}" "${imageUrls[1]}"`, { timeout: 30000 }).toString());
  if (r[0] && !r[0].error) imgDiag = r[0].base64;
  if (r[1] && !r[1].error) imgMgmt = r[1].base64;
} catch(e) { console.warn("Image fetch:", e.message); }

// ── Palette ──────────────────────────────────────────────────────────────────
const C = {
  midnight: "0D0D2B",   // dominant dark (richer than navy)
  indigo:   "1A1A6C",
  teal:     "0D9488",
  sky:      "22D3EE",
  lime:     "A3E635",
  amber:    "F59E0B",
  red:      "EF4444",
  green:    "22C55E",
  white:    "FFFFFF",
  offwht:   "F1F5F9",
  slate:    "334155",
  lgray:    "CBD5E1",
  dgray:    "64748B",
  gold:     "EAB308",
  purple:   "7C3AED",
};

// ── Helpers ──────────────────────────────────────────────────────────────────
const pres = new pptxgen();
pres.layout = "LAYOUT_16x9";
pres.title  = "Hypersensitivity Pneumonitis: Senior Pulmonologist Update 2026";
pres.author = "Pulmonology Advanced Education";

// TITLE SLIDE
function titleSlide(title, subtitle, tag) {
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x:0,y:0,w:10,h:5.625, fill:{color:C.midnight} });
  // gradient band
  s.addShape(pres.ShapeType.rect, { x:0,y:3.8,w:10,h:0.22, fill:{color:C.teal} });
  s.addShape(pres.ShapeType.rect, { x:0,y:4.02,w:10,h:0.06, fill:{color:C.sky} });
  // decorative circles
  s.addShape(pres.ShapeType.ellipse, { x:7.5,y:-1.5,w:5,h:5, fill:{color:C.teal, transparency:85}, line:{color:C.teal,transparency:85} });
  s.addShape(pres.ShapeType.ellipse, { x:8.5,y:2.5,w:3,h:3,  fill:{color:C.purple, transparency:88}, line:{color:C.purple,transparency:88} });
  s.addText(title, { x:0.55,y:0.8,w:8.5,h:2.2, fontSize:36,bold:true,color:C.white,fontFace:"Calibri",align:"left",valign:"middle",margin:0 });
  s.addText(subtitle, { x:0.55,y:3.0,w:7.5,h:0.55, fontSize:15,color:C.sky,fontFace:"Calibri",align:"left",margin:0 });
  if(tag){ s.addText(tag, { x:0.55,y:3.55,w:7,h:0.3, fontSize:10,color:C.amber,fontFace:"Calibri",bold:true,align:"left",margin:0 }); }
  s.addText("Murray & Nadel's Respiratory Medicine 7e  ·  Am J Respir Crit Care Med  ·  JAMA  ·  ERJ  ·  Lancet Respir Med", {
    x:0.55,y:5.28,w:9,h:0.28, fontSize:8,color:C.dgray,fontFace:"Calibri",align:"left",margin:0
  });
}

// SECTION DIVIDER
function secDiv(num, title, subtitle) {
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x:0,y:0,w:10,h:5.625, fill:{color:C.slate} });
  s.addShape(pres.ShapeType.rect, { x:0,y:0,w:0.22,h:5.625, fill:{color:C.teal} });
  s.addShape(pres.ShapeType.ellipse, { x:6.2,y:2.0,w:5.5,h:5.5, fill:{color:C.teal,transparency:90}, line:{color:C.teal,transparency:90} });
  s.addText(`${num}`, { x:0.5,y:0.5,w:2,h:1.2, fontSize:60,bold:true,color:C.teal,fontFace:"Calibri",margin:0 });
  s.addText(title, { x:0.5,y:1.5,w:8.5,h:1.5, fontSize:30,bold:true,color:C.white,fontFace:"Calibri",align:"left",margin:0 });
  if(subtitle){ s.addText(subtitle, { x:0.5,y:3.0,w:7.5,h:0.6, fontSize:14,color:C.sky,fontFace:"Calibri",align:"left",margin:0 }); }
}

// CONTENT SLIDE – heading bar + bullets, optional evidence badge
function cSlide(heading, items, opts={}) {
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x:0,y:0,w:10,h:5.625, fill:{color:C.offwht} });
  s.addShape(pres.ShapeType.rect, { x:0,y:0,w:10,h:1.05, fill:{color:C.midnight} });
  s.addShape(pres.ShapeType.rect, { x:0,y:1.05,w:10,h:0.07, fill:{color:C.teal} });
  s.addText(heading, { x:0.35,y:0.05,w:9.4,h:0.95, fontSize:21,bold:true,color:C.white,fontFace:"Calibri",align:"left",valign:"middle",margin:0 });
  // evidence badge
  if(opts.badge){
    s.addShape(pres.ShapeType.roundRect, { x:7.8,y:0.1,w:1.9,h:0.38, fill:{color:C.teal}, rectRadius:0.04, line:{color:C.teal} });
    s.addText(opts.badge, { x:7.8,y:0.1,w:1.9,h:0.38, fontSize:7,color:C.white,fontFace:"Calibri",bold:true,align:"center",valign:"middle",margin:0 });
  }
  // source tag
  if(opts.src){
    s.addShape(pres.ShapeType.roundRect, { x:opts.srcX||5.5,y:0.13,w:opts.srcW||2.2,h:0.32, fill:{color:C.amber,transparency:10}, rectRadius:0.04, line:{color:C.amber} });
    s.addText(opts.src, { x:opts.srcX||5.5,y:0.13,w:opts.srcW||2.2,h:0.32, fontSize:6.5,color:C.midnight,fontFace:"Calibri",bold:true,align:"center",valign:"middle",margin:0 });
  }
  const flat = items.map((b,i)=>{
    if(b.type==="h"){ return [{ text:b.text, options:{bold:true,color:C.teal,fontSize:b.fs||14,breakLine:true} }]; }
    if(b.type==="sub"){ return [{ text:"    – "+b.text, options:{color:C.slate,fontSize:11,breakLine:true} }]; }
    if(b.type==="ref"){ return [{ text:"  → "+b.text, options:{color:C.purple,fontSize:10,italic:true,breakLine:true} }]; }
    if(b.type==="warn"){ return [{ text:"⚠  "+b.text, options:{color:C.red,fontSize:b.fs||12,bold:true,breakLine:true} }]; }
    if(b.type==="key"){ return [{ text:"★  "+b.text, options:{color:C.gold,fontSize:b.fs||12.5,bold:true,breakLine:true} }]; }
    return [{ text:"●  "+b.text, options:{color:C.midnight,fontSize:b.fs||12.5,bold:b.bold||false,breakLine:true} }];
  }).flat();
  if(flat.length){ flat[flat.length-1].options.breakLine=false; }
  s.addText(flat, { x:opts.x||0.35,y:opts.y||1.25,w:opts.w||9.3,h:opts.h||4.1,fontFace:"Calibri",valign:"top",margin:5 });
  if(opts.foot){
    s.addText(opts.foot, { x:0.35,y:5.3,w:9.3,h:0.28, fontSize:7.5,color:C.dgray,fontFace:"Calibri",italic:true,align:"left",margin:0 });
  }
}

// TWO-COL SLIDE
function twoCol(heading, leftT, left, rightT, right, opts={}) {
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x:0,y:0,w:10,h:5.625, fill:{color:C.offwht} });
  s.addShape(pres.ShapeType.rect, { x:0,y:0,w:10,h:1.05, fill:{color:C.midnight} });
  s.addShape(pres.ShapeType.rect, { x:0,y:1.05,w:10,h:0.07, fill:{color:C.teal} });
  s.addShape(pres.ShapeType.line, { x:5.1,y:1.2,w:0,h:4.1, line:{color:C.lgray,width:1.2} });
  s.addText(heading, { x:0.35,y:0.05,w:9.4,h:0.95, fontSize:21,bold:true,color:C.white,fontFace:"Calibri",align:"left",valign:"middle",margin:0 });
  if(opts.badge){
    s.addShape(pres.ShapeType.roundRect, { x:7.8,y:0.1,w:1.9,h:0.38, fill:{color:C.teal}, rectRadius:0.04, line:{color:C.teal} });
    s.addText(opts.badge, { x:7.8,y:0.1,w:1.9,h:0.38, fontSize:7,color:C.white,fontFace:"Calibri",bold:true,align:"center",valign:"middle",margin:0 });
  }
  if(leftT){ s.addText(leftT, { x:0.35,y:1.14,w:4.6,h:0.35, fontSize:12,bold:true,color:C.teal,fontFace:"Calibri",margin:0 }); }
  if(rightT){ s.addText(rightT, { x:5.25,y:1.14,w:4.5,h:0.35, fontSize:12,bold:true,color:C.teal,fontFace:"Calibri",margin:0 }); }
  const mk = arr => {
    const f = arr.map(b=>{
      if(b.type==="h"){ return [{ text:b.text, options:{bold:true,color:C.teal,fontSize:b.fs||12.5,breakLine:true} }]; }
      if(b.type==="sub"){ return [{ text:"    – "+b.text, options:{color:C.slate,fontSize:10.5,breakLine:true} }]; }
      if(b.type==="ref"){ return [{ text:"→ "+b.text, options:{color:C.purple,fontSize:10,italic:true,breakLine:true} }]; }
      if(b.type==="warn"){ return [{ text:"⚠  "+b.text, options:{color:C.red,fontSize:11,bold:true,breakLine:true} }]; }
      if(b.type==="key"){ return [{ text:"★  "+b.text, options:{color:C.gold,fontSize:11.5,bold:true,breakLine:true} }]; }
      return [{ text:"●  "+b.text, options:{color:C.midnight,fontSize:b.fs||12,bold:b.bold||false,breakLine:true} }];
    }).flat();
    if(f.length){ f[f.length-1].options.breakLine=false; }
    return f;
  };
  const ly = leftT ? 1.55 : 1.25;
  const ry = rightT ? 1.55 : 1.25;
  s.addText(mk(left),  { x:0.35,y:ly,w:4.6,h:3.8,fontFace:"Calibri",valign:"top",margin:4 });
  s.addText(mk(right), { x:5.25,y:ry,w:4.45,h:3.8,fontFace:"Calibri",valign:"top",margin:4 });
  if(opts.foot){ s.addText(opts.foot, { x:0.35,y:5.3,w:9.3,h:0.28, fontSize:7.5,color:C.dgray,fontFace:"Calibri",italic:true,align:"left",margin:0 }); }
}

// IMAGE SLIDE
function imgSlide(heading, imgData, caption, iy=1.18, ih=3.9) {
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x:0,y:0,w:10,h:5.625, fill:{color:C.offwht} });
  s.addShape(pres.ShapeType.rect, { x:0,y:0,w:10,h:1.05, fill:{color:C.midnight} });
  s.addShape(pres.ShapeType.rect, { x:0,y:1.05,w:10,h:0.07, fill:{color:C.teal} });
  s.addText(heading, { x:0.35,y:0.05,w:9.4,h:0.95, fontSize:21,bold:true,color:C.white,fontFace:"Calibri",align:"left",valign:"middle",margin:0 });
  if(imgData){ s.addImage({ data:imgData, x:0.4,y:iy,w:9.2,h:ih }); }
  if(caption){ s.addText(caption, { x:0.35,y:5.18,w:9.3,h:0.4, fontSize:7.5,color:C.dgray,fontFace:"Calibri",italic:true,align:"center",margin:0 }); }
}

// TABLE SLIDE
function tableSlide(heading, rows, colWidths, opts={}) {
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x:0,y:0,w:10,h:5.625, fill:{color:C.offwht} });
  s.addShape(pres.ShapeType.rect, { x:0,y:0,w:10,h:1.05, fill:{color:C.midnight} });
  s.addShape(pres.ShapeType.rect, { x:0,y:1.05,w:10,h:0.07, fill:{color:C.teal} });
  s.addText(heading, { x:0.35,y:0.05,w:9.4,h:0.95, fontSize:21,bold:true,color:C.white,fontFace:"Calibri",align:"left",valign:"middle",margin:0 });
  s.addTable(rows, { x:0.3,y:1.22,w:9.4,h:opts.h||4.1, colW:colWidths, fontFace:"Calibri",fontSize:11, border:{pt:0.5,color:"D1D5DB"}, fill:{color:C.white} });
  if(opts.foot){ s.addText(opts.foot, { x:0.35,y:5.3,w:9.3,h:0.28, fontSize:7.5,color:C.dgray,fontFace:"Calibri",italic:true,align:"left",margin:0 }); }
}

// EVIDENCE SLIDE – highlighted citation box
function evidSlide(heading, citationText, summaryItems, opts={}) {
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x:0,y:0,w:10,h:5.625, fill:{color:C.offwht} });
  s.addShape(pres.ShapeType.rect, { x:0,y:0,w:10,h:1.05, fill:{color:C.midnight} });
  s.addShape(pres.ShapeType.rect, { x:0,y:1.05,w:10,h:0.07, fill:{color:C.teal} });
  // evidence badge
  s.addShape(pres.ShapeType.roundRect, { x:6.5,y:0.14,w:3.2,h:0.35, fill:{color:C.amber}, rectRadius:0.04, line:{color:C.amber} });
  s.addText(opts.badge||"NEW EVIDENCE", { x:6.5,y:0.14,w:3.2,h:0.35, fontSize:7,color:C.midnight,fontFace:"Calibri",bold:true,align:"center",valign:"middle",margin:0 });
  s.addText(heading, { x:0.35,y:0.05,w:6.0,h:0.95, fontSize:20,bold:true,color:C.white,fontFace:"Calibri",align:"left",valign:"middle",margin:0 });
  // citation box
  s.addShape(pres.ShapeType.roundRect, { x:0.35,y:1.2,w:9.3,h:0.72, fill:{color:"1E293B"}, rectRadius:0.06, line:{color:C.teal,width:1.5} });
  s.addText(citationText, { x:0.45,y:1.22,w:9.1,h:0.68, fontSize:9,color:C.sky,fontFace:"Calibri",italic:true,valign:"middle",margin:0 });
  // bullets
  const flat = summaryItems.map(b=>{
    if(b.type==="h"){ return [{ text:b.text, options:{bold:true,color:C.teal,fontSize:13.5,breakLine:true} }]; }
    if(b.type==="sub"){ return [{ text:"    – "+b.text, options:{color:C.slate,fontSize:11,breakLine:true} }]; }
    if(b.type==="key"){ return [{ text:"★  "+b.text, options:{color:C.gold,fontSize:12.5,bold:true,breakLine:true} }]; }
    if(b.type==="warn"){ return [{ text:"⚠  "+b.text, options:{color:C.red,fontSize:12,bold:true,breakLine:true} }]; }
    return [{ text:"●  "+b.text, options:{color:C.midnight,fontSize:12,bold:b.bold||false,breakLine:true} }];
  }).flat();
  if(flat.length){ flat[flat.length-1].options.breakLine=false; }
  s.addText(flat, { x:0.35,y:2.05,w:9.3,h:3.15,fontFace:"Calibri",valign:"top",margin:5 });
  if(opts.foot){ s.addText(opts.foot, { x:0.35,y:5.32,w:9.3,h:0.25, fontSize:7,color:C.dgray,fontFace:"Calibri",italic:true,align:"left",margin:0 }); }
}

// CLOSING SLIDE
function closingSlide() {
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x:0,y:0,w:10,h:5.625, fill:{color:C.midnight} });
  s.addShape(pres.ShapeType.rect, { x:0,y:2.55,w:10,h:0.12, fill:{color:C.teal} });
  s.addShape(pres.ShapeType.ellipse, { x:-1.5,y:3,w:6,h:6, fill:{color:C.teal,transparency:90}, line:{color:C.teal,transparency:90} });
  s.addShape(pres.ShapeType.ellipse, { x:7.5,y:-1,w:4,h:4, fill:{color:C.purple,transparency:90}, line:{color:C.purple,transparency:90} });
  s.addText("Where are we headed?", { x:1,y:0.5,w:8,h:0.55, fontSize:16,color:C.sky,fontFace:"Calibri",bold:true,align:"center",margin:0 });
  s.addText([
    { text:"The future of HP management lies at the intersection of\n", options:{color:C.white,fontSize:20,bold:true,breakLine:true} },
    { text:"precision immunology, genomics, and antifibrotic biology.\n", options:{color:C.sky,fontSize:17,breakLine:true} },
    { text:"Single-cell transcriptomics is redefining disease endotypes.\n", options:{color:C.lgray,fontSize:14,breakLine:true} },
    { text:"Telomere-guided immunosuppression is already changing practice.\n", options:{color:C.lgray,fontSize:14,breakLine:true} },
    { text:"The antifibrotic era has arrived — clinical trial data are accumulating fast.", options:{color:C.amber,fontSize:14,bold:true} },
  ], { x:0.8,y:2.75,w:8.4,h:2.4,fontFace:"Calibri",align:"center",valign:"middle",margin:0 });
  s.addText("Based on Murray & Nadel 7e · Am J Respir Crit Care Med 2024–2025 · Lancet Respir Med 2025 · ERJ 2023 · Expert Rev Clin Immunol 2025 · PMC Open Access 2025", {
    x:0.5,y:5.3,w:9,h:0.26, fontSize:7,color:C.dgray,fontFace:"Calibri",align:"center",margin:0
  });
}

// ═══════════════════════════════════════════════════════════════════════════
//  BUILD SLIDES
// ═══════════════════════════════════════════════════════════════════════════

// ── SLIDE 1: Title ───────────────────────────────────────────────────────────
titleSlide(
  "Hypersensitivity Pneumonitis\nAdvanced Update 2026",
  "For Senior Pulmonologists: Pathogenesis, Diagnostics & Emerging Therapies",
  "● Includes data from AJRCCM 2024 · ERJ 2023 · Expert Rev Clin Immunol 2025 · PMC Open Access 2025"
);

// ── SLIDE 2: Agenda / What's New ─────────────────────────────────────────────
cSlide("Agenda: What Has Changed in HP?", [
  { type:"h",  text:"1.  Redefined Classification — Fibrotic vs Nonfibrotic Endotypes" },
  { text:"Shift from time-based (acute/subacute/chronic) to biology-based classification" },
  { type:"h",  text:"2.  Updated Diagnostic Framework (ATS 2020 + Post-2020 Evidence)" },
  { text:"HRCT certainty model, MDD role, antigen indeterminate status outcomes" },
  { type:"h",  text:"3.  Single-Cell Immunology — Novel Disease Mechanisms Uncovered" },
  { text:"GZMhi cytotoxic T cells, SPP1hi macrophages, CCL3/CCL4 monocytes — AJRCCM 2024" },
  { type:"h",  text:"4.  Genomics & Biomarkers — Precision Medicine Era Begins" },
  { text:"Telomere length as treatment decision tool; MUC5B SNP; KL-6; SP-D" },
  { type:"h",  text:"5.  Antifibrotic Therapy — Evidence From RCTs" },
  { text:"Nintedanib in PPF (INBUILD); Pirfenidone in fibrotic HP — 2025 NMA + meta-analysis" },
  { type:"h",  text:"6.  Practical Challenges — CT Overlap, CTD Mimicry, Acute Exacerbations" },
  { text:"14% of 'typical fHP pattern' on CT eventually develop CTD — AJRCCM 2025" },
], { foot:"Sources: Murray & Nadel 7e; AJRCCM 2024–2025; ERJ 2023; Expert Rev Clin Immunol 2025; PMC 2025" });

// ── SLIDE 3: Section – New Classification ────────────────────────────────────
secDiv("01", "Updated Classification &\nDisease Endotypes", "From time-based to biology-based — why it matters clinically");

// ── SLIDE 4: Classification in Detail ────────────────────────────────────────
twoCol(
  "Nonfibrotic vs Fibrotic HP: Key Differences",
  "NONFIBROTIC HP", [
    { text:"Predominantly inflammatory — lymphocytic alveolitis" },
    { text:"Acute onset 4–8 h post-exposure: fever, chills, dyspnea" },
    { text:"HRCT: GGO, centrilobular nodules, air trapping" },
    { text:"BAL: lymphocytosis >50%, reversed CD4:CD8 ratio" },
    { text:"Histology: poorly-formed granulomas + bronchiolitis" },
    { text:"Reversible with complete antigen avoidance" },
    { text:"PFTs: restriction + low DLCO; may fully normalise" },
    { type:"key", text:"Antigen identification = excellent prognosis" },
  ],
  "FIBROTIC HP", [
    { text:"Inflammatory + fibrotic — mixed mechanism" },
    { text:"Insidious onset; antigen link often unclear" },
    { text:"HRCT: traction bronchiectasis, honeycombing, mid-zone" },
    { text:"BAL lymphocytosis reduced (median 24%); often <30%" },
    { text:"Histology: UIP or NSIP-like + bronchiolocentric clue" },
    { text:"Progresses even after antigen removal in many" },
    { text:"PFTs: low FVC%, low DLCO% — serial decline" },
    { type:"warn", text:"Mortality approaches IPF in advanced fibrotic HP" },
  ],
  { badge:"CLASSIFICATION 2020+", foot:"Murray & Nadel 7e, Chapter 91; ATS/JRS/ALAT 2020 HP Guideline" }
);

// ── SLIDE 5: Section – New Pathogenesis ──────────────────────────────────────
secDiv("02", "Immunopathogenesis:\nSingle-Cell Revolution", "What scRNA-seq is teaching us about fibrotic HP");

// ── SLIDE 6: Single-Cell Evidence ───────────────────────────────────────────
evidSlide(
  "Single-Cell Transcriptomics in Fibrotic HP",
  "Zhao AY, Unterman A, et al. "Single-Cell Analysis Reveals Novel Immune Perturbations in Fibrotic Hypersensitivity Pneumonitis." Am J Respir Crit Care Med. 2024 Nov;210(9). PMID: 38924775",
  [
    { type:"h", text:"Study Design" },
    { text:"5' scRNA-seq on PBMCs + BAL from 45 FHP, 63 IPF, 4 nonfibrotic HP, 36 healthy controls (US + Mexico)" },
    { text:"501,534 PBMCs and 88,336 BAL cells profiled" },
    { type:"h", text:"Key Findings — Unique to FHP" },
    { type:"key", text:"GZMhi cytotoxic CD4+ AND CD8+ T cells — elevated vs both IPF and controls" },
    { text:"TF activities: TGFβ, TNFα, and NFκB pathways in these T cells" },
    { type:"key", text:"CCL3hi/CCL4hi and S100Ahi classical monocytes → differentiate into SPP1hi fibrotic macrophages" },
    { text:"SPP1hi macrophages are shared with IPF — converging downstream fibrotic mechanism" },
    { type:"h", text:"Clinical Implication" },
    { text:"GZMhi T cells and SPP1+ macrophages = potential novel therapeutic targets" },
    { text:"Data publicly available: http://ildimmunecellatlas.com" },
  ],
  { badge:"AJRCCM 2024 · scRNA-seq", foot:"PMID 38924775 | DOI: 10.1164/rccm.202401-0078OC" }
);

// ── SLIDE 7: Classical Immunopathogenesis ────────────────────────────────────
twoCol(
  "Classical Immunopathogenesis: Dual Mechanism (Updated View)",
  "TYPE III — Immune Complex", [
    { text:"Inhaled antigens → specific serum IgG (precipitins)" },
    { text:"Antigen-antibody complexes → complement activation" },
    { text:"Acute neutrophilic alveolitis within hours" },
    { text:"Explains acute febrile HP presentation" },
    { type:"h", text:"Histology" },
    { text:"Peribronchiolar mononuclear infiltrate" },
    { text:"Poorly-formed noncaseating granulomas (2/3 cases)" },
    { text:"Cholesterol clefts, Schaumann bodies in giant cells" },
  ],
  "TYPE IV — Cell-Mediated (New Insights)", [
    { text:"CD4+ and CD8+ T cells — sensitised to antigen" },
    { type:"key", text:"NEW: GZMhi cytotoxic T cells — unique to FHP (not seen in IPF)" },
    { text:"TGFβ + TNFα + NFκB pathway activation" },
    { type:"key", text:"NEW: S100Ahi monocytes → SPP1hi fibrotic macrophages (shared with IPF)" },
    { type:"h", text:"Fibrosis Pathway" },
    { text:"SPP1+ macrophages drive myofibroblast activation" },
    { text:"Telomere shortening accelerates fibroblast senescence" },
    { text:"TGFβ1 → collagen deposition → irreversible fibrosis" },
  ],
  { badge:"UPDATED PATHOGENESIS", foot:"Murray & Nadel 7e; Zhao et al. AJRCCM 2024 (PMID:38924775)" }
);

// ── SLIDE 8: Section – Diagnosis ─────────────────────────────────────────────
secDiv("03", "Diagnostics: Evolving\nEvidence & Pitfalls", "CT overlap, CTD mimicry, and the antigen-indeterminate problem");

// ── SLIDE 9: CT Overlap Evidence ─────────────────────────────────────────────
evidSlide(
  "The 'Typical fHP Pattern' CT Trap",
  "Ryerson CJ, Marinescu DC, Muller NL, et al. "Outcomes of a Typical Fibrotic Hypersensitivity Pneumonitis Pattern on Chest CT." Am J Respir Crit Care Med. 2025 Oct. PMID: 40505139",
  [
    { type:"h", text:"Study: Prospective Registry — 164 patients with CT pattern of 'typical fHP'" },
    { text:"Multidisciplinary diagnoses established by consensus (structured MDD)" },
    { type:"h", text:"The Diagnosis Distribution Was Striking:" },
    { text:"fHP with exposure identified: 49 patients (30%)" },
    { text:"fHP without exposure identified: 56 patients (34%)" },
    { type:"key", text:"CTD-ILD: 36 patients (22%) — most common non-HP diagnosis" },
    { text:"Other MDD diagnoses: 23 patients (14%)" },
    { type:"h", text:"Outcome Differences" },
    { text:"fHP without exposure: WORSE lung function decline and higher mortality/transplant rate" },
    { type:"warn", text:"14% of 'antigen-negative fHP' developed CTD features (new autoimmune serology or rheumatologist-confirmed CTD) during follow-up" },
    { type:"key", text:"Conclusion: Always screen for CTD in antigen-negative fHP. Order ANA, anti-CCP, anti-Scl70, myositis panel." },
  ],
  { badge:"AJRCCM 2025 · Prospective", foot:"PMID 40505139 | DOI: 10.1164/rccm.202411-2215OC" }
);

// ── SLIDE 10: Diagnostic Algorithm ───────────────────────────────────────────
if (imgDiag) {
  imgSlide("Diagnostic Algorithm for HP (Murray & Nadel Fig 91.2)", imgDiag,
    "Fig 91.2 — Integrated HP diagnostic approach: exposure assessment → HRCT certainty → MDD → biopsy when needed. (Murray & Nadel's Respiratory Medicine, Chapter 91)");
}

// ── SLIDE 11: Diagnostic Certainty Framework ──────────────────────────────────
const hdr = (txt, bg) => ({ text: txt, options: { bold:true, color:"FFFFFF", fill:{color:bg}, align:"center", fontSize:10.5 }});
tableSlide(
  "ATS 2020 Diagnostic Certainty Framework — Annotated for Senior Practice",
  [
    [hdr("Domain", C.midnight), hdr("CONFIDENT Dx", C.teal), hdr("WORKING Dx", C.slate), hdr("UNLIKELY HP", "991B1B")],
    [
      { text:"Antigen Exposure", options:{bold:true, fontSize:10} },
      { text:"Known exposure + positive history or serology" },
      { text:"Suspected but unconfirmed; antigen indeterminate" },
      { text:"No relevant exposure despite exhaustive search" },
    ],
    [
      { text:"HRCT Pattern", options:{bold:true, fontSize:10} },
      { text:"Typical HP: GGO + centrilobular nodules + air trapping" },
      { text:"Compatible but atypical; mid-upper fibrosis possible" },
      { text:"Clearly favours IPF/UIP, NSIP without HP features" },
    ],
    [
      { text:"BAL", options:{bold:true, fontSize:10} },
      { text:"Supports but not required; lymphocytosis >30%" },
      { text:"Borderline lymphocytosis (20–30%); may guide biopsy" },
      { text:"Normal BAL or neutrophilia only — does not exclude" },
    ],
    [
      { text:"Biopsy", options:{bold:true, fontSize:10} },
      { text:"Not required if Confident Dx on MDD" },
      { text:"TBBx ± Cryo/SLB; aim to improve certainty at MDD" },
      { text:"SLB may redirect to IPF, CTD-ILD or other diagnosis" },
    ],
    [
      { text:"★ Senior Pearl", options:{bold:true, fontSize:10, color:"92400E"} },
      { text:"22% of typical fHP CT = CTD-ILD (Ryerson 2025)", options:{italic:true, fontSize:9.5} },
      { text:"Check autoimmune serology in ALL antigen-negative patients", options:{italic:true, fontSize:9.5} },
      { text:"Reconsider HP if no antigen + atypical HRCT + ANA+", options:{italic:true, fontSize:9.5} },
    ],
  ],
  [2.0, 2.5, 2.5, 2.4],
  { foot:"ATS/JRS/ALAT 2020 HP Guidelines; Ryerson CJ et al. AJRCCM 2025 (PMID:40505139)" }
);

// ── SLIDE 12: Section – Genomics & Biomarkers ────────────────────────────────
secDiv("04", "Genomics, Telomeres\n& Biomarkers", "Precision medicine is no longer theoretical in HP");

// ── SLIDE 13: Telomere Evidence ───────────────────────────────────────────────
evidSlide(
  "Telomere Length: Rethinking Immunosuppression",
  "Zhang D, Adegunsoye A, Oldham JM, et al. "Telomere length and immunosuppression in non-IPF interstitial lung disease." Eur Respir J. 2023 Nov. PMID: 37591536",
  [
    { type:"h", text:"Study Design" },
    { text:"Retrospective multicentre cohort: 613 (discovery) + 325 (replication) patients" },
    { text:"Populations: fibrotic HP (fHP), unclassifiable ILD, CTD-ILD across 5 centres" },
    { text:"LTL measured by qPCR; outcome: 2-year transplant-free survival" },
    { type:"h", text:"Key Findings — Practice-Changing" },
    { type:"key", text:"fHP + LTL <10th percentile + immunosuppression (AZA or MMF): HR 4.97 (CI 2.26–10.92, p<0.001)" },
    { text:"Replication cohort confirmed: HR 4.90 (CI 1.74–13.77, p=0.003)" },
    { text:"Significant interaction between telomere shortening and immunosuppressant exposure" },
    { text:"Patients with normal LTL: no differential survival with immunosuppression" },
    { type:"h", text:"Clinical Practice Implication" },
    { type:"warn", text:"CHECK TELOMERE LENGTH before starting AZA/MMF in fibrotic HP patients" },
    { text:"Short telomeres → AVOID immunosuppression → consider antifibrotics or transplant" },
  ],
  { badge:"ERJ 2023 · PRACTICE-CHANGING", foot:"PMID 37591536 | DOI: 10.1183/13993003.00441-2023 | Open Access via PMC10695771" }
);

// ── SLIDE 14: Genomics & Biomarkers Overview ──────────────────────────────────
cSlide("Genomics & Biomarkers in Fibrotic HP: Current Evidence", [
  { type:"h", text:"GENETIC RISK MARKERS" },
  { text:"MUC5B rs35705950 promoter SNP — associated with susceptibility AND worse prognosis in fibrotic HP" },
  { text:"Telomere gene mutations (TERT, TERC, RTEL1, PARN) — telomeropathy as HP substrate" },
  { text:"Short telomeres (<10th percentile) in ~22% of fibrotic ILD patients; modify treatment decisions" },
  { type:"h", text:"SERUM BIOMARKERS (Research / Emerging)" },
  { text:"KL-6 (Krebs von den Lungen 6): elevated in active fibrotic HP; tracks disease activity over time" },
  { text:"SP-D (surfactant protein D): correlates with alveolar epithelial injury" },
  { text:"CCL18: elevated in progressive fibrosis; prognostic marker across ILDs" },
  { text:"YKL-40 / CHI3L1: chitinase marker of macrophage activation" },
  { type:"h", text:"BAL IMMUNE PHENOTYPING (Research)" },
  { text:"SPP1+ macrophage enrichment: fibrotic trajectory marker (Zhao et al. 2024)" },
  { type:"key", text:"GZMhi cytotoxic T cell expansion in BAL = unique FHP signature vs IPF" },
], { badge:"PRECISION MEDICINE", foot:"Murray & Nadel 7e; Zhao et al. AJRCCM 2024; Zhang et al. ERJ 2023; D'Alessandro et al. Panminerva Med 2022" });

// ── SLIDE 15: Section – Antifibrotic Therapy ──────────────────────────────────
secDiv("05", "Antifibrotic Therapy\nin HP", "From IPF to progressive pulmonary fibrosis — what's the evidence?");

// ── SLIDE 16: Nintedanib / INBUILD NMA Evidence ───────────────────────────────
evidSlide(
  "Antifibrotics in Progressive HP: Network Meta-Analysis",
  "Singh P, Thampi G, Gupta K, et al. "Clinical efficacy and safety evaluation of drug therapies for PF-ILDs: a network meta-analysis of RCTs." Expert Rev Clin Immunol. 2025 Aug. PMID: 40754799",
  [
    { type:"h", text:"Study: NMA of 65 RCTs (13,521 patients); 4 studies (259 patients) specifically in chronic HP (CHP)" },
    { type:"h", text:"Findings for CHP:" },
    { text:"Pirfenidone + prednisolone showed benefit in CHP in the available (limited) RCT data" },
    { text:"Nintedanib: established in IPF and PPF (INBUILD trial); HP patients included via PPF criterion" },
    { type:"h", text:"Network Evidence: Drugs effective across PF-ILDs" },
    { text:"Pirfenidone: slows FVC decline, reduces mortality in IPF; promising in fibrotic HP" },
    { text:"Nintedanib: effective in IPF + PPF (including HP with progressive phenotype)" },
    { type:"key", text:"Conclusion: Pirfenidone and nintedanib are the most evidence-supported agents for PF-ILDs including progressive HP" },
    { type:"warn", text:"High-quality RCT data specific to HP remain scarce — only 4 HP-specific RCTs in this NMA" },
  ],
  { badge:"NMA · Systematic Review 2025", foot:"PMID 40754799 | DOI: 10.1080/1744666X.2025.2543473" }
);

// ── SLIDE 17: Pirfenidone in Fibrotic HP Meta-Analysis ───────────────────────
evidSlide(
  "Pirfenidone in Fibrotic HP: Meta-Analysis (2025)",
  "Giri B et al. "Efficacy of pirfenidone in fibrotic hypersensitivity pneumonitis: a systematic review and meta-analysis of RCTs." Open Access. PMC 2025. PMID: 41377281",
  [
    { type:"h", text:"Study: Systematic review + meta-analysis of RCTs on pirfenidone in fibrotic HP" },
    { type:"h", text:"Primary Outcomes:" },
    { text:"% predicted FVC: Non-significant increase [MD: +3.65; 95% CI: −1.63 to +8.94; p=0.18]" },
    { text:"% predicted DLCO: Non-significant [MD: +7.64; 95% CI: −1.46 to +16.74; p=0.10]" },
    { type:"h", text:"Secondary Outcome — Quality of Life:" },
    { type:"key", text:"SGRQ score: Significant improvement [MD: −5.0; 95% CI: −6.88 to −3.12; p<0.00001]" },
    { type:"h", text:"Interpretation" },
    { text:"Pirfenidone does NOT significantly improve objective lung function metrics in fibrotic HP" },
    { text:"BUT significantly improves quality of life (SGRQ) — clinically meaningful" },
    { type:"warn", text:"Important caveat: Very limited HP-specific RCT data; results driven by small trial pool" },
    { text:"Pathophysiological overlap with IPF supports continued investigation in HP" },
  ],
  { badge:"META-ANALYSIS 2025 · Open Access", foot:"PMID 41377281 | PMC12689064 | Free full text available" }
);

// ── SLIDE 18: Management Algorithm Image ─────────────────────────────────────
if (imgMgmt) {
  imgSlide("HP Management Algorithm (Murray & Nadel Fig 91.6)", imgMgmt,
    "Fig 91.6 — HP management: antigen avoidance → corticosteroids → corticosteroid-sparing (AZA/MMF) → antifibrotics → transplant evaluation. (Murray & Nadel 7e, Ch.91)");
}

// ── SLIDE 19: Comprehensive Management Ladder ─────────────────────────────────
cSlide("Management: Evidence-Graded Treatment Ladder", [
  { type:"h", text:"STEP 1 — Antigen Avoidance (ALL patients; first-line)" },
  { text:"Complete removal is most effective intervention; even partial avoidance slows progression" },
  { text:"Occupational counselling; environmental remediation; HEPA filtration; industrial hygienist referral" },
  { type:"h", text:"STEP 2 — Corticosteroids (Inflammatory / Symptomatic disease)" },
  { text:"Prednisone 0.5 mg/kg/day → taper over 4–6 weeks; limited evidence base" },
  { text:"Monitoring: bone density, glycaemia, infection risk; plan exit strategy early" },
  { type:"h", text:"STEP 3 — Steroid-Sparing Immunosuppression (Fibrotic HP — with caution)" },
  { type:"warn", text:"CHECK TELOMERE LENGTH first — LTL <10th percentile + AZA/MMF = 5x mortality HR (ERJ 2023)" },
  { text:"If LTL normal: AZA (2–3 mg/kg/day) or MMF (1–3 g/day)" },
  { type:"h", text:"STEP 4 — Antifibrotic Therapy (Progressive Fibrotic HP)" },
  { text:"Nintedanib: FDA-approved for PPF (INBUILD 2020); use if FVC declining ≥5–10%/yr despite Steps 1–3" },
  { text:"Pirfenidone: improves QoL (SGRQ) in fibrotic HP; consider for progressive disease" },
  { type:"h", text:"STEP 5 — Lung Transplantation" },
  { text:"Refer: FVC <50%, DLCO <40%, resting/exertional hypoxemia, rapid decline despite therapy" },
], { foot:"Murray & Nadel 7e; Zhang et al. ERJ 2023 (PMID:37591536); Giri et al. PMC 2025 (PMID:41377281); Singh et al. 2025 (PMID:40754799)" });

// ── SLIDE 20: Section – Acute Exacerbations ───────────────────────────────────
secDiv("06", "Acute Exacerbations of\nFibrotic HP", "A medical emergency — recognition and management");

// ── SLIDE 21: Acute Exacerbation ──────────────────────────────────────────────
twoCol(
  "Acute Exacerbation of Fibrotic HP (AE-fHP)",
  "RECOGNITION", [
    { text:"Rapid worsening of dyspnea within 30 days" },
    { text:"New bilateral GGO on HRCT superimposed on fibrotic background" },
    { text:"Exclude: infection, pulmonary embolism, cardiac failure" },
    { text:"Triggers: infection, surgical procedures, inhalation events" },
    { text:"May occur without identifiable trigger (idiopathic AE)" },
    { type:"warn", text:"Mortality of AE-fHP: 50–80% in-hospital" },
    { text:"Similar mechanism to AE-IPF: epithelial injury + macrophage storm" },
  ],
  "MANAGEMENT", [
    { type:"h", text:"Evidence-Based Steps" },
    { text:"High-dose IV methylprednisolone 500–1000 mg x 3 days" },
    { text:"Broad-spectrum antibiotics (exclude infection)" },
    { text:"Prophylactic anticoagulation if no contraindication" },
    { text:"Supplemental O2 + NIV / HFNO for respiratory support" },
    { text:"Continue antifibrotic if patient tolerating" },
    { type:"h", text:"ICU Considerations" },
    { text:"Intubation and mechanical ventilation: very poor outcomes; discuss goals of care early" },
    { type:"key", text:"Palliative/comfort care discussion ESSENTIAL at AE presentation" },
  ],
  { badge:"HIGH MORTALITY — EMERGENCY", foot:"Murray & Nadel 7e; analogous to AE-IPF evidence (Collard et al. AJRCCM)" }
);

// ── SLIDE 22: Section – Emerging & Future Therapies ──────────────────────────
secDiv("07", "Emerging & Future\nTherapies", "What to watch in the next 2–3 years");

// ── SLIDE 23: Pipeline ─────────────────────────────────────────────────────────
cSlide("Emerging Therapeutic Targets in HP / Fibrotic ILD", [
  { type:"h", text:"IN CLINICAL TRIALS" },
  { text:"Nerandomilast (BI 1015550) — PDE4B inhibitor; Phase III in IPF/PPF — includes HP with progressive phenotype" },
  { text:"MTX-463 — anti-WISP1 mAb; Phase 2 ongoing in PPF (NCT in progress); IPF/HP eligible" },
  { text:"Inhaled treprostinil (TETON-2): met primary endpoint (+95.6 mL FVC vs placebo); TETON-1 results expected mid-2026" },
  { text:"AI-designed drugs: Insilico Medicine's INS018_055 (IPF) — first AI-designed drug in Phase II; signals for HP pipeline" },
  { type:"h", text:"MECHANISTICALLY COMPELLING (Pre-Clinical / Early Phase)" },
  { text:"Anti-CCL3/CCL4 and anti-S100A8/9: targeting monocyte recruitment to lung (Zhao 2024 scRNA-seq rationale)" },
  { text:"GZMhi cytotoxic T cell blockade: novel in FHP; no clinical agents yet but clear target from AJRCCM 2024" },
  { text:"SPP1+ macrophage inhibition: shared IPF-HP target; galectin-3 inhibitors under investigation" },
  { type:"h", text:"SUPPORTIVE / ADJUNCT" },
  { text:"Inhaled N-acetylcysteine, antioxidant strategies in oxidative-stress driven HP" },
  { text:"Pulmonary hypertension in HP: mosliciguat (Phase 2 NCT06635850) — now recruiting" },
], { badge:"PIPELINE 2025–2026", foot:"Pulm Ther 2026 (Springer); Pulmonary Fibrosis Foundation Clinical Trials 2025–2026; PMID:40754799" });

// ── SLIDE 24: Section – Surveillance & Monitoring ────────────────────────────
secDiv("08", "Monitoring &\nSurveillance Strategy", "Tracking progression in the clinic");

// ── SLIDE 25: Monitoring Table ─────────────────────────────────────────────────
tableSlide(
  "Structured Monitoring Protocol for Fibrotic HP",
  [
    [
      { text:"Assessment", options:{bold:true,color:"FFFFFF",fill:{color:C.midnight},align:"center"} },
      { text:"Frequency", options:{bold:true,color:"FFFFFF",fill:{color:C.midnight},align:"center"} },
      { text:"Threshold for Action", options:{bold:true,color:"FFFFFF",fill:{color:C.midnight},align:"center"} },
      { text:"Evidence Level", options:{bold:true,color:"FFFFFF",fill:{color:C.midnight},align:"center"} },
    ],
    [{ text:"PFTs (FVC + DLCO)" },{ text:"Every 3–6 months" },{ text:"FVC decline ≥5–10% in 6–12 months → escalate therapy / add antifibrotic" },{ text:"Expert consensus; INBUILD trial" }],
    [{ text:"HRCT chest" },{ text:"At diagnosis; then annually or with clinical worsening" },{ text:"New/worsening fibrosis, new GGO (AE?), PA enlargement (PH?)" },{ text:"ATS 2020 Guideline" }],
    [{ text:"6MWT + SpO2" },{ text:"Every 3–6 months" },{ text:">50 m decline or new exertional desaturation → transplant workup" },{ text:"ILD-GAP index" }],
    [{ text:"Leukocyte Telomere Length" },{ text:"Once at diagnosis" },{ text:"LTL <10th percentile → avoid AZA/MMF (HR ~5x mortality)" },{ text:"Zhang et al. ERJ 2023" }],
    [{ text:"Autoimmune serology (ANA, anti-CCP, myositis, Scl70)" },{ text:"At Dx + annually if antigen-negative" },{ text:"New positivity → rheumatology referral; reconsider CTD-ILD vs HP" },{ text:"Ryerson AJRCCM 2025" }],
    [{ text:"Echocardiography" },{ text:"At Dx; repeat if SpO2 low or DLCO drop" },{ text:"PA systolic pressure >40 mmHg → PH evaluation; consider treprostinil" },{ text:"Murray & Nadel 7e" }],
    [{ text:"Antigen reassessment" },{ text:"Each clinic visit" },{ text:"Any new exposure? Ongoing low-level exposure? Occupational hygienist if needed" },{ text:"ATS 2020 Guideline" }],
  ],
  [2.5, 1.8, 3.2, 1.9],
  { foot:"Murray & Nadel 7e Ch.91; Zhang ERJ 2023 (PMID:37591536); Ryerson AJRCCM 2025 (PMID:40505139); ATS/JRS/ALAT 2020" }
);

// ── SLIDE 26: Prognostic Scoring ──────────────────────────────────────────────
cSlide("Prognostic Markers & Risk Stratification", [
  { type:"h", text:"ILD-GAP INDEX (Validated in fHP)" },
  { text:"Gender (Male=1) + Age (>65=1–2) + Physiology (FVC <70% + DLCO <40%) → total score 0–8" },
  { text:"Higher GAP score = higher 1-year mortality; guides transplant listing priority" },
  { type:"h", text:"HIGH-RISK FEATURES (Murray & Nadel, Table 91.1)" },
  { text:"Male sex + older age + bibasilar Velcro crackles" },
  { text:"FVC <70% predicted at baseline; DLCO <40% predicted" },
  { text:"Honeycombing, traction bronchiectasis, elevated PA:Ao ratio on HRCT" },
  { text:"Fibroblast foci on histology; fibrotic pattern on biopsy" },
  { text:"MUC5B risk allele + shorter telomere length (<10th percentile)" },
  { text:"No identified antigen; smoking; prior acute exacerbation; pulmonary hypertension" },
  { type:"h", text:"BIOMARKERS UNDER INVESTIGATION" },
  { text:"KL-6 serial trend: rising levels = disease activity; use for monitoring response" },
  { text:"SP-D: alveolar epithelial injury marker" },
  { type:"key", text:"GZMhi T cell and SPP1+ macrophage signatures may become prognostic endotype markers" },
], { foot:"Murray & Nadel 7e Table 91.1; Zhao et al. AJRCCM 2024; D'Alessandro et al. Panminerva 2022" });

// ── SLIDE 27: Lung Transplant ─────────────────────────────────────────────────
cSlide("Lung Transplant in HP: Indications & Outcomes", [
  { type:"h", text:"REFERRAL CRITERIA (per ATS / ISHLT)" },
  { text:"FVC <50% predicted OR DLCO <40% predicted at any time point" },
  { text:"Decline in FVC ≥10% (absolute) in 12 months" },
  { text:"Resting SpO2 <88% or significant exertional desaturation" },
  { text:"6MWT <250 m or >50 m decline in 12 months" },
  { text:"Pulmonary hypertension on echo or right heart catheterisation" },
  { text:"Refractory disease despite antigen avoidance + pharmacotherapy" },
  { type:"h", text:"OUTCOMES" },
  { text:"Bilateral lung transplant preferred over single-lung in younger patients" },
  { text:"Post-transplant survival in HP comparable to other non-IPF ILD" },
  { text:"Age-adjusted HP mortality rising: 0.1 → 0.7 per million (1988–2016); +5.6%/year (Murray & Nadel 7e)" },
  { type:"h", text:"TIMING MATTERS" },
  { type:"warn", text:"Refer EARLY — waitlist mortality in fibrotic HP is significant; do not wait for 'end-stage'" },
  { text:"Early referral ≠ immediate listing; allows time for transplant workup & optimisation" },
], { foot:"Murray & Nadel 7e Ch.91; ISHLT Guidelines; ATS 2020 HP Guidelines" });

// ── SLIDE 28: Surveillance in Special Situations ─────────────────────────────
cSlide("Special Situations in Senior Practice", [
  { type:"h", text:"WIND INSTRUMENT / MUSICAL INSTRUMENT HP" },
  { text:"Trombone player's lung, saxophone lung, bagpipe lung — increasingly recognised" },
  { text:"Fungi (Fusarium, Penicillium), MAC, Candida in contaminated instruments" },
  { text:"Ask about musical hobbies in ALL unexplained ILD" },
  { type:"h", text:"HP IN PATIENTS WITH AUTOIMMUNE FEATURES" },
  { text:"HP can coexist with CTD; autoimmune serology does NOT exclude HP" },
  { text:"Beware: antigen-negative fHP → 14% develop confirmed CTD (Ryerson 2025)" },
  { text:"MDD should include rheumatology for complex cases" },
  { type:"h", text:"HP IN THE IMMUNOCOMPROMISED HOST" },
  { text:"PCP, atypical infections can mimic HP on HRCT (GGO + diffuse infiltrates)" },
  { text:"BAL culture and metagenomic sequencing essential in immunocompromised" },
  { type:"h", text:"OCCUPATIONAL HP OUTBREAKS" },
  { text:"Report to occupational health authorities; systematic workplace assessment mandatory" },
  { text:"Engineering controls and surveillance spirometry for co-workers" },
], { foot:"Murray & Nadel 7e; Spagnolo et al. J Intern Med 2023 (PMID:37535448); ATS 2020 Guidelines" });

// ── SLIDE 29: Evidence Summary Table ─────────────────────────────────────────
tableSlide(
  "Key Evidence Summary: HP 2023–2026",
  [
    [
      { text:"Study / Guideline", options:{bold:true,color:"FFFFFF",fill:{color:C.midnight},align:"center"} },
      { text:"Year / Journal", options:{bold:true,color:"FFFFFF",fill:{color:C.midnight},align:"center"} },
      { text:"Key Finding", options:{bold:true,color:"FFFFFF",fill:{color:C.midnight},align:"center"} },
      { text:"PMID", options:{bold:true,color:"FFFFFF",fill:{color:C.midnight},align:"center"} },
    ],
    [{ text:"Zhao AY et al. scRNA-seq FHP" },{ text:"AJRCCM 2024" },{ text:"GZMhi cytotoxic T cells + SPP1+ macrophages unique to FHP; novel therapeutic targets" },{ text:"38924775" }],
    [{ text:"Ryerson CJ et al. fHP CT patterns" },{ text:"AJRCCM 2025" },{ text:"22% of 'typical fHP CT' = CTD-ILD; 14% antigen-neg fHP → CTD over follow-up" },{ text:"40505139" }],
    [{ text:"Zhang D et al. Telomere + immunosuppression" },{ text:"ERJ 2023" },{ text:"LTL <10th%ile + AZA/MMF: HR 4.97 mortality in fHP; avoid immunosuppression in short-telomere patients" },{ text:"37591536" }],
    [{ text:"Giri B et al. Pirfenidone meta-analysis" },{ text:"PMC 2025 (Open)" },{ text:"Pirfenidone improves QoL (SGRQ ↓5 pts) but not FVC/DLCO in fibrotic HP" },{ text:"41377281" }],
    [{ text:"Singh P et al. NMA PF-ILDs" },{ text:"Expert Rev Clin Immunol 2025" },{ text:"Pirfenidone + prednisolone benefit in CHP; nintedanib effective for PPF including HP" },{ text:"40754799" }],
    [{ text:"Koschel D et al. S2k Guideline" },{ text:"Respiration 2025" },{ text:"German national guideline: HP diagnosis, antifibrotic use, monitoring framework" },{ text:"39870058" }],
    [{ text:"Yanagawa M et al. ILD Imaging Advances" },{ text:"Radiology 2025" },{ text:"AI-based quantitative CT analysis for progressive ILD monitoring; emerging role in HP" },{ text:"40358445" }],
  ],
  [3.0, 1.7, 3.3, 1.4],
  { foot:"All PMIDs verified on PubMed. Open access papers: PMID 41377281 (PMC12689064), PMID 37591536 (PMC10695771)" }
);

// ── SLIDE 30: Closing ─────────────────────────────────────────────────────────
closingSlide();

// ── WRITE ──────────────────────────────────────────────────────────────────
const out = "/home/daytona/workspace/hp-presentation/HP_Senior_Pulmonologist_2026.pptx";
pres.writeFile({ fileName: out }).then(() => {
  console.log("SUCCESS:", out);
}).catch(e => { console.error("ERROR:", e.message); process.exit(1); });
!

Failed to create session: unauthorized: authentication failed: Bearer token is invalid

We encountered an error while processing your request. Please try again or reach out to us for help.

Instead of creating the ppt , show me the Data you found

Here is a comprehensive synthesis of all the research data gathered for the senior pulmonologist presentation on Hypersensitivity Pneumonitis:

Hypersensitivity Pneumonitis: Latest Research Evidence (2023–2026)


1. SINGLE-CELL TRANSCRIPTOMICS — NOVEL IMMUNOPATHOGENESIS

Zhao AY, Unterman A, Abu Hussein NS, et al.

"Single-Cell Analysis Reveals Novel Immune Perturbations in Fibrotic Hypersensitivity Pneumonitis" Am J Respir Crit Care Med. 2024 Nov 15; 210(9). PMID: 38924775 | DOI: 10.1164/rccm.202401-0078OC | PMC11568434 (Open Access)
Study Design:
  • 5' single-cell RNA sequencing (scRNA-seq) on PBMCs + BAL cells
  • 45 fibrotic HP (FHP), 63 IPF, 4 nonfibrotic HP, 36 healthy controls (US + Mexico)
  • 501,534 PBMCs and 88,336 BAL cells profiled
  • Methods: Seurat (differential gene expression), DoRothEA-VIPER (TF activity), Monocle3 + Velocyto-scVelo-CellRank (trajectory)
Key Findings — Unique to Fibrotic HP:
  • GZMhi cytotoxic CD4+ AND CD8+ T cells: significantly elevated in FHP vs both IPF and healthy controls — reflects a unique T cell-driven inflammatory signature
  • These cells show active TGFβ, TNFα, and NFκB pathway transcription factor activity
  • S100Ahi and CCL3hi/CCL4hi classical monocytes: significantly enriched in FHP
  • Trajectory analysis shows S100Ahi monocytes differentiate into SPP1hi lung macrophages — the same pro-fibrotic macrophage population seen in IPF
  • SPP1hi macrophage enrichment is a converging downstream fibrotic mechanism shared between FHP and IPF
Clinical Implication:
  • GZMhi cytotoxic T cells and SPP1+ macrophages are potential novel therapeutic targets specific to FHP
  • Data publicly available at: http://ildimmunecellatlas.com

2. DIAGNOSTIC PITFALL — CT OVERLAP WITH CTD-ILD

Ryerson CJ, Marinescu DC, Muller NL, Hague CJ, Murphy D, Churg A, et al.

"Outcomes of a Typical Fibrotic Hypersensitivity Pneumonitis Pattern on Chest Computed Tomography" Am J Respir Crit Care Med. 2025 Oct. PMID: 40505139 | DOI: 10.1164/rccm.202411-2215OC
Study Design:
  • Prospective registry study
  • 164 patients with CT patterns classified as "typical fHP" per ATS 2020 guidelines
  • Multidisciplinary diagnoses established by structured consensus MDD
The Diagnosis Distribution:
Multidisciplinary Diagnosisn%
fHP with probable/possible exposure identified4930%
fHP without any exposure identified5634%
CTD-ILD3622%
Other diagnoses2314%
Outcome Differences:
  • fHP without identified exposure: significantly worse lung function decline and higher rate of death/transplantation
  • 14% of antigen-negative fHP patients developed confirmed CTD features during follow-up (new autoimmune serology OR rheumatologist-confirmed CTD)
Practice-Changing Implication:
  • A "typical fHP pattern" on HRCT does NOT confirm HP - 36% of such patients had non-HP diagnoses
  • Always screen for CTD in antigen-negative fibrotic HP: ANA, anti-CCP, anti-Scl70, myositis panels
  • Consider rheumatology referral at diagnosis for all antigen-negative cases

3. TELOMERE LENGTH — RETHINKING IMMUNOSUPPRESSION

Zhang D, Adegunsoye A, Oldham JM, Kozlitina J, et al.

"Telomere length and immunosuppression in non-idiopathic pulmonary fibrosis interstitial lung disease" Eur Respir J. 2023 Nov. PMID: 37591536 | DOI: 10.1183/13993003.00441-2023 | PMC10695771 (Open Access)
Study Design:
  • Retrospective multicentre cohort; 5 centres
  • Discovery cohort: n=613 | Replication cohort: n=325
  • Populations: fibrotic HP, unclassifiable ILD, CTD-ILD
  • LTL measured by quantitative PCR; expressed as age-adjusted percentiles
  • Outcome: 2-year transplant-free survival
Key Findings — Practice-Changing:
GroupHR (Mortality)95% CIp-value
fHP + LTL <10th%ile + AZA or MMF (Discovery)4.972.26–10.92<0.001
fHP + LTL <10th%ile + AZA or MMF (Replication)4.901.74–13.770.003
Patients with LTL ≥10th percentileNo differential survivalNS
  • Significant interaction between telomere shortening and immunosuppressant exposure (p_interaction = 0.013 discovery; 0.011 replication)
  • ~22% of fibrotic ILD patients had LTL <10th percentile
Clinical Practice Implication:
  • Measure telomere length before starting AZA or MMF in fibrotic HP
  • Short telomeres (<10th percentile) → avoid immunosuppression → consider antifibrotics or expedited transplant listing
  • This interaction likely reflects accelerated telomere attrition from cytotoxic drug effects in already telomere-impaired cells

4. ANTIFIBROTIC THERAPY — PIRFENIDONE META-ANALYSIS

Giri B, et al.

"Efficacy of pirfenidone in fibrotic hypersensitivity pneumonitis: a systematic review and meta-analysis of randomized controlled trials" Open Access. PMC 2025. PMID: 41377281 | PMC12689064
Pooled Results:
OutcomeMean Difference95% CIp-valueSignificance
% predicted FVC+3.65−1.63 to +8.940.18Non-significant
% predicted DLCO+7.64−1.46 to +16.740.10Non-significant
SGRQ score (QoL)−5.0−6.88 to −3.12<0.00001Significant ✓
Interpretation:
  • Pirfenidone does not significantly improve objective lung function (FVC/DLCO) in fibrotic HP in the current limited RCT pool
  • Pirfenidone does significantly improve quality of life (SGRQ reduction of 5 points = clinically meaningful threshold)
  • Important caveat: very limited HP-specific RCT data; results are driven by a small trial pool
  • Pathophysiological overlap with IPF (TGFβ pathway, myofibroblast activation) supports continued investigation

5. NETWORK META-ANALYSIS — ANTIFIBROTICS IN PROGRESSIVE PF-ILDs

Singh P, Thampi G, Gupta K, Gangte N, Pattnaik B, Agrawal A, et al.

"Clinical efficacy and safety evaluation of drug therapies for PF-ILDs: a network meta-analysis of RCTs" Expert Rev Clin Immunol. 2025 Aug. PMID: 40754799 | DOI: 10.1080/1744666X.2025.2543473
Scale: 65 RCTs (13,521 patients across IPF, CTD-ILD, chronic HP, sarcoidosis)
  • HP-specific: 4 RCTs (259 patients) for 3 drugs in chronic HP (CHP)
HP-Specific Findings:
  • Pirfenidone + prednisolone: showed benefit in CHP from available RCT data
  • Nintedanib: established efficacy in IPF and PPF (INBUILD); HP patients included via PPF progression criterion
Broader PF-ILD Conclusions:
  • In IPF: pirfenidone, nintedanib, and IFN-γ-1b slowed lung function decline and reduced mortality
  • In CTD-ILD: pirfenidone, nintedanib, tocilizumab, and cyclophosphamide improved outcomes
  • Pirfenidone and nintedanib remain the most evidence-supported agents across PF-ILDs including progressive HP
  • Emerging therapies (IFN-γ-1b) warrant further research
Critical Caveat: Only 4 HP-specific RCTs exist - the evidence gap for HP-targeted antifibrotic trials remains large

6. HRCT IMAGING ADVANCES

Yanagawa M, Han J, Wada N, et al.

"Advances in Concept and Imaging of Interstitial Lung Disease" Radiology. 2025 May. PMID: 40358445
  • AI-based quantitative CT analysis for progressive ILD monitoring
  • Computer-aided detection of traction bronchiectasis, GGO extent, and fibrosis scoring
  • Emerging role in serial HP monitoring to quantify progression objectively
  • Potential to replace subjective radiologist scoring for clinical trial endpoints

Sellers T, Martin MD, Kanne JP, et al.

"Hypersensitivity Pneumonitis: Imaging Findings and Patterns" Semin Roentgenol. 2026 Jan. PMID: 41513513
  • Updated pictorial review of HP HRCT patterns in the context of 2020 guideline classifications
  • Distinguishing features between typical fHP pattern vs UIP (IPF) pattern reviewed with updated criteria

7. GERMAN NATIONAL PRACTICE GUIDELINE (S2k)

Koschel D, Behr J, Berger M, et al.

"Diagnosis and Treatment of Hypersensitivity Pneumonitis: S2k Guideline of the German Respiratory Society and the German Society for Allergology and Clinical Immunology" Respiration. 2025. PMID: 39870058
  • National-level evidence synthesis covering HP diagnosis, antifibrotic use, monitoring framework
  • Endorses antifibrotic therapy for progressive fibrotic HP
  • Aligns with ATS 2020 on antigen avoidance as cornerstone

8. BROADER ILD / EPIDEMIOLOGY CONTEXT

Spagnolo P, Guler SA, Chaudhuri N, et al.

"Global epidemiology and burden of interstitial lung disease" Lancet Respir Med. 2025 Aug. PMID: 40684782
  • HP is among the most common ILDs globally at tertiary centres
  • Rising age-adjusted HP mortality: 0.1 → 0.7 per million (1988–2016); +5.6%/year average increase
  • Fibrotic HP: 56–68% of all HP cases; prevalence 0.9–1.7 per 100,000/year

9. EMERGING PIPELINE (2025–2026)

From the Pulmonary Fibrosis Foundation and Pulm Ther 2026 (Springer):
Drug / InterventionMechanismStatusNotes
Nerandomilast (BI 1015550)PDE4B inhibitorPhase III (IPF + PPF)HP with progressive phenotype eligible
MTX-463Anti-WISP1 mAbPhase 2 (PPF)Concomitant antifibrotics permitted
Inhaled treprostinil (TETON-2)Prostacyclin analoguePhase 3 — COMPLETED+95.6 mL FVC vs placebo (p<0.0001); TETON-1 ongoing
MosliciguatsGC stimulatorPhase 2 (PH-ILD)NCT06635850 — now recruiting
INS018_055 (Insilico Medicine)AI-designed drug (IPF target)Phase 2First AI-designed molecule in ILD trials
Anti-SPP1+ macrophage strategiesSPP1 pathway inhibitionPre-clinicalRationale from Zhao AJRCCM 2024
GZMhi T cell targetingCytotoxic T cell blockadeConceptual / pre-clinicalUnique FHP target — no clinical agent yet

10. KEY TEXTBOOK EVIDENCE (Murray & Nadel 7e, Chapter 91)

Prognostic Table 91.1 — Baseline Adverse Prognostic Indicators:
DomainAdverse Factor
DemographicsMale sex, older age
Physical examAuscultatory crackles
Pulmonary physiologyLow FVC%, low DLCO%
HRCTHoneycombing, traction bronchiectasis, inspiratory mosaic + expiratory air trapping, increased PA:Ao ratio
PathologyIncreased fibrosis, fibroblast foci
GenomicsMUC5B rs35705950 SNP, telomere length <10th percentile for age
CompositeAbnormal ILD-GAP index
OtherNo known antigen, smoking, acute exacerbation, pulmonary hypertension
Classic HP Diagnostic Triad (Histology):
  1. Peribronchiolar mononuclear cell infiltrate (lymphocytes predominate)
  2. Poorly-formed noncaseating granulomas (present in 2/3 of cases; peribronchiolar)
  3. Cellular bronchiolitis

SUMMARY: What Has Changed for Senior Pulmonologists

DomainOld ParadigmNew Evidence (2023–2026)
PathogenesisType III + IV hypersensitivity; granulomatous inflammation+ GZMhi cytotoxic T cells; SPP1+ fibrotic macrophages (AJRCCM 2024)
DiagnosisTypical fHP CT = confident HP36% of typical fHP CT = non-HP; 22% = CTD-ILD (AJRCCM 2025)
ImmunosuppressionAZA/MMF standard for fibrotic HPCheck telomere length first — short LTL + AZA/MMF = 5x mortality (ERJ 2023)
AntifibroticsNintedanib only (via PPF label)Pirfenidone improves QoL; NMA supports both in progressive HP (2025)
BiomarkersSerum precipitins + BAL lymphocytosisKL-6, SP-D, GZMhi T cell signatures, telomere length emerging
CT MonitoringVisual radiologist scoringAI quantitative CT analysis for objective fibrosis progression tracking
PipelineLimited HP-specific trialsTreprostinil (TETON met endpoint), nerandomilast, MTX-463, mosliciguat (PH-HP)

Create a comparison infographic: traditional HP classification (acute/chronic) vs. new fibrotic/nonfibrotic endotype model

Generating Image

Medical infographic comparing two classification systems for Hypersensitivity Pneumonitis (HP / Extrinsic Allergic Alveolitis). Split into two clear vertical panels side by side with a bold dividing line in the center. LEFT PANEL — titled "TRADITIONAL CLASSIFICATION (Pre-2020)" with a muted blue-grey background: Three rows stacked vertically representing the old time-based system: 1. "ACUTE HP" box (light blue): "Onset within hours of exposure • Fever, chills, dyspnea • Resolves with avoidance • Time-based: <3 months" 2. "SUBACUTE HP" box (medium blue): "Gradual onset • Weeks to months • Overlaps with acute and chronic • Often misclassified • Poor prognostic precision" 3. "CHRONIC HP" box (dark blue): "Insidious onset • >6 months • Progressive fibrosis possible • Hard to distinguish from other ILDs" Below: a red "LIMITATION" banner: "Time-based only — does not predict prognosis or guide treatment" RIGHT PANEL — titled "NEW ENDOTYPE MODEL (ATS 2020+)" with a rich teal-navy gradient background: Two rows representing the biology-based classification: 1. "NONFIBROTIC HP" box (teal/green): "Inflammatory phenotype • Reversible with antigen removal • HRCT: GGO + centrilobular nodules + air trapping • BAL: lymphocytosis >50% • Histology: granulomas + bronchiolitis • Prognosis: GOOD if antigen identified" 2. "FIBROTIC HP" box (deep indigo): "Mixed inflammatory + fibrotic • May progress even after antigen removal • HRCT: traction bronchiectasis + honeycombing • BAL: reduced lymphocytosis • Histology: UIP or NSIP-like pattern • Prognosis: POOR — approaches IPF mortality • Treatment: consider antifibrotics + telomere testing" Below: a green "ADVANTAGE" banner: "Biology-based — guides prognosis, treatment decisions, and antifibrotic use" CENTER DIVIDER — a vertical arrow pointing right labeled "PARADIGM SHIFT" in bold amber/gold text TOP of infographic — full-width dark navy header: "Hypersensitivity Pneumonitis: Classification Paradigm Shift" with subtitle "Time-Based Model vs. Biology-Based Endotype Model (ATS/JRS/ALAT 2020)" BOTTOM of infographic — full-width footer in small text: "Sources: ATS/JRS/ALAT 2020 HP Guidelines • Murray & Nadel's Respiratory Medicine 7e • Am J Respir Crit Care Med 2025" Design style: Clean medical/scientific infographic, high contrast, professional color palette of navy, teal, indigo, amber, and white. Bold section headings, clear icons or small visual indicators for each feature (lung icon, clock icon, DNA/biology icon). Suitable for senior pulmonologist conference presentation.

HP Classification Paradigm Shift Infographic

Here's a breakdown of what the infographic covers:
Left Panel — Traditional Model (Pre-2020) The old time-based system divided HP into three tiers — Acute (<3 months), Subacute, and Chronic (>6 months). The fundamental problem: the "subacute" category was notoriously hard to define, overlapping with both ends. More critically, the time elapsed since onset gives no information about whether fibrosis is present, what the prognosis is, or what treatment to use.
Right Panel — New Endotype Model (ATS 2020+) The current framework is biology-based — driven by two questions:
  1. Is fibrosis present on HRCT or histology?
  2. Has an antigen been identified?
This directly maps to clinical decisions:
  • Nonfibrotic HP → focus on antigen removal; steroids if needed; good prognosis if antigen found
  • Fibrotic HP → check telomere length before immunosuppression; consider nintedanib/pirfenidone if progressive; transplant evaluation if advanced
The Paradigm Shift (center arrow) The shift was driven by a landmark cluster analysis of a large prospective multicenter cohort (cited in Murray & Nadel 7e) showing that most HP cases fit a two-cluster model, not three — and that the subacute category provided no independent prognostic precision. The ATS/JRS/ALAT 2020 guidelines formally adopted this framework.
This is a shared conversation. Sign in to Orris to start your own chat.