Abdominal lump

Reading File
The query "abdominal lump" is broad - it could mean clinical approach, differential diagnosis, specific conditions, or a particular region. Let me clarify before doing deep research.
Asking for Preferences

What aspect of 'abdominal lump' are you looking for? · What is the context?

I'll provide a comprehensive clinical overview of abdominal lumps - covering approach, regional differentials, examination, and investigations. Let me pull from the medical library now.
Searching sources...
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Finding Sources
Reading File
Finding Sources
Reading File
Reading File
Reading File
Finding Sources
Reading File
I now have solid content from Harrison's and Pye's Surgical Handicraft. Let me compile a comprehensive, well-structured answer.

Abdominal Lump: Clinical Overview

Definition and Initial Approach

An abdominal lump is any palpable mass arising within or on the abdominal wall or cavity. The clinical approach follows a systematic pattern: history → examination → investigations.

Causes: The "Six Fs" (Abdominal Swelling)

A useful mnemonic for the broad causes of abdominal swelling and masses (Harrison's Principles, 22nd Ed.):
"F"CauseExamples
FlatusIntestinal gasAerophagia, IBS, SIBO, lactose intolerance
FatAdiposityObesity, Cushing's syndrome
FluidAscitesCirrhosis, heart failure, malignancy, TB
FetusPregnancyUterus rising from pelvis at ~12 weeks
FecesConstipation/obstructionBowel obstruction, severe constipation
Fatal GrowthNeoplasm/massCarcinoma, abscess, cyst, organomegaly, AAA

Regional Differential Diagnosis

RegionCommon Causes
Right hypochondriumHepatomegaly, Riedel's lobe (normal variant), distended gallbladder, hepatic metastases
EpigastriumGastric carcinoma, pancreatic pseudocyst/tumor, aortic aneurysm (pulsatile)
Left hypochondriumSplenomegaly (lymphoma, portal hypertension, haematological malignancy)
Umbilical/periumbilicalSmall bowel mass, lymph nodes, aortic aneurysm
Right iliac fossaAppendix mass/abscess, Crohn's disease (doughy mass), caecal carcinoma, iliopsoas abscess, ovarian cyst (female)
Left iliac fossaSigmoid carcinoma, diverticular mass, ovarian cyst (female)
FlanksRenal mass (descends on inspiration), polycystic kidneys
Suprapubic/hypogastricBladder distension, uterine fibroid/carcinoma, ovarian mass
DiffuseAscites, gross organomegaly, mesenteric cyst

History Taking

Key questions (Harrison's, 22nd Ed.):
  • Onset and timing: Sudden vs. gradual; related to meals or bowel habit
  • Associated symptoms: Weight loss, night sweats, anorexia (suggest malignancy); jaundice, alcohol use (suggest liver disease); inability to pass stool/flatus (obstruction)
  • Prior surgery: Adhesions, recurrent pathology
  • Risk factors: Alcohol, viral hepatitis (cirrhosis); family history of malignancy

Physical Examination

Positioning

Patient supine, hands by sides, single pillow under head (Pye's Surgical Handicraft, p. 265-266).

Inspection

  • Visible mass, asymmetric distension
  • Visible peristalsis (intestinal obstruction)
  • Epigastric pulsation (aortic aneurysm)
  • Caput medusae (dilated periumbilical veins): portal hypertension / portal vein thrombosis
  • Dilated flank veins: IVC obstruction
  • Spider angiomas, palmar erythema, gynecomastia: liver disease
  • Surgical scars: adhesions or recurrent pathology

Auscultation (before palpation)

  • High-pitched localized bowel sounds: intestinal obstruction
  • Absent bowel sounds: peritonitis / paralytic ileus
  • Umbilical venous hum: portal hypertension
  • Hepatic bruit (rare): hepatocellular carcinoma or alcoholic hepatitis

Percussion

  • Tympanic: gas-filled bowel (flatus)
  • Dull: solid mass or fluid (ascites)
  • Shifting dullness / fluid thrill: ascites (needs >1500 mL to detect clinically)
  • Splenomegaly: dull to percussion below left costal margin

Palpation

  • Begin gently, away from the painful area
  • Renal masses arise in the flanks and descend on inspiration (bimanually palpable - ballotable)
  • Splenomegaly: descends on deep inspiration toward right iliac fossa, has a notch, cannot get above it
  • Hepatomegaly: descends on inspiration, dull to percussion, cannot get above it
  • Non-tender mass: likely neoplastic
  • Tender mass: likely inflammatory (e.g., Crohn's disease, abscess)
  • Assess: size, shape, surface, consistency, mobility, movement with respiration, pulsatility, reducibility (hernia)

Always Complete With

  • Rectal examination (rectal carcinoma, extrinsic pelvic mass)
  • Lymph nodes - especially Virchow's node (left supraclavicular fossa): suggests metastatic abdominal malignancy

Investigations

Imaging

TestUse
Abdominal X-rayDilated bowel loops (obstruction/ileus), calcification (stones, AAA), fecal loading
UltrasoundFirst-line: detects ascites (as little as 100 mL), hepatosplenomegaly, gallstones, renal masses, abdominal aortic aneurysm
CT abdomen/pelvisDefinitive characterization; retroperitoneal nodes, pancreatic lesions, staging malignancy
MRILiver lesions, soft tissue characterization

Laboratory

  • FBC: Anaemia (blood loss/malignancy), leukocytosis (infection), cytopenias (hypersplenism)
  • LFTs + albumin + PT/INR: Hepatic function (cirrhosis, malignancy)
  • Amylase/lipase: Pancreatitis
  • Urea & electrolytes: Renal function
  • Tumour markers: CEA (colorectal), CA-125 (ovarian), AFP (hepatocellular), CA 19-9 (pancreatic) - as clinically indicated
  • Urine protein: Nephrotic syndrome

Interventional

  • Diagnostic paracentesis: Ascites - serum-ascites albumin gradient (SAAG) differentiates portal hypertension (SAAG ≥1.1) from other causes
  • Biopsy: Tissue diagnosis for solid masses

Key Clinical Clues at a Glance

FindingThink of
Pulsatile expansile epigastric massAbdominal aortic aneurysm
Non-tender RUQ mass + jaundiceCourvoisier's sign (pancreatic/biliary carcinoma)
Doughy RIF mass + diarrhoeaCrohn's disease
Ballotable flank massRenal cell carcinoma / hydronephrosis
Left supraclavicular node (Virchow's)Gastric/GI metastasis
Umbilical noduleSister Mary Joseph nodule (metastatic intra-abdominal carcinoma)
Shifting dullness + fluid thrillAscites

Sources:

Treatment and management of acute pancreatitis

Acute pancreatitis management centers on aggressive IV fluid resuscitation, analgesia, and nutritional support. Mild cases are self-limiting; severe cases require ICU care. ERCP is indicated for gallstone pancreatitis with cholangitis. Antibiotics are NOT routine - only for infected necrosis.
Searching sources...
Finding Sources
Searching PubMed

"acute pancreatitis"[MeSH Terms] AND "management"[MeSH Terms]

Finding Sources
Searching PubMed

"acute pancreatitis" AND "fluid resuscitation"

Reading File
Finding Sources
The best sources are Sleisenger & Fordtran's (the gold-standard GI textbook) and Rosen's Emergency Medicine. Let me read those in parallel.
Reading File
Reading File
Good content from Rosen's. The Sleisenger block was pediatric - I need the adult management block. Let me read more from Rosen's and also get the dedicated management section from Sleisenger.
Reading File
Finding Sources
Reading File
Reading File
Excellent - I got comprehensive management content from Rosen's. I now have all the information needed for a thorough response.

Treatment and Management of Acute Pancreatitis

Diagnosis (Atlanta Criteria - 2 of 3 required)

  1. Abdominal pain characteristic of acute pancreatitis (persistent epigastric/LUQ pain, often radiating to the back)
  2. Serum lipase or amylase ≥3x upper limit of normal (lipase preferred - more sensitive and specific; stays elevated 1-2 weeks vs. 3-5 days for amylase)
  3. Characteristic findings on abdominal imaging
Degree of enzyme elevation does NOT correlate with severity. - Rosen's Emergency Medicine

Severity Classification (Revised Atlanta 2012)

GradeDefinitionMortality
MildNo organ failure, no local/systemic complications<1%
Moderately SevereTransient organ failure (<48h) OR local complications~5-8%
SeverePersistent organ failure (>48h), single or multi-organUp to 30%
Scoring systems: BISAP (Bedside Index of Severity in AP), Ranson's criteria, APACHE II, and CT Severity Index (CTSI) all used to stratify risk.

1. Fluid Resuscitation (MOST CRITICAL early intervention)

  • Aggressive IV fluids are the cornerstone of early management
  • Goal-directed resuscitation: 250-500 mL/hr initially, titrated to clinical response
  • Preferred fluid: Lactated Ringer's (LR) is preferred over normal saline - evidence shows LR reduces the incidence of SIRS and may reduce the inflammatory response
  • Targets: urine output >0.5 mL/kg/hr, heart rate <100, MAP >65 mmHg, normalization of hematocrit and BUN
  • Overly aggressive resuscitation can worsen outcomes (abdominal compartment syndrome, pulmonary edema) - reassess every 6 hours
  • Avoid: Normal saline (hyperchloremic acidosis risk); colloids have no proven benefit

2. Analgesia

  • Effective pain control is essential - pain causes splinting, hypoventilation, and distress
  • IV opioids are safe and effective - morphine, hydromorphone, or fentanyl
  • Historical concern that morphine causes sphincter of Oddi spasm is not supported by clinical evidence and should not withhold treatment
  • NSAIDs (ketorolac) may be used as adjuncts
  • Epidural analgesia in severe cases (specialist setting)

3. Nil by Mouth / Nutrition

Mild Pancreatitis

  • Early oral feeding as soon as tolerated (even within 24h if pain is controlled and nausea/vomiting has settled)
  • Start with soft/low-fat diet - no need to wait for enzyme normalization or bowel sounds to return
  • Clear liquids first, advancing as tolerated

Moderate-Severe Pancreatitis

  • Early enteral nutrition is strongly preferred over TPN
  • Nasogastric (NG) or nasojejunal (NJ) feeding: RCTs show both are equally effective; NG is easier to place
  • Start enteral feeding within 24-72 hours of admission
  • Benefits of enteral over parenteral: maintains gut barrier, reduces bacterial translocation, lower infection rates, fewer complications, cheaper
  • TPN only if enteral route is not tolerated or contraindicated (e.g., ileus, fistula, bowel obstruction)
  • Never keep NPO beyond 24-48h in severe pancreatitis - this increases morbidity

4. Antibiotics

Prophylactic antibiotics are NOT recommended in acute pancreatitis, including in sterile necrotizing pancreatitis.
  • Multiple RCTs and meta-analyses have failed to show benefit of prophylactic antibiotics in preventing infected necrosis
  • Antibiotics ARE indicated when:
    • Infected pancreatic necrosis is confirmed or strongly suspected (fever + leukocytosis + CT showing gas in necrosis, or positive FNA culture)
    • Concurrent cholangitis (sepsis from biliary obstruction)
    • Other proven bacterial infection (pneumonia, UTI, line infection)
  • Drug of choice for infected necrosis: Carbapenems (imipenem/meropenem) - good pancreatic penetration; alternatives: fluoroquinolones + metronidazole

5. Management of Specific Causes

Gallstone Pancreatitis

  • Urgent ERCP (within 24-72h) is indicated if concurrent acute cholangitis or persistent biliary obstruction is present
  • ERCP is NOT routinely required in mild gallstone pancreatitis without cholangitis - stones usually pass spontaneously
  • Cholecystectomy should be performed during the same admission (or within 2 weeks) for mild gallstone pancreatitis to prevent recurrence
  • Delaying cholecystectomy risks recurrence rate of ~25-30%

Hypertriglyceridemia-Induced (TG >1000 mg/dL)

  • Insulin infusion (even in non-diabetics) activates lipoprotein lipase and rapidly reduces triglycerides
  • Plasmapheresis in refractory cases
  • Long-term: fibrates, omega-3 fatty acids, dietary fat restriction

Alcohol-Induced

  • Address alcohol cessation
  • Monitor for alcohol withdrawal (Wernicke's, DTs)

6. Monitoring and ICU

  • Continuous monitoring of urine output, vitals, oxygen saturation
  • Serial labs: FBC, BMP, LFTs, CRP, procalcitonin
  • Watch for organ failure: renal (creatinine), pulmonary (PaO2/FiO2), cardiovascular (MAP)
  • Oxygen therapy / mechanical ventilation if ARDS develops
  • Renal replacement therapy for renal failure

7. Management of Complications

Pancreatic Necrosis

  • Sterile necrosis: managed conservatively (supportive care)
  • Infected necrosis: antibiotics + minimally invasive necrosectomy (step-up approach)
    • Step-up: percutaneous drainage → video-assisted retroperitoneal debridement (VARD) → open surgery only if above fails
    • Open necrosectomy carries 30-40% mortality; minimally invasive approaches preferred
    • Delay intervention until necrosis is "walled off" (>3-4 weeks) to improve outcomes

Pancreatic Pseudocyst

  • Most resolve spontaneously
  • Drainage indicated if: symptomatic, growing, infected, causing obstruction
  • Preferred: endoscopic cyst-gastrostomy or cyst-duodenostomy (EUS-guided)

Abdominal Compartment Syndrome

  • Monitor intra-abdominal pressure (IAP >20 mmHg + new organ failure)
  • Reduce fluids, neuromuscular blockade, percutaneous drainage of ascites; surgical decompression if refractory

8. Summary Management Algorithm

Diagnosis confirmed (≥2 Atlanta criteria)
         |
         ▼
Aggressive IV LR fluids + IV analgesia
         |
         ▼
Assess severity (BISAP, APACHE II, SIRS criteria)
         |
    _____|_____
   |           |
  Mild      Moderate/Severe
   |           |
Early oral  ICU admission
 feeding    Enteral nutrition ≤72h
   |        Monitor organ function
   |           |
Cholecystectomy  Antibiotics ONLY if infected necrosis
same admission    or cholangitis

Key Points at a Glance

InterventionRecommendation
IV fluid choiceLactated Ringer's preferred
Opioid analgesiaSafe - morphine concern is a myth
Feeding in mild APEarly oral feeding, low fat
Feeding in severe APEnteral (NG/NJ) within 24-72h
Prophylactic antibioticsNOT recommended
AntibioticsOnly for infected necrosis or cholangitis
ERCPOnly if cholangitis or persistent biliary obstruction
Cholecystectomy (gallstone AP)Same admission or within 2 weeks
CT imagingNot routine; after 48-72h if no improvement
NecrosectomyStep-up approach; delay ≥4 weeks if possible

Sources:

Make me a presentation for postgraduate class

Asking for Preferences

Which topic should the presentation cover? · What format do you need?

Reading File
Reading File
Reading File
Running Command

mkdir -p /home/daytona/workspace/acute-pancreatitis-ppt && ls /home/daytona/workspace/acute-pancreatitis-ppt

Writing File

~/acute-pancreatitis-ppt/create_ppt.js

const pptxgen = require("pptxgenjs");

const pres = new pptxgen();
pres.layout = "LAYOUT_16x9";
pres.title = "Acute Pancreatitis: Treatment & Management";
pres.author = "Postgraduate Medical Education";

// ─── COLOR PALETTE ───────────────────────────────────────────────────────────
const C = {
  navy:    "0D2B4E",   // dominant dark bg
  teal:    "1A7A8A",   // heading bars / accents
  sky:     "2DB8CC",   // highlights / icons
  white:   "FFFFFF",
  offwhite:"F4F8FA",
  amber:   "F0A500",   // warning / key points
  red:     "C0392B",   // danger / critical
  grey:    "5A6A7A",   // body text on light bg
  lightbg: "EBF4F7",   // light slide bg
};

// ─── HELPER: section header bar ──────────────────────────────────────────────
function addTopBar(slide, title) {
  slide.addShape(pres.shapes.RECTANGLE, {
    x: 0, y: 0, w: 10, h: 0.7,
    fill: { color: C.teal }, line: { color: C.teal }
  });
  slide.addText(title.toUpperCase(), {
    x: 0.3, y: 0, w: 9.4, h: 0.7,
    fontSize: 13, bold: true, color: C.white, valign: "middle", charSpacing: 2, margin: 0
  });
}

// ─── HELPER: footer ──────────────────────────────────────────────────────────
function addFooter(slide, text = "Acute Pancreatitis | Postgraduate Class") {
  slide.addShape(pres.shapes.RECTANGLE, {
    x: 0, y: 5.35, w: 10, h: 0.275,
    fill: { color: C.navy }, line: { color: C.navy }
  });
  slide.addText(text, {
    x: 0.3, y: 5.35, w: 9.4, h: 0.275,
    fontSize: 7.5, color: C.sky, valign: "middle", margin: 0
  });
}

// ─── HELPER: colored card ────────────────────────────────────────────────────
function addCard(slide, x, y, w, h, bg, title, bullets, titleColor = C.white, textColor = C.navy) {
  slide.addShape(pres.shapes.RECTANGLE, {
    x, y, w, h,
    fill: { color: bg },
    shadow: { type: "outer", color: "000000", blur: 5, offset: 2, angle: 135, opacity: 0.12 }
  });
  const items = [];
  if (title) {
    items.push({ text: title, options: { bold: true, color: titleColor, fontSize: 11, breakLine: bullets.length > 0 } });
  }
  bullets.forEach((b, i) => {
    items.push({ text: b, options: { color: textColor, fontSize: 9.5, bullet: { indent: 10 }, breakLine: i < bullets.length - 1 } });
  });
  slide.addText(items, { x: x + 0.12, y: y + 0.1, w: w - 0.24, h: h - 0.2, valign: "top" });
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 1 — TITLE
// ═══════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  // Full dark bg
  s.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: C.navy }, line: { color: C.navy } });
  // Teal accent bar left
  s.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0, w: 0.25, h: 5.625, fill: { color: C.sky }, line: { color: C.sky } });
  // Decorative circle
  s.addShape(pres.shapes.ELLIPSE, { x: 7.2, y: -0.8, w: 3.8, h: 3.8, fill: { color: C.teal, transparency: 75 }, line: { color: C.teal, transparency: 75 } });
  s.addShape(pres.shapes.ELLIPSE, { x: 7.8, y: 3.2, w: 2.5, h: 2.5, fill: { color: C.sky, transparency: 80 }, line: { color: C.sky, transparency: 80 } });

  s.addText("ACUTE PANCREATITIS", {
    x: 0.5, y: 1.1, w: 7, h: 0.85,
    fontSize: 34, bold: true, color: C.white, charSpacing: 3
  });
  s.addShape(pres.shapes.RECTANGLE, { x: 0.5, y: 2.05, w: 3.5, h: 0.06, fill: { color: C.amber }, line: { color: C.amber } });
  s.addText("Treatment & Management", {
    x: 0.5, y: 2.2, w: 7, h: 0.55,
    fontSize: 18, color: C.sky, italic: true
  });
  s.addText("Postgraduate Medical Education  |  2026", {
    x: 0.5, y: 4.7, w: 7, h: 0.4,
    fontSize: 11, color: C.grey
  });
  s.addText([
    { text: "Sources: ", options: { bold: true, color: C.sky, fontSize: 8 } },
    { text: "Rosen's Emergency Medicine 9e  ·  Sleisenger & Fordtran's GI & Liver Disease  ·  Harrison's Principles 22e", options: { color: C.grey, fontSize: 8 } }
  ], { x: 0.5, y: 5.1, w: 9, h: 0.35 });
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 2 — OVERVIEW / AGENDA
// ═══════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: C.offwhite }, line: { color: C.offwhite } });
  addTopBar(s, "Overview");

  const topics = [
    ["01", "Epidemiology & Aetiology"],
    ["02", "Pathophysiology"],
    ["03", "Diagnosis & Severity Classification"],
    ["04", "Fluid Resuscitation"],
    ["05", "Analgesia & Nutrition"],
    ["06", "Antibiotic Policy"],
    ["07", "Disease-Specific & ERCP"],
    ["08", "Complications & Interventions"],
    ["09", "Management Algorithm"],
    ["10", "Key Takeaways"],
  ];

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

  col1.forEach(([num, title], i) => {
    const y = 0.95 + i * 0.82;
    s.addShape(pres.shapes.RECTANGLE, { x: 0.4, y, w: 0.52, h: 0.52, fill: { color: C.teal }, line: { color: C.teal } });
    s.addText(num, { x: 0.4, y, w: 0.52, h: 0.52, fontSize: 14, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    s.addText(title, { x: 1.05, y: y + 0.08, w: 3.8, h: 0.38, fontSize: 12, color: C.grey });
  });

  col2.forEach(([num, title], i) => {
    const y = 0.95 + i * 0.82;
    s.addShape(pres.shapes.RECTANGLE, { x: 5.3, y, w: 0.52, h: 0.52, fill: { color: C.sky }, line: { color: C.sky } });
    s.addText(num, { x: 5.3, y, w: 0.52, h: 0.52, fontSize: 14, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    s.addText(title, { x: 5.95, y: y + 0.08, w: 3.8, h: 0.38, fontSize: 12, color: C.grey });
  });

  addFooter(s);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 3 — EPIDEMIOLOGY & AETIOLOGY
// ═══════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: C.offwhite }, line: { color: C.offwhite } });
  addTopBar(s, "01  ·  Epidemiology & Aetiology");

  // Stats row
  const stats = [
    { val: "#1", label: "GI cause of\nhospitalisation (USA)" },
    { val: "40-70%", label: "Caused by\ngallstones" },
    { val: "25-35%", label: "Caused by\nalcohol" },
    { val: "≤30%", label: "Mortality in\nsevere cases" },
  ];
  stats.forEach((st, i) => {
    const x = 0.3 + i * 2.38;
    s.addShape(pres.shapes.RECTANGLE, {
      x, y: 0.85, w: 2.1, h: 1.25,
      fill: { color: C.navy },
      shadow: { type: "outer", color: "000000", blur: 6, offset: 2, angle: 135, opacity: 0.15 }
    });
    s.addText(st.val, { x, y: 0.9, w: 2.1, h: 0.65, fontSize: 22, bold: true, color: C.amber, align: "center" });
    s.addText(st.label, { x, y: 1.52, w: 2.1, h: 0.55, fontSize: 8.5, color: C.sky, align: "center" });
  });

  s.addText("CAUSES", { x: 0.3, y: 2.3, w: 4, h: 0.35, fontSize: 10, bold: true, color: C.teal, charSpacing: 2 });

  const causes = [
    ["Gallstones", "40–70% of cases — most common overall"],
    ["Alcohol", "25–35% — second most common"],
    ["Hypertriglyceridaemia", "TG >1000 mg/dL — third most common"],
    ["Post-ERCP", "5–10% incidence after procedure"],
    ["Drugs", "Valproate, azathioprine, thiazides, steroids"],
    ["Rare", "Hypercalcaemia, trauma, autoimmune, viral (mumps, EBV, CMV), hereditary"],
    ["Idiopathic", "~15–20% — after excluding all known causes"],
  ];

  causes.forEach(([title, desc], i) => {
    const y = 2.72 + i * 0.38;
    s.addShape(pres.shapes.RECTANGLE, { x: 0.3, y, w: 0.08, h: 0.24, fill: { color: C.sky }, line: { color: C.sky } });
    s.addText([
      { text: title + "  ", options: { bold: true, color: C.navy, fontSize: 9.5 } },
      { text: desc, options: { color: C.grey, fontSize: 9.5 } }
    ], { x: 0.5, y, w: 9.2, h: 0.34 });
  });

  addFooter(s);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 4 — PATHOPHYSIOLOGY
// ═══════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: C.navy }, line: { color: C.navy } });
  addTopBar(s, "02  ·  Pathophysiology");

  const steps = [
    { x: 0.3,  label: "Inciting\nEvent", detail: "Gallstone, alcohol,\ndrug, duct obstruction" },
    { x: 2.55, label: "Acinar Cell\nInjury", detail: "Disruption of\nmembrane trafficking" },
    { x: 4.8,  label: "Trypsinogen\nActivation", detail: "Auto-activation →\ntrypsin release" },
    { x: 7.05, label: "Autodigestion\n+ SIRS", detail: "Cytokines, oedema,\nnecrosis, shock" },
  ];

  steps.forEach((st, i) => {
    s.addShape(pres.shapes.RECTANGLE, {
      x: st.x, y: 0.95, w: 2.0, h: 2.1,
      fill: { color: C.teal },
      shadow: { type: "outer", color: "000000", blur: 8, offset: 3, angle: 135, opacity: 0.25 }
    });
    s.addText(st.label, { x: st.x, y: 1.05, w: 2.0, h: 0.75, fontSize: 12, bold: true, color: C.white, align: "center" });
    s.addShape(pres.shapes.RECTANGLE, { x: st.x + 0.1, y: 1.82, w: 1.8, h: 0.04, fill: { color: C.amber }, line: { color: C.amber } });
    s.addText(st.detail, { x: st.x, y: 1.9, w: 2.0, h: 0.85, fontSize: 9, color: C.sky, align: "center" });
    if (i < 3) {
      s.addText("→", { x: st.x + 2.05, y: 1.3, w: 0.4, h: 0.5, fontSize: 22, color: C.amber, align: "center" });
    }
  });

  const consequences = [
    "Local: oedema, haemorrhage, necrosis, pseudocyst",
    "Pulmonary: ARDS, pleural effusion (esp. left-sided, up to 50%)",
    "Renal: acute kidney injury from hypoperfusion + inflammatory mediators",
    "Cardiovascular: SIRS → septic shock, DIC",
    "Metabolic: hyperglycaemia (↓ insulin), hypocalcaemia (↓ albumin + Mg²⁺)",
  ];

  s.addText("SYSTEMIC CONSEQUENCES", { x: 0.3, y: 3.25, w: 5, h: 0.35, fontSize: 10, bold: true, color: C.amber, charSpacing: 2 });
  consequences.forEach((c, i) => {
    s.addText([
      { text: "▸  ", options: { color: C.sky, fontSize: 9.5 } },
      { text: c, options: { color: C.offwhite, fontSize: 9.5 } }
    ], { x: 0.3, y: 3.62 + i * 0.35, w: 9.4, h: 0.32 });
  });

  addFooter(s);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 5 — DIAGNOSIS & SEVERITY
// ═══════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: C.offwhite }, line: { color: C.offwhite } });
  addTopBar(s, "03  ·  Diagnosis & Severity Classification");

  // Diagnosis box
  s.addShape(pres.shapes.RECTANGLE, { x: 0.3, y: 0.85, w: 4.4, h: 2.2, fill: { color: C.navy } });
  s.addText("ATLANTA CRITERIA (≥2 of 3)", { x: 0.4, y: 0.9, w: 4.2, h: 0.4, fontSize: 10, bold: true, color: C.amber });
  const diag = [
    "① Epigastric pain characteristic of AP",
    "② Serum lipase or amylase ≥3× ULN",
    "③ Characteristic findings on CT / MRI",
  ];
  diag.forEach((d, i) => {
    s.addText(d, { x: 0.45, y: 1.38 + i * 0.5, w: 4.15, h: 0.42, fontSize: 10.5, color: C.white });
  });

  // Lipase note
  s.addShape(pres.shapes.RECTANGLE, { x: 0.3, y: 3.15, w: 4.4, h: 0.72, fill: { color: C.teal } });
  s.addText([
    { text: "Lipase", options: { bold: true, color: C.amber, fontSize: 10 } },
    { text: " preferred over amylase — more sensitive & specific.\nElevated for ", options: { color: C.white, fontSize: 9.5 } },
    { text: "1–2 weeks", options: { bold: true, color: C.amber, fontSize: 9.5 } },
    { text: " vs. 3–5 days. Degree does NOT correlate with severity.", options: { color: C.white, fontSize: 9.5 } },
  ], { x: 0.4, y: 3.18, w: 4.2, h: 0.68 });

  // Severity table
  s.addText("REVISED ATLANTA SEVERITY", { x: 4.9, y: 0.85, w: 4.8, h: 0.38, fontSize: 10, bold: true, color: C.teal, charSpacing: 2 });

  const rows = [
    { grade: "MILD", bg: "2E7D32", def: "No organ failure\nNo local/systemic complications", mort: "<1%" },
    { grade: "MOD. SEVERE", bg: "F57F17", def: "Transient organ failure (<48h)\nOR local complications", mort: "5–8%" },
    { grade: "SEVERE", bg: C.red, def: "Persistent organ failure (>48h)\nSingle or multi-organ", mort: "≤30%" },
  ];
  rows.forEach((r, i) => {
    const y = 1.32 + i * 1.2;
    s.addShape(pres.shapes.RECTANGLE, { x: 4.9, y, w: 1.55, h: 1.08, fill: { color: r.bg } });
    s.addText(r.grade, { x: 4.9, y, w: 1.55, h: 1.08, fontSize: 9.5, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    s.addShape(pres.shapes.RECTANGLE, { x: 6.48, y, w: 2.65, h: 1.08, fill: { color: C.lightbg } });
    s.addText(r.def, { x: 6.52, y, w: 2.58, h: 1.08, fontSize: 9, color: C.navy, valign: "middle" });
    s.addShape(pres.shapes.RECTANGLE, { x: 9.16, y, w: 0.74, h: 1.08, fill: { color: C.navy } });
    s.addText(r.mort, { x: 9.16, y, w: 0.74, h: 1.08, fontSize: 10, bold: true, color: C.amber, align: "center", valign: "middle", margin: 0 });
  });

  s.addText("Scoring: BISAP · Ranson's · APACHE II · CT Severity Index", {
    x: 4.9, y: 4.95, w: 4.8, h: 0.35, fontSize: 9, color: C.grey, italic: true
  });

  addFooter(s);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 6 — FLUID RESUSCITATION
// ═══════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: C.navy }, line: { color: C.navy } });
  addTopBar(s, "04  ·  Fluid Resuscitation  —  The Cornerstone of Early Management");

  const cards = [
    { x: 0.3,  y: 0.9,  w: 2.9, h: 1.35, bg: C.teal,  title: "FLUID OF CHOICE",     bullets: ["Lactated Ringer's (LR)", "Reduces SIRS vs. normal saline", "Avoid NS → hyperchloraemic acidosis"] },
    { x: 3.4,  y: 0.9,  w: 2.9, h: 1.35, bg: "1E5C6B", title: "RATE",                bullets: ["250–500 mL/hr initially", "Reassess every 6 hours", "Titrate to clinical response"] },
    { x: 6.5,  y: 0.9,  w: 3.2, h: 1.35, bg: "15404E", title: "TARGETS",             bullets: ["Urine output >0.5 mL/kg/hr", "Heart rate <100 bpm", "MAP >65 mmHg, ↓ BUN & Hct"] },
    { x: 0.3,  y: 2.42, w: 4.4, h: 1.4,  bg: "1D3557", title: "CAUTION: OVER-RESUSCITATION", bullets: ["Abdominal compartment syndrome", "Pulmonary oedema / ARDS", "Worsens outcomes — do not blindly push fluids", "Colloids have NO proven benefit"] },
    { x: 4.9,  y: 2.42, w: 4.8, h: 1.4,  bg: "1D3557", title: "MONITORING",          bullets: ["Continuous: vitals, urine output, SpO₂", "Serial labs: FBC, BMP, LFTs, CRP, procalcitonin", "Repeat fluid assessment every 6h", "Consider CVP / invasive monitoring in severe AP"] },
  ];

  cards.forEach(c => {
    addCard(s, c.x, c.y, c.w, c.h, c.bg, c.title, c.bullets, C.amber, C.sky);
  });

  s.addShape(pres.shapes.RECTANGLE, { x: 0.3, y: 4.02, w: 9.4, h: 0.72, fill: { color: C.red } });
  s.addText([
    { text: "⚠  KEY POINT:  ", options: { bold: true, fontSize: 11, color: C.white } },
    { text: "Aggressive early IV fluid resuscitation with Lactated Ringer's is the single most important intervention in acute pancreatitis.", options: { fontSize: 10.5, color: C.white } }
  ], { x: 0.45, y: 4.02, w: 9.1, h: 0.72, valign: "middle" });

  addFooter(s);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 7 — ANALGESIA & NUTRITION
// ═══════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: C.offwhite }, line: { color: C.offwhite } });
  addTopBar(s, "05  ·  Analgesia & Nutrition");

  // Left: Analgesia
  s.addShape(pres.shapes.RECTANGLE, { x: 0.3, y: 0.85, w: 4.4, h: 0.42, fill: { color: C.teal }, line: { color: C.teal } });
  s.addText("ANALGESIA", { x: 0.3, y: 0.85, w: 4.4, h: 0.42, fontSize: 11, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });

  const analg = [
    ["IV Opioids", "Morphine, hydromorphone, fentanyl — safe and effective"],
    ["Morphine myth", "Concern about sphincter of Oddi spasm is NOT supported by evidence — do not withhold"],
    ["NSAIDs", "Ketorolac as adjunct; rectal indomethacin may reduce post-ERCP pancreatitis"],
    ["Epidural", "Consider in severe AP — specialist setting"],
  ];
  analg.forEach(([title, desc], i) => {
    const y = 1.38 + i * 0.6;
    s.addShape(pres.shapes.RECTANGLE, { x: 0.3, y, w: 0.07, h: 0.38, fill: { color: C.sky }, line: { color: C.sky } });
    s.addText([
      { text: title + ":  ", options: { bold: true, color: C.navy, fontSize: 10 } },
      { text: desc, options: { color: C.grey, fontSize: 9.5 } }
    ], { x: 0.48, y, w: 4.18, h: 0.5 });
  });

  // Right: Nutrition
  s.addShape(pres.shapes.RECTANGLE, { x: 5.0, y: 0.85, w: 4.7, h: 0.42, fill: { color: C.navy }, line: { color: C.navy } });
  s.addText("NUTRITION", { x: 5.0, y: 0.85, w: 4.7, h: 0.42, fontSize: 11, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });

  s.addShape(pres.shapes.RECTANGLE, { x: 5.0, y: 1.35, w: 4.7, h: 1.55, fill: { color: C.lightbg } });
  s.addText("MILD AP", { x: 5.1, y: 1.38, w: 4.5, h: 0.35, fontSize: 10, bold: true, color: C.teal });
  const mildNutr = [
    "Early oral feeding as soon as tolerated (even within 24h)",
    "Soft / low-fat diet — no need to wait for enzyme normalisation",
    "Start clear liquids, advance as tolerated",
  ];
  mildNutr.forEach((t, i) => {
    s.addText([
      { text: "✓  ", options: { color: C.teal, fontSize: 9.5 } },
      { text: t, options: { color: C.grey, fontSize: 9.5 } }
    ], { x: 5.05, y: 1.76 + i * 0.36, w: 4.55, h: 0.33 });
  });

  s.addShape(pres.shapes.RECTANGLE, { x: 5.0, y: 3.0, w: 4.7, h: 2.0, fill: { color: C.navy } });
  s.addText("MODERATE / SEVERE AP", { x: 5.1, y: 3.04, w: 4.5, h: 0.35, fontSize: 10, bold: true, color: C.amber });
  const sevNutr = [
    "Enteral nutrition strongly preferred over TPN",
    "NG or NJ tube — both equally effective (NG easier to place)",
    "Start within 24–72 hours of admission",
    "Enteral nutrition: ↓ infection, ↓ bacterial translocation, ↓ complications, cheaper",
    "TPN only if enteral route contraindicated (ileus, fistula, obstruction)",
    "Never keep NPO beyond 24–48h in severe AP",
  ];
  sevNutr.forEach((t, i) => {
    s.addText([
      { text: "▸  ", options: { color: C.sky, fontSize: 9 } },
      { text: t, options: { color: C.offwhite, fontSize: 9 } }
    ], { x: 5.05, y: 3.42 + i * 0.3, w: 4.55, h: 0.28 });
  });

  addFooter(s);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 8 — ANTIBIOTIC POLICY
// ═══════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: C.offwhite }, line: { color: C.offwhite } });
  addTopBar(s, "06  ·  Antibiotic Policy");

  // BIG NO box
  s.addShape(pres.shapes.RECTANGLE, { x: 0.3, y: 0.85, w: 9.4, h: 1.05, fill: { color: C.red } });
  s.addText([
    { text: "✗  PROPHYLACTIC ANTIBIOTICS ARE NOT RECOMMENDED  ", options: { bold: true, fontSize: 14, color: C.white } },
    { text: "— even in sterile necrotising pancreatitis", options: { fontSize: 13, color: C.white } }
  ], { x: 0.4, y: 0.85, w: 9.2, h: 1.05, valign: "middle" });

  s.addText("Multiple RCTs and meta-analyses have consistently failed to show benefit of prophylactic antibiotics in preventing infected pancreatic necrosis.", {
    x: 0.3, y: 2.02, w: 9.4, h: 0.5, fontSize: 10, color: C.grey, italic: true
  });

  // When to USE
  s.addShape(pres.shapes.RECTANGLE, { x: 0.3, y: 2.65, w: 4.55, h: 0.42, fill: { color: "2E7D32" }, line: { color: "2E7D32" } });
  s.addText("ANTIBIOTICS ARE INDICATED WHEN:", { x: 0.3, y: 2.65, w: 4.55, h: 0.42, fontSize: 10, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });

  const indications = [
    "Infected pancreatic necrosis (confirmed or strongly suspected)",
    "  · Fever + leukocytosis + gas in necrosis on CT",
    "  · Or: positive FNA culture",
    "Concurrent acute cholangitis",
    "Other proven bacterial infection (pneumonia, UTI, line sepsis)",
  ];
  indications.forEach((ind, i) => {
    s.addText([
      { text: ind.startsWith("  ·") ? "" : "✓  ", options: { color: "2E7D32", fontSize: 9.5, bold: true } },
      { text: ind, options: { color: C.navy, fontSize: 9.5 } }
    ], { x: 0.3, y: 3.15 + i * 0.37, w: 4.55, h: 0.34 });
  });

  // Drug choice
  s.addShape(pres.shapes.RECTANGLE, { x: 5.15, y: 2.65, w: 4.55, h: 0.42, fill: { color: C.teal }, line: { color: C.teal } });
  s.addText("DRUG OF CHOICE (INFECTED NECROSIS):", { x: 5.15, y: 2.65, w: 4.55, h: 0.42, fontSize: 10, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });

  const drugs = [
    ["1st line", "Carbapenems (imipenem / meropenem)", "Excellent pancreatic penetration; broad spectrum"],
    ["2nd line", "Fluoroquinolone + metronidazole", "For penicillin-allergic patients"],
    ["Avoid", "Aminoglycosides", "Poor pancreatic penetration"],
  ];
  drugs.forEach(([tier, drug, note], i) => {
    const y = 3.15 + i * 0.65;
    s.addShape(pres.shapes.RECTANGLE, { x: 5.15, y, w: 0.9, h: 0.55, fill: { color: i === 0 ? C.teal : i === 1 ? "1D3557" : C.red } });
    s.addText(tier, { x: 5.15, y, w: 0.9, h: 0.55, fontSize: 9, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    s.addText([
      { text: drug + "\n", options: { bold: true, color: C.navy, fontSize: 9.5 } },
      { text: note, options: { color: C.grey, fontSize: 8.5 } }
    ], { x: 6.12, y, w: 3.5, h: 0.55 });
  });

  addFooter(s);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 9 — DISEASE-SPECIFIC MANAGEMENT & ERCP
// ═══════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: C.navy }, line: { color: C.navy } });
  addTopBar(s, "07  ·  Disease-Specific Management & ERCP");

  const panels = [
    {
      x: 0.3, y: 0.85, w: 4.55, h: 4.4, bg: C.teal, title: "GALLSTONE PANCREATITIS",
      items: [
        ["ERCP within 24–72h", "ONLY if concurrent cholangitis or persistent biliary obstruction — NOT routine in mild AP"],
        ["Gallstones pass spontaneously", "ERCP not needed without obstruction/cholangitis"],
        ["Cholecystectomy", "Perform during SAME admission (or ≤2 weeks) to prevent recurrence"],
        ["Recurrence risk", "~25–30% if cholecystectomy is delayed"],
        ["Prophylactic stent at ERCP", "Reduces post-ERCP pancreatitis risk in high-risk patients"],
        ["Rectal indomethacin", "Given peri-procedurally significantly reduces post-ERCP pancreatitis"],
      ]
    },
    {
      x: 5.15, y: 0.85, w: 4.55, h: 2.0, bg: "1A5276", title: "HYPERTRIGLYCERIDAEMIA-INDUCED (TG >1000 mg/dL)",
      items: [
        ["Insulin infusion", "Even in non-diabetics — activates lipoprotein lipase, rapidly lowers TG"],
        ["Plasmapheresis", "For refractory cases or TG >2000 mg/dL"],
        ["Long-term", "Fibrates, omega-3, strict dietary fat restriction"],
      ]
    },
    {
      x: 5.15, y: 3.05, w: 4.55, h: 2.2, bg: "1D3557", title: "ALCOHOL-INDUCED",
      items: [
        ["Alcohol cessation", "Mandatory — reduces risk of recurrence and progression to chronic pancreatitis"],
        ["Withdrawal monitoring", "Watch for DTs, Wernicke's encephalopathy — thiamine supplementation"],
        ["Counselling / referral", "Addiction services; relapse prevention"],
        ["Note", "Enzyme levels may be falsely normal (amylase) early in alcohol-induced AP — use lipase"],
      ]
    },
  ];

  panels.forEach(p => {
    s.addShape(pres.shapes.RECTANGLE, {
      x: p.x, y: p.y, w: p.w, h: p.h,
      fill: { color: p.bg },
      shadow: { type: "outer", color: "000000", blur: 6, offset: 2, angle: 135, opacity: 0.2 }
    });
    s.addText(p.title, { x: p.x + 0.12, y: p.y + 0.1, w: p.w - 0.24, h: 0.38, fontSize: 10, bold: true, color: C.amber });
    p.items.forEach(([k, v], i) => {
      s.addText([
        { text: k + ":  ", options: { bold: true, color: C.sky, fontSize: 9 } },
        { text: v, options: { color: C.white, fontSize: 9 } }
      ], { x: p.x + 0.12, y: p.y + 0.54 + i * 0.56, w: p.w - 0.24, h: 0.5 });
    });
  });

  addFooter(s);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 10 — COMPLICATIONS & INTERVENTIONS
// ═══════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: C.offwhite }, line: { color: C.offwhite } });
  addTopBar(s, "08  ·  Complications & Interventions");

  const comps = [
    {
      title: "PANCREATIC NECROSIS", color: C.navy,
      rows: [
        "Sterile necrosis → conservative management (supportive care)",
        "Infected necrosis → antibiotics + minimally invasive necrosectomy (step-up approach)",
        "Step-up: Percutaneous drainage → VARD → open surgery (last resort)",
        "Open necrosectomy mortality 30–40%; minimally invasive preferred",
        "Delay intervention until necrosis is 'walled-off' (≥3–4 weeks)",
      ]
    },
    {
      title: "PANCREATIC PSEUDOCYST", color: C.teal,
      rows: [
        "Most resolve spontaneously — observe",
        "Drainage if: symptomatic, growing, infected, causing obstruction",
        "Preferred: EUS-guided cyst-gastrostomy or cyst-duodenostomy",
        "Avoid premature drainage before maturation",
      ]
    },
    {
      title: "ABDOMINAL COMPARTMENT SYNDROME", color: "7B1FA2",
      rows: [
        "Monitor intra-abdominal pressure (IAP >20 mmHg + new organ failure)",
        "Reduce fluids, neuromuscular blockade, nasogastric decompression",
        "Percutaneous drainage of ascites",
        "Surgical decompression if refractory",
      ]
    },
    {
      title: "ORGAN FAILURE MANAGEMENT", color: C.red,
      rows: [
        "Pulmonary: O₂ therapy, CPAP/BiPAP, mechanical ventilation for ARDS",
        "Renal: renal replacement therapy (haemodialysis/haemofiltration)",
        "Cardiovascular: vasopressors (noradrenaline), inotropes for shock",
        "DIC: fresh frozen plasma, platelets as needed",
      ]
    },
  ];

  const positions = [
    { x: 0.3, y: 0.85, w: 4.55 },
    { x: 5.15, y: 0.85, w: 4.55 },
    { x: 0.3, y: 3.1, w: 4.55 },
    { x: 5.15, y: 3.1, w: 4.55 },
  ];

  comps.forEach((comp, idx) => {
    const pos = positions[idx];
    const h = 2.1;
    s.addShape(pres.shapes.RECTANGLE, {
      x: pos.x, y: pos.y, w: pos.w, h,
      fill: { color: comp.color },
      shadow: { type: "outer", color: "000000", blur: 5, offset: 2, angle: 135, opacity: 0.13 }
    });
    s.addText(comp.title, { x: pos.x + 0.12, y: pos.y + 0.08, w: pos.w - 0.24, h: 0.38, fontSize: 9.5, bold: true, color: C.amber });
    comp.rows.forEach((row, i) => {
      s.addText([
        { text: "▸  ", options: { color: C.sky, fontSize: 9 } },
        { text: row, options: { color: C.white, fontSize: 9 } }
      ], { x: pos.x + 0.12, y: pos.y + 0.5 + i * 0.32, w: pos.w - 0.24, h: 0.29 });
    });
  });

  addFooter(s);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 11 — MANAGEMENT ALGORITHM
// ═══════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: C.navy }, line: { color: C.navy } });
  addTopBar(s, "09  ·  Management Algorithm");

  // Flow chart
  const nodes = [
    { x: 3.5, y: 0.82, w: 3.0, h: 0.65, bg: C.amber, text: "DIAGNOSIS CONFIRMED\n(≥2 Atlanta Criteria)", textColor: C.navy },
    { x: 3.5, y: 1.72, w: 3.0, h: 0.65, bg: C.teal, text: "IV LR + Analgesia\nNPO initially", textColor: C.white },
    { x: 3.5, y: 2.62, w: 3.0, h: 0.65, bg: "1D3557", text: "Assess Severity\n(BISAP / APACHE II)", textColor: C.white },
  ];

  nodes.forEach(n => {
    s.addShape(pres.shapes.RECTANGLE, { x: n.x, y: n.y, w: n.w, h: n.h, fill: { color: n.bg } });
    s.addText(n.text, { x: n.x, y: n.y, w: n.w, h: n.h, fontSize: 9.5, bold: true, color: n.textColor, align: "center", valign: "middle", margin: 0 });
    // arrow down
    s.addShape(pres.shapes.RECTANGLE, { x: 4.9, y: n.y + n.h, w: 0.2, h: 0.45, fill: { color: C.sky }, line: { color: C.sky } });
  });

  // Branch
  s.addText("↙", { x: 2.8, y: 3.45, w: 1.0, h: 0.5, fontSize: 28, color: C.sky, align: "center" });
  s.addText("↘", { x: 6.2, y: 3.45, w: 1.0, h: 0.5, fontSize: 28, color: C.sky, align: "center" });

  s.addShape(pres.shapes.RECTANGLE, { x: 0.3, y: 3.88, w: 4.0, h: 1.45, fill: { color: "2E7D32" } });
  s.addText("MILD", { x: 0.3, y: 3.88, w: 4.0, h: 0.38, fontSize: 11, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
  const mild = ["Early oral feeding", "Cholecystectomy same admission (if gallstone AP)", "Discharge when tolerating diet + pain controlled"];
  mild.forEach((t, i) => {
    s.addText([{ text: "✓  ", options: { color: C.amber, fontSize: 9 } }, { text: t, options: { color: C.white, fontSize: 9 } }],
      { x: 0.4, y: 4.3 + i * 0.33, w: 3.8, h: 0.3 });
  });

  s.addShape(pres.shapes.RECTANGLE, { x: 5.7, y: 3.88, w: 4.0, h: 1.45, fill: { color: C.red } });
  s.addText("MODERATE / SEVERE", { x: 5.7, y: 3.88, w: 4.0, h: 0.38, fontSize: 10.5, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
  const sev = ["ICU admission", "Enteral nutrition within 24–72h", "Antibiotics ONLY for infected necrosis / cholangitis", "Step-up approach for necrosis if needed"];
  sev.forEach((t, i) => {
    s.addText([{ text: "▸  ", options: { color: C.amber, fontSize: 9 } }, { text: t, options: { color: C.white, fontSize: 9 } }],
      { x: 5.8, y: 4.3 + i * 0.33, w: 3.8, h: 0.3 });
  });

  addFooter(s);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 12 — KEY TAKEAWAYS
// ═══════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: C.navy }, line: { color: C.navy } });
  // Accent
  s.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0, w: 0.25, h: 5.625, fill: { color: C.amber }, line: { color: C.amber } });
  s.addShape(pres.shapes.RECTANGLE, { x: 0, y: 5.35, w: 10, h: 0.275, fill: { color: C.teal }, line: { color: C.teal } });

  s.addText("KEY TAKEAWAYS", { x: 0.5, y: 0.25, w: 9, h: 0.65, fontSize: 22, bold: true, color: C.amber, charSpacing: 4 });
  s.addShape(pres.shapes.RECTANGLE, { x: 0.5, y: 0.95, w: 5, h: 0.05, fill: { color: C.sky }, line: { color: C.sky } });

  const takeaways = [
    ["Fluid", "Lactated Ringer's is fluid of choice; aggressive early resuscitation is the most critical intervention"],
    ["Analgesia", "IV opioids are safe; the morphine/sphincter of Oddi concern is a myth"],
    ["Feeding", "Early oral feeding in mild AP; enteral (NG/NJ) nutrition within 24–72h in severe AP — never prolonged NPO"],
    ["No prophylactic ABx", "Antibiotics only for infected necrosis or concurrent cholangitis — RCTs show no benefit prophylactically"],
    ["ERCP", "Only for gallstone AP with cholangitis or persistent biliary obstruction — not routine"],
    ["Cholecystectomy", "Same admission or within 2 weeks after gallstone AP to prevent ~30% recurrence"],
    ["Necrosectomy", "Step-up approach; delay ≥4 weeks until 'walled-off'; minimally invasive preferred"],
    ["Severity", "Persistent organ failure (>48h) = severe AP; mortality up to 30%"],
  ];

  takeaways.forEach(([key, val], i) => {
    const y = 1.1 + i * 0.53;
    s.addShape(pres.shapes.RECTANGLE, { x: 0.5, y, w: 1.4, h: 0.42, fill: { color: i % 2 === 0 ? C.teal : C.sky } });
    s.addText(key, { x: 0.5, y, w: 1.4, h: 0.42, fontSize: 9, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    s.addText(val, { x: 2.05, y, w: 7.7, h: 0.42, fontSize: 9.5, color: C.offwhite, valign: "middle" });
  });
}

// ═══════════════════════════════════════════════════════════════════════════════
// WRITE FILE
// ═══════════════════════════════════════════════════════════════════════════════
pres.writeFile({ fileName: "/home/daytona/workspace/acute-pancreatitis-ppt/Acute_Pancreatitis_Management.pptx" })
  .then(() => console.log("✅ Presentation saved successfully."))
  .catch(err => console.error("❌ Error:", err));
Running Command

cd /home/daytona/workspace/acute-pancreatitis-ppt && node create_ppt.js

The error is on line 72 - the addTopBar function uses pres.shapes.RECTANGLE but the pres object might not be scoped correctly. The issue is that pres.shapes is accessed inside a function before pres is in scope. Let me check and fix.
Running Command

node -e "const pptxgen = require('pptxgenjs'); const pres = new pptxgen(); console.log(Object.keys(pres.shapes).slice(0,5)); console.log(pres.ShapeType ? 'ShapeType exists' : 'no ShapeType');"

Running Command

node -e "const pptxgen = require('pptxgenjs'); const pres = new pptxgen(); console.log('RECTANGLE:', pres.shapes.RECTANGLE); console.log('ELLIPSE:', pres.shapes.ELLIPSE);"

ELLIPSE is undefined. Let me find the correct shape name and fix the script.
Running Command

node -e "const pptxgen = require('pptxgenjs'); const pres = new pptxgen(); const shapes = Object.keys(pres.shapes); const ellipses = shapes.filter(s => s.toLowerCase().includes('ellip') || s.toLowerCase().includes('oval') || s.toLowerCase().includes('circle')); console.log(ellipses);"

The shape is OVAL not ELLIPSE. Let me fix all occurrences in the script.
Editing File

~/acute-pancreatitis-ppt/create_ppt.js

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/acute-pancreatitis-ppt/create_ppt.js'
Running Command

cd /home/daytona/workspace/acute-pancreatitis-ppt && node create_ppt.js

Running Command

ls -lh /home/daytona/workspace/acute-pancreatitis-ppt/Acute_Pancreatitis_Management.pptx

Your presentation is ready! Download it here:

Acute Pancreatitis Management

Presentation · PPTX


What's inside (12 slides):
#SlideContent
1TitleDark navy/teal design with source citations
2Overview / Agenda10-topic outline with numbered visual tiles
3Epidemiology & AetiologyStats cards (gallstones 40-70%, alcohol 25-35%, mortality ≤30%) + causes list
4PathophysiologyDark theme flow: Inciting Event → Acinar Injury → Trypsinogen → Autodigestion/SIRS + systemic consequences
5Diagnosis & SeverityAtlanta criteria, lipase vs. amylase, Revised Atlanta severity table (Mild/Mod-Severe/Severe) with mortality
6Fluid ResuscitationLR preference, rates, targets, caution against over-resuscitation - with red warning bar
7Analgesia & NutritionOpioid myth busted; mild AP (early oral) vs. severe AP (enteral NG/NJ within 72h)
8Antibiotic PolicyBold red "NO prophylactic antibiotics" bar + clear indications + drug choice (carbapenems)
9Disease-Specific & ERCPGallstones (ERCP criteria, same-admission cholecystectomy), hypertriglyceridaemia, alcohol
10ComplicationsNecrosis step-up, pseudocyst drainage, abdominal compartment syndrome, organ failure
11Management AlgorithmVisual flowchart: Diagnosis → Fluids → Severity → Mild vs. Severe pathways
12Key Takeaways8 colour-coded points for rapid review
Design: Navy/teal/amber medical colour scheme with dark title/conclusion slides and light content slides, consistent headers, footers, and shadow cards throughout.
This is a shared conversation. Sign in to Orris to start your own chat.