Presentation on capnographs

Asking for Preferences
Reading File
Reading File
Searching the Web

capnography waveform interpretation ICU anesthesia clinical guide 2024

Reading File
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Reading File
Finding Sources
Running Command

mkdir -p /home/daytona/workspace/capnography-pptx && ls /home/daytona/workspace/…

Writing File

~/capnography-pptx/build_capno.js

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

// ─── THEME ───────────────────────────────────────────────────────────────────
const C = {
  navy:    "0A1628",   // dominant dark background
  teal:    "0D7377",   // primary accent
  green:   "14A085",   // secondary accent / highlight
  amber:   "F59E0B",   // warning / alert
  white:   "F0F4F8",   // body text
  silver:  "94A3B8",   // muted text
  red:     "E53E3E",   // danger
  bg2:     "0F1F35",   // slightly lighter dark bg
  bg3:     "1A2F4A",   // card backgrounds
};

const pres = new pptxgen();
pres.layout  = "LAYOUT_16x9";
pres.author  = "Orris";
pres.title   = "Capnography: Principles & Clinical Practice";
pres.subject = "ICU / Anesthesia Education";

// ─── HELPERS ─────────────────────────────────────────────────────────────────
function darkSlide(slide) {
  slide.background = { color: C.navy };
}
function cardSlide(slide) {
  slide.background = { color: C.bg2 };
}

function topBar(slide, color = C.teal) {
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 0.08, fill: { color }, line: { color } });
}
function sectionTag(slide, text, x = 8.4, y = 0.12) {
  slide.addText(text.toUpperCase(), {
    x, y, w: 1.5, h: 0.22, fontSize: 7, bold: true, color: C.teal,
    charSpacing: 2, align: "right", valign: "middle",
  });
}
function slideTitle(slide, title, subtitle = null) {
  slide.addText(title, {
    x: 0.45, y: 0.14, w: 9.1, h: 0.55,
    fontSize: 22, bold: true, color: C.white, fontFace: "Calibri",
    margin: 0,
  });
  if (subtitle) {
    slide.addText(subtitle, {
      x: 0.45, y: 0.70, w: 9.1, h: 0.3,
      fontSize: 11, color: C.teal, fontFace: "Calibri",
      margin: 0, italic: true,
    });
  }
}
function divider(slide, y = 1.05) {
  slide.addShape(pres.ShapeType.line, {
    x: 0.45, y, w: 9.1, h: 0,
    line: { color: C.teal, width: 1.2 },
  });
}
function bullets(slide, items, x, y, w, h, opts = {}) {
  const base = { fontSize: 12.5, color: C.white, fontFace: "Calibri", ...opts };
  const arr = items.map((item, i) => ({
    text: item,
    options: { bullet: { indent: 14 }, breakLine: i < items.length - 1, ...base },
  }));
  slide.addText(arr, { x, y, w, h, valign: "top" });
}
function card(slide, x, y, w, h, fillColor = C.bg3) {
  slide.addShape(pres.ShapeType.roundRect, {
    x, y, w, h,
    fill: { color: fillColor },
    line: { color: C.teal, width: 0.8 },
    rectRadius: 0.06,
  });
}
function cardTitle(slide, text, x, y, w, color = C.teal) {
  slide.addText(text, {
    x, y, w, h: 0.3,
    fontSize: 10.5, bold: true, color, fontFace: "Calibri",
    margin: 0,
  });
}
function badge(slide, text, x, y, bg = C.teal) {
  slide.addShape(pres.ShapeType.roundRect, {
    x, y, w: 0.55, h: 0.28,
    fill: { color: bg },
    line: { color: bg },
    rectRadius: 0.04,
  });
  slide.addText(text, {
    x, y, w: 0.55, h: 0.28,
    fontSize: 9, bold: true, color: C.white, align: "center", valign: "middle",
    fontFace: "Calibri", margin: 0,
  });
}

// ─── SLIDE 1: TITLE ───────────────────────────────────────────────────────────
{
  const s = pres.addSlide();
  darkSlide(s);
  // Left accent bar
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.35, h: 5.625, fill: { color: C.teal }, line: { color: C.teal } });
  // Decorative wave rect
  s.addShape(pres.ShapeType.rect, { x: 5.8, y: 0, w: 4.2, h: 5.625, fill: { color: C.bg3 }, line: { color: C.bg3 } });

  s.addText("CAPNOGRAPHY", {
    x: 0.6, y: 1.2, w: 5, h: 0.85,
    fontSize: 38, bold: true, color: C.white, fontFace: "Calibri", charSpacing: 4,
  });
  s.addText("Principles & Clinical Practice", {
    x: 0.6, y: 2.05, w: 5, h: 0.45,
    fontSize: 18, color: C.teal, fontFace: "Calibri", italic: true,
  });
  s.addShape(pres.ShapeType.line, {
    x: 0.6, y: 2.55, w: 3.2, h: 0,
    line: { color: C.amber, width: 2.5 },
  });
  s.addText("For ICU & Anesthesia Clinicians", {
    x: 0.6, y: 2.72, w: 5, h: 0.3,
    fontSize: 11, color: C.silver, fontFace: "Calibri",
  });

  // Right panel content
  s.addText("Key Topics", {
    x: 6.1, y: 0.7, w: 3.6, h: 0.35,
    fontSize: 13, bold: true, color: C.teal, fontFace: "Calibri",
  });
  const topics = [
    "Physics & Technology",
    "Normal Waveform Phases",
    "Abnormal Patterns",
    "Clinical Applications",
    "ETT Confirmation",
    "CPR & ROSC Monitoring",
    "Dead Space & Physiology",
    "Troubleshooting",
    "Special Populations",
  ];
  topics.forEach((t, i) => {
    badge(s, `${i+1}`, 6.1, 1.12 + i * 0.44, C.teal);
    s.addText(t, {
      x: 6.72, y: 1.12 + i * 0.44, w: 2.9, h: 0.28,
      fontSize: 10, color: C.white, fontFace: "Calibri", valign: "middle", margin: 0,
    });
  });
}

