Make me a ppt on pulmonary TB

Asking for Preferences
Reading File
Reading File
Reading File
Finding Sources
Finding Sources
Reading File
Reading File
Finding Sources
Searching Images

pulmonary tuberculosis chest X-ray cavitary lesion

Reading File
Reading File
Searching Images

tuberculosis granuloma pathology Ghon complex histology

Finding Sources
Running Command

mkdir -p /home/daytona/workspace/pulmonary-tb-ppt && ls /home/daytona/workspace/pulmonary-tb-ppt/

Writing File

~/pulmonary-tb-ppt/create_pptx.js

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

const pres = new pptxgen();
pres.layout = "LAYOUT_16x9";
pres.title = "Pulmonary Tuberculosis";
pres.author = "Orris Medical";

// ─── COLOUR PALETTE ───────────────────────────────────────────────
// Deep navy dominates; warm amber accent; off-white text; muted teal highlight
const C = {
  navy:    "0D1B2A",   // dominant dark bg
  navyMid: "1A2E45",   // card/panel bg
  teal:    "1B6CA8",   // section headings / accent bars
  amber:   "E8A020",   // hot accent / callout
  white:   "F4F7FB",   // body text
  light:   "C8D8E8",   // subtext / caption
  dark:    "071220",   // extra dark for gradient
  red:     "C0392B",   // danger / warning
  green:   "1E8449",   // good / treatment success
};

// ─── HELPER: slide master bg ──────────────────────────────────────
function addBg(slide) {
  slide.addShape(pres.ShapeType.rect, {
    x: 0, y: 0, w: 10, h: 5.625,
    fill: { type: "solid", color: C.navy }
  });
}

function accentBar(slide, color = C.amber, x = 0.5, y = 1.0, w = 9, h = 0.06) {
  slide.addShape(pres.ShapeType.rect, { x, y, w, h, fill: { type: "solid", color }, line: { width: 0 } });
}

function sectionPill(slide, label, x = 0.5, y = 0.25) {
  slide.addShape(pres.ShapeType.roundRect, {
    x, y, w: 1.9, h: 0.32,
    fill: { type: "solid", color: C.teal },
    line: { width: 0 },
    rectRadius: 0.15
  });
  slide.addText(label, { x, y, w: 1.9, h: 0.32, fontSize: 9, bold: true, color: C.white, align: "center", valign: "middle" });
}

function slideTitle(slide, txt, y = 0.62) {
  slide.addText(txt, { x: 0.5, y, w: 9, h: 0.7, fontSize: 28, bold: true, color: C.white, fontFace: "Calibri" });
}

function bulletBox(slide, items, x, y, w, h, fontSize = 13) {
  const rich = items.map((item, i) => {
    const isLast = i === items.length - 1;
    if (typeof item === "string") {
      return { text: item, options: { bullet: { code: "2022" }, color: C.white, fontSize, fontFace: "Calibri", breakLine: !isLast, paraSpaceAfter: 4 } };
    }
    // Object with bold header
    return [
      { text: item.h + "  ", options: { bold: true, color: C.amber, fontSize, fontFace: "Calibri", bullet: { code: "25B6" }, paraSpaceAfter: 4, breakLine: false } },
      { text: item.b, options: { color: C.white, fontSize, fontFace: "Calibri", breakLine: !isLast, paraSpaceAfter: 4 } }
    ];
  }).flat();
  slide.addText(rich, { x, y, w, h, valign: "top" });
}

function card(slide, x, y, w, h, color = C.navyMid) {
  slide.addShape(pres.ShapeType.roundRect, {
    x, y, w, h,
    fill: { type: "solid", color },
    line: { color: C.teal, width: 1 },
    rectRadius: 0.12
  });
}

// ─── Fetch images ─────────────────────────────────────────────────
const imgUrls = [
  // CXR cavitary TB
  "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_5731433f093f995f2ec4949020c20f50064272fe1fbc40c755858e26d135d651.jpg",
  // Spectrum diagram
  "https://cdn.orris.care/cdss_images/046cd4462d9d9fa681a176d411a6d4251ce62042f233094b748c513fedef7dc3.png",
  // Caseous granuloma histology
  "https://cdn.orris.care/cdss_images/Pathology_1760055323313_fdbd6813-f234-40a2-8bf7-895e3a1e34b4.jpg",
  // CXR + CT composite (reactivation)
  "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_4dbe84955206a8e0df67d401cbef5b4bbd372e65fda0fcc4b650ce9366c2df1c.jpg",
];

let imgs = [];
try {
  const raw = execSync(
    `node /home/daytona/skills/shared/scripts/fetch_images.js ${imgUrls.map(u => `"${u}"`).join(" ")}`,
    { maxBuffer: 50 * 1024 * 1024 }
  ).toString();
  imgs = JSON.parse(raw);
} catch (e) {
  console.error("Image fetch error:", e.message);
}

function getImg(idx) {
  return imgs[idx] && !imgs[idx].error ? imgs[idx].base64 : null;
}

// ══════════════════════════════════════════════════════════════════
// SLIDE 1 — TITLE
// ══════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  // Dark gradient bg
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { type: "solid", color: C.dark } });
  // Navy overlay strip
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { type: "solid", color: C.navy }, transparency: 10 });
  // Amber vertical accent bar (left)
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.18, h: 5.625, fill: { type: "solid", color: C.amber }, line: { width: 0 } });
  // Teal vertical bar
  s.addShape(pres.ShapeType.rect, { x: 0.18, y: 0, w: 0.08, h: 5.625, fill: { type: "solid", color: C.teal }, line: { width: 0 } });

  s.addText("PULMONARY", { x: 0.6, y: 1.2, w: 8.8, h: 0.9, fontSize: 56, bold: true, color: C.amber, fontFace: "Calibri", charSpacing: 6 });
  s.addText("TUBERCULOSIS", { x: 0.6, y: 2.0, w: 8.8, h: 0.9, fontSize: 56, bold: true, color: C.white, fontFace: "Calibri", charSpacing: 6 });
  s.addShape(pres.ShapeType.rect, { x: 0.6, y: 3.0, w: 5, h: 0.06, fill: { type: "solid", color: C.teal }, line: { width: 0 } });
  s.addText("A Comprehensive Overview for Medical Students", {
    x: 0.6, y: 3.15, w: 8.5, h: 0.45, fontSize: 16, color: C.light, italic: true, fontFace: "Calibri"
  });
  s.addText("Based on Harrison's Principles of Internal Medicine & Fishman's Pulmonary Diseases", {
    x: 0.6, y: 4.8, w: 8.5, h: 0.35, fontSize: 10, color: C.light, italic: true, fontFace: "Calibri"
  });
  // Bacterium icon circles (decorative)
  for (let i = 0; i < 5; i++) {
    s.addShape(pres.ShapeType.ellipse, {
      x: 7.5 + i * 0.35, y: 1.0 + i * 0.4, w: 0.22, h: 0.22,
      fill: { type: "solid", color: C.teal }, transparency: 50, line: { width: 0 }
    });
  }
}

