Hello, Aris. This is my presentation for the, uh, CPC meet tomorrow being held in my college. I want you to design a Word document in which, uh, I want a whole discussion on, uh, the above-mentioned topic, what all possible questions can be asked by the Uh, people on the dais, and, uh, what all should I know regarding this condition and, uh, relatable conditions and all the anatomy generally with clinical images. Okay? Give me a full-on study material.

Reading File
Running Command

python -m markitdown "/home/daytona/workspace/attachments/a1a26773-76d9-4f77-9d0…

Reading File
Running Command

pip install markitdown -q && python -m markitdown "/home/daytona/workspace/attac…

Reading File
Running Command

/home/daytona/.local/bin/markitdown "/home/daytona/workspace/attachments/a1a2677…

Running Command

cd /home/daytona/skills/pptx && python scripts/office/unpack.py "/home/daytona/w…

Running Command

unzip -o "/home/daytona/workspace/attachments/a1a26773-76d9-4f77-9d02-95f1044cb2…

Running Command

python3 -c " import zipfile, os path = '/home/daytona/workspace/attachments/a1a2…

Running Command

python3 -c " import zipfile, re path = '/home/daytona/workspace/attachments/a1a2…

Finding Sources
Searching PubMed

Lemmel syndrome periampullary diverticulum obstructive jaundice

Searching the Web

Lemmel syndrome periampullary duodenal diverticulum CBD compression radiology clinical images MRCP

Reading File
Loading Image
Loading Image
Loading Image
Browsing Directory

/home/daytona/skills/docx

Loading Image
Searching the Web

duodenum anatomy ampulla of Vater CBD anatomy periampullary region diagram

Running Command

mkdir -p /home/daytona/workspace/lemmel-cpc && ls /home/daytona/skills/docx/scri…

Writing File

~/lemmel-cpc/build_doc.js

const {
  Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell,
  HeadingLevel, AlignmentType, BorderStyle, WidthType, ShadingType,
  VerticalAlign, PageNumber, Header, Footer, PageBreak,
  LevelFormat, ImageRun, ExternalHyperlink
} = require('docx');
const fs = require('fs');
const https = require('https');
const http = require('http');

// Helper: download image to buffer
function downloadImage(url) {
  return new Promise((resolve, reject) => {
    const proto = url.startsWith('https') ? https : http;
    proto.get(url, { headers: { 'User-Agent': 'Mozilla/5.0' } }, (res) => {
      if (res.statusCode === 301 || res.statusCode === 302) {
        return downloadImage(res.headers.location).then(resolve).catch(reject);
      }
      const chunks = [];
      res.on('data', c => chunks.push(c));
      res.on('end', () => resolve(Buffer.concat(chunks)));
      res.on('error', reject);
    }).on('error', reject);
  });
}

function h1(text) {
  return new Paragraph({
    heading: HeadingLevel.HEADING_1,
    children: [new TextRun({ text, bold: true, size: 34, color: '1B3A6B', font: 'Arial' })],
    spacing: { before: 360, after: 160 },
    border: { bottom: { color: '1B3A6B', size: 8, style: BorderStyle.SINGLE } }
  });
}

function h2(text) {
  return new Paragraph({
    heading: HeadingLevel.HEADING_2,
    children: [new TextRun({ text, bold: true, size: 28, color: '2E6DA4', font: 'Arial' })],
    spacing: { before: 280, after: 120 }
  });
}

function h3(text) {
  return new Paragraph({
    heading: HeadingLevel.HEADING_3,
    children: [new TextRun({ text, bold: true, size: 24, color: '1B3A6B', font: 'Arial' })],
    spacing: { before: 200, after: 80 }
  });
}

function para(text, opts = {}) {
  return new Paragraph({
    children: [new TextRun({ text, size: 22, font: 'Arial', ...opts })],
    spacing: { after: 120, line: 360 },
    alignment: AlignmentType.JUSTIFIED
  });
}

function bullet(text, level = 0) {
  return new Paragraph({
    numbering: { reference: 'bullets', level },
    children: [new TextRun({ text, size: 22, font: 'Arial' })],
    spacing: { after: 80 }
  });
}

function numbered(text, level = 0) {
  return new Paragraph({
    numbering: { reference: 'numbers', level },
    children: [new TextRun({ text, size: 22, font: 'Arial' })],
    spacing: { after: 80 }
  });
}

function boldPara(label, text) {
  return new Paragraph({
    children: [
      new TextRun({ text: label + ': ', bold: true, size: 22, font: 'Arial', color: '1B3A6B' }),
      new TextRun({ text, size: 22, font: 'Arial' })
    ],
    spacing: { after: 100 },
    alignment: AlignmentType.JUSTIFIED
  });
}

function highlightBox(lines, bgColor = 'EBF3FB') {
  const cells = lines.map(line =>
    new Paragraph({
      children: [new TextRun({ text: line, size: 20, font: 'Arial', color: '1B3A6B' })],
      spacing: { after: 60 }
    })
  );
  return new Table({
    width: { size: 100, type: WidthType.PERCENTAGE },
    rows: [new TableRow({
      children: [new TableCell({
        children: cells,
        shading: { type: ShadingType.CLEAR, fill: bgColor },
        margins: { top: 120, bottom: 120, left: 200, right: 200 }
      })]
    })]
  });
}

function warningBox(lines) {
  return highlightBox(lines, 'FFF3CD');
}

function greenBox(lines) {
  return highlightBox(lines, 'D4EDDA');
}

function redBox(lines) {
  return highlightBox(lines, 'F8D7DA');
}

function twoColTable(rows, header1, header2) {
  const headerRow = new TableRow({
    children: [
      new TableCell({
        children: [new Paragraph({ children: [new TextRun({ text: header1, bold: true, size: 22, font: 'Arial', color: 'FFFFFF' })], alignment: AlignmentType.CENTER })],
        shading: { type: ShadingType.CLEAR, fill: '1B3A6B' },
        margins: { top: 80, bottom: 80, left: 120, right: 120 }
      }),
      new TableCell({
        children: [new Paragraph({ children: [new TextRun({ text: header2, bold: true, size: 22, font: 'Arial', color: 'FFFFFF' })], alignment: AlignmentType.CENTER })],
        shading: { type: ShadingType.CLEAR, fill: '1B3A6B' },
        margins: { top: 80, bottom: 80, left: 120, right: 120 }
      })
    ]
  });
  const dataRows = rows.map((r, i) =>
    new TableRow({
      children: r.map(cell =>
        new TableCell({
          children: [new Paragraph({ children: [new TextRun({ text: cell, size: 20, font: 'Arial' })], alignment: AlignmentType.LEFT })],
          shading: { type: ShadingType.CLEAR, fill: i % 2 === 0 ? 'F0F6FF' : 'FFFFFF' },
          margins: { top: 60, bottom: 60, left: 120, right: 120 }
        })
      )
    })
  );
  return new Table({
    width: { size: 100, type: WidthType.PERCENTAGE },
    rows: [headerRow, ...dataRows]
  });
}

function threeColTable(rows, h1t, h2t, h3t) {
  const headerRow = new TableRow({
    children: [h1t, h2t, h3t].map(h =>
      new TableCell({
        children: [new Paragraph({ children: [new TextRun({ text: h, bold: true, size: 22, font: 'Arial', color: 'FFFFFF' })], alignment: AlignmentType.CENTER })],
        shading: { type: ShadingType.CLEAR, fill: '2E6DA4' },
        margins: { top: 80, bottom: 80, left: 120, right: 120 }
      })
    )
  });
  const dataRows = rows.map((r, i) =>
    new TableRow({
      children: r.map(cell =>
        new TableCell({
          children: [new Paragraph({ children: [new TextRun({ text: cell, size: 20, font: 'Arial' })], alignment: AlignmentType.LEFT })],
          shading: { type: ShadingType.CLEAR, fill: i % 2 === 0 ? 'F5F9FF' : 'FFFFFF' },
          margins: { top: 60, bottom: 60, left: 120, right: 120 }
        })
      )
    })
  );
  return new Table({
    width: { size: 100, type: WidthType.PERCENTAGE },
    rows: [headerRow, ...dataRows]
  });
}

function qaBox(q, a) {
  return new Table({
    width: { size: 100, type: WidthType.PERCENTAGE },
    rows: [
      new TableRow({
        children: [new TableCell({
          children: [new Paragraph({ children: [new TextRun({ text: 'Q: ' + q, bold: true, size: 22, font: 'Arial', color: '7B2D00' })], spacing: { after: 80 } })],
          shading: { type: ShadingType.CLEAR, fill: 'FEF3E2' },
          margins: { top: 100, bottom: 60, left: 200, right: 200 }
        })]
      }),
      new TableRow({
        children: [new TableCell({
          children: [new Paragraph({ children: [new TextRun({ text: 'A: ' + a, size: 22, font: 'Arial', color: '1A4A1A' })], spacing: { after: 60 } })],
          shading: { type: ShadingType.CLEAR, fill: 'F0FAF0' },
          margins: { top: 60, bottom: 100, left: 200, right: 200 }
        })]
      })
    ]
  });
}

function spacer() {
  return new Paragraph({ children: [new TextRun('')], spacing: { after: 120 } });
}

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

async function buildDoc() {
  // Download images
  let radiopaediaImg, jkmsImg, mrcp2Img;
  try {
    radiopaediaImg = await downloadImage('https://prod-images-static.radiopaedia.org/images/52122945/72c659ba1cd34aeb0eefc4afbc8006_big_gallery.jpeg');
    console.log('Image 1 (Radiopaedia MRI) downloaded, size:', radiopaediaImg.length);
  } catch (e) { console.log('Image 1 failed:', e.message); }
  try {
    jkmsImg = await downloadImage('https://jkms.org/ArticleImage/0063JKMS/jkms-29-874-ab001.jpg');
    console.log('Image 2 (JKMS CT+MRCP) downloaded, size:', jkmsImg.length);
  } catch (e) { console.log('Image 2 failed:', e.message); }
  try {
    mrcp2Img = await downloadImage('https://clinicalimagingscience.org/content/12/2023/13/1/img/JCIS-13-11-g003.png');
    console.log('Image 3 (JCIS MRCP) downloaded, size:', mrcp2Img.length);
  } catch (e) { console.log('Image 3 failed:', e.message); }

  const imageElements = [];
  if (radiopaediaImg && radiopaediaImg.length > 1000) {
    imageElements.push(new Paragraph({
      children: [new ImageRun({ data: radiopaediaImg, transformation: { width: 320, height: 260 }, type: 'jpg' })],
      alignment: AlignmentType.CENTER, spacing: { after: 80 }
    }));
    imageElements.push(new Paragraph({ children: [new TextRun({ text: 'Figure 1: Coronal T2-weighted MRI showing periampullary diverticulum (large air-fluid structure) compressing distal CBD with upstream biliary dilatation — classic Lemmel syndrome on MRI (Radiopaedia)', size: 18, italics: true, font: 'Arial', color: '555555' })], alignment: AlignmentType.CENTER, spacing: { after: 160 } }));
  }
  if (jkmsImg && jkmsImg.length > 1000) {
    imageElements.push(new Paragraph({
      children: [new ImageRun({ data: jkmsImg, transformation: { width: 480, height: 300 }, type: 'jpg' })],
      alignment: AlignmentType.CENTER, spacing: { after: 80 }
    }));
    imageElements.push(new Paragraph({ children: [new TextRun({ text: 'Figure 2: (A) Axial CT showing periampullary diverticulum (solid arrow). (B) Coronal CT confirming CBD compression (open arrow = dilated CBD; solid arrow = diverticulum). (C) Schematic diagram: PAD (orange) compressing CBD (blue) next to gallbladder (GB, green). (D) MRCP showing upstream biliary tree dilation with cut-off at periampullary region (arrow). Source: JKMS', size: 18, italics: true, font: 'Arial', color: '555555' })], alignment: AlignmentType.CENTER, spacing: { after: 160 } }));
  }
  if (mrcp2Img && mrcp2Img.length > 1000) {
    imageElements.push(new Paragraph({
      children: [new ImageRun({ data: mrcp2Img, transformation: { width: 520, height: 220 }, type: 'png' })],
      alignment: AlignmentType.CENTER, spacing: { after: 80 }
    }));
    imageElements.push(new Paragraph({ children: [new TextRun({ text: 'Figure 3: Axial T2 MRI images showing dilated CBD (arrow) compressed by periampullary diverticulum (asterisk). Right panel: ERCP with biliary stent placement for relief of obstruction. Source: J Clin Imaging Sci 2023', size: 18, italics: true, font: 'Arial', color: '555555' })], alignment: AlignmentType.CENTER, spacing: { after: 160 } }));
  }

  const doc = new Document({
    numbering: {
      config: [
        { reference: 'bullets', levels: [{ level: 0, format: LevelFormat.BULLET, text: '\u2022', alignment: AlignmentType.LEFT, style: { paragraph: { indent: { left: 720, hanging: 360 } } } }, { level: 1, format: LevelFormat.BULLET, text: '\u25E6', alignment: AlignmentType.LEFT, style: { paragraph: { indent: { left: 1080, hanging: 360 } } } }] },
        { reference: 'numbers', levels: [{ level: 0, format: LevelFormat.DECIMAL, text: '%1.', alignment: AlignmentType.LEFT, style: { paragraph: { indent: { left: 720, hanging: 360 } } } }] }
      ]
    },
    styles: {
      default: { document: { run: { font: 'Arial', size: 22 } } },
      paragraphStyles: [
        { id: 'Heading1', name: 'Heading 1', basedOn: 'Normal', next: 'Normal', quickFormat: true, run: { size: 34, bold: true, font: 'Arial', color: '1B3A6B' }, paragraph: { spacing: { before: 360, after: 160 }, outlineLevel: 0 } },
        { id: 'Heading2', name: 'Heading 2', basedOn: 'Normal', next: 'Normal', quickFormat: true, run: { size: 28, bold: true, font: 'Arial', color: '2E6DA4' }, paragraph: { spacing: { before: 280, after: 120 }, outlineLevel: 1 } },
        { id: 'Heading3', name: 'Heading 3', basedOn: 'Normal', next: 'Normal', quickFormat: true, run: { size: 24, bold: true, font: 'Arial', color: '1B3A6B' }, paragraph: { spacing: { before: 200, after: 80 }, outlineLevel: 2 } }
      ]
    },
    sections: [{
      properties: { page: { margin: { top: 1134, bottom: 1134, left: 1134, right: 1134 } } },
      headers: {
        default: new Header({
          children: [new Paragraph({
            children: [new TextRun({ text: 'CPC STUDY MATERIAL - LEMMEL SYNDROME | Surgery Department', size: 18, font: 'Arial', color: '888888', italics: true })],
            alignment: AlignmentType.RIGHT,
            border: { bottom: { color: '1B3A6B', size: 6, style: BorderStyle.SINGLE } }
          })]
        })
      },
      footers: {
        default: new Footer({
          children: [new Paragraph({
            children: [
              new TextRun({ text: 'Prepared for CPC Meet - General Surgery | July 2026   |   Page ', size: 18, font: 'Arial', color: '888888' }),
              new TextRun({ children: [PageNumber.CURRENT], size: 18, font: 'Arial', color: '888888' })
            ],
            alignment: AlignmentType.CENTER,
            border: { top: { color: '1B3A6B', size: 6, style: BorderStyle.SINGLE } }
          })]
        })
      },
      children: [

        // TITLE PAGE
        spacer(), spacer(),
        new Paragraph({
          children: [new TextRun({ text: 'CPC STUDY MATERIAL', bold: true, size: 52, font: 'Arial', color: '1B3A6B' })],
          alignment: AlignmentType.CENTER, spacing: { after: 120 }
        }),
        new Paragraph({
          children: [new TextRun({ text: 'Lemmel Syndrome', bold: true, size: 44, font: 'Arial', color: '2E6DA4' })],
          alignment: AlignmentType.CENTER, spacing: { after: 80 }
        }),
        new Paragraph({
          children: [new TextRun({ text: 'A Rare Association of Cholelithiasis and Lemmel Syndrome:', size: 28, font: 'Arial', color: '444444', italics: true })],
          alignment: AlignmentType.CENTER, spacing: { after: 40 }
        }),
        new Paragraph({
          children: [new TextRun({ text: 'Diagnostic and Management Dilemmas', size: 28, font: 'Arial', color: '444444', italics: true })],
          alignment: AlignmentType.CENTER, spacing: { after: 200 }
        }),
        new Paragraph({ border: { bottom: { color: '2E6DA4', size: 10, style: BorderStyle.SINGLE } }, children: [new TextRun('')], spacing: { after: 200 } }),
        new Paragraph({
          children: [new TextRun({ text: 'Presented by: Dr. Meenakshy', size: 24, font: 'Arial', color: '333333', bold: true })],
          alignment: AlignmentType.CENTER, spacing: { after: 60 }
        }),
        new Paragraph({
          children: [new TextRun({ text: 'PG-2, Department of General Surgery (GS-3)', size: 22, font: 'Arial', color: '555555' })],
          alignment: AlignmentType.CENTER, spacing: { after: 60 }
        }),
        new Paragraph({
          children: [new TextRun({ text: 'CPC Meet | Surgery - Radiology - Pathology Correlation', size: 22, font: 'Arial', color: '555555' })],
          alignment: AlignmentType.CENTER, spacing: { after: 60 }
        }),
        new Paragraph({
          children: [new TextRun({ text: 'July 2026', size: 22, font: 'Arial', color: '555555', italics: true })],
          alignment: AlignmentType.CENTER, spacing: { after: 400 }
        }),
        pageBreak(),

        // ===================== SECTION 1: CASE SUMMARY =====================
        h1('SECTION 1: CASE SUMMARY'),
        highlightBox([
          'Patient:   74-year-old Female  |  Department: General Surgery',
          'Chief Complaint: Recurrent right upper quadrant pain x 2 years, colicky, non-radiating, aggravated by heavy meals',
          'Final Diagnosis: Symptomatic Cholelithiasis with Incidental Asymptomatic Lemmel Syndrome'
        ]),
        spacer(),

        h2('1.1 Clinical History'),
        boldPara('Presenting Complaint', 'Recurrent episodes of right upper quadrant colicky pain for 2 years, non-radiating, worsened with heavy meals. No jaundice, no fever with chills, no vomiting, no loss of appetite, no weight loss, no clay-coloured stools, no high-coloured urine, no itching.'),
        boldPara('Past Medical History', 'Known hypertensive on medications x 5 years. H/o LSCS (55 years ago). Post-menopausal for 24 years. No prior biliary intervention or ERCP.'),
        boldPara('Personal History', 'Mixed diet. Normal bowel and bladder habits. No alcohol, no smoking.'),

        h2('1.2 Physical Examination'),
        bullet('Vitals: Stable'),
        bullet('No icterus'),
        bullet('P/A: Soft, tenderness in right hypochondrium and epigastrium (++), no rebound tenderness, Murphy\'s sign negative, no organomegaly, all hernial orifices free'),
        bullet('CVS: S1, S2 heard; RS: BLAE+; CNS: no focal neurological deficit'),
        spacer(),

        h2('1.3 Laboratory Investigations'),
        twoColTable([
          ['Total Bilirubin', '0.72 mg/dL (Normal)'],
          ['ALP / GGT', '75 / 15 U/L (Normal)'],
          ['AST / ALT', '17 / 12 U/L (Normal)'],
          ['Amylase / Lipase', '30 / 27 U/L (Normal)'],
          ['Total Leukocyte Count', '11,420 cells/cumm (Mildly elevated)'],
          ['CRP', '5 mg/L (Mildly elevated)'],
        ], 'Parameter', 'Result / Interpretation'),
        spacer(),
        warningBox(['KEY POINT: Completely NORMAL liver function tests despite dilated CBD (9.6 mm) on imaging. This is the hallmark of ASYMPTOMATIC Lemmel syndrome - purely a radiological finding without biochemical biliary obstruction.']),
        spacer(),

        h2('1.4 Imaging Findings'),
        h3('CT Abdomen (Plain)'),
        bullet('Two gallstones within gallbladder, largest 13 x 8 mm - likely cholelithiasis'),
        bullet('Diverticulum of size 11 x 12 mm in D2 segment of duodenum'),
        spacer(),
        h3('MRCP'),
        bullet('Gallbladder well distended, multiple (~6-7) T2 hypointense filling defects in body and neck, largest 9 x 6 mm'),
        bullet('Well-defined T2 hyperintense lesion measuring 1.8 x 1.3 cm in medial aspect of D2 duodenum causing compression of CBD with upstream dilatation (CBD ~9.6 mm)'),
        bullet('No filling defect within CBD (excludes choledocholithiasis)'),
        bullet('Diagnosis on imaging: Periampullary duodenal diverticulum compressing CBD = Lemmel Syndrome'),
        spacer(),
        ...imageElements,

        h2('1.5 Intraoperative Findings'),
        bullet('Gallbladder distended'),
        bullet('CBD dilated'),
        bullet('Adhesions noted'),
        bullet('Standard 4-port laparoscopic cholecystectomy performed uneventfully'),
        spacer(),

        h2('1.6 Histopathology'),
        highlightBox(['Follicular (Calculous) Cholecystitis', 'Post-laparoscopic cholecystectomy gallbladder specimen', 'Duodenal diverticulum: NOT biopsied/resected - managed conservatively (asymptomatic)']),
        spacer(),

        h2('1.7 Management & Outcome'),
        bullet('Periampullary diverticulum: Conservative management. No ERCP/sphincterotomy - LFTs normal, no jaundice, no cholangitis'),
        bullet('Cholelithiasis: Elective laparoscopic cholecystectomy (standard 4-port)'),
        bullet('Gastroenterology opinion sought - reassurance and follow-up advised'),
        bullet('Postoperative course: Uneventful. No fever, no bile leak, no wound complications'),
        bullet('Counselled about rare risks of diverticulitis, cholangitis, GI bleeding from diverticulum'),
        spacer(),
        pageBreak(),

        // ===================== SECTION 2: DISEASE OVERVIEW =====================
        h1('SECTION 2: LEMMEL SYNDROME - DISEASE OVERVIEW'),

        h2('2.1 Definition'),
        para('Lemmel syndrome is a rare condition characterised by extrinsic compression of the distal common bile duct (and sometimes the main pancreatic duct) by a periampullary duodenal diverticulum (PAD), causing obstructive jaundice or biliary/pancreatic complications - in the ABSENCE of choledocholithiasis or a pancreatobiliary tumour.'),
        spacer(),
        highlightBox([
          'First described by: Dr. Gerhard Lemmel (1934) - "Uber Duodenaldivertikel und ihre klinische Bedeutung"',
          'Prevalence of periampullary diverticula: 5-27% on imaging; up to 15% on ERCP series',
          'Symptomatic Lemmel syndrome: Only 1-5% of periampullary diverticula cause biliary obstruction',
          'Duodenal diverticula are the 2nd most common site for GI diverticula (after colon)'
        ]),
        spacer(),

        h2('2.2 Anatomy of the Periampullary Region'),
        h3('Duodenum - Key Anatomical Points'),
        bullet('The duodenum has 4 parts: D1 (superior/bulb), D2 (descending), D3 (horizontal), D4 (ascending)'),
        bullet('D2 is the most important: contains the major duodenal papilla (ampulla of Vater), the minor papilla, and receives the CBD and main pancreatic duct'),
        bullet('Blood supply: Superior and inferior pancreaticoduodenal arteries (branches of gastroduodenal artery and SMA)'),
        bullet('The ampulla of Vater opens on the medial wall of D2, approximately at the junction of the middle and lower thirds'),
        bullet('The ampulla is surrounded by the Sphincter of Oddi (smooth muscle complex regulating CBD, pancreatic duct, and common channel)'),
        spacer(),
        h3('Common Bile Duct (CBD)'),
        bullet('Four segments: Supraduodenal, retroduodenal, intrapancreatic, intraduodenal (intramural)'),
        bullet('Normal CBD diameter: < 6 mm (< 8 mm post-cholecystectomy; < 10 mm in elderly)'),
        bullet('The intrapancreatic and intraduodenal segments are most vulnerable to extrinsic compression by periampullary diverticula'),
        bullet('CBD terminates at the ampulla of Vater alongside the main pancreatic duct (duct of Wirsung)'),
        spacer(),
        h3('Periampullary Region'),
        bullet('Defined as the region within 2-3 cm of the ampulla of Vater'),
        bullet('Structures in this region: Ampulla, distal CBD, distal pancreatic duct, D2 wall, pancreatic head'),
        bullet('Periampullary diverticula arise from the medial wall of D2, typically at the point where the CBD/pancreatic duct enter - a site of relative muscular weakness'),
        spacer(),

        h2('2.3 Duodenal Diverticula - Classification'),
        h3('Types'),
        twoColTable([
          ['Congenital (Intraluminal)', 'Develops from incomplete canalisation during embryogenesis; protrudes into duodenal lumen; mostly intraluminal; rare'],
          ['Acquired (Extraluminal / True Pseudodiverticulum)', 'Most common type; outpouching of mucosa + submucosa through a defect in the muscle layer; NO true muscular wall; equivalent to a "pseudodiverticulum"'],
        ], 'Type', 'Features'),
        spacer(),
        h3('Li-Tanaka Classification of Periampullary Diverticulum (by papilla position)'),
        threeColTable([
          ['Type I', 'Papilla INSIDE the diverticulum, not at margin', 'Most difficult for ERCP cannulation'],
          ['Type II', 'Papilla at the MARGIN of the diverticulum (IIa: inside margin; IIb: outside margin <1 cm)', 'Moderately difficult'],
          ['Type III', 'Papilla OUTSIDE and NEAR the diverticulum (≥1 cm from margin)', 'Easier cannulation'],
          ['Type IV', 'Papilla at margin; 2 or more diverticula present', 'Most complex variant'],
        ], 'Type', 'Papilla Position', 'Clinical Implication'),
        spacer(),

        h2('2.4 Epidemiology'),
        bullet('Duodenal diverticula: Found in ~22% of the general population'),
        bullet('Prevalence increases with age: Up to 10-15% by the 8th decade'),
        bullet('90% of duodenal diverticula are ASYMPTOMATIC'),
        bullet('Complications occur in ~5% of cases'),
        bullet('Lemmel syndrome specifically: Very rare; estimated prevalence <0.01% (case reports predominate in literature)'),
        bullet('More common in the elderly; female preponderance noted in some series'),
        spacer(),

        h2('2.5 Pathogenesis of Lemmel Syndrome'),
        para('Three main mechanisms have been proposed:'),
        numbered('Direct mechanical compression: The enlarged diverticulum directly compresses the distal CBD or pancreatic duct, causing upstream dilatation.'),
        numbered('Sphincter of Oddi dysfunction: Chronic inflammation and fibrosis of the papillae caused by recurrent diverticulitis/direct mechanical irritation leads to sphincter dysfunction.'),
        numbered('Outpouching due to increased intraduodenal pressure: Progressive weakening of intestinal smooth muscle due to chronic pressure leads to diverticular formation; this enlarging diverticulum then compresses adjacent biliary/pancreatic structures.'),
        spacer(),
        highlightBox([
          'The hallmark of Lemmel syndrome is that obstruction/compression occurs WITHOUT:',
          '  - Choledocholithiasis (no CBD stones)',
          '  - Pancreatobiliary tumour (no malignancy)',
          '  - Only the PAD is responsible for the compression'
        ]),
        spacer(),

        h2('2.6 Clinical Presentation'),
        twoColTable([
          ['Symptomatic (Classic)', 'Obstructive jaundice, right upper quadrant pain, fever (Charcot\'s triad if cholangitis), deranged LFTs (elevated bilirubin, ALP, GGT), dark urine, pale stools, pruritus'],
          ['Asymptomatic (Incidental - this case)', 'No jaundice, normal LFTs, CBD dilatation found incidentally on imaging done for another indication (e.g., gallstone workup)'],
          ['With Pancreatitis', 'Epigastric pain, elevated serum amylase/lipase, may show double-duct sign on MRCP'],
          ['With Cholangitis', 'Fever + jaundice + abdominal pain (Charcot\'s triad); sepsis if severe (Reynolds\' pentad)'],
          ['With GI Bleeding', 'Haematemesis or melaena if diverticular erosion or bleeding vessel involved'],
          ['With Diverticulitis', 'Localised RUQ/epigastric pain, fever, elevated CRP/WBC; may mimic pancreatic or duodenal pathology'],
        ], 'Presentation Type', 'Features'),
        spacer(),
        pageBreak(),

        // ===================== SECTION 3: INVESTIGATIONS =====================
        h1('SECTION 3: INVESTIGATIONS'),

        h2('3.1 Laboratory Tests'),
        bullet('Complete Blood Count (CBC): Leucocytosis if diverticulitis/cholangitis; anaemia if GI bleeding'),
        bullet('Liver Function Tests (LFT): Elevated conjugated (direct) bilirubin, elevated ALP/GGT if obstructive jaundice; ALT/AST may also rise in prolonged obstruction'),
        bullet('Serum Amylase/Lipase: Elevated if associated pancreatitis'),
        bullet('CRP/ESR: Elevated in inflammatory states (diverticulitis, cholangitis)'),
        bullet('Coagulation profile: Prolonged PT/INR if vitamin K malabsorption from prolonged obstructive jaundice'),
        bullet('Renal function tests and electrolytes: Baseline and if planning contrast imaging'),
        bullet('Blood culture: If cholangitis/sepsis suspected'),
        spacer(),

        h2('3.2 Imaging Modalities'),
        h3('Ultrasonography (USG Abdomen)'),
        bullet('First-line investigation; widely available, no radiation'),
        bullet('Can detect: CBD dilatation, intrahepatic biliary radicle (IHBR) dilatation, gallstones, echogenic material in periampullary region'),
        bullet('Limitations: Periampullary region often obscured by bowel gas; diverticulum itself may not be visualised'),
        bullet('Used in 48% of cases in systematic review'),
        spacer(),
        h3('CT Abdomen (Plain + Contrast)'),
        bullet('Gold standard for initial cross-sectional assessment'),
        bullet('Shows thin-walled cavitary lesion on the MEDIAL WALL of D2 containing air, fluid, or enteroliths'),
        bullet('Oral contrast CT: Contrast enters the diverticulum from the duodenum - pathognomonic finding'),
        bullet('Demonstrates CBD compression and upstream dilatation'),
        bullet('Can rule out tumour, abscess, pancreatic mass'),
        bullet('Used in 78% of cases in literature review'),
        bullet('Pitfall: A fluid-filled diverticulum may be mistaken for a pancreatic cyst, cystic neoplasm, or abscess'),
        spacer(),
        h3('MRCP (Magnetic Resonance Cholangiopancreatography)'),
        bullet('Investigation of choice for Lemmel syndrome - non-invasive, no radiation, excellent biliary/pancreatic duct visualisation'),
        bullet('Shows: Dilated CBD and IHBR, T2 hyperintense periampullary lesion, "double-duct sign" if pancreatic duct also involved, absence of CBD stones/tumour'),
        bullet('Distinguishes Lemmel syndrome from choledocholithiasis and malignancy'),
        bullet('Used in 60% of cases in literature review'),
        bullet('In this case: Confirmed diverticulum in medial D2 causing CBD compression (9.6 mm dilatation)'),
        spacer(),
        h3('ERCP (Endoscopic Retrograde Cholangiopancreatography)'),
        bullet('Diagnostic AND therapeutic'),
        bullet('Can directly visualise periampullary diverticulum and papilla'),
        bullet('Allows sphincterotomy, stone extraction, stent placement'),
        bullet('Technical challenge: Cannulation success rates 62.4% with periampullary diverticula vs. 92.7% without (literature)'),
        bullet('ERCP tips for intra-diverticular papilla (Li-Tanaka Type I-II):'),
        bullet('Papilla usually at 3-8 o\'clock position on diverticulum edge', 1),
        bullet('Use biopsy forceps in working channel to evert mucosa and identify papilla', 1),
        bullet('Advance endoscope tip into sac carefully (risk of perforation)', 1),
        bullet('Air aspiration may reveal papilla location', 1),
        bullet('Change patient to prone position', 1),
        bullet('Saline instillation on contralateral wall may protrude papilla', 1),
        spacer(),
        h3('Endoscopic Ultrasound (EUS)'),
        bullet('Useful when other modalities are inconclusive'),
        bullet('Excellent for characterising periampullary lesions and biliary anatomy'),
        bullet('Can guide fine needle aspiration if malignancy needs to be excluded'),
        spacer(),
        h3('Barium Meal / Fluoroscopy'),
        bullet('Older modality; can show duodenal diverticulum filling with barium'),
        bullet('Less commonly used in modern practice; largely replaced by CT and MRCP'),
        spacer(),

        h2('3.3 Imaging Summary Table'),
        threeColTable([
          ['USG', 'CBD dilatation, gallstones', '48% use; limited for periampullary region'],
          ['CT Abdomen (+ oral contrast)', 'Diverticulum on medial D2, air/fluid/enterolith, CBD compression', '78% use; best for acute presentation'],
          ['MRCP', 'T2 hyperintense PAD, CBD/PD dilatation, no stones/tumour', '60% use; INVESTIGATION OF CHOICE'],
          ['ERCP', 'Direct visualisation + therapeutic', 'Technically challenging; use when intervention planned'],
          ['EUS', 'Periampullary lesion characterisation', 'For inconclusive cases'],
        ], 'Modality', 'Key Findings', 'Comments'),
        spacer(),
        pageBreak(),

        // ===================== SECTION 4: DIFFERENTIAL DIAGNOSIS =====================
        h1('SECTION 4: DIFFERENTIAL DIAGNOSIS'),
        para('Lemmel syndrome is a rare diagnosis of exclusion. The following conditions must be ruled out:'),
        spacer(),

        twoColTable([
          ['Choledocholithiasis', 'CBD stones causing obstructive jaundice; filling defects on MRCP/ERCP; most common cause of extrahepatic biliary obstruction'],
          ['Carcinoma of Ampulla of Vater', 'Malignant; progressive jaundice; silver/acholic stools; endoscopy + biopsy required; Thomas\'s sign (silver stools); often presents as obstructive jaundice with low CBD cut-off on MRCP'],
          ['Carcinoma of Head of Pancreas', 'Progressive painless jaundice; weight loss; double-duct sign; Courvoisier\'s sign (palpable GB); poor prognosis'],
          ['Periampullary Carcinoma', 'Four types: Ampullary, distal CBD, duodenal, pancreatic head; collectively better prognosis than pancreatic head Ca alone'],
          ['Cholangiocarcinoma', 'Hilar or distal; Bismuth-Corlette classification for hilar type; progressive jaundice + weight loss'],
          ['Primary Sclerosing Cholangitis (PSC)', 'Multifocal biliary strictures; associated with IBD (especially UC); p-ANCA positive; "beaded" appearance on cholangiography'],
          ['Primary Biliary Cholangitis (PBC)', 'Autoimmune; AMA (anti-mitochondrial antibody) positive; female preponderance; pruritus prominent'],
          ['Mirizzi Syndrome', 'CBD compression by stone impacted in cystic duct/Hartmann\'s pouch; important surgical trap; 4 types (Csendes classification)'],
          ['Acute Cholecystitis', 'Fever, Murphy\'s sign positive, leukocytosis; wall thickening on USG'],
          ['Pancreatic Pseudocyst', 'Usually post-pancreatitis; fluid collection; may compress CBD'],
          ['Duodenal/Pancreatic Abscess', 'Air-fluid filled lesion; septic picture; may mimic fluid-filled periampullary diverticulum on CT'],
        ], 'Diagnosis', 'Key Differentiating Features'),
        spacer(),
        redBox([
          'RED FLAGS that should make you think MALIGNANCY over Lemmel syndrome:',
          '- Progressive (not intermittent) jaundice',
          '- Significant weight loss or anorexia',
          '- Painless jaundice (classic for pancreatic head Ca)',
          '- Courvoisier\'s sign: Palpable, non-tender gallbladder',
          '- CA 19-9 elevated',
          '- Enhancing mass on CT; stricture without adjacent diverticulum on MRCP'
        ]),
        spacer(),
        pageBreak(),

        // ===================== SECTION 5: MANAGEMENT =====================
        h1('SECTION 5: MANAGEMENT OF LEMMEL SYNDROME'),

        h2('5.1 Management Principles'),
        para('Management depends on the clinical presentation. The guiding principle is: TREAT THE SYMPTOMS, NOT THE RADIOLOGICAL FINDING. An asymptomatic diverticulum with incidentally found CBD dilatation does NOT mandate intervention if LFTs are normal and there are no clinical features of obstruction or complication.'),
        spacer(),

        h2('5.2 Asymptomatic Lemmel Syndrome (as in this case)'),
        greenBox([
          'Management: CONSERVATIVE (Watchful Observation)',
          '- Regular clinical follow-up',
          '- Repeat LFTs if symptoms develop',
          '- Counsel patient about warning symptoms: jaundice, fever, worsening pain',
          '- NO ERCP, NO sphincterotomy, NO surgical resection',
          '- Treat any coincidental pathology (e.g., cholecystectomy for symptomatic cholelithiasis)'
        ]),
        spacer(),

        h2('5.3 Symptomatic Lemmel Syndrome - Indications for Intervention'),
        bullet('Recurrent cholangitis'),
        bullet('Obstructive jaundice (biochemically confirmed)'),
        bullet('Gastrointestinal bleeding from diverticulum'),
        bullet('Diverticulitis or perforation'),
        bullet('Associated pancreatitis'),
        spacer(),

        h2('5.4 Endoscopic Management'),
        h3('Endoscopic Sphincterotomy (ES)'),
        bullet('First-line endoscopic intervention for biliary obstruction in Lemmel syndrome'),
        bullet('Releases CBD obstruction; allows biliary drainage'),
        bullet('Technically challenging due to intra-diverticular or peri-diverticular papilla location'),
        bullet('Success rates 62-95% depending on papilla position and endoscopist expertise'),
        spacer(),
        h3('Endoscopic Biliary Stenting'),
        bullet('Alternative or adjunct to sphincterotomy'),
        bullet('Used when sphincterotomy fails or anatomy is very distorted'),
        bullet('Short-term relief; stent exchange required periodically'),
        spacer(),
        h3('Endoscopic Diverticulotomy'),
        bullet('Cutting the septum between the diverticulum and the papilla'),
        bullet('Less commonly performed; reserved for experienced endoscopists'),
        spacer(),

        h2('5.5 Surgical Management'),
        h3('Indications for Surgery'),
        bullet('Failed endoscopic management'),
        bullet('Diverticular perforation or uncontrolled haemorrhage'),
        bullet('Recurrent symptoms despite endoscopic therapy'),
        bullet('Suspected malignancy requiring resection'),
        spacer(),
        h3('Surgical Options'),
        twoColTable([
          ['Diverticulectomy', 'Excision of the diverticulum; risk of duodenal leak/fistula; requires precise closure'],
          ['Duodenectomy', 'Partial removal of D2; complex; for large diverticula'],
          ['Roux-en-Y Hepaticojejunostomy', 'Biliary bypass; for irreparable CBD damage or failed reconstruction'],
          ['Transduodenal Sphincteroplasty', 'Opening the sphincter of Oddi surgically; alternative to endoscopic sphincterotomy'],
          ['Whipple\'s Procedure (Pancreaticoduodenectomy)', 'Reserved for malignancy or complex periampullary disease; rarely needed for Lemmel syndrome alone'],
        ], 'Procedure', 'Indication / Notes'),
        spacer(),

        h2('5.6 Management of Associated Cholelithiasis'),
        bullet('Symptomatic cholelithiasis treated with laparoscopic cholecystectomy as DEFINITIVE management'),
        bullet('This is independent of the management decision for Lemmel syndrome'),
        bullet('In this case: Standard 4-port laparoscopic cholecystectomy performed without complications'),
        bullet('Periampullary diverticulum does NOT contraindicate cholecystectomy'),
        spacer(),
        pageBreak(),

        // ===================== SECTION 6: RELATED CONDITIONS =====================
        h1('SECTION 6: RELATED CONDITIONS YOU MUST KNOW'),

        h2('6.1 Mirizzi Syndrome'),
        para('Mirizzi syndrome is extrinsic compression of the CBD by a stone impacted in the cystic duct or Hartmann\'s pouch. It is an important surgical trap and must be known for contrast with Lemmel syndrome.'),
        twoColTable([
          ['Type I', 'Extrinsic compression of CHD by impacted stone in cystic duct/Hartmann\'s pouch; no fistula'],
          ['Type II', 'Cholecystocholedochal fistula involving less than 1/3 of CBD circumference'],
          ['Type III', 'Fistula involving up to 2/3 of CBD circumference'],
          ['Type IV', 'Complete destruction of CBD wall; fistula involving entire circumference'],
        ], 'Type (McSherry / Csendes)', 'Description'),
        spacer(),
        boldPara('Management', 'Type I: Laparoscopic/open cholecystectomy. Types II-IV: Open surgery with biliary reconstruction (hepaticojejunostomy or primary repair over T-tube).'),
        spacer(),

        h2('6.2 Choledocholithiasis'),
        bullet('CBD stones: Primary (formed in CBD) or secondary (migrated from gallbladder)'),
        bullet('Presentation: Biliary colic, obstructive jaundice, Charcot\'s triad (RUQ pain + fever + jaundice), Reynolds\' pentad (+ hypotension + altered sensorium = ascending cholangitis)'),
        bullet('Diagnosis: USG (dilated CBD), MRCP (filling defects), ERCP (diagnostic + therapeutic)'),
        bullet('Management: ERCP + sphincterotomy + stone extraction; laparoscopic CBD exploration; open CBD exploration (Choledochotomy + T-tube drainage)'),
        spacer(),

        h2('6.3 Cholangitis'),
        bullet('Definition: Bacterial infection of the biliary tree, usually secondary to biliary obstruction (stones, stricture, tumour)'),
        bullet('Charcot\'s triad: RUQ pain + fever with rigors + jaundice (66% sensitivity)'),
        bullet('Reynolds\' pentad: Charcot\'s triad + hypotension + altered sensorium (septic cholangitis)'),
        bullet('Tokyo Guidelines (TG18) severity grading: Grade I (mild), Grade II (moderate), Grade III (severe/organ failure)'),
        bullet('Management: IV antibiotics, biliary drainage (ERCP/PTBD/surgical), treat underlying cause'),
        spacer(),

        h2('6.4 Acute Pancreatitis'),
        bullet('Lemmel syndrome can cause acute pancreatitis via PAD compression of the pancreatic duct'),
        bullet('Atlanta Classification: Mild (no organ failure), Moderately Severe (transient organ failure <48h), Severe (persistent organ failure >48h)'),
        bullet('Ranson\'s criteria, BISAP score, CTSI for severity assessment'),
        bullet('If PAD is the cause: Endoscopic decompression (ERCP + sphincterotomy) may prevent recurrence'),
        spacer(),

        h2('6.5 Gallbladder Pathology'),
        h3('Follicular (Calculous) Cholecystitis - Histopathology in this case'),
        bullet('Calculous cholecystitis: Chronic inflammation of the gallbladder caused by gallstones'),
        bullet('Gross: Thickened, fibrotic wall; stones; may show Rokitansky-Aschoff sinuses'),
        bullet('"Follicular" refers to the presence of lymphoid follicles with germinal centres in the wall - an immune reaction to chronic inflammation'),
        bullet('Microscopy: Mucosal ulceration, submucosal fibrosis, lymphoid infiltrate, Rokitansky-Aschoff sinuses (pseudodiverticula of mucosa into muscular layer)'),
        bullet('Management: Cholecystectomy is curative'),
        spacer(),
        h3('Cholelithiasis'),
        bullet('Cholesterol stones (80%): Radiolucent, associated with obesity, female sex, pregnancy, rapid weight loss; "5 Fs" - Fat, Female, Fertile, Forty, Fair'),
        bullet('Pigment stones: Black (haemolytic disease, cirrhosis) or Brown (infection, biliary stasis)'),
        bullet('Mixed stones: Most common overall in clinical practice'),
        spacer(),

        h2('6.6 Periampullary Carcinoma vs. Carcinoma Head of Pancreas'),
        threeColTable([
          ['Carcinoma Ampulla of Vater', 'Intermittent (fluctuating) jaundice', 'Best prognosis; 5-yr survival 40-60%'],
          ['Carcinoma Distal CBD', 'Progressive jaundice', '5-yr survival 20-30%'],
          ['Carcinoma Head of Pancreas', 'Progressive painless jaundice; weight loss; Courvoisier\'s sign', 'Worst prognosis; <10% 5-yr survival'],
          ['Carcinoma Periampullary Duodenum', 'Obstruction, bleeding', '5-yr survival 30-50%'],
        ], 'Tumour', 'Presentation', 'Prognosis'),
        spacer(),
        boldPara('Courvoisier\'s Law', 'In obstructive jaundice, if the gallbladder is palpable and non-tender, the obstruction is unlikely to be due to stones (stone disease causes fibrotic, non-distensible GB). More likely a periampullary tumour.'),
        spacer(),
        pageBreak(),

        // ===================== SECTION 7: POSSIBLE QUESTIONS =====================
        h1('SECTION 7: EXPECTED QUESTIONS FROM THE DAIS - WITH MODEL ANSWERS'),
        para('These are the most likely questions you will face at the CPC. Each answer is concise and based on the presented case and standard surgical literature.'),
        spacer(),

        h2('7.1 Questions on the Case'),
        qaBox(
          'Why was the diagnosis labelled "asymptomatic" Lemmel syndrome if the CBD was dilated?',
          'Because Lemmel syndrome is defined by CBD compression causing biliary obstruction; in THIS case the LFTs were COMPLETELY NORMAL (Total bilirubin 0.72, ALP 75, AST/ALT 17/12) despite MRCP showing a dilated CBD of 9.6 mm. There was no biochemical evidence of biliary obstruction, no jaundice, no cholangitis. The dilatation was a purely radiological finding, most likely intermittent and compensated. This distinguishes "asymptomatic" from "classic/symptomatic" Lemmel syndrome.'
        ),
        spacer(),
        qaBox(
          'Why was ERCP NOT performed in this patient?',
          'The indications for ERCP in Lemmel syndrome are: obstructive jaundice with raised bilirubin, recurrent cholangitis, GI bleeding, pancreatitis, or diverticulitis. This patient had NONE of these - LFTs were normal, no jaundice, no cholangitis, no pancreatitis. There was no biochemical obstruction to relieve. Performing ERCP in this setting would expose the patient to unnecessary procedural risks (perforation, post-ERCP pancreatitis, cholangitis, bleeding) without clinical benefit. The principle is "treat the patient, not the imaging."'
        ),
        spacer(),
        qaBox(
          'What is the significance of a mildly elevated WBC (11,420) in this patient?',
          'The mild leucocytosis here is likely a reactive/stress response rather than indicating active infection. There was no fever with chills, no localising signs of cholangitis (no jaundice, no spiking temperature), CRP was only 5 mg/L. The context of 2 years of intermittent biliary colic with a recent acute episode likely explains the mild inflammatory response. Active infection would typically show WBC >12,000-15,000, elevated CRP >50-100 mg/L, and systemic signs.'
        ),
        spacer(),
        qaBox(
          'Would you have done an intraoperative cholangiogram (IOC) in this case?',
          'IOC was not reported here. Given the pre-operative MRCP showing NO filling defect in CBD (CBD clear), and completely normal LFTs including bilirubin and ALP, IOC may not have been mandatory. However, some surgeons argue IOC should be performed routinely or when CBD is dilated (9.6 mm on MRCP) even with normal LFTs, to definitively exclude choledocholithiasis before cholecystectomy. The decision should be individualised based on clinical suspicion and available expertise.'
        ),
        spacer(),
        qaBox(
          'What is the Li-Tanaka classification and how is it relevant here?',
          'Li-Tanaka classifies periampullary diverticula based on the position of the major duodenal papilla relative to the diverticulum. Type I: papilla inside the diverticulum. Type II: papilla at the margin (IIa inside, IIb outside <1cm). Type III: papilla outside ≥1cm. Type IV: ≥2 diverticula. This is relevant because it predicts the technical difficulty of ERCP cannulation - Type I is the most challenging as the papilla is buried inside the diverticulum. In this case, the classification was not specified, but identifying it would be important if ERCP were planned.'
        ),
        spacer(),

        h2('7.2 Questions on Lemmel Syndrome Pathophysiology'),
        qaBox(
          'What is the exact mechanism by which a periampullary diverticulum causes CBD compression?',
          'Three mechanisms: (1) DIRECT MECHANICAL COMPRESSION: The diverticulum, when filled with food/fluid/air, physically compresses the distal CBD or pancreatic duct running in the adjacent pancreaticoduodenal groove. (2) SPHINCTER OF ODDI DYSFUNCTION: Chronic mechanical irritation from the adjacent diverticulum leads to fibrous thickening and dysfunction of the sphincter of Oddi, impairing biliary flow. (3) CHRONIC INFLAMMATION: Recurrent diverticulitis causes progressive fibrosis around the papilla and distal CBD, leading to biliary stricture.'
        ),
        spacer(),
        qaBox(
          'Why is Lemmel syndrome more common in elderly patients?',
          'Acquired duodenal diverticula develop due to progressive weakening of intestinal smooth muscle at sites of entry of blood vessels (locus minoris resistentiae) secondary to increased intraduodenal pressure and age-related loss of muscle tone and elastin/collagen integrity. Prevalence increases from <5% in young adults to 10-15% by age 80. Additionally, older patients have longer cumulative exposure to the diverticular compression effect on the CBD.'
        ),
        spacer(),
        qaBox(
          'What is the "double-duct sign" in the context of Lemmel syndrome?',
          'The double-duct sign refers to simultaneous dilatation of both the common bile duct AND the main pancreatic duct on MRCP or CT. It occurs when the periampullary diverticulum compresses BOTH ductal systems simultaneously. While classically associated with malignancy (carcinoma head of pancreas), it can also occur in Lemmel syndrome. The KEY DIFFERENTIATOR is the absence of a discrete mass lesion and the presence of a periampullary diverticulum on imaging in Lemmel syndrome.'
        ),
        spacer(),

        h2('7.3 Questions on Anatomy'),
        qaBox(
          'What are the relations of the second part of the duodenum (D2)?',
          'D2 (Descending duodenum): Anterior - transverse colon, right lobe of liver, gallbladder. Posterior - right kidney, right renal vessels, right ureter, right psoas muscle, hilum of right kidney. Medial - head of pancreas, CBD (grooves the medial wall), portal vein. Lateral - ascending colon (right colic flexure/hepatic flexure), right lobe of liver. The major duodenal papilla opens on the posteromedial wall of D2 approximately 7-10 cm from the pylorus. This is the site where periampullary diverticula arise.'
        ),
        spacer(),
        qaBox(
          'Describe the sphincter of Oddi and its relevance.',
          'The sphincter of Oddi is a complex of smooth muscle sphincters at the confluence of the CBD, pancreatic duct, and the ampullary common channel within the wall of D2. It comprises: (1) Sphincter choledochus (around distal CBD), (2) Sphincter pancreaticus (around distal pancreatic duct), (3) Sphincter ampullae (around the common channel). It regulates flow of bile and pancreatic juice into the duodenum. Cholecystokinin (CCK) and secretin relax it; somatostatin contracts it. Dysfunction leads to biliary pain, elevated LFTs, and is implicated in Lemmel syndrome pathogenesis.'
        ),
        spacer(),
        qaBox(
          'What are the segments of the CBD and which is most affected in Lemmel syndrome?',
          'The CBD has 4 segments: (1) Supraduodenal: From junction of cystic duct + hepatic duct to upper border of D1; ~2.5 cm. (2) Retroduodenal: Behind D1; ~1.5 cm. (3) Intrapancreatic: Within the head of pancreas; ~2.5 cm. (4) Intraduodenal: Within the wall of D2; ~1.5 cm - ends at the ampulla of Vater. In Lemmel syndrome, the INTRAPANCREATIC and INTRADUODENAL segments are most vulnerable to extrinsic compression by the periampullary diverticulum, as this is where the diverticulum is anatomically adjacent to the CBD.'
        ),
        spacer(),

        h2('7.4 Radiology Questions'),
        qaBox(
          'What are the CT and MRCP features that help diagnose Lemmel syndrome?',
          'CT: (1) Thin-walled or no-walled cavitary lesion on the medial wall of D2, containing air ± fluid ± enterolith. (2) Oral contrast fills the diverticulum from the duodenal lumen (pathognomonic). (3) CBD dilatation upstream, possibly pancreatic duct dilatation. (4) No discrete mass lesion. (5) Gallbladder may be distended if outflow obstruction is severe. MRCP: (1) T2 hyperintense cystic/air structure on medial D2 wall. (2) Dilated CBD and/or pancreatic duct upstream. (3) No filling defect within CBD (distinguishes from choledocholithiasis). (4) No periampullary enhancing mass (distinguishes from tumour). KEY: Diagnosis is made by EXCLUDING other causes (stones, tumour) AND demonstrating the PAD compressing the CBD.'
        ),
        spacer(),
        qaBox(
          'How do you distinguish Lemmel syndrome from carcinoma head of pancreas on MRCP?',
          'Carcinoma head of pancreas: Progressive jaundice, weight loss, CA 19-9 markedly elevated; MRCP shows an enhancing mass in the pancreatic head with abrupt cut-off of CBD and/or pancreatic duct (malignant stricture); upstream dilatation severe; double-duct sign; no diverticulum. Lemmel syndrome: Intermittent jaundice or asymptomatic; CA 19-9 normal; MRCP shows a T2 hyperintense air/fluid-containing lesion (diverticulum) on medial D2 wall; no discrete enhancing mass; compression is extrinsic, not intrinsic; characteristic periampullary location of the lesion.'
        ),
        spacer(),

        h2('7.5 Management Questions'),
        qaBox(
          'What are the surgical options if ERCP fails or is contraindicated in Lemmel syndrome?',
          'Surgical options include: (1) Diverticulectomy - excision of the diverticulum with primary duodenal closure (risk: duodenal leak/fistula); (2) Transduodenal sphincteroplasty - surgical opening of sphincter of Oddi to achieve biliary decompression; (3) Roux-en-Y hepaticojejunostomy - biliary bypass, used when CBD has been damaged or primary repair is not feasible; (4) Duodenectomy (partial) - for very large diverticula in a favourable location; (5) Whipple\'s procedure (pancreaticoduodenectomy) - reserved for cases with suspected malignancy or complex periampullary disease not amenable to lesser procedures.'
        ),
        spacer(),
        qaBox(
          'In a patient with Lemmel syndrome + cholangitis, what is the sequence of management?',
          'In acute cholangitis with suspected Lemmel syndrome: (1) Resuscitation - IV fluids, correct coagulopathy. (2) IV antibiotics - broad spectrum covering gram-negative bacteria and anaerobes (e.g., piperacillin-tazobactam or ciprofloxacin + metronidazole). (3) BILIARY DECOMPRESSION - urgent ERCP + sphincterotomy (first-line); PTBD (percutaneous transhepatic biliary drainage) if ERCP fails or is not possible; surgical drainage if both fail. (4) Identify and treat underlying cause - Confirm PAD, rule out stones/tumour, treat diverticulitis if present. (5) Follow-up - Consider definitive surgical management if cholangitis recurs despite endoscopic therapy.'
        ),
        spacer(),
        qaBox(
          'What is the ERCP sphincterotomy rate of success in periampullary diverticulum cases?',
          'ERCP cannulation success in periampullary diverticulum is significantly lower than in normal anatomy: 62.4% vs 92.7% (some series). After excluding cases where the papilla could not even be identified, success rates improve to ~94-95%. The difficulty depends on the Li-Tanaka type: Type I (papilla inside diverticulum) is hardest. Various techniques (two-device method, position change, saline instillation) can improve success rates in experienced hands.'
        ),
        spacer(),
        pageBreak(),

        // ===================== SECTION 8: HIGH-YIELD FACTS =====================
        h1('SECTION 8: HIGH-YIELD FACTS & QUICK REVISION TABLE'),

        h2('8.1 Key Definitions'),
        twoColTable([
          ['Lemmel Syndrome', 'CBD compression by periampullary duodenal diverticulum WITHOUT choledocholithiasis or tumour'],
          ['Periampullary Diverticulum (PAD)', 'Outpouching of duodenal wall within 2-3 cm of ampulla of Vater'],
          ['Ampulla of Vater', 'Confluence of CBD and main pancreatic duct opening at major duodenal papilla in D2'],
          ['Sphincter of Oddi', 'Complex of smooth muscle sphincters regulating bile/pancreatic juice flow at the ampulla'],
          ['Double-Duct Sign', 'Simultaneous dilatation of CBD + pancreatic duct; classically malignancy, but also in Lemmel syndrome'],
          ['Courvoisier\'s Law', 'Palpable non-tender GB in jaundiced patient = unlikely stones; likely tumour'],
          ['Charcot\'s Triad', 'RUQ pain + fever + jaundice = acute cholangitis'],
          ['Reynolds\' Pentad', 'Charcot\'s triad + hypotension + altered sensorium = septic/ascending cholangitis'],
          ['Mirizzi Syndrome', 'CBD compression by stone in cystic duct/Hartmann\'s pouch'],
          ['Rokitansky-Aschoff Sinuses', 'Pseudodiverticula of gallbladder mucosa into muscular layer - seen in chronic cholecystitis'],
        ], 'Term', 'Definition'),
        spacer(),

        h2('8.2 Mnemonics & Memory Aids'),
        highlightBox([
          '"LEMMEL" - Learning Every Mechanism Makes Extrinsic Lesion (Lemmel = Luminal/periampullary diverticulum causing Extrinsic compression of CBD = Masquerades as biliary obstruction Even with normal LFTs)',
          '',
          '"5 Fs of Cholelithiasis" - Fat, Female, Fertile (pregnant/OCPs), Forty (age >40), Fair (light-skinned / genetic)',
          '',
          '"Reynolds\' Pentad" = Charcot\'s Triad + 2 bad signs (hypotension + mental status change) = life-threatening ascending cholangitis',
          '',
          'Double-Duct Sign: Think "2 dilated ducts" = always think MALIGNANCY first, but do not forget Lemmel in the right clinical context',
          '',
          'Courvoisier\'s Rule: "No stones = No fibrosis = GB distends" - palpable non-tender GB in jaundice = periampullary malignancy until proven otherwise'
        ]),
        spacer(),

        h2('8.3 Treatment Algorithm Summary'),
        threeColTable([
          ['Asymptomatic Lemmel (this case)', 'Conservative; observe; treat co-morbidities', 'NO ERCP, NO surgery'],
          ['Obstructive Jaundice / Cholangitis', 'ERCP + sphincterotomy + biliary stent if needed', 'Antibiotics if infection'],
          ['ERCP Failure (technical)', 'PTBD (percutaneous transhepatic biliary drainage)', 'Bridging to definitive surgery'],
          ['Recurrent Cholangitis post-ERCP', 'Surgical options: diverticulectomy, hepaticojejunostomy', 'Tailored to anatomy'],
          ['Diverticular perforation', 'Emergency surgery: primary repair vs. diversion', 'ICU support if needed'],
          ['Associated Pancreatitis', 'Conservative + ERCP to decompress pancreatic duct if obstructed', 'Per Atlanta severity'],
        ], 'Scenario', 'Primary Management', 'Notes'),
        spacer(),

        h2('8.4 Recent Literature (PubMed 2022-2024)'),
        bullet('Lemmel Syndrome remains a CASE REPORT-level diagnosis; no RCTs or meta-analyses. All evidence is from case series and single-centre reports.'),
        bullet('Battah et al., Cureus 2023 (PMID 37069880): Emphasises Lemmel\'s as a rare complication of PAD; CT and MRCP are key; management should be tailored to symptom severity.'),
        bullet('Maloku & Aybay, Int J Surg Case Rep 2023 (PMID 37087935): Documents misdiagnosis as pancreatic head tumour in 2 cases; highlights importance of CT oral contrast and MRCP for differentiation.'),
        bullet('Ali et al., Cureus 2024 (PMID 39205778): "Surgical Enigma" - discusses the complexity of surgical decision-making; advocates for endoscopy-first approach.'),
        bullet('Nathyal et al., Cureus 2024 (PMID 39735110): Detailed CT findings in Lemmel syndrome; oral contrast CT is pathognomonic when contrast fills the diverticulum.'),
        bullet('Krisem et al., JCIS 2023: Large PAD (8.3 cm) causing double-duct sign; MRCP confirmed diagnosis; conservative treatment adequate initially.'),
        spacer(),
        pageBreak(),

        // ===================== SECTION 9: TAKE-HOME MESSAGES =====================
        h1('SECTION 9: TAKE-HOME MESSAGES'),
        spacer(),
        greenBox([
          '1. Lemmel syndrome is a RARE but IMPORTANT cause of obstructive jaundice caused by periampullary duodenal diverticulum compressing the CBD - WITHOUT stones or tumour.',
          '',
          '2. The defining investigation is MRCP - it shows the T2 hyperintense periampullary lesion and confirms absence of CBD stones or tumour.',
          '',
          '3. NOT every CBD dilatation on imaging warrants intervention - if LFTs are normal and patient is asymptomatic, CONSERVATIVE MANAGEMENT is appropriate.',
          '',
          '4. The key diagnostic challenge is distinguishing Lemmel syndrome from periampullary malignancy. No mass, no weight loss, air in the diverticulum, and normal CA19-9 favour Lemmel.',
          '',
          '5. When intervention IS needed, ERCP + sphincterotomy is the first-line approach; surgical options (diverticulectomy, hepaticojejunostomy) are reserved for failed endoscopy or complications.',
          '',
          '6. Clinico-radio-pathological correlation is the cornerstone of CPC diagnosis. In this case, normal LFTs despite radiological CBD dilatation was the critical clue.'
        ]),
        spacer(),

        h2('References'),
        numbered('Lemmel G. Uber Duodenaldivertikel und ihre klinische Bedeutung. Arch Verdauungskr. 1934.'),
        numbered('Love JS, Yellen M, Melitas C, Yazici C, Zar F. Diagnosis and Management of Lemmel Syndrome: Case Rep Gastroenterol. 2022;16(3):663-674.'),
        numbered('Krisem M, Hirunpat P, Tungtrongchitr N. Lemmel Syndrome, a Rare Cause of Obstructive Jaundice by Periampullary Duodenal Diverticulum. J Clin Imaging Sci. 2023;13:11.'),
        numbered('Battah A, Farouji I, DaCosta TR. Lemmel\'s Syndrome: A Rare Complication of Periampullary Diverticula. Cureus. 2023 Mar. PMID: 37069880.'),
        numbered('Maloku H, Nuh Aybay M. Periampullary diverticulitis (Lemmel\'s syndrome) misdiagnosed as pancreatic head tumour: A report of two cases. Int J Surg Case Rep. 2023 May. PMID: 37087935.'),
        numbered('Ali IM, Shetty SK, Shetty V. Lemmel Syndrome: A Surgical Enigma. Cureus. 2024 Jul. PMID: 39205778.'),
        numbered('Nathyal S, Malgotra S, Mahajan M. Computed Tomographic Findings in Lemmel Syndrome. Cureus. 2024 Nov. PMID: 39735110.'),
        numbered('Altonbary AY, Bahgat MH. Endoscopic retrograde cholangiopancreatography in periampullary diverticulum: The challenge of cannulation. World J Gastrointest Endosc. 2016;8(6):282-287.'),
        numbered('Clinical Gastrointestinal Endoscopy, Expert Consult, 3rd Edition - Periampullary Duodenal Diverticula chapter.'),
        numbered('Yeo CJ (ed). Shackelford\'s Surgery of the Alimentary Tract, 8th Edition.'),
        spacer(),
        spacer(),
        new Paragraph({
          children: [new TextRun({ text: 'END OF CPC STUDY MATERIAL', bold: true, size: 24, font: 'Arial', color: '888888' })],
          alignment: AlignmentType.CENTER,
          border: { top: { color: '1B3A6B', size: 8, style: BorderStyle.SINGLE } },
          spacing: { before: 240, after: 240 }
        })
      ]
    }]
  });

  const buffer = await Packer.toBuffer(doc);
  fs.writeFileSync('/home/daytona/workspace/lemmel-cpc/Lemmel_Syndrome_CPC_Study_Material.docx', buffer);
  console.log('Document written successfully!');
  console.log('Size:', buffer.length, 'bytes');
}

buildDoc().catch(e => { console.error('ERROR:', e.message); process.exit(1); });
Running Command

cd /home/daytona/workspace/lemmel-cpc && npm install docx 2>&1 | tail -5 && node…

This is a shared conversation. Sign in to Orris to start your own chat.