Create complete presentation on capnographs

Asking for Preferences
Reading File
Finding Sources
Searching the Web

capnography ICU anesthesia waveform interpretation clinical uses 2024

Reading File
Finding Sources
Reading Web Page

https://resources.wfsahq.org/wp-content/uploads/ATOTW534.pdf

Reading File
Reading File
Reading File
Running Command

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

Writing File

~/capnography-pptx/build.js

const pptxgen = require("pptxgenjs");

const pres = new pptxgen();
pres.layout = "LAYOUT_16x9";
pres.author = "Orris Medical";
pres.title = "Capnography: Advanced Clinical Applications";

// ─── PALETTE ────────────────────────────────────────────────────────────────
const DARK   = "0A1628";   // dominant deep navy
const MID    = "122B4F";   // supporting navy
const ACCENT = "00C9A7";   // teal accent
const GOLD   = "F4A261";   // warm alert/highlight
const WHITE  = "FFFFFF";
const LGRAY  = "D0E4F7";   // light blue-gray
const RED    = "E63946";
const GREEN  = "2DC653";
const YELLOW = "FFD166";

// ─── HELPER FUNCTIONS ───────────────────────────────────────────────────────
function titleSlide(pres) {
  const slide = pres.addSlide();
  // Full dark background
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: DARK } });
  // Accent bar left
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.18, h: 5.625, fill: { color: ACCENT } });
  // Decorative circle
  slide.addShape(pres.ShapeType.ellipse, { x: 7.2, y: -0.8, w: 4.5, h: 4.5, fill: { color: MID }, line: { color: MID } });
  slide.addShape(pres.ShapeType.ellipse, { x: 7.8, y: -0.3, w: 3.3, h: 3.3, fill: { color: ACCENT }, line: { color: ACCENT }, transparency: 80 });

  // CO2 symbol large watermark
  slide.addText("CO₂", { x: 6.8, y: 0.6, w: 3, h: 2, fontSize: 96, color: ACCENT, bold: true, align: "center", transparency: 70 });

  slide.addText("CAPNOGRAPHY", {
    x: 0.5, y: 1.1, w: 7, h: 0.9,
    fontSize: 44, bold: true, color: ACCENT, charSpacing: 8, margin: 0
  });
  slide.addText("Advanced Clinical Applications for ICU & Anesthesia", {
    x: 0.5, y: 2.05, w: 7.5, h: 0.6,
    fontSize: 18, color: LGRAY, italic: true, margin: 0
  });
  // Divider line
  slide.addShape(pres.ShapeType.rect, { x: 0.5, y: 2.8, w: 4, h: 0.04, fill: { color: ACCENT } });
  slide.addText("Principles • Waveforms • Pathophysiology • Clinical Decision-Making", {
    x: 0.5, y: 2.95, w: 8, h: 0.45,
    fontSize: 13, color: LGRAY, margin: 0
  });
  slide.addText("Barash Clinical Anesthesia 9e  |  WFSA ATOTW 534  |  AHA Guidelines 2020", {
    x: 0.5, y: 5.0, w: 9, h: 0.4,
    fontSize: 10, color: "6B8CAE", italic: true, margin: 0
  });
  return slide;
}

function sectionDivider(pres, number, title, subtitle) {
  const slide = pres.addSlide();
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: MID } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.18, h: 5.625, fill: { color: ACCENT } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 2.3, w: 10, h: 0.05, fill: { color: ACCENT }, transparency: 60 });
  slide.addText(number, {
    x: 0.5, y: 0.7, w: 1.4, h: 1.4,
    fontSize: 72, bold: true, color: ACCENT, align: "center", margin: 0, transparency: 30
  });
  slide.addText(title, {
    x: 0.5, y: 2.0, w: 9, h: 0.9,
    fontSize: 36, bold: true, color: WHITE, margin: 0
  });
  slide.addText(subtitle, {
    x: 0.5, y: 3.0, w: 9, h: 0.7,
    fontSize: 16, color: LGRAY, italic: true, margin: 0
  });
  return slide;
}

function contentSlide(pres, title, bullets, options = {}) {
  const slide = pres.addSlide();
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: DARK } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 1.0, fill: { color: MID } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0.95, w: 10, h: 0.06, fill: { color: ACCENT } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.18, h: 5.625, fill: { color: ACCENT } });

  slide.addText(title, {
    x: 0.4, y: 0.12, w: 9.2, h: 0.75,
    fontSize: 22, bold: true, color: WHITE, valign: "middle", margin: 0
  });

  const bulletItems = bullets.map((b, i) => {
    if (typeof b === "string") {
      return [
        { text: "▸  ", options: { color: ACCENT, bold: true, fontSize: 13 } },
        { text: b, options: { color: LGRAY, fontSize: 13, breakLine: i < bullets.length - 1 } }
      ];
    } else {
      // { text, sub } format
      return [
        { text: "▸  ", options: { color: ACCENT, bold: true, fontSize: 13 } },
        { text: b.text, options: { color: WHITE, fontSize: 13, bold: true, breakLine: true } },
        { text: "    " + b.sub, options: { color: "8BAAC8", fontSize: 11.5, breakLine: i < bullets.length - 1 } }
      ];
    }
  }).flat();

  slide.addText(bulletItems, {
    x: 0.4, y: 1.1, w: options.w || 9.2, h: 4.3,
    valign: "top", lineSpacingMultiple: 1.35, margin: [0, 0, 0, 8]
  });

  if (options.note) {
    slide.addShape(pres.ShapeType.rect, { x: 0.4, y: 4.9, w: 9.2, h: 0.5, fill: { color: "0D2240" }, rounding: true });
    slide.addText("⚑  " + options.note, {
      x: 0.5, y: 4.92, w: 9, h: 0.42,
      fontSize: 10, color: GOLD, italic: true, valign: "middle", margin: 0
    });
  }
  return slide;
}