// ══════════════════════════════════════════════════════════════════
// SLIDE 2 — TABLE OF CONTENTS
// ══════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBg(s);
  accentBar(s, C.amber);
  slideTitle(s, "Lecture Outline");

  const topics = [
    ["01", "Epidemiology & Global Burden"],
    ["02", "Aetiology & Microbiology"],
    ["03", "Pathogenesis & Immunology"],
    ["04", "Classification (Latent vs Active)"],
    ["05", "Clinical Features"],
    ["06", "Diagnosis (Smear, Culture, NAAT, TST, IGRA, CXR)"],
    ["07", "Radiology"],
    ["08", "Treatment — Drug-Susceptible TB"],
    ["09", "Drug-Resistant TB (MDR & XDR)"],
    ["10", "Special Situations (HIV, Miliary, Extrapulmonary)"],
    ["11", "Prevention & Public Health"],
    ["12", "Summary & Key Points"],
  ];

  const col1 = topics.slice(0, 6);
  const col2 = topics.slice(6);

  [col1, col2].forEach((col, ci) => {
    const xBase = ci === 0 ? 0.5 : 5.3;
    col.forEach(([num, label], ri) => {
      const y = 1.25 + ri * 0.62;
      // number circle
      s.addShape(pres.ShapeType.ellipse, {
        x: xBase, y: y - 0.02, w: 0.36, h: 0.36,
        fill: { type: "solid", color: C.teal }, line: { width: 0 }
      });
      s.addText(num, { x: xBase, y: y - 0.02, w: 0.36, h: 0.36, fontSize: 9, bold: true, color: C.white, align: "center", valign: "middle" });
      s.addText(label, { x: xBase + 0.45, y: y, w: 4.3, h: 0.32, fontSize: 12.5, color: C.white, fontFace: "Calibri", valign: "middle" });
    });
  });
}

// ══════════════════════════════════════════════════════════════════
// SLIDE 3 — EPIDEMIOLOGY
// ══════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBg(s);
  sectionPill(s, "EPIDEMIOLOGY");
  accentBar(s, C.amber, 0.5, 0.7);
  slideTitle(s, "Global Burden of TB", 0.8);

  // Stat cards
  const stats = [
    { n: "~10.8M", label: "New TB cases\nglobally (2023)" },
    { n: "1.25M", label: "Deaths attributed\nto TB (2023)" },
    { n: "¼ World", label: "Population estimated\nlatently infected" },
    { n: "#1", label: "Leading infectious\ndisease killer" },
  ];
  stats.forEach((st, i) => {
    const x = 0.3 + i * 2.4;
    card(s, x, 1.55, 2.15, 1.5);
    s.addText(st.n, { x, y: 1.65, w: 2.15, h: 0.6, fontSize: 26, bold: true, color: C.amber, fontFace: "Calibri", align: "center" });
    s.addText(st.label, { x, y: 2.2, w: 2.15, h: 0.7, fontSize: 10, color: C.light, align: "center", fontFace: "Calibri" });
  });

  accentBar(s, C.teal, 0.5, 3.3, 9, 0.04);
  bulletBox(s, [
    { h: "High-burden regions:", b: "South-East Asia (45%), Africa (24%), Western Pacific (18%) — account for most new cases" },
    { h: "Risk factors:", b: "HIV co-infection, malnutrition, overcrowding, diabetes, immunosuppressants, smoking, ESRD, silicosis" },
    { h: "India, China, Indonesia, Philippines & Pakistan:", b: "contribute >50% of global new TB cases" },
    { h: "Drug-resistant TB:", b: "~400,000 new MDR/RR-TB cases annually — a major global threat" },
  ], 0.5, 3.4, 9, 2.0, 12);
}

// ══════════════════════════════════════════════════════════════════
// SLIDE 4 — AETIOLOGY & MICROBIOLOGY
// ══════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBg(s);
  sectionPill(s, "MICROBIOLOGY");
  accentBar(s, C.amber, 0.5, 0.7);
  slideTitle(s, "Aetiology & Microbiology", 0.8);

  card(s, 0.4, 1.4, 4.3, 3.8);
  s.addText("The Organism", { x: 0.5, y: 1.5, w: 4.1, h: 0.4, fontSize: 15, bold: true, color: C.amber, fontFace: "Calibri" });
  bulletBox(s, [
    { h: "Species:", b: "Mycobacterium tuberculosis (MTB)" },
    { h: "Family:", b: "Mycobacteriaceae; Actinobacteria" },
    { h: "Morphology:", b: "Slender, curved rod; 2–4 µm long" },
    { h: "Cell wall:", b: "High lipid content (mycolic acids) → waxy envelope" },
    { h: "Staining:", b: "Acid-fast bacillus (AFB); Ziehl-Neelsen stain — bright red rods on blue bg" },
    { h: "Growth:", b: "Slow-growing; doubling time ~20 h; strictly aerobic" },
    { h: "Culture:", b: "Lowenstein-Jensen medium; growth in 3–8 weeks" },
    { h: "Transmission:", b: "Airborne droplet nuclei (1–5 µm); expelled by cough, sneeze, speech" },
  ], 0.5, 1.95, 4.1, 3.1, 11.5);

  card(s, 4.9, 1.4, 4.7, 3.8);
  s.addText("Key Properties", { x: 5.0, y: 1.5, w: 4.5, h: 0.4, fontSize: 15, bold: true, color: C.amber, fontFace: "Calibri" });
  bulletBox(s, [
    { h: "Virulence factors:", b: "Cord factor (trehalose dimycolate) — inhibits phagocyte activation; lipoarabinomannan (LAM) — dampens macrophage responses" },
    { h: "Survives inside macrophages:", b: "blocks phagolysosome fusion via LAM" },
    { h: "Reservoir:", b: "Exclusively humans (no animal reservoir for M. tuberculosis)" },
    { h: "Infectivity:", b: "Inhalation of as few as 1–10 bacilli can establish infection" },
    { h: "Stability:", b: "Sensitive to UV light and heat; can survive in dark, cool, damp environments for hours" },
    { h: "MTB complex:", b: "Includes M. bovis (BCG vaccine strain), M. africanum, M. canetti" },
  ], 5.0, 1.95, 4.5, 3.1, 11.5);
}

// ══════════════════════════════════════════════════════════════════
// SLIDE 5 — PATHOGENESIS (with diagram image)
// ══════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBg(s);
  sectionPill(s, "PATHOGENESIS");
  accentBar(s, C.amber, 0.5, 0.7);
  slideTitle(s, "Pathogenesis", 0.8);

  const diagramImg = getImg(1); // spectrum/progression diagram
  if (diagramImg) {
    s.addImage({ data: diagramImg, x: 5.5, y: 1.3, w: 4.1, h: 3.9 });
    s.addShape(pres.ShapeType.rect, { x: 5.5, y: 5.2, w: 4.1, h: 0.25, fill: { type: "solid", color: C.navyMid }, line: { width: 0 } });
    s.addText("TB infection spectrum (Harrison's, Fig. 299-3)", { x: 5.5, y: 5.2, w: 4.1, h: 0.25, fontSize: 8, italic: true, color: C.light, align: "center" });
  }

  const steps = [
    ["1. Inhalation", "Droplet nuclei reach alveoli; alveolar macrophages phagocytose bacilli"],
    ["2. Intracellular survival", "MTB blocks phagosome-lysosome fusion via LAM; multiplies inside macrophage"],
    ["3. Granuloma formation", "Infected macrophages recruit T cells, monocytes → epithelioid granuloma with Langhans giant cells; central caseous necrosis"],
    ["4. Ghon focus", "Primary subpleural lesion + hilar lymphadenopathy = Ghon complex"],
    ["5. Latency vs progression", "In 90–95%: cell-mediated immunity contains infection (latent TB). In 5–10%: progressive primary or reactivation disease occurs"],
    ["6. Reactivation", "Immunosuppression → breakdown of granuloma → bacilli spill into airways → cavitary disease"],
  ];

  steps.forEach(([h, b], i) => {
    const y = 1.3 + i * 0.68;
    s.addShape(pres.ShapeType.rect, { x: 0.4, y: y, w: 0.06, h: 0.45, fill: { type: "solid", color: C.amber }, line: { width: 0 } });
    s.addText(h, { x: 0.55, y: y, w: 4.7, h: 0.22, fontSize: 11.5, bold: true, color: C.amber, fontFace: "Calibri" });
    s.addText(b, { x: 0.55, y: y + 0.2, w: 4.7, h: 0.44, fontSize: 10.5, color: C.white, fontFace: "Calibri", wrap: true });
  });
}

