Make presentation on hypovolemic shock in GI bleeding it’s path physiological in detail explanation and more text signs symptoms diagnosis and treatment with step by step approaches

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

hypovolemic shock pathophysiology diagram

Searching Images

GI bleeding upper gastrointestinal hemorrhage causes

Reading File
Searching Images

hemorrhagic shock ATLS classification blood loss vital signs

Running Command

mkdir -p /home/daytona/workspace/hypovolemic-shock-gi && ls /home/daytona/workspace/

Writing File

~/hypovolemic-shock-gi/build.js

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

// Fetch images
const imageUrls = [
  "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_bdeafeef7610b98c1313148f2edcdeda5bd5f3adba2ade5ad110c32d716bfb1c.jpg",   // echo hypovolemic shock
  "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_37113599f423d6e81d9dbdc0cf8391dc0c17d4317f485b633047f1e7a66b6a72.jpg",   // gastroscopy UGI bleeding
  "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_79d6a6f93ec405d342788a7b84126e1fd1b7bd1fa0bf0c413286fefe5874a723.jpg",   // CT shock IVC flat
  "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_56f2259480d4aa374de3c081ad8ac68f41cc4bad01f1e68b546997cc3e722fd7.jpg",   // Dieulafoy endoscopy
  "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_608c1980be7581548a3262c001885c43ea0423a8079b941df88317d1d0468d0a.jpg",   // RBC scintigraphy GI bleed
];

console.log("Fetching images...");
let images;
try {
  const result = execSync(
    `node /home/daytona/skills/shared/scripts/fetch_images.js "${imageUrls[0]}" "${imageUrls[1]}" "${imageUrls[2]}" "${imageUrls[3]}"`,
    { timeout: 60000 }
  ).toString();
  images = JSON.parse(result);
  console.log("Images fetched:", images.map(i => i.error ? "ERROR: " + i.error : "OK").join(", "));
} catch (e) {
  console.error("Image fetch failed:", e.message);
  images = imageUrls.map(url => ({ url, base64: null, error: "fetch failed" }));
}

// Color Palette
const DARK_RED = "8B0000";
const CRIMSON = "C0392B";
const BLOOD_RED = "A93226";
const DEEP_NAVY = "1A1A2E";
const DARK_SLATE = "16213E";
const MID_BLUE = "0F3460";
const ACCENT_GOLD = "F5A623";
const LIGHT_GOLD = "F8D27D";
const WHITE = "FFFFFF";
const OFF_WHITE = "F5F5F5";
const LIGHT_GREY = "D5D8DC";
const BODY_TEXT = "E8E8E8";

const pres = new pptxgen();
pres.layout = "LAYOUT_WIDE"; // 13.33" x 7.5"
pres.title = "Hypovolemic Shock in GI Bleeding";
pres.author = "Medical Education";

// ─────────────────────────────────────────────────────────────────
// HELPER FUNCTIONS
// ─────────────────────────────────────────────────────────────────
function addSlideBackground(slide, color) {
  slide.background = { color };
}

function addTitle(slide, titleText, subtitleText, titleColor, subtitleColor) {
  // Decorative top bar
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 13.33, h: 0.08, fill: { color: CRIMSON } });
  slide.addText(titleText, {
    x: 0.4, y: 0.15, w: 12.5, h: 0.7,
    fontSize: 28, bold: true, color: titleColor || WHITE,
    fontFace: "Calibri", charSpacing: 1,
  });
  if (subtitleText) {
    slide.addText(subtitleText, {
      x: 0.4, y: 0.85, w: 12.5, h: 0.35,
      fontSize: 13, color: subtitleColor || LIGHT_GOLD,
      fontFace: "Calibri", italic: true,
    });
  }
  // Bottom bar
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 7.42, w: 13.33, h: 0.08, fill: { color: CRIMSON } });
}

function addBullets(slide, items, x, y, w, h, fontSize, color, bold, indent) {
  const bullets = items.map((item, i) => ({
    text: item,
    options: {
      bullet: { indent: indent || 15 },
      breakLine: i < items.length - 1,
      fontSize: fontSize || 13,
      color: color || BODY_TEXT,
      bold: bold || false,
      fontFace: "Calibri",
    }
  }));
  slide.addText(bullets, { x, y, w, h, valign: "top" });
}

function addSectionLabel(slide, text, x, y, w, color) {
  slide.addShape(pres.ShapeType.rect, { x, y, w, h: 0.32, fill: { color: color || CRIMSON }, line: { color: color || CRIMSON } });
  slide.addText(text, {
    x: x + 0.08, y: y + 0.02, w: w - 0.16, h: 0.28,
    fontSize: 11, bold: true, color: WHITE, fontFace: "Calibri",
  });
}

function addInfoBox(slide, text, x, y, w, h, fillColor, textColor, fontSize) {
  slide.addShape(pres.ShapeType.rect, { x, y, w, h, fill: { color: fillColor || MID_BLUE }, line: { color: ACCENT_GOLD, pt: 1 } });
  slide.addText(text, {
    x: x + 0.1, y: y + 0.05, w: w - 0.2, h: h - 0.1,
    fontSize: fontSize || 12, color: textColor || WHITE, fontFace: "Calibri", valign: "top",
  });
}

// ─────────────────────────────────────────────────────────────────
// SLIDE 1: TITLE
// ─────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addSlideBackground(slide, DEEP_NAVY);

  // Full-bleed dramatic accent
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 13.33, h: 7.5, fill: { color: DEEP_NAVY } });
  // Left blood-red panel
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 4.2, h: 7.5, fill: { color: DARK_RED } });
  // Diagonal accent shape
  slide.addShape(pres.ShapeType.rect, { x: 3.8, y: 0, w: 0.7, h: 7.5, fill: { color: BLOOD_RED }, line: { color: BLOOD_RED } });

  // Left panel text: vertical label
  slide.addText("EMERGENCY MEDICINE", {
    x: 0.18, y: 2.2, w: 3.5, h: 0.5,
    fontSize: 11, color: LIGHT_GOLD, bold: true, charSpacing: 4, fontFace: "Calibri", align: "left",
  });

  slide.addText("CRITICAL CARE", {
    x: 0.18, y: 2.75, w: 3.5, h: 0.4,
    fontSize: 11, color: LIGHT_GREY, charSpacing: 3, fontFace: "Calibri", align: "left",
  });

  // Red cross / medical icon simulation
  slide.addShape(pres.ShapeType.rect, { x: 1.2, y: 3.4, w: 1.6, h: 0.35, fill: { color: WHITE }, line: { color: WHITE } });
  slide.addShape(pres.ShapeType.rect, { x: 1.77, y: 2.95, w: 0.45, h: 1.25, fill: { color: WHITE }, line: { color: WHITE } });

  // Main title
  slide.addText("HYPOVOLEMIC SHOCK", {
    x: 4.7, y: 1.5, w: 8.3, h: 1.1,
    fontSize: 44, bold: true, color: WHITE,
    fontFace: "Calibri", charSpacing: 2,
  });
  slide.addText("in Gastrointestinal Bleeding", {
    x: 4.7, y: 2.65, w: 8.3, h: 0.7,
    fontSize: 26, color: ACCENT_GOLD, fontFace: "Calibri", italic: true,
  });

  // Gold divider
  slide.addShape(pres.ShapeType.rect, { x: 4.7, y: 3.5, w: 7.0, h: 0.06, fill: { color: ACCENT_GOLD } });

  // Subtitle content
  slide.addText([
    { text: "Pathophysiology  •  Classification  •  Clinical Features", options: { breakLine: true } },
    { text: "Diagnosis  •  Step-by-Step Management", options: {} },
  ], {
    x: 4.7, y: 3.7, w: 8.3, h: 0.9,
    fontSize: 15, color: LIGHT_GREY, fontFace: "Calibri", align: "left",
  });

  // Topics overview pills
  const topics = ["Pathophysiology", "ATLS Classes", "Signs & Symptoms", "Lab & Imaging", "Treatment Protocol"];
  topics.forEach((t, i) => {
    const col = i % 3;
    const row = Math.floor(i / 3);
    slide.addShape(pres.ShapeType.roundRect, {
      x: 4.7 + col * 2.7, y: 5.0 + row * 0.65, w: 2.5, h: 0.45,
      fill: { color: MID_BLUE }, line: { color: ACCENT_GOLD, pt: 1 }, rectRadius: 0.1,
    });
    slide.addText(t, {
      x: 4.7 + col * 2.7 + 0.1, y: 5.0 + row * 0.65 + 0.06, w: 2.3, h: 0.33,
      fontSize: 11, color: ACCENT_GOLD, bold: true, fontFace: "Calibri", align: "center",
    });
  });

  // Date
  slide.addText("May 2026", {
    x: 4.7, y: 6.8, w: 8.3, h: 0.3,
    fontSize: 10, color: LIGHT_GREY, fontFace: "Calibri",
  });
}

// ─────────────────────────────────────────────────────────────────
// SLIDE 2: OVERVIEW & DEFINITION
// ─────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addSlideBackground(slide, DARK_SLATE);
  addTitle(slide, "Overview: Shock & GI Bleeding", "Definitions, Epidemiology, and the Clinical Challenge");

  // Left column: definition
  slide.addShape(pres.ShapeType.rect, { x: 0.3, y: 1.3, w: 6.0, h: 5.7, fill: { color: MID_BLUE }, line: { color: CRIMSON, pt: 2 } });
  addSectionLabel(slide, "WHAT IS HYPOVOLEMIC SHOCK?", 0.3, 1.3, 6.0, CRIMSON);
  const defItems = [
    "A state of circulatory failure resulting from inadequate intravascular volume",
    "Most commonly encountered shock in surgical & emergency practice",
    "Characterized by ↓ venous return → ↓ cardiac output → inadequate tissue perfusion",
    "Blood loss >20% of circulating volume required to produce the full syndrome",
    "GI bleeding is a leading non-traumatic cause of hemorrhagic hypovolemic shock",
    "Pathological hallmark: increased SVR + decreased CO ('cold shock')",
    "Untreated → cellular hypoxia → anaerobic metabolism → lactic acidosis → organ failure",
  ];
  addBullets(slide, defItems, 0.45, 1.75, 5.7, 4.9, 12, BODY_TEXT, false, 18);

  // Right column: epidemiology
  slide.addShape(pres.ShapeType.rect, { x: 6.8, y: 1.3, w: 6.2, h: 2.6, fill: { color: "1E2D45" }, line: { color: ACCENT_GOLD, pt: 1 } });
  addSectionLabel(slide, "EPIDEMIOLOGY", 6.8, 1.3, 6.2, MID_BLUE);
  const epidItems = [
    "Upper GI bleeding (UGIB): ~100/100,000 admissions/year",
    "UGIB mortality: 2–10% overall; up to 15% in cirrhosis",
    "Lower GI bleeding (LGIB): stops spontaneously in 80–85%",
    "LGIB mortality: 2–4%; higher with hemodynamic compromise",
    "~10–15% of hematochezia cases originate from massive UGIB",
  ];
  addBullets(slide, epidItems, 6.95, 1.75, 5.9, 2.1, 11.5, BODY_TEXT);

  // Right lower: GI Bleed classification
  slide.addShape(pres.ShapeType.rect, { x: 6.8, y: 4.1, w: 6.2, h: 2.9, fill: { color: "1E2D45" }, line: { color: ACCENT_GOLD, pt: 1 } });
  addSectionLabel(slide, "GI BLEEDING: UPPER vs LOWER", 6.8, 4.1, 6.2, MID_BLUE);
  const giItems = [
    "UGIB (proximal to Ligament of Treitz): peptic ulcer, varices, Mallory-Weiss tear, Dieulafoy lesion, angiodysplasia, aortoenteric fistula",
    "LGIB (distal to Ligament of Treitz): diverticulosis, angiodysplasia, IBD, ischemic colitis, neoplasia, post-polypectomy",
    "Hematemesis / coffee-ground emesis → UGIB",
    "Melena (black tarry stool, ≥50 mL blood) → usually proximal",
    "Hematochezia (bright red blood per rectum) → usually LGIB; massive UGIB if with hemodynamic instability",
  ];
  addBullets(slide, giItems, 6.95, 4.55, 5.9, 2.4, 11, BODY_TEXT);
}

// ─────────────────────────────────────────────────────────────────
// SLIDE 3: PATHOPHYSIOLOGY PART 1 — HEMORRHAGE & COMPENSATORY REFLEXES
// ─────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addSlideBackground(slide, DARK_SLATE);
  addTitle(slide, "Pathophysiology — Part 1: Hemorrhage & Compensatory Mechanisms",
    "Guyton & Hall Physiology | Mulholland & Greenfield's Surgery");

  // Step flow boxes for cascade
  const steps = [
    { label: "1. BLOOD LOSS", text: "Loss of intravascular volume\n↓ Circulating blood volume\n↓ Venous return (preload)\n↓ End-diastolic volume" },
    { label: "2. ↓ CARDIAC OUTPUT", text: "Starling's law: ↓ preload → ↓ stroke volume\n↓ Cardiac output (CO)\nArterial pressure begins to fall\n(10% loss: no change; >15%: CO drops first)" },
    { label: "3. SYMPATHETIC ACTIVATION", text: "Baroreceptors detect ↓ arterial pressure\nMassive SNS discharge\n↑ HR (up to 160–180 bpm)\nPeripheral vasoconstriction (↑ SVR)" },
    { label: "4. NEUROENDOCRINE RESPONSE", text: "↑ Renin → ↑ Angiotensin II → vasoconstriction + ↓ urine output\n↑ ADH/Vasopressin → ↑ free water retention\n↑ Aldosterone → ↑ Na+ & H2O reabsorption\nVenous constriction → ↑ venous return" },
    { label: "5. CELLULAR HYPOXIA", text: "Prolonged ↓ O2 delivery to tissues\nShift to anaerobic glycolysis\nLactic acid accumulates → metabolic acidosis\n'Vicious cycle' of progressive shock begins" },
    { label: "6. IRREVERSIBLE SHOCK", text: ">40–45% blood volume lost → CO & BP → 0\nCell membrane failure, ion pump failure\nMyocardial depression (MDF release)\nMulti-organ dysfunction syndrome (MODS)" },
  ];

  const cols = 3, rows = 2;
  steps.forEach((s, i) => {
    const col = i % cols;
    const row = Math.floor(i / cols);
    const x = 0.3 + col * 4.3;
    const y = 1.3 + row * 2.9;
    // Arrow between boxes in same row
    if (col < cols - 1) {
      slide.addShape(pres.ShapeType.rect, { x: x + 4.05, y: y + 1.0, w: 0.25, h: 0.07, fill: { color: ACCENT_GOLD } });
    }
    slide.addShape(pres.ShapeType.roundRect, {
      x, y, w: 4.0, h: 2.7,
      fill: { color: i < 3 ? "1C2E4A" : "2D1515" },
      line: { color: i < 3 ? ACCENT_GOLD : CRIMSON, pt: 1.5 },
      rectRadius: 0.1,
    });
    slide.addShape(pres.ShapeType.rect, { x, y, w: 4.0, h: 0.38, fill: { color: i < 3 ? MID_BLUE : BLOOD_RED }, line: { color: i < 3 ? MID_BLUE : BLOOD_RED } });
    slide.addText(s.label, {
      x: x + 0.1, y: y + 0.04, w: 3.8, h: 0.3,
      fontSize: 11, bold: true, color: WHITE, fontFace: "Calibri",
    });
    slide.addText(s.text, {
      x: x + 0.1, y: y + 0.45, w: 3.8, h: 2.1,
      fontSize: 11, color: BODY_TEXT, fontFace: "Calibri", valign: "top",
    });
  });

  // Downward arrow between rows
  slide.addShape(pres.ShapeType.rect, { x: 6.45, y: 4.05, w: 0.07, h: 0.3, fill: { color: ACCENT_GOLD } });
}

// ─────────────────────────────────────────────────────────────────
// SLIDE 4: PATHOPHYSIOLOGY PART 2 — ORGAN RESPONSES
// ─────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addSlideBackground(slide, DARK_SLATE);
  addTitle(slide, "Pathophysiology — Part 2: Organ-Specific Responses",
    "Mulholland & Greenfield's Surgery | Sabiston Textbook of Surgery");

  // Organ columns
  const organs = [
    { name: "CARDIOVASCULAR", color: CRIMSON, items: ["↑ HR, ↑ SVR via SNS activation", "Coronary + cerebral flow preserved via autoregulation (BP >70 mmHg)", "'Last stand': CNS ischemic response at BP <50 mmHg", "Progressive myocardial depression with MDF release", "Eventual cardiac arrest in irreversible shock"] },
    { name: "RENAL", color: "1565C0", items: ["SNS → afferent arteriole constriction", "↓ GFR → oliguria (urine <0.5 mL/kg/hr)", "Angiotensin II + ADH → avid sodium & water retention", "Prolonged ischemia → Acute Tubular Necrosis (ATN)", "Urine Na <20 mEq/L, osmolality >400 mOsm/kg in prerenal state", "FENa <1% distinguishes prerenal from ATN"] },
    { name: "PULMONARY", color: "6A1A5A", items: ["First organ to fail in progressive shock", "Inflammatory mediators from hypoperfused tissues", "ARDS: acute lung injury triggered by ischemia-reperfusion", "High-mortality complication of unresuscitated shock", "Increased vascular permeability → pulmonary edema"] },
    { name: "HEPATIC", color: "4A6A1A", items: ["Not overtly ischemic early", "Releases acute-phase reactants", "Continued shock → hepatic necrosis → ↑ AST/ALT", "↓ Synthesis of coagulation factors → coagulopathy", "Loss of glycogen stores → hypoglycemia in severe cases"] },
    { name: "GASTROINTESTINAL", color: "8A5200", items: ["Gut ischemia → mucosal barrier failure", "Bacterial translocation from gut lumen", "Amplifies systemic inflammatory response (SIRS)", "GI hypoperfusion is both cause and consequence in GI bleeding shock", "Mesenteric vasoconstriction worsens mucosal ischemia"] },
    { name: "COAGULATION", color: "5D1F1F", items: ["Consumption coagulopathy (DIC in severe cases)", "Acidosis + hypothermia → coagulation enzyme dysfunction", "'Lethal triad': acidosis + hypothermia + coagulopathy", "Platelet dysfunction with massive blood loss", "1:1:1 pRBC:FFP:platelets in massive transfusion protocol"] },
  ];

  organs.forEach((o, i) => {
    const col = i % 3;
    const row = Math.floor(i / 3);
    const x = 0.3 + col * 4.3;
    const y = 1.3 + row * 2.9;
    slide.addShape(pres.ShapeType.roundRect, {
      x, y, w: 4.0, h: 2.7,
      fill: { color: DEEP_NAVY },
      line: { color: o.color, pt: 2 },
      rectRadius: 0.08,
    });
    slide.addShape(pres.ShapeType.rect, { x, y, w: 4.0, h: 0.35, fill: { color: o.color }, line: { color: o.color } });
    slide.addText(o.name, {
      x: x + 0.1, y: y + 0.04, w: 3.8, h: 0.27,
      fontSize: 10.5, bold: true, color: WHITE, fontFace: "Calibri",
    });
    addBullets(slide, o.items, x + 0.1, y + 0.42, 3.8, 2.2, 10.5, BODY_TEXT, false, 12);
  });
}

// ─────────────────────────────────────────────────────────────────
// SLIDE 5: ATLS HEMORRHAGIC SHOCK CLASSIFICATION
// ─────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addSlideBackground(slide, DARK_SLATE);
  addTitle(slide, "ATLS Classification of Hemorrhagic Shock",
    "ACS ATLS | Mulholland & Greenfield's Surgery | Sabiston Textbook of Surgery");

  // Table header
  const cols_w = [1.5, 1.9, 1.9, 1.9, 1.9, 1.9];
  const startX = 0.27;
  const startY = 1.35;
  const headers = ["Parameter", "Class I", "Class II", "Class III", "Class IV", "Irreversible"];
  const headerColors = ["2C2C2C", "155724", "856404", BLOOD_RED, DARK_RED, "4A0000"];
  headers.forEach((h, i) => {
    const x = startX + cols_w.slice(0, i).reduce((a, b) => a + b, 0);
    slide.addShape(pres.ShapeType.rect, { x, y: startY, w: cols_w[i], h: 0.42, fill: { color: headerColors[i] }, line: { color: "111111", pt: 0.5 } });
    slide.addText(h, { x: x + 0.05, y: startY + 0.06, w: cols_w[i] - 0.1, h: 0.3, fontSize: 11, bold: true, color: WHITE, fontFace: "Calibri", align: "center" });
  });

  const rows = [
    ["Blood Loss (%)", "Up to 15%", "15–30%", "30–40%", ">40%", ">50%"],
    ["Volume (mL)*", "<750 mL", "800–1500", "1500–2000", ">2000", "Exsanguinating"],
    ["Heart Rate", "<100 bpm", "100–120", "120–140", ">140", "Bradycardia/0"],
    ["Blood Pressure", "Normal", "Normal/↓", "↓ Systolic", "Very Low", "Unmeasurable"],
    ["Pulse Pressure", "Normal/↑", "↓", "↓", "↓↓", "Absent"],
    ["Resp Rate", "14–20", "20–30", "30–40", ">35", "Agonal"],
    ["Urine Output", ">30 mL/hr", "20–30", "5–15", "Negligible", "None"],
    ["Mental Status", "Slightly anxious", "Anxious", "Confused/combative", "Lethargic/obtunded", "Unresponsive"],
    ["Skin", "Normal, warm", "Pale, cool", "Pale, cold, clammy", "Cold, mottled", "Mottled/cyanosed"],
    ["Capillary Refill", "Normal", "Delayed", "Markedly delayed", "Absent", "Absent"],
    ["Resuscitation", "Crystalloid only", "Crystalloid ± blood", "Blood + crystalloid", "Immediate transfusion", "MTP + surgical control"],
  ];

  const rowColors = ["1A2A3A", "182030", "1A2A3A", "182030", "1A2A3A", "182030", "1A2A3A", "182030", "1A2A3A", "182030", "1A2A3A"];
  const highlightCells = [[3, 5], [4, 5], [5, 5]]; // highlight class IV and irreversible cells

  rows.forEach((row, ri) => {
    row.forEach((cell, ci) => {
      const x = startX + cols_w.slice(0, ci).reduce((a, b) => a + b, 0);
      const y = startY + 0.42 + ri * 0.49;
      const isHighlighted = ci >= 3;
      const fillColor = ci === 0 ? MID_BLUE : (ci >= 4 ? (ci === 5 ? "3A0000" : "2A0F0F") : rowColors[ri]);
      slide.addShape(pres.ShapeType.rect, { x, y, w: cols_w[ci], h: 0.47, fill: { color: fillColor }, line: { color: "111111", pt: 0.5 } });
      slide.addText(cell, {
        x: x + 0.05, y: y + 0.06, w: cols_w[ci] - 0.1, h: 0.35,
        fontSize: 10, color: ci >= 3 ? (ci === 5 ? ACCENT_GOLD : LIGHT_GREY) : (ci === 0 ? WHITE : BODY_TEXT),
        bold: ci === 0 || ci >= 4, fontFace: "Calibri", align: "center",
      });
    });
  });

  // Footer note
  slide.addText("*Estimated for 70 kg adult. Blood volume ≈ 7% of ideal body weight (~4,900 mL). Individual variation due to age, comorbidities, beta-blockers.", {
    x: 0.27, y: 7.0, w: 13.0, h: 0.3,
    fontSize: 9, color: LIGHT_GREY, italic: true, fontFace: "Calibri",
  });
}

// ─────────────────────────────────────────────────────────────────
// SLIDE 6: SIGNS & SYMPTOMS
// ─────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addSlideBackground(slide, DARK_SLATE);
  addTitle(slide, "Clinical Signs & Symptoms",
    "GI Bleeding + Hypovolemic Shock: What to Look For");

  // Left: GI-specific symptoms
  slide.addShape(pres.ShapeType.rect, { x: 0.3, y: 1.3, w: 4.0, h: 5.8, fill: { color: "1E1E35" }, line: { color: ACCENT_GOLD, pt: 1.5 } });
  addSectionLabel(slide, "GI BLEEDING SYMPTOMS", 0.3, 1.3, 4.0, "333370");
  const giSx = [
    "Hematemesis: bright red blood (active/ongoing bleeding)",
    "Coffee-ground emesis: old, oxidized blood (slower bleed)",
    "Melena: black, tarry, foul-smelling stool (≥50 mL blood)",
    "Hematochezia: bright red blood per rectum (usually LGIB; massive UGIB if hemodynamically unstable)",
    "Abdominal pain / epigastric distress",
    "Nausea, vomiting (may precede Mallory-Weiss tear)",
    "History: NSAID/aspirin use, alcohol, cirrhosis, prior GI bleed",
  ];
  addBullets(slide, giSx, 0.45, 1.75, 3.7, 5.1, 11.5, BODY_TEXT);

  // Middle: Hemodynamic symptoms
  slide.addShape(pres.ShapeType.rect, { x: 4.65, y: 1.3, w: 4.0, h: 5.8, fill: { color: "2D1515" }, line: { color: CRIMSON, pt: 1.5 } });
  addSectionLabel(slide, "HEMODYNAMIC SYMPTOMS", 4.65, 1.3, 4.0, BLOOD_RED);
  const hemoSx = [
    "Tachycardia: earliest hemodynamic sign (HR >100)",
    "Hypotension: SBP <90 mmHg (late sign — compensated initially)",
    "Narrow pulse pressure (↑ diastolic from adrenergic discharge)",
    "Orthostatic hypotension: ↓ SBP >20 mmHg on standing",
    "Tachypnea: respiratory compensation for acidosis",
    "Oliguria: <0.5 mL/kg/hr (reflects ↓ renal perfusion)",
    "Thirst, weakness, dizziness, presyncope/syncope",
  ];
  addBullets(slide, hemoSx, 4.8, 1.75, 3.7, 5.1, 11.5, BODY_TEXT);

  // Right: Physical exam findings
  slide.addShape(pres.ShapeType.rect, { x: 9.0, y: 1.3, w: 4.0, h: 5.8, fill: { color: "1A2A1A" }, line: { color: "4CAF50", pt: 1.5 } });
  addSectionLabel(slide, "PHYSICAL EXAMINATION", 9.0, 1.3, 4.0, "2E7D32");
  const examFindings = [
    "Pallor: skin, conjunctiva, nail beds",
    "Cold, clammy skin (peripheral vasoconstriction)",
    "Delayed capillary refill (>2 seconds)",
    "Weak, rapid, thready pulse",
    "Mottling of extremities (advanced shock)",
    "Altered mental status: anxiety → confusion → obtundation → coma",
    "Abdominal tenderness (peritonitis if perforation)",
    "Rectal exam: melena, bright blood, or clots on glove",
    "Stigmata of portal hypertension: spider angiomata, caput medusae, splenomegaly, ascites (varices likely)",
    "Signs of liver disease: jaundice, asterixis, gynecomastia",
  ];
  addBullets(slide, examFindings, 9.15, 1.75, 3.7, 5.1, 11, BODY_TEXT);
}

// ─────────────────────────────────────────────────────────────────
// SLIDE 7: DIAGNOSIS — LABS & IMAGING
// ─────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addSlideBackground(slide, DARK_SLATE);
  addTitle(slide, "Diagnosis: Laboratory & Imaging Workup",
    "Sabiston Textbook of Surgery | Rosen's Emergency Medicine | Sleisenger & Fordtran's");

  // Lab panel
  slide.addShape(pres.ShapeType.rect, { x: 0.3, y: 1.3, w: 6.1, h: 5.8, fill: { color: "161E2E" }, line: { color: ACCENT_GOLD, pt: 1.5 } });
  addSectionLabel(slide, "LABORATORY INVESTIGATIONS", 0.3, 1.3, 6.1, "1A4A7A");

  const labGroups = [
    { heading: "CBC", items: ["Hemoglobin/Hematocrit — may be initially normal (hemodilution lags)", "Platelets — thrombocytopenia in cirrhosis, consumption in DIC", "WBC — leukocytosis with stress/infection"] },
    { heading: "Coagulation", items: ["PT/INR — prolonged in liver disease/coagulopathy", "aPTT", "Fibrinogen — target >100 mg/dL in active bleeding"] },
    { heading: "Metabolic", items: ["BMP/BUN:Cr ratio >30 strongly suggests UGIB (LR 7.5)", "Lactate — elevated (>2 mmol/L) indicates tissue hypoperfusion", "Arterial Blood Gas — metabolic acidosis (↓ pH, ↓ HCO3)", "Base deficit — correlates with severity of hemorrhage"] },
    { heading: "Liver Function", items: ["AST/ALT — hepatic ischemia or primary liver disease", "Albumin, bilirubin — cirrhosis assessment", "Ammonia — hepatic encephalopathy if cirrhosis"] },
    { heading: "Blood Bank", items: ["Type and Screen / Crossmatch", "TEG/ROTEM — dynamic clot testing for massive transfusion guidance"] },
  ];

  let yPos = 1.78;
  labGroups.forEach(g => {
    slide.addText(g.heading, {
      x: 0.45, y: yPos, w: 5.8, h: 0.28,
      fontSize: 11, bold: true, color: ACCENT_GOLD, fontFace: "Calibri",
    });
    yPos += 0.3;
    g.items.forEach(item => {
      slide.addText("• " + item, {
        x: 0.55, y: yPos, w: 5.7, h: 0.28,
        fontSize: 10.5, color: BODY_TEXT, fontFace: "Calibri",
      });
      yPos += 0.28;
    });
    yPos += 0.1;
  });

  // Imaging panel
  slide.addShape(pres.ShapeType.rect, { x: 6.8, y: 1.3, w: 6.2, h: 2.7, fill: { color: "161E2E" }, line: { color: ACCENT_GOLD, pt: 1.5 } });
  addSectionLabel(slide, "IMAGING STUDIES", 6.8, 1.3, 6.2, "1A4A7A");
  const imagingItems = [
    "CT Angiography (CTA): first-line for hemodynamically stable LGIB; detects bleeding >0.3–0.5 mL/min; identifies vascular anomalies; flat IVC sign → shock",
    "Technetium-99m RBC Scintigraphy: detects bleeding >0.1 mL/min; identifies intermittent/slow bleed; localizes source before angiography",
    "Conventional Angiography: therapeutic (embolization) and diagnostic; requires >0.5 mL/min active bleed",
    "CXR/AXR: exclude perforation (free air), obstruction",
    "Bedside FAST/POCUS: assess IVC collapsibility (fluid responsiveness), LV function in shock",
  ];
  addBullets(slide, imagingItems, 6.95, 1.75, 5.9, 2.2, 10.5, BODY_TEXT);

  // Risk scoring
  slide.addShape(pres.ShapeType.rect, { x: 6.8, y: 4.2, w: 6.2, h: 2.9, fill: { color: "161E2E" }, line: { color: CRIMSON, pt: 1.5 } });
  addSectionLabel(slide, "RISK STRATIFICATION SCORES", 6.8, 4.2, 6.2, BLOOD_RED);
  const scoreItems = [
    "Glasgow-Blatchford Score (GBS): pre-endoscopy risk; predicts need for intervention; BUN, Hb, SBP, HR, melena, syncope, liver disease, cardiac failure",
    "Rockford Score (post-endoscopy): rebleeding risk from endoscopic findings",
    "AIMS65: Albumin <3, INR >1.5, Altered mental status, SBP <90, Age >65 — predicts inpatient mortality",
    "Shock Index (HR/SBP): >1.0 = significant hemorrhage; >1.5 = massive hemorrhage requiring transfusion",
    "Revised Trauma Score / ATLS Class: used for triaging hemorrhagic shock severity",
  ];
  addBullets(slide, scoreItems, 6.95, 4.65, 5.9, 2.35, 10.5, BODY_TEXT);
}

// ─────────────────────────────────────────────────────────────────
// SLIDE 8: ENDOSCOPY (DIAGNOSTIC & THERAPEUTIC)
// ─────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addSlideBackground(slide, DARK_SLATE);
  addTitle(slide, "Endoscopy: The Cornerstone of GI Bleeding Management",
    "Rosen's Emergency Medicine | Sabiston Textbook of Surgery | Sleisenger & Fordtran's");

  // Image — endoscopy GI bleeding
  if (images[1] && !images[1].error) {
    slide.addImage({ data: images[1].base64, x: 0.3, y: 1.3, w: 4.8, h: 3.6 });
  }
  slide.addText("Gastroscopy showing upper GI bleeding with angiodysplasia and endoclip hemostasis", {
    x: 0.3, y: 4.95, w: 4.8, h: 0.4,
    fontSize: 9, color: LIGHT_GREY, italic: true, fontFace: "Calibri",
  });

  // Right panel: endoscopy details
  slide.addShape(pres.ShapeType.rect, { x: 5.5, y: 1.3, w: 7.5, h: 5.8, fill: { color: "161E2E" }, line: { color: ACCENT_GOLD, pt: 1.5 } });
  addSectionLabel(slide, "ESOPHAGOGASTRODUODENOSCOPY (EGD) — UPPER GI BLEEDING", 5.5, 1.3, 7.5, MID_BLUE);

  const endoGroups = [
    { heading: "Timing", items: ["Urgent EGD within 12–24 hours for hemodynamically stable UGIB", "Immediate EGD (<12 h) for unstable patients after initial resuscitation", "Elective intubation may be needed for ongoing hematemesis / altered mental status", "Avoid routine NG lavage — does not improve outcomes"] },
    { heading: "Forrest Classification (Ulcer Bleeding)", items: ["Ia: Spurting vessel → high risk; immediate therapy", "Ib: Oozing vessel → high risk; therapy required", "IIa: Non-bleeding visible vessel → intermediate; treat endoscopically", "IIb: Adherent clot → intermediate risk", "IIc: Flat pigmented spot / III: Clean base → low risk; no endoscopic therapy"] },
    { heading: "Endoscopic Hemostatic Techniques", items: ["Injection: epinephrine (vasoconstriction) — always combine with second modality", "Thermal coagulation: bipolar, heater probe, APC", "Mechanical: endoclips, over-the-scope clips (OTSC), bands (varices)", "Combination therapy superior to single-modality", "Hemospray/TC-325: powder agent for diffuse/refractory bleeding"] },
    { heading: "Colonoscopy (LGIB)", items: ["Urgent colonoscopy within 24 h after bowel prep for hemodynamically stable LGIB", "Injection, clips, thermal therapy for diverticular bleeding, angiodysplasia"] },
  ];

  let yPos = 1.78;
  endoGroups.forEach(g => {
    slide.addText(g.heading, {
      x: 5.65, y: yPos, w: 7.2, h: 0.28,
      fontSize: 11, bold: true, color: ACCENT_GOLD, fontFace: "Calibri",
    });
    yPos += 0.3;
    g.items.forEach(item => {
      slide.addText("• " + item, {
        x: 5.75, y: yPos, w: 7.1, h: 0.28,
        fontSize: 10.5, color: BODY_TEXT, fontFace: "Calibri",
      });
      yPos += 0.28;
    });
    yPos += 0.1;
  });
}

// ─────────────────────────────────────────────────────────────────
// SLIDE 9: TREATMENT — STEP-BY-STEP RESUSCITATION
// ─────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addSlideBackground(slide, DARK_SLATE);
  addTitle(slide, "Step-by-Step Treatment: Initial Resuscitation",
    "Sabiston Textbook of Surgery | Rosen's Emergency Medicine | Mulholland & Greenfield's Surgery");

  const steps = [
    {
      num: "STEP 1", label: "AIRWAY & VASCULAR ACCESS",
      items: ["Secure airway: elective intubation if ongoing hematemesis, GCS <8, or respiratory failure", "Two large-bore IV catheters (≥18G) OR large-bore central cordis", "Consider IO access if IV access difficult in extremis", "Supplemental oxygen (100% via NRB mask)"]
    },
    {
      num: "STEP 2", label: "INITIAL FLUID RESUSCITATION",
      items: ["Warmed isotonic crystalloid (NS or LR): 1–2 L IV rapid bolus", "Permissive hypotension strategy in active hemorrhage: target SBP 80–90 mmHg until bleeding controlled", "Avoid excessive crystalloid — worsens coagulopathy, dilutional anemia, and acidosis", "Reassess hemodynamic response after each bolus (HR, BP, urine output, lactate)"]
    },
    {
      num: "STEP 3", label: "BLOOD PRODUCT TRANSFUSION",
      items: ["pRBC transfusion: trigger Hb <7 g/dL (restrictive strategy) in stable; <9 g/dL in active/unstable bleeding", "Do NOT delay transfusion pending labs in active ongoing hemorrhage", "Massive Transfusion Protocol (MTP): 1:1:1 ratio pRBC:FFP:Platelets", "Whole blood (if available): may be superior to component therapy in hemorrhagic shock", "Cryoprecipitate: 1 unit/10 kg if fibrinogen <100–150 mg/dL"]
    },
    {
      num: "STEP 4", label: "PHARMACOLOGICAL THERAPY",
      items: ["Tranexamic Acid (TXA): 1g IV over 10 min if within 3 hours of onset — reduces mortality in hemorrhagic shock", "PPI therapy: IV pantoprazole/esomeprazole (bolus + infusion) — reduces rebleeding in peptic ulcer disease", "Somatostatin analogues (octreotide): reduces portal pressure in variceal bleeding", "Vasopressin / Terlipressin: variceal bleeding; also for vasopressin-deficient state in refractory shock", "Vitamin K (oral/IV) if coagulopathy due to nutritional/liver causes", "Avoid ACEIs, ARBs, beta-blockers in hypotensive cirrhotic patients"]
    },
  ];

  const stepColors = [MID_BLUE, "1A5A2A", BLOOD_RED, "5A3A00"];

  steps.forEach((s, i) => {
    const col = i % 2;
    const row = Math.floor(i / 2);
    const x = 0.3 + col * 6.4;
    const y = 1.3 + row * 2.9;
    slide.addShape(pres.ShapeType.roundRect, {
      x, y, w: 6.1, h: 2.7,
      fill: { color: DEEP_NAVY },
      line: { color: stepColors[i], pt: 2 },
      rectRadius: 0.1,
    });
    // Step number badge
    slide.addShape(pres.ShapeType.roundRect, {
      x: x + 0.1, y: y + 0.1, w: 1.1, h: 0.35,
      fill: { color: stepColors[i] }, line: { color: stepColors[i] }, rectRadius: 0.08,
    });
    slide.addText(s.num, {
      x: x + 0.12, y: y + 0.14, w: 1.06, h: 0.27,
      fontSize: 9.5, bold: true, color: WHITE, fontFace: "Calibri", align: "center",
    });
    slide.addText(s.label, {
      x: x + 1.3, y: y + 0.13, w: 4.7, h: 0.32,
      fontSize: 11, bold: true, color: WHITE, fontFace: "Calibri",
    });
    addBullets(slide, s.items, x + 0.15, y + 0.52, 5.8, 2.1, 10.5, BODY_TEXT, false, 12);
  });
}

// ─────────────────────────────────────────────────────────────────
// SLIDE 10: TREATMENT — DEFINITIVE & SURGICAL
// ─────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addSlideBackground(slide, DARK_SLATE);
  addTitle(slide, "Step-by-Step Treatment: Definitive Hemorrhage Control",
    "Sabiston Textbook of Surgery | Rosen's Emergency Medicine | Mulholland & Greenfield's Surgery");

  const steps2 = [
    {
      num: "STEP 5", label: "ENDOSCOPIC HEMORRHAGE CONTROL",
      items: ["Urgent EGD within 12–24 h for UGIB; within 24 h colonoscopy for LGIB", "Combination endoscopic therapy preferred (injection + thermal/mechanical)", "Forrest Class Ia/Ib/IIa: definitive endoscopic hemostasis", "Variceal banding (EVL) preferred over sclerotherapy for esophageal varices", "Repeat endoscopy at 24 h for high-risk stigmata", "Second-look endoscopy for hemostasis failure"]
    },
    {
      num: "STEP 6", label: "INTERVENTIONAL RADIOLOGY",
      items: ["Transcatheter angiographic embolization: for ongoing LGIB, or UGIB failing endoscopy", "Highly effective: 90%+ technical success for arterial bleeding", "Preferred over surgery in high-risk surgical candidates", "TIPS (Transjugular Intrahepatic Portosystemic Shunt): for refractory variceal bleeding", "CT angiography to localize before interventional radiology"]
    },
    {
      num: "STEP 7", label: "SURGICAL INTERVENTION",
      items: ["Indications: continued hemodynamic instability despite resuscitation, failure of endoscopic & IR therapy, life-threatening hemorrhage (Class IV)", "Emergency laparotomy or laparoscopy guided by preoperative localization", "Damage control surgery: abbreviated initial procedure → ICU resuscitation → definitive repair", "Specific procedures: oversewing ulcer, partial gastrectomy, colonic resection, vascular control", "Mandatory with uncontrolled hemorrhage: SBP <70 despite maximum resuscitation"]
    },
    {
      num: "STEP 8", label: "ICU MONITORING & ENDPOINTS",
      items: ["Admit to ICU: all unstable patients, active bleeding, transfusion requirement", "Resuscitation endpoints: lactate clearance (<2 mmol/L), urine output >0.5 mL/kg/hr, MAP >65 mmHg, base deficit correction", "Monitor: continuous ECG, arterial line (IBP), CVP, serial ABG, lactate, Hb", "TEG/ROTEM guided transfusion in ongoing hemorrhage", "Treat 'lethal triad': correct acidosis (bicarb/THAM), hypothermia (warming blankets, warmed fluids), coagulopathy (MTP)"]
    },
  ];

  const stepColors2 = ["5A1A7A", "005A5A", "1A1A7A", "7A5A00"];

  steps2.forEach((s, i) => {
    const col = i % 2;
    const row = Math.floor(i / 2);
    const x = 0.3 + col * 6.4;
    const y = 1.3 + row * 2.9;
    slide.addShape(pres.ShapeType.roundRect, {
      x, y, w: 6.1, h: 2.7,
      fill: { color: DEEP_NAVY },
      line: { color: stepColors2[i], pt: 2 },
      rectRadius: 0.1,
    });
    slide.addShape(pres.ShapeType.roundRect, {
      x: x + 0.1, y: y + 0.1, w: 1.1, h: 0.35,
      fill: { color: stepColors2[i] }, line: { color: stepColors2[i] }, rectRadius: 0.08,
    });
    slide.addText(s.num, {
      x: x + 0.12, y: y + 0.14, w: 1.06, h: 0.27,
      fontSize: 9.5, bold: true, color: WHITE, fontFace: "Calibri", align: "center",
    });
    slide.addText(s.label, {
      x: x + 1.3, y: y + 0.13, w: 4.7, h: 0.32,
      fontSize: 11, bold: true, color: WHITE, fontFace: "Calibri",
    });
    addBullets(slide, s.items, x + 0.15, y + 0.52, 5.8, 2.1, 10.5, BODY_TEXT, false, 12);
  });
}

// ─────────────────────────────────────────────────────────────────
// SLIDE 11: VARICEAL BLEEDING SPECIAL CONSIDERATIONS
// ─────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addSlideBackground(slide, DARK_SLATE);
  addTitle(slide, "Special Scenario: Variceal Bleeding & Cirrhotic Patient",
    "Rosen's Emergency Medicine | Sleisenger & Fordtran's | GOLDMAN-CECIL MEDICINE");

  // Pathophysiology of varices
  slide.addShape(pres.ShapeType.rect, { x: 0.3, y: 1.3, w: 4.0, h: 5.8, fill: { color: "1E1525" }, line: { color: "8A2BE2", pt: 1.5 } });
  addSectionLabel(slide, "PATHOPHYSIOLOGY OF VARICES", 0.3, 1.3, 4.0, "5A1A8A");
  const varPath = [
    "Portal hypertension (portal pressure >10–12 mmHg): drives varix formation",
    "Cirrhosis → ↑ hepatic vascular resistance → portal HTN",
    "Collateral channels form at gastroesophageal junction (varices)",
    "Varix rupture: wall tension exceeds threshold (LaPlace's law)",
    "Initial bleeding often massive and life-threatening",
    "Coagulopathy + thrombocytopenia in cirrhosis worsens hemorrhage",
    "Mortality: 10–15% per episode; 60% rebleed within 1 year without treatment",
    "MAP is independent predictor of mortality in cirrhosis — maintain carefully",
  ];
  addBullets(slide, varPath, 0.45, 1.75, 3.7, 5.1, 11, BODY_TEXT);

  // Management
  slide.addShape(pres.ShapeType.rect, { x: 4.65, y: 1.3, w: 4.0, h: 5.8, fill: { color: "1E2515" }, line: { color: "2E7D32", pt: 1.5 } });
  addSectionLabel(slide, "VARICEAL HEMORRHAGE MANAGEMENT", 4.65, 1.3, 4.0, "2E7D32");
  const varMgmt = [
    "Resuscitation: IV access, blood products (pRBC, FFP, platelets)",
    "Target Hb 7–8 g/dL (avoid over-transfusion — worsens portal pressure)",
    "Terlipressin or Octreotide (IV infusion): ↓ portal pressure; start immediately",
    "IV antibiotics (ceftriaxone or norfloxacin): mandatory — reduces infection risk and mortality",
    "Urgent EGD: endoscopic variceal ligation (EVL) — gold standard",
    "Sengstaken-Blakemore tube: temporary tamponade bridge to definitive therapy",
    "TIPS: refractory variceal bleeding, Child-Pugh B/C; reduces portal pressure",
    "Avoid beta-blockers, ACEIs, ARBs in acute hemorrhage (↓ MAP)",
    "Primary prophylaxis: propranolol/carvedilol; secondary prophylaxis: EVL + NSBB",
  ];
  addBullets(slide, varMgmt, 4.8, 1.75, 3.7, 5.1, 11, BODY_TEXT);

  // Coagulopathy box
  slide.addShape(pres.ShapeType.rect, { x: 9.0, y: 1.3, w: 4.0, h: 2.7, fill: { color: "2D1515" }, line: { color: CRIMSON, pt: 1.5 } });
  addSectionLabel(slide, "COAGULOPATHY IN CIRRHOSIS", 9.0, 1.3, 4.0, BLOOD_RED);
  const coag = [
    "Thrombocytopenia → target platelets >50,000/mm³",
    "INR/PT elevated → but standard dosing of FFP not evidence-based",
    "Cryoprecipitate (1U/10 kg) if fibrinogen <100 mg/dL",
    "Vitamin K (PO 10–20 mEq q6–12h) for nutritional/GI losses",
    "TEG/ROTEM: more accurate clotting assessment in cirrhosis than standard PT/INR",
  ];
  addBullets(slide, coag, 9.15, 1.75, 3.7, 2.2, 10.5, BODY_TEXT);

  // Encephalopathy box
  slide.addShape(pres.ShapeType.rect, { x: 9.0, y: 4.2, w: 4.0, h: 2.9, fill: { color: "1A2A10" }, line: { color: ACCENT_GOLD, pt: 1.5 } });
  addSectionLabel(slide, "HEPATIC ENCEPHALOPATHY", 9.0, 4.2, 4.0, "2E7D32");
  const enceph = [
    "Blood in GI tract → ↑ gut ammonia production → encephalopathy",
    "Risk increases with severity of bleeding",
    "Lactulose: first-line to reduce ammonia absorption",
    "Rifaximin: non-absorbable antibiotic; reduces gut bacterial ammonia production",
    "Monitor grade (I–IV): mild confusion → coma",
    "Airway protection if Grade III–IV encephalopathy",
  ];
  addBullets(slide, enceph, 9.15, 4.65, 3.7, 2.35, 10.5, BODY_TEXT);
}

// ─────────────────────────────────────────────────────────────────
// SLIDE 12: CT IMAGING — SHOCK FINDINGS
// ─────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addSlideBackground(slide, DARK_SLATE);
  addTitle(slide, "Imaging in Hypovolemic Shock & GI Bleeding",
    "CT Angiography | Nuclear Medicine | Radiology of Shock");

  if (images[2] && !images[2].error) {
    slide.addImage({ data: images[2].base64, x: 0.3, y: 1.3, w: 5.5, h: 4.1 });
    slide.addText("CT: Characteristic IVC collapse patterns in hypovolemic shock (A: slit-like IVC, B: small aorta in traumatic shock, C: flat IVC with ascites, D: IVC halo sign)", {
      x: 0.3, y: 5.45, w: 5.5, h: 0.5,
      fontSize: 9, color: LIGHT_GREY, italic: true, fontFace: "Calibri", wrap: true,
    });
  }

  slide.addShape(pres.ShapeType.rect, { x: 6.2, y: 1.3, w: 6.8, h: 5.8, fill: { color: "161E2E" }, line: { color: ACCENT_GOLD, pt: 1.5 } });
  addSectionLabel(slide, "KEY IMAGING FINDINGS IN SHOCK + GI BLEEDING", 6.2, 1.3, 6.8, MID_BLUE);

  const imgDetails = [
    { heading: "CT Shock Signs (CECT)", items: ["Flat/slit IVC: hallmark of hypovolemia (IVC diameter <9 mm, collapsibility >50%)", "Small aortic calibre: loss of intravascular volume", "'Halo sign' around IVC: peri-vascular edema from endothelial leak", "Hypodense rings around vessels: plasma extravasation", "Shock bowel: diffuse bowel wall thickening, mucosal enhancement, ascites"] },
    { heading: "CT Angiography (GI Bleed)", items: ["Active extravasation: hyperattenuating blush >85 HU in arterial phase", "Detects bleeding rate as low as 0.3–0.5 mL/min", "Identifies culprit vessel for targeted embolization", "Non-contrast phase: hyperdense intraluminal blood (acute hemorrhage)", "Identifies neoplasm, diverticulosis, vascular malformation"] },
    { heading: "Nuclear Medicine (Tc-99m RBC Scan)", items: ["Most sensitive: detects bleeding >0.1 mL/min", "Ideal for slow / intermittent bleeding", "Dynamic early images (0–30 min): focal tracer extravasation", "Delayed images: tracer follows bowel transit to localize origin", "Not useful for rapid, life-threatening hemorrhage (use CTA)"] },
    { heading: "Bedside POCUS in Shock", items: ["IVC diameter <2 cm + collapsibility >50% → fluid responsive", "'Kissing walls' sign on PSAX: severely depleted LV in profound hypovolemia", "Hyperdynamic LV: compensatory in early shock", "Rule out cardiac tamponade, tension pneumothorax as alternate shock etiology"] },
  ];

  let yPos = 1.78;
  imgDetails.forEach(g => {
    slide.addText(g.heading, {
      x: 6.35, y: yPos, w: 6.5, h: 0.28,
      fontSize: 11, bold: true, color: ACCENT_GOLD, fontFace: "Calibri",
    });
    yPos += 0.3;
    g.items.forEach(item => {
      slide.addText("• " + item, {
        x: 6.45, y: yPos, w: 6.4, h: 0.28,
        fontSize: 10.5, color: BODY_TEXT, fontFace: "Calibri",
      });
      yPos += 0.28;
    });
    yPos += 0.1;
  });
}

// ─────────────────────────────────────────────────────────────────
// SLIDE 13: COMPLICATIONS & MODS
// ─────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addSlideBackground(slide, DARK_SLATE);
  addTitle(slide, "Complications: MODS, Lethal Triad & Secondary Events",
    "Mulholland & Greenfield's Surgery | Sabiston Textbook of Surgery");

  // Lethal Triad
  slide.addShape(pres.ShapeType.rect, { x: 0.3, y: 1.3, w: 4.0, h: 2.8, fill: { color: "2D1515" }, line: { color: CRIMSON, pt: 2 } });
  addSectionLabel(slide, "THE LETHAL TRIAD OF TRAUMA/HEMORRHAGE", 0.3, 1.3, 4.0, BLOOD_RED);
  slide.addText([
    { text: "Acidosis", options: { bold: true, color: ACCENT_GOLD } },
    { text: " (pH <7.35, lactic acidosis, base deficit >6)", options: { color: BODY_TEXT } },
    { text: "\n• Impairs enzyme function, coagulation cascade, myocardial contractility\n\n", options: { color: BODY_TEXT } },
    { text: "Hypothermia", options: { bold: true, color: ACCENT_GOLD } },
    { text: " (core temp <35°C)\n• Coagulation enzyme dysfunction\n• Platelet dysfunction, cardiac arrhythmias\n\n", options: { color: BODY_TEXT } },
    { text: "Coagulopathy", options: { bold: true, color: ACCENT_GOLD } },
    { text: "\n• Consumption of clotting factors\n• DIC in extreme cases\n• Dilutional with crystalloid overload", options: { color: BODY_TEXT } },
  ], { x: 0.45, y: 1.75, w: 3.7, h: 2.2, fontSize: 10.5, fontFace: "Calibri", valign: "top" });

  // MODS
  slide.addShape(pres.ShapeType.rect, { x: 0.3, y: 4.3, w: 4.0, h: 2.8, fill: { color: "1A2020" }, line: { color: "008080", pt: 2 } });
  addSectionLabel(slide, "MULTI-ORGAN DYSFUNCTION SYNDROME (MODS)", 0.3, 4.3, 4.0, "006060");
  const modsItems = ["Sequential organ failure following prolonged shock", "Lung (ARDS) → Kidney (ATN) → Liver → Gut → Coagulation (DIC)", "Triggered by ischemia-reperfusion injury + systemic inflammation", "MODS carries >50% mortality once ≥3 organs involved", "Prevention: early goal-directed resuscitation, source control"];
  addBullets(slide, modsItems, 0.45, 4.75, 3.7, 2.2, 10.5, BODY_TEXT);

  // Rebleeding risk
  slide.addShape(pres.ShapeType.rect, { x: 4.65, y: 1.3, w: 4.2, h: 5.8, fill: { color: "1A1A30" }, line: { color: ACCENT_GOLD, pt: 1.5 } });
  addSectionLabel(slide, "REBLEEDING RISK FACTORS", 4.65, 1.3, 4.2, MID_BLUE);
  const rebleedItems = [
    "Forrest class Ia/Ib/IIa ulcer stigmata",
    "Ulcer size >2 cm",
    "Posterior duodenal wall ulcer (overlying GDA)",
    "High-risk endoscopic features despite initial hemostasis",
    "Coagulopathy not corrected",
    "Continued NSAID / anticoagulant use",
    "Liver disease / portal hypertension",
    "Recurrent variceal hemorrhage (60% at 1 year without prophylaxis)",
    "Hemodynamic instability at presentation",
    "Multiple comorbidities (ASA ≥3)",
    "PPI infusion reduces rebleeding: 80 mg IV bolus then 8 mg/hr infusion for 72 h",
  ];
  addBullets(slide, rebleedItems, 4.8, 1.78, 3.9, 5.1, 11, BODY_TEXT);

  // Predictors of mortality
  slide.addShape(pres.ShapeType.rect, { x: 9.2, y: 1.3, w: 3.8, h: 5.8, fill: { color: "2A1515" }, line: { color: CRIMSON, pt: 1.5 } });
  addSectionLabel(slide, "MORTALITY PREDICTORS", 9.2, 1.3, 3.8, BLOOD_RED);
  const mortPred = [
    "Shock at presentation (SBP <90)",
    "Age >65 years",
    "Comorbidities: cardiac, hepatic, renal failure",
    "Active bleeding at endoscopy",
    "Rebleeding in hospital",
    "Need for surgery",
    "Coagulopathy: INR >1.5 or fibrinogen <100",
    "Albumin <3 g/dL (AIMS65 score)",
    "Altered mental status",
    "Vasopressor requirement",
    "Lactate >4 mmol/L on admission",
    "Base deficit > -6",
    "Failure to clear lactate within 6 h",
  ];
  addBullets(slide, mortPred, 9.35, 1.75, 3.5, 5.1, 10.5, BODY_TEXT);
}

// ─────────────────────────────────────────────────────────────────
// SLIDE 14: CLINICAL ALGORITHM / FLOWCHART
// ─────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addSlideBackground(slide, DEEP_NAVY);
  addTitle(slide, "Clinical Algorithm: GI Bleeding with Hemodynamic Instability",
    "Step-by-Step Approach | Emergency & Surgical Management");

  // Main flow boxes
  const boxes = [
    { x: 5.3, y: 1.3, w: 2.7, h: 0.6, color: BLOOD_RED, text: "PATIENT PRESENTS WITH GI BLEEDING", fontSize: 9, bold: true },
    { x: 5.3, y: 2.1, w: 2.7, h: 0.6, color: MID_BLUE, text: "IMMEDIATE ASSESSMENT\nAirway, Breathing, Circulation (ABC)\nVital signs, Shock Index (HR/SBP)", fontSize: 8.5 },
    { x: 5.3, y: 2.9, w: 2.7, h: 0.6, color: "1A5A2A", text: "HEMODYNAMICALLY STABLE?", fontSize: 10, bold: true },
  ];

  boxes.forEach(b => {
    slide.addShape(pres.ShapeType.roundRect, { x: b.x, y: b.y, w: b.w, h: b.h, fill: { color: b.color }, line: { color: ACCENT_GOLD, pt: 1 }, rectRadius: 0.08 });
    slide.addText(b.text, { x: b.x + 0.08, y: b.y + 0.06, w: b.w - 0.16, h: b.h - 0.12, fontSize: b.fontSize || 9, bold: b.bold || false, color: WHITE, fontFace: "Calibri", align: "center" });
    // Downward connector
    if (b !== boxes[boxes.length - 1]) {
      slide.addShape(pres.ShapeType.rect, { x: b.x + b.w / 2 - 0.03, y: b.y + b.h, w: 0.06, h: 0.1, fill: { color: ACCENT_GOLD } });
    }
  });

  // YES branch (stable) — RIGHT
  const stableX = 9.2;
  slide.addText("YES", { x: 8.15, y: 3.1, w: 0.8, h: 0.25, fontSize: 9, bold: true, color: "#4CAF50", fontFace: "Calibri", align: "center" });
  slide.addShape(pres.ShapeType.rect, { x: 8.0, y: 3.2, w: 1.2, h: 0.06, fill: { color: ACCENT_GOLD } });

  const stableSteps = [
    { text: "NPO + IV Access (2x large bore)\nLabs: CBC, BMP, PT/INR, T&S\nType & Screen" },
    { text: "Risk Stratify:\nGlasgow-Blatchford Score\nAIMS65 Score" },
    { text: "UGIB: EGD within 24 h\nLGIB: Colonoscopy within 24 h\nafter bowel prep" },
    { text: "Low-risk: discharge\nHigh-risk: admit + PPI\nRepeated endoscopy if rebleed" },
  ];
  stableSteps.forEach((s, i) => {
    const y = 2.95 + i * 0.9;
    slide.addShape(pres.ShapeType.roundRect, { x: stableX, y, w: 3.8, h: 0.75, fill: { color: "0F3460" }, line: { color: ACCENT_GOLD, pt: 0.8 }, rectRadius: 0.06 });
    slide.addText(s.text, { x: stableX + 0.1, y: y + 0.07, w: 3.6, h: 0.6, fontSize: 9, color: WHITE, fontFace: "Calibri" });
    if (i < stableSteps.length - 1) slide.addShape(pres.ShapeType.rect, { x: stableX + 1.85, y: y + 0.75, w: 0.05, h: 0.15, fill: { color: ACCENT_GOLD } });
  });

  // NO branch (unstable) — LEFT
  slide.addText("NO", { x: 4.4, y: 3.1, w: 0.75, h: 0.25, fontSize: 9, bold: true, color: CRIMSON, fontFace: "Calibri", align: "center" });
  slide.addShape(pres.ShapeType.rect, { x: 3.9, y: 3.2, w: 1.3, h: 0.06, fill: { color: CRIMSON } });

  const unstableSteps = [
    { text: "ACTIVATE MTP & Resuscitation Team\n2x large-bore IV or cordis, O2, monitor" },
    { text: "Warmed crystalloid bolus 1–2L\npRBC if Hb <7 (or actively bleeding)\nMTP 1:1:1 if massive hemorrhage" },
    { text: "Pharmacology:\nTranexamic Acid (within 3h)\nOctreotide if variceal\nPPI bolus + infusion" },
    { text: "Urgent EGD: UGIB → endoscopic\nhemostasis\nColonoscopy/IR: LGIB" },
    { text: "Failure → IR Embolization\nor Emergency Surgery\n(Damage Control Protocol)" },
  ];
  unstableSteps.forEach((s, i) => {
    const y = 2.95 + i * 0.85;
    slide.addShape(pres.ShapeType.roundRect, { x: 0.3, y, w: 3.5, h: 0.72, fill: { color: "2D1515" }, line: { color: CRIMSON, pt: 0.8 }, rectRadius: 0.06 });
    slide.addText(s.text, { x: 0.4, y: y + 0.07, w: 3.3, h: 0.58, fontSize: 8.5, color: WHITE, fontFace: "Calibri" });
    if (i < unstableSteps.length - 1) slide.addShape(pres.ShapeType.rect, { x: 1.8, y: y + 0.72, w: 0.05, h: 0.13, fill: { color: CRIMSON } });
  });

  // ICU box at bottom center
  slide.addShape(pres.ShapeType.roundRect, { x: 4.0, y: 6.55, w: 5.3, h: 0.7, fill: { color: "1A1A30" }, line: { color: ACCENT_GOLD, pt: 1.5 }, rectRadius: 0.1 });
  slide.addText("ICU MONITORING: Lactate clearance, urine output >0.5 mL/kg/hr, MAP >65 mmHg\nTreat lethal triad: Acidosis + Hypothermia + Coagulopathy", {
    x: 4.1, y: 6.6, w: 5.1, h: 0.6,
    fontSize: 9.5, color: ACCENT_GOLD, bold: true, fontFace: "Calibri", align: "center",
  });
}

// ─────────────────────────────────────────────────────────────────
// SLIDE 15: SUMMARY
// ─────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addSlideBackground(slide, DEEP_NAVY);

  // Left dark red panel
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 4.0, h: 7.5, fill: { color: DARK_RED } });
  slide.addText("KEY\nTAKEAWAYS", {
    x: 0.15, y: 2.5, w: 3.7, h: 2.0,
    fontSize: 32, bold: true, color: WHITE, fontFace: "Calibri", align: "center", charSpacing: 2,
  });
  slide.addText("Hypovolemic Shock\nin GI Bleeding", {
    x: 0.15, y: 4.6, w: 3.7, h: 1.0,
    fontSize: 14, color: LIGHT_GOLD, fontFace: "Calibri", align: "center", italic: true,
  });
  slide.addShape(pres.ShapeType.rect, { x: 0.5, y: 4.55, w: 3.0, h: 0.05, fill: { color: ACCENT_GOLD } });

  // Right panel: key takeaways
  const takeaways = [
    "Hypovolemic shock = ↓ intravascular volume → ↓ CO → inadequate perfusion; commonest shock in surgical practice",
    "GI bleeding (peptic ulcer, varices, diverticular, angiodysplasia) is a leading cause of non-traumatic hemorrhagic shock",
    "ATLS Classes I–IV guide resuscitation: >20% blood loss produces shock; >40% is immediately life-threatening",
    "Compensatory mechanisms (SNS, RAAS, ADH) temporarily maintain BP but fail with >30–40% blood loss",
    "Earliest sign: tachycardia. Hypotension is a late sign indicating decompensated shock",
    "BUN:Cr ratio >30 strongly predicts UGIB (LR 7.5); Shock Index (HR/SBP) >1.0 = significant hemorrhage",
    "Resuscitation priorities: airway → IV access → crystalloid bolus → MTP transfusion (1:1:1) → TXA",
    "Restrictive transfusion strategy (Hb trigger <7 g/dL) unless active/ongoing bleeding",
    "PPI IV infusion + Octreotide (varices) + IV antibiotics reduce morbidity and mortality",
    "Urgent EGD within 12–24 h: cornerstone of diagnosis and hemostasis",
    "Failure of endoscopy → IR embolization; failure of IR → surgical hemorrhage control",
    "Lethal triad (acidosis + hypothermia + coagulopathy) must be aggressively reversed",
    "MODS is the terminal pathway: prevent by early, goal-directed resuscitation and source control",
  ];

  takeaways.forEach((t, i) => {
    const col = Math.floor(i / 7);
    const row = i % 7;
    slide.addShape(pres.ShapeType.roundRect, {
      x: 4.3 + col * 4.4, y: 0.45 + row * 0.93, w: 4.2, h: 0.85,
      fill: { color: i % 2 === 0 ? MID_BLUE : "1A2A3A" }, line: { color: ACCENT_GOLD, pt: 0.8 }, rectRadius: 0.06,
    });
    slide.addText([
      { text: String(i + 1) + ".  ", options: { bold: true, color: ACCENT_GOLD } },
      { text: t, options: { color: BODY_TEXT } },
    ], {
      x: 4.4 + col * 4.4, y: 0.5 + row * 0.93, w: 4.0, h: 0.75,
      fontSize: 9.5, fontFace: "Calibri", valign: "middle",
    });
  });

  // Bottom bar
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 7.35, w: 13.33, h: 0.15, fill: { color: CRIMSON } });
  slide.addText("Sources: Guyton & Hall Physiology | Sabiston Textbook of Surgery | Mulholland & Greenfield's Surgery | Rosen's Emergency Medicine | Sleisenger & Fordtran's GI | Goldman-Cecil Medicine", {
    x: 0.3, y: 7.1, w: 13.0, h: 0.22,
    fontSize: 7.5, color: LIGHT_GREY, italic: true, fontFace: "Calibri",
  });
}

// ─────────────────────────────────────────────────────────────────
// WRITE FILE
// ─────────────────────────────────────────────────────────────────
pres.writeFile({ fileName: "/home/daytona/workspace/hypovolemic-shock-gi/Hypovolemic_Shock_GI_Bleeding.pptx" })
  .then(() => console.log("SUCCESS: Presentation saved!"))
  .catch(e => console.error("ERROR:", e));
Your credits are exhausted. Your daily credits reset tomorrow, or you can purchase a top-up for more.

Yes

Your credits are exhausted. Your daily credits reset tomorrow, or you can purchase a top-up for more.

Generate a Word document with step-by-step treatment protocols

Your credits are exhausted. Your daily credits reset tomorrow, or you can purchase a top-up for more.

Make presentations on hypvolomia in gi bleeding according to emergency

Your credits are exhausted. Your daily credits reset tomorrow, or you can purchase a top-up for more.

Make presentation on hypovolemic shock in GI bleeding it’s path physiological in detail explanation and more text signs symptoms diagnosis and treatment with step by step approaches In Emergency medicine

Your credits are exhausted. Your daily credits reset tomorrow, or you can purchase a top-up for more.
This is a shared conversation. Sign in to Orris to start your own chat.