Management diagnosis and treatment of acute pancreatitis and acute pancrea With complication

Reading File
Finding Sources
Searching PubMed

"acute pancreatitis"[MeSH Terms] AND management

Reading File
Reading File
Searching PubMed

"acute pancreatitis" AND treatment

Reading File
Reading File
Reading File
Finding Sources
Reading File
Finding Sources
Reading File
Reading File
Reading File
Reading File
Reading File
Loading Image
Loading Image
I now have comprehensive information from multiple authoritative sources. Let me compose the full answer.

Acute Pancreatitis: Diagnosis, Management, and Complications

Sources: Rosen's Emergency Medicine 9e, Sleisenger & Fordtran's GI and Liver Disease, Sabiston Textbook of Surgery, Maingot's Abdominal Operations

1. Definition and Pathophysiology

Acute pancreatitis (AP) is an inflammatory condition causing enzymatic autodigestion and destruction of pancreatic tissue. It ranges from mild, self-limited disease to sepsis and multi-organ failure. AP is the most common pancreatic disease worldwide and a top cause of GI-related hospitalization. Mortality can reach 30% in severe necrotizing cases.
The core mechanism involves premature activation of trypsinogen within acinar cells, triggering a cascade that activates phospholipases, elastases, and other enzymes - leading to local tissue destruction and a systemic inflammatory response (SIRS).

2. Etiology

CategoryExamples
Most CommonGallstones (40-70%), Alcohol (25-35%)
Toxic-MetabolicHypertriglyceridemia (TG >1000 mg/dL), hypercalcemia, uremia, drugs, scorpion venom
Mechanical-ObstructivePost-ERCP, trauma, pancreas divisum, ampullary/pancreatic tumors
InfectiousMumps, coxsackievirus, CMV, EBV, HIV, Salmonella, Mycoplasma, Ascaris
AutoimmuneIgG4-related (Type 1 autoimmune pancreatitis)
IdiopathicUp to ~20% (many from occult microlithiasis)
Smoking and diabetes are independent risk factors.

3. Clinical Presentation

Symptoms:
  • Persistent, moderate-to-severe epigastric or LUQ pain radiating to the back, chest, or flanks
  • Pain eased by sitting forward or bending
  • Nausea, vomiting, anorexia
  • Oral intake worsens pain
Signs:
  • Tachycardia, fever, tachypnea (reflect SIRS)
  • Hypotension/shock in severe cases
  • Epigastric tenderness with or without guarding
  • Jaundice suggests obstructive etiology (gallstone)
  • Cullen sign (periumbilical ecchymosis) and Grey Turner sign (flank ecchymosis) - rare, indicate retroperitoneal hemorrhage and poor prognosis
  • Absent/diminished bowel sounds if ileus present
  • Pleural effusion (left-sided more common, up to 50% of severe cases)

4. Diagnosis

Diagnostic Criteria (2 of 3 required):
  1. Characteristic abdominal pain
  2. Serum lipase or amylase ≥3x upper limit of normal
  3. Characteristic findings on cross-sectional imaging
Laboratory Tests:
  • Lipase - more specific and sensitive than amylase; preferred
  • Amylase - rises earlier, clears faster; less specific
  • CBC (leukocytosis), BUN, creatinine, LFTs (ALT >3x ULN suggests gallstone etiology)
  • CRP (most useful at 24-48 h for severity); Procalcitonin (early predictor of severity)
  • Hematocrit (hemoconcentration = risk for necrosis); BUN (elevated = poor prognosis)
  • Serum triglycerides, calcium
  • Blood glucose
Imaging:
  • Ultrasound - first-line to assess for gallstones/biliary dilation; limited for direct pancreatic visualization (obscured by bowel gas)
  • CT with IV contrast - NOT routine; indicated only for:
    1. Diagnostic uncertainty or normal enzyme levels with high suspicion
    2. Rule out other intra-abdominal pathology
    3. Assess for complications in patients not improving after 48-72 hours
    • Best done 3-7 days after onset (necrosis may not be apparent earlier)
    • Sensitivity/specificity >90% for diagnosis
    • Pancreatic necrosis: areas of non-enhancement (<40-50 HU vs. normal 100-150 HU)
  • MRI/MRCP - equivalent to CT; superior for gallbladder/biliary tract; preferred when contrast contraindicated; also evaluates pancreatic duct integrity
  • EUS/MRCP - evaluate bile duct stones before ERCP
CT of Acute Interstitial Pancreatitis (peripancreatic fat stranding, arrows):
CT - Acute Interstitial Pancreatitis
CT of Necrotizing Pancreatitis (decreased enhancement where parenchyma replaced by necrotic fluid, arrow):
CT - Necrotizing Pancreatitis

5. Severity Classification (Revised 2012 Atlanta)

GradeCriteria
MildNo organ failure; no local or systemic complications
Moderately SevereTransient organ failure (<48h); local or systemic complications
SeverePersistent organ failure (>48h); local complications
Organ failure is defined by a modified Marshall score ≥2 for respiratory, cardiovascular, or renal systems.

6. Severity Scoring Systems

ScoreVariablesHigh-Risk Threshold
Ranson Criteria11 variables at admission + 48h (age, WBC, glucose, LDH, AST; BUN, fluid deficit, hematocrit drop, calcium, PaO2, base deficit)≥3 signs = severe
APACHE II15 physiological variables (ICU-based, can be used early)≥8 = severe
BISAPBUN >25, Impaired mental status, SIRS, Age >60, Pleural effusion≥3 = high risk
Modified CTSIPancreatic inflammation + necrosis on CT≥4 = high risk
HAPSPeritonitis + creatinine + hematocrit97% specific for mild disease (not sensitive)
CRP>150 mg/L at 48 hIndicates severe AP

7. Management

7.1 General Supportive Care (All Patients)

A. Fluid Resuscitation (most important)
  • Patients are volume-depleted due to decreased oral intake, vomiting, and third-spacing from inflammation
  • Goal-directed therapy:
    • Heart rate <120/min
    • Mean arterial pressure 65-85 mmHg
    • Urine output >0.5-1 mL/kg/h
  • IAP/APA recommendation: 5-10 mL/kg/h; ACG: 250-500 mL/h
  • Preferred fluid: Lactated Ringer's (LR) over normal saline - LR has anti-inflammatory properties and avoids hyperchloremic acidosis that worsens SIRS and activates trypsinogen
  • Monitor: hematocrit, BUN, creatinine as surrogate markers
  • Colloids not routinely recommended; may help if Hct <24 or albumin <2 g/dL
B. Pain Management
  • IV opioid analgesia (morphine, hydromorphone); pethidine/meperidine no longer preferred
  • Patient-controlled analgesia (PCA) for severe pain
C. Oral Intake / Nutrition
  • Mild AP: Advance to oral diet as tolerated - do NOT enforce NPO; early oral feeding when tolerated improves outcomes
  • Severe AP / inability to tolerate orally:
    • Enteral nutrition preferred over parenteral (reduces infectious complications, costs)
    • Nasogastric (NG) feeding is as effective as nasojejunal for most patients; nasojejunal preferred if intolerant due to severe duodenal edema
    • Endoscopic nasojejunal tube placement is feasible
    • Parenteral nutrition (TPN) only if enteral route not possible
D. Anti-emetics and analgesia adjuncts
  • Ondansetron, metoclopramide for nausea/vomiting
E. Monitoring
  • Urine output, vital signs, electrolytes (correct hypocalcemia, hypomagnesemia, hyperglycemia)
  • Oxygen saturation; supplemental O2 if hypoxic
  • ICU admission for severe disease or organ failure

7.2 Antibiotics

  • NOT indicated prophylactically in sterile AP (no benefit shown, increases resistant organisms)
  • Indicated when:
    • Infected pancreatic necrosis confirmed or strongly suspected
    • Concurrent cholangitis
  • Agents that penetrate pancreatic necrosis:
    • Carbapenems (first-line) - imipenem, meropenem
    • Quinolones (ciprofloxacin) + metronidazole
    • Third-generation cephalosporins
    • Piperacillin-tazobactam

7.3 Endoscopic and Surgical Interventions

ERCP:
  • NOT routinely indicated in AP
  • Indicated in:
    1. Acute cholangitis + gallstone pancreatitis - urgent ERCP within 24-48h
    2. Biliary obstruction (hyperbilirubinemia + clinical cholangitis) - ERCP within 72h
    3. NOT recommended for uncomplicated biliary pancreatitis without obstruction (meta-analyses show no mortality benefit)
Cholecystectomy:
  • Early laparoscopic cholecystectomy within 3 days in mild biliary pancreatitis (without waiting for enzyme normalization) - reduces need for subsequent ERCP and improves outcomes
  • Standard of care for gallstone AP before discharge (or same admission)
  • If poor surgical candidate: ERCP + biliary sphincterotomy reduces recurrent AP risk

8. Complications

8.1 Classification of Local Fluid Collections (Atlanta 2012)

Subtype<4 Weeks>4 Weeks
Interstitial EdematousAcute Peripancreatic Fluid Collection (APFC) - no wall, homogeneousPseudocyst - encapsulated, homogeneous, well-defined wall, no solid debris
NecrotizingAcute Necrotic Collection (ANC) - heterogeneous, no wall, intra/extra-pancreaticWalled-Off Necrosis (WON) - mixed liquid/solid, encapsulated

8.2 Necrotizing Pancreatitis

  • Occurs in 5-10% of AP cases
  • Involves nonviable pancreatic parenchyma +/- peripancreatic fat
  • CT: non-enhancing areas (<40-50 HU on contrast-enhanced CT)
  • Risk of infection correlates with extent of necrosis:
    • <30% gland affected: 22% risk
    • 30-50% affected: 37% risk
    • 70% affected: 46% risk
  • Causative organisms: gram-negative rods (E. coli, Klebsiella, Pseudomonas), Enterococcus (bacterial translocation from gut)
Diagnosis of infected necrosis:
  • Gas within necrosis on CT (pathognomonic when not instrumented)
  • FNA: positive Gram stain/culture
  • Suspect if: prolonged fever, leukocytosis, sepsis/organ failure >7 days after onset, or clinical deterioration after 10-14 days
Management of pancreatic necrosis:
  • Sterile necrosis: Conservative - only intervene if persistent pain, failure to improve, or biliary/enteric obstruction. Delay intervention to allow WON formation.
  • Infected necrosis: Requires intervention
    • IV antibiotics (carbapenems first-line)
    • Step-up approach preferred over immediate open surgery:
      1. Percutaneous/endoscopic drainage (first step)
      2. Minimally invasive necrosectomy (video-assisted retroperitoneal debridement - VARD, endoscopic transluminal necrosectomy)
      3. Open surgical necrosectomy (last resort) - historically high mortality; still used when minimally invasive fails

8.3 Pseudocyst

  • Requires ≥4 weeks to encapsulate after AP
  • Round/oval, well-defined wall, no solid debris (if solid debris = WON, not pseudocyst)
  • Most acute peripancreatic fluid collections (APFCs) resolve spontaneously
  • Indications for drainage:
    • Symptomatic (pain, early satiety, nausea)
    • Infected
    • Enlarging or causing obstruction
  • Drainage options:
    • Endoscopic ultrasound-guided transmural drainage (preferred if adjacent to stomach/duodenum)
    • Percutaneous CT-guided drainage
    • Surgical cystenterostomy (for pseudocysts not amenable to above)

8.4 Systemic Complications

SystemComplication
PulmonaryARDS, pleural effusion (left > right), atelectasis, hypoxemia
CardiovascularHypovolemic shock, decreased MAP, need for vasopressors
RenalAcute kidney injury from hypoperfusion + inflammatory mediators
HematologicDIC, coagulopathy from cytokine-mediated coagulation activation
MetabolicHypocalcemia, hyperglycemia, hypomagnesemia

8.5 Vascular Complications

  • Splenic/portal vein thrombosis - can cause left-sided portal hypertension
  • Pseudoaneurysm (splenic artery most common) - risk of massive hemorrhage; treat with angioembolization

8.6 GI Complications

  • Bowel necrosis (rare, very high mortality)
  • Gastric outlet obstruction (from peripancreatic inflammation/pseudocyst)
  • GI hemorrhage (from pseudoaneurysm, or erosion into adjacent bowel)

9. Prognosis and Disposition

  • Mild AP: >80% of cases; usually resolves in 3-5 days; can be discharged when tolerating oral intake with controlled pain
  • Moderately severe to severe AP: ICU admission; mortality 15-30% in severe necrotizing disease
  • Poor prognostic indicators: hemoconcentration (Hct >44%), BUN >20 mg/dL on admission, rising creatinine, BISAP ≥3, APACHE II ≥8, CRP >150 at 48h, SIRS persisting >48h

10. Recurrence Prevention

  • Gallstone AP: Cholecystectomy (same admission or within 2-4 weeks) is mandatory to prevent recurrence
  • Alcoholic AP: Strict alcohol cessation; counseling and rehabilitation
  • Hypertriglyceridemia: Fibrates, omega-3 FA, dietary fat restriction
  • Drug-induced: Identify and discontinue causative drug

Key Recent Literature:
Sources: Rosen's Emergency Medicine 9e, Ch. 77; Sabiston Textbook of Surgery; Sleisenger & Fordtran's GI & Liver Disease; Clinical Gastrointestinal Endoscopy 3e

Make me a presentation for the same topic for postgraduate surgery class

Reading File
Reading File
Reading File
Running Command

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

Writing File

~/acute-pancreatitis-ppt/generate.js

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

// ─── FETCH CT IMAGES ─────────────────────────────────────────────────────────
const imageUrls = [
  "https://cdn.orris.care/cdss_images/71be8116952f4d991641f237070e79b366b32835ffda114a398f928ab2d21c7f.png",
  "https://cdn.orris.care/cdss_images/55abdf6ea09afed1952f58c769ebc07ad2b964eb2638ea5ab95ac3a7056e562e.png",
  "https://cdn.orris.care/cdss_images/8700248dc005de4b6b9987e569c05b4e3ca4becd7c6abbf612b9022114650015.png"
];
let imgs = [];
try {
  const raw = execSync(
    `node /home/daytona/skills/shared/scripts/fetch_images.js ${imageUrls.map(u => `"${u}"`).join(" ")}`
  ).toString();
  imgs = JSON.parse(raw);
} catch(e) {
  imgs = imageUrls.map(() => ({ base64: null, error: e.message }));
}

// ─── PALETTE ─────────────────────────────────────────────────────────────────
const C = {
  navy:    "0D2B55",   // dominant dark background
  blue:    "1A4A8A",   // section headers
  teal:    "0E7C86",   // accents / highlights
  orange:  "E8630A",   // hot accent (warning/severe)
  cream:   "F5F0E8",   // body bg
  white:   "FFFFFF",
  ltBlue:  "D6E4F0",   // table header
  ltGrey:  "EEF2F6",
  text:    "1C2B3A",
  subtext: "4A6077",
  red:     "C0392B",
  green:   "1E8449",
};

const pres = new pptxgen();
pres.layout = "LAYOUT_16x9";
pres.title = "Acute Pancreatitis – Diagnosis, Management & Complications";
pres.author = "Postgraduate Surgery";