// ══════════════════════════════════════════════════════════════════
// SLIDE 6 — HISTOPATHOLOGY (granuloma image)
// ══════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBg(s);
  sectionPill(s, "HISTOPATHOLOGY");
  accentBar(s, C.amber, 0.5, 0.7);
  slideTitle(s, "Granuloma — The Hallmark Lesion", 0.8);

  const histoImg = getImg(2); // caseous granuloma histology
  if (histoImg) {
    s.addImage({ data: histoImg, x: 5.4, y: 1.3, w: 4.2, h: 3.8 });
    s.addText("Caseating granuloma with Langhans giant cells (H&E)", {
      x: 5.4, y: 5.1, w: 4.2, h: 0.3, fontSize: 8, italic: true, color: C.light, align: "center"
    });
  }

  s.addText("Components of the Granuloma", { x: 0.5, y: 1.35, w: 4.6, h: 0.4, fontSize: 15, bold: true, color: C.amber, fontFace: "Calibri" });
  bulletBox(s, [
    { h: "Core:", b: "Caseous (cheese-like) necrosis — acellular zone containing dead bacilli & lipid material" },
    { h: "Middle zone:", b: "Epithelioid macrophages (activated, elongated nucleus)" },
    { h: "Langhans giant cells:", b: "Fused macrophages; horseshoe-shaped nuclei at periphery" },
    { h: "Outer rim:", b: "CD4+ T lymphocytes providing IFN-γ to sustain macrophage activation" },
    { h: "Fibrosis:", b: "Collagen deposition — may calcify (Ranke complex if healed)" },
  ], 0.5, 1.8, 4.7, 2.5, 12);

  s.addText("Clinical Significance", { x: 0.5, y: 4.35, w: 4.6, h: 0.35, fontSize: 13, bold: true, color: C.teal, fontFace: "Calibri" });
  bulletBox(s, [
    "Caseous necrosis liquefies → cavitation in post-primary TB",
    "Liquefied material drains into airways → highly infectious sputum",
    "Haematogenous spread from primary focus → miliary TB",
  ], 0.5, 4.7, 4.7, 0.85, 11);
}

// ══════════════════════════════════════════════════════════════════
// SLIDE 7 — LATENT vs ACTIVE TB
// ══════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBg(s);
  sectionPill(s, "CLASSIFICATION");
  accentBar(s, C.amber, 0.5, 0.7);
  slideTitle(s, "Latent TB Infection vs Active TB Disease", 0.8);

  // Two columns
  const lx = 0.3, rx = 5.2, cw = 4.5;
  // Latent card
  card(s, lx, 1.45, cw, 3.9, "1A3A5C");
  s.addShape(pres.ShapeType.rect, { x: lx, y: 1.45, w: cw, h: 0.45, fill: { type: "solid", color: C.teal }, line: { width: 0 }, rectRadius: 0.08 });
  s.addText("LATENT TB INFECTION (LTBI)", { x: lx, y: 1.45, w: cw, h: 0.45, fontSize: 13, bold: true, color: C.white, align: "center", valign: "middle" });
  bulletBox(s, [
    "Bacteria present but contained by immune system",
    "No symptoms; non-infectious",
    "TST / IGRA: Positive; Sputum smear: Negative",
    "CXR: Normal (or calcified Ghon focus)",
    "Affects ~1.7 billion people worldwide",
    "5–10% lifetime risk of reactivation to active disease",
    "Risk ↑ with HIV, immunosuppression, malnutrition",
    "Treatment: 3HP (INH + rifapentine ×12 doses) or 6H (INH 6 months)",
  ], lx + 0.15, 2.0, cw - 0.3, 3.2, 11.5);

  // Active card
  card(s, rx, 1.45, cw, 3.9, "3D1515");
  s.addShape(pres.ShapeType.rect, { x: rx, y: 1.45, w: cw, h: 0.45, fill: { type: "solid", color: C.red }, line: { width: 0 }, rectRadius: 0.08 });
  s.addText("ACTIVE TB DISEASE", { x: rx, y: 1.45, w: cw, h: 0.45, fontSize: 13, bold: true, color: C.white, align: "center", valign: "middle" });
  bulletBox(s, [
    "Bacteria actively multiplying; usually symptomatic",
    "Infectious (esp. if pulmonary and smear-positive)",
    "TST / IGRA: Positive; Sputum smear: Often positive",
    "CXR: Infiltrates, cavities, lymphadenopathy",
    "Systemic symptoms: fever, night sweats, weight loss",
    "Cough (productive) ≥ 2–3 weeks is hallmark",
    "Progressive primary OR reactivation of LTBI",
    "Requires mandatory notification + multidrug therapy",
  ], rx + 0.15, 2.0, cw - 0.3, 3.2, 11.5);

  s.addText("⚑  Critical distinction: LTBI ≠ Active TB — therapy differs entirely!", {
    x: 0.4, y: 5.35, w: 9.2, h: 0.25, fontSize: 10.5, bold: true, color: C.amber, align: "center", fontFace: "Calibri"
  });
}