// ─── SLIDE 2: WHAT IS CAPNOGRAPHY? ───────────────────────────────────────────
{
  const s = pres.addSlide();
  cardSlide(s);
  topBar(s);
  sectionTag(s, "Introduction");
  slideTitle(s, "What is Capnography?");
  divider(s);

  // Definition card
  card(s, 0.4, 1.15, 9.2, 1.0, C.bg3);
  s.addText("Capnography is the continuous, non-invasive measurement and graphical display of CO₂ concentration in respiratory gases, providing real-time breath-by-breath data on ventilation, perfusion, and metabolism.", {
    x: 0.6, y: 1.22, w: 8.8, h: 0.85,
    fontSize: 13, color: C.white, fontFace: "Calibri", valign: "middle",
  });

  // Three pillars
  const pillars = [
    { title: "Capnometry",    desc: "Numeric display only — ETCO₂ value in mmHg or %",        color: C.teal  },
    { title: "Capnography",   desc: "Numeric + waveform (capnogram) — preferred in ICU/OR",   color: C.green },
    { title: "Capnogram",     desc: "The actual CO₂ waveform trace over time",                 color: C.amber },
  ];
  pillars.forEach((p, i) => {
    const x = 0.4 + i * 3.1;
    card(s, x, 2.3, 2.9, 1.55, C.bg3);
    s.addShape(pres.ShapeType.rect, { x, y: 2.3, w: 2.9, h: 0.35, fill: { color: p.color }, line: { color: p.color } });
    s.addText(p.title, { x, y: 2.3, w: 2.9, h: 0.35, fontSize: 12, bold: true, color: C.navy, align: "center", valign: "middle", fontFace: "Calibri", margin: 0 });
    s.addText(p.desc, { x: x + 0.1, y: 2.7, w: 2.7, h: 1.1, fontSize: 11, color: C.white, fontFace: "Calibri", valign: "top" });
  });

  s.addText("Normal ETCO₂: 35–45 mmHg (reflects PaCO₂ with a 2–5 mmHg gradient due to alveolar dead space)", {
    x: 0.4, y: 3.98, w: 9.2, h: 0.3,
    fontSize: 10.5, color: C.silver, italic: true, fontFace: "Calibri",
  });
  s.addText("Sources: Morgan & Mikhail's Clinical Anesthesiology, 7e | Barash Clinical Anesthesia, 9e", {
    x: 0.4, y: 5.25, w: 9.2, h: 0.22,
    fontSize: 7.5, color: C.silver, italic: true, fontFace: "Calibri",
  });
}

// ─── SLIDE 3: PHYSICS & TECHNOLOGY ───────────────────────────────────────────
{
  const s = pres.addSlide();
  cardSlide(s);
  topBar(s);
  sectionTag(s, "Technology");
  slideTitle(s, "Physics & Technology");
  divider(s);

  // Left: Beer-Lambert
  card(s, 0.4, 1.15, 4.4, 2.5, C.bg3);
  cardTitle(s, "Beer-Lambert Law", 0.55, 1.22, 4.1);
  s.addText([
    { text: "A = ε × c × l", options: { bold: true, fontSize: 15, color: C.amber, breakLine: true } },
    { text: "\nAbsorption of infrared (IR) light is proportional to the concentration of CO₂ in the gas sample. CO₂ absorbs IR at 4.26 µm wavelength. N₂ and O₂ do not absorb IR — measured separately.", options: { fontSize: 11, color: C.white } },
  ], { x: 0.55, y: 1.55, w: 4.1, h: 2.0, valign: "top", fontFace: "Calibri" });

  // Right: two sub-cards
  card(s, 5.05, 1.15, 4.5, 1.18, C.bg3);
  cardTitle(s, "Mainstream (In-line)", 5.2, 1.22, 4.2, C.green);
  bullets(s, [
    "Sensor sits directly at airway adapter",
    "No lag time, no aspiration loss",
    "Heavier — risk of ETT traction",
    "Best for intubated patients",
  ], 5.2, 1.52, 4.2, 0.75, { fontSize: 10.5 });

  card(s, 5.05, 2.45, 4.5, 1.2, C.bg3);
  cardTitle(s, "Sidestream (Diverting)", 5.2, 2.52, 4.2, C.amber);
  bullets(s, [
    "Aspirates gas ~50–250 mL/min to bedside analyzer",
    "Prone to water condensation / obstruction",
    "Works with non-intubated patients (nasal cannula)",
    "Slight lag; may dilute ETCO₂ in small VT (pediatrics)",
  ], 5.2, 2.82, 4.2, 0.78, { fontSize: 10.5 });

  card(s, 0.4, 3.78, 9.15, 0.75, C.bg3);
  cardTitle(s, "Colorimetric Capnometry", 0.55, 3.85, 9.0, C.silver);
  s.addText("Semi-quantitative device using a pH-sensitive indicator that changes color with CO₂ exposure. Used for rapid ETT confirmation — NOT a substitute for continuous waveform capnography.", {
    x: 0.55, y: 4.12, w: 9.0, h: 0.35,
    fontSize: 10.5, color: C.white, fontFace: "Calibri",
  });

  s.addText("Sources: Morgan & Mikhail's Clinical Anesthesiology, 7e | Tintinalli's Emergency Medicine", {
    x: 0.4, y: 5.25, w: 9.2, h: 0.22,
    fontSize: 7.5, color: C.silver, italic: true, fontFace: "Calibri",
  });
}

// ─── SLIDE 4: NORMAL CAPNOGRAM ────────────────────────────────────────────────
{
  const s = pres.addSlide();
  cardSlide(s);
  topBar(s);
  sectionTag(s, "Waveform");
  slideTitle(s, "The Normal Capnogram", "4-Phase respiratory cycle");
  divider(s);

  // Fetch waveform image
  let waveformImg = null;
  try {
    const result = JSON.parse(execSync(
      `node /home/daytona/skills/shared/scripts/fetch_images.js "https://cdn.orris.care/cdss_images/828c73846ab533126561d83ab1202121bde9bde9bec54ca7033cf1a352eb89e7.png"`,
      { timeout: 30000 }
    ).toString());
    if (result[0] && !result[0].error) waveformImg = result[0].base64;
  } catch(e) { /* skip */ }

  if (waveformImg) {
    s.addImage({ data: waveformImg, x: 0.4, y: 1.15, w: 4.4, h: 3.2 });
  } else {
    card(s, 0.4, 1.15, 4.4, 3.2, C.bg3);
    s.addText("[Capnogram waveform diagram]", { x: 0.4, y: 2.5, w: 4.4, h: 0.4, fontSize: 11, color: C.silver, align: "center", fontFace: "Calibri" });
  }

  // Phases
  const phases = [
    { ph: "Phase I",   col: C.teal,   desc: "Baseline — anatomic dead space gas (CO₂ ≈ 0 mmHg)" },
    { ph: "Phase II",  col: C.green,  desc: "Steep upstroke — mixing of dead space & alveolar gas" },
    { ph: "Phase III", col: C.amber,  desc: "Alveolar plateau — plateau of CO₂; ETCO₂ measured at peak" },
    { ph: "Phase 0",   col: C.silver, desc: "Inspiratory downstroke — rapid return to baseline" },
  ];
  phases.forEach((p, i) => {
    card(s, 5.05, 1.15 + i * 0.98, 4.5, 0.88, C.bg3);
    badge(s, p.ph.split(" ")[1], 5.15, 1.22 + i * 0.98, p.col);
    s.addText(p.ph, { x: 5.75, y: 1.22 + i * 0.98, w: 3.7, h: 0.25, fontSize: 10.5, bold: true, color: p.col, fontFace: "Calibri", margin: 0 });
    s.addText(p.desc, { x: 5.75, y: 1.48 + i * 0.98, w: 3.7, h: 0.48, fontSize: 10, color: C.white, fontFace: "Calibri", valign: "top" });
  });

  s.addText("Normal ETCO₂: 35–45 mmHg | PaCO₂–ETCO₂ gradient: 2–5 mmHg (reflects alveolar dead space)", {
    x: 0.4, y: 5.05, w: 9.2, h: 0.25,
    fontSize: 9.5, color: C.silver, italic: true, fontFace: "Calibri",
  });
  s.addText("Source: Morgan & Mikhail's Clinical Anesthesiology, 7e, p.227", {
    x: 0.4, y: 5.3, w: 9.2, h: 0.2,
    fontSize: 7.5, color: C.silver, italic: true, fontFace: "Calibri",
  });
}