function twoColSlide(pres, title, col1Title, col1Items, col2Title, col2Items, col1Color = ACCENT, col2Color = GOLD) {
  const slide = pres.addSlide();
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: DARK } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 1.0, fill: { color: MID } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0.95, w: 10, h: 0.06, fill: { color: ACCENT } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.18, h: 5.625, fill: { color: ACCENT } });
  slide.addText(title, { x: 0.4, y: 0.12, w: 9.2, h: 0.75, fontSize: 22, bold: true, color: WHITE, valign: "middle", margin: 0 });

  // Col 1
  slide.addShape(pres.ShapeType.rect, { x: 0.4, y: 1.1, w: 4.4, h: 4.2, fill: { color: "0D2240" }, rounding: true });
  slide.addText(col1Title, { x: 0.5, y: 1.15, w: 4.2, h: 0.45, fontSize: 14, bold: true, color: col1Color, margin: 0 });
  const c1 = col1Items.map((t, i) => [
    { text: "•  ", options: { color: col1Color, bold: true, fontSize: 12 } },
    { text: t, options: { color: LGRAY, fontSize: 12, breakLine: i < col1Items.length - 1 } }
  ]).flat();
  slide.addText(c1, { x: 0.5, y: 1.65, w: 4.1, h: 3.4, valign: "top", lineSpacingMultiple: 1.35, margin: 0 });

  // Col 2
  slide.addShape(pres.ShapeType.rect, { x: 5.2, y: 1.1, w: 4.4, h: 4.2, fill: { color: "0D2240" }, rounding: true });
  slide.addText(col2Title, { x: 5.3, y: 1.15, w: 4.2, h: 0.45, fontSize: 14, bold: true, color: col2Color, margin: 0 });
  const c2 = col2Items.map((t, i) => [
    { text: "•  ", options: { color: col2Color, bold: true, fontSize: 12 } },
    { text: t, options: { color: LGRAY, fontSize: 12, breakLine: i < col2Items.length - 1 } }
  ]).flat();
  slide.addText(c2, { x: 5.3, y: 1.65, w: 4.1, h: 3.4, valign: "top", lineSpacingMultiple: 1.35, margin: 0 });

  return slide;
}

function waveformSlide(pres) {
  const slide = pres.addSlide();
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: DARK } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 1.0, fill: { color: MID } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0.95, w: 10, h: 0.06, fill: { color: ACCENT } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.18, h: 5.625, fill: { color: ACCENT } });
  slide.addText("The Normal Capnogram: Four Phases", {
    x: 0.4, y: 0.12, w: 9.2, h: 0.75, fontSize: 22, bold: true, color: WHITE, valign: "middle", margin: 0
  });

  // Y-axis label
  slide.addText("PaCO₂\n(mmHg)", { x: 0.22, y: 1.5, w: 0.9, h: 1.0, fontSize: 9, color: LGRAY, align: "center", margin: 0 });

  // Waveform canvas background
  slide.addShape(pres.ShapeType.rect, { x: 1.0, y: 1.1, w: 6.2, h: 3.4, fill: { color: "061120" }, rounding: false });

  // Grid lines (horizontal)
  for (let i = 0; i < 5; i++) {
    const y = 1.1 + i * 0.68;
    slide.addShape(pres.ShapeType.line, { x: 1.0, y, w: 6.2, h: 0, line: { color: "1A3D5C", width: 0.5 } });
  }
  // Y-axis values
  ["50","40","30","20","10","0"].forEach((v, i) => {
    slide.addText(v, { x: 0.5, y: 1.0 + i * 0.56, w: 0.45, h: 0.3, fontSize: 9, color: "6B8CAE", align: "right", margin: 0 });
  });

  // Capnogram waveform drawn with lines — one full breath cycle + partial second
  // Phase I (baseline) → Phase II (steep rise) → Phase III (plateau) → Phase IV (drop inspiration)
  const waveColor = ACCENT;
  const lw = 3;

  // Breath 1
  // Phase I: baseline 0
  slide.addShape(pres.ShapeType.line, { x: 1.1, y: 4.3, w: 0.5, h: 0, line: { color: waveColor, width: lw } });
  // Phase II: steep rise to ~40mmHg
  slide.addShape(pres.ShapeType.line, { x: 1.6, y: 4.3, w: 0.25, h: -2.0, line: { color: waveColor, width: lw } });
  // Phase III: alveolar plateau (slight slope up)
  slide.addShape(pres.ShapeType.line, { x: 1.85, y: 2.3, w: 1.2, h: -0.15, line: { color: waveColor, width: lw } });
  // D point — ETCO2 peak
  slide.addShape(pres.ShapeType.ellipse, { x: 3.0, y: 2.1, w: 0.12, h: 0.12, fill: { color: GOLD }, line: { color: GOLD } });
  // Phase IV (0): steep drop back to 0
  slide.addShape(pres.ShapeType.line, { x: 3.05, y: 2.15, w: 0.25, h: 2.15, line: { color: waveColor, width: lw } });
  // Next Phase I
  slide.addShape(pres.ShapeType.line, { x: 3.3, y: 4.3, w: 0.6, h: 0, line: { color: waveColor, width: lw } });
  // Breath 2
  slide.addShape(pres.ShapeType.line, { x: 3.9, y: 4.3, w: 0.25, h: -2.0, line: { color: waveColor, width: lw } });
  slide.addShape(pres.ShapeType.line, { x: 4.15, y: 2.3, w: 1.2, h: -0.15, line: { color: waveColor, width: lw } });
  slide.addShape(pres.ShapeType.ellipse, { x: 5.3, y: 2.1, w: 0.12, h: 0.12, fill: { color: GOLD }, line: { color: GOLD } });
  slide.addShape(pres.ShapeType.line, { x: 5.35, y: 2.15, w: 0.25, h: 2.15, line: { color: waveColor, width: lw } });
  slide.addShape(pres.ShapeType.line, { x: 5.6, y: 4.3, w: 0.6, h: 0, line: { color: waveColor, width: lw } });
  // Partial breath 3 rise only
  slide.addShape(pres.ShapeType.line, { x: 6.2, y: 4.3, w: 0.25, h: -2.0, line: { color: waveColor, width: lw } });
  slide.addShape(pres.ShapeType.line, { x: 6.45, y: 2.3, w: 0.6, h: -0.15, line: { color: waveColor, width: lw } });

  // Phase labels under waveform
  const phases = [
    { label: "Phase I\nInspiratory\nBaseline", x: 1.05 },
    { label: "Phase II\nExpiratory\nUpstroke", x: 1.5 },
    { label: "Phase III\nAlveolar\nPlateau", x: 2.1 },
    { label: "Phase IV\nInspiratory\nDownstroke", x: 3.0 },
  ];
  phases.forEach(p => {
    slide.addText(p.label, { x: p.x, y: 4.55, w: 0.85, h: 0.75, fontSize: 8.5, color: "8BAAC8", align: "center", margin: 0 });
  });

  // ETCO2 label
  slide.addText("ETCO₂\n35–45 mmHg", { x: 3.1, y: 1.75, w: 1.3, h: 0.55, fontSize: 9.5, color: GOLD, bold: true, margin: 0 });

  // Right panel — phase details
  slide.addShape(pres.ShapeType.rect, { x: 7.4, y: 1.1, w: 2.25, h: 4.2, fill: { color: "0D2240" }, rounding: true });
  slide.addText("Phase Details", { x: 7.5, y: 1.15, w: 2.1, h: 0.38, fontSize: 12, bold: true, color: ACCENT, margin: 0 });
  const phaseDetails = [
    { text: "I — Baseline", options: { bold: true, color: ACCENT, fontSize: 10.5 } },
    { text: "\nInspired gas, CO₂ = 0 mmHg\n", options: { color: LGRAY, fontSize: 9.5 } },
    { text: "II — Upstroke", options: { bold: true, color: YELLOW, fontSize: 10.5 } },
    { text: "\nDead space + alveolar gas mixing\n", options: { color: LGRAY, fontSize: 9.5 } },
    { text: "III — Plateau", options: { bold: true, color: GREEN, fontSize: 10.5 } },
    { text: "\nAlveolar gas; slope reflects V/Q\nPeak = ETCO₂\n", options: { color: LGRAY, fontSize: 9.5 } },
    { text: "IV — Downstroke", options: { bold: true, color: RED, fontSize: 10.5 } },
    { text: "\nFresh gas inhalation; rapid drop to 0", options: { color: LGRAY, fontSize: 9.5 } },
  ];
  slide.addText(phaseDetails, { x: 7.5, y: 1.6, w: 2.0, h: 3.5, valign: "top", lineSpacingMultiple: 1.2, margin: 0 });
  return slide;
}