// ══════════════════════════════════════════════════════════════════
// SLIDE 8 — CLINICAL FEATURES
// ══════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBg(s);
  sectionPill(s, "CLINICAL FEATURES");
  accentBar(s, C.amber, 0.5, 0.7);
  slideTitle(s, "Clinical Features of Pulmonary TB", 0.8);

  // Symptoms column
  card(s, 0.3, 1.4, 3.1, 3.9);
  s.addShape(pres.ShapeType.rect, { x: 0.3, y: 1.4, w: 3.1, h: 0.42, fill: { type: "solid", color: "8B2252" }, line: { width: 0 } });
  s.addText("SYMPTOMS", { x: 0.3, y: 1.4, w: 3.1, h: 0.42, fontSize: 13, bold: true, color: C.white, align: "center", valign: "middle" });
  bulletBox(s, [
    "Persistent cough > 2–3 weeks (most common)",
    "Productive / mucoid / purulent sputum",
    "Haemoptysis (advanced disease)",
    "Fever (typically low-grade, afternoon)",
    "Drenching night sweats",
    "Progressive weight loss & anorexia",
    "Fatigue & malaise",
    "Dyspnoea (late / extensive disease)",
    "25% of culture-confirmed cases have no cough!",
  ], 0.4, 1.9, 2.9, 3.3, 11);

  // Signs column
  card(s, 3.6, 1.4, 2.85, 3.9);
  s.addShape(pres.ShapeType.rect, { x: 3.6, y: 1.4, w: 2.85, h: 0.42, fill: { type: "solid", color: C.teal }, line: { width: 0 } });
  s.addText("SIGNS", { x: 3.6, y: 1.4, w: 2.85, h: 0.42, fontSize: 13, bold: true, color: C.white, align: "center", valign: "middle" });
  bulletBox(s, [
    "Often minimal on exam",
    "Post-tussive rales (upper zones)",
    "Amphoric breath sounds (cavity)",
    "Dullness to percussion (effusion)",
    "Cervical lymphadenopathy (uncommon in adults)",
    "Hepatosplenomegaly (miliary)",
    "Choroidal tubercles on fundoscopy",
    "Wasting / temporal wasting",
  ], 3.7, 1.9, 2.65, 3.3, 11);

  // Special populations
  card(s, 6.65, 1.4, 3.0, 3.9);
  s.addShape(pres.ShapeType.rect, { x: 6.65, y: 1.4, w: 3.0, h: 0.42, fill: { type: "solid", color: "5D4037" }, line: { width: 0 } });
  s.addText("SPECIAL GROUPS", { x: 6.65, y: 1.4, w: 3.0, h: 0.42, fontSize: 13, bold: true, color: C.white, align: "center", valign: "middle" });
  bulletBox(s, [
    "HIV+ patients: atypical presentation; fewer cavities; lower smear positivity; possible normal CXR",
    "Elderly: less fever, more insidious; often misdiagnosed as malignancy",
    "Children: often primary progressive; intrathoracic adenopathy predominates",
    "Diabetes: more severe, faster progression; impaired granuloma formation",
  ], 6.75, 1.9, 2.8, 3.3, 11);

  s.addText("Remember: TB is the 'Great Imitator' — keep a high index of suspicion", {
    x: 0.4, y: 5.35, w: 9.2, h: 0.25, fontSize: 10, bold: true, italic: true, color: C.amber, align: "center"
  });
}

// ══════════════════════════════════════════════════════════════════
// SLIDE 9 — RADIOLOGY (with CXR image)
// ══════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBg(s);
  sectionPill(s, "RADIOLOGY");
  accentBar(s, C.amber, 0.5, 0.7);
  slideTitle(s, "Radiological Findings in TB", 0.8);

  const cxrImg = getImg(0); // CXR cavitary
  if (cxrImg) {
    s.addImage({ data: cxrImg, x: 5.6, y: 1.3, w: 4.0, h: 3.8 });
    // Annotation arrow to cavity (decorative)
    s.addShape(pres.ShapeType.rect, { x: 5.6, y: 5.1, w: 4.0, h: 0.3, fill: { type: "solid", color: C.navyMid }, line: { width: 0 } });
    s.addText("PA CXR: Bilateral infiltrates with left upper lobe cavity — active TB", {
      x: 5.6, y: 5.12, w: 4.0, h: 0.28, fontSize: 8, italic: true, color: C.light, align: "center"
    });
  }

  s.addText("Primary TB", { x: 0.5, y: 1.4, w: 4.8, h: 0.35, fontSize: 14, bold: true, color: C.teal, fontFace: "Calibri" });
  bulletBox(s, [
    "Lower/middle lobe consolidation (any lobe in children)",
    "Hilar & paratracheal lymphadenopathy",
    "Pleural effusion (unilateral, exudative)",
    "Calcified Ghon focus + calcified hilar node = Ranke complex",
  ], 0.5, 1.75, 4.9, 1.3, 11.5);

  s.addText("Post-Primary (Reactivation) TB", { x: 0.5, y: 3.15, w: 4.8, h: 0.35, fontSize: 14, bold: true, color: C.amber, fontFace: "Calibri" });
  bulletBox(s, [
    "Apical & posterior upper lobe (Simon foci) — hallmark site",
    "Fibrocavitary disease — thick-walled cavities",
    "Tree-in-bud pattern (CT) — endobronchial spread",
    "Consolidation, nodules, scarring, volume loss",
    "Miliary TB: 1–2 mm diffuse bilateral nodules (millet seeds)",
  ], 0.5, 3.5, 4.9, 1.55, 11.5);

  s.addText("CT Chest adds sensitivity when CXR normal (e.g., HIV+)", {
    x: 0.5, y: 5.2, w: 4.8, h: 0.25, fontSize: 10, bold: true, color: C.light, italic: true
  });
}

// ══════════════════════════════════════════════════════════════════
// SLIDE 10 — DIAGNOSIS OVERVIEW
// ══════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBg(s);
  sectionPill(s, "DIAGNOSIS");
  accentBar(s, C.amber, 0.5, 0.7);
  slideTitle(s, "Diagnosis of Pulmonary TB", 0.8);

  const tests = [
    { title: "Sputum AFB Smear", color: "1A4A6B", items: ["3 specimens (8 h apart)", "Ziehl-Neelsen / auramine-rhodamine stain", "Sensitivity 50–80%; Specificity ~98%", "Quick (hours); cheap", "Cannot speciate / drug-sensitivity test"] },
    { title: "Culture (Gold Standard)", color: "1A5C38", items: ["Lowenstein-Jensen (solid) or MGIT (liquid)", "Sensitivity >95%", "MGIT results: 1–3 weeks; LJ: 3–8 weeks", "Enables DST (drug susceptibility testing)", "Required for definitive diagnosis"] },
    { title: "Xpert MTB/RIF (NAAT)", color: "5C3A1A", items: ["Simultaneous MTB detection + rifampicin resistance", "Results in ~2 hours", "Sensitivity 88% (smear-positive), 67% (smear-negative)", "WHO recommended as initial test", "Detects RIF resistance → proxy for MDR-TB"] },
    { title: "TST (Mantoux)", color: "3A1A5C", items: ["5 TU PPD; read at 48–72 h", "≥10 mm induration = positive (immunocompetent)", "≥5 mm in HIV / close contact", "Cannot distinguish latent vs active TB", "Boosting phenomenon; BCG cross-reaction"] },
  ];

  tests.forEach((t, i) => {
    const x = 0.3 + i * 2.38;
    card(s, x, 1.45, 2.2, 3.95, t.color);
    s.addShape(pres.ShapeType.rect, { x, y: 1.45, w: 2.2, h: 0.42, fill: { type: "solid", color: t.color }, line: { width: 0 } });
    s.addText(t.title, { x: x + 0.05, y: 1.45, w: 2.1, h: 0.42, fontSize: 10.5, bold: true, color: C.amber, fontFace: "Calibri", valign: "middle", align: "center", wrap: true });
    bulletBox(s, t.items, x + 0.1, 1.95, 2.0, 3.4, 10);
  });

  s.addText("IGRA (QuantiFERON-TB Gold): Measures IFN-γ release; no BCG cross-reaction; preferred in BCG-vaccinated individuals; same limitations as TST for active vs latent", {
    x: 0.3, y: 5.3, w: 9.4, h: 0.28, fontSize: 9.5, italic: true, color: C.light, fontFace: "Calibri", align: "left"
  });
}

