Make presentation on Hypovolemic shock in GI bleeding , it’s pathophysiology in detail explanation and more text signs symptoms diagnosis and treatment with step by step approaches as for in Emergency Medicine

Reading File
Reading File
Reading File
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Searching Images

hypovolemic shock pathophysiology diagram hemorrhage

Running Command

ls -la /home/daytona/workspace/ && mkdir -p /home/daytona/workspace/gi-shock-pptx

Running Command

mkdir -p /home/user/workspace/gi-shock-pptx && ls /home/user/workspace/

Running Command

echo $HOME && ls $HOME

Running Command

mkdir -p /home/daytona/gi-shock-pptx && echo "Directory created"

Writing File

/home/daytona/gi-shock-pptx/build.js

const pptxgen = require("pptxgenjs");

const pres = new pptxgen();
pres.layout = "LAYOUT_16x9";
pres.title = "Hypovolemic Shock in GI Bleeding";
pres.author = "Emergency Medicine";

// ─── Color Palette ───────────────────────────────────────────────────────────
const C = {
  bg:       "0D1B2A",   // deep navy (dominant)
  bgLight:  "112233",   // slide body bg
  accent1:  "E63946",   // vivid red (blood / danger)
  accent2:  "F4A261",   // amber (warning)
  accent3:  "2EC4B6",   // teal (labs / treatment)
  white:    "FFFFFF",
  offWhite: "D6E4F0",
  yellow:   "FFD166",
  gray:     "8BA3BC",
  darkBg:   "071525",
};

// ─── Helper: add slide background rect ───────────────────────────────────────
function bgRect(slide, color) {
  slide.addShape(pres.ShapeType.rect, {
    x: 0, y: 0, w: "100%", h: "100%",
    fill: { color: color || C.bg },
    line: { color: color || C.bg },
  });
}

// ─── Helper: section header bar ──────────────────────────────────────────────
function headerBar(slide, title, color) {
  slide.addShape(pres.ShapeType.rect, {
    x: 0, y: 0, w: "100%", h: 1.0,
    fill: { color: color || C.accent1 },
    line: { color: color || C.accent1 },
  });
  slide.addText(title, {
    x: 0.3, y: 0.1, w: 9.4, h: 0.75,
    fontSize: 28, bold: true, color: C.white,
    fontFace: "Calibri", align: "left", valign: "middle", margin: 0,
  });
}

// ─── Helper: colored left stripe ─────────────────────────────────────────────
function leftStripe(slide, color) {
  slide.addShape(pres.ShapeType.rect, {
    x: 0, y: 0, w: 0.15, h: "100%",
    fill: { color: color || C.accent1 },
    line: { color: color || C.accent1 },
  });
}

// ─── Helper: bullet list ─────────────────────────────────────────────────────
function bullets(items, opts = {}) {
  return items.map((t, i) => ({
    text: t,
    options: {
      bullet: { code: "2022" },
      color: opts.color || C.offWhite,
      fontSize: opts.fontSize || 15,
      bold: opts.bold || false,
      breakLine: i < items.length - 1,
      paraSpaceBefore: opts.spaceBefore || 4,
    },
  }));
}

// ─── Helper: numbered list ────────────────────────────────────────────────────
function numbered(items, opts = {}) {
  return items.map((t, i) => ({
    text: t,
    options: {
      bullet: { type: "number" },
      color: opts.color || C.offWhite,
      fontSize: opts.fontSize || 15,
      bold: opts.bold || false,
      breakLine: i < items.length - 1,
      paraSpaceBefore: opts.spaceBefore || 4,
    },
  }));
}

// ──────────────────────────────────────────────────────────────────────────────
// SLIDE 1 — TITLE
// ──────────────────────────────────────────────────────────────────────────────
{
  const s = pres.addSlide();
  // Deep background
  bgRect(s, C.darkBg);

  // Red diagonal accent band
  s.addShape(pres.ShapeType.rect, {
    x: 0, y: 3.6, w: "100%", h: 0.12,
    fill: { color: C.accent1 }, line: { color: C.accent1 },
  });

  // Large red block left
  s.addShape(pres.ShapeType.rect, {
    x: 0, y: 0, w: 0.55, h: "100%",
    fill: { color: C.accent1 }, line: { color: C.accent1 },
  });

  s.addText("HYPOVOLEMIC SHOCK", {
    x: 0.8, y: 0.55, w: 9, h: 1.2,
    fontSize: 42, bold: true, color: C.white,
    fontFace: "Calibri", align: "left", charSpacing: 3,
  });
  s.addText("IN GASTROINTESTINAL BLEEDING", {
    x: 0.8, y: 1.65, w: 9, h: 0.8,
    fontSize: 26, bold: false, color: C.accent2,
    fontFace: "Calibri", align: "left",
  });
  s.addText("Emergency Medicine — Pathophysiology, Diagnosis & Step-by-Step Management", {
    x: 0.8, y: 2.5, w: 9, h: 0.55,
    fontSize: 14, color: C.gray, fontFace: "Calibri", align: "left",
  });

  // Bottom bar
  s.addShape(pres.ShapeType.rect, {
    x: 0, y: 5.2, w: "100%", h: 0.425,
    fill: { color: "0A1520" }, line: { color: "0A1520" },
  });
  s.addText("Tintinalli's Emergency Medicine  ·  Rosen's Emergency Medicine  ·  Guyton & Hall Physiology  ·  Sabiston Surgery", {
    x: 0.6, y: 5.22, w: 9, h: 0.38,
    fontSize: 9, color: C.gray, fontFace: "Calibri", align: "left",
  });
}

// ──────────────────────────────────────────────────────────────────────────────
// SLIDE 2 — OVERVIEW / AGENDA
// ──────────────────────────────────────────────────────────────────────────────
{
  const s = pres.addSlide();
  bgRect(s);
  headerBar(s, "Outline", C.accent1);

  const topics = [
    "Definition & Classification of Shock",
    "Causes of GI Bleeding (Upper & Lower)",
    "Pathophysiology — Detailed Cascade",
    "Compensatory Mechanisms",
    "ATLS Classification of Hemorrhagic Shock",
    "Signs & Symptoms",
    "Diagnosis — Labs, Imaging & Risk Scores",
    "Step-by-Step Emergency Management",
    "Resuscitation Strategies & Massive Transfusion",
    "Endoscopy, Interventional Radiology & Surgery",
    "Disposition & Monitoring",
  ];

  s.addText(numbered(topics, { fontSize: 15, spaceBefore: 6 }), {
    x: 0.5, y: 1.1, w: 9, h: 4.3,
    fontFace: "Calibri", valign: "top",
  });
}