function abnormalWaveformsSlide(pres) {
  const slide = pres.addSlide();
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: DARK } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 1.0, fill: { color: MID } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0.95, w: 10, h: 0.06, fill: { color: ACCENT } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.18, h: 5.625, fill: { color: ACCENT } });
  slide.addText("Abnormal Waveform Patterns & Clinical Significance", {
    x: 0.4, y: 0.12, w: 9.2, h: 0.75, fontSize: 22, bold: true, color: WHITE, valign: "middle", margin: 0
  });

  const patterns = [
    {
      name: "Shark-Fin / Obstructive",
      color: RED,
      desc: "Slurred upstroke + rounded plateau peak; Phase II-III merge into a sloping ramp. Indicates airflow obstruction — bronchospasm, COPD, asthma, kinked ETT.",
      x: 0.3, y: 1.1
    },
    {
      name: "Curare Cleft",
      color: GOLD,
      desc: "Notch in plateau (Phase III) caused by incomplete neuromuscular blockade — diaphragmatic contraction during expiration. Indicates residual paralysis.",
      x: 0.3, y: 2.5
    },
    {
      name: "Rebreathing (Elevated Baseline)",
      color: YELLOW,
      desc: "Baseline CO₂ > 0. Causes: exhausted CO₂ absorber, faulty circuit valve, low FGF, or calibration error.",
      x: 0.3, y: 3.9
    },
    {
      name: "Sudden Loss of Waveform",
      color: RED,
      desc: "Esophageal intubation, circuit disconnect, ventilator failure, cardiac arrest (no pulmonary blood flow). FIRST confirm tube placement.",
      x: 5.2, y: 1.1
    },
    {
      name: "Sustained Low ETCO₂",
      color: ACCENT,
      desc: "Hyperventilation, hypothermia, PE (dead space ↑), low cardiac output. Gradient PaCO₂ - ETCO₂ > 5 mmHg suggests V/Q mismatch.",
      x: 5.2, y: 2.5
    },
    {
      name: "Sustained High ETCO₂",
      color: GOLD,
      desc: "Hypoventilation, malignant hyperthermia, sepsis (↑ metabolic CO₂), exogenous CO₂ (laparoscopy), NaHCO₃ infusion.",
      x: 5.2, y: 3.9
    }
  ];

  patterns.forEach(p => {
    slide.addShape(pres.ShapeType.rect, { x: p.x, y: p.y, w: 4.6, h: 1.25, fill: { color: "0A1E38" }, rounding: true, line: { color: p.color, width: 1.5 } });
    slide.addText(p.name, { x: p.x + 0.15, y: p.y + 0.07, w: 4.3, h: 0.32, fontSize: 11.5, bold: true, color: p.color, margin: 0 });
    slide.addText(p.desc, { x: p.x + 0.15, y: p.y + 0.42, w: 4.3, h: 0.78, fontSize: 9.8, color: LGRAY, margin: 0 });
  });

  return slide;
}

function etco2table(pres) {
  const slide = pres.addSlide();
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: DARK } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 1.0, fill: { color: MID } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0.95, w: 10, h: 0.06, fill: { color: ACCENT } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.18, h: 5.625, fill: { color: ACCENT } });
  slide.addText("ETCO₂ Changes: Systematic Differential Diagnosis", {
    x: 0.4, y: 0.12, w: 9.2, h: 0.75, fontSize: 22, bold: true, color: WHITE, valign: "middle", margin: 0
  });

  const rows = [
    ["", "ETCO₂ Change", "Mechanism", "Clinical Causes"],
    ["↑ High", "> 45 mmHg", "↑ CO₂ production or ↓ ventilation", "Hypoventilation, MH, sepsis, laparoscopy, NaHCO₃, tourniquet release"],
    ["↓ Low", "< 35 mmHg", "↓ CO₂ production or ↑ dead space", "Hyperventilation, hypothermia, PE, low CO, hemorrhage, cardiac arrest"],
    ["→ Zero", "0 mmHg", "No CO₂ measured", "Esophageal intubation, circuit disconnect, cardiac arrest, apnea"],
    ["↑ Gradient", "PaCO₂ - ETCO₂ > 5", "V/Q mismatch / dead space", "PE, ARDS, low CO states, COPD, prone position (variable)"],
  ];

  const colW = [0.9, 1.5, 2.8, 4.0];
  const rowH = 0.72;
  const startX = 0.35;
  const startY = 1.1;
  const rowColors = [MID, "08192E", "0A1E38", "08192E", "0A1E38"];
  const textColors = [ACCENT, RED, ACCENT, YELLOW, GOLD];

  rows.forEach((row, ri) => {
    let xCursor = startX;
    row.forEach((cell, ci) => {
      const isHeader = ri === 0;
      slide.addShape(pres.ShapeType.rect, {
        x: xCursor, y: startY + ri * rowH, w: colW[ci], h: rowH,
        fill: { color: isHeader ? "0D2240" : rowColors[ri] },
        line: { color: "1A3D5C", width: 0.5 }
      });
      slide.addText(cell, {
        x: xCursor + 0.06, y: startY + ri * rowH + 0.04,
        w: colW[ci] - 0.12, h: rowH - 0.08,
        fontSize: isHeader ? 11 : (ci === 0 ? 14 : 10.5),
        bold: isHeader || ci === 0,
        color: isHeader ? ACCENT : (ci === 0 ? textColors[ri] : LGRAY),
        valign: "middle", margin: 0
      });
      xCursor += colW[ci];
    });
  });
  return slide;
}