// ══════════════════════════════════════════════════════════════════
// SLIDE 11 — SPUTUM + LABORATORY
// ══════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBg(s);
  sectionPill(s, "LABORATORY");
  accentBar(s, C.amber, 0.5, 0.7);
  slideTitle(s, "Sample Collection & Laboratory Workup", 0.8);

  // Sputum collection
  card(s, 0.3, 1.4, 4.5, 2.2);
  s.addText("Sputum Collection Protocol", { x: 0.4, y: 1.5, w: 4.3, h: 0.38, fontSize: 14, bold: true, color: C.amber, fontFace: "Calibri" });
  bulletBox(s, [
    "Collect 3 specimens at least 8 h apart (spot – early morning – spot)",
    "Early morning specimen has highest mycobacterial yield",
    "Minimum 2–5 mL per specimen; deep cough after rinse",
    "If unable to produce: nebulised saline induction, BAL, or bronchoscopy",
    "Avoid saliva contamination — degrades organisms",
  ], 0.4, 1.9, 4.3, 1.6, 11.5);

  card(s, 0.3, 3.75, 4.5, 1.65);
  s.addText("Blood / Other Tests", { x: 0.4, y: 3.85, w: 4.3, h: 0.35, fontSize: 13, bold: true, color: C.teal, fontFace: "Calibri" });
  bulletBox(s, [
    "FBC: leukocytosis; anaemia (normocytic)",
    "ESR / CRP: elevated (non-specific)",
    "LFT, RFT: baseline before treatment",
    "HIV test: MANDATORY in all TB patients",
    "Urine LAM: helpful in advanced HIV (CD4 <100)",
  ], 0.4, 4.2, 4.3, 1.1, 11);

  // Diagnostic algorithm
  card(s, 5.0, 1.4, 4.65, 4.0);
  s.addText("Diagnostic Algorithm (Pulmonary TB)", { x: 5.1, y: 1.5, w: 4.45, h: 0.38, fontSize: 13, bold: true, color: C.amber, fontFace: "Calibri" });
  const algo = [
    ["Step 1", "Clinical suspicion (cough ≥2 wks + systemic sx) + CXR"],
    ["Step 2", "Collect 3 sputum specimens (spot, AM, spot)"],
    ["Step 3", "Xpert MTB/RIF on initial sample (WHO 1st line)"],
    ["Step 4", "AFB smear microscopy ×3 (if Xpert unavailable)"],
    ["Step 5", "Sputum culture on all specimens (LJ/MGIT)"],
    ["Step 6", "Drug susceptibility testing (DST) on all culture-positive isolates"],
    ["Step 7", "If smear-negative: CT chest, bronchoscopy, BAL, or repeat Xpert on BAL"],
  ];
  algo.forEach(([step, desc], i) => {
    const y = 2.0 + i * 0.48;
    s.addShape(pres.ShapeType.roundRect, { x: 5.1, y, w: 0.82, h: 0.32, fill: { type: "solid", color: C.teal }, line: { width: 0 }, rectRadius: 0.08 });
    s.addText(step, { x: 5.1, y, w: 0.82, h: 0.32, fontSize: 9, bold: true, color: C.white, align: "center", valign: "middle" });
    s.addText(desc, { x: 6.0, y: y + 0.02, w: 3.55, h: 0.32, fontSize: 10, color: C.white, fontFace: "Calibri", valign: "middle", wrap: true });
  });
}

// ══════════════════════════════════════════════════════════════════
// SLIDE 12 — CXR + CT (composite image)
// ══════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBg(s);
  sectionPill(s, "IMAGING");
  accentBar(s, C.amber, 0.5, 0.7);
  slideTitle(s, "Radiological Patterns — Case Examples", 0.8);

  const ctImg = getImg(3); // CXR+CT composite
  if (ctImg) {
    s.addImage({ data: ctImg, x: 0.3, y: 1.35, w: 9.4, h: 3.8 });
    s.addText("Left: PA CXR showing left apical thick-walled cavity + lower lobe infiltrate + pleural effusion. Right panels (B–D): CT axial sections showing large apical cavity with air-fluid level, tree-in-bud nodules, and endobronchial dissemination — classic reactivation TB.", {
      x: 0.3, y: 5.12, w: 9.4, h: 0.45, fontSize: 9, italic: true, color: C.light, align: "center"
    });
  } else {
    s.addText("(Radiological images not available)", { x: 1, y: 2.5, w: 8, h: 1, fontSize: 16, color: C.light, align: "center" });
  }
}

// ══════════════════════════════════════════════════════════════════
// SLIDE 13 — TREATMENT PRINCIPLES
// ══════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBg(s);
  sectionPill(s, "TREATMENT");
  accentBar(s, C.amber, 0.5, 0.7);
  slideTitle(s, "Treatment of Drug-Susceptible TB", 0.8);

  // Phase cards
  const phases = [
    {
      phase: "Intensive Phase", dur: "2 months (8 weeks)",
      drugs: "RIPE: Rifampicin + Isoniazid + Pyrazinamide + Ethambutol",
      goal: "Kill rapidly dividing organisms; reduce bacillary load rapidly",
      color: "1A3A2A"
    },
    {
      phase: "Continuation Phase", dur: "4 months (16 weeks)",
      drugs: "RI: Rifampicin + Isoniazid",
      goal: "Eliminate dormant and semi-dormant bacilli; prevent relapse",
      color: "1A2A3A"
    }
  ];

  phases.forEach((p, i) => {
    const x = 0.3 + i * 4.8;
    card(s, x, 1.45, 4.4, 2.1, p.color);
    s.addText(p.phase, { x: x + 0.1, y: 1.55, w: 4.2, h: 0.4, fontSize: 15, bold: true, color: C.amber, fontFace: "Calibri" });
    s.addText("Duration: " + p.dur, { x: x + 0.1, y: 1.95, w: 4.2, h: 0.28, fontSize: 11.5, color: C.light, fontFace: "Calibri", bold: true });
    s.addText("Drugs: " + p.drugs, { x: x + 0.1, y: 2.23, w: 4.2, h: 0.38, fontSize: 11, color: C.white, fontFace: "Calibri", wrap: true });
    s.addText("Goal: " + p.goal, { x: x + 0.1, y: 2.62, w: 4.2, h: 0.45, fontSize: 10.5, color: C.light, fontFace: "Calibri", italic: true, wrap: true });
  });

  s.addText("Standard Regimen = 2HRZE / 4HR (or 2RIPE / 4RI)", {
    x: 0.3, y: 3.65, w: 9.4, h: 0.38, fontSize: 16, bold: true, color: C.amber, fontFace: "Calibri", align: "center"
  });

  // Drug doses table
  const drugs = [
    ["Drug", "Daily Dose (Adult)", "Major Side Effect"],
    ["Rifampicin (R)", "10 mg/kg (max 600 mg)", "Hepatotoxicity; orange body fluids; enzyme inducer"],
    ["Isoniazid (H)", "5 mg/kg (max 300 mg)", "Peripheral neuropathy (prevent with pyridoxine B6); hepatotoxicity"],
    ["Pyrazinamide (Z)", "25 mg/kg (max 2 g)", "Hyperuricaemia, gout, hepatotoxicity"],
    ["Ethambutol (E)", "15–20 mg/kg (max 1.6 g)", "Optic neuritis (monitor visual acuity)"],
  ];

  const tableProps = { x: 0.3, y: 4.1, w: 9.4, h: 1.4, fontSize: 10, fontFace: "Calibri" };
  s.addTable(drugs, {
    ...tableProps,
    align: "left",
    border: { type: "solid", color: C.teal, pt: 0.5 },
    fill: { color: C.navyMid },
    color: C.white,
    rowH: 0.28,
    valign: "middle",
    fontSize: 10,
    fontFace: "Calibri",
    firstRowFill: { color: C.teal },
    firstRowColor: C.white,
    firstRowBold: true,
  });
}