// ──────────────────────────────────────────────────────────────────────────────
// SLIDE 3 — DEFINITION & CLASSIFICATION
// ──────────────────────────────────────────────────────────────────────────────
{
  const s = pres.addSlide();
  bgRect(s);
  leftStripe(s, C.accent1);
  headerBar(s, "Definition & Classification of Shock", C.accent1);

  s.addText("SHOCK DEFINED", {
    x: 0.35, y: 1.1, w: 9, h: 0.4,
    fontSize: 13, bold: true, color: C.accent2,
    fontFace: "Calibri", charSpacing: 2,
  });
  s.addText(
    "Shock is a state of inadequate tissue perfusion resulting in cellular hypoxia and organ dysfunction.\n" +
    "Defined as systolic BP <90 mmHg or MAP <65 mmHg with evidence of end-organ dysfunction.",
    {
      x: 0.35, y: 1.45, w: 9.2, h: 0.75,
      fontSize: 13.5, color: C.offWhite, fontFace: "Calibri", wrap: true,
    }
  );

  // 4 boxes
  const types = [
    { label: "HYPOVOLEMIC", desc: "↓ intravascular volume\n(hemorrhage, GI loss)", color: C.accent1 },
    { label: "DISTRIBUTIVE", desc: "Septic, anaphylactic,\nneurogenic", color: "7B2D8B" },
    { label: "CARDIOGENIC", desc: "Pump failure\n(MI, cardiomyopathy)", color: "1E6091" },
    { label: "OBSTRUCTIVE", desc: "PE, tamponade,\ntension pneumothorax", color: "1A7A4A" },
  ];

  types.forEach((t, i) => {
    const x = 0.25 + i * 2.4;
    s.addShape(pres.ShapeType.roundRect, {
      x, y: 2.35, w: 2.2, h: 1.35,
      rectRadius: 0.08,
      fill: { color: t.color },
      line: { color: C.white, width: 1 },
    });
    s.addText(t.label, {
      x, y: 2.38, w: 2.2, h: 0.42,
      fontSize: 12, bold: true, color: C.white,
      fontFace: "Calibri", align: "center", valign: "middle", margin: 0,
    });
    s.addText(t.desc, {
      x, y: 2.78, w: 2.2, h: 0.88,
      fontSize: 11, color: C.white,
      fontFace: "Calibri", align: "center", valign: "top",
    });
  });

  s.addText("★ GI BLEEDING IS A PRIMARY CAUSE OF HYPOVOLEMIC SHOCK IN THE ED", {
    x: 0.25, y: 3.85, w: 9.5, h: 0.42,
    fontSize: 13, bold: true, color: C.yellow,
    fontFace: "Calibri", align: "center",
    fill: { color: "1A0A00" },
  });

  s.addText(
    "Key hemodynamic hallmarks of hypovolemic shock: ↓ CO · ↑ SVR · ↓ ScvO₂ · ↑ HR · ↓ Pulse pressure\n" +
    "GI bleeding accounts for ~300,000 hospitalizations/year in the US — upper GI 70%, lower GI 30%",
    {
      x: 0.35, y: 4.3, w: 9.2, h: 0.9,
      fontSize: 12, color: C.gray, fontFace: "Calibri", wrap: true,
    }
  );
}

// ──────────────────────────────────────────────────────────────────────────────
// SLIDE 4 — CAUSES OF GI BLEEDING
// ──────────────────────────────────────────────────────────────────────────────
{
  const s = pres.addSlide();
  bgRect(s);
  leftStripe(s, C.accent2);
  headerBar(s, "Causes of GI Bleeding", C.accent2);

  // Upper GI
  s.addShape(pres.ShapeType.rect, {
    x: 0.3, y: 1.1, w: 4.3, h: 0.38,
    fill: { color: C.accent1 }, line: { color: C.accent1 },
  });
  s.addText("UPPER GI BLEEDING  (proximal to Ligament of Treitz)", {
    x: 0.3, y: 1.1, w: 4.3, h: 0.38,
    fontSize: 12, bold: true, color: C.white, fontFace: "Calibri",
    align: "center", valign: "middle", margin: 0,
  });
  s.addText(bullets([
    "Peptic ulcer disease — Most common (45–60%)",
    "Esophageal / gastric varices — (cirrhosis, portal HTN)",
    "Mallory-Weiss tear — Forceful vomiting",
    "Esophagitis / gastritis / duodenitis",
    "Dieulafoy's lesion — Aberrant submucosal artery",
    "Gastric antral vascular ectasia (GAVE)",
    "Aortoenteric fistula — Post-aortic graft",
    "Malignancy (gastric / esophageal cancer)",
  ], { fontSize: 13 }), {
    x: 0.3, y: 1.5, w: 4.3, h: 3.7,
    fontFace: "Calibri", valign: "top",
  });

  // Lower GI
  s.addShape(pres.ShapeType.rect, {
    x: 5.0, y: 1.1, w: 4.6, h: 0.38,
    fill: { color: "1A6091" }, line: { color: "1A6091" },
  });
  s.addText("LOWER GI BLEEDING  (distal to Ligament of Treitz)", {
    x: 5.0, y: 1.1, w: 4.6, h: 0.38,
    fontSize: 12, bold: true, color: C.white, fontFace: "Calibri",
    align: "center", valign: "middle", margin: 0,
  });
  s.addText(bullets([
    "Diverticulosis — Most common LGIB (40%+)",
    "Ischemic colitis — Especially in elderly",
    "Angiodysplasia / AVM",
    "Colorectal cancer / polyps",
    "Inflammatory bowel disease (Crohn's, UC)",
    "Anorectal disease — Hemorrhoids, fissures",
    "Meckel's diverticulum — Young patients",
    "Infectious colitis — Campylobacter, C. diff",
  ], { fontSize: 13 }), {
    x: 5.0, y: 1.5, w: 4.6, h: 3.7,
    fontFace: "Calibri", valign: "top",
  });

  // Key note
  s.addText("⚠  One-third of presumed LGIB has an upper GI source — always assess with NG tube or upper endoscopy first", {
    x: 0.3, y: 5.2, w: 9.4, h: 0.32,
    fontSize: 11, color: C.yellow, fontFace: "Calibri", align: "center",
  });
}

// ──────────────────────────────────────────────────────────────────────────────
// SLIDE 5 — PATHOPHYSIOLOGY OVERVIEW
// ──────────────────────────────────────────────────────────────────────────────
{
  const s = pres.addSlide();
  bgRect(s);
  leftStripe(s, C.accent1);
  headerBar(s, "Pathophysiology — The Hemorrhagic Cascade", C.accent1);

  // Cascade flow chart using boxes + arrows
  const steps = [
    { text: "GI HEMORRHAGE\n(Acute Blood Loss)", color: C.accent1 },
    { text: "↓ Circulating Blood Volume\n(Intravascular Depletion)", color: "7B1E1E" },
    { text: "↓ Venous Return (Preload)\n↓ Right Atrial Pressure", color: "8B2500" },
    { text: "↓ Cardiac Output\n(Frank-Starling mechanism)", color: "1A4A6E" },
    { text: "↓ Mean Arterial Pressure\n↓ Oxygen Delivery to Tissues", color: "0D3A50" },
    { text: "CELLULAR HYPOXIA\n→ Anaerobic Metabolism → Lactic Acidosis", color: "1A2A10" },
  ];

  const boxW = 1.45, boxH = 0.72, startX = 0.22, gapX = 0.14, y = 1.15;
  steps.forEach((st, i) => {
    const x = startX + i * (boxW + gapX);
    s.addShape(pres.ShapeType.roundRect, {
      x, y, w: boxW, h: boxH,
      rectRadius: 0.07,
      fill: { color: st.color },
      line: { color: C.white, width: 1 },
    });
    s.addText(st.text, {
      x, y, w: boxW, h: boxH,
      fontSize: 9.5, color: C.white, bold: true,
      fontFace: "Calibri", align: "center", valign: "middle",
    });
    if (i < steps.length - 1) {
      s.addShape(pres.ShapeType.rect, {
        x: x + boxW, y: y + boxH / 2 - 0.04, w: gapX, h: 0.08,
        fill: { color: C.accent2 }, line: { color: C.accent2 },
      });
    }
  });

  // Sympathetic activation box
  s.addShape(pres.ShapeType.rect, {
    x: 0.22, y: 2.0, w: "95%", h: 0.05,
    fill: { color: C.accent2 }, line: { color: C.accent2 },
  });

  s.addText("SYMPATHETIC NERVOUS SYSTEM ACTIVATION (Baroreceptor Reflex)", {
    x: 0.22, y: 2.1, w: 9.5, h: 0.3,
    fontSize: 13, bold: true, color: C.accent2,
    fontFace: "Calibri", align: "center",
  });

  const snsCols = [
    {
      title: "Cardiovascular",
      items: ["↑ Heart rate (tachycardia)", "↑ Myocardial contractility", "Arteriolar constriction → ↑ SVR", "Venous constriction → ↑ venous return", "Redistribution to heart & brain"],
    },
    {
      title: "Hormonal (RAAS + ADH)",
      items: ["↑ Renin → Angiotensin II", "↑ Aldosterone → Na⁺ / H₂O retention", "↑ ADH / Vasopressin → ↑ water reabsorption", "↑ Cortisol & catecholamines", "Stress hyperglycemia"],
    },
    {
      title: "Cellular / Microvascular",
      items: ["Transcapillary fluid shift (Starling)", "↓ Capillary hydrostatic pressure", "Protein oncotic absorption from interstitium", "Microcirculatory failure in Class III–IV", "Reperfusion injury & SIRS if prolonged"],
    },
  ];

  snsCols.forEach((col, i) => {
    const x = 0.22 + i * 3.25;
    s.addShape(pres.ShapeType.roundRect, {
      x, y: 2.5, w: 3.1, h: 2.9,
      rectRadius: 0.08,
      fill: { color: "0C1E30" },
      line: { color: C.accent3, width: 1.5 },
    });
    s.addText(col.title, {
      x, y: 2.5, w: 3.1, h: 0.38,
      fontSize: 12, bold: true, color: C.accent3,
      fontFace: "Calibri", align: "center", valign: "middle",
    });
    s.addText(bullets(col.items, { fontSize: 11, spaceBefore: 3 }), {
      x: x + 0.1, y: 2.9, w: 2.9, h: 2.45,
      fontFace: "Calibri", valign: "top",
    });
  });
}

// ──────────────────────────────────────────────────────────────────────────────
// SLIDE 6 — DETAILED PHYSIOLOGY
// ──────────────────────────────────────────────────────────────────────────────
{
  const s = pres.addSlide();
  bgRect(s);
  leftStripe(s, C.accent3);
  headerBar(s, "Compensatory Physiology in Detail", C.accent3);

  const leftItems = [
    "Baroreceptors in carotid sinus & aortic arch detect ↓ BP",
    "Signal to vasomotor center → massive sympathetic discharge",
    "HR increases from 72 to 160–180 bpm",
    "Arterioles constrict → ↑ total peripheral resistance (TPR)",
    "Venous reservoirs constrict → maintain venous return",
    "CNS ischemic response: 'last stand' reflex — extreme SNS stimulation when brain O₂ falls, maintains BP at second plateau ~50 mmHg",
    "Coronary & cerebral blood flow preferentially preserved",
  ];

  const rightItems = [
    "10% blood loss: no measurable change in BP or HR",
    "15–20% loss: tachycardia + narrowed pulse pressure begins",
    "30–40% loss: hypotension occurs (BP maintained by reflexes until this point)",
    "40–45% loss: cardiac output and BP fall to zero",
    "Without sympathetic reflexes: only 15–20% loss = death",
    "With intact reflexes: can survive 30–40% loss",
    "Pa = CO × TPR: pressure maintained by ↑ TPR even as CO falls",
  ];

  s.addText("Sympathetic Reflex Compensations", {
    x: 0.35, y: 1.1, w: 4.5, h: 0.35,
    fontSize: 13, bold: true, color: C.accent2,
    fontFace: "Calibri",
  });
  s.addText(bullets(leftItems, { fontSize: 12, spaceBefore: 5 }), {
    x: 0.35, y: 1.45, w: 4.5, h: 3.9,
    fontFace: "Calibri", valign: "top",
  });

  s.addShape(pres.ShapeType.line, {
    x: 5.1, y: 1.1, w: 0, h: 4.35,
    line: { color: C.gray, width: 0.5 },
  });

  s.addText("Blood Volume Threshold Effects", {
    x: 5.2, y: 1.1, w: 4.5, h: 0.35,
    fontSize: 13, bold: true, color: C.accent2,
    fontFace: "Calibri",
  });
  s.addText(bullets(rightItems, { fontSize: 12, spaceBefore: 5 }), {
    x: 5.2, y: 1.45, w: 4.5, h: 3.9,
    fontFace: "Calibri", valign: "top",
  });

  // Bottom note
  s.addShape(pres.ShapeType.rect, {
    x: 0.22, y: 5.25, w: 9.56, h: 0.27,
    fill: { color: "0C1E30" }, line: { color: "0C1E30" },
  });
  s.addText("Source: Guyton & Hall Medical Physiology — Blood volume estimated at 7% of ideal body weight (~4,900 mL in 70 kg adult)", {
    x: 0.22, y: 5.25, w: 9.56, h: 0.27,
    fontSize: 9, color: C.gray, fontFace: "Calibri", align: "center",
  });
}

// ──────────────────────────────────────────────────────────────────────────────
// SLIDE 7 — ATLS CLASSIFICATION
// ──────────────────────────────────────────────────────────────────────────────
{
  const s = pres.addSlide();
  bgRect(s);
  headerBar(s, "ATLS Classification of Hemorrhagic Shock", C.accent1);

  const headers = ["Parameter", "Class I", "Class II", "Class III", "Class IV"];
  const rows = [
    ["Blood Loss (mL)", "<750", "800–1,500", "1,500–2,000", ">2,000"],
    ["Blood Loss (%)", "<15%", "15–30%", "30–40%", ">40%"],
    ["Heart Rate (bpm)", "<100", "100–120", "120–140", ">140"],
    ["Systolic BP", "Normal", "Normal", "↓", "↓↓"],
    ["Pulse Pressure", "Normal/↑", "↓", "↓", "↓↓"],
    ["Respiratory Rate", "14–20", "20–30", "30–40", ">35"],
    ["Urine Output (mL/hr)", ">30", "20–30", "5–15", "Negligible"],
    ["Mental Status", "Slightly anxious", "Mildly anxious", "Confused / aggressive", "Lethargic / coma"],
    ["Capillary Refill", "Normal", "Delayed", "Delayed", "Absent"],
    ["Fluid Replacement", "Crystalloid ± blood", "Crystalloid", "Blood + crystalloid", "Blood + surgery/IR"],
  ];

  const rowColors = ["1A2E40", "162636", "1A2E40", "162636", "1A2E40", "162636", "1A2E40", "162636", "1A2E40", "162636"];
  const classColors = [null, "1A5200", "946300", "8B2500", C.accent1];

  // Header row
  headers.forEach((h, col) => {
    const x = 0.12 + col * 1.93;
    s.addShape(pres.ShapeType.rect, {
      x, y: 1.0, w: 1.88, h: 0.38,
      fill: { color: classColors[col] || "1A0000" },
      line: { color: C.bg, width: 0.5 },
    });
    s.addText(h, {
      x, y: 1.0, w: 1.88, h: 0.38,
      fontSize: 11, bold: true, color: C.white, fontFace: "Calibri",
      align: "center", valign: "middle",
    });
  });

  rows.forEach((row, ri) => {
    row.forEach((cell, col) => {
      const x = 0.12 + col * 1.93;
      const y = 1.4 + ri * 0.41;
      s.addShape(pres.ShapeType.rect, {
        x, y, w: 1.88, h: 0.4,
        fill: { color: rowColors[ri] },
        line: { color: C.bg, width: 0.5 },
      });
      s.addText(cell, {
        x, y, w: 1.88, h: 0.4,
        fontSize: col === 0 ? 10.5 : 11,
        bold: col === 0,
        color: col === 0 ? C.accent2 : C.offWhite,
        fontFace: "Calibri", align: "center", valign: "middle",
      });
    });
  });

  s.addText("Source: ATLS (American College of Surgeons) · Mulholland & Greenfield Surgery", {
    x: 0.12, y: 5.52, w: 9.76, h: 0.2,
    fontSize: 8, color: C.gray, fontFace: "Calibri", align: "center",
  });
}

// ──────────────────────────────────────────────────────────────────────────────
// SLIDE 8 — SIGNS & SYMPTOMS
// ──────────────────────────────────────────────────────────────────────────────
{
  const s = pres.addSlide();
  bgRect(s);
  leftStripe(s, C.accent2);
  headerBar(s, "Signs & Symptoms", C.accent2);

  const cols = [
    {
      title: "🩸 GI Bleeding Signs",
      color: C.accent1,
      items: [
        "Hematemesis — Fresh blood or 'coffee-ground' vomitus",
        "Melena — Black, tarry, malodorous stools (upper source)",
        "Hematochezia — Bright red blood per rectum (rapid UGIB or LGIB)",
        "Occult blood — Guaiac-positive stool, iron-deficiency anemia",
        "Rectal bleeding — Variable from hemorrhoids to massive LGIB",
      ],
    },
    {
      title: "💉 Shock Signs",
      color: "1A6091",
      items: [
        "Tachycardia — Often earliest sign (HR >100 bpm)",
        "Hypotension — Systolic <90 mmHg (late sign!)",
        "Narrow pulse pressure (<20 mmHg)",
        "Tachypnea — Compensatory hyperventilation",
        "Pallor, diaphoresis, cold clammy skin",
        "Delayed capillary refill (>2 sec)",
        "Oliguria or anuria (<0.5 mL/kg/hr)",
        "Altered mental status — Confusion, agitation, obtundation",
      ],
    },
    {
      title: "🔍 History Clues",
      color: "1A5200",
      items: [
        "NSAIDs / aspirin / anticoagulant use",
        "Alcohol use / liver disease / cirrhosis",
        "Prior peptic ulcer disease or varices",
        "H. pylori history",
        "Prior GI surgeries / aortic graft",
        "Syncope / presyncope / lightheadedness",
        "Orthostatic symptoms",
        "Weight loss → malignancy?",
      ],
    },
  ];

  cols.forEach((col, i) => {
    const x = 0.22 + i * 3.28;
    s.addShape(pres.ShapeType.roundRect, {
      x, y: 1.1, w: 3.1, h: 0.38,
      rectRadius: 0.06,
      fill: { color: col.color },
      line: { color: col.color },
    });
    s.addText(col.title, {
      x, y: 1.1, w: 3.1, h: 0.38,
      fontSize: 12, bold: true, color: C.white,
      fontFace: "Calibri", align: "center", valign: "middle", margin: 0,
    });
    s.addText(bullets(col.items, { fontSize: 11.5, spaceBefore: 4 }), {
      x: x + 0.05, y: 1.5, w: 3.05, h: 3.9,
      fontFace: "Calibri", valign: "top",
    });
  });

  s.addText("⚠ Tachycardia may be masked by beta-blockers, pacemakers, or athletic conditioning — do not rely on HR alone!", {
    x: 0.22, y: 5.2, w: 9.56, h: 0.3,
    fontSize: 11, color: C.yellow, fontFace: "Calibri", align: "center",
    bold: true,
  });
}

// ──────────────────────────────────────────────────────────────────────────────
// SLIDE 9 — DIAGNOSIS
// ──────────────────────────────────────────────────────────────────────────────
{
  const s = pres.addSlide();
  bgRect(s);
  leftStripe(s, C.accent3);
  headerBar(s, "Diagnosis — Labs, Imaging & Risk Stratification", C.accent3);

  // Labs column
  s.addText("LABORATORY TESTS", {
    x: 0.3, y: 1.1, w: 4.6, h: 0.3,
    fontSize: 12, bold: true, color: C.accent3, fontFace: "Calibri", charSpacing: 1,
  });
  s.addText(bullets([
    "CBC — Hgb, Hct (may be normal early in acute bleeding)",
    "BMP / Chem — BUN:Creatinine ratio >30 suggests upper GI source",
    "Coagulation — PT, INR, aPTT, fibrinogen",
    "Type & Screen / Crossmatch — Order IMMEDIATELY",
    "Lactate — Elevated in tissue hypoperfusion (>2 mmol/L)",
    "ABG — pH, base excess, PaO₂, CO₂",
    "LFTs, albumin — Assess liver disease / varices risk",
    "Platelet count — Thrombocytopenia common in cirrhosis",
    "TEG / ROTEM — Viscoelastic testing for massive hemorrhage",
    "Shock Index = HR ÷ SBP (>1.0 = severe shock)",
  ], { fontSize: 12, spaceBefore: 3 }), {
    x: 0.3, y: 1.42, w: 4.5, h: 4.0,
    fontFace: "Calibri", valign: "top",
  });

  // Right column
  s.addText("IMAGING & ENDOSCOPY", {
    x: 5.1, y: 1.1, w: 4.7, h: 0.3,
    fontSize: 12, bold: true, color: C.accent2, fontFace: "Calibri", charSpacing: 1,
  });
  s.addText(bullets([
    "POCUS — IVC collapsibility, 'kissing walls' LV sign, pericardial effusion",
    "Chest/Abdominal X-ray — Free air, obstruction, aortic widening",
    "CT Angiography — Localizes bleeding (≥0.3–0.5 mL/min), preferred before IR",
    "Upper GI Endoscopy — Gold standard for upper GI; both diagnostic & therapeutic",
    "Colonoscopy — Locates lower GI source after prep (if stable)",
    "Tagged RBC scan (Tc-99m) — Detects slow bleeding ≥0.1 mL/min",
    "Angiography — Detects ≥0.5 mL/min; allows embolization",
  ], { fontSize: 12, spaceBefore: 3 }), {
    x: 5.1, y: 1.42, w: 4.6, h: 2.4,
    fontFace: "Calibri", valign: "top",
  });

  s.addText("RISK SCORES", {
    x: 5.1, y: 3.95, w: 4.7, h: 0.3,
    fontSize: 12, bold: true, color: C.accent2, fontFace: "Calibri", charSpacing: 1,
  });
  const scores = [
    ["Glasgow-Blatchford (GBS)", "Pre-endoscopy; predicts need for intervention (score ≥7 = high risk)"],
    ["Rockall Score", "Post-endoscopy; predicts rebleeding & mortality"],
    ["AIMS65", "Albumin, INR, Mental status, SBP, Age ≥65; predicts mortality"],
    ["Shock Index (SI)", "HR/SBP — SI >1.0 predicts hemodynamic instability"],
  ];
  scores.forEach((sc, i) => {
    s.addText([
      { text: sc[0] + ": ", options: { bold: true, color: C.yellow, fontSize: 11 } },
      { text: sc[1], options: { color: C.offWhite, fontSize: 11 } },
    ], {
      x: 5.1, y: 4.27 + i * 0.29, w: 4.6, h: 0.28,
      fontFace: "Calibri",
    });
  });
}

// ──────────────────────────────────────────────────────────────────────────────
// SLIDE 10 — STEP-BY-STEP EMERGENCY MANAGEMENT
// ──────────────────────────────────────────────────────────────────────────────
{
  const s = pres.addSlide();
  bgRect(s);
  headerBar(s, "Step-by-Step Emergency Management", C.accent1);

  const steps = [
    {
      num: "1",
      title: "IMMEDIATE RESUSCITATION (0–5 min)",
      color: C.accent1,
      items: [
        "Activate massive transfusion protocol (MTP) if severe shock",
        "Two large-bore IVs (16G or larger) in antecubital fossa",
        "Intraosseous access if IV fails",
        "Supplemental O₂ / prepare for airway management",
        "Cardiac monitor, pulse oximetry, continuous BP monitoring",
        "Position: supine, legs elevated (Trendelenburg if BP <70)",
      ],
    },
    {
      num: "2",
      title: "FLUID RESUSCITATION (5–20 min)",
      color: C.accent2,
      items: [
        "Warm isotonic crystalloid (NS or LR) — 1–2 L bolus initially",
        "Goal MAP ≥65 mmHg (permissive hypotension ~80–90 SBP until bleeding controlled)",
        "Type & Screen STAT — prepare blood products",
        "pRBCs 1 unit if Hgb <7 g/dL or hemodynamically unstable",
        "For hemorrhagic shock: 1:1:1 ratio pRBC : FFP : Platelets (MTP)",
        "Target: Hgb 7–9, PLT >50k, INR <1.5, fibrinogen >200",
      ],
    },
    {
      num: "3",
      title: "DIAGNOSTIC WORKUP (Simultaneous)",
      color: C.accent3,
      items: [
        "CBC, BMP, coags, type & cross, lactate, LFTs, ABG",
        "POCUS — assess cardiac function, IVC collapsibility",
        "NG tube lavage — bloody = upper GI source",
        "Risk stratify: GBS, Rockall, AIMS65",
        "CT angiography if hemodynamically stable",
      ],
    },
  ];

  const boxH = 3.5, startY = 1.05;
  steps.forEach((st, i) => {
    const x = 0.18 + i * 3.27;
    // Number circle
    s.addShape(pres.ShapeType.ellipse, {
      x: x + 0.05, y: startY - 0.02, w: 0.45, h: 0.45,
      fill: { color: st.color },
      line: { color: C.white, width: 1 },
    });
    s.addText(st.num, {
      x: x + 0.05, y: startY - 0.02, w: 0.45, h: 0.45,
      fontSize: 15, bold: true, color: C.white,
      fontFace: "Calibri", align: "center", valign: "middle",
    });

    // Title
    s.addText(st.title, {
      x: x + 0.55, y: startY, w: 2.55, h: 0.42,
      fontSize: 10, bold: true, color: st.color,
      fontFace: "Calibri", valign: "middle",
    });

    // Content box
    s.addShape(pres.ShapeType.roundRect, {
      x, y: startY + 0.45, w: 3.1, h: boxH - 0.45,
      rectRadius: 0.06,
      fill: { color: "0C1E30" },
      line: { color: st.color, width: 1 },
    });
    s.addText(bullets(st.items, { fontSize: 11.5, spaceBefore: 5 }), {
      x: x + 0.1, y: startY + 0.55, w: 2.9, h: boxH - 0.6,
      fontFace: "Calibri", valign: "top",
    });
  });

  s.addText("Simultaneously stabilize + diagnose + call GI / Surgery / IR team early", {
    x: 0.18, y: 5.25, w: 9.6, h: 0.3,
    fontSize: 11.5, bold: true, color: C.yellow, fontFace: "Calibri", align: "center",
  });
}

// ──────────────────────────────────────────────────────────────────────────────
// SLIDE 11 — RESUSCITATION STRATEGIES
// ──────────────────────────────────────────────────────────────────────────────
{
  const s = pres.addSlide();
  bgRect(s);
  leftStripe(s, C.accent1);
  headerBar(s, "Resuscitation Strategies & Massive Transfusion Protocol", C.accent1);

  // MTP Box
  s.addShape(pres.ShapeType.roundRect, {
    x: 0.3, y: 1.1, w: 4.5, h: 4.2,
    rectRadius: 0.1,
    fill: { color: "1A0A0A" },
    line: { color: C.accent1, width: 2 },
  });
  s.addText("MASSIVE TRANSFUSION PROTOCOL (MTP)", {
    x: 0.3, y: 1.1, w: 4.5, h: 0.42,
    fontSize: 12, bold: true, color: C.accent1,
    fontFace: "Calibri", align: "center", valign: "middle",
  });
  s.addText(bullets([
    "Trigger: >10 units pRBC in 24h, or >4 units in 1h, or ongoing hemorrhagic shock",
    "Ratio: 1:1:1 — pRBC : FFP : Platelets",
    "Alternative: Fresh Whole Blood (superior if available)",
    "Add cryoprecipitate if fibrinogen <150–200 mg/dL",
    "Tranexamic Acid (TXA): 1g IV over 10 min (within 3h of bleeding onset)",
    "Calcium gluconate — Replace after every 4 units pRBC to prevent hypocalcemia",
    "Warm all fluids — Target normothermia",
    "Monitor with TEG / ROTEM for goal-directed transfusion",
    "Avoid overresuscitation with crystalloids — dilutional coagulopathy risk",
  ], { fontSize: 11.5, spaceBefore: 4 }), {
    x: 0.4, y: 1.52, w: 4.3, h: 3.7,
    fontFace: "Calibri", valign: "top",
  });

  // Targets Box
  s.addShape(pres.ShapeType.roundRect, {
    x: 5.1, y: 1.1, w: 4.6, h: 2.1,
    rectRadius: 0.1,
    fill: { color: "0A1520" },
    line: { color: C.accent3, width: 2 },
  });
  s.addText("RESUSCITATION ENDPOINTS", {
    x: 5.1, y: 1.1, w: 4.6, h: 0.38,
    fontSize: 12, bold: true, color: C.accent3,
    fontFace: "Calibri", align: "center", valign: "middle",
  });
  const targets = [
    ["MAP", "≥65 mmHg (60 in traumatic hemorrhage)"],
    ["Hgb", "7–9 g/dL (restrictive strategy)"],
    ["Platelets", ">50,000/μL (>100k if intracranial)"],
    ["INR", "<1.5"],
    ["Fibrinogen", ">200 mg/dL"],
    ["Lactate", "Normalize (<2 mmol/L)"],
    ["Urine Output", "≥0.5 mL/kg/hr"],
    ["Temperature", ">35°C"],
  ];
  targets.forEach((t, i) => {
    s.addText([
      { text: t[0] + ": ", options: { bold: true, color: C.yellow, fontSize: 11.5 } },
      { text: t[1], options: { color: C.offWhite, fontSize: 11.5 } },
    ], {
      x: 5.2, y: 1.5 + i * 0.215, w: 4.4, h: 0.22,
      fontFace: "Calibri",
    });
  });

  // "Lethal Triad" box
  s.addShape(pres.ShapeType.roundRect, {
    x: 5.1, y: 3.3, w: 4.6, h: 1.95,
    rectRadius: 0.1,
    fill: { color: "1A0A0A" },
    line: { color: C.accent2, width: 2 },
  });
  s.addText("☠ LETHAL TRIAD — Avoid / Reverse", {
    x: 5.1, y: 3.3, w: 4.6, h: 0.38,
    fontSize: 12, bold: true, color: C.accent2,
    fontFace: "Calibri", align: "center", valign: "middle",
  });
  s.addText(bullets([
    "Hypothermia — Impairs clotting enzymes; warm fluids & blankets",
    "Acidosis — Metabolic (lactic); bicarbonate rarely needed, fix perfusion",
    "Coagulopathy — Dilutional + consumptive; FFP + cryo + TXA",
  ], { fontSize: 12, spaceBefore: 5 }), {
    x: 5.2, y: 3.7, w: 4.4, h: 1.5,
    fontFace: "Calibri", valign: "top",
  });
}

// ──────────────────────────────────────────────────────────────────────────────
// SLIDE 12 — HEMOSTASIS: ENDOSCOPY / IR / SURGERY
// ──────────────────────────────────────────────────────────────────────────────
{
  const s = pres.addSlide();
  bgRect(s);
  leftStripe(s, C.accent3);
  headerBar(s, "Hemostasis — Endoscopy, IR & Surgery", C.accent3);

  const cols = [
    {
      title: "ENDOSCOPIC THERAPY",
      color: C.accent3,
      items: [
        "Upper GI: EGD within 24h (12–24h if high risk, after stabilization)",
        "Injection therapy — Epinephrine 1:10,000 into bleeding vessel",
        "Thermal coagulation — Heater probe, bipolar cautery",
        "Hemoclips — Mechanical closure of bleeding vessel",
        "Band ligation — Esophageal varices (variceal bleeding)",
        "TIPS — Transjugular intrahepatic portosystemic shunt for refractory varices",
        "Colonoscopy — LGIB if hemodynamically stable post-prep",
        "Lower GI endoscopic coagulation / clips",
      ],
    },
    {
      title: "INTERVENTIONAL RADIOLOGY",
      color: C.accent2,
      items: [
        "CT angiography first to localize bleeding",
        "Mesenteric angiography — Active bleeding ≥0.5 mL/min",
        "Transcatheter arterial embolization (TAE) — Coils, gel foam",
        "Particularly useful for lower GI diverticular bleeding",
        "Bronchial artery embolization for hemoptysis",
        "TIPS for portal hypertension / variceal hemorrhage",
        "Superior to surgery in frail patients — less morbidity",
      ],
    },
    {
      title: "SURGERY",
      color: C.accent1,
      items: [
        "Indications: Failure of endoscopy + IR, perforation, peritonitis",
        "Massive hemorrhage requiring >6 units pRBC with no source control",
        "Upper GI: Oversew ulcer, vagotomy, antrectomy",
        "Variceal: Splenorenal shunt, devascularization procedures",
        "Lower GI: Segmental colectomy (must localize first!)",
        "Damage Control Surgery — Temporary packing + ICU stabilization",
        "Total colectomy as last resort for unlocalized LGIB",
      ],
    },
  ];

  cols.forEach((col, i) => {
    const x = 0.22 + i * 3.27;
    s.addShape(pres.ShapeType.roundRect, {
      x, y: 1.08, w: 3.1, h: 0.38,
      rectRadius: 0.05,
      fill: { color: col.color },
      line: { color: col.color },
    });
    s.addText(col.title, {
      x, y: 1.08, w: 3.1, h: 0.38,
      fontSize: 11.5, bold: true, color: C.white,
      fontFace: "Calibri", align: "center", valign: "middle", margin: 0,
    });
    s.addText(bullets(col.items, { fontSize: 11.5, spaceBefore: 4 }), {
      x: x + 0.1, y: 1.48, w: 2.9, h: 4.05,
      fontFace: "Calibri", valign: "top",
    });
  });

  s.addText("Escalate to surgery early: anesthesia, OR, and blood bank should be notified when MTP is activated", {
    x: 0.22, y: 5.25, w: 9.56, h: 0.28,
    fontSize: 11, color: C.yellow, bold: true, fontFace: "Calibri", align: "center",
  });
}

// ──────────────────────────────────────────────────────────────────────────────
// SLIDE 13 — VARICEAL BLEEDING SPECIAL TOPIC
// ──────────────────────────────────────────────────────────────────────────────
{
  const s = pres.addSlide();
  bgRect(s);
  leftStripe(s, "7B2D8B");
  headerBar(s, "Special Topic: Variceal Bleeding in Portal Hypertension", "7B2D8B");

  s.addText(
    "Variceal hemorrhage carries 20–30% mortality per episode. Cirrhosis → portal HTN → ↑ resistance → collateral formation (esophageal & gastric varices).",
    {
      x: 0.35, y: 1.12, w: 9.3, h: 0.55,
      fontSize: 13, color: C.offWhite, fontFace: "Calibri", wrap: true,
    }
  );

  const lc = [
    {
      title: "Initial Management",
      color: C.accent1,
      items: [
        "Airway protection — High aspiration risk; early intubation",
        "Avoid over-transfusion: target Hgb 7–8 (over-resuscitation worsens portal pressure)",
        "Terlipressin 2 mg IV q4h (or octreotide 50 mcg bolus + 50 mcg/h infusion)",
        "Vasoactive agent BEFORE endoscopy — Reduces mortality",
        "Prophylactic antibiotics: ceftriaxone 1g/day × 7 days (reduces SBP & rebleeding)",
        "Lactulose / rifaximin for hepatic encephalopathy prevention",
      ],
    },
    {
      title: "Endoscopic & Definitive",
      color: "7B2D8B",
      items: [
        "EGD within 12 hours of presentation",
        "Esophageal variceal ligation (EVL) — First-line over sclerotherapy",
        "N-butyl-2-cyanoacrylate (glue) for gastric varices",
        "Balloon tamponade (Sengstaken-Blakemore tube) — Bridge to definitive therapy, max 24h",
        "TIPS — If endoscopy fails; 90% success in hemorrhage control",
        "Early TIPS (within 72h) in Child-Pugh B/C — Improves survival",
        "Beta-blockers (propranolol/nadolol) + EVL for secondary prophylaxis",
      ],
    },
  ];

  lc.forEach((col, i) => {
    const x = 0.3 + i * 5.0;
    s.addShape(pres.ShapeType.roundRect, {
      x, y: 1.75, w: 4.6, h: 0.38,
      rectRadius: 0.05,
      fill: { color: col.color },
      line: { color: col.color },
    });
    s.addText(col.title, {
      x, y: 1.75, w: 4.6, h: 0.38,
      fontSize: 12, bold: true, color: C.white,
      fontFace: "Calibri", align: "center", valign: "middle", margin: 0,
    });
    s.addText(bullets(col.items, { fontSize: 12, spaceBefore: 4 }), {
      x: x + 0.1, y: 2.15, w: 4.4, h: 3.05,
      fontFace: "Calibri", valign: "top",
    });
  });

  s.addText("MELD score predicts 90-day mortality in cirrhotic patients with variceal bleeding — consider hepatology & transplant referral", {
    x: 0.3, y: 5.22, w: 9.4, h: 0.3,
    fontSize: 11, color: C.yellow, bold: true, fontFace: "Calibri", align: "center",
  });
}

// ──────────────────────────────────────────────────────────────────────────────
// SLIDE 14 — MEDICATIONS QUICK REFERENCE
// ──────────────────────────────────────────────────────────────────────────────
{
  const s = pres.addSlide();
  bgRect(s);
  leftStripe(s, C.accent2);
  headerBar(s, "Pharmacological Management — Quick Reference", C.accent2);

  const drugs = [
    ["Drug", "Dose / Route", "Indication", "Notes"],
    ["Tranexamic Acid (TXA)", "1g IV over 10 min → 1g over 8h", "Hemorrhagic shock", "Within 3h of onset; anti-fibrinolytic"],
    ["Octreotide", "50 mcg IV bolus → 50 mcg/h infusion", "Variceal bleeding", "Reduces portal pressure"],
    ["Terlipressin", "1–2 mg IV q4–6h", "Variceal bleeding", "Superior to octreotide; not in all countries"],
    ["PPI (Pantoprazole)", "80 mg IV bolus → 8 mg/h infusion", "Peptic ulcer / non-variceal", "Pre- and post-endoscopy"],
    ["Ceftriaxone", "1g IV daily × 7 days", "Variceal + cirrhosis", "Prevents SBP, reduces rebleeding"],
    ["Vasopressin", "0.03–0.04 units/min IV", "Refractory hemorrhagic shock", "Bridge; give with nitroglycerin"],
    ["Norepinephrine", "0.01–3 mcg/kg/min IV", "Refractory shock, vasodilation", "Use after volume optimization"],
    ["FFP", "1:1:1 with pRBC + platelets", "Coagulopathy / MTP", "4 units FFP per 4 units pRBC"],
    ["Vitamin K", "10 mg IV (slow)", "Warfarin reversal", "Takes 6–12h; use 4-factor PCC urgently"],
    ["4-Factor PCC (KCentra)", "25–50 units/kg IV", "Urgent warfarin reversal", "Rapid reversal; give with Vitamin K"],
  ];

  const colW = [2.3, 2.0, 1.9, 3.4];
  const startX = 0.1;
  drugs.forEach((row, ri) => {
    row.forEach((cell, ci) => {
      const x = startX + colW.slice(0, ci).reduce((a, b) => a + b, 0);
      const y = 1.05 + ri * 0.43;
      s.addShape(pres.ShapeType.rect, {
        x, y, w: colW[ci], h: 0.42,
        fill: { color: ri === 0 ? C.accent2 : ri % 2 === 0 ? "1A2E40" : "0C1E30" },
        line: { color: C.bg, width: 0.5 },
      });
      s.addText(cell, {
        x, y, w: colW[ci], h: 0.42,
        fontSize: ri === 0 ? 11 : 10.5,
        bold: ri === 0 || ci === 0,
        color: ri === 0 ? C.darkBg : ci === 0 ? C.yellow : C.offWhite,
        fontFace: "Calibri", align: ri === 0 ? "center" : "left", valign: "middle",
        margin: 4,
      });
    });
  });
}

// ──────────────────────────────────────────────────────────────────────────────
// SLIDE 15 — DISPOSITION & MONITORING
// ──────────────────────────────────────────────────────────────────────────────
{
  const s = pres.addSlide();
  bgRect(s);
  leftStripe(s, C.accent3);
  headerBar(s, "Disposition, Monitoring & Follow-up", C.accent3);

  const panels = [
    {
      title: "ICU ADMISSION CRITERIA",
      color: C.accent1,
      x: 0.3, y: 1.1, w: 4.4, h: 2.2,
      items: [
        "Class III or IV hemorrhagic shock",
        "Active variceal bleeding",
        "Age >60 + significant comorbidities",
        "Active ongoing transfusion requirements",
        "Post-emergency endoscopy or IR embolization",
        "Hemodynamic instability despite initial resuscitation",
        "Intubated patients",
      ],
    },
    {
      title: "CONTINUOUS MONITORING",
      color: C.accent3,
      x: 5.1, y: 1.1, w: 4.6, h: 2.2,
      items: [
        "Arterial line for continuous BP in severe shock",
        "Central venous catheter — CVP trending, vasoactive drugs",
        "Foley catheter — Urine output every hour",
        "Serial CBC, coags, lactate q2–4h until stable",
        "Pulse oximetry + capnography",
        "Repeat POCUS to reassess IVC / cardiac function",
        "ECG monitoring for arrhythmias",
      ],
    },
    {
      title: "DISCHARGE CRITERIA (Low-Risk GIB)",
      color: "1A5200",
      x: 0.3, y: 3.45, w: 4.4, h: 2.1,
      items: [
        "GBS score = 0: Low-risk — consider outpatient management",
        "Hemodynamically stable for ≥24h",
        "Hgb stable (not declining) ≥24h",
        "No high-risk endoscopic stigmata",
        "Reliable social support + close follow-up arranged",
        "Non-variceal source with successful hemostasis",
        "PPI therapy initiated",
      ],
    },
    {
      title: "SECONDARY PREVENTION",
      color: "7B2D8B",
      x: 5.1, y: 3.45, w: 4.6, h: 2.1,
      items: [
        "H. pylori testing and eradication if peptic ulcer",
        "PPI therapy long-term if NSAID use cannot be stopped",
        "Non-selective beta-blockers + EVL for varices",
        "Reduce alcohol / manage liver disease",
        "Anticoagulation reversal review — Balance thrombosis vs. bleeding",
        "Outpatient GI follow-up within 1–2 weeks",
        "Repeat endoscopy at 2–4 weeks for high-risk stigmata",
      ],
    },
  ];

  panels.forEach((p) => {
    s.addShape(pres.ShapeType.roundRect, {
      x: p.x, y: p.y, w: p.w, h: 0.38,
      rectRadius: 0.06,
      fill: { color: p.color },
      line: { color: p.color },
    });
    s.addText(p.title, {
      x: p.x, y: p.y, w: p.w, h: 0.38,
      fontSize: 11.5, bold: true, color: C.white,
      fontFace: "Calibri", align: "center", valign: "middle", margin: 0,
    });
    s.addShape(pres.ShapeType.roundRect, {
      x: p.x, y: p.y + 0.38, w: p.w, h: p.h - 0.38,
      rectRadius: 0.06,
      fill: { color: "0C1E30" },
      line: { color: p.color, width: 1 },
    });
    s.addText(bullets(p.items, { fontSize: 11, spaceBefore: 3 }), {
      x: p.x + 0.1, y: p.y + 0.44, w: p.w - 0.2, h: p.h - 0.5,
      fontFace: "Calibri", valign: "top",
    });
  });
}

// ──────────────────────────────────────────────────────────────────────────────
// SLIDE 16 — SUMMARY ALGORITHM
// ──────────────────────────────────────────────────────────────────────────────
{
  const s = pres.addSlide();
  bgRect(s, C.darkBg);
  headerBar(s, "Emergency Algorithm — GI Bleeding with Hypovolemic Shock", C.accent1);

  const alg = [
    { step: "PRESENTATION", text: "GI Bleeding + Hemodynamic Instability", color: C.accent1 },
    { step: "PRIMARY SURVEY", text: "Airway • Breathing • Circulation • 2 large-bore IVs • Labs • Monitor", color: "1A6091" },
    { step: "RESUSCITATE", text: "Warm crystalloid 1–2L → Blood products 1:1:1 → Activate MTP if needed → TXA 1g IV", color: "7B1E1E" },
    { step: "RISK STRATIFY", text: "Glasgow-Blatchford Score • Rockall • AIMS65 • Shock Index", color: "1A5200" },
    { step: "DIAGNOSE", text: "POCUS → NG tube → CT angiography (stable) → EGD within 12–24h", color: "7B4A00" },
    { step: "TREAT SOURCE", text: "Endoscopy (clips/cautery/bands) → IR embolization → Surgery if refractory", color: "7B2D8B" },
    { step: "DISPOSITION", text: "ICU if Class III–IV / active bleeding / variceal / post-procedure", color: "0D5E5E" },
  ];

  alg.forEach((a, i) => {
    const y = 1.1 + i * 0.61;
    // Step badge
    s.addShape(pres.ShapeType.roundRect, {
      x: 0.2, y, w: 1.6, h: 0.5,
      rectRadius: 0.05,
      fill: { color: a.color },
      line: { color: a.color },
    });
    s.addText(a.step, {
      x: 0.2, y, w: 1.6, h: 0.5,
      fontSize: 10, bold: true, color: C.white,
      fontFace: "Calibri", align: "center", valign: "middle",
    });
    // Arrow
    s.addShape(pres.ShapeType.rect, {
      x: 1.82, y: y + 0.2, w: 0.18, h: 0.1,
      fill: { color: a.color }, line: { color: a.color },
    });
    // Content
    s.addShape(pres.ShapeType.roundRect, {
      x: 2.02, y, w: 7.7, h: 0.5,
      rectRadius: 0.05,
      fill: { color: "0C1C2C" },
      line: { color: a.color, width: 1 },
    });
    s.addText(a.text, {
      x: 2.1, y, w: 7.55, h: 0.5,
      fontSize: 13, color: C.offWhite,
      fontFace: "Calibri", valign: "middle",
    });
  });
}

// ──────────────────────────────────────────────────────────────────────────────
// SLIDE 17 — KEY TAKEAWAYS
// ──────────────────────────────────────────────────────────────────────────────
{
  const s = pres.addSlide();
  bgRect(s, C.darkBg);

  // Red block left
  s.addShape(pres.ShapeType.rect, {
    x: 0, y: 0, w: 0.55, h: "100%",
    fill: { color: C.accent1 }, line: { color: C.accent1 },
  });

  s.addText("KEY TAKEAWAYS", {
    x: 0.8, y: 0.2, w: 8.8, h: 0.55,
    fontSize: 30, bold: true, color: C.white, fontFace: "Calibri",
    charSpacing: 3,
  });

  const points = [
    "Hypovolemic shock from GI bleeding is a life-threatening emergency — act within minutes, not hours",
    "Tachycardia is the EARLIEST sign — hypotension is LATE and indicates >30% volume loss",
    "ATLS Class I–IV guides fluid/blood strategy: Class III+ requires blood products, not just crystalloid",
    "Activate MTP early: 1:1:1 (pRBC:FFP:Platelets) + TXA + calcium; avoid the lethal triad",
    "BUN:Cr ratio >30 distinguishes upper from lower GI source before endoscopy",
    "Variceal bleeding: Octreotide/terlipressin + prophylactic antibiotics + EGD within 12h + early TIPS",
    "Permissive hypotension (SBP 80–90) until source control — overresuscitation worsens coagulopathy",
    "POCUS is your fastest bedside tool: IVC collapse = hypovolemia; LV 'kissing walls' = severe depletion",
    "Glasgow-Blatchford Score 0 = safe for outpatient; ≥7 = high risk for intervention",
    "Escalate early: simultaneous GI + IR + Surgery notification when MTP is activated",
  ];

  points.forEach((pt, i) => {
    s.addShape(pres.ShapeType.ellipse, {
      x: 0.75, y: 0.86 + i * 0.48, w: 0.28, h: 0.28,
      fill: { color: C.accent1 }, line: { color: C.accent1 },
    });
    s.addText(String(i + 1), {
      x: 0.75, y: 0.86 + i * 0.48, w: 0.28, h: 0.28,
      fontSize: 10, bold: true, color: C.white,
      fontFace: "Calibri", align: "center", valign: "middle",
    });
    s.addText(pt, {
      x: 1.12, y: 0.85 + i * 0.48, w: 8.65, h: 0.46,
      fontSize: 12.5, color: i % 2 === 0 ? C.offWhite : C.gray,
      fontFace: "Calibri", valign: "middle", wrap: true,
    });
  });
}

// ──────────────────────────────────────────────────────────────────────────────
// WRITE FILE
// ──────────────────────────────────────────────────────────────────────────────
pres.writeFile({ fileName: "/home/daytona/gi-shock-pptx/Hypovolemic_Shock_GI_Bleeding_EM.pptx" })
  .then(() => console.log("✅ Presentation saved successfully"))
  .catch(err => { console.error("❌ Error:", err); process.exit(1); });
You've run out of free credits. Sign up for a free account to continue using Orris.
This is a shared conversation. Sign in to Orris to start your own chat.