// ─── SLIDE 5: CO₂ PHYSIOLOGY ──────────────────────────────────────────────────
{
  const s = pres.addSlide();
  cardSlide(s);
  topBar(s);
  sectionTag(s, "Physiology");
  slideTitle(s, "CO₂ Physiology & the ETCO₂–PaCO₂ Relationship");
  divider(s);

  card(s, 0.4, 1.15, 9.2, 0.85, C.bg3);
  s.addText("ETCO₂ is determined by 3 factors: CO₂ Production (VCO₂) | Alveolar Ventilation (VA) | Ventilation-Perfusion (V/Q) Matching", {
    x: 0.6, y: 1.22, w: 8.8, h: 0.7,
    fontSize: 12.5, color: C.white, bold: true, fontFace: "Calibri", valign: "middle", align: "center",
  });

  const factors = [
    {
      title: "CO₂ Production ↑",
      items: ["Fever / hyperthermia", "Malignant hyperthermia", "Hypermetabolic states", "Reperfusion after ischemia", "Bicarbonate administration"],
      col: C.amber,
    },
    {
      title: "Alveolar Ventilation ↑",
      items: ["Reduces ETCO₂ (hyperventilation)", "Reduces PaCO₂ in parallel", "Used in controlled ventilation", "Hyperventilation: ETCO₂ <35 mmHg", "Hypoventilation: ETCO₂ >45 mmHg"],
      col: C.teal,
    },
    {
      title: "V/Q Mismatch & Dead Space",
      items: ["Pulmonary embolism ↑ dead space", "Air embolism → sudden ETCO₂ drop", "Decreased cardiac output", "Hypotension / shock states", "PaCO₂–ETCO₂ gradient widens"],
      col: C.red,
    },
  ];
  factors.forEach((f, i) => {
    const x = 0.4 + i * 3.1;
    card(s, x, 2.1, 2.9, 3.0, C.bg3);
    s.addShape(pres.ShapeType.rect, { x, y: 2.1, w: 2.9, h: 0.33, fill: { color: f.col }, line: { color: f.col } });
    s.addText(f.title, { x, y: 2.1, w: 2.9, h: 0.33, fontSize: 10.5, bold: true, color: C.navy, align: "center", valign: "middle", fontFace: "Calibri", margin: 0 });
    bullets(s, f.items, x + 0.1, 2.48, 2.7, 2.55, { fontSize: 10.5 });
  });

  s.addText("Source: Morgan & Mikhail's Clinical Anesthesiology, 7e | Roberts & Hedges' Clinical Procedures", {
    x: 0.4, y: 5.3, w: 9.2, h: 0.2,
    fontSize: 7.5, color: C.silver, italic: true, fontFace: "Calibri",
  });
}

// ─── SLIDE 6: ABNORMAL WAVEFORMS ─────────────────────────────────────────────
{
  const s = pres.addSlide();
  cardSlide(s);
  topBar(s);
  sectionTag(s, "Waveform");
  slideTitle(s, "Abnormal Capnogram Patterns", "Recognition & clinical significance");
  divider(s);

  const patterns = [
    { label: "Obstructive pattern (COPD/Asthma)", color: C.amber, desc: "Shark fin / slanted plateau — incomplete emptying; no true plateau. PaCO₂–ETCO₂ gradient ↑↑. Suggests air trapping.", icon: "~" },
    { label: "Baseline > 0 (Rebreathing)", color: C.red, desc: "Elevated inspired CO₂. Causes: exhausted CO₂ absorbent, incompetent expiratory valve, inadequate fresh gas flow.", icon: "↑" },
    { label: "Sudden ETCO₂ → 0", color: C.red, desc: "Circuit disconnection, esophageal intubation, cardiac arrest, complete airway obstruction, apnea.", icon: "!" },
    { label: "Gradual ETCO₂ decline", color: C.amber, desc: "Decreasing cardiac output, pulmonary embolism, air embolism, severe hypotension, hyperventilation.", icon: "↓" },
    { label: "Curare cleft (Phase III dip)", color: C.teal, desc: "Spontaneous respiratory effort during controlled ventilation — patient 'biting back' during phase III plateau.", icon: "⌒" },
    { label: "Elevated plateau (Hypoventilation)", color: C.amber, desc: "ETCO₂ >45 mmHg: inadequate ventilator settings, opioid over-sedation, airway obstruction.", icon: "↑" },
  ];

  patterns.forEach((p, i) => {
    const col = i < 3 ? 0 : 1;
    const row = i % 3;
    const x = col === 0 ? 0.4 : 5.05;
    const y = 1.15 + row * 1.38;
    card(s, x, y, 4.5, 1.28, C.bg3);
    badge(s, p.icon, x + 0.1, y + 0.08, p.color);
    s.addText(p.label, { x: x + 0.72, y: y + 0.08, w: 3.7, h: 0.28, fontSize: 10, bold: true, color: p.color, fontFace: "Calibri", margin: 0 });
    s.addText(p.desc, { x: x + 0.1, y: y + 0.42, w: 4.28, h: 0.78, fontSize: 9.5, color: C.white, fontFace: "Calibri", valign: "top" });
  });

  s.addText("Source: Morgan & Mikhail's Clinical Anesthesiology, 7e, Figure 6-3 | Tintinalli's Emergency Medicine", {
    x: 0.4, y: 5.3, w: 9.2, h: 0.2,
    fontSize: 7.5, color: C.silver, italic: true, fontFace: "Calibri",
  });
}

// ─── SLIDE 7: ETT CONFIRMATION ────────────────────────────────────────────────
{
  const s = pres.addSlide();
  cardSlide(s);
  topBar(s);
  sectionTag(s, "Clinical Use");
  slideTitle(s, "Endotracheal Tube Confirmation & Placement");
  divider(s);

  card(s, 0.4, 1.15, 9.2, 0.78, "1A3A5C");
  s.addText("⚠  Waveform capnography is the GOLD STANDARD for confirming ETT placement — mandatory during ALL anesthetic procedures per ASA standards.", {
    x: 0.6, y: 1.22, w: 8.8, h: 0.65,
    fontSize: 12.5, bold: true, color: C.amber, fontFace: "Calibri", valign: "middle",
  });

  const cols = [
    {
      title: "Tracheal Intubation",
      color: C.green,
      items: [
        "Persistent CO₂ waveform with each breath",
        "ETCO₂ 35–45 mmHg after 3–6 breaths",
        "Waveform confirms tracheal placement",
        "Most reliable confirmation method available",
        "Persists even with epinephrine during CPR",
      ],
    },
    {
      title: "Esophageal Intubation",
      color: C.red,
      items: [
        "Initial transient CO₂ from swallowed air",
        "Washes out within 2–4 breaths → zero",
        "Capnograph rapidly & reliably detects this",
        "Must REMOVE tube and reintubate immediately",
        "Do NOT rely on auscultation alone",
      ],
    },
    {
      title: "Mainstem Bronchus",
      color: C.amber,
      items: [
        "Capnography does NOT reliably detect this",
        "ETCO₂ still present but unilateral ventilation",
        "Auscultation + CXR remain necessary",
        "SpO₂ drop may be first clue",
        "Confirm position: pull back ETT slowly",
      ],
    },
  ];
  cols.forEach((c, i) => {
    const x = 0.4 + i * 3.1;
    card(s, x, 2.05, 2.9, 3.15, C.bg3);
    s.addShape(pres.ShapeType.rect, { x, y: 2.05, w: 2.9, h: 0.35, fill: { color: c.color }, line: { color: c.color } });
    s.addText(c.title, { x, y: 2.05, w: 2.9, h: 0.35, fontSize: 11, bold: true, color: C.navy, align: "center", valign: "middle", fontFace: "Calibri", margin: 0 });
    bullets(s, c.items, x + 0.1, 2.45, 2.7, 2.7, { fontSize: 10.5 });
  });

  s.addText("Source: Morgan & Mikhail's Clinical Anesthesiology, 7e, p.227 | ASA Monitoring Standards", {
    x: 0.4, y: 5.3, w: 9.2, h: 0.2,
    fontSize: 7.5, color: C.silver, italic: true, fontFace: "Calibri",
  });
}