// ══════════════════════════════════════════════════════════════════
// SLIDE 14 — TREATMENT MONITORING & DOT
// ══════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBg(s);
  sectionPill(s, "TREATMENT");
  accentBar(s, C.amber, 0.5, 0.7);
  slideTitle(s, "Treatment Monitoring & DOT", 0.8);

  card(s, 0.3, 1.4, 4.5, 3.9);
  s.addText("Monitoring during Treatment", { x: 0.4, y: 1.5, w: 4.3, h: 0.38, fontSize: 14, bold: true, color: C.amber, fontFace: "Calibri" });
  bulletBox(s, [
    "Monthly clinical assessment: weight, symptoms, adherence",
    "Sputum AFB smear + culture monthly until negative",
    "75–80% culture-negative at 2 months; 95% at 3 months",
    "Positive culture at 4 months = treatment failure",
    "LFTs: if symptomatic hepatitis or baseline abnormal",
    "Visual acuity + colour discrimination (ethambutol)",
    "Uric acid if symptomatic gout (pyrazinamide)",
    "HIV viral load / CD4 count if co-infected",
    "CXR at baseline; repeat if clinically indicated",
  ], 0.4, 1.95, 4.3, 3.2, 11.5);

  card(s, 5.0, 1.4, 4.6, 3.9);
  s.addText("Directly Observed Therapy (DOT)", { x: 5.1, y: 1.5, w: 4.4, h: 0.38, fontSize: 14, bold: true, color: C.amber, fontFace: "Calibri" });
  bulletBox(s, [
    "WHO-recommended strategy for all TB patients",
    "Health worker observes every dose administration",
    "Prevents non-adherence — the main cause of treatment failure & drug resistance",
    "Infectious until: ≥2 wks therapy + clinical response + 3 AFB-negative sputa",
    "Discharge from hospital: requires isolation room / own home + health dept notification",
    "Never add a single drug to a failing regimen — promotes resistance",
    "DOTS (strategy): Political commitment + case detection + standardised therapy + drug supply + monitoring system",
  ], 5.1, 1.95, 4.4, 3.2, 11.5);
}

// ══════════════════════════════════════════════════════════════════
// SLIDE 15 — DRUG-RESISTANT TB
// ══════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBg(s);
  sectionPill(s, "DRUG RESISTANCE");
  accentBar(s, C.red, 0.5, 0.7);
  slideTitle(s, "Drug-Resistant TB (MDR & XDR)", 0.8);

  // Definition boxes
  const defs = [
    { label: "MDR-TB", color: "7B1A1A", def: "Resistant to at least Isoniazid AND Rifampicin (the two most potent first-line drugs)" },
    { label: "Pre-XDR-TB", color: "8B2E00", def: "MDR-TB + resistance to any fluoroquinolone (levofloxacin / moxifloxacin)" },
    { label: "XDR-TB", color: "6A0A0A", def: "Pre-XDR-TB + resistance to at least one drug in the group bedaquiline or linezolid" },
  ];

  defs.forEach((d, i) => {
    const x = 0.3 + i * 3.2;
    card(s, x, 1.4, 3.0, 1.35, d.color);
    s.addText(d.label, { x: x + 0.1, y: 1.5, w: 2.8, h: 0.4, fontSize: 18, bold: true, color: C.amber, fontFace: "Calibri", align: "center" });
    s.addText(d.def, { x: x + 0.1, y: 1.9, w: 2.8, h: 0.75, fontSize: 10, color: C.white, fontFace: "Calibri", wrap: true, align: "center" });
  });

  s.addText("Causes of Drug Resistance", { x: 0.4, y: 2.95, w: 4.4, h: 0.35, fontSize: 14, bold: true, color: C.teal, fontFace: "Calibri" });
  bulletBox(s, [
    "Inadequate / incomplete treatment courses",
    "Monotherapy or sub-therapeutic drug levels",
    "Poor adherence; drug shortages",
    "Transmission of already-resistant strains",
    "Spontaneous mutation: 1 in 10⁶–10⁸ organisms",
  ], 0.4, 3.3, 4.4, 2.0, 12);

  s.addText("MDR-TB Treatment", { x: 5.0, y: 2.95, w: 4.6, h: 0.35, fontSize: 14, bold: true, color: C.amber, fontFace: "Calibri" });
  bulletBox(s, [
    "BPaL regimen (WHO 2022): Bedaquiline + Pretomanid + Linezolid — 6 months for XDR/treatment-intolerant MDR-TB",
    "Shorter oral MDR regimen (BPaLM): adds Moxifloxacin — 6 months",
    "Conventional MDR: 18–20 months; includes injectable agents (avoid if possible)",
    "Drug susceptibility testing is mandatory before starting MDR treatment",
    "Consult national/regional TB experts — do NOT treat MDR-TB alone",
    "~60% treatment success for MDR-TB globally (vs ~85% drug-susceptible TB)",
  ], 5.0, 3.3, 4.6, 2.0, 11.5);
}

// ══════════════════════════════════════════════════════════════════
// SLIDE 16 — TB/HIV & SPECIAL SITUATIONS
// ══════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBg(s);
  sectionPill(s, "SPECIAL SITUATIONS");
  accentBar(s, C.amber, 0.5, 0.7);
  slideTitle(s, "TB/HIV Co-infection & Miliary TB", 0.8);

  card(s, 0.3, 1.4, 4.5, 3.9);
  s.addShape(pres.ShapeType.rect, { x: 0.3, y: 1.4, w: 4.5, h: 0.42, fill: { type: "solid", color: "8B0000" }, line: { width: 0 } });
  s.addText("TB / HIV Co-infection", { x: 0.3, y: 1.4, w: 4.5, h: 0.42, fontSize: 14, bold: true, color: C.white, align: "center", valign: "middle" });
  bulletBox(s, [
    "HIV is the strongest risk factor for TB reactivation (20–37× higher risk than HIV-negative individuals)",
    "TB is the leading cause of death in HIV+ patients globally",
    "Atypical presentation: fewer cavities, lower smear positivity, possible normal CXR",
    "Extrapulmonary & disseminated TB more common as CD4 falls",
    "Diagnose: Xpert + urine LAM (CD4 <100); culture is gold standard",
    "Treat TB first; start ART within 2–8 weeks (earlier if CD4 <50)",
    "IRIS (Immune Reconstitution Inflammatory Syndrome): TB worsening after ART initiation — manage with NSAIDs/steroids",
    "Drug interactions: rifampicin ↓ levels of many ARVs — use rifabutin or adjust doses",
  ], 0.4, 1.9, 4.3, 3.3, 11);

  card(s, 5.0, 1.4, 4.6, 3.9);
  s.addShape(pres.ShapeType.rect, { x: 5.0, y: 1.4, w: 4.6, h: 0.42, fill: { type: "solid", color: C.teal }, line: { width: 0 } });
  s.addText("Miliary TB", { x: 5.0, y: 1.4, w: 4.6, h: 0.42, fontSize: 14, bold: true, color: C.white, align: "center", valign: "middle" });
  bulletBox(s, [
    "Haematogenous dissemination from a primary or reactivation focus",
    "1–2 mm granulomatous nodules in lungs, liver, spleen, bone marrow, adrenals, kidneys",
    "Clinical: fever, night sweats, weight loss; often no localising symptoms",
    "CXR: 'millet seed' bilateral nodules (~85%); CT more sensitive",
    "Choroidal tubercles on fundoscopy — pathognomonic",
    "Hepatosplenomegaly, lymphadenopathy",
    "Blood cultures positive in 20–40% of AIDS patients with miliary TB",
    "Treatment: same 2HRZE / 4HR regimen; steroids if meningitis component",
  ], 5.1, 1.9, 4.4, 3.3, 11);
}