// ─── HELPER FUNCTIONS ────────────────────────────────────────────────────────
function darkSlide(slide) {
  slide.addShape(pres.shapes.RECTANGLE, { x:0, y:0, w:10, h:5.625, fill:{ color: C.navy } });
}
function lightSlide(slide) {
  slide.addShape(pres.shapes.RECTANGLE, { x:0, y:0, w:10, h:5.625, fill:{ color: C.cream } });
  // top accent bar
  slide.addShape(pres.shapes.RECTANGLE, { x:0, y:0, w:10, h:0.07, fill:{ color: C.teal } });
}
function sectionHeader(slide, title, subtitle) {
  darkSlide(slide);
  slide.addShape(pres.shapes.RECTANGLE, { x:0, y:2.2, w:10, h:0.06, fill:{ color: C.teal } });
  slide.addText(title, { x:0.6, y:1.4, w:8.8, h:0.8, fontSize:38, bold:true, color:C.white, fontFace:"Calibri" });
  if (subtitle) slide.addText(subtitle, { x:0.6, y:2.35, w:8.8, h:0.5, fontSize:18, color:C.ltBlue, fontFace:"Calibri" });
}
function slideTitle(slide, title) {
  slide.addShape(pres.shapes.RECTANGLE, { x:0, y:0, w:10, h:0.72, fill:{ color: C.blue } });
  slide.addText(title, { x:0.3, y:0, w:9.4, h:0.72, fontSize:22, bold:true, color:C.white, fontFace:"Calibri", valign:"middle", margin:0 });
}
function bulletBox(slide, items, opts) {
  const defaults = { x:0.35, y:0.85, w:9.3, h:4.5, fontSize:15, color:C.text, fontFace:"Calibri" };
  const o = Object.assign({}, defaults, opts);
  const richText = items.map((item, i) => {
    if (typeof item === "string") {
      return { text: item, options: { bullet: { type:"bullet", code:"25B6", color: C.teal }, color: C.text, fontSize: o.fontSize, breakLine: i < items.length-1 } };
    } else {
      // { text, sub: true } for sub-bullets
      return { text: item.text, options: { bullet: { type:"bullet", code:"25AA", color: C.subtext, indent: 20 }, color: C.subtext, fontSize: o.fontSize - 1.5, breakLine: i < items.length-1 } };
    }
  });
  slide.addText(richText, { x:o.x, y:o.y, w:o.w, h:o.h, fontFace:o.fontFace });
}
function tag(slide, label, color, x, y, w) {
  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, { x, y, w: w||1.6, h:0.32, fill:{ color }, rectRadius:0.05 });
  slide.addText(label, { x, y, w: w||1.6, h:0.32, fontSize:11, bold:true, color:C.white, align:"center", valign:"middle", margin:0 });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 1 – TITLE SLIDE
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  darkSlide(s);
  // left teal bar
  s.addShape(pres.shapes.RECTANGLE, { x:0, y:0, w:0.12, h:5.625, fill:{ color: C.teal } });
  // orange accent strip
  s.addShape(pres.shapes.RECTANGLE, { x:0.12, y:3.55, w:9.88, h:0.06, fill:{ color: C.orange } });

  s.addText("ACUTE PANCREATITIS", {
    x:0.45, y:0.9, w:9.1, h:1.1, fontSize:46, bold:true, color:C.white,
    fontFace:"Calibri", charSpacing:3
  });
  s.addText("Diagnosis · Management · Complications", {
    x:0.45, y:2.05, w:9.1, h:0.55, fontSize:22, color:C.ltBlue, fontFace:"Calibri", italic:true
  });
  s.addText("Postgraduate Surgery — Grand Rounds", {
    x:0.45, y:3.7, w:9.1, h:0.35, fontSize:14, color:C.teal, fontFace:"Calibri", bold:true
  });
  s.addText("Sources: Rosen's Emergency Medicine 9e · Sleisenger & Fordtran · Sabiston Surgery", {
    x:0.45, y:4.9, w:9.1, h:0.35, fontSize:10, color:"6A8BA4", fontFace:"Calibri"
  });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 2 – OVERVIEW / LEARNING OBJECTIVES
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  lightSlide(s);
  slideTitle(s, "Learning Objectives");
  bulletBox(s, [
    "Define acute pancreatitis and understand its pathophysiology",
    "Identify common etiologies and risk factors",
    "Apply 2012 Revised Atlanta Classification for disease severity",
    "Interpret diagnostic workup: labs, imaging, and scoring systems",
    "Formulate evidence-based management: fluids, nutrition, ERCP, surgery",
    "Recognize and manage local and systemic complications",
    "Understand step-up approach to infected necrotizing pancreatitis"
  ], { y:0.9, fontSize:16 });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 3 – SECTION: FUNDAMENTALS
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  sectionHeader(s, "Section 1: Fundamentals", "Definition · Epidemiology · Pathophysiology");
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 4 – DEFINITION & EPIDEMIOLOGY
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  lightSlide(s);
  slideTitle(s, "Definition & Epidemiology");

  // Left column
  s.addShape(pres.shapes.RECTANGLE, { x:0.3, y:0.9, w:4.5, h:4.4, fill:{ color: C.white }, shadow:{ type:"outer", color:"000000", blur:8, offset:2, angle:135, opacity:0.1 } });
  s.addText("DEFINITION", { x:0.3, y:0.9, w:4.5, h:0.42, fontSize:13, bold:true, color:C.white, align:"center", valign:"middle", fill:{ color: C.blue }, margin:0 });
  bulletBox(s, [
    "Inflammatory condition → enzymatic autodigestion of pancreatic tissue",
    "Spectrum: mild self-limited → severe necrotizing with MOF",
    "#1 most common pancreatic disease worldwide",
    "Leading GI cause of hospitalization in USA",
    "Overall mortality ~3–5%; severe cases up to 30%",
    "Recurrent AP can evolve to chronic pancreatitis"
  ], { x:0.4, y:1.35, w:4.3, h:3.7, fontSize:13.5 });

  // Right column
  s.addShape(pres.shapes.RECTANGLE, { x:5.2, y:0.9, w:4.5, h:4.4, fill:{ color: C.white }, shadow:{ type:"outer", color:"000000", blur:8, offset:2, angle:135, opacity:0.1 } });
  s.addText("PATHOPHYSIOLOGY", { x:5.2, y:0.9, w:4.5, h:0.42, fontSize:13, bold:true, color:C.white, align:"center", valign:"middle", fill:{ color: C.teal }, margin:0 });
  bulletBox(s, [
    "Premature trypsinogen activation inside acinar cells",
    "Activates phospholipases, elastase, kallikrein cascade",
    "Local: fat necrosis, vascular injury, haemorrhage",
    "Systemic: SIRS → cytokine storm → MOF",
    "Increased microvascular permeability → third-spacing",
    "Bacterial translocation from ischaemic gut → infected necrosis"
  ], { x:5.3, y:1.35, w:4.3, h:3.7, fontSize:13.5 });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 5 – ETIOLOGY
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  lightSlide(s);
  slideTitle(s, "Etiology");

  const causes = [
    { cat:"Gallstones", pct:"40–70%", color: C.orange },
    { cat:"Alcohol", pct:"25–35%", color: C.blue },
    { cat:"Hypertriglyceridaemia\n(TG >1000 mg/dL)", pct:"~4%", color: C.teal },
    { cat:"Post-ERCP", pct:"~3%", color:"7D3C98" },
    { cat:"Medications", pct:"~2%", color:"1E8449" },
    { cat:"Idiopathic / Other", pct:"~15%", color:"707070" },
  ];
  const cols = [0.3, 3.45, 6.6];
  const rows = [0.88, 2.8];
  causes.forEach((c, i) => {
    const col = cols[i % 3];
    const row = rows[Math.floor(i / 3)];
    s.addShape(pres.shapes.RECTANGLE, { x:col, y:row, w:2.9, h:1.7, fill:{ color: c.color } });
    s.addText(c.pct, { x:col, y:row+0.1, w:2.9, h:0.6, fontSize:26, bold:true, color:C.white, align:"center", valign:"middle", margin:0 });
    s.addText(c.cat, { x:col, y:row+0.7, w:2.9, h:0.9, fontSize:13, color:C.white, align:"center", valign:"middle", margin:0 });
  });

  s.addText("Other causes: Hypercalcaemia • Trauma • Pancreas divisum • Autoimmune • Infections (mumps, EBV) • Hereditary • Scorpion venom", {
    x:0.3, y:4.7, w:9.4, h:0.55, fontSize:11.5, color:C.subtext, fontFace:"Calibri", italic:true
  });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 6 – SECTION: DIAGNOSIS
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  sectionHeader(s, "Section 2: Clinical Features & Diagnosis", "Presentation · Labs · Imaging");
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 7 – CLINICAL FEATURES
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  lightSlide(s);
  slideTitle(s, "Clinical Features");

  // Symptoms
  s.addShape(pres.shapes.RECTANGLE, { x:0.3, y:0.88, w:4.5, h:2.2, fill:{ color: C.white }, shadow:{ type:"outer", color:"000000", blur:6, offset:2, angle:135, opacity:0.1 } });
  s.addText("SYMPTOMS", { x:0.3, y:0.88, w:4.5, h:0.38, fontSize:12, bold:true, color:C.white, align:"center", valign:"middle", fill:{ color: C.blue }, margin:0 });
  bulletBox(s, [
    "Epigastric/LUQ pain → radiates to back",
    "Pain eased by sitting forward",
    "Nausea, vomiting, anorexia",
    "Oral intake worsens pain"
  ], { x:0.4, y:1.3, w:4.3, h:1.65, fontSize:13.5 });

  // Signs
  s.addShape(pres.shapes.RECTANGLE, { x:5.2, y:0.88, w:4.5, h:2.2, fill:{ color: C.white }, shadow:{ type:"outer", color:"000000", blur:6, offset:2, angle:135, opacity:0.1 } });
  s.addText("SIGNS", { x:5.2, y:0.88, w:4.5, h:0.38, fontSize:12, bold:true, color:C.white, align:"center", valign:"middle", fill:{ color: C.teal }, margin:0 });
  bulletBox(s, [
    "Epigastric tenderness ± guarding",
    "Fever, tachycardia, tachypnoea",
    "Jaundice → biliary obstruction",
    "Absent bowel sounds (ileus)"
  ], { x:5.3, y:1.3, w:4.3, h:1.65, fontSize:13.5 });

  // Severe signs boxes
  s.addShape(pres.shapes.RECTANGLE, { x:0.3, y:3.2, w:4.5, h:2.1, fill:{ color:"FFF3CD" }, shadow:{ type:"outer", color:"000000", blur:6, offset:2, angle:135, opacity:0.1 } });
  s.addText("SIGNS OF SEVERITY", { x:0.3, y:3.2, w:4.5, h:0.38, fontSize:12, bold:true, color:C.white, align:"center", valign:"middle", fill:{ color: C.orange }, margin:0 });
  bulletBox(s, [
    "Cullen sign – periumbilical ecchymosis",
    "Grey Turner sign – flank ecchymosis",
    "(Both = retroperitoneal bleed → poor prognosis)"
  ], { x:0.4, y:3.62, w:4.3, h:1.55, fontSize:13, color:"7B4000" });

  s.addShape(pres.shapes.RECTANGLE, { x:5.2, y:3.2, w:4.5, h:2.1, fill:{ color:"FDECEA" }, shadow:{ type:"outer", color:"000000", blur:6, offset:2, angle:135, opacity:0.1 } });
  s.addText("SYSTEMIC FEATURES", { x:5.2, y:3.2, w:4.5, h:0.38, fontSize:12, bold:true, color:C.white, align:"center", valign:"middle", fill:{ color: C.red }, margin:0 });
  bulletBox(s, [
    "ARDS · pleural effusion (L > R)",
    "Hypotension / shock",
    "AKI · coagulopathy / DIC",
    "Hypocalcaemia · hyperglycaemia"
  ], { x:5.3, y:3.62, w:4.3, h:1.55, fontSize:13, color: C.red });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 8 – DIAGNOSIS CRITERIA & LABS
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  lightSlide(s);
  slideTitle(s, "Diagnostic Criteria & Laboratory Workup");

  // Diagnostic criteria box
  s.addShape(pres.shapes.RECTANGLE, { x:0.3, y:0.88, w:9.4, h:1.3, fill:{ color: C.navy } });
  s.addText("DIAGNOSIS: 2 of 3 criteria required", {
    x:0.3, y:0.88, w:9.4, h:0.38, fontSize:13, bold:true, color:C.teal, align:"center", margin:0
  });
  const criteria = ["1. Characteristic epigastric pain", "2. Lipase or Amylase ≥ 3× ULN", "3. Characteristic imaging findings (CT/MRI)"];
  criteria.forEach((c, i) => {
    s.addShape(pres.shapes.ROUNDED_RECTANGLE, { x:0.45 + i*3.15, y:1.32, w:2.9, h:0.72, fill:{ color: C.teal }, rectRadius:0.08 });
    s.addText(c, { x:0.45 + i*3.15, y:1.32, w:2.9, h:0.72, fontSize:12.5, color:C.white, align:"center", valign:"middle", margin:0 });
  });

  // Lab table
  const rows = [
    ["Test", "Finding", "Notes"],
    ["Lipase", "≥3× ULN (preferred)", "More specific than amylase, stays elevated longer"],
    ["Amylase", "≥3× ULN", "Rises earlier, less specific; may be normal in alcoholic AP"],
    ["ALT", ">3× ULN", "Suggests gallstone etiology (94% PPV)"],
    ["CRP", ">150 mg/L at 48h", "Best severity marker at 48h"],
    ["BUN / Creatinine", "Elevated", "BUN rise = poor prognosis; AKI monitoring"],
    ["Haematocrit", ">44%", "Hemoconcentration = risk for necrosis"],
    ["Procalcitonin", "Elevated early", "Early predictor of severe AP and infection"],
    ["Ca²⁺, Glucose, TG", "See notes", "Hypocalcaemia (fat saponification); TG >1000 = cause"]
  ];
  const colW = [1.6, 2.2, 5.45];
  const startY = 2.25;
  rows.forEach((row, ri) => {
    const bg = ri === 0 ? C.blue : (ri % 2 === 0 ? C.ltGrey : C.white);
    const fc = ri === 0 ? C.white : C.text;
    const bld = ri === 0;
    let cx = 0.3;
    row.forEach((cell, ci) => {
      s.addShape(pres.shapes.RECTANGLE, { x:cx, y:startY + ri*0.36, w:colW[ci], h:0.36, fill:{ color: bg }, line:{ color:"D0D8E4", width:0.5 } });
      s.addText(cell, { x:cx+0.05, y:startY + ri*0.36, w:colW[ci]-0.1, h:0.36, fontSize:11, color:fc, bold:bld, valign:"middle", margin:0 });
      cx += colW[ci];
    });
  });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 9 – IMAGING
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  lightSlide(s);
  slideTitle(s, "Imaging in Acute Pancreatitis");

  // Left text
  bulletBox(s, [
    "Ultrasound — FIRST LINE: detects gallstones/biliary dilation; poor for pancreas (bowel gas)",
    "CT with IV contrast — NOT routine; indications:",
    { text:"Diagnostic uncertainty / normal enzymes with high suspicion", sub:true },
    { text:"Rule out other intra-abdominal pathology", sub:true },
    { text:"Assess complications if not improving at 48–72 h", sub:true },
    { text:"Best done 3–7 days after onset (necrosis may not appear early)", sub:true },
    "MRI/MRCP — equivalent to CT; superior for biliary; preferred when contrast contraindicated",
    "MRCP/EUS — evaluate bile duct stones before ERCP"
  ], { x:0.3, y:0.85, w:5.4, h:4.5, fontSize:12.5 });

  // CT images on right
  if (imgs[0] && imgs[0].base64) {
    s.addImage({ data: imgs[0].base64, x:5.9, y:0.85, w:3.9, h:2.1 });
    s.addText("Interstitial Pancreatitis — peripancreatic fat stranding (arrows)", {
      x:5.9, y:2.95, w:3.9, h:0.35, fontSize:9.5, color:C.subtext, italic:true, align:"center"
    });
  }
  if (imgs[1] && imgs[1].base64) {
    s.addImage({ data: imgs[1].base64, x:5.9, y:3.35, w:3.9, h:2.0 });
    s.addText("Necrotising Pancreatitis — non-enhancing necrotic area (arrow)", {
      x:5.9, y:5.35, w:3.9, h:0.25, fontSize:9.5, color:C.subtext, italic:true, align:"center"
    });
  }
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 10 – SECTION: SEVERITY
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  sectionHeader(s, "Section 3: Severity Classification", "Atlanta 2012 · Scoring Systems");
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 11 – REVISED ATLANTA CLASSIFICATION
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  lightSlide(s);
  slideTitle(s, "Revised Atlanta Classification 2012");

  const grades = [
    { label:"MILD", color: C.green, criteria:["No organ failure","No local complications","No systemic complications","Resolves in 3–5 days","No ICU needed"] },
    { label:"MODERATELY SEVERE", color: C.orange, criteria:["Transient organ failure (<48h)","OR local complications present","OR systemic comorbidity exacerbation","May need short ICU stay","Higher risk of necrosis"] },
    { label:"SEVERE", color: C.red, criteria:["Persistent organ failure (>48h)","Modified Marshall score ≥2","Respiratory / CVS / Renal failure","High mortality (15–30%)","ICU admission mandatory"] },
  ];

  grades.forEach((g, i) => {
    const x = 0.3 + i * 3.2;
    s.addShape(pres.shapes.RECTANGLE, { x, y:0.88, w:3.0, h:0.5, fill:{ color: g.color } });
    s.addText(g.label, { x, y:0.88, w:3.0, h:0.5, fontSize:14, bold:true, color:C.white, align:"center", valign:"middle", margin:0 });
    s.addShape(pres.shapes.RECTANGLE, { x, y:1.38, w:3.0, h:3.9, fill:{ color: C.white }, shadow:{ type:"outer", color:"000000", blur:6, offset:2, angle:135, opacity:0.1 } });
    g.criteria.forEach((c, ci) => {
      s.addShape(pres.shapes.RECTANGLE, { x: x+0.08, y: 1.5 + ci*0.68, w:0.06, h:0.32, fill:{ color: g.color } });
      s.addText(c, { x: x+0.22, y: 1.5 + ci*0.68, w:2.7, h:0.52, fontSize:12.5, color:C.text, valign:"middle" });
    });
  });

  s.addShape(pres.shapes.RECTANGLE, { x:0, y:5.25, w:10, h:0.38, fill:{ color: C.navy } });
  s.addText("Organ Failure = Modified Marshall Score ≥ 2 for Respiratory, Cardiovascular, or Renal systems  |  Classification requires 48h — limits use in ED", {
    x:0.2, y:5.25, w:9.6, h:0.38, fontSize:10.5, color:C.ltBlue, valign:"middle", margin:0
  });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 12 – SCORING SYSTEMS
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  lightSlide(s);
  slideTitle(s, "Severity Scoring Systems");

  const scores = [
    { name:"Ranson Criteria", vars:"11 vars: 5 at admission + 6 at 48h\nAge, WBC, glucose, LDH, AST;\nBUN rise, fluid deficit, Ca, PaO2, base deficit, Hct drop", cutoff:"≥3 = Severe", when:"At 48h", color: C.blue },
    { name:"APACHE II", vars:"15 physiological variables\nAge, temperature, MAP, HR, RR,\nPaO2, pH, Na, K, Cr, Hct, WBC, GCS, etc.", cutoff:"≥8 = Severe", when:"Any time (ICU)", color: C.teal },
    { name:"BISAP Score", vars:"BUN >25 mg/dL\nImpaired mental status\nSIRS criteria\nAge >60\nPleural effusion", cutoff:"≥3 = High Risk", when:"At admission (ED use)", color:"7D3C98" },
    { name:"Modified CTSI", vars:"Pancreatic inflammation grade (0–4)\n+ Necrosis (0–4)\n+ Extrapancreatic complications (+2)", cutoff:"≥4 = Severe", when:"On CT imaging", color: C.orange },
  ];
  scores.forEach((sc, i) => {
    const col = i % 2 === 0 ? 0.3 : 5.15;
    const row = i < 2 ? 0.88 : 3.1;
    s.addShape(pres.shapes.RECTANGLE, { x:col, y:row, w:4.55, h:0.38, fill:{ color: sc.color } });
    s.addText(sc.name, { x:col, y:row, w:4.55, h:0.38, fontSize:13, bold:true, color:C.white, align:"center", valign:"middle", margin:0 });
    s.addShape(pres.shapes.RECTANGLE, { x:col, y:row+0.38, w:4.55, h:1.9, fill:{ color: C.white }, shadow:{ type:"outer", color:"000000", blur:6, offset:1, angle:135, opacity:0.1 } });
    s.addText(sc.vars, { x:col+0.12, y:row+0.45, w:2.9, h:1.7, fontSize:11, color:C.text, valign:"top" });
    s.addShape(pres.shapes.ROUNDED_RECTANGLE, { x:col+3.05, y:row+0.5, w:1.35, h:0.5, fill:{ color: sc.color }, rectRadius:0.06 });
    s.addText(sc.cutoff, { x:col+3.05, y:row+0.5, w:1.35, h:0.5, fontSize:10, bold:true, color:C.white, align:"center", valign:"middle", margin:0 });
    s.addText(sc.when, { x:col+3.0, y:row+1.1, w:1.5, h:0.5, fontSize:10, color:sc.color, italic:true, align:"center" });
  });

  s.addShape(pres.shapes.RECTANGLE, { x:0, y:5.25, w:10, h:0.38, fill:{ color: C.ltGrey } });
  s.addText("CRP >150 mg/L at 48h = Severe  |  Hematocrit >44% = risk for necrosis  |  HAPS: 97% specific for mild AP (peritonitis, Cr, Hct)", {
    x:0.2, y:5.25, w:9.6, h:0.38, fontSize:10.5, color:C.subtext, valign:"middle", italic:true, margin:0
  });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 13 – SECTION: MANAGEMENT
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  sectionHeader(s, "Section 4: Management", "Fluids · Analgesia · Nutrition · ERCP · Surgery");
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 14 – FLUID RESUSCITATION
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  lightSlide(s);
  slideTitle(s, "Fluid Resuscitation — The Most Critical Initial Step");

  s.addShape(pres.shapes.RECTANGLE, { x:0.3, y:0.88, w:9.4, h:0.58, fill:{ color: C.teal } });
  s.addText("Treatment is MAINLY SUPPORTIVE — Aggressive, goal-directed fluid resuscitation is the cornerstone", {
    x:0.3, y:0.88, w:9.4, h:0.58, fontSize:14, bold:true, color:C.white, align:"center", valign:"middle", margin:0
  });

  // Goals box
  s.addShape(pres.shapes.RECTANGLE, { x:0.3, y:1.55, w:4.45, h:2.55, fill:{ color: C.white }, shadow:{ type:"outer", color:"000000", blur:6, offset:2, angle:135, opacity:0.1 } });
  s.addText("TARGETS (IAP/APA)", { x:0.3, y:1.55, w:4.45, h:0.38, fontSize:12, bold:true, color:C.white, align:"center", valign:"middle", fill:{ color: C.blue }, margin:0 });
  bulletBox(s, [
    "Rate: 5–10 mL/kg/h (IAP) or 250–500 mL/h (ACG)",
    "Heart rate < 120/min",
    "MAP 65–85 mmHg",
    "Urine output > 0.5–1 mL/kg/h",
    "Monitor: Hct, BUN, creatinine"
  ], { x:0.4, y:1.97, w:4.25, h:2.0, fontSize:13 });

  // Fluid choice
  s.addShape(pres.shapes.RECTANGLE, { x:5.15, y:1.55, w:4.55, h:2.55, fill:{ color: C.white }, shadow:{ type:"outer", color:"000000", blur:6, offset:2, angle:135, opacity:0.1 } });
  s.addText("FLUID CHOICE", { x:5.15, y:1.55, w:4.55, h:0.38, fontSize:12, bold:true, color:C.white, align:"center", valign:"middle", fill:{ color: C.teal }, margin:0 });
  bulletBox(s, [
    "Lactated Ringer's preferred over Normal Saline",
    "NS → hyperchloraemic acidosis → activates trypsinogen → worsens SIRS",
    "LR has anti-inflammatory properties",
    "Colloids: not routine; consider if Hct <24 or albumin <2 g/dL",
    "Reassess frequently — avoid over-resuscitation"
  ], { x:5.25, y:1.97, w:4.35, h:2.0, fontSize:13 });

  // Warning
  s.addShape(pres.shapes.RECTANGLE, { x:0.3, y:4.2, w:9.4, h:1.15, fill:{ color:"FFF3CD" } });
  s.addText("⚠  Inadequate resuscitation in first 24h → increased SIRS, organ failure, necrosis, ICU admission\n⚠  Over-resuscitation → ARDS, abdominal compartment syndrome, earlier sepsis", {
    x:0.5, y:4.2, w:9.1, h:1.15, fontSize:12, color:"7B4000", valign:"middle"
  });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 15 – NUTRITION & ANALGESIA
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  lightSlide(s);
  slideTitle(s, "Analgesia, Nutrition & Monitoring");

  // Analgesia
  s.addShape(pres.shapes.RECTANGLE, { x:0.3, y:0.88, w:2.95, h:4.45, fill:{ color: C.white }, shadow:{ type:"outer", color:"000000", blur:6, offset:2, angle:135, opacity:0.1 } });
  s.addText("ANALGESIA", { x:0.3, y:0.88, w:2.95, h:0.38, fontSize:12, bold:true, color:C.white, align:"center", valign:"middle", fill:{ color:"7D3C98" }, margin:0 });
  bulletBox(s, [
    "IV opioids (morphine, hydromorphone)",
    "PCA for severe pain",
    "Meperidine no longer preferred",
    "NSAIDs as adjuncts if no AKI",
    "Anti-emetics: ondansetron, metoclopramide"
  ], { x:0.4, y:1.3, w:2.75, h:3.9, fontSize:12.5 });

  // Nutrition
  s.addShape(pres.shapes.RECTANGLE, { x:3.55, y:0.88, w:6.15, h:4.45, fill:{ color: C.white }, shadow:{ type:"outer", color:"000000", blur:6, offset:2, angle:135, opacity:0.1 } });
  s.addText("NUTRITION (ESPEN 2024 Guidelines)", { x:3.55, y:0.88, w:6.15, h:0.38, fontSize:12, bold:true, color:C.white, align:"center", valign:"middle", fill:{ color: C.teal }, margin:0 });
  bulletBox(s, [
    "Mild AP: Start oral diet as tolerated — do NOT enforce NPO",
    "Severe AP / unable to eat:",
    { text:"Enteral nutrition preferred over TPN (fewer infections, lower cost)", sub:true },
    { text:"Nasogastric (NG) feeding = effective as nasojejunal for most patients", sub:true },
    { text:"Nasojejunal preferred if intolerant due to severe duodenal oedema", sub:true },
    { text:"Endoscopic NJ tube placement is feasible", sub:true },
    "TPN only if enteral route not possible",
    "Monitoring: electrolytes, glucose, calcium, magnesium, renal function"
  ], { x:3.65, y:1.3, w:5.95, h:3.9, fontSize:13 });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 16 – ANTIBIOTICS & ERCP
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  lightSlide(s);
  slideTitle(s, "Antibiotics & Endoscopic Management (ERCP)");

  // Antibiotics
  s.addShape(pres.shapes.RECTANGLE, { x:0.3, y:0.88, w:4.5, h:4.45, fill:{ color: C.white }, shadow:{ type:"outer", color:"000000", blur:6, offset:2, angle:135, opacity:0.1 } });
  s.addText("ANTIBIOTICS", { x:0.3, y:0.88, w:4.5, h:0.38, fontSize:12, bold:true, color:C.white, align:"center", valign:"middle", fill:{ color: C.red }, margin:0 });
  bulletBox(s, [
    "NOT indicated prophylactically in sterile AP",
    "Indicated when:",
    { text:"Infected pancreatic necrosis confirmed/suspected", sub:true },
    { text:"Concurrent acute cholangitis", sub:true },
    "Agents that penetrate pancreatic necrosis:",
    { text:"Carbapenems (imipenem, meropenem) — FIRST LINE", sub:true },
    { text:"Fluoroquinolones + metronidazole", sub:true },
    { text:"3rd-gen cephalosporins, piperacillin-tazobactam", sub:true },
    "Duration: guided by clinical response + culture"
  ], { x:0.4, y:1.3, w:4.3, h:3.9, fontSize:12.5 });

  // ERCP
  s.addShape(pres.shapes.RECTANGLE, { x:5.2, y:0.88, w:4.5, h:4.45, fill:{ color: C.white }, shadow:{ type:"outer", color:"000000", blur:6, offset:2, angle:135, opacity:0.1 } });
  s.addText("ERCP", { x:5.2, y:0.88, w:4.5, h:0.38, fontSize:12, bold:true, color:C.white, align:"center", valign:"middle", fill:{ color: C.blue }, margin:0 });
  bulletBox(s, [
    "NOT routinely indicated in AP",
    "Indicated in:",
    { text:"Acute cholangitis + gallstone AP → urgent ERCP <24–48h", sub:true },
    { text:"Biliary obstruction (elevated bilirubin + cholangitis) within 72h", sub:true },
    "NOT recommended for uncomplicated biliary AP (no mortality benefit)",
    "Less invasive alternatives: MRCP, EUS to detect CBD stones first",
    "Cholecystectomy:",
    { text:"Early laparoscopic cholecystectomy within 3 days (mild AP) — standard of care", sub:true },
    { text:"Reduces need for ERCP and risk of recurrence", sub:true }
  ], { x:5.3, y:1.3, w:4.3, h:3.9, fontSize:12.5 });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 17 – SECTION: COMPLICATIONS
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  sectionHeader(s, "Section 5: Complications", "Local · Systemic · Necrotizing · Pseudocyst");
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 18 – LOCAL COMPLICATIONS (ATLANTA MORPHOLOGY)
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  lightSlide(s);
  slideTitle(s, "Local Complications — Revised Atlanta Morphology");

  // Table
  const cols = [1.6, 3.85, 3.85];
  const headers = ["Subtype", "< 4 Weeks", "> 4 Weeks"];
  const rows2 = [
    ["Interstitial\nEdematous", "Acute Peripancreatic Fluid\nCollection (APFC)\n• Homogeneous fluid\n• No wall / capsule\n• Confined to fascial planes", "Pseudocyst\n• Encapsulated, round/oval\n• No solid debris\n• Well-defined wall\n• ≥4 weeks to form"],
    ["Necrotising", "Acute Necrotic Collection\n(ANC)\n• Heterogeneous + nonliquid\n• No wall\n• Intra- or extra-pancreatic", "Walled-Off Necrosis\n(WON)\n• Mixed liquid + solid\n• Encapsulated, well-defined\n• ≥4 weeks\n• May be infected"],
  ];

  // header row
  let cx = 0.3;
  headers.forEach((h, ci) => {
    s.addShape(pres.shapes.RECTANGLE, { x:cx, y:0.88, w:cols[ci], h:0.46, fill:{ color: C.navy }, line:{ color: C.teal, width:1 } });
    s.addText(h, { x:cx+0.05, y:0.88, w:cols[ci]-0.1, h:0.46, fontSize:13, bold:true, color:C.white, align:"center", valign:"middle", margin:0 });
    cx += cols[ci];
  });
  // data rows
  rows2.forEach((row, ri) => {
    cx = 0.3;
    const bg = ri === 0 ? C.ltBlue : "#E8F8E8";
    const headBg = ri === 0 ? C.blue : C.teal;
    row.forEach((cell, ci) => {
      s.addShape(pres.shapes.RECTANGLE, { x:cx, y:1.34 + ri*2.05, w:cols[ci], h:2.05, fill:{ color: ci===0 ? headBg : bg }, line:{ color:"C0C8D4", width:0.5 } });
      s.addText(cell, { x:cx+0.08, y:1.38 + ri*2.05, w:cols[ci]-0.12, h:1.9, fontSize:ci===0?14:11.5, bold:ci===0, color:ci===0?C.white:C.text, valign:"top" });
      cx += cols[ci];
    });
  });

  s.addShape(pres.shapes.RECTANGLE, { x:0, y:5.28, w:10, h:0.35, fill:{ color: C.ltGrey } });
  s.addText("Most APFCs resolve spontaneously  |  Pseudocyst drainage when: symptomatic, infected, enlarging, or causing obstruction", {
    x:0.2, y:5.28, w:9.6, h:0.35, fontSize:10.5, color:C.subtext, italic:true, valign:"middle", margin:0
  });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 19 – NECROTISING PANCREATITIS
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  lightSlide(s);
  slideTitle(s, "Necrotising Pancreatitis — Diagnosis & Step-Up Management");

  // Left col
  bulletBox(s, [
    "Occurs in 5–10% of AP cases",
    "CT: non-enhancing areas <40–50 HU (normal 100–150 HU)",
    "Risk of infection ∝ extent of necrosis:",
    { text:"<30% gland → 22% infection risk", sub:true },
    { text:"30–50% gland → 37% risk", sub:true },
    { text:">70% gland → 46% risk", sub:true },
    "Organisms: E. coli, Klebsiella, Pseudomonas, Enterococcus (gut translocation)",
    "Diagnose infected necrosis: gas on CT, or FNA (Gram stain/culture)",
    "Suspect if: fever/WBC >7 days, sepsis, or clinical deterioration after day 10–14"
  ], { x:0.3, y:0.88, w:5.4, h:4.5, fontSize:12.5 });

  // Step-up ladder
  const steps = [
    { n:"1", label:"IV Antibiotics (Carbapenem)", sub:"Start immediately when infected necrosis suspected/confirmed", color: C.blue },
    { n:"2", label:"Percutaneous / Endoscopic Drainage", sub:"First-line intervention; delay to allow WON formation (≥4 wks)", color: C.teal },
    { n:"3", label:"Minimally Invasive Necrosectomy", sub:"Video-assisted (VARD) or endoscopic transluminal necrosectomy", color: C.orange },
    { n:"4", label:"Open Surgical Necrosectomy", sub:"Last resort — only if minimally invasive fails; high mortality", color: C.red },
  ];
  steps.forEach((st, i) => {
    const y = 0.88 + i * 1.1;
    s.addShape(pres.shapes.RECTANGLE, { x:6.0, y, w:3.8, h:0.95, fill:{ color: st.color }, shadow:{ type:"outer", color:"000000", blur:4, offset:2, angle:135, opacity:0.12 } });
    s.addShape(pres.shapes.RECTANGLE, { x:6.0, y, w:0.42, h:0.95, fill:{ color:"00000030" } });
    s.addText(st.n, { x:6.0, y, w:0.42, h:0.95, fontSize:20, bold:true, color:C.white, align:"center", valign:"middle", margin:0 });
    s.addText(st.label, { x:6.48, y:y+0.05, w:3.27, h:0.4, fontSize:12, bold:true, color:C.white, valign:"middle" });
    s.addText(st.sub, { x:6.48, y:y+0.48, w:3.27, h:0.38, fontSize:10, color:C.white, valign:"top" });
    // arrow
    if (i < steps.length-1) {
      s.addShape(pres.shapes.RECTANGLE, { x:7.7, y:y+0.95, w:0.4, h:0.15, fill:{ color: C.subtext } });
    }
  });

  s.addShape(pres.shapes.RECTANGLE, { x:5.95, y:5.25, w:3.85, h:0.35, fill:{ color: C.ltGrey } });
  s.addText("Sterile necrosis → conservative unless persistent pain/obstruction/failure to improve", {
    x:5.95, y:5.25, w:3.85, h:0.35, fontSize:10, color:C.subtext, italic:true, align:"center", valign:"middle", margin:0
  });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 20 – SYSTEMIC COMPLICATIONS
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  lightSlide(s);
  slideTitle(s, "Systemic & Vascular Complications");

  const comps = [
    { sys:"Pulmonary", items:["ARDS","Pleural effusion (L>R, up to 50%)","Atelectasis, hypoxaemia","Shallow breathing (pain splinting)"], color: C.blue },
    { sys:"Cardiovascular", items:["Hypovolaemic shock","Decreased MAP","Need for vasopressors","Pericardial effusion (rare)"], color: C.red },
    { sys:"Renal", items:["Acute kidney injury (AKI)","Hypoperfusion + inflammatory mediators","Monitor urine output + creatinine"], color: C.teal },
    { sys:"Haematologic", items:["DIC / Coagulopathy","Cytokine-mediated coagulation activation","Thrombocytopenia"], color:"7D3C98" },
    { sys:"Metabolic", items:["Hypocalcaemia (fat saponification)","Hyperglycaemia","Hypomagnesaemia","Hyperlipidaemia"], color: C.orange },
    { sys:"Vascular / GI", items:["Splenic/portal vein thrombosis","Pseudoaneurysm (splenic a.) → haemorrhage","Bowel necrosis (rare, very high mortality)","Gastric outlet obstruction"], color:"1E8449" },
  ];
  const positions = [
    [0.3, 0.88], [3.55, 0.88], [6.8, 0.88],
    [0.3, 3.1], [3.55, 3.1], [6.8, 3.1]
  ];
  comps.forEach((c, i) => {
    const [x, y] = positions[i];
    s.addShape(pres.shapes.RECTANGLE, { x, y, w:3.0, h:2.12, fill:{ color: C.white }, shadow:{ type:"outer", color:"000000", blur:6, offset:2, angle:135, opacity:0.1 } });
    s.addShape(pres.shapes.RECTANGLE, { x, y, w:3.0, h:0.38, fill:{ color: c.color } });
    s.addText(c.sys, { x, y, w:3.0, h:0.38, fontSize:12, bold:true, color:C.white, align:"center", valign:"middle", margin:0 });
    c.items.forEach((item, ii) => {
      s.addShape(pres.shapes.RECTANGLE, { x:x+0.1, y:y+0.44+ii*0.38, w:0.06, h:0.22, fill:{ color: c.color } });
      s.addText(item, { x:x+0.22, y:y+0.44+ii*0.38, w:2.72, h:0.35, fontSize:11, color:C.text, valign:"middle" });
    });
  });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 21 – RECURRENCE PREVENTION
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  lightSlide(s);
  slideTitle(s, "Prognosis & Recurrence Prevention");

  // Prognosis
  s.addShape(pres.shapes.RECTANGLE, { x:0.3, y:0.88, w:4.5, h:4.45, fill:{ color: C.white }, shadow:{ type:"outer", color:"000000", blur:6, offset:2, angle:135, opacity:0.1 } });
  s.addText("PROGNOSIS", { x:0.3, y:0.88, w:4.5, h:0.38, fontSize:12, bold:true, color:C.white, align:"center", valign:"middle", fill:{ color: C.blue }, margin:0 });
  bulletBox(s, [
    "Mild AP: >80% of cases; resolves 3–5 days",
    "Severe AP: mortality 15–30%",
    "Poor prognostic indicators:",
    { text:"Hematocrit >44% on admission", sub:true },
    { text:"BUN >20 mg/dL or rising", sub:true },
    { text:"Creatinine rising at 24h", sub:true },
    { text:"BISAP ≥3, APACHE II ≥8", sub:true },
    { text:"CRP >150 at 48h", sub:true },
    { text:"SIRS persisting >48h", sub:true },
    { text:"Infected necrotizing pancreatitis", sub:true }
  ], { x:0.4, y:1.3, w:4.3, h:3.9, fontSize:12.5 });

  // Prevention
  s.addShape(pres.shapes.RECTANGLE, { x:5.2, y:0.88, w:4.5, h:4.45, fill:{ color: C.white }, shadow:{ type:"outer", color:"000000", blur:6, offset:2, angle:135, opacity:0.1 } });
  s.addText("RECURRENCE PREVENTION", { x:5.2, y:0.88, w:4.5, h:0.38, fontSize:12, bold:true, color:C.white, align:"center", valign:"middle", fill:{ color: C.teal }, margin:0 });
  bulletBox(s, [
    "Gallstone AP → Cholecystectomy (same admission or within 2–4 wks) — MANDATORY",
    "Alcoholic AP → Strict alcohol cessation; rehabilitation",
    "Hypertriglyceridaemia → Fibrates, omega-3 FA, low-fat diet",
    "Drug-induced → Identify and stop causative agent",
    "Recurrent idiopathic → Genetic testing (SPINK1, CFTR, PRSS1); consider MRCP",
    "Post-AP → Monitor for chronic pancreatitis, diabetes, exocrine insufficiency"
  ], { x:5.3, y:1.3, w:4.3, h:3.9, fontSize:12.5 });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 22 – KEY TAKEAWAYS
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  darkSlide(s);
  s.addShape(pres.shapes.RECTANGLE, { x:0, y:0, w:0.12, h:5.625, fill:{ color: C.teal } });
  s.addText("KEY TAKEAWAYS", {
    x:0.45, y:0.3, w:9.1, h:0.55, fontSize:28, bold:true, color:C.white, fontFace:"Calibri", charSpacing:2
  });
  s.addShape(pres.shapes.RECTANGLE, { x:0.45, y:0.88, w:9.1, h:0.04, fill:{ color: C.teal } });

  const takeaways = [
    { n:"01", text:"Diagnosis requires 2 of 3: pain + enzymes ≥3× ULN + imaging", color: C.teal },
    { n:"02", text:"Gallstones (40–70%) and alcohol (25–35%) account for most cases", color: C.blue },
    { n:"03", text:"Fluid resuscitation with Lactated Ringer's is the cornerstone — goal-directed, not empiric", color: C.orange },
    { n:"04", text:"CT is NOT routine — use only for diagnostic uncertainty or complications at 48–72h", color: C.teal },
    { n:"05", text:"Antibiotics are NOT prophylactic; reserve for infected necrosis or cholangitis", color: C.blue },
    { n:"06", text:"Early enteral nutrition > TPN; NG feeding as effective as nasojejunal for most", color: C.orange },
    { n:"07", text:"Infected necrotizing AP: step-up approach — drain first, then necrosectomy only if needed", color: C.teal },
    { n:"08", text:"Early cholecystectomy (same admission) is mandatory in gallstone pancreatitis", color: C.blue },
  ];

  takeaways.forEach((t, i) => {
    const col = i < 4 ? 0.45 : 5.05;
    const row = 1.0 + (i % 4) * 1.1;
    s.addShape(pres.shapes.RECTANGLE, { x:col, y:row, w:0.5, h:0.55, fill:{ color: t.color } });
    s.addText(t.n, { x:col, y:row, w:0.5, h:0.55, fontSize:14, bold:true, color:C.white, align:"center", valign:"middle", margin:0 });
    s.addShape(pres.shapes.RECTANGLE, { x:col+0.5, y:row, w:4.15, h:0.55, fill:{ color:"FFFFFF15" } });
    s.addText(t.text, { x:col+0.58, y:row, w:4.0, h:0.55, fontSize:12, color:C.white, valign:"middle" });
  });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 23 – REFERENCES
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  lightSlide(s);
  slideTitle(s, "References");
  bulletBox(s, [
    "Rosen's Emergency Medicine: Concepts and Clinical Practice, 9th Edition, Ch. 77",
    "Sleisenger & Fordtran's Gastrointestinal and Liver Disease, 11th Edition",
    "Sabiston Textbook of Surgery, 21st Edition, Ch. 92",
    "Revised Atlanta Classification of Acute Pancreatitis 2012. Banks PA et al. Gut. 2013;62:102–111",
    "Arvanitakis M et al. ESPEN Practical Guideline on Clinical Nutrition in Acute and Chronic Pancreatitis. Clin Nutr. 2024 Feb. [PMID: 38169174]",
    "Trikudanathan G et al. Diagnosis and Management of Acute Pancreatitis. Gastroenterology. 2024 Sep. [PMID: 38759844]",
    "Beij A et al. Acute Pancreatitis: An Update of Evidence-Based Management and Recent Trends. United European Gastroenterol J. 2025 Feb. [PMID: 39804691]",
    "IAP/APA Evidence-Based Guidelines for the Management of Acute Pancreatitis. Pancreatology. 2013;13:e1–e15"
  ], { y:0.9, fontSize:14 });
}

// ─── WRITE FILE ──────────────────────────────────────────────────────────────
pres.writeFile({ fileName: "/home/daytona/workspace/acute-pancreatitis-ppt/Acute_Pancreatitis_PG_Surgery.pptx" })
  .then(() => console.log("SUCCESS: File written"))
  .catch(e => console.error("ERROR:", e));
Running Command

cd /home/daytona/workspace/acute-pancreatitis-ppt && node generate.js 2>&1

Editing File

~/acute-pancreatitis-ppt/generate.js

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/acute-pancreatitis-ppt/generate.js'
Editing File

~/acute-pancreatitis-ppt/generate.js

Error: String not found in file: '    s.addShape(pres.shapes.RECTANGLE, { x:col, y:row, w:0.42, h:0.95, fill:{ color:"00000030" } });'
Searching Content

"00000030" in ~/acute-pancreatitis-ppt

Running Command

sed -i 's/"00000030"/"1A3A5C"/g' /home/daytona/workspace/acute-pancreatitis-ppt/…

Running Command

grep -n "00000030" /home/daytona/workspace/acute-pancreatitis-ppt/generate.js | …

Editing File

~/acute-pancreatitis-ppt/generate.js

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

node /home/daytona/workspace/acute-pancreatitis-ppt/generate.js 2>&1

Running Command

ls -lh /home/daytona/workspace/acute-pancreatitis-ppt/Acute_Pancreatitis_PG_Surg…

Your presentation is ready. Download it here:

Acute Pancreatitis PG Surgery

Presentation · PPTX


What's inside (23 slides):
#Slide
1Title Slide — dark navy + teal design
2Learning Objectives
3Section Header: Fundamentals
4Definition, Epidemiology & Pathophysiology (dual columns)
5Etiology — colour-coded tile grid with prevalence %
6Section Header: Clinical Features & Diagnosis
7Symptoms, Signs, Signs of Severity, Systemic Features (4-panel)
8Diagnostic Criteria (2-of-3 rule) + full lab table
9Imaging — indications, modalities + real CT images embedded
10Section Header: Severity Classification
11Revised Atlanta Classification 2012 (Mild / Mod-Severe / Severe — 3-column)
12Scoring Systems — Ranson, APACHE II, BISAP, Modified CTSI
13Section Header: Management
14Fluid Resuscitation — goals, LR vs NS, warning boxes
15Analgesia, Nutrition & Monitoring (ESPEN 2024 guidelines)
16Antibiotics + ERCP indications (dual column)
17Section Header: Complications
18Local Complications — Atlanta morphology table (APFC/Pseudocyst/ANC/WON)
19Necrotising Pancreatitis + Step-Up Management ladder
20Systemic & Vascular Complications (6-panel grid)
21Prognosis & Recurrence Prevention
22Key Takeaways (8 numbered points, dark background)
23References (including ESPEN 2024, Gastroenterology 2024, UEG J 2025)
Design: Navy/teal/orange palette, section headers, cards with shadows, colour-coded severity indicators, and the two actual CT scan images (interstitial pancreatitis + necrotising pancreatitis) are embedded directly from the textbook.

For postgraduate surgery clinical discussion

Asking for Preferences

For post graduate general surgery

Asking for Preferences

Clinics

Asking for Preferences
Reading File
Running Command

mkdir -p /home/daytona/workspace/acute-pancreatitis-clinics && ls /home/daytona/…

Writing File

~/acute-pancreatitis-clinics/generate.js

const {
  Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell,
  Header, Footer, AlignmentType, HeadingLevel, BorderStyle, WidthType,
  ShadingType, VerticalAlign, PageNumber, NumberFormat,
  TableOfContents, UnderlineType, PageBreak
} = require("docx");
const fs = require("fs");

// ─── COLOUR / STYLE CONSTANTS ────────────────────────────────────────────────
const NAVY   = "0D2B55";
const TEAL   = "0E7C86";
const ORANGE = "E8630A";
const RED    = "C0392B";
const GREEN  = "1E6B3A";
const GREY   = "4A6077";
const LTBLUE = "D6E4F0";
const WHITE  = "FFFFFF";
const BLACK  = "1C2B3A";
const LTGREY = "EEF2F6";
const CREAM  = "FFF8F0";

// ─── HELPER FUNCTIONS ────────────────────────────────────────────────────────

function heading1(text) {
  return new Paragraph({
    text,
    heading: HeadingLevel.HEADING_1,
    spacing: { before: 400, after: 160 },
    shading: { type: ShadingType.SOLID, color: NAVY, fill: NAVY },
    run: { color: WHITE, bold: true, size: 28 }
  });
}

function heading2(text, color = TEAL) {
  return new Paragraph({
    children: [new TextRun({ text, bold: true, size: 26, color: WHITE })],
    heading: HeadingLevel.HEADING_2,
    spacing: { before: 320, after: 120 },
    shading: { type: ShadingType.SOLID, color, fill: color }
  });
}

function heading3(text, color = NAVY) {
  return new Paragraph({
    children: [new TextRun({ text, bold: true, size: 22, color })],
    spacing: { before: 240, after: 80 },
    border: {
      bottom: { style: BorderStyle.SINGLE, size: 4, color: TEAL }
    }
  });
}

function body(text, opts = {}) {
  return new Paragraph({
    children: [new TextRun({ text, size: 20, color: BLACK, ...opts })],
    spacing: { before: 60, after: 60 },
    indent: opts.indent ? { left: 360 } : undefined
  });
}

function bullet(text, level = 0, bold = false, color = BLACK) {
  return new Paragraph({
    children: [new TextRun({ text, size: 20, color, bold })],
    bullet: { level },
    spacing: { before: 40, after: 40 },
  });
}

function numbered(text, level = 0, bold = false, color = BLACK) {
  return new Paragraph({
    children: [new TextRun({ text, size: 20, color, bold })],
    numbering: { reference: "main-numbering", level },
    spacing: { before: 40, after: 40 },
  });
}

function labelValue(label, value) {
  return new Paragraph({
    children: [
      new TextRun({ text: label + ": ", bold: true, size: 20, color: NAVY }),
      new TextRun({ text: value, size: 20, color: BLACK })
    ],
    spacing: { before: 50, after: 50 },
    indent: { left: 360 }
  });
}

function qaQuestion(num, text) {
  return new Paragraph({
    children: [
      new TextRun({ text: `Q${num}. `, bold: true, size: 22, color: ORANGE }),
      new TextRun({ text, bold: true, size: 22, color: NAVY })
    ],
    spacing: { before: 240, after: 80 },
    shading: { type: ShadingType.SOLID, color: CREAM, fill: CREAM },
    border: {
      left: { style: BorderStyle.THICK, size: 12, color: ORANGE }
    },
    indent: { left: 160 }
  });
}

function answerIntro(text) {
  return new Paragraph({
    children: [
      new TextRun({ text: "Model Answer: ", bold: true, size: 20, color: GREEN }),
      new TextRun({ text, size: 20, color: BLACK, italic: true })
    ],
    spacing: { before: 60, after: 60 },
    indent: { left: 200 }
  });
}

function keyPoint(text) {
  return new Paragraph({
    children: [
      new TextRun({ text: "⭐  ", size: 20, color: ORANGE, bold: true }),
      new TextRun({ text, size: 20, color: NAVY, bold: true })
    ],
    spacing: { before: 60, after: 60 },
    shading: { type: ShadingType.SOLID, color: "FFF3CD", fill: "FFF3CD" },
    indent: { left: 200 }
  });
}

function examTip(text) {
  return new Paragraph({
    children: [
      new TextRun({ text: "EXAMINER'S TIP: ", bold: true, size: 19, color: RED }),
      new TextRun({ text, size: 19, color: "8B0000", italic: true })
    ],
    spacing: { before: 80, after: 80 },
    shading: { type: ShadingType.SOLID, color: "FDECEA", fill: "FDECEA" },
    border: {
      left: { style: BorderStyle.THICK, size: 10, color: RED }
    },
    indent: { left: 200 }
  });
}

function spacer(lines = 1) {
  return new Paragraph({ text: "", spacing: { before: lines * 60, after: 0 } });
}

function pageBreakPara() {
  return new Paragraph({ children: [new PageBreak()] });
}

function simpleTable(headers, rows, headerColor = NAVY) {
  const colCount = headers.length;
  const colWidth = Math.floor(9000 / colCount);

  const headerRow = new TableRow({
    tableHeader: true,
    children: headers.map(h =>
      new TableCell({
        children: [new Paragraph({ children: [new TextRun({ text: h, bold: true, size: 18, color: WHITE })], alignment: AlignmentType.CENTER })],
        shading: { type: ShadingType.SOLID, color: headerColor, fill: headerColor },
        verticalAlign: VerticalAlign.CENTER,
        width: { size: colWidth, type: WidthType.DXA }
      })
    )
  });

  const dataRows = rows.map((row, ri) =>
    new TableRow({
      children: row.map((cell, ci) =>
        new TableCell({
          children: [new Paragraph({ children: [new TextRun({ text: cell, size: 18, color: BLACK, bold: ci === 0 })], alignment: ci === 0 ? AlignmentType.LEFT : AlignmentType.LEFT })],
          shading: { type: ShadingType.SOLID, color: ri % 2 === 0 ? LTGREY : WHITE, fill: ri % 2 === 0 ? LTGREY : WHITE },
          width: { size: colWidth, type: WidthType.DXA }
        })
      )
    })
  );

  return new Table({
    width: { size: 100, type: WidthType.PERCENTAGE },
    rows: [headerRow, ...dataRows],
    margins: { top: 60, bottom: 60, left: 80, right: 80 }
  });
}

// ─── DOCUMENT CONTENT ────────────────────────────────────────────────────────
const children = [];

// ════════════════════════════════════════════════════════════════════════════
// COVER
// ════════════════════════════════════════════════════════════════════════════
children.push(
  new Paragraph({
    children: [new TextRun({ text: "POSTGRADUATE GENERAL SURGERY", bold: true, size: 36, color: WHITE, allCaps: true })],
    alignment: AlignmentType.CENTER,
    shading: { type: ShadingType.SOLID, color: NAVY, fill: NAVY },
    spacing: { before: 200, after: 0 },
    border: { top: { style: BorderStyle.THICK, size: 12, color: TEAL } }
  }),
  new Paragraph({
    children: [new TextRun({ text: "Clinical Discussion", bold: true, size: 48, color: WHITE })],
    alignment: AlignmentType.CENTER,
    shading: { type: ShadingType.SOLID, color: NAVY, fill: NAVY },
    spacing: { before: 0, after: 0 }
  }),
  new Paragraph({
    children: [new TextRun({ text: "ACUTE PANCREATITIS", bold: true, size: 56, color: TEAL, allCaps: true })],
    alignment: AlignmentType.CENTER,
    shading: { type: ShadingType.SOLID, color: NAVY, fill: NAVY },
    spacing: { before: 0, after: 0 }
  }),
  new Paragraph({
    children: [new TextRun({ text: "& Acute Pancreatic Complications", bold: false, size: 30, color: LTBLUE, italic: true })],
    alignment: AlignmentType.CENTER,
    shading: { type: ShadingType.SOLID, color: NAVY, fill: NAVY },
    spacing: { before: 0, after: 0 }
  }),
  new Paragraph({
    children: [new TextRun({ text: "Case-Based Clinical Discussion  |  Viva Voce Q&A  |  Examiner Tips", size: 20, color: "A0B8CC", italic: true })],
    alignment: AlignmentType.CENTER,
    shading: { type: ShadingType.SOLID, color: NAVY, fill: NAVY },
    spacing: { before: 60, after: 0 },
    border: { bottom: { style: BorderStyle.THICK, size: 12, color: ORANGE } }
  }),
  new Paragraph({
    children: [new TextRun({ text: "Sources: Rosen's Emergency Medicine 9e | Sleisenger & Fordtran's GI & Liver Disease | Sabiston Textbook of Surgery | ESPEN 2024 | Atlanta Classification 2012", size: 16, color: GREY, italic: true })],
    alignment: AlignmentType.CENTER,
    spacing: { before: 120, after: 400 }
  }),
  pageBreakPara()
);

// ════════════════════════════════════════════════════════════════════════════
// SECTION 1: CASE VIGNETTE 1 — MILD AP
// ════════════════════════════════════════════════════════════════════════════
children.push(
  heading1("CASE 1: Acute Biliary Pancreatitis"),
  spacer(),
  heading2("Clinical Vignette", TEAL),
  new Paragraph({
    children: [new TextRun({ text: "A 42-year-old obese female presents to casualty with a 10-hour history of severe epigastric pain radiating to the back. The pain came on suddenly after a fatty meal, and is associated with nausea and three episodes of vomiting. She has no jaundice. She has had similar but milder episodes in the past. She does not consume alcohol.", size: 20, color: BLACK })],
    spacing: { before: 80, after: 80 },
    shading: { type: ShadingType.SOLID, color: "F0F7FF", fill: "F0F7FF" },
    border: { left: { style: BorderStyle.THICK, size: 12, color: TEAL } },
    indent: { left: 200 }
  }),
  spacer(),
  heading3("Examination Findings", NAVY),
  labelValue("Vitals", "Temp 38.1°C  |  HR 108/min  |  BP 124/78 mmHg  |  RR 20/min  |  SpO2 98%"),
  labelValue("Abdomen", "Epigastric and RUQ tenderness, guarding present, no rigidity, bowel sounds sluggish"),
  labelValue("Chest", "Clear bilaterally"),
  labelValue("Jaundice", "Absent"),
  spacer(),
  heading3("Investigations", NAVY),
  simpleTable(
    ["Investigation", "Result", "Significance"],
    [
      ["Serum Lipase", "1,840 U/L (>3× ULN)", "Diagnostic — most specific enzyme"],
      ["Serum Amylase", "920 U/L (>3× ULN)", "Raised but less specific"],
      ["ALT", "186 U/L (>3× ULN)", "Biliary aetiology (94% PPV if >3×)"],
      ["Total Bilirubin", "22 µmol/L (mildly elevated)", "Suggests transient biliary obstruction"],
      ["Serum Calcium", "2.1 mmol/L", "Hypocalcaemia — severity marker"],
      ["WBC", "13.4 × 10⁹/L", "Leukocytosis — SIRS response"],
      ["Haematocrit", "44%", "Borderline — risk for necrosis"],
      ["BUN", "7.2 mmol/L", "Normal at admission"],
      ["CRP", "28 mg/L (on admission)", "Rises — recheck at 48h"],
      ["Serum Glucose", "8.1 mmol/L", "Mild hyperglycaemia"],
      ["Triglycerides", "1.8 mmol/L", "Normal — not causative"],
      ["USS Abdomen", "Gallbladder calculi, CBD 7 mm, no obvious stone, oedematous pancreas", "Confirms biliary aetiology"],
    ]
  ),
  spacer(),
  pageBreakPara()
);

// ─── VIVA Q&A FOR CASE 1 ────────────────────────────────────────────────────
children.push(
  heading2("Viva Voce Discussion — Case 1", NAVY),
  spacer(),

  qaQuestion(1, "How do you establish the diagnosis of acute pancreatitis?"),
  answerIntro("Two of three criteria must be satisfied:"),
  bullet("Characteristic epigastric pain radiating to the back", 0, true, NAVY),
  bullet("Serum lipase or amylase ≥ 3× upper limit of normal", 0, true, NAVY),
  bullet("Characteristic imaging findings (CT or MRI) — only if the first two are absent", 0, true, NAVY),
  body("In this patient: criteria 1 and 2 are both met. Imaging is NOT required to diagnose AP."),
  keyPoint("Lipase is preferred over amylase — more specific, stays elevated longer. Amylase may be normal in alcoholic AP and hypertriglyceridaemia-induced AP."),
  examTip("Examiners commonly ask: 'What is the single best enzyme to diagnose AP?' — Answer: Serum lipase."),
  spacer(),

  qaQuestion(2, "What is the most likely aetiology in this patient and how do you confirm it?"),
  answerIntro("Gallstone (biliary) pancreatitis — most likely given:"),
  bullet("Obese female, fatty meal trigger, prior similar episodes", 1),
  bullet("ALT >3× ULN — 94% PPV for gallstone aetiology", 1),
  bullet("Gallstones on ultrasound + dilated CBD (7 mm)", 1),
  body("Confirmation: Ultrasound is first-line. If CBD stones not visualised, proceed to MRCP or EUS. Avoid routine early ERCP unless cholangitis or obstruction is present."),
  keyPoint("ALT >3× ULN in context of AP = biliary aetiology until proven otherwise."),
  examTip("Gallstones (40–70%) and alcohol (25–35%) account for the majority of AP cases worldwide. Know how to distinguish them clinically."),
  spacer(),

  qaQuestion(3, "How do you classify the severity of this attack and what scoring system would you use?"),
  answerIntro("Use the Revised Atlanta Classification 2012:"),
  simpleTable(
    ["Grade", "Criteria"],
    [
      ["Mild", "No organ failure; no local or systemic complications"],
      ["Moderately Severe", "Transient organ failure (<48h) OR local complications"],
      ["Severe", "Persistent organ failure (>48h) — modified Marshall score ≥2"]
    ]
  ),
  spacer(),
  body("Bedside scoring systems for severity:"),
  simpleTable(
    ["Score", "Components", "Severe Threshold", "Best Used"],
    [
      ["Ranson", "5 admission + 6 at 48h criteria", "≥3", "48h after admission"],
      ["APACHE II", "15 physiological variables", "≥8", "ICU, any time"],
      ["BISAP", "BUN, mental status, SIRS, Age, Pleural effusion", "≥3", "ED / admission"],
      ["Modified CTSI", "Inflammation grade + necrosis on CT", "≥4", "After CT imaging"],
      ["HAPS", "Peritonitis, Creatinine, Haematocrit", "Any positive = not harmless", "To identify mild AP"],
    ]
  ),
  spacer(),
  body("In this patient: HR 108 (SIRS), Hct 44%, BUN normal, no organ failure — likely mild/moderately severe. Reassess at 48h."),
  keyPoint("CRP >150 mg/L at 48h is the most reliable single serum marker for severe AP."),
  examTip("Know all five severity scoring systems by name and their cut-offs. Ranson and BISAP are most commonly asked."),
  spacer(),

  qaQuestion(4, "What is your immediate management plan?"),
  answerIntro("Management is primarily supportive:"),
  numbered("IV Fluid Resuscitation — cornerstone of treatment", 0, true, NAVY),
  bullet("Goal-directed: HR <120, MAP 65–85 mmHg, urine output >0.5–1 mL/kg/h", 1),
  bullet("Rate: 5–10 mL/kg/h (IAP/APA); ACG recommends 250–500 mL/h", 1),
  bullet("Preferred fluid: Lactated Ringer's (LR) — anti-inflammatory; NS causes hyperchloraemic acidosis which activates trypsinogen and worsens SIRS", 1),
  numbered("Analgesia", 0, true, NAVY),
  bullet("IV opioid analgesia (morphine or hydromorphone)", 1),
  bullet("PCA for severe pain", 1),
  bullet("Meperidine (pethidine) no longer preferred", 1),
  numbered("Nil by mouth (initially), then early oral feeding", 0, true, NAVY),
  bullet("Mild AP: advance oral diet as tolerated — DO NOT enforce prolonged NPO", 1),
  bullet("Clear liquids → soft diet as symptoms allow", 1),
  numbered("Anti-emetics: ondansetron or metoclopramide", 0, true, NAVY),
  numbered("Monitor: vitals, urine output (catheterise), BUN, creatinine, CRP at 48h", 0, true, NAVY),
  numbered("Ultrasound: already done — confirms biliary aetiology", 0, true, NAVY),
  numbered("Antibiotics: NOT indicated in uncomplicated AP (no prophylactic benefit)", 0, true, RED),
  keyPoint("LR > Normal Saline for fluid resuscitation in AP — this is a commonly examined topic."),
  examTip("Do not give prophylactic antibiotics in AP. This is a classic examiner trap."),
  spacer(),

  qaQuestion(5, "When is ERCP indicated and what is your plan for the gallstones?"),
  answerIntro("ERCP is NOT routinely indicated in biliary AP."),
  body("ERCP is indicated ONLY in:"),
  bullet("Acute cholangitis with biliary AP → urgent ERCP within 24–48 hours", 1),
  bullet("Biliary obstruction (elevated bilirubin + clinical cholangitis) → ERCP within 72 hours", 1),
  body("This patient has no cholangitis (no fever-jaundice-RUQ pain triad of Charcot) and no persistent obstruction — ERCP is NOT indicated now."),
  body("Plan for gallstones:"),
  bullet("Early laparoscopic cholecystectomy within 3 days of admission (mild biliary AP) — this is the standard of care", 1, true, GREEN),
  bullet("Reduces recurrence risk and avoids need for ERCP", 1),
  bullet("Do NOT wait for enzyme normalisation before cholecystectomy in mild AP", 1),
  bullet("If unfit for surgery: ERCP with biliary sphincterotomy as alternative", 1),
  keyPoint("Early cholecystectomy (same admission) is MANDATORY in gallstone AP. Do not discharge without definitive management."),
  examTip("A very common exam question: 'What is the definitive management of biliary pancreatitis?' — Laparoscopic cholecystectomy, ideally same admission."),
  spacer(),
  pageBreakPara()
);

// ════════════════════════════════════════════════════════════════════════════
// SECTION 2: CASE VIGNETTE 2 — SEVERE/NECROTISING AP
// ════════════════════════════════════════════════════════════════════════════
children.push(
  heading1("CASE 2: Severe Necrotising Pancreatitis"),
  spacer(),
  heading2("Clinical Vignette", TEAL),
  new Paragraph({
    children: [new TextRun({ text: "A 52-year-old male chronic alcoholic is brought to the emergency department with severe central abdominal pain for 3 days, progressively worsening. He has been unable to eat or drink for 48 hours. On examination he is restless, jaundiced, tachycardic (HR 128/min), hypotensive (BP 86/52), febrile (39.2°C), and oliguric (UO 10 mL/h). Abdomen is rigid with involuntary guarding. Both flanks show reddish-brown discolouration.", size: 20, color: BLACK })],
    spacing: { before: 80, after: 80 },
    shading: { type: ShadingType.SOLID, color: "FFF5F5", fill: "FFF5F5" },
    border: { left: { style: BorderStyle.THICK, size: 12, color: RED } },
    indent: { left: 200 }
  }),
  spacer(),
  heading3("Examination Findings", NAVY),
  labelValue("Vitals", "Temp 39.2°C  |  HR 128/min  |  BP 86/52 mmHg  |  RR 26/min  |  SpO2 91% on air"),
  labelValue("Flanks", "Grey Turner sign positive (reddish-brown retroperitoneal haemorrhage)"),
  labelValue("Abdomen", "Rigid, diffuse guarding, rebound tenderness, absent bowel sounds"),
  labelValue("Urine output", "10 mL/h — oliguria"),
  spacer(),
  heading3("Investigations", NAVY),
  simpleTable(
    ["Investigation", "Result", "Significance"],
    [
      ["Serum Lipase", "3,200 U/L", "Diagnostic of AP"],
      ["WBC", "24.0 × 10⁹/L", "Severe SIRS/sepsis"],
      ["Haematocrit", "48%", "Haemoconcentration → necrosis risk"],
      ["BUN", "18 mmol/L", "Elevated → poor prognosis"],
      ["Serum Creatinine", "310 µmol/L (rising)", "AKI — organ failure"],
      ["Serum Ca²⁺", "1.6 mmol/L", "Hypocalcaemia (fat saponification)"],
      ["CRP", "268 mg/L at 48h", "Severe AP (>150 = severe)"],
      ["PaO2", "61 mmHg on air", "Hypoxaemia → ARDS risk"],
      ["Procalcitonin", "4.8 ng/mL", "Suggests infected necrosis"],
      ["Prothrombin time", "18 sec", "Coagulopathy"],
      ["ALT/AST", "Normal", "Unlikely biliary — alcohol aetiology"],
      ["Contrast-enhanced CT", "Necrosis of 60% of pancreatic parenchyma + peripancreatic fluid + gas bubbles in necrotic area", "Infected necrotising pancreatitis"],
      ["Blood cultures", "Pending", "E. coli and Klebsiella likely"],
    ]
  ),
  spacer(),
  pageBreakPara()
);

// ─── VIVA Q&A FOR CASE 2 ────────────────────────────────────────────────────
children.push(
  heading2("Viva Voce Discussion — Case 2", NAVY),
  spacer(),

  qaQuestion(6, "How do you classify this patient's acute pancreatitis and why?"),
  answerIntro("This is SEVERE acute pancreatitis by the Revised Atlanta Classification 2012:"),
  bullet("Persistent organ failure (>48h):", 0, true, RED),
  bullet("Respiratory: PaO2 61 mmHg (hypoxaemia)", 1),
  bullet("Cardiovascular: BP 86/52 (hypotension, MAP <65)", 1),
  bullet("Renal: Creatinine 310 µmol/L, oliguria (AKI)", 1),
  bullet("Modified Marshall score ≥2 for all three systems", 0, true, RED),
  bullet("Local complication: Necrotising pancreatitis with infected collection (gas on CT)", 0, true, RED),
  spacer(),
  body("Severity scores:"),
  bullet("Ranson criteria: Age >55 ✓, WBC >16,000 ✓, glucose, LDH — likely ≥5 points = predicted mortality >40%", 1),
  bullet("APACHE II: multiple abnormal variables — likely ≥8", 1),
  bullet("BISAP: BUN elevated ✓, SIRS ✓, Age >60 — likely ≥3", 1),
  bullet("Modified CTSI: 60% necrosis (4 pts) + extrapancreatic complications (+2) = 6 → Severe", 1),
  keyPoint("Grey Turner sign (flank ecchymosis) = retroperitoneal haemorrhage. Rare but when present signals severe necrotising AP with poor prognosis."),
  examTip("Always define 'severe AP' using the Atlanta 2012 definition (persistent organ failure >48h). Do not use outdated definitions."),
  spacer(),

  qaQuestion(7, "What are the pathological types of AP and the Atlanta morphological classification of fluid collections?"),
  answerIntro("Two pathological types:"),
  bullet("Interstitial Oedematous Pancreatitis (80–90%) — pancreatic oedema, no parenchymal necrosis; usually self-limiting", 1),
  bullet("Necrotising Pancreatitis (5–10%) — nonviable pancreatic parenchyma ± peripancreatic fat necrosis; CT: non-enhancing areas <40–50 HU (normal 100–150 HU)", 1),
  spacer(),
  simpleTable(
    ["Subtype", "< 4 Weeks", "> 4 Weeks"],
    [
      ["Interstitial Edematous", "Acute Peripancreatic Fluid Collection (APFC)\n- No wall, homogeneous fluid\n- Confined to fascial planes", "Pseudocyst\n- Encapsulated, well-defined wall\n- Homogeneous fluid, no solid debris\n- Round/oval"],
      ["Necrotising", "Acute Necrotic Collection (ANC)\n- Heterogeneous, liquid + solid\n- No definable wall\n- Intra/extra-pancreatic", "Walled-Off Necrosis (WON)\n- Mixed liquid/solid content\n- Encapsulated with well-defined wall\n- ≥4 weeks to form"]
    ]
  ),
  spacer(),
  keyPoint("Pseudocyst = no solid debris. WON = solid + liquid debris. This distinction is critical — misidentifying WON as pseudocyst leads to inadequate drainage."),
  examTip("'What is the difference between a pseudocyst and walled-off necrosis?' — A very commonly asked examiner question."),
  spacer(),

  qaQuestion(8, "How does infected pancreatic necrosis develop and how do you diagnose it?"),
  answerIntro("Pathophysiology of infected necrosis:"),
  bullet("Mucosal ischaemia from SIRS → increased intestinal permeability → bacterial translocation (peaks ~1 week after onset)", 1),
  bullet("Organisms: gram-negative rods (E. coli, Klebsiella, Pseudomonas) and Enterococcus spp.", 1),
  bullet("Risk correlates with extent of necrosis:", 1),
  body("  <30% necrosis → 22% infection risk  |  30–50% → 37%  |  >70% → 46%", { bold: false }),
  spacer(),
  body("Diagnosis:"),
  bullet("Gas within necrotic collection on CT (without prior instrumentation) = pathognomonic", 0, true, GREEN),
  bullet("FNA (CT-guided fine needle aspiration) — Gram stain + culture: positive = confirmatory", 0),
  bullet("Negative FNA does not exclude infection — 42% of 'persistent unwellness' cases with negative cultures still have infected necrosis on operation", 0),
  bullet("Clinical suspicion: fever, leukocytosis, sepsis, clinical deterioration after day 7–10", 0),
  keyPoint("Gas in pancreatic necrosis on CT without prior instrumentation = infected necrosis until proven otherwise. Act immediately."),
  examTip("This patient has gas in the necrotic area on CT. Diagnosis of infected necrosis is confirmed. What is your management? → Step-up approach."),
  spacer(),

  qaQuestion(9, "Describe the step-up approach to management of infected necrotising pancreatitis."),
  answerIntro("The step-up approach is the current standard of care, delaying open surgery:"),
  spacer(),
  simpleTable(
    ["Step", "Intervention", "Timing", "Key Points"],
    [
      ["1", "IV Antibiotics", "Immediately", "Carbapenems (imipenem/meropenem) first-line\nAlternatives: quinolones + metronidazole, pip-tazo, 3rd gen cephalosporins\nAll penetrate pancreatic necrosis"],
      ["2", "Percutaneous / Endoscopic Drainage", "Delay as long as possible; ideal after WON forms (≥4 wks)", "CT-guided percutaneous catheter drain\nOR EUS-guided transmural endoscopic drainage\nAllows collection to liquefy — easier drainage"],
      ["3", "Minimally Invasive Necrosectomy", "Only if step 2 fails", "Video-Assisted Retroperitoneal Debridement (VARD)\nEndoscopic transluminal necrosectomy\nLaparoscopic transgastric necrosectomy"],
      ["4", "Open Surgical Necrosectomy", "Last resort — step 3 fails or emergency", "Highest morbidity/mortality\nTechniques: closed continuous irrigation, open packing\nMortality historically 20–40%"]
    ]
  ),
  spacer(),
  body("For sterile necrosis (no infection):"),
  bullet("Conservative management in majority of cases", 1),
  bullet("Intervene only if: persistent pain, failure to improve, biliary or enteric obstruction", 1),
  bullet("Delay any intervention to allow WON formation", 1),
  keyPoint("Step-up approach: antibiotics → drain → minimal invasive necrosectomy → open surgery. Delayed intervention = better outcomes."),
  examTip("'Why delay surgery in infected necrosis?' — Waiting for WON formation (≥4 weeks) allows the necrosis to become better demarcated, reducing surgical risk and improving drainage."),
  spacer(),

  qaQuestion(10, "How do you manage this patient's multi-organ failure?"),
  answerIntro("ICU admission is mandatory. Organ-by-organ approach:"),
  numbered("Fluid Resuscitation (CVS support)", 0, true, NAVY),
  bullet("Goal-directed LR resuscitation: MAP ≥65 mmHg, UO ≥0.5 mL/kg/h", 1),
  bullet("Vasopressors (noradrenaline) if fluid-refractory hypotension", 1),
  numbered("Respiratory", 0, true, NAVY),
  bullet("High-flow O2 → Non-invasive ventilation (CPAP/BiPAP) → Mechanical ventilation if ARDS develops", 1),
  bullet("PaO2/FiO2 ratio <200 = ARDS — lung-protective ventilation strategy", 1),
  numbered("Renal", 0, true, NAVY),
  bullet("IV fluids to optimise renal perfusion; avoid nephrotoxic drugs", 1),
  bullet("Renal replacement therapy (RRT) if AKI worsens or refractory acidosis", 1),
  numbered("Nutrition", 0, true, NAVY),
  bullet("Enteral nutrition PREFERRED over TPN (ESPEN 2024)", 1, true, GREEN),
  bullet("NG feeding as effective as nasojejunal in most; NJ preferred if gastroparesis/duodenal oedema", 1),
  bullet("TPN only if enteral route completely impossible", 1),
  numbered("Coagulopathy / DIC", 0, true, NAVY),
  bullet("FFP, platelets, cryoprecipitate as needed; haematology input", 1),
  numbered("Metabolic corrections", 0, true, NAVY),
  bullet("IV calcium gluconate for symptomatic hypocalcaemia", 1),
  bullet("Insulin infusion for hyperglycaemia (target 6–10 mmol/L)", 1),
  bullet("Magnesium, potassium replacement", 1),
  keyPoint("Enteral nutrition is superior to TPN in severe AP — lower infection rate, lower cost, maintains gut mucosal integrity reducing bacterial translocation."),
  examTip("Know the rationale for enteral over parenteral nutrition: it maintains the gut mucosal barrier, reducing bacterial translocation that drives infected necrosis."),
  spacer(),
  pageBreakPara()
);

// ════════════════════════════════════════════════════════════════════════════
// SECTION 3: CASE 3 — PANCREATIC PSEUDOCYST
// ════════════════════════════════════════════════════════════════════════════
children.push(
  heading1("CASE 3: Pancreatic Pseudocyst"),
  spacer(),
  heading2("Clinical Vignette", TEAL),
  new Paragraph({
    children: [new TextRun({ text: "A 38-year-old male presents 6 weeks after an episode of alcohol-induced acute pancreatitis. He complains of persistent epigastric pain, early satiety, nausea, and a 4 kg weight loss. On examination there is a palpable epigastric mass. CT abdomen shows a 9 cm well-defined, thin-walled, homogeneous fluid collection adjacent to the body of the pancreas with no internal solid debris.", size: 20, color: BLACK })],
    spacing: { before: 80, after: 80 },
    shading: { type: ShadingType.SOLID, color: "F0FFF0", fill: "F0FFF0" },
    border: { left: { style: BorderStyle.THICK, size: 12, color: GREEN } },
    indent: { left: 200 }
  }),
  spacer(),
  heading2("Viva Voce Discussion — Case 3", NAVY),
  spacer(),

  qaQuestion(11, "What is the diagnosis? How do you distinguish it from walled-off necrosis?"),
  answerIntro("Diagnosis: Pancreatic pseudocyst — a large (9 cm), symptomatic collection."),
  spacer(),
  simpleTable(
    ["Feature", "Pseudocyst", "Walled-Off Necrosis (WON)"],
    [
      ["Timing", "≥4 weeks after interstitial AP", "≥4 weeks after necrotising AP"],
      ["Content", "Homogeneous fluid only", "Mixed fluid + solid necrotic debris"],
      ["Wall", "Well-defined, thin, smooth", "Well-defined wall, thicker"],
      ["CT density", "Fluid density throughout", "Heterogeneous — solid areas present"],
      ["Origin", "Ductal leak ± fat necrosis", "Necrotic pancreatic/peripancreatic tissue"],
      ["Management", "Drainage (endoscopic preferred)", "Drainage ± necrosectomy for WON"],
    ]
  ),
  spacer(),
  keyPoint("CT characterisation is essential. Endoscopic drainage of WON without debridement will fail — mistake it for pseudocyst at your peril."),
  examTip("Always distinguish pseudocyst (no debris) from WON (solid + liquid debris) on CT before planning drainage."),
  spacer(),

  qaQuestion(12, "What are the indications for draining a pseudocyst and what are the options?"),
  answerIntro("Indications for drainage:"),
  bullet("Symptomatic (pain, nausea, early satiety, weight loss) — as in this patient", 0, true),
  bullet("Infected pseudocyst (fever, sepsis)", 0, true),
  bullet("Enlarging collection", 0, true),
  bullet("Causing biliary or gastric outlet obstruction", 0, true),
  bullet("Pseudoaneurysm within collection (requires angioembolisation first)", 0, true),
  body("Asymptomatic pseudocysts: observe — majority resolve spontaneously."),
  spacer(),
  body("Drainage options:"),
  simpleTable(
    ["Method", "Indication", "Pros / Cons"],
    [
      ["EUS-guided endoscopic transmural drainage", "Collection adjacent to stomach/duodenum (≤1 cm from wall) — preferred", "Minimally invasive, low recurrence, allows stent; needs EUS expertise"],
      ["Percutaneous CT-guided drainage", "Collection not adjacent to GI wall; infected collection", "Less invasive; may need prolonged catheter; higher recurrence"],
      ["Surgical cystenterostomy (cystgastrostomy / cystjejunostomy)", "Failed endoscopic/percutaneous; disconnected pancreatic duct syndrome", "Definitive; higher morbidity than endoscopic"],
    ]
  ),
  spacer(),
  keyPoint("Endoscopic (EUS-guided) drainage is the preferred first-line approach for symptomatic pseudocysts adjacent to the gastric/duodenal wall."),
  examTip("Mention 'disconnected pancreatic duct syndrome' — ERCP to assess pancreatic duct integrity before surgery is important for surgical planning."),
  spacer(),
  pageBreakPara()
);

// ════════════════════════════════════════════════════════════════════════════
// SECTION 4: RAPID-FIRE VIVA QUESTIONS
// ════════════════════════════════════════════════════════════════════════════
children.push(
  heading1("Rapid-Fire Viva Questions"),
  spacer(),
  heading2("Short Answer Q&A", ORANGE),
  spacer(),

  qaQuestion(13, "Name four systemic complications of acute pancreatitis."),
  bullet("Pulmonary: ARDS, pleural effusion (left-sided > right, up to 50%), atelectasis", 0),
  bullet("Cardiovascular: hypovolaemic shock, need for vasopressors", 0),
  bullet("Renal: acute kidney injury (AKI) — hypoperfusion + inflammatory mediators", 0),
  bullet("Haematologic: DIC, coagulopathy, thrombocytopenia", 0),
  bullet("Metabolic: hypocalcaemia, hyperglycaemia, hypomagnesaemia", 0),
  spacer(),

  qaQuestion(14, "What antibiotics penetrate pancreatic necrosis?"),
  bullet("Carbapenems (imipenem, meropenem) — FIRST LINE", 0, true, GREEN),
  bullet("Fluoroquinolones (ciprofloxacin) + metronidazole", 0),
  bullet("Third-generation cephalosporins", 0),
  bullet("Piperacillin-tazobactam", 0),
  keyPoint("Prophylactic antibiotics are NOT indicated in sterile AP — no survival benefit shown in RCTs."),
  spacer(),

  qaQuestion(15, "What is the modified Marshall score and what does it measure?"),
  body("The Modified Marshall Score measures organ failure severity in AP across three systems:"),
  simpleTable(
    ["System", "Score 0", "Score 1", "Score 2", "Score 3", "Score 4"],
    [
      ["Respiratory (PaO2/FiO2)", ">400", "301–400", "201–300", "101–200", "≤101"],
      ["Renal (Cr µmol/L)", "<134", "134–169", "170–310", "311–439", ">439"],
      ["Cardiovascular (MAP)", "No hypotension", "Fluid responsive", "Dopamine <5 or dobutamine any dose", "Dopamine >5, epi, norepi ≤0.1", "epi/norepi >0.1"]
    ]
  ),
  spacer(),
  body("Score ≥2 in any system = organ failure. Persistent ≥48h = Severe AP (Atlanta 2012)."),
  spacer(),

  qaQuestion(16, "What are Cullen's and Grey Turner's signs? What do they indicate?"),
  bullet("Cullen sign: periumbilical bluish-black ecchymosis — haemoperitoneum tracking along falciform ligament", 0),
  bullet("Grey Turner sign: reddish-brown ecchymosis over the flanks — retroperitoneal haemorrhage tracking to flank", 0),
  bullet("Both are rare (<3%), neither sensitive nor specific", 0),
  bullet("When present: poor prognostic sign — indicates haemorrhagic necrotising AP", 0),
  examTip("These signs can appear 1–2 days after onset. Their presence mandates ICU-level care."),
  spacer(),

  qaQuestion(17, "What is BISAP score and how is it calculated?"),
  body("BISAP = Bedside Index of Severity in Acute Pancreatitis. Score 1 point for each:"),
  simpleTable(
    ["Letter", "Component", "Threshold"],
    [
      ["B", "Blood Urea Nitrogen (BUN)", ">25 mg/dL (>8.9 mmol/L)"],
      ["I", "Impaired mental status (GCS <15)", "Any alteration"],
      ["S", "SIRS criteria (≥2 of 4)", "Temp, HR, RR, WBC"],
      ["A", "Age", ">60 years"],
      ["P", "Pleural effusion on imaging", "Any pleural effusion"]
    ]
  ),
  spacer(),
  body("Score ≥3 = high risk for severe AP, ICU, mortality. Advantage: calculable at ED admission."),
  spacer(),

  qaQuestion(18, "What is the role of CT in acute pancreatitis?"),
  body("CT is NOT routine in AP. It is indicated only in:"),
  bullet("Diagnostic uncertainty (atypical pain, normal enzymes with high clinical suspicion)", 0),
  bullet("Rule out other intra-abdominal catastrophe (perforated viscus, AAA)", 0),
  bullet("Assess complications in patients not improving after 48–72 hours of treatment", 0),
  body("Best timing: 3–7 days after onset (early CT underestimates necrosis)."),
  body("CT Severity Index (CTSI): pancreatic inflammation (0–4) + necrosis (0–4) + extrapancreatic complications (+2)."),
  body("Sensitivity/specificity of contrast-enhanced CT for AP: >90%."),
  examTip("Never order routine CT in mild AP — increased cost, radiation, no management benefit. State this clearly in viva."),
  spacer(),

  qaQuestion(19, "What is post-ERCP pancreatitis? How is it prevented?"),
  body("Post-ERCP pancreatitis (PEP) occurs in 3–5% of ERCPs (up to 15% in high-risk patients)."),
  body("Prevention strategies:"),
  bullet("Rectal indomethacin (100 mg) — MOST effective pharmacological prophylaxis (standard of care)", 0, true, GREEN),
  bullet("Aggressive IV hydration with LR peri-procedurally", 0),
  bullet("Pancreatic duct stent placement in high-risk cases (e.g., difficult cannulation)", 0),
  bullet("Guidewire-assisted cannulation over contrast injection", 0),
  bullet("Limit contrast injection into pancreatic duct", 0),
  keyPoint("Rectal indomethacin is the single most important intervention for preventing post-ERCP pancreatitis."),
  spacer(),

  qaQuestion(20, "How do you manage a pancreatic pseudoaneurysm?"),
  body("Pseudoaneurysm complicates AP from erosion of peripancreatic vessels (splenic artery most common, then hepatic, gastroduodenal)."),
  body("Presentation: GI bleeding, haemoperitoneum, haemobilia, or haemorrhage into pseudocyst."),
  body("Management:"),
  bullet("Emergency angiography + transcatheter arterial embolisation (TAE) — treatment of choice (90%+ success rate)", 0, true, GREEN),
  bullet("Surgery (ligation + drainage) if angioembolisation fails or unavailable", 0),
  bullet("NEVER attempt endoscopic drainage of a pseudocyst before ruling out pseudoaneurysm (risk of fatal haemorrhage)", 0, true, RED),
  keyPoint("Always perform contrast-enhanced CT before draining any pseudocyst to exclude a pseudoaneurysm."),
  spacer(),
  pageBreakPara()
);

// ════════════════════════════════════════════════════════════════════════════
// SECTION 5: SUMMARY REFERENCE TABLES
// ════════════════════════════════════════════════════════════════════════════
children.push(
  heading1("Summary Reference Tables"),
  spacer(),
  heading2("Ranson Criteria", NAVY),
  body("Score ≥3 = Severe AP. Predicted mortality: 0–2 signs <1%; 3–4 signs 15%; 5–6 signs 40%; >6 signs ~100%."),
  spacer(),
  simpleTable(
    ["On Admission (5 criteria)", "At 48 Hours (6 criteria)"],
    [
      ["Age >55 years", "BUN rise >1.8 mmol/L (>5 mg/dL)"],
      ["WBC >16,000/mm³", "Serum calcium <2 mmol/L (<8 mg/dL)"],
      ["Serum glucose >11.1 mmol/L (>200 mg/dL)", "PaO2 <60 mmHg"],
      ["Serum LDH >350 IU/L", "Base deficit >4 mEq/L"],
      ["Serum AST >250 IU/L", "Fluid sequestration >6 L"],
      ["", "Haematocrit drop >10%"]
    ]
  ),
  spacer(),
  heading2("Differential Diagnosis of Acute Pancreatitis", NAVY),
  simpleTable(
    ["Condition", "Distinguishing Features"],
    [
      ["Perforated peptic ulcer", "Sudden onset; free air on CXR/CT; amylase may be mildly elevated"],
      ["Acute cholecystitis", "RUQ pain; positive Murphy's sign; USS shows gallbladder wall thickening; normal lipase"],
      ["Mesenteric ischaemia", "Older patient; AF; pain out of proportion to signs; CT angiography"],
      ["Aortic dissection / AAA", "Tearing back pain; unequal pulses; CT aortogram"],
      ["Bowel obstruction", "Colicky pain; distension; air-fluid levels on AXR/CT"],
      ["Inferior MI", "ECG changes; troponin; referred epigastric pain"],
      ["Ectopic pregnancy", "Female; urine β-hCG; pelvic USS"]
    ]
  ),
  spacer(),
  heading2("Complications Summary", NAVY),
  simpleTable(
    ["Category", "Complication", "Management"],
    [
      ["Local (<4 wks)", "APFC — acute peripancreatic fluid collection", "Usually resolves spontaneously"],
      ["Local (<4 wks)", "ANC — acute necrotic collection", "Conservative / drain if infected (step-up)"],
      ["Local (>4 wks)", "Pseudocyst", "Drain if symptomatic/infected/enlarging — EUS preferred"],
      ["Local (>4 wks)", "Walled-off necrosis (WON)", "Step-up: drain → necrosectomy (VARD/endoscopic → open)"],
      ["Vascular", "Pseudoaneurysm (splenic artery)", "Angioembolisation first-line; surgery if failed"],
      ["Vascular", "Splenic/portal vein thrombosis", "Anticoagulation; portal HTN management if late"],
      ["Systemic", "ARDS", "Lung-protective ventilation; O2 support; diuretics"],
      ["Systemic", "AKI", "IV fluids; avoid nephrotoxins; RRT if severe"],
      ["Systemic", "DIC / Coagulopathy", "FFP, platelets, cryoprecipitate; haematology input"],
      ["Systemic", "Hypocalcaemia", "IV calcium gluconate (symptomatic); monitor ECG"],
      ["GI", "Gastric outlet obstruction", "NG decompression; parenteral nutrition; treat underlying collection"],
      ["GI", "GI haemorrhage", "Angiography + embolisation; exclude pseudoaneurysm"],
    ]
  ),
  spacer(),
  heading2("Key Guidelines & References", NAVY),
  bullet("Banks PA et al. Revised Atlanta Classification 2012. Gut. 2013;62:102–111.", 0),
  bullet("IAP/APA Evidence-Based Guidelines. Pancreatology. 2013;13:e1–e15.", 0),
  bullet("Arvanitakis M et al. ESPEN Practical Guideline on Nutrition in Pancreatitis. Clin Nutr. 2024 Feb. PMID: 38169174.", 0),
  bullet("Trikudanathan G et al. Diagnosis and Management of Acute Pancreatitis. Gastroenterology. 2024 Sep. PMID: 38759844.", 0),
  bullet("Beij A et al. Evidence-Based Management and Recent Trends in AP. United European Gastroenterol J. 2025 Feb. PMID: 39804691.", 0),
  bullet("Rosen's Emergency Medicine, 9th Edition, Chapter 77.", 0),
  bullet("Sabiston Textbook of Surgery, 21st Edition, Chapter 92.", 0),
  bullet("Sleisenger & Fordtran's Gastrointestinal and Liver Disease, 11th Edition.", 0),
  spacer(),
  new Paragraph({
    children: [
      new TextRun({ text: "Prepared for Postgraduate General Surgery Clinical Discussion", bold: true, size: 18, color: WHITE })
    ],
    alignment: AlignmentType.CENTER,
    shading: { type: ShadingType.SOLID, color: NAVY, fill: NAVY },
    spacing: { before: 200, after: 200 },
    border: {
      top: { style: BorderStyle.THICK, size: 8, color: TEAL },
      bottom: { style: BorderStyle.THICK, size: 8, color: TEAL }
    }
  })
);

// ─── BUILD DOCUMENT ──────────────────────────────────────────────────────────
const doc = new Document({
  numbering: {
    config: [
      {
        reference: "main-numbering",
        levels: [
          { level: 0, format: LevelFormat ? LevelFormat.DECIMAL : "decimal", text: "%1.", alignment: AlignmentType.START, style: { paragraph: { indent: { left: 360, hanging: 260 } } } }
        ]
      }
    ]
  },
  styles: {
    default: {
      document: {
        run: { font: "Calibri", size: 20, color: BLACK },
        paragraph: { spacing: { line: 276 } }
      }
    },
    paragraphStyles: [
      {
        id: "Heading1",
        name: "Heading 1",
        basedOn: "Normal",
        run: { bold: true, size: 28, color: WHITE, font: "Calibri" },
        paragraph: {
          spacing: { before: 400, after: 160 },
          shading: { type: ShadingType.SOLID, color: NAVY, fill: NAVY }
        }
      },
      {
        id: "Heading2",
        name: "Heading 2",
        basedOn: "Normal",
        run: { bold: true, size: 24, color: WHITE, font: "Calibri" },
        paragraph: {
          spacing: { before: 300, after: 120 }
        }
      },
      {
        id: "Heading3",
        name: "Heading 3",
        basedOn: "Normal",
        run: { bold: true, size: 22, color: NAVY, font: "Calibri" },
        paragraph: {
          spacing: { before: 240, after: 80 }
        }
      }
    ]
  },
  sections: [
    {
      properties: {
        page: {
          margin: { top: 720, right: 900, bottom: 720, left: 900 },
          size: { width: 12240, height: 15840 }
        }
      },
      headers: {
        default: new Header({
          children: [
            new Paragraph({
              children: [
                new TextRun({ text: "PG General Surgery Clinical Discussion — Acute Pancreatitis", size: 18, color: GREY, italic: true }),
              ],
              border: { bottom: { style: BorderStyle.SINGLE, size: 4, color: TEAL } }
            })
          ]
        })
      },
      footers: {
        default: new Footer({
          children: [
            new Paragraph({
              children: [
                new TextRun({ text: "Rosen's EM 9e | Sleisenger & Fordtran | Sabiston Surgery | Atlanta 2012 | ESPEN 2024          Page ", size: 16, color: GREY }),
                new TextRun({ children: [PageNumber.CURRENT], size: 16, color: GREY }),
                new TextRun({ text: " / ", size: 16, color: GREY }),
                new TextRun({ children: [PageNumber.TOTAL_PAGES], size: 16, color: GREY })
              ],
              alignment: AlignmentType.RIGHT,
              border: { top: { style: BorderStyle.SINGLE, size: 4, color: TEAL } }
            })
          ]
        })
      },
      children
    }
  ]
});

Packer.toBuffer(doc).then(buffer => {
  fs.writeFileSync("/home/daytona/workspace/acute-pancreatitis-clinics/Acute_Pancreatitis_PG_Surgery_Clinics.docx", buffer);
  console.log("SUCCESS: File written.");
}).catch(e => {
  console.error("ERROR:", e.message);
  process.exit(1);
});
Running Command

cd /home/daytona/workspace/acute-pancreatitis-clinics && node generate.js 2>&1

Editing File

~/acute-pancreatitis-clinics/generate.js

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

cd /home/daytona/workspace/acute-pancreatitis-clinics && node generate.js 2>&1

Running Command

ls -lh /home/daytona/workspace/acute-pancreatitis-clinics/Acute_Pancreatitis_PG_…

Your clinical discussion document is ready. Download it here:

Acute Pancreatitis PG Surgery Clinics

Word Document · DOCX


What's inside:
The document is formatted as a full postgraduate general surgery clinical discussion (clinics) resource, with:
3 Clinical Cases with Full Workups
CaseScenario
Case 142F with acute biliary pancreatitis — mild/moderate
Case 252M with severe necrotising pancreatitis + MOF + infected necrosis
Case 338M with pancreatic pseudocyst at 6 weeks post-AP
20 Viva Voce Questions with Model Answers, including:
  • How to diagnose AP (2-of-3 rule)
  • Biliary vs alcoholic aetiology
  • Revised Atlanta Classification 2012
  • All 5 severity scoring systems (Ranson, APACHE II, BISAP, CTSI, HAPS)
  • Fluid management (LR vs NS — why it matters)
  • ERCP indications and timing
  • Infected necrosis: step-up approach (drain → VARD → open)
  • Pseudocyst vs WON distinction
  • Pseudoaneurysm management
  • Post-ERCP pancreatitis prevention (rectal indomethacin)
Summary Reference Tables:
  • Ranson criteria (all 11 variables)
  • Atlanta morphological classification (APFC / ANC / Pseudocyst / WON)
  • Full complications table with management
  • Differential diagnosis table
  • Key guidelines and references (Atlanta 2012, ESPEN 2024, IAP/APA)
Design features: Colour-coded question boxes (orange), model answer labels (green), examiner tips (red alert boxes), key point highlights (gold), investigation tables, with header/footer on every page.

Can you answer here

Of course! Here is the full Postgraduate General Surgery Clinical Discussion on Acute Pancreatitis, directly in chat.

POSTGRADUATE GENERAL SURGERY — CLINICAL DISCUSSION

Acute Pancreatitis & Complications


CASE 1: Acute Biliary Pancreatitis

Clinical Vignette

A 42-year-old obese female presents with a 10-hour history of severe epigastric pain radiating to the back, sudden onset after a fatty meal, with nausea and vomiting. No jaundice. No alcohol history. Similar milder episodes in the past.
Vitals: Temp 38.1°C | HR 108/min | BP 124/78 | RR 20/min | SpO2 98% Abdomen: Epigastric + RUQ tenderness, guarding, sluggish bowel sounds

Investigations

TestResultSignificance
Serum Lipase1,840 U/L (>3× ULN)Diagnostic — most specific
Serum Amylase920 U/LRaised, less specific
ALT186 U/L (>3× ULN)Biliary aetiology (94% PPV)
Total Bilirubin22 µmol/LTransient biliary obstruction
WBC13.4 × 10⁹/LSIRS response
Haematocrit44%Borderline — necrosis risk
CRP28 mg/L (admission)Recheck at 48h
Serum Ca²⁺2.1 mmol/LMild hypocalcaemia
USS AbdomenGallbladder calculi, CBD 7mm, oedematous pancreasConfirms biliary aetiology

Q1. How do you diagnose acute pancreatitis?

2 of 3 criteria required:
  1. Characteristic epigastric pain radiating to the back
  2. Serum lipase or amylase ≥ 3× ULN
  3. Characteristic imaging on CT/MRI (only needed if 1 and 2 absent)
This patient satisfies criteria 1 + 2. CT is not required to make the diagnosis.
Lipase is preferred over amylase — more specific, stays elevated longer. Amylase may be normal in alcoholic AP and hypertriglyceridaemia-induced AP.
Examiner tip: "What is the single best enzyme to diagnose AP?" → Serum lipase.

Q2. What is the most likely aetiology and how do you confirm it?

Gallstone (biliary) pancreatitis — supported by:
  • Obese female, fatty meal trigger, prior similar episodes (classic risk profile)
  • ALT >3× ULN — 94% PPV for gallstone aetiology
  • Gallstones on USS + dilated CBD (7 mm)
Confirmation: USS first-line. If CBD stones not seen, proceed to MRCP or EUS. Avoid early routine ERCP unless cholangitis or obstruction is present.
Examiner tip: ALT >3× ULN in the setting of AP = biliary aetiology until proven otherwise.

Q3. How do you classify severity and which scoring systems do you use?

Revised Atlanta Classification 2012

GradeCriteria
MildNo organ failure; no local or systemic complications
Moderately SevereTransient organ failure (<48h) OR local complications
SeverePersistent organ failure (>48h); modified Marshall score ≥2

Scoring Systems

ScoreComponentsThresholdBest Used
Ranson5 at admission + 6 at 48h≥3 = severeAt 48h
APACHE II15 physiological variables≥8 = severeICU, any time
BISAPBUN, mental status, SIRS, Age >60, Pleural effusion≥3 = high riskED / admission
Modified CTSICT inflammation grade + necrosis≥4 = severeAfter CT
HAPSPeritonitis + creatinine + haematocritAny positive = not harmlessIdentify mild AP
CRP >150 mg/L at 48h is the most reliable single serum marker for severe AP.
This patient: HR 108 (SIRS), Hct 44%, no organ failure — likely mild to moderately severe. Reassess at 48h.

Q4. What is your immediate management?

Treatment is mainly supportive:
1. IV Fluid Resuscitation — cornerstone
  • Goal-directed: HR <120, MAP 65-85 mmHg, urine output >0.5-1 mL/kg/h
  • Rate: 5-10 mL/kg/h (IAP/APA) or 250-500 mL/h (ACG)
  • Preferred fluid: Lactated Ringer's (LR) over Normal Saline
    • NS causes hyperchloraemic metabolic acidosis → activates trypsinogen → worsens SIRS
    • LR has anti-inflammatory properties
  • Monitor: Hct, BUN, creatinine as surrogates
2. Analgesia
  • IV opioids (morphine or hydromorphone); PCA for severe pain
  • Meperidine no longer preferred
3. Nutrition
  • Mild AP: advance oral diet as tolerated — do NOT enforce prolonged NPO
  • Severe AP: enteral feeding preferred over TPN (see below)
4. Anti-emetics: ondansetron, metoclopramide
5. Antibiotics: NOT indicated in uncomplicated sterile AP (no prophylactic benefit demonstrated in RCTs)
6. Monitoring: urine output (catheterise), vitals, BUN, creatinine, CRP at 48h, electrolytes
Examiner tip: Do NOT give prophylactic antibiotics in AP. This is a classic examiner trap.

Q5. When is ERCP indicated? What is the definitive management of the gallstones?

ERCP is NOT routinely indicated in biliary AP.
ERCP is indicated ONLY in:
  • Acute cholangitis with biliary AP → urgent ERCP within 24-48 hours
  • Biliary obstruction (elevated bilirubin + cholangitis) → ERCP within 72 hours
This patient has no cholangitis (no Charcot's triad) and no persistent obstruction — ERCP is not indicated.
Definitive management:
  • Early laparoscopic cholecystectomy within 3 days of admission (standard of care in mild biliary AP)
  • Reduces recurrence and avoids need for ERCP
  • Do NOT wait for enzyme normalisation before cholecystectomy
  • If unfit for surgery: ERCP with biliary sphincterotomy as alternative
Examiner tip: "What is the definitive management of biliary pancreatitis?" → Laparoscopic cholecystectomy, ideally same admission. This is mandatory — never discharge without a plan.


CASE 2: Severe Necrotising Pancreatitis

Clinical Vignette

A 52-year-old male chronic alcoholic presents with severe central abdominal pain for 3 days. Unable to eat or drink for 48 hours. Restless, jaundiced, tachycardic (HR 128), hypotensive (BP 86/52), febrile (39.2°C), oliguric (10 mL/h). Abdomen rigid with involuntary guarding. Both flanks show reddish-brown discolouration (Grey Turner sign).
TestResult
Serum Lipase3,200 U/L
WBC24.0 × 10⁹/L
Haematocrit48%
BUN18 mmol/L (elevated)
Creatinine310 µmol/L, rising
Serum Ca²⁺1.6 mmol/L
CRP (at 48h)268 mg/L
PaO261 mmHg on air
Procalcitonin4.8 ng/mL
Contrast-enhanced CT60% pancreatic necrosis + peripancreatic fluid + gas bubbles in necrotic area

Q6. How do you classify this patient's AP?

Severe acute pancreatitis (Atlanta 2012) — persistent organ failure (>48h):
  • Respiratory: PaO2 61 mmHg — hypoxaemia (Marshall score ≥2)
  • Cardiovascular: BP 86/52, MAP <65 mmHg (Marshall score ≥2)
  • Renal: Creatinine 310 µmol/L, oliguria — AKI (Marshall score ≥2)
Local complication: Necrotising pancreatitis with infected collection (gas on CT without prior instrumentation = pathognomonic).
Severity scores predict mortality >40%: Ranson likely ≥5 | APACHE II ≥8 | BISAP ≥3 | Modified CTSI = 6 (necrosis 4pts + extrapancreatic +2).
Grey Turner sign (flank ecchymosis) = retroperitoneal haemorrhage. Rare but signals haemorrhagic necrotising AP with poor prognosis.

Q7. What are the types of AP and the Atlanta morphological fluid collection classification?

Two pathological types:
  • Interstitial oedematous pancreatitis (80-90%) — pancreatic oedema only, no necrosis; usually self-limiting
  • Necrotising pancreatitis (5-10%) — non-viable parenchyma ± peripancreatic fat necrosis; CT shows non-enhancing areas <40-50 HU (normal 100-150 HU)

Atlanta Morphological Classification

Subtype< 4 Weeks> 4 Weeks
Interstitial EdematousAPFC — no wall, homogeneous fluid, confined to fascial planesPseudocyst — encapsulated, well-defined wall, homogeneous fluid, NO solid debris
NecrotisingANC — heterogeneous liquid + solid, no wall, intra/extra-pancreaticWON — mixed liquid + solid, encapsulated, well-defined wall
Key distinction: Pseudocyst = fluid only. WON = fluid + solid necrotic debris. Misidentifying WON as a pseudocyst and performing simple drainage leads to failure.

Q8. How does infected pancreatic necrosis develop and how is it diagnosed?

Pathophysiology:
  • Mucosal ischaemia from SIRS → increased intestinal permeability → bacterial translocation (peaks ~1 week after onset)
  • Organisms: E. coli, Klebsiella, Pseudomonas (gram-negative rods) + Enterococcus
Risk correlates with extent of necrosis:
  • <30% necrosis → 22% infection risk
  • 30-50% necrosis → 37% risk
  • 70% necrosis → 46% risk
Diagnosis:
  • Gas in necrotic collection on CT (without prior instrumentation) = pathognomonic — act immediately
  • CT-guided FNA (Gram stain + culture) if diagnosis equivocal — note: 42% of patients with "persistent unwellness" have infected necrosis even with negative FNA
  • Suspect clinically if: fever/leukocytosis persisting >7 days, sepsis, clinical deterioration after day 10-14

Q9. Describe the step-up approach to infected necrotising pancreatitis.

The step-up approach is the current standard of care — delay open surgery as long as possible:
StepInterventionTimingNotes
1IV AntibioticsImmediatelyCarbapenems (imipenem/meropenem) first-line; alternatives: quinolones + metronidazole, piperacillin-tazobactam, 3rd-gen cephalosporins
2Percutaneous / Endoscopic DrainageDelay; ideally after WON forms (≥4 wks)CT-guided drain OR EUS-guided transmural drainage; allows collection to liquefy
3Minimally Invasive NecrosectomyIf step 2 failsVARD (Video-Assisted Retroperitoneal Debridement); endoscopic transluminal necrosectomy; laparoscopic transgastric necrosectomy
4Open Surgical NecrosectomyLast resortHistorically 20-40% mortality; closed irrigation or open packing
For sterile necrosis: Conservative in the majority. Intervene only for persistent pain, failure to improve, or biliary/enteric obstruction — and delay to allow WON formation.
Examiner tip: "Why delay surgery in infected necrosis?" — Waiting for WON formation (≥4 weeks) makes the necrosis better demarcated, reduces morbidity, and improves drainage success.

Q10. How do you manage multi-organ failure in severe AP?

ICU admission is mandatory. Organ-by-organ:
Cardiovascular/Fluids: Goal-directed LR resuscitation (MAP ≥65, UO ≥0.5 mL/kg/h); noradrenaline if fluid-refractory
Respiratory: High-flow O2 → CPAP/BiPAP → mechanical ventilation if ARDS (lung-protective ventilation, tidal volume 6 mL/kg IBW)
Renal: Optimise perfusion; avoid nephrotoxins; RRT if worsening AKI or refractory acidosis
Nutrition (ESPEN 2024):
  • Enteral nutrition PREFERRED over TPN — maintains gut mucosal integrity, reduces bacterial translocation and infection rate, lower cost
  • NG feeding = effective as nasojejunal in most; NJ preferred if gastroparesis/duodenal oedema
  • TPN only if enteral route completely impossible
Coagulopathy/DIC: FFP, platelets, cryoprecipitate; haematology input
Metabolic: IV calcium gluconate (symptomatic hypocalcaemia); insulin infusion for hyperglycaemia (target 6-10 mmol/L); replace magnesium, potassium


CASE 3: Pancreatic Pseudocyst

Clinical Vignette

A 38-year-old male presents 6 weeks after alcohol-induced AP with persistent epigastric pain, early satiety, nausea, and 4 kg weight loss. Palpable epigastric mass. CT shows a 9 cm well-defined, thin-walled, homogeneous fluid collection adjacent to the body of the pancreas — no internal solid debris.

Q11. What is the diagnosis? How do you distinguish it from WON?

Diagnosis: Symptomatic pancreatic pseudocyst (large, 9 cm)
FeaturePseudocystWalled-Off Necrosis (WON)
Timing≥4 weeks after interstitial AP≥4 weeks after necrotising AP
ContentHomogeneous fluid ONLYMixed fluid + solid necrotic debris
CT appearanceFluid density throughoutHeterogeneous — solid areas present
WallThin, smooth, well-definedWell-defined, may be thicker
OriginDuctal leak ± fat necrosisLiquefied necrotic pancreatic tissue
ManagementDrainage (EUS preferred)Drainage ± necrosectomy
Pseudocyst = no debris. WON = solid + liquid debris. Always characterise on CT before planning drainage.

Q12. Indications for drainage and options?

Indications for drainage:
  • Symptomatic (pain, early satiety, weight loss) — as in this patient ✓
  • Infected pseudocyst
  • Enlarging collection
  • Biliary or gastric outlet obstruction
  • Pseudoaneurysm within collection (requires angioembolisation first — CT with contrast before any drainage)
Asymptomatic pseudocysts: observe — majority resolve spontaneously.
Drainage options:
MethodBest ForNotes
EUS-guided transmural drainage (preferred)Collection adjacent to stomach/duodenum (≤1 cm)Minimally invasive, low recurrence, allows stent placement
Percutaneous CT-guided drainageNot adjacent to GI wall; infected collectionsHigher recurrence; may need prolonged catheter
Surgical cystenterostomy (cystgastrostomy / Roux-en-Y cystjejunostomy)Failed endoscopic/percutaneous; disconnected duct syndromeDefinitive; higher morbidity
Examiner tip: Always rule out a pseudoaneurysm (contrast-enhanced CT) before draining any pseudocyst — blind drainage of a pseudoaneurysm can cause fatal haemorrhage.


RAPID-FIRE VIVA QUESTIONS

Q: Name the antibiotics that penetrate pancreatic necrosis.
  • Carbapenems (imipenem/meropenem) — first-line
  • Fluoroquinolones + metronidazole
  • 3rd-generation cephalosporins
  • Piperacillin-tazobactam
  • (Prophylactic antibiotics in sterile AP = NOT indicated)
Q: What is the Modified Marshall Score? Measures organ failure severity across three systems (respiratory, renal, cardiovascular). Score ≥2 in any system = organ failure. Persistent ≥48h = Severe AP (Atlanta 2012).
Q: BISAP score — components?
  • B — BUN >25 mg/dL
  • I — Impaired mental status
  • S — SIRS criteria (≥2 of 4)
  • A — Age >60
  • P — Pleural effusion
Score ≥3 = high risk. Advantage: calculable at ED admission.
Q: CT in AP — when is it indicated? NOT routine. Indicated only for:
  1. Diagnostic uncertainty / normal enzymes with high clinical suspicion
  2. Rule out other intra-abdominal catastrophe
  3. Complications in patients not improving at 48-72 hours
Best done 3-7 days after onset. Early CT underestimates necrosis.
Q: What is post-ERCP pancreatitis and how is it prevented? Occurs in 3-5% of ERCPs. Prevention:
  • Rectal indomethacin 100 mg — most effective pharmacological prophylaxis (standard of care)
  • Aggressive peri-procedural LR hydration
  • Pancreatic duct stent in high-risk cases
  • Guidewire-assisted cannulation
Q: How do you manage a pancreatic pseudoaneurysm?
  • Erosion of peripancreatic vessels — splenic artery most common
  • Presents as GI bleed, haemoperitoneum, or haemorrhage into pseudocyst
  • Treatment of choice: Angiography + transcatheter arterial embolisation (TAE)
  • Surgery (ligation + drainage) if embolisation fails
  • NEVER drain a pseudocyst without excluding a pseudoaneurysm first (fatal haemorrhage risk)

SUMMARY: Complications at a Glance

CategoryComplicationManagement
Local <4 wksAPFCObservation — usually resolves
Local <4 wksANC (infected)Antibiotics + step-up drainage
Local >4 wksPseudocyst (symptomatic)EUS drainage (preferred)
Local >4 wksWON (infected)Step-up: drain → VARD → open
VascularPseudoaneurysmAngioembolisation first
VascularSplenic vein thrombosisAnticoagulation; portal HTN management
SystemicARDSLung-protective ventilation
SystemicAKIFluids + RRT if severe
SystemicDICFFP, platelets, cryoprecipitate
MetabolicHypocalcaemiaIV calcium gluconate
GIGastric outlet obstructionNG decompression; treat collection

Sources: Rosen's Emergency Medicine 9e | Sleisenger & Fordtran's GI & Liver Disease | Sabiston Surgery 21e | Atlanta Classification 2012 (Banks et al., Gut 2013) | ESPEN Guidelines 2024 (PMID: 38169174) | Gastroenterology 2024 (PMID: 38759844)
This is a shared conversation. Sign in to Orris to start your own chat.