function rolesSlide(pres) {
  const slide = pres.addSlide();
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: DARK } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 1.0, fill: { color: MID } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0.95, w: 10, h: 0.06, fill: { color: ACCENT } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.18, h: 5.625, fill: { color: ACCENT } });
  slide.addText("Clinical Applications by Setting", {
    x: 0.4, y: 0.12, w: 9.2, h: 0.75, fontSize: 22, bold: true, color: WHITE, valign: "middle", margin: 0
  });

  const cards = [
    { icon: "🔬", title: "Intubation Confirmation", color: GREEN, text: "Gold standard for ETT placement (AHA Class IA). Continuous waveform > colorimetric. Must confirm with each manual bag ventilation.", x: 0.3, y: 1.1 },
    { icon: "❤", title: "CPR Quality & ROSC", color: RED, text: "ETCO₂ < 10 mmHg during CPR = poor prognosis. Abrupt rise to ≥ 35-40 mmHg signals ROSC. Also guides CPR chest compression depth/rate.", x: 3.55, y: 1.1 },
    { icon: "🫁", title: "Mechanical Ventilation", color: ACCENT, text: "Monitor adequacy of ventilation. Adjust TV/RR in ARDS lung-protective strategy. Detect air leak, obstruction, asynchrony.", x: 6.8, y: 1.1 },
    { icon: "💉", title: "Procedural Sedation / MAC", color: GOLD, text: "Detects respiratory depression 4+ min before SpO₂ drop. Mandated for moderate/deep sedation (ASA 2018). Especially critical with supplemental O₂.", x: 0.3, y: 3.15 },
    { icon: "🧪", title: "Malignant Hyperthermia", color: YELLOW, text: "Sudden unexplained rise in ETCO₂ is the earliest sign. Triggers cessation of volatile agents and dantrolene administration.", x: 3.55, y: 3.15 },
    { icon: "🚑", title: "ICU Monitoring", color: LGRAY, text: "Confirm airway at insertion and continuously. Detect circuit disconnection. ETCO₂ trend replaces frequent ABG in stable ventilated patients.", x: 6.8, y: 3.15 },
  ];

  cards.forEach(card => {
    slide.addShape(pres.ShapeType.rect, { x: card.x, y: card.y, w: 3.0, h: 1.9, fill: { color: "0D2240" }, rounding: true, line: { color: card.color, width: 1.5 } });
    slide.addText(card.icon + " " + card.title, { x: card.x + 0.12, y: card.y + 0.1, w: 2.8, h: 0.42, fontSize: 11, bold: true, color: card.color, margin: 0 });
    slide.addText(card.text, { x: card.x + 0.12, y: card.y + 0.55, w: 2.8, h: 1.25, fontSize: 9.5, color: LGRAY, margin: 0 });
  });

  return slide;
}

function technologySlide(pres) {
  const slide = pres.addSlide();
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: DARK } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 1.0, fill: { color: MID } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0.95, w: 10, h: 0.06, fill: { color: ACCENT } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.18, h: 5.625, fill: { color: ACCENT } });
  slide.addText("Technology: Measurement Methods & Equipment", {
    x: 0.4, y: 0.12, w: 9.2, h: 0.75, fontSize: 22, bold: true, color: WHITE, valign: "middle", margin: 0
  });

  // Three main tech method cards
  const methods = [
    {
      title: "Mainstream",
      color: ACCENT,
      items: [
        "Sensor in-line with airway circuit",
        "No aspiration — real-time waveform",
        "Larger sensor head adds dead space",
        "Condensation can impair accuracy",
        "Better for small patients (neonates)"
      ]
    },
    {
      title: "Sidestream",
      color: GOLD,
      items: [
        "Aspirates 50-200 mL/min via T-piece",
        "Most common in OR & ICU",
        "Lightweight proximal connector",
        "Slight signal delay (2-3 sec)",
        "Water trap required; may underestimate ETCO₂ in neonates"
      ]
    },
    {
      title: "Microstream",
      color: YELLOW,
      items: [
        "Modified sidestream; very low flow (~50 mL/min)",
        "CO₂-specific laser spectroscopy",
        "Minimal N₂O/O₂ collision broadening",
        "Suitable for nasal/oral cannula in non-intubated",
        "Widely used in procedural sedation"
      ]
    }
  ];

  methods.forEach((m, i) => {
    const x = 0.3 + i * 3.2;
    slide.addShape(pres.ShapeType.rect, { x, y: 1.1, w: 3.0, h: 3.2, fill: { color: "0D2240" }, rounding: true, line: { color: m.color, width: 1.5 } });
    slide.addText(m.title, { x: x + 0.15, y: 1.15, w: 2.7, h: 0.42, fontSize: 14, bold: true, color: m.color, margin: 0 });
    const bullets = m.items.map((t, j) => [
      { text: "•  ", options: { color: m.color, bold: true, fontSize: 11 } },
      { text: t, options: { color: LGRAY, fontSize: 11, breakLine: j < m.items.length - 1 } }
    ]).flat();
    slide.addText(bullets, { x: x + 0.15, y: 1.65, w: 2.7, h: 2.5, valign: "top", lineSpacingMultiple: 1.3, margin: 0 });
  });

  // Bottom note on IR spectroscopy
  slide.addShape(pres.ShapeType.rect, { x: 0.3, y: 4.4, w: 9.4, h: 0.92, fill: { color: "0A1E38" }, rounding: true });
  slide.addText([
    { text: "Principle: ", options: { bold: true, color: ACCENT, fontSize: 11 } },
    { text: "CO₂ absorbs infrared light at 4.26 μm. The Beer-Lambert law governs absorption proportional to CO₂ concentration. Modern analysers apply collision-broadening correction factors for O₂ and N₂O.", options: { color: LGRAY, fontSize: 11 } },
    { text: "  |  Capnometry vs Capnography: ", options: { bold: true, color: GOLD, fontSize: 11 } },
    { text: "Capnometry = numeric ETCO₂ value only. Capnography = waveform + numeric — clinically superior.", options: { color: LGRAY, fontSize: 11 } },
  ], { x: 0.5, y: 4.43, w: 9.0, h: 0.88, valign: "middle", margin: 0 });

  return slide;
}