// ══════════════════════════════════════════════════════════════════
// SLIDE 17 — EXTRAPULMONARY TB
// ══════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBg(s);
  sectionPill(s, "EXTRAPULMONARY TB");
  accentBar(s, C.amber, 0.5, 0.7);
  slideTitle(s, "Extrapulmonary TB", 0.8);

  const sites = [
    { site: "Lymph nodes", detail: "Most common extrapulmonary site; cervical nodes (scrofula); cold abscess; biopsy shows caseating granuloma" },
    { site: "Pleura", detail: "Exudative lymphocytic effusion; ADA >45 IU/L; often resolves spontaneously but requires treatment" },
    { site: "Meningitis / CNS", detail: "Most severe form; basilar meningitis; cranial nerve palsies; hydrocephalus; CSF: lymphocytosis, high protein, low glucose; add dexamethasone" },
    { site: "Bone / Joint (Pott's)", detail: "Thoracic spine most common; vertebral collapse → kyphosis (Gibbus); psoas abscess; paraplegia risk" },
    { site: "GU Tract", detail: "'Sterile pyuria' (WBC in urine, no growth on standard culture); renal cortex → descending infection; irregular calcifications on IVP" },
    { site: "Pericardium", detail: "Constrictive pericarditis; friction rub; pericardial effusion; may need pericardiectomy; steroids reduce inflammation" },
    { site: "Abdomen", detail: "Ileocaecal most common; ascites; LAM + lymphadenopathy; peritoneal nodules on laparoscopy; SAAG <1.1" },
    { site: "Adrenal glands", detail: "Bilateral destruction → Addison's disease; bilateral adrenal calcification on imaging is classic" },
  ];

  const cols = [sites.slice(0, 4), sites.slice(4)];
  cols.forEach((col, ci) => {
    const xBase = ci === 0 ? 0.3 : 5.1;
    col.forEach((item, ri) => {
      const y = 1.45 + ri * 1.02;
      card(s, xBase, y, 4.5, 0.9, C.navyMid);
      s.addText(item.site, { x: xBase + 0.1, y: y + 0.05, w: 4.3, h: 0.3, fontSize: 12.5, bold: true, color: C.amber, fontFace: "Calibri" });
      s.addText(item.detail, { x: xBase + 0.1, y: y + 0.33, w: 4.3, h: 0.52, fontSize: 10, color: C.white, fontFace: "Calibri", wrap: true });
    });
  });
}

// ══════════════════════════════════════════════════════════════════
// SLIDE 18 — PREVENTION & PUBLIC HEALTH
// ══════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBg(s);
  sectionPill(s, "PREVENTION");
  accentBar(s, C.amber, 0.5, 0.7);
  slideTitle(s, "Prevention & Public Health Control", 0.8);

  card(s, 0.3, 1.4, 4.5, 3.9);
  s.addText("BCG Vaccine", { x: 0.4, y: 1.5, w: 4.3, h: 0.38, fontSize: 15, bold: true, color: C.amber, fontFace: "Calibri" });
  bulletBox(s, [
    "Bacille Calmette-Guérin (live attenuated M. bovis)",
    "Given at birth in high-burden countries",
    "Protects against severe forms in children: 70–80% efficacy for miliary TB and TB meningitis",
    "Variable efficacy against pulmonary TB in adults (0–80%)",
    "Does NOT prevent infection or reactivation",
    "Contraindicated in HIV+ (with CD4 <200) and other immunocompromised states",
    "BCG scar = evidence of vaccination; can cause false-positive TST",
  ], 0.4, 1.95, 4.3, 3.2, 11.5);

  card(s, 5.0, 1.4, 4.6, 3.9);
  s.addText("Public Health Measures", { x: 5.1, y: 1.5, w: 4.4, h: 0.38, fontSize: 15, bold: true, color: C.amber, fontFace: "Calibri" });
  bulletBox(s, [
    "Mandatory notification of TB cases to public health authorities",
    "Contact tracing: screen all close contacts with TST/IGRA + CXR",
    "Airborne precautions: N95 respirators; negative-pressure isolation rooms",
    "Respiratory etiquette: cover cough; surgical mask on TB patient",
    "LTBI treatment in high-risk contacts prevents future active disease",
    "End TB Strategy (WHO): targets 90% reduction in TB deaths by 2030",
    "Social determinants: address poverty, overcrowding, malnutrition",
    "Screen high-risk groups: miners, prisoners, healthcare workers, immunocompromised",
  ], 5.1, 1.95, 4.4, 3.2, 11.5);
}

// ══════════════════════════════════════════════════════════════════
// SLIDE 19 — COMPLICATIONS
// ══════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBg(s);
  sectionPill(s, "COMPLICATIONS");
  accentBar(s, C.red, 0.5, 0.7);
  slideTitle(s, "Complications of Pulmonary TB", 0.8);

  const comps = [
    { title: "Haemoptysis", desc: "Erosion of Rasmussen's aneurysm (dilated pulmonary artery adjacent to cavity); can be massive and life-threatening; manage with bronchial artery embolisation" },
    { title: "Pneumothorax", desc: "Rupture of subpleural focus or cavity into pleural space; tension pneumothorax if ball-valve mechanism" },
    { title: "Empyema", desc: "Bronchopleural fistula; frank pus in pleural space; requires drainage + prolonged treatment" },
    { title: "Bronchiectasis", desc: "Permanent dilation of airways from chronic inflammation and fibrosis; recurrent infections, chronic productive cough" },
    { title: "Respiratory Failure", desc: "Extensive parenchymal destruction (destroyed lung); may require mechanical ventilation; cor pulmonale in chronic disease" },
    { title: "Aspergilloma", desc: "Fungal ball (Aspergillus) colonises pre-existing TB cavity; Monod sign on CXR; haemoptysis; treat with voriconazole / surgical resection" },
    { title: "ARDS", desc: "In severe miliary TB or extensive pneumonic TB; high mortality; manage in ICU" },
    { title: "Amyloidosis", desc: "Chronic inflammation → secondary (AA) amyloidosis; renal impairment, hepatosplenomegaly (now rare with early treatment)" },
  ];

  const cols2 = [comps.slice(0, 4), comps.slice(4)];
  cols2.forEach((col, ci) => {
    const xBase = ci === 0 ? 0.3 : 5.1;
    col.forEach((item, ri) => {
      const y = 1.4 + ri * 1.03;
      card(s, xBase, y, 4.5, 0.92, "1F1215");
      s.addShape(pres.ShapeType.rect, { x: xBase, y, w: 0.07, h: 0.92, fill: { type: "solid", color: C.red }, line: { width: 0 } });
      s.addText(item.title, { x: xBase + 0.15, y: y + 0.06, w: 4.25, h: 0.3, fontSize: 12.5, bold: true, color: C.amber, fontFace: "Calibri" });
      s.addText(item.desc, { x: xBase + 0.15, y: y + 0.35, w: 4.25, h: 0.52, fontSize: 10, color: C.white, fontFace: "Calibri", wrap: true });
    });
  });
}