// ─── SLIDE 8: CAPNOGRAPHY IN CPR ─────────────────────────────────────────────
{
  const s = pres.addSlide();
  cardSlide(s);
  topBar(s, C.red);
  sectionTag(s, "Resuscitation");
  slideTitle(s, "Capnography in Cardiac Arrest & CPR", "AHA 2020 Guidelines: Continuous waveform capnography for ALL intubated patients");
  divider(s);

  // Fetch CPR capnogram image
  let cprImg = null;
  try {
    const result = JSON.parse(execSync(
      `node /home/daytona/skills/shared/scripts/fetch_images.js "https://cdn.orris.care/cdss_images/350f35fead1f8eaf09cb2344b95c939b89f1408dfc5f5732b87a17d63dd7fb30.png"`,
      { timeout: 30000 }
    ).toString());
    if (result[0] && !result[0].error) cprImg = result[0].base64;
  } catch(e) { /* skip */ }

  if (cprImg) {
    s.addImage({ data: cprImg, x: 0.4, y: 1.15, w: 4.0, h: 2.6 });
  }

  const panels = [
    { title: "ETCO₂ at Cardiac Arrest",  col: C.red,   text: "ETCO₂ falls abruptly at the onset of cardiac arrest due to cessation of pulmonary circulation — CO₂ accumulates in tissues but cannot be exhaled." },
    { title: "During CPR",                col: C.amber, text: "ETCO₂ correlates with cardiac output during CPR. Higher ETCO₂ (>10 mmHg) indicates better compression quality. Target ETCO₂ ≥10–20 mmHg." },
    { title: "ROSC Detection",            col: C.green, text: "Sudden rise in ETCO₂ (>35–40 mmHg) during CPR is a sensitive early indicator of ROSC — often before a palpable pulse." },
    { title: "Termination Guide",         col: C.silver, text: "ETCO₂ persistently <10 mmHg after 20+ min of ACLS correlates with poor survival; can support decision to cease resuscitation (context-dependent)." },
  ];
  panels.forEach((p, i) => {
    const x = 4.6;
    const y = 1.15 + i * 1.08;
    card(s, x, y, 5.0, 0.98, C.bg3);
    s.addShape(pres.ShapeType.rect, { x, y, w: 0.22, h: 0.98, fill: { color: p.col }, line: { color: p.col } });
    s.addText(p.title, { x: x + 0.32, y: y + 0.04, w: 4.6, h: 0.26, fontSize: 10.5, bold: true, color: p.col, fontFace: "Calibri", margin: 0 });
    s.addText(p.text, { x: x + 0.32, y: y + 0.32, w: 4.6, h: 0.62, fontSize: 9.8, color: C.white, fontFace: "Calibri", valign: "top" });
  });

  s.addText("Source: Roberts & Hedges' Clinical Procedures in Emergency Medicine | AHA 2020 ACLS Guidelines", {
    x: 0.4, y: 5.3, w: 9.2, h: 0.2,
    fontSize: 7.5, color: C.silver, italic: true, fontFace: "Calibri",
  });
}

// ─── SLIDE 9: VENTILATOR MANAGEMENT ─────────────────────────────────────────
{
  const s = pres.addSlide();
  cardSlide(s);
  topBar(s);
  sectionTag(s, "Ventilation");
  slideTitle(s, "Capnography in Mechanical Ventilation", "ICU monitoring & ventilator optimization");
  divider(s);

  const items = [
    {
      title: "Confirming Ventilation Adequacy",
      color: C.green,
      points: ["Target ETCO₂ 35–45 mmHg in most patients", "Trend ETCO₂ to guide RR and VT adjustments", "Compare with ABG PaCO₂ — understand the gradient"],
    },
    {
      title: "Detecting Circuit Problems",
      color: C.amber,
      points: ["Sudden ETCO₂ → 0: disconnection or extubation", "Rising baseline CO₂: CO₂ absorbent exhausted", "Incompetent valve: CO₂ in inspired limb"],
    },
    {
      title: "Weaning & Spontaneous Breathing",
      color: C.teal,
      points: ["Rising ETCO₂ during SBT → failing wean", "Curare cleft → return of respiratory drive", "Monitor RR via capnograph during sedation vacation"],
    },
    {
      title: "Protective Lung Ventilation",
      color: C.silver,
      points: ["Permissive hypercapnia: accept ETCO₂ 45–60+", "ARDS: track CO₂ during low VT strategy", "Prone positioning: re-establish ETCO₂ baseline"],
    },
    {
      title: "Malignant Hyperthermia",
      color: C.red,
      points: ["Sudden dramatic ↑ ETCO₂ is earliest sign (before temperature rise)", "Act immediately: stop trigger agent, give dantrolene", "Increase minute ventilation to compensate"],
    },
    {
      title: "Air / Venous Gas Embolism",
      color: C.red,
      points: ["Rapid fall in ETCO₂ — increased dead space + ↓ CO", "Sensitive early indicator in sitting position surgery", "Simultaneously: hypotension, ↑ PAP, 'mill-wheel' murmur"],
    },
  ];

  items.forEach((item, i) => {
    const col = i % 2 === 0 ? 0 : 1;
    const row = Math.floor(i / 2);
    const x = col === 0 ? 0.4 : 5.05;
    const y = 1.15 + row * 1.42;
    card(s, x, y, 4.5, 1.32, C.bg3);
    s.addShape(pres.ShapeType.rect, { x, y, w: 4.5, h: 0.3, fill: { color: item.color }, line: { color: item.color } });
    s.addText(item.title, { x, y, w: 4.5, h: 0.3, fontSize: 10, bold: true, color: C.navy, align: "center", valign: "middle", fontFace: "Calibri", margin: 0 });
    bullets(s, item.points, x + 0.1, y + 0.34, 4.28, 0.94, { fontSize: 10 });
  });

  s.addText("Source: Morgan & Mikhail's Clinical Anesthesiology, 7e | Tintinalli's Emergency Medicine", {
    x: 0.4, y: 5.3, w: 9.2, h: 0.2,
    fontSize: 7.5, color: C.silver, italic: true, fontFace: "Calibri",
  });
}

// ─── SLIDE 10: PROCEDURAL SEDATION ───────────────────────────────────────────
{
  const s = pres.addSlide();
  cardSlide(s);
  topBar(s);
  sectionTag(s, "Sedation");
  slideTitle(s, "Capnography During Procedural Sedation & MAC", "Earlier detection than pulse oximetry");
  divider(s);

  card(s, 0.4, 1.15, 9.2, 0.82, "1A3A5C");
  s.addText([
    { text: "Key Evidence: ", options: { bold: true, color: C.amber } },
    { text: "Waugh et al. meta-analysis — respiratory depression 17.6× more likely to be detected with capnography vs. standard monitoring alone. Apnea episodes >20 seconds NOT detected by provider but detected by capnography (Soto et al.).", options: { color: C.white } },
  ], { x: 0.6, y: 1.22, w: 8.8, h: 0.7, fontSize: 11, fontFace: "Calibri", valign: "middle" });

  const sedCards = [
    {
      title: "Why Pulse Ox Lags",
      col: C.amber,
      text: "Supplemental O₂ delays SpO₂ drop by 4–5 minutes even after complete apnea. SpO₂ alone misses early hypoventilation. Capnography detects airway events 45+ seconds before SpO₂ falls.",
    },
    {
      title: "Nasal Sampling Methods",
      col: C.teal,
      text: "Modified nasal cannula with integrated CO₂ port allows continuous ETCO₂ monitoring in non-intubated patients receiving O₂. IV catheter inserted into face mask also works (Figs. 30-1, 30-2).",
    },
    {
      title: "Clinical Thresholds",
      col: C.green,
      text: "Apnea: ETCO₂ drops to 0. Hypoventilation: ETCO₂ >50 mmHg or apneic episodes. Obstruction: obstructive waveform shape without plateau. Act on capnograph change — do not wait for SpO₂ drop.",
    },
    {
      title: "Guideline Recommendations",
      col: C.silver,
      text: "ACEP Level B recommendation for PSA capnography. Growing consensus for routine use in all moderate-deep sedation. Barash (9e): 'capnography should be utilized in every MAC case' — cost is low, benefit is high.",
    },
  ];
  sedCards.forEach((c, i) => {
    const x = i < 2 ? 0.4 + i * 4.65 : 0.4 + (i - 2) * 4.65;
    const y = i < 2 ? 2.1 : 3.6;
    card(s, x, y, 4.45, 1.38, C.bg3);
    s.addShape(pres.ShapeType.rect, { x, y, w: 4.45, h: 0.3, fill: { color: c.col }, line: { color: c.col } });
    s.addText(c.title, { x, y, w: 4.45, h: 0.3, fontSize: 10.5, bold: true, color: C.navy, align: "center", valign: "middle", fontFace: "Calibri", margin: 0 });
    s.addText(c.text, { x: x + 0.1, y: y + 0.34, w: 4.25, h: 1.0, fontSize: 10, color: C.white, fontFace: "Calibri", valign: "top" });
  });

  s.addText("Source: Barash Clinical Anesthesia, 9e | Roberts & Hedges' Clinical Procedures | Waugh et al. meta-analysis", {
    x: 0.4, y: 5.3, w: 9.2, h: 0.2,
    fontSize: 7.5, color: C.silver, italic: true, fontFace: "Calibri",
  });
}

// ─── SLIDE 11: DEAD SPACE ─────────────────────────────────────────────────────
{
  const s = pres.addSlide();
  cardSlide(s);
  topBar(s);
  sectionTag(s, "Physiology");
  slideTitle(s, "Dead Space & the PaCO₂–ETCO₂ Gradient", "Understanding when the gradient matters most");
  divider(s);

  // Equation display
  card(s, 0.4, 1.15, 9.2, 0.72, C.bg3);
  s.addText([
    { text: "PaCO₂ − ETCO₂ = ", options: { color: C.silver } },
    { text: "Alveolar Dead Space Effect", options: { bold: true, color: C.amber } },
    { text: "   |   Normal: 2–5 mmHg   |   Widened gradient: ↑ dead space or ↓ perfusion", options: { color: C.silver } },
  ], { x: 0.6, y: 1.22, w: 8.8, h: 0.58, fontSize: 12, fontFace: "Calibri", valign: "middle", align: "center" });

  const dsData = [
    { label: "Anatomical Dead Space",  col: C.teal,   text: "Conducting airways (≈2 mL/kg). ETCO₂ phase I reflects this. Increased by tracheostomy, ETT connector dead space." },
    { label: "Alveolar Dead Space",    col: C.amber,  text: "Ventilated but non-perfused alveoli. Normal ≈0. Increases with PE, ↓CO, air embolism, ARDS — widens PaCO₂–ETCO₂ gradient." },
    { label: "Physiological Dead Space", col: C.green, text: "Sum of anatomical + alveolar. Elevated in shock, PE, COPD. Measured by Bohr equation: Vd/Vt = (PaCO₂ − PECO₂) / PaCO₂." },
  ];
  dsData.forEach((d, i) => {
    card(s, 0.4 + i * 3.1, 2.0, 2.9, 1.6, C.bg3);
    s.addShape(pres.ShapeType.rect, { x: 0.4 + i * 3.1, y: 2.0, w: 2.9, h: 0.32, fill: { color: d.col }, line: { color: d.col } });
    s.addText(d.label, { x: 0.4 + i * 3.1, y: 2.0, w: 2.9, h: 0.32, fontSize: 10, bold: true, color: C.navy, align: "center", valign: "middle", fontFace: "Calibri", margin: 0 });
    s.addText(d.text, { x: 0.5 + i * 3.1, y: 2.36, w: 2.7, h: 1.2, fontSize: 10, color: C.white, fontFace: "Calibri", valign: "top" });
  });

  // Clinical table
  card(s, 0.4, 3.75, 9.2, 1.42, C.bg3);
  cardTitle(s, "Clinical Causes of Widened PaCO₂–ETCO₂ Gradient", 0.55, 3.82, 9.0, C.teal);
  const causes = [
    ["Pulmonary Embolism", "Air Embolism", "Severe Hypotension", "Cardiac Arrest"],
    ["ARDS / ALI", "COPD (obstructed phase III)", "Prone Positioning", "Reduced CO from any cause"],
  ];
  causes.forEach((row, ri) => {
    row.forEach((cell, ci) => {
      s.addText("• " + cell, {
        x: 0.55 + ci * 2.25, y: 4.12 + ri * 0.42, w: 2.2, h: 0.38,
        fontSize: 10, color: C.white, fontFace: "Calibri",
      });
    });
  });

  s.addText("Source: Morgan & Mikhail's Clinical Anesthesiology, 7e | ROSEN's Emergency Medicine", {
    x: 0.4, y: 5.3, w: 9.2, h: 0.2,
    fontSize: 7.5, color: C.silver, italic: true, fontFace: "Calibri",
  });
}

// ─── SLIDE 12: SPECIAL POPULATIONS ───────────────────────────────────────────
{
  const s = pres.addSlide();
  cardSlide(s);
  topBar(s);
  sectionTag(s, "Special Populations");
  slideTitle(s, "Special Populations & Settings");
  divider(s);

  const pops = [
    {
      title: "Pediatrics",
      icon: "P",
      col: C.teal,
      items: [
        "High aspiration rate may dilute ETCO₂ (sidestream) — use low dead-space sampling",
        "Small VT: sidestream aspiration may pull fresh gas → underestimate ETCO₂",
        "Mainstream sensors may be too heavy for small airways",
        "Functional residual capacity lower → faster desaturation; capnography even more critical",
        "Apnea detection in neonates/NICU: nasal capnography highly sensitive",
      ],
    },
    {
      title: "Obstetrics",
      icon: "O",
      col: C.green,
      items: [
        "Pregnancy: baseline ETCO₂ lower (28–32 mmHg) due to progesterone-driven hyperventilation",
        "Rapid sequence induction: capnography immediately post-intubation mandatory",
        "Difficult airway risk higher — cannot rely on auscultation alone",
        "Failed intubation scenario: capnography confirms supraglottic device ventilation",
      ],
    },
    {
      title: "Bariatrics",
      icon: "B",
      col: C.amber,
      items: [
        "Increased risk of hypoventilation under sedation",
        "Pulse oximetry more prone to delay in this population",
        "Sidestream cannula during MAC/moderate sedation essential",
        "ETCO₂ trending helps guide PEEP and VT adjustments",
      ],
    },
    {
      title: "Non-OR Settings",
      icon: "N",
      col: C.silver,
      items: [
        "Endoscopy, MRI, radiology suites: sidestream nasal capnography",
        "ICU transport: continuous waveform confirms ETT position",
        "Emergency department: confirm tube placement, monitor PSA",
        "Prehospital / EMS: ETCO₂ guides CPR quality in field",
      ],
    },
  ];
  pops.forEach((p, i) => {
    const x = i < 2 ? 0.4 + i * 4.65 : 0.4 + (i - 2) * 4.65;
    const y = i < 2 ? 1.15 : 3.32;
    card(s, x, y, 4.45, 2.05, C.bg3);
    s.addShape(pres.ShapeType.rect, { x, y, w: 4.45, h: 0.32, fill: { color: p.col }, line: { color: p.col } });
    badge(s, p.icon, x + 0.1, y + 0.02, C.navy);
    s.addText(p.title, { x: x + 0.72, y: y, w: 3.65, h: 0.32, fontSize: 11, bold: true, color: C.navy, valign: "middle", fontFace: "Calibri", margin: 0 });
    bullets(s, p.items, x + 0.1, y + 0.38, 4.25, 1.62, { fontSize: 9.8 });
  });

  s.addText("Source: Barash Clinical Anesthesia, 9e | Roberts & Hedges' Clinical Procedures", {
    x: 0.4, y: 5.3, w: 9.2, h: 0.2,
    fontSize: 7.5, color: C.silver, italic: true, fontFace: "Calibri",
  });
}

// ─── SLIDE 13: TROUBLESHOOTING ────────────────────────────────────────────────
{
  const s = pres.addSlide();
  cardSlide(s);
  topBar(s);
  sectionTag(s, "Troubleshooting");
  slideTitle(s, "Systematic Troubleshooting Guide", "When something looks wrong — is it the patient or the equipment?");
  divider(s);

  card(s, 0.4, 1.15, 9.2, 0.55, C.bg3);
  s.addText("Systematic approach: Check PATIENT first → then EQUIPMENT. Do NOT assume an equipment problem until patient causes are excluded.", {
    x: 0.6, y: 1.2, w: 8.8, h: 0.45, fontSize: 11.5, bold: true, color: C.amber, fontFace: "Calibri", valign: "middle",
  });

  const rows = [
    { finding: "ETCO₂ = 0 (sudden)", patient: "Cardiac arrest, complete airway obstruction, bronchospasm, tension pneumothorax", equip: "Circuit disconnection, kinked ETT, blocked sampling line, sensor failure" },
    { finding: "ETCO₂ trending up", patient: "Hypoventilation, MH, sepsis, fever, CO₂ reabsorption", equip: "Partial obstruction of sampling line, water trap full" },
    { finding: "ETCO₂ trending down", patient: "Hyperventilation, ↓CO, PE, air embolism, hypothermia", equip: "Leak in circuit, sidestream over-aspiration (pediatrics)" },
    { finding: "Elevated inspired CO₂ (baseline >0)", patient: "None — this is almost always equipment", equip: "Exhausted CO₂ absorbent, incompetent expiratory valve, inadequate fresh gas flow" },
    { finding: "Shark-fin waveform", patient: "Bronchospasm, COPD exacerbation, mucus plug, secretions", equip: "Kinked or obstructed ETT, water in sampling line" },
    { finding: "Inconsistent/noisy waveform", patient: "Hiccoughs, patient movement, spontaneous breathing effort", equip: "Water precipitation in tubing, loose sampling connection" },
  ];

  // Table header
  const hdr = ["Finding", "Patient Cause", "Equipment Cause"];
  const colW = [2.6, 3.3, 3.3];
  const colX = [0.4, 3.05, 6.4];
  hdr.forEach((h, i) => {
    s.addShape(pres.ShapeType.rect, { x: colX[i], y: 1.78, w: colW[i], h: 0.28, fill: { color: C.teal }, line: { color: C.teal } });
    s.addText(h, { x: colX[i], y: 1.78, w: colW[i], h: 0.28, fontSize: 9.5, bold: true, color: C.navy, align: "center", valign: "middle", fontFace: "Calibri", margin: 0 });
  });
  rows.forEach((r, i) => {
    const bg = i % 2 === 0 ? C.bg3 : C.navy;
    const y = 2.1 + i * 0.52;
    const cells = [r.finding, r.patient, r.equip];
    cells.forEach((cell, j) => {
      s.addShape(pres.ShapeType.rect, { x: colX[j], y, w: colW[j], h: 0.5, fill: { color: bg }, line: { color: C.bg3 } });
      s.addText(cell, { x: colX[j] + 0.05, y, w: colW[j] - 0.1, h: 0.5, fontSize: 8.8, color: j === 0 ? C.amber : C.white, fontFace: "Calibri", valign: "middle", bold: j === 0 });
    });
  });

  s.addText("Source: Morgan & Mikhail's Clinical Anesthesiology, 7e | Roberts & Hedges' Clinical Procedures", {
    x: 0.4, y: 5.3, w: 9.2, h: 0.2,
    fontSize: 7.5, color: C.silver, italic: true, fontFace: "Calibri",
  });
}

// ─── SLIDE 14: ETCO₂ AS PROGNOSTIC TOOL ──────────────────────────────────────
{
  const s = pres.addSlide();
  cardSlide(s);
  topBar(s, C.amber);
  sectionTag(s, "Prognosis");
  slideTitle(s, "ETCO₂ as a Prognostic & Diagnostic Tool");
  divider(s);

  const cards4 = [
    {
      title: "CPR Quality Indicator",
      col: C.green,
      body: "ETCO₂ positively correlates with: cardiac output, coronary perfusion pressure, compression efficacy, ROSC likelihood, and survival. Target >10 mmHg during CPR; aim for >20 mmHg with good technique.",
    },
    {
      title: "Pulmonary Embolism",
      col: C.amber,
      body: "Acute PE increases dead space → ETCO₂ drops. The PaCO₂–ETCO₂ gradient widens. Clinical context: sudden hypotension + ETCO₂ drop → initiate PE workup. Not diagnostic alone but supports suspicion.",
    },
    {
      title: "Malignant Hyperthermia",
      col: C.red,
      body: "Sudden unexplained rise in ETCO₂ is the EARLIEST sign of MH — precedes temperature rise. Immediately: discontinue volatile agent, hyperventilate, give dantrolene 2.5 mg/kg IV (up to 10 mg/kg).",
    },
    {
      title: "Termination of Resuscitation",
      col: C.silver,
      body: "ETCO₂ <10 mmHg after 20 minutes of ACLS is associated with near-zero survival in unwitnessed arrest. Consider as one factor (not sole criterion) in termination decision. AHA 2020 supports this use.",
    },
  ];
  cards4.forEach((c, i) => {
    const x = i < 2 ? 0.4 + i * 4.65 : 0.4 + (i - 2) * 4.65;
    const y = i < 2 ? 1.15 : 3.2;
    card(s, x, y, 4.45, 1.88, C.bg3);
    s.addShape(pres.ShapeType.rect, { x, y, w: 4.45, h: 0.32, fill: { color: c.col }, line: { color: c.col } });
    s.addText(c.title, { x, y, w: 4.45, h: 0.32, fontSize: 11, bold: true, color: C.navy, align: "center", valign: "middle", fontFace: "Calibri", margin: 0 });
    s.addText(c.body, { x: x + 0.1, y: y + 0.38, w: 4.25, h: 1.45, fontSize: 10, color: C.white, fontFace: "Calibri", valign: "top" });
  });

  s.addText("Source: Roberts & Hedges' p.415 | AHA 2020 ACLS Guidelines | Morgan & Mikhail's Clinical Anesthesiology, 7e", {
    x: 0.4, y: 5.3, w: 9.2, h: 0.2,
    fontSize: 7.5, color: C.silver, italic: true, fontFace: "Calibri",
  });
}

// ─── SLIDE 15: NON-INTUBATED MONITORING ───────────────────────────────────────
{
  const s = pres.addSlide();
  cardSlide(s);
  topBar(s);
  sectionTag(s, "Non-Intubated");
  slideTitle(s, "Capnography in Non-Intubated Patients", "Monitoring ventilation without an airway device");
  divider(s);

  card(s, 0.4, 1.15, 9.2, 0.65, C.bg3);
  s.addText("Impedance-based respiratory monitoring detects chest wall movement — NOT airflow. In obstructive apnea or laryngospasm, chest wall still moves, but NO ventilation occurs. Capnography provides DIRECT airway-based respiratory rate.", {
    x: 0.6, y: 1.2, w: 8.8, h: 0.55, fontSize: 11, color: C.amber, fontFace: "Calibri", valign: "middle",
  });

  const methods = [
    { m: "Nasal Cannula O₂/CO₂", d: "Dual-purpose cannula: delivers O₂ + samples CO₂. Most common method for MAC/procedural sedation. Waveform quality good in cooperative patients. Respiratory rate accurate.", c: C.teal },
    { m: "Face Mask Adapter",     d: "IV catheter or sampling port inserted into face mask. Good for patients with mouth breathing or high O₂ requirements. Slightly diluted ETCO₂ but adequate for trend monitoring.", c: C.green },
    { m: "Oral-Nasal Cannula",    d: "Samples both oral and nasal airflow. More accurate in mouth-breathers. Provides true airway CO₂ regardless of route. Preferred for deep sedation cases.", c: C.amber },
    { m: "Tracheostomy Adapter",  d: "Sampling line attached to trach tube connector. Direct airway measurement. Minimal dilution. Standard approach for trach-dependent ICU patients.", c: C.silver },
  ];
  methods.forEach((m, i) => {
    const x = i < 2 ? 0.4 + i * 4.65 : 0.4 + (i - 2) * 4.65;
    const y = i < 2 ? 1.92 : 3.58;
    card(s, x, y, 4.45, 1.52, C.bg3);
    s.addShape(pres.ShapeType.rect, { x, y, w: 4.45, h: 0.3, fill: { color: m.c }, line: { color: m.c } });
    s.addText(m.m, { x, y, w: 4.45, h: 0.3, fontSize: 10.5, bold: true, color: C.navy, align: "center", valign: "middle", fontFace: "Calibri", margin: 0 });
    s.addText(m.d, { x: x + 0.1, y: y + 0.35, w: 4.25, h: 1.14, fontSize: 10, color: C.white, fontFace: "Calibri", valign: "top" });
  });

  s.addText("Source: Barash Clinical Anesthesia, 9e, pp.2492–2493 | Roberts & Hedges' Clinical Procedures", {
    x: 0.4, y: 5.3, w: 9.2, h: 0.2,
    fontSize: 7.5, color: C.silver, italic: true, fontFace: "Calibri",
  });
}

// ─── SLIDE 16: QUICK REFERENCE GUIDE ─────────────────────────────────────────
{
  const s = pres.addSlide();
  cardSlide(s);
  topBar(s, C.green);
  sectionTag(s, "Quick Reference");
  slideTitle(s, "Quick Reference: ETCO₂ Values at a Glance");
  divider(s);

  const valueRows = [
    { range: "35–45 mmHg",  label: "NORMAL",         col: C.green,  meaning: "Adequate ventilation & perfusion" },
    { range: "<35 mmHg",    label: "LOW / HYPER",     col: C.teal,   meaning: "Hyperventilation, PE, ↓CO, hypothermia" },
    { range: ">45 mmHg",    label: "HIGH / HYPO",     col: C.amber,  meaning: "Hypoventilation, MH, fever, obstruction" },
    { range: "= 0",         label: "CRITICAL",        col: C.red,    meaning: "Apnea, cardiac arrest, circuit disconnect, esophageal intubation" },
    { range: ">10 mmHg",    label: "CPR TARGET",      col: C.green,  meaning: "Minimum acceptable ETCO₂ during CPR — suggests adequate compressions" },
    { range: "<10 mmHg",    label: "POOR CPR / POOR Px", col: C.red, meaning: "Poor compression quality or futile resuscitation (>20 min ACLS)" },
    { range: "Sudden rise", label: "ROSC",            col: C.green,  meaning: "Abrupt jump in ETCO₂ during CPR → Return of spontaneous circulation" },
    { range: "28–32 mmHg",  label: "PREGNANCY",       col: C.teal,   meaning: "Normal baseline in pregnancy — progesterone-driven hyperventilation" },
  ];

  valueRows.forEach((r, i) => {
    const y = 1.15 + i * 0.54;
    s.addShape(pres.ShapeType.rect, { x: 0.4, y, w: 1.9, h: 0.46, fill: { color: r.col }, line: { color: r.col } });
    s.addText(r.range, { x: 0.4, y, w: 1.9, h: 0.46, fontSize: 11.5, bold: true, color: C.navy, align: "center", valign: "middle", fontFace: "Calibri", margin: 0 });

    s.addShape(pres.ShapeType.rect, { x: 2.35, y, w: 1.9, h: 0.46, fill: { color: C.bg3 }, line: { color: r.col } });
    s.addText(r.label, { x: 2.35, y, w: 1.9, h: 0.46, fontSize: 10, bold: true, color: r.col, align: "center", valign: "middle", fontFace: "Calibri", margin: 0 });

    s.addShape(pres.ShapeType.rect, { x: 4.3, y, w: 5.3, h: 0.46, fill: { color: C.bg3 }, line: { color: C.bg3 } });
    s.addText(r.meaning, { x: 4.4, y, w: 5.1, h: 0.46, fontSize: 10.5, color: C.white, fontFace: "Calibri", valign: "middle" });
  });

  s.addText("Source: Morgan & Mikhail's Clinical Anesthesiology, 7e | AHA 2020 | Barash Clinical Anesthesia, 9e | Roberts & Hedges'", {
    x: 0.4, y: 5.3, w: 9.2, h: 0.2,
    fontSize: 7.5, color: C.silver, italic: true, fontFace: "Calibri",
  });
}

// ─── SLIDE 17: KEY CLINICAL PEARLS ───────────────────────────────────────────
{
  const s = pres.addSlide();
  cardSlide(s);
  topBar(s, C.amber);
  sectionTag(s, "Clinical Pearls");
  slideTitle(s, "10 Clinical Pearls for Practice");
  divider(s);

  const pearls = [
    "Capnography is the gold standard for ETT confirmation — not auscultation, not chest rise.",
    "A transient CO₂ trace (2–4 breaths) after intubation does NOT confirm tracheal placement — always watch for persistence.",
    "In patients on supplemental O₂, SpO₂ may take 4–5 minutes to drop after apnea. Capnography detects apnea immediately.",
    "The PaCO₂–ETCO₂ gradient is normally 2–5 mmHg. Widening suggests dead space (PE, ↓CO, air embolism).",
    "Sudden unexplained rise in ETCO₂ during anesthesia = malignant hyperthermia until proven otherwise.",
    "A sudden drop of ETCO₂ to zero during stable ventilation = circuit disconnection (or cardiac arrest) until proven otherwise.",
    "ETCO₂ during CPR reflects cardiac output — use it as a compression quality metric and early ROSC detector.",
    "In COPD/asthma, a slanted 'shark fin' phase III means no reliable plateau — ETCO₂ may significantly underestimate PaCO₂.",
    "An elevated CO₂ baseline (inspired CO₂ >0) is almost always equipment: check absorbent, valve, and fresh gas flow.",
    "Normal ETCO₂ does NOT rule out pathology — always interpret in clinical context with ABG when uncertain.",
  ];
  pearls.forEach((p, i) => {
    const y = 1.15 + i * 0.42;
    badge(s, `${i + 1}`, 0.4, y, C.amber);
    s.addText(p, { x: 1.0, y, w: 8.6, h: 0.35, fontSize: 10.5, color: C.white, fontFace: "Calibri", valign: "middle" });
  });
}

// ─── SLIDE 18: SUMMARY ────────────────────────────────────────────────────────
{
  const s = pres.addSlide();
  darkSlide(s);
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.35, h: 5.625, fill: { color: C.teal }, line: { color: C.teal } });

  s.addText("Summary", { x: 0.6, y: 0.3, w: 9, h: 0.5, fontSize: 11, color: C.teal, bold: true, charSpacing: 3, fontFace: "Calibri" });
  s.addText("Capnography at a Glance", { x: 0.6, y: 0.78, w: 9, h: 0.55, fontSize: 26, bold: true, color: C.white, fontFace: "Calibri" });
  s.addShape(pres.ShapeType.line, { x: 0.6, y: 1.38, w: 3.5, h: 0, line: { color: C.amber, width: 2.5 } });

  const summaryPoints = [
    { icon: "◆", col: C.teal,  text: "Measure CO₂ continuously — it reflects ventilation, perfusion, and metabolism simultaneously." },
    { icon: "◆", col: C.green, text: "ETCO₂ is mandatory in ALL intubated patients: OR, ICU, transport, resuscitation." },
    { icon: "◆", col: C.amber, text: "Waveform analysis is superior to numeric value alone — shape tells the full story." },
    { icon: "◆", col: C.teal,  text: "In non-intubated patients, capnography detects hypoventilation earlier than pulse oximetry." },
    { icon: "◆", col: C.red,   text: "During CPR, ETCO₂ > 10 mmHg = adequate compressions; sudden rise = ROSC." },
    { icon: "◆", col: C.green, text: "Equipment artifacts and patient pathology can produce identical findings — think both." },
  ];

  summaryPoints.forEach((p, i) => {
    s.addText(p.icon, { x: 0.6, y: 1.55 + i * 0.58, w: 0.3, h: 0.42, fontSize: 13, color: p.col, fontFace: "Calibri", valign: "middle", margin: 0 });
    s.addText(p.text, { x: 0.98, y: 1.55 + i * 0.58, w: 8.6, h: 0.45, fontSize: 12, color: C.white, fontFace: "Calibri", valign: "middle" });
  });

  s.addText("Presented by Orris  |  Sources: Morgan & Mikhail 7e | Barash 9e | Roberts & Hedges' | Tintinalli's | AHA 2020", {
    x: 0.6, y: 5.28, w: 9.0, h: 0.22, fontSize: 7.5, color: C.silver, fontFace: "Calibri",
  });
}

// ─── WRITE FILE ───────────────────────────────────────────────────────────────
pres.writeFile({ fileName: "/home/daytona/workspace/capnography-pptx/Capnography_ICU_Anesthesia.pptx" })
  .then(() => console.log("DONE: Capnography_ICU_Anesthesia.pptx"))
  .catch(e => { console.error("ERROR:", e); process.exit(1); });
Running Command

cd /home/daytona/workspace/capnography-pptx && node build_capno.js 2>&1

Running Command

ls -lh /home/daytona/workspace/capnography-pptx/Capnography_ICU_Anesthesia.pptx

Your presentation is ready:

Capnography ICU Anesthesia

Presentation · PPTX


18 slides built from authoritative sources (Morgan & Mikhail's Clinical Anesthesiology 7e, Barash Clinical Anesthesia 9e, Roberts & Hedges' Clinical Procedures, Tintinalli's Emergency Medicine, AHA 2020 ACLS Guidelines). Dark navy/teal color scheme designed for clinical audiences.
Slide structure:
#Slide
1Title slide with topic index
2What is Capnography? (definitions: capnometry vs capnography vs capnogram)
3Physics & Technology (Beer-Lambert law, mainstream vs sidestream)
4The Normal Capnogram — 4 phases with textbook waveform diagram
5CO₂ Physiology & ETCO₂-PaCO₂ relationship
6Abnormal Waveform Patterns (6 patterns with clinical significance)
7ETT Confirmation (tracheal vs esophageal vs mainstem)
8Capnography in CPR & Cardiac Arrest (with CPR capnogram image)
9Mechanical Ventilation — ventilator management, MH, air embolism
10Procedural Sedation & MAC (meta-analysis evidence, threshold guidance)
11Dead Space & the PaCO₂-ETCO₂ gradient
12Special Populations (pediatrics, obstetrics, bariatrics, non-OR)
13Systematic Troubleshooting Table (patient vs equipment causes)
14ETCO₂ as Prognostic Tool (CPR quality, PE, MH, termination)
15Non-Intubated Monitoring (nasal cannula, mask, trach adapters)
16Quick Reference Table (ETCO₂ values & meanings at a glance)
1710 Clinical Pearls
18Summary slide
This is a shared conversation. Sign in to Orris to start your own chat.