function cprSlide(pres) {
  const slide = pres.addSlide();
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: DARK } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 1.0, fill: { color: MID } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0.95, w: 10, h: 0.06, fill: { color: RED } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.18, h: 5.625, fill: { color: RED } });
  slide.addText("Capnography in Cardiac Arrest & CPR", {
    x: 0.4, y: 0.12, w: 9.2, h: 0.75, fontSize: 22, bold: true, color: WHITE, valign: "middle", margin: 0
  });

  // ETCO2 during CPR visual
  slide.addShape(pres.ShapeType.rect, { x: 0.3, y: 1.1, w: 4.5, h: 4.15, fill: { color: "0A1628" }, rounding: true });
  slide.addText("ETCO₂ During CPR", { x: 0.45, y: 1.15, w: 4.2, h: 0.4, fontSize: 13, bold: true, color: RED, margin: 0 });

  // Visual bar chart representing ETCO2 levels
  const bars = [
    { label: "Normal\nperfusion", val: 38, color: GREEN },
    { label: "CPR\n(poor)", val: 8, color: RED },
    { label: "CPR\n(good)", val: 18, color: GOLD },
    { label: "ROSC", val: 40, color: GREEN },
  ];
  const barW = 0.65;
  const maxH = 2.0;
  const maxVal = 50;
  bars.forEach((b, i) => {
    const bh = (b.val / maxVal) * maxH;
    const bx = 0.5 + i * 1.05;
    const by = 3.9 - bh;
    slide.addShape(pres.ShapeType.rect, { x: bx, y: by, w: barW, h: bh, fill: { color: b.color }, rounding: true });
    slide.addText(b.val + "", { x: bx, y: by - 0.3, w: barW, h: 0.28, fontSize: 10, bold: true, color: b.color, align: "center", margin: 0 });
    slide.addText(b.label, { x: bx - 0.05, y: 4.0, w: barW + 0.1, h: 0.65, fontSize: 8.5, color: LGRAY, align: "center", margin: 0 });
  });
  // Threshold line
  slide.addShape(pres.ShapeType.line, { x: 0.45, y: 3.1, w: 4.0, h: 0, line: { color: GOLD, width: 1, dashType: "dash" } });
  slide.addText("10 mmHg\nthreshold", { x: 3.95, y: 2.95, w: 0.85, h: 0.5, fontSize: 8, color: GOLD, margin: 0 });

  // Key points right panel
  slide.addShape(pres.ShapeType.rect, { x: 5.1, y: 1.1, w: 4.55, h: 4.15, fill: { color: "0D2240" }, rounding: true });
  slide.addText("Key Clinical Points  (AHA 2020)", { x: 5.25, y: 1.15, w: 4.2, h: 0.4, fontSize: 12, bold: true, color: RED, margin: 0 });
  const cprPoints = [
    { text: "ETCO₂ reflects cardiac output", sub: "CO₂ reaches lungs only if blood is moving — ETCO₂ ≈ surrogate for pulmonary blood flow during CPR" },
    { text: "< 10 mmHg after 20 min = poor outcome", sub: "Used as one factor (not sole criterion) in termination-of-resuscitation decisions" },
    { text: "CPR quality optimization", sub: "Rising ETCO₂ suggests improved compressions; target ETCO₂ ≥ 10 mmHg" },
    { text: "ROSC detection", sub: "Sudden sustained rise to ≥ 35–40 mmHg is highly specific for ROSC — reduces unnecessary interruptions for pulse checks" },
    { text: "Avoid pseudo-ROSC", sub: "NaHCO₃ bolus causes transient ETCO₂ spike — do not confuse with ROSC" },
  ];
  const cprBullets = cprPoints.map((p, i) => [
    { text: "▸  ", options: { color: RED, bold: true, fontSize: 11 } },
    { text: p.text + "\n", options: { color: WHITE, fontSize: 11, bold: true } },
    { text: "    " + p.sub + (i < cprPoints.length - 1 ? "\n" : ""), options: { color: "8BAAC8", fontSize: 10 } }
  ]).flat();
  slide.addText(cprBullets, { x: 5.25, y: 1.65, w: 4.25, h: 3.45, valign: "top", lineSpacingMultiple: 1.2, margin: 0 });

  return slide;
}

function physSlide(pres) {
  const slide = pres.addSlide();
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: DARK } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 1.0, fill: { color: MID } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0.95, w: 10, h: 0.06, fill: { color: ACCENT } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.18, h: 5.625, fill: { color: ACCENT } });
  slide.addText("Physiology: CO₂ Transport & the PaCO₂ – ETCO₂ Gradient", {
    x: 0.4, y: 0.12, w: 9.2, h: 0.75, fontSize: 22, bold: true, color: WHITE, valign: "middle", margin: 0
  });

  // Left column: CO2 transport diagram (text-based)
  slide.addShape(pres.ShapeType.rect, { x: 0.3, y: 1.1, w: 4.5, h: 4.15, fill: { color: "0D2240" }, rounding: true });
  slide.addText("CO₂ Transport in Blood", { x: 0.45, y: 1.15, w: 4.2, h: 0.38, fontSize: 13, bold: true, color: ACCENT, margin: 0 });

  const transport = [
    { pct: "70%", label: "Bicarbonate (HCO₃⁻)", color: ACCENT },
    { pct: "23%", label: "Carbamino-Hb", color: GOLD },
    { pct: "7%",  label: "Dissolved CO₂", color: LGRAY },
  ];
  transport.forEach((t, i) => {
    const bw = parseFloat(t.pct) / 100 * 3.8;
    slide.addShape(pres.ShapeType.rect, { x: 0.5, y: 1.65 + i * 0.6, w: bw, h: 0.4, fill: { color: t.color }, rounding: true });
    slide.addText(t.pct + " — " + t.label, { x: 0.55, y: 1.67 + i * 0.6, w: 4.0, h: 0.36, fontSize: 11, color: DARK, bold: true, valign: "middle", margin: 0 });
  });

  const gradPoints = [
    "Normal PaCO₂ – ETCO₂ gradient: 2–5 mmHg",
    "Widened gradient (> 5 mmHg) indicates ↑ dead space ventilation",
    "Dead space causes: PE, low CO, ARDS, hyperinflation",
    "Normal ETCO₂ does NOT rule out abnormal PaCO₂ — always correlate with ABG in critically ill patients",
    "Alveolar equation: PaCO₂ ≈ VCO₂ / (VA × k)",
    "Decreased VA or increased dead space → ↑ PaCO₂ without proportional ↑ ETCO₂"
  ];
  slide.addText("PaCO₂ – ETCO₂ Gradient", { x: 0.45, y: 3.5, w: 4.0, h: 0.38, fontSize: 12, bold: true, color: GOLD, margin: 0 });
  const gradItems = gradPoints.map((g, i) => [
    { text: "• ", options: { color: GOLD, bold: true, fontSize: 10.5 } },
    { text: g, options: { color: LGRAY, fontSize: 10.5, breakLine: i < gradPoints.length - 1 } }
  ]).flat();
  slide.addText(gradItems, { x: 0.45, y: 3.95, w: 4.2, h: 1.15, valign: "top", lineSpacingMultiple: 1.3, margin: 0 });

  // Right column: Determinants of ETCO2
  slide.addShape(pres.ShapeType.rect, { x: 5.1, y: 1.1, w: 4.55, h: 4.15, fill: { color: "0A1E38" }, rounding: true });
  slide.addText("Determinants of ETCO₂", { x: 5.25, y: 1.15, w: 4.2, h: 0.38, fontSize: 13, bold: true, color: ACCENT, margin: 0 });

  const determinants = [
    { factor: "CO₂ Production (VCO₂)", items: ["Metabolic rate, fever, shivering", "Malignant hyperthermia, sepsis", "Tourniquet release, reperfusion"] },
    { factor: "Alveolar Ventilation (VA)", items: ["RR and tidal volume settings", "Dead space fraction (Vd/Vt)", "ETT position, circuit leaks"] },
    { factor: "Pulmonary Blood Flow (Q)", items: ["Cardiac output", "Pulmonary embolism", "Cardiac arrest"] },
  ];
  let yOff = 1.6;
  determinants.forEach(d => {
    slide.addText(d.factor, { x: 5.25, y: yOff, w: 4.2, h: 0.32, fontSize: 11, bold: true, color: GOLD, margin: 0 });
    yOff += 0.32;
    d.items.forEach(it => {
      slide.addText("  · " + it, { x: 5.25, y: yOff, w: 4.2, h: 0.28, fontSize: 10, color: LGRAY, margin: 0 });
      yOff += 0.28;
    });
    yOff += 0.08;
  });

  return slide;
}

function nonIntubatedSlide(pres) {
  const slide = pres.addSlide();
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: DARK } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 1.0, fill: { color: MID } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0.95, w: 10, h: 0.06, fill: { color: ACCENT } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.18, h: 5.625, fill: { color: ACCENT } });
  slide.addText("Capnography in the Non-Intubated Patient", {
    x: 0.4, y: 0.12, w: 9.2, h: 0.75, fontSize: 22, bold: true, color: WHITE, valign: "middle", margin: 0
  });

  const items = [
    {
      title: "Key Principle",
      color: ACCENT,
      text: "In non-intubated patients, sidestream sample is diluted with ambient/supplemental O₂. The absolute ETCO₂ value is less reliable than the trend and waveform pattern. Focus on respiratory rate, waveform morphology, and changes from baseline."
    },
    {
      title: "Detection Advantage",
      color: GREEN,
      text: "Capnography detects apnea or hypoventilation 4+ minutes before SpO₂ drops — critical when supplemental O₂ masks respiratory depression. Pulse oximetry alone is inadequate for ventilatory monitoring during sedation."
    },
    {
      title: "Devices Used",
      color: GOLD,
      text: "Nasal cannula with oral sampling port (most common). Nasal-oral mask for mouth-breathers. Microstream technology preferred due to low flow requirements and CO₂ specificity."
    },
    {
      title: "Procedural Sedation (ASA/ACEP Mandate)",
      color: YELLOW,
      text: "Continuous waveform capnography mandated for all moderate/deep sedation cases (ASA 2018, ACEP). Multiple RCTs show earlier detection of respiratory compromise vs. standard monitoring alone."
    },
    {
      title: "PACU & Post-op Monitoring",
      color: LGRAY,
      text: "Mask capnography detects apnea events after intrathecal opioids (e.g., morphine after C-section). Undetected by 2-hourly nursing checks in one study of 80 patients — 198 apnea alerts captured by capnography."
    },
    {
      title: "ICU / NIV",
      color: ACCENT,
      text: "Useful during NIV to monitor adequacy of ventilation without invasive airway. Also valuable during transport of non-intubated trauma patients — more stable than SpO₂ alone."
    },
  ];

  items.forEach((item, i) => {
    const col = i % 2 === 0 ? 0.3 : 5.2;
    const row = Math.floor(i / 2);
    const y = 1.1 + row * 1.45;
    slide.addShape(pres.ShapeType.rect, { x: col, y, w: 4.65, h: 1.3, fill: { color: "0D2240" }, rounding: true, line: { color: item.color, width: 1.3 } });
    slide.addText(item.title, { x: col + 0.13, y: y + 0.08, w: 4.4, h: 0.32, fontSize: 11, bold: true, color: item.color, margin: 0 });
    slide.addText(item.text, { x: col + 0.13, y: y + 0.43, w: 4.4, h: 0.82, fontSize: 9.2, color: LGRAY, margin: 0 });
  });

  return slide;
}

function pitfallsSlide(pres) {
  const slide = pres.addSlide();
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: DARK } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 1.0, fill: { color: MID } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0.95, w: 10, h: 0.06, fill: { color: RED } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.18, h: 5.625, fill: { color: RED } });
  slide.addText("Pitfalls, Limitations & Troubleshooting", {
    x: 0.4, y: 0.12, w: 9.2, h: 0.75, fontSize: 22, bold: true, color: WHITE, valign: "middle", margin: 0
  });

  const rows = [
    ["Pitfall / Source of Error", "Cause", "Solution / Caveat"],
    ["Low ETCO₂ ≠ low PaCO₂", "Widened dead-space gradient (PE, low CO)", "Confirm with ABG; calculate Vd/Vt"],
    ["Normal ETCO₂ ≠ normal ventilation", "ETCO₂ can appear normal in compensated V/Q mismatch", "Clinical assessment + ABG mandatory in unstable pts"],
    ["False low in non-intubated", "Dilution by ambient O₂ / air", "Use trends not absolute values; microstream preferred"],
    ["Elevated baseline / rebreathing", "Exhausted CO₂ absorber, faulty valve", "Replace absorber; check valves; increase FGF"],
    ["Signal dropout", "Moisture in sample line, blocked cannula", "Water trap, frequent line changes"],
    ["NaHCO₃ pseudo-ROSC", "Exogenous CO₂ from bicarbonate bolus", "Correlate with pulse check after bicarb"],
    ["TIVA / Xenon", "IR spectroscopy cannot detect xenon", "Capnography only measures CO₂; no xenon data"],
    ["Prone positioning", "ETCO₂ may change with position — not always pathological", "Establish new baseline after repositioning"],
  ];

  const cw = [2.6, 3.5, 3.4];
  const rh = 0.47;
  const sx = 0.28, sy = 1.08;
  rows.forEach((row, ri) => {
    let xc = sx;
    row.forEach((cell, ci) => {
      slide.addShape(pres.ShapeType.rect, {
        x: xc, y: sy + ri * rh, w: cw[ci], h: rh,
        fill: { color: ri === 0 ? "0D2240" : (ri % 2 === 0 ? "08192E" : "0A1E38") },
        line: { color: "1A3D5C", width: 0.5 }
      });
      slide.addText(cell, {
        x: xc + 0.07, y: sy + ri * rh + 0.03, w: cw[ci] - 0.14, h: rh - 0.06,
        fontSize: ri === 0 ? 10.5 : 9.8, bold: ri === 0,
        color: ri === 0 ? ACCENT : (ci === 0 ? GOLD : LGRAY),
        valign: "middle", margin: 0
      });
      xc += cw[ci];
    });
  });
  return slide;
}

function summarySlide(pres) {
  const slide = pres.addSlide();
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: DARK } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.18, h: 5.625, fill: { color: ACCENT } });
  slide.addShape(pres.ShapeType.ellipse, { x: 7.5, y: 3.5, w: 4.5, h: 4.5, fill: { color: MID }, line: { color: MID } });

  slide.addText("Key Takeaways", {
    x: 0.4, y: 0.3, w: 9, h: 0.7, fontSize: 32, bold: true, color: ACCENT, margin: 0
  });
  slide.addShape(pres.ShapeType.rect, { x: 0.4, y: 1.05, w: 3.5, h: 0.04, fill: { color: ACCENT } });

  const points = [
    "Capnography is the standard of care for ventilation monitoring in ALL anesthetized and deeply sedated patients",
    "The four-phase waveform encodes airway anatomy, gas exchange, and cardiac output simultaneously",
    "ETCO₂ changes should be interpreted alongside waveform morphology and the PaCO₂ gradient",
    "In CPR: ETCO₂ < 10 mmHg predicts poor outcome; sudden rise ≥ 35 mmHg signals ROSC",
    "Malignant hyperthermia: unexplained rising ETCO₂ is the earliest trigger — act immediately",
    "Non-intubated monitoring: detect hypoventilation 4+ min before pulse oximetry — never rely on SpO₂ alone during sedation",
    "Always correlate with clinical examination and ABG in critically ill patients — no monitor replaces bedside assessment",
  ];

  const items = points.map((p, i) => [
    { text: String(i + 1) + ".  ", options: { color: ACCENT, bold: true, fontSize: 12.5 } },
    { text: p, options: { color: LGRAY, fontSize: 12.5, breakLine: i < points.length - 1 } }
  ]).flat();

  slide.addText(items, {
    x: 0.4, y: 1.2, w: 7.3, h: 4.1,
    valign: "top", lineSpacingMultiple: 1.4, margin: 0
  });

  slide.addText("CO₂", {
    x: 7.5, y: 3.6, w: 2.4, h: 1.5, fontSize: 72, bold: true, color: ACCENT, align: "center", transparency: 50
  });
  slide.addText("Sources: Barash Clinical Anesthesia 9e | WFSA ATOTW 534 (2024) | AHA 2020 Guidelines | Medscape Capnography Review", {
    x: 0.4, y: 5.25, w: 9.2, h: 0.3, fontSize: 8, color: "4A6580", italic: true, margin: 0
  });

  return slide;
}

// ─── BUILD PRESENTATION ─────────────────────────────────────────────────────

// Slide 1: Title
titleSlide(pres);

// Slide 2: Agenda
contentSlide(pres, "Presentation Agenda", [
  { text: "1.  Physiology & Physics", sub: "CO₂ production/transport, Beer-Lambert law, IR spectroscopy" },
  { text: "2.  Technology", sub: "Mainstream vs. sidestream vs. microstream; capnometry vs. capnography" },
  { text: "3.  The Normal Capnogram", sub: "Four phases, alpha/beta angles, ETCO₂ reference ranges" },
  { text: "4.  Abnormal Waveforms & Differential Diagnosis", sub: "Pattern recognition: obstructive, rebreathing, curare cleft, flat-line" },
  { text: "5.  ETCO₂ Changes — Systematic Approach", sub: "High, low, zero — causes and clinical interpretation" },
  { text: "6.  Clinical Applications", sub: "Intubation, CPR, MH, ICU ventilation, procedural sedation" },
  { text: "7.  Non-Intubated Monitoring", sub: "Sedation safety, NIV, PACU, transport" },
  { text: "8.  Pitfalls, Limitations & Troubleshooting", sub: "Common errors and how to avoid them" },
]);

// Slide 3: Physiology overview
sectionDivider(pres, "01", "Physiology & Physics", "Understanding what CO₂ tells us about the patient's physiology");

physSlide(pres);

// Slide 5: Technology
sectionDivider(pres, "02", "Technology & Equipment", "From infrared spectroscopy to bedside monitoring");

technologySlide(pres);

// Slide 7: Normal waveform
sectionDivider(pres, "03", "The Normal Capnogram", "Four phases, reference values, and clinical correlates");

waveformSlide(pres);

// Additional normal waveform details
contentSlide(pres, "Normal Capnogram: Clinical Reference Values & Interpretation", [
  { text: "Normal ETCO₂ range: 35–45 mmHg", sub: "Reflects alveolar PCO₂ at end-expiration; best approximates PaCO₂ in healthy patients" },
  { text: "Normal PaCO₂ – ETCO₂ gradient: 2–5 mmHg", sub: "Widened gradient (> 5 mmHg) indicates increased alveolar dead space" },
  { text: "Alpha angle (< 90°)", sub: "Between Phase II and III — sharpness reflects homogenous lung emptying; obtuse = inhomogeneous V/Q (obstructive disease)" },
  { text: "Beta angle (≈ 90°)", sub: "Between Phase III and Phase IV — rounded beta angle suggests CO₂ rebreathing" },
  { text: "Respiratory rate visible on trend", sub: "Apnea shows as flat line; breath stacking shows progressive baseline elevation" },
  { text: "Phase III slope (S III)", sub: "Normally slightly upward; steep rise = severe V/Q mismatch (COPD, asthma exacerbation)" },
], { note: "ETCO₂ should always be interpreted with waveform morphology — numeric value alone is insufficient" });

// Slide 10: Abnormal waveforms
sectionDivider(pres, "04", "Abnormal Waveform Patterns", "Pattern recognition as a diagnostic tool");

abnormalWaveformsSlide(pres);

// Slide 12: ETCO2 differential
sectionDivider(pres, "05", "ETCO₂ Changes: Systematic Approach", "High, low, zero — causes and clinical response");

etco2table(pres);

// Slide 14: Clinical applications
sectionDivider(pres, "06", "Clinical Applications", "Anesthesia, ICU, Emergency Medicine");

rolesSlide(pres);

// ETT confirmation + MH detail
twoColSlide(pres,
  "Intubation Confirmation & Malignant Hyperthermia",
  "ETT Confirmation (AHA Class IA)",
  [
    "Continuous waveform capnography is the gold standard",
    "Colorimetric CO₂ detectors acceptable only if waveform unavailable",
    "Absence of waveform after intubation = esophageal intubation until proven otherwise",
    "Confirm after each patient repositioning, transport, and manual ventilation",
    "Six consecutive ETCO₂ waveforms recommended before securing ETT",
    "Supraglottic airways: capnography also confirms adequate ventilation"
  ],
  "Malignant Hyperthermia Early Warning",
  [
    "Unexplained ETCO₂ rise is the EARLIEST sign of MH (before hyperthermia develops)",
    "Mechanism: massively ↑ cellular metabolism → ↑ CO₂ production overwhelms ventilation",
    "Action: increase minute ventilation → stop volatile agents → dantrolene IV",
    "ETCO₂ may exceed 100 mmHg in severe MH",
    "Also monitor temperature, rigidity, CK, ABG (severe metabolic acidosis)",
    "MH hotline: 1-800-MH-HYPER (North America)"
  ],
  GREEN, RED
);

// Slide 16: CPR
sectionDivider(pres, "07", "Cardiac Arrest & CPR", "ETCO₂ as a hemodynamic surrogate");

cprSlide(pres);

// Slide 18: Non-intubated
sectionDivider(pres, "08", "Non-Intubated Monitoring", "Procedural sedation, PACU, ICU, transport");

nonIntubatedSlide(pres);

// Slide 20: Pitfalls
sectionDivider(pres, "09", "Pitfalls & Limitations", "When capnography can mislead");

pitfallsSlide(pres);

// Slide 22: Summary
summarySlide(pres);

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

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

Running Command

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

Your presentation is ready:

Capnography Advanced

Presentation · PPTX


Here is what is included across 22 slides in a dark navy/teal clinical theme:
SectionContent
TitleStyled cover with CO₂ motif
Agenda8-topic roadmap with sub-themes
Physiology & PhysicsCO₂ transport (70% HCO₃⁻ / 23% carbamino / 7% dissolved), Beer-Lambert law, IR spectroscopy at 4.26 μm, PaCO₂ - ETCO₂ gradient, determinants of ETCO₂
TechnologyMainstream vs. sidestream vs. microstream — specs, trade-offs, ideal use cases; capnometry vs. capnography distinction
Normal CapnogramDrawn four-phase waveform with phase annotations; alpha/beta angles; Phase III slope significance
Abnormal Waveform PatternsShark-fin (obstructive), curare cleft, elevated baseline/rebreathing, sudden loss, sustained high/low ETCO₂
Systematic ETCO₂ DifferentialColor-coded table: High / Low / Zero / Widened gradient — mechanism + causes
Clinical Applications6-card grid: intubation confirmation, CPR, mechanical ventilation, procedural sedation/MAC, malignant hyperthermia, ICU monitoring
ETT & MH DetailTwo-column deep-dive; MH: earliest sign, ETCO₂ > 100 mmHg, dantrolene trigger
Cardiac Arrest & CPRBar chart of ETCO₂ in various CPR states; AHA 2020 five key points including ROSC detection and NaHCO₃ pseudo-ROSC warning
Non-Intubated Monitoring4-min SpO₂ detection advantage, ASA/ACEP mandate, PACU opioid monitoring data, NIV, transport
Pitfalls & Limitations8-row table: source of error, cause, corrective action
Key Takeaways7-point summary for rapid recall
Sources: Barash Clinical Anesthesia 9e, WFSA ATOTW 534 (Oct 2024), AHA 2020 Guidelines, Medscape End-Tidal Capnography reference.

Pdf and presentation both?

Reading File
Running Command

libreoffice --headless --convert-to pdf /home/daytona/workspace/capnography-pptx…

Running Command

mkdir -p /home/daytona/workspace/capnography-pptx/output && libreoffice --headle…

Running Command

chmod 777 /home/daytona/workspace/capnography-pptx/output && cp /home/daytona/wo…

Running Command

cp /home/daytona/workspace/capnography-pptx/Capnography_Advanced.pptx /tmp/cap.p…

Running Command

cp /tmp/cap.pdf /home/daytona/workspace/capnography-pptx/Capnography_Advanced.pd…

Both files are ready for download:
PowerPoint:

Capnography Advanced

Presentation · PPTX

(371 KB — fully editable, all slides with dark theme)
PDF:

Capnography Advanced

PDF Document · PDF

(179 KB — 22 slides, print/share ready)
Both contain the same 22-slide deck covering physiology, technology, normal/abnormal waveforms, ETCO₂ differentials, CPR, malignant hyperthermia, non-intubated monitoring, and pitfalls — sourced from Barash Clinical Anesthesia 9e, WFSA ATOTW 534, and AHA 2020 guidelines.

Can not download

Running Command

ls -lh /home/daytona/workspace/capnography-pptx/ && echo "---" && file /home/day…

The files are confirmed valid on the server. The download issue is likely a browser/client-side problem. Here are a few things to try:
Option 1 — Right-click the links below and choose "Save link as..."
  • Capnography Advanced

    Presentation · PPTX

  • Capnography Advanced

    PDF Document · PDF

Option 2 — Try a different browser (Chrome or Edge work most reliably for file downloads from this interface)
Option 3 — If you see a blank page instead of a download, press Ctrl+S (Windows) or Cmd+S (Mac) to save the file once it opens in the browser tab.
Option 4 — Mobile? If you're on a phone or tablet, long-press the link and select "Download link."
The files are confirmed on the server:
  • PPTX — 371 KB, valid Zip/Office archive, 22 slides
  • PDF — 179 KB, valid PDF 1.7, 23 pages
If none of those work, let me know what device/browser you're using and I can troubleshoot further or convert the content to a different delivery format.
This is a shared conversation. Sign in to Orris to start your own chat.