// ══════════════════════════════════════════════════════════════════
// SLIDE 20 — LATENT TB TREATMENT
// ══════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBg(s);
  sectionPill(s, "LTBI TREATMENT");
  accentBar(s, C.amber, 0.5, 0.7);
  slideTitle(s, "Treatment of Latent TB Infection (LTBI)", 0.8);

  const regimens = [
    ["3HP", "Isoniazid + Rifapentine", "Once weekly × 12 doses", "Preferred (WHO 2020); high completion; DOTS needed"],
    ["1HP", "Isoniazid + Rifapentine", "Daily × 4 weeks (28 doses)", "Effective; shorter duration; equivalent efficacy"],
    ["4R", "Rifampicin alone", "Daily × 4 months", "Good for INH-resistant contacts; well tolerated"],
    ["6H", "Isoniazid alone", "Daily × 6 months", "Classic regimen; widely used; less effective than rifampicin-based in HIV+"],
    ["9H", "Isoniazid alone", "Daily × 9 months", "Alternative where 6H fails; preferred in HIV+ (older guideline)"],
  ];

  s.addTable(
    [["Regimen", "Drugs", "Duration", "Notes"], ...regimens],
    {
      x: 0.3, y: 1.4, w: 9.4, h: 2.5,
      align: "left",
      border: { type: "solid", color: C.teal, pt: 0.5 },
      fill: { color: C.navyMid },
      color: C.white,
      rowH: 0.42,
      valign: "middle",
      fontSize: 11,
      fontFace: "Calibri",
      firstRowFill: { color: C.teal },
      firstRowColor: C.white,
      firstRowBold: true,
    }
  );

  s.addText("Who should receive LTBI treatment?", { x: 0.4, y: 4.05, w: 9.2, h: 0.38, fontSize: 14, bold: true, color: C.amber, fontFace: "Calibri" });
  bulletBox(s, [
    "Close contacts of smear-positive TB patients (especially children < 5 years and HIV+)",
    "HIV-positive individuals with positive TST/IGRA (regardless of CD4 count)",
    "Patients starting anti-TNF therapy, dialysis, or solid organ transplant with positive TST/IGRA",
    "Healthcare workers, prisoners, homeless individuals with documented recent TST conversion",
    "Always exclude active TB before starting LTBI treatment",
  ], 0.4, 4.45, 9.2, 1.1, 12);
}

// ══════════════════════════════════════════════════════════════════
// SLIDE 21 — KEY POINTS SUMMARY
// ══════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBg(s);
  sectionPill(s, "SUMMARY");
  accentBar(s, C.amber, 0.5, 0.7);
  slideTitle(s, "Key Points to Remember", 0.8);

  const kps = [
    "TB remains the world's leading infectious disease killer — caused by M. tuberculosis, transmitted via airborne droplet nuclei.",
    "The hallmark lesion is the caseating granuloma; the Ghon complex marks primary infection.",
    "90–95% of infected individuals develop latent TB; only 5–10% progress to active disease.",
    "Classic symptoms: persistent cough ≥2 weeks, fever, night sweats, weight loss, haemoptysis.",
    "Post-primary TB: apical fibrocavitary disease on CXR; smear-positive sputum.",
    "Diagnosis: Xpert MTB/RIF (WHO preferred), AFB smear, culture (gold standard), TST/IGRA for latent disease.",
    "Treatment of drug-susceptible TB: 2HRZE / 4HR (6 months total); DOT to prevent resistance.",
    "MDR-TB: resistant to INH + RIF; treat with BPaLM regimen (6 months).",
    "HIV co-infection: most important risk factor; start ART within 2–8 weeks of TB treatment.",
    "BCG vaccine: protects children from severe forms; mandatory notification + contact tracing are essential public health tools.",
  ];

  kps.forEach((kp, i) => {
    const row = Math.floor(i / 2);
    const col = i % 2;
    const x = 0.3 + col * 4.85;
    const y = 1.4 + row * 0.82;
    s.addShape(pres.ShapeType.roundRect, {
      x, y, w: 4.6, h: 0.72,
      fill: { type: "solid", color: C.navyMid },
      line: { color: C.teal, width: 0.7 },
      rectRadius: 0.1
    });
    s.addShape(pres.ShapeType.ellipse, {
      x: x + 0.1, y: y + 0.18, w: 0.32, h: 0.32,
      fill: { type: "solid", color: C.amber }, line: { width: 0 }
    });
    s.addText(String(i + 1), { x: x + 0.1, y: y + 0.18, w: 0.32, h: 0.32, fontSize: 10, bold: true, color: C.navy, align: "center", valign: "middle" });
    s.addText(kp, { x: x + 0.5, y: y + 0.08, w: 4.0, h: 0.6, fontSize: 10, color: C.white, fontFace: "Calibri", wrap: true, valign: "middle" });
  });
}

// ══════════════════════════════════════════════════════════════════
// SLIDE 22 — REFERENCES / THANK YOU
// ══════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { type: "solid", color: C.dark } });
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { type: "solid", color: C.navy }, transparency: 10 });
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.18, h: 5.625, fill: { type: "solid", color: C.amber }, line: { width: 0 } });
  s.addShape(pres.ShapeType.rect, { x: 0.18, y: 0, w: 0.08, h: 5.625, fill: { type: "solid", color: C.teal }, line: { width: 0 } });

  s.addText("References & Further Reading", { x: 0.55, y: 0.5, w: 9, h: 0.5, fontSize: 22, bold: true, color: C.amber, fontFace: "Calibri" });
  s.addShape(pres.ShapeType.rect, { x: 0.55, y: 1.05, w: 7, h: 0.05, fill: { type: "solid", color: C.teal }, line: { width: 0 } });

  const refs = [
    "1. Harrison's Principles of Internal Medicine, 21st Edition (2022). Chapter 299: Tuberculosis. McGraw-Hill.",
    "2. Fishman's Pulmonary Diseases and Disorders, 5th Edition. Chapter 87: Pulmonary Infections.",
    "3. WHO Global Tuberculosis Report 2023. World Health Organization, Geneva.",
    "4. CDC. Core Curriculum on Tuberculosis (2021). Centers for Disease Control and Prevention.",
    "5. Pai M et al. Tuberculosis. Nature Reviews Disease Primers 2016; 2:16076.",
    "6. Furin J, Cox H, Pai M. Tuberculosis. The Lancet 2019; 393(10181):1642–1656.",
    "7. WHO Treatment Guidelines for Drug-Resistant Tuberculosis, 2022 Update.",
    "8. Standard treatment regimen abbreviations: H=Isoniazid; R=Rifampicin; Z=Pyrazinamide; E=Ethambutol; B=Bedaquiline; Pa=Pretomanid; L=Linezolid; M=Moxifloxacin",
  ];

  refs.forEach((r, i) => {
    s.addText(r, { x: 0.55, y: 1.2 + i * 0.44, w: 9, h: 0.42, fontSize: 10.5, color: C.light, fontFace: "Calibri", wrap: true });
  });

  s.addText("Thank You", { x: 0.55, y: 5.1, w: 9, h: 0.4, fontSize: 20, bold: true, color: C.amber, fontFace: "Calibri", align: "center" });
}

// ─── Write file ──────────────────────────────────────────────────
pres.writeFile({ fileName: "/home/daytona/workspace/pulmonary-tb-ppt/Pulmonary_Tuberculosis.pptx" })
  .then(() => console.log("SUCCESS: Pulmonary_Tuberculosis.pptx created"))
  .catch(e => { console.error("ERROR:", e); process.exit(1); });
Your credits are exhausted. Your daily credits reset tomorrow, or you can purchase a top-up for more.
This is a shared conversation. Sign in to Orris to start your own chat.