Pancreatitis and abscess This both surgery topics medha naku ippudu quiz vundhi so please help me time ledhu naku neet ga ardham iyye la help chei also references should ne from swarts textbook only ok na also neet ga explain chei or oka pdf chesi ivvu e topics lo main ga chuskovalsimavi enti enti viii clinical signs pathophysiology tests to be done to assess and how to treat what is the presentation of the patient with particular diseases how the patient presents symptoms procedures to be done anni ila arrange chesi ivvu also treatment kuda
mkdir -p /tmp/workspace/surgery-quiz && ls /tmp/workspace/surgery-quiz/
cat << 'PYEOF' > /tmp/workspace/surgery-quiz/generate_pdf.py from reportlab.lib.pagesizes import A4 from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle from reportlab.lib.units import cm from reportlab.lib import colors from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, HRFlowable, PageBreak from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_JUSTIFY doc = SimpleDocTemplate( "/tmp/workspace/surgery-quiz/Pancreatitis_and_Abscess_QuizPrep.pdf", pagesize=A4, rightMargin=2*cm, leftMargin=2*cm, topMargin=2*cm, bottomMargin=2*cm ) styles = getSampleStyleSheet() # Custom styles title_style = ParagraphStyle('Title', parent=styles['Title'], fontSize=20, textColor=colors.HexColor('#1a3a5c'), spaceAfter=8, alignment=TA_CENTER, fontName='Helvetica-Bold') h1_style = ParagraphStyle('H1', parent=styles['Heading1'], fontSize=16, textColor=colors.white, backColor=colors.HexColor('#1a3a5c'), spaceBefore=14, spaceAfter=6, leftIndent=-10, rightIndent=-10, fontName='Helvetica-Bold', borderPad=6) h2_style = ParagraphStyle('H2', parent=styles['Heading2'], fontSize=13, textColor=colors.HexColor('#1a3a5c'), spaceBefore=10, spaceAfter=4, fontName='Helvetica-Bold', borderWidth=0, borderColor=colors.HexColor('#1a3a5c'), borderPad=2) h3_style = ParagraphStyle('H3', parent=styles['Heading3'], fontSize=11, textColor=colors.HexColor('#c0392b'), spaceBefore=8, spaceAfter=3, fontName='Helvetica-Bold') body_style = ParagraphStyle('Body', parent=styles['Normal'], fontSize=9.5, leading=14, spaceAfter=4, alignment=TA_JUSTIFY) bullet_style = ParagraphStyle('Bullet', parent=styles['Normal'], fontSize=9.5, leading=13, leftIndent=15, spaceAfter=2, bulletIndent=5) ref_style = ParagraphStyle('Ref', parent=styles['Normal'], fontSize=8, textColor=colors.HexColor('#666666'), fontName='Helvetica-Oblique', spaceAfter=2, leftIndent=10) highlight_style = ParagraphStyle('Highlight', parent=styles['Normal'], fontSize=9.5, leading=13, backColor=colors.HexColor('#fff3cd'), borderColor=colors.HexColor('#ffc107'), borderWidth=1, borderPad=4, spaceAfter=6) story = [] # TITLE PAGE story.append(Spacer(1, 1*cm)) story.append(Paragraph("SURGERY QUIZ PREP", title_style)) story.append(Paragraph("Pancreatitis & Surgical Abscess", ParagraphStyle('Sub', parent=styles['Title'], fontSize=14, textColor=colors.HexColor('#c0392b'), alignment=TA_CENTER))) story.append(Spacer(1, 0.3*cm)) story.append(Paragraph("Reference: Schwartz's Principles of Surgery, 11th Edition", ref_style)) story.append(HRFlowable(width="100%", thickness=2, color=colors.HexColor('#1a3a5c'))) story.append(Spacer(1, 0.5*cm)) # TABLE OF CONTENTS INFO BOX toc_data = [ ['TOPIC', 'PAGE'], ['PART 1: ACUTE PANCREATITIS', '1'], [' - Definition & Epidemiology', ''], [' - Etiology (Causes)', ''], [' - Pathophysiology', ''], [' - Clinical Presentation (How patient presents)', ''], [' - Clinical Signs', ''], [' - Investigations / Tests', ''], [' - Severity Scoring (Ranson\'s, APACHE, BISAP, SOFA)', ''], [' - Classification of Complications', ''], [' - Treatment / Management', ''], ['PART 2: CHRONIC PANCREATITIS', '2'], [' - Definition & Causes', ''], [' - Clinical Presentation', ''], [' - Investigations', ''], [' - Treatment', ''], ['PART 3: PANCREATIC ABSCESS', '3'], [' - Definition & Pathophysiology', ''], [' - Clinical Presentation', ''], [' - Investigations', ''], [' - Treatment / Drainage Procedures', ''], ['PART 4: SURGICAL ABSCESS (General)', '4'], [' - Anorectal Abscess', ''], [' - Subphrenic & Hematogenous Abscess', ''], ] toc_table = Table(toc_data, colWidths=[13*cm, 2*cm]) toc_table.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,0), colors.HexColor('#1a3a5c')), ('TEXTCOLOR', (0,0), (-1,0), colors.white), ('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'), ('FONTSIZE', (0,0), (-1,0), 10), ('FONTSIZE', (0,1), (-1,-1), 9), ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.HexColor('#f0f4f8'), colors.white]), ('GRID', (0,0), (-1,-1), 0.5, colors.HexColor('#cccccc')), ('VALIGN', (0,0), (-1,-1), 'MIDDLE'), ('TOPPADDING', (0,0), (-1,-1), 4), ('BOTTOMPADDING', (0,0), (-1,-1), 4), ])) story.append(toc_table) story.append(PageBreak()) # ============================================================ # PART 1: ACUTE PANCREATITIS # ============================================================ story.append(Paragraph("PART 1: ACUTE PANCREATITIS", h1_style)) story.append(Spacer(1, 0.3*cm)) story.append(Paragraph("1. DEFINITION & EPIDEMIOLOGY", h2_style)) story.append(Paragraph( "Acute pancreatitis is an <b>inflammatory disorder of the pancreas</b> characterized by edema and, when severe, necrosis. " "It ranges from mild, self-limiting inflammation to severe and critical disease with infected pancreatic necrosis, " "multiple organ failure, and high mortality.", body_style)) epi_data = [ ['Key Fact', 'Detail'], ['Most common GI discharge diagnosis (USA)', '274,119 cases in 2009'], ['Incidence', '5-80 per 100,000 population worldwide'], ['Incidence trend', '+30% since 2000'], ['Mortality', '1 per 100,000 overall; varies by severity'], ['Mild disease mortality', '<1%'], ['Moderate disease mortality', '~10%'], ['Severe disease mortality', '20-40%'], ['Critical disease mortality', '>50%'], ['Peak incidence', 'Native Americans: 4/100K; Whites: 5.7/100K; Blacks: 20.7/100K'], ] t = Table(epi_data, colWidths=[8*cm, 7*cm]) t.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,0), colors.HexColor('#2980b9')), ('TEXTCOLOR', (0,0), (-1,0), colors.white), ('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'), ('FONTSIZE', (0,0), (-1,-1), 9), ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.HexColor('#eaf4fb'), colors.white]), ('GRID', (0,0), (-1,-1), 0.5, colors.grey), ('TOPPADDING', (0,0), (-1,-1), 3), ('BOTTOMPADDING', (0,0), (-1,-1), 3), ])) story.append(t) story.append(Spacer(1, 0.3*cm)) story.append(Paragraph("2. ETIOLOGY (CAUSES) - Remember: GET SMASHED", h2_style)) story.append(Paragraph("<b>Most common: Gallstones + Alcohol = 80% of cases</b>", highlight_style)) causes = [ ["G", "Gallstones (most common)", "Stone impaction in sphincter of Oddi → ductal hypertension"], ["E", "Ethanol (Alcohol)", "Acinar cell injury, sphincter spasm, protein plugs"], ["T", "Trauma", "External, surgical, ERCP (~5-10% of procedures)"], ["S", "Steroids", "Drug-induced"], ["M", "Mumps / Infections", "Viral, bacterial"], ["A", "Autoimmune", "Autoimmune pancreatitis"], ["S", "Scorpion sting / Venom", "Scorpion venom"], ["H", "Hyperlipidemia / Hypercalcemia", "Metabolic causes"], ["E", "ERCP", "Iatrogenic (most common iatrogenic cause)"], ["D", "Drugs / Divisum", "Pancreas divisum, various drugs"], ] cause_table = Table(causes, colWidths=[1*cm, 5*cm, 9*cm]) cause_table.setStyle(TableStyle([ ('FONTNAME', (0,0), (-1,-1), 'Helvetica'), ('FONTSIZE', (0,0), (-1,-1), 9), ('BACKGROUND', (0,0), (0,-1), colors.HexColor('#1a3a5c')), ('TEXTCOLOR', (0,0), (0,-1), colors.white), ('FONTNAME', (0,0), (0,-1), 'Helvetica-Bold'), ('FONTSIZE', (0,0), (0,-1), 11), ('ROWBACKGROUNDS', (1,0), (-1,-1), [colors.HexColor('#fdf2e9'), colors.white]), ('GRID', (0,0), (-1,-1), 0.5, colors.grey), ('TOPPADDING', (0,0), (-1,-1), 3), ('BOTTOMPADDING', (0,0), (-1,-1), 3), ('VALIGN', (0,0), (-1,-1), 'MIDDLE'), ])) story.append(cause_table) story.append(Spacer(1, 0.3*cm)) story.append(Paragraph("3. PATHOPHYSIOLOGY", h2_style)) story.append(Paragraph("<b>Key Concept:</b> Premature, intrapancreatic activation of digestive enzymes → auto-digestion (Chiari, 1896)", highlight_style)) story.append(Paragraph("Step-by-step mechanism:", h3_style)) path_steps = [ ("Step 1", "Injurious stimulus (gallstone, alcohol, etc.) acts on acinar cells"), ("Step 2", "Sustained cytosolic calcium increase → zymogens colocalize with lysosomal enzymes (cathepsin B)"), ("Step 3", "Cathepsin B activates trypsinogen → trypsin (within colocalization vacuoles)"), ("Step 4", "Trypsin permeabilizes vacuoles → releases cathepsin B into cytosol → apoptotic cascade"), ("Step 5", "Trypsin activates other zymogens: elastase, phospholipase A2, chymotrypsin, kallikrein"), ("Step 6", "Activated enzymes cause pancreatic parenchymal necrosis + autodigestion"), ("Step 7", "Local: edema, fat necrosis, vascular damage, hemorrhage"), ("Step 8", "Systemic: SIRS → cytokine storm → MODS (multi-organ dysfunction syndrome)"), ] for step, desc in path_steps: story.append(Paragraph(f"<b>{step}:</b> {desc}", bullet_style)) story.append(Spacer(1, 0.2*cm)) story.append(Paragraph("Alcohol mechanism specifically:", h3_style)) story.append(Paragraph("• Acinar cells metabolize ethanol → predisposes to autodigestive injury + necroinflammation", bullet_style)) story.append(Paragraph("• Stellate cells activated → myofibroblast phenotype → pro-inflammatory cytokines", bullet_style)) story.append(Paragraph("• Brief secretory burst + sphincter of Oddi spasm → triggers pancreatitis", bullet_style)) story.append(Paragraph("• ↑ protein content of pancreatic juice + ↓ bicarbonate + ↓ trypsin inhibitor", bullet_style)) story.append(Paragraph("• Formation of protein plugs → obstructs pancreatic outflow", bullet_style)) story.append(Spacer(1, 0.3*cm)) story.append(Paragraph("4. CLINICAL PRESENTATION (How the Patient Presents)", h2_style)) story.append(Paragraph("Typical patient story:", h3_style)) story.append(Paragraph( "Patient comes with <b>sudden onset severe epigastric pain</b>, often radiating to the back (belt-like), " "after a heavy meal or alcohol intake (gallstone patient: elderly female; alcohol patient: young male). " "Accompanied by nausea, vomiting, and abdominal tenderness.", highlight_style)) presentation_data = [ ['Feature', 'Details'], ['PAIN', 'Severe epigastric pain, constant, radiating to back/flanks\n"Belt-like" or "boring" pain'], ['ONSET', 'Sudden, after heavy meal or alcohol binge'], ['NAUSEA/VOMITING', 'Present; vomiting does not relieve pain'], ['FEVER', 'Low-grade initially; high fever if infected necrosis/abscess'], ['POSITION', 'Patient leans forward to relieve pain (knee-chest/fetal position)'], ['JAUNDICE', 'If gallstone obstructs CBD (rare in acute presentation)'], ['SHOCK', 'In severe cases: hypotension, tachycardia'], ] pt = Table(presentation_data, colWidths=[4*cm, 11*cm]) pt.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,0), colors.HexColor('#27ae60')), ('TEXTCOLOR', (0,0), (-1,0), colors.white), ('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'), ('FONTSIZE', (0,0), (-1,-1), 9), ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.HexColor('#eafaf1'), colors.white]), ('GRID', (0,0), (-1,-1), 0.5, colors.grey), ('TOPPADDING', (0,0), (-1,-1), 3), ('BOTTOMPADDING', (0,0), (-1,-1), 3), ('VALIGN', (0,0), (-1,-1), 'TOP'), ])) story.append(pt) story.append(Spacer(1, 0.3*cm)) story.append(Paragraph("5. CLINICAL SIGNS (Examination Findings)", h2_style)) signs_data = [ ['Sign', 'Description', 'Significance'], ['Grey Turner\'s Sign', 'Flank/loin bruising (ecchymosis)', 'Retroperitoneal hemorrhagic pancreatitis'], ['Cullen\'s Sign', 'Periumbilical bruising', 'Retroperitoneal hemorrhagic pancreatitis'], ['Fox\'s Sign', 'Bruising over inguinal ligament', 'Hemorrhagic pancreatitis'], ['Tenderness', 'Epigastric tenderness ± guarding', 'Universal finding'], ['Rigidity', 'Board-like abdomen', 'Severe disease / peritonitis'], ['Tachycardia', 'HR >100 bpm', 'Hypovolemia / SIRS'], ['Hypotension', 'BP <90 mmHg', 'Severe disease, third-spacing'], ['Tachypnea', 'RR >20', 'ARDS, pleural effusion, SIRS'], ['Jaundice', 'Scleral icterus', 'Biliary obstruction (gallstone)'], ['Fever', '>38.5°C', 'Infected necrosis, abscess, cholangitis'], ['Bowel sounds', 'Absent (ileus)', 'Peritoneal irritation'], ['Chvostek / Trousseau', 'Hypocalcemia signs', 'Saponification of peripancreatic fat'], ] st = Table(signs_data, colWidths=[4*cm, 6*cm, 5*cm]) st.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,0), colors.HexColor('#c0392b')), ('TEXTCOLOR', (0,0), (-1,0), colors.white), ('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'), ('FONTSIZE', (0,0), (-1,-1), 9), ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.HexColor('#fdf2f2'), colors.white]), ('GRID', (0,0), (-1,-1), 0.5, colors.grey), ('TOPPADDING', (0,0), (-1,-1), 3), ('BOTTOMPADDING', (0,0), (-1,-1), 3), ('VALIGN', (0,0), (-1,-1), 'TOP'), ])) story.append(st) story.append(Spacer(1, 0.3*cm)) story.append(Paragraph("6. INVESTIGATIONS / TESTS", h2_style)) story.append(Paragraph("A. Blood Tests:", h3_style)) blood_data = [ ['Test', 'Finding', 'Notes'], ['Serum Amylase', '>3x upper limit of normal', 'Rises in 2-12 hrs; normalizes in 3-5 days; NOT specific'], ['Serum Lipase', '>3x upper limit of normal', 'MORE specific & sensitive than amylase; stays elevated longer'], ['WBC', '>16,000/mm³', 'Leukocytosis (part of Ranson\'s)'], ['Blood glucose', '>200 mg/dL', 'Part of Ranson\'s criteria'], ['Serum LDH', '>350 IU/L', 'Part of Ranson\'s criteria'], ['Serum AST', '>250 U/dL', 'Part of Ranson\'s criteria'], ['Serum Calcium', '<8 mg/dL', 'Hypocalcemia (saponification) - poor prognosis sign'], ['Serum Bilirubin', 'Elevated if CBD obstruction', 'Suggests gallstone etiology'], ['Alkaline phosphatase', '>300 IU/L', 'Gallstone etiology likely'], ['ALT/AST', 'ALT >100 IU/L', 'Gallstone etiology'], ['Triglycerides', 'Markedly elevated', 'Hypertriglyceridemia cause'], ['Hematocrit', 'Elevated (hemoconcentration)', 'Fall >10 points at 48h = poor prognosis'], ['BUN', 'Elevated', 'Rise >5 mg/dL at 48h = poor prognosis'], ['Arterial PO2', '<60 mmHg', 'ARDS / respiratory failure'], ['CRP', '>150 mg/dL at 24h', 'Predicts severity (= Ranson\'s accuracy)'], ['Procalcitonin', 'Elevated', 'Suggests infected necrosis'], ] bt = Table(blood_data, colWidths=[4.5*cm, 4.5*cm, 6*cm]) bt.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,0), colors.HexColor('#8e44ad')), ('TEXTCOLOR', (0,0), (-1,0), colors.white), ('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'), ('FONTSIZE', (0,0), (-1,-1), 8.5), ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.HexColor('#f5eef8'), colors.white]), ('GRID', (0,0), (-1,-1), 0.5, colors.grey), ('TOPPADDING', (0,0), (-1,-1), 2), ('BOTTOMPADDING', (0,0), (-1,-1), 2), ('VALIGN', (0,0), (-1,-1), 'TOP'), ])) story.append(bt) story.append(Spacer(1, 0.2*cm)) story.append(Paragraph("B. Imaging:", h3_style)) imaging_data = [ ['Imaging Modality', 'Finding', 'Purpose'], ['Ultrasound (USG)', 'Gallstones, CBD dilation, edematous pancreas', 'FIRST LINE - always do; cheap, no radiation'], ['CT Scan (contrast-enhanced)', 'Pancreatic necrosis, collections, abscess', 'GOLD STANDARD for severity assessment; CT Severity Index (CTSI)'], ['MRI / MRCP', 'Distinguishes solid necrosis from fluid; CBD stones', 'Superior to CT for solid content in collections'], ['X-Ray (Abdomen erect)', 'Sentinel loop (dilated jejunum), Colon cut-off sign', 'Non-specific; rules out perforation'], ['X-Ray (Chest)', 'Pleural effusion (esp. left-sided), ARDS', 'Pulmonary complications'], ['ERCP', 'CBD stones, pancreatic duct disruption', 'THERAPEUTIC: stone extraction, stenting'], ['EUS (Endoscopic USG)', 'Microlithiasis, chronic pancreatitis changes', 'Diagnosis of occult cause'], ['Angiography / CTA', 'Pseudoaneurysm, active bleeding', 'When bleeding complication suspected'], ] it = Table(imaging_data, colWidths=[4*cm, 5.5*cm, 5.5*cm]) it.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,0), colors.HexColor('#16a085')), ('TEXTCOLOR', (0,0), (-1,0), colors.white), ('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'), ('FONTSIZE', (0,0), (-1,-1), 8.5), ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.HexColor('#e8f8f5'), colors.white]), ('GRID', (0,0), (-1,-1), 0.5, colors.grey), ('TOPPADDING', (0,0), (-1,-1), 2), ('BOTTOMPADDING', (0,0), (-1,-1), 2), ('VALIGN', (0,0), (-1,-1), 'TOP'), ])) story.append(it) story.append(PageBreak()) story.append(Paragraph("7. SEVERITY SCORING SYSTEMS", h2_style)) story.append(Paragraph("A. Ranson's Criteria (MOST IMPORTANT FOR EXAM)", h3_style)) story.append(Paragraph("<b>Non-gallstone pancreatitis:</b>", body_style)) ranson_data = [ ['AT ADMISSION', 'DURING INITIAL 48 HOURS'], ['Age > 55 years', 'Hematocrit fall > 10 points'], ['WBC > 16,000/mm³', 'BUN elevation > 5 mg/dL'], ['Blood glucose > 200 mg/dL', 'Serum calcium < 8 mg/dL'], ['Serum LDH > 350 IU/L', 'Arterial PO₂ < 60 mmHg'], ['Serum AST > 250 U/dL', 'Base deficit > 4 mEq/L'], ['', 'Estimated fluid sequestration > 6 L'], ] rt = Table(ranson_data, colWidths=[7.5*cm, 7.5*cm]) rt.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,0), colors.HexColor('#c0392b')), ('TEXTCOLOR', (0,0), (-1,0), colors.white), ('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'), ('FONTSIZE', (0,0), (-1,-1), 9), ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.HexColor('#fff5f5'), colors.white]), ('GRID', (0,0), (-1,-1), 0.5, colors.grey), ('TOPPADDING', (0,0), (-1,-1), 3), ('BOTTOMPADDING', (0,0), (-1,-1), 3), ])) story.append(rt) story.append(Paragraph("<b>Gallstone pancreatitis:</b> Age >70y, WBC >18,000, Glucose >220, LDH >400, AST >250 | 48h: Hct fall >10, BUN >2, Ca <8, Base deficit >5, Fluid sequestration >4L", body_style)) story.append(Paragraph("✅ <b><3 criteria = Mild disease</b> | ⚠️ <b>3-5 criteria = Moderate-Severe</b> | 🚨 <b>>6 criteria = Mortality ~50%</b>", highlight_style)) story.append(Spacer(1, 0.2*cm)) story.append(Paragraph("B. Other Scoring Systems:", h3_style)) score_data = [ ['Score', 'Parameters', 'Threshold for Severe'], ['APACHE II', 'Acute physiology, age, chronic health', 'Score ≥ 8 at 24h'], ['BISAP', 'BUN >25, Impaired mental status, SIRS, Age >60, Pleural effusion', '≥ 3 points'], ['SOFA', 'Respiration, Coagulation, Liver, CVS, CNS, Renal', 'Score > 2 for each organ failure'], ['Glasgow (Modified)', '8 clinical/biochemical params over 48h', '≥ 3 positive criteria'], ['CRP', 'Single biochemical marker', '>150 mg/dL at 24h'], ['CT Severity Index', 'CT grade (A-E) + % necrosis', 'CTSI ≥ 3 = moderate/severe'], ] sct = Table(score_data, colWidths=[3.5*cm, 7*cm, 4.5*cm]) sct.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,0), colors.HexColor('#2c3e50')), ('TEXTCOLOR', (0,0), (-1,0), colors.white), ('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'), ('FONTSIZE', (0,0), (-1,-1), 8.5), ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.HexColor('#f2f3f4'), colors.white]), ('GRID', (0,0), (-1,-1), 0.5, colors.grey), ('TOPPADDING', (0,0), (-1,-1), 3), ('BOTTOMPADDING', (0,0), (-1,-1), 3), ('VALIGN', (0,0), (-1,-1), 'TOP'), ])) story.append(sct) story.append(Spacer(1, 0.3*cm)) story.append(Paragraph("8. CLASSIFICATION OF COMPLICATIONS", h2_style)) story.append(Paragraph("A. Local Complications (Revised Atlanta Classification):", h3_style)) comp_data = [ ['', 'ACUTE (<4 weeks, No defined wall)', '', 'CHRONIC (>4 weeks, Defined wall)', ''], ['Content', 'No Infection', 'Infection', 'No Infection', 'Infection'], ['FLUID', 'Acute Pancreatic Fluid Collection (APFC)', 'Infected APFC', 'PSEUDOCYST', 'Infected Pseudocyst'], ['SOLID ± FLUID', 'Acute Necrotic Collection (ANC)', 'Infected ANC', 'Walled-Off Necrosis (WON)', 'Infected WON / ABSCESS'], ] ct = Table(comp_data, colWidths=[3*cm, 3.5*cm, 2.5*cm, 3.5*cm, 2.5*cm]) ct.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,0), colors.HexColor('#7f8c8d')), ('TEXTCOLOR', (0,0), (-1,0), colors.white), ('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'), ('BACKGROUND', (0,1), (-1,1), colors.HexColor('#bdc3c7')), ('FONTNAME', (0,1), (-1,1), 'Helvetica-Bold'), ('FONTSIZE', (0,0), (-1,-1), 8.5), ('BACKGROUND', (1,2), (1,3), colors.HexColor('#eafaf1')), ('BACKGROUND', (3,2), (3,3), colors.HexColor('#eafaf1')), ('BACKGROUND', (2,2), (2,3), colors.HexColor('#fdf2f2')), ('BACKGROUND', (4,2), (4,3), colors.HexColor('#fdf2f2')), ('GRID', (0,0), (-1,-1), 0.5, colors.grey), ('TOPPADDING', (0,0), (-1,-1), 3), ('BOTTOMPADDING', (0,0), (-1,-1), 3), ('VALIGN', (0,0), (-1,-1), 'MIDDLE'), ('ALIGN', (0,0), (-1,-1), 'CENTER'), ('SPAN', (0,0), (0,1)), ])) story.append(ct) story.append(Spacer(1, 0.2*cm)) story.append(Paragraph("B. Systemic Complications:", h3_style)) sys_comp = [ ["Pulmonary", "Pleural effusion, Pneumonia, ARDS, Atelectasis"], ["Cardiovascular", "Hypotension, Hypovolemia, Pericardial effusion, ST changes, Sudden death"], ["Renal", "Oliguria, Azotemia, Renal vein/artery thrombosis"], ["Hematologic", "Hemoconcentration, DIC"], ["GI", "GI hemorrhage, Peptic ulcer, Portal/splenic vein thrombosis with varices"], ["Metabolic", "Hyperglycemia, Hypocalcemia, Hypertriglyceridemia, Encephalopathy"], ["CNS", "Psychosis, Fat emboli, Alcohol withdrawal"], ["Fat necrosis", "Intra-abdominal saponification, Subcutaneous tissue necrosis"], ["Eyes", "Purtscher's retinopathy (sudden blindness) - RARE"], ] syst = Table(sys_comp, colWidths=[4*cm, 11*cm]) syst.setStyle(TableStyle([ ('FONTSIZE', (0,0), (-1,-1), 9), ('FONTNAME', (0,0), (0,-1), 'Helvetica-Bold'), ('ROWBACKGROUNDS', (0,0), (-1,-1), [colors.HexColor('#fef9e7'), colors.white]), ('GRID', (0,0), (-1,-1), 0.5, colors.grey), ('TOPPADDING', (0,0), (-1,-1), 3), ('BOTTOMPADDING', (0,0), (-1,-1), 3), ])) story.append(syst) story.append(PageBreak()) story.append(Paragraph("9. TREATMENT / MANAGEMENT OF ACUTE PANCREATITIS", h2_style)) story.append(Paragraph("<b>Principle: No specific cure; treatment is supportive. Manage complications aggressively.</b>", highlight_style)) story.append(Paragraph("A. Initial / Emergency Management:", h3_style)) tx_steps = [ ("ADMIT", "All patients with suspected acute pancreatitis must be admitted. Transfer severe/critical to ICU / tertiary center."), ("IV FLUIDS", "MOST IMPORTANT intervention. Balanced crystalloid (Lactated Ringer's preferred over normal saline). Goal: restore BP, urine output. 5-10 mL/kg/hr initially."), ("ANALGESIA", "Adequate pain control is essential. IV opioids (morphine, pethidine) are used. No evidence one opioid is superior."), ("NPO / NUTRITION", "Do NOT 'rest the pancreas' by starvation. Early enteral nutrition within 24-72h. Nasogastric tube feeds if not tolerating oral. Parenteral nutrition only if enteral not possible."), ("OXYGEN", "Supplemental O2; monitor for ARDS."), ("CATHETER", "Urinary catheter to monitor urine output."), ("MONITORING", "Vitals, blood glucose, electrolytes, ABG, urine output continuously."), ("ANTIBIOTICS", "NOT routinely given. Only for confirmed infected necrosis/abscess (guided by CT/FNA). Carbapenems (imipenem) if given."), ("ERCP", "Early ERCP (within 24-48h) for gallstone pancreatitis with cholangitis/CBD obstruction. No benefit without cholangitis."), ("CHOLECYSTECTOMY", "After recovery from gallstone pancreatitis - same admission or within 2-4 weeks. Prevents recurrence."), ] for step, desc in tx_steps: story.append(Paragraph(f"<b>{step}:</b> {desc}", bullet_style)) story.append(Spacer(1, 0.2*cm)) story.append(Paragraph("B. Management of Local Complications:", h3_style)) local_tx = [ ['Complication', 'Treatment'], ['Acute Pancreatic Fluid Collection (APFC)', 'Usually resolves spontaneously. No intervention needed unless infected or symptomatic.'], ['Pseudocyst', 'If symptomatic / infected: endoscopic cystogastrostomy (preferred), percutaneous drain, or surgical drainage.'], ['Sterile Walled-Off Necrosis (WON)', 'Conservative management initially. Intervention if infected or causing symptoms.'], ['Infected Necrosis / Abscess', 'DRAINAGE IS MANDATORY. Step-up approach: 1) Percutaneous drain → 2) Endoscopic necrosectomy → 3) Surgical necrosectomy (last resort).'], ['Pancreatic Ascites', 'ERCP + stenting; octreotide; surgery if fails.'], ['Pseudoaneurysm', 'Angiographic embolization is treatment of choice.'], ['Hemorrhage', 'Angiography + embolization first; surgery if fails.'], ] ltx = Table(local_tx, colWidths=[5*cm, 10*cm]) ltx.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,0), colors.HexColor('#1a3a5c')), ('TEXTCOLOR', (0,0), (-1,0), colors.white), ('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'), ('FONTSIZE', (0,0), (-1,-1), 9), ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.HexColor('#eaf4fb'), colors.white]), ('GRID', (0,0), (-1,-1), 0.5, colors.grey), ('TOPPADDING', (0,0), (-1,-1), 3), ('BOTTOMPADDING', (0,0), (-1,-1), 3), ('VALIGN', (0,0), (-1,-1), 'TOP'), ])) story.append(ltx) story.append(PageBreak()) # ============================================================ # PART 2: CHRONIC PANCREATITIS # ============================================================ story.append(Paragraph("PART 2: CHRONIC PANCREATITIS", h1_style)) story.append(Spacer(1, 0.3*cm)) story.append(Paragraph("1. DEFINITION", h2_style)) story.append(Paragraph( "Chronic pancreatitis is an <b>incurable, chronic inflammatory condition</b> that is multifactorial, " "highly variable in presentation, and a challenge to treat. It results in <b>irreversible fibrosis</b> of the " "pancreatic parenchyma, leading to loss of exocrine and endocrine function.", body_style)) story.append(Paragraph("2. ETIOLOGY - Remember: TIGAR-O Classification", h2_style)) tigar_data = [ ['Category', 'Examples'], ['T - Toxic/Metabolic', 'Alcohol (most common, >50% in West), Smoking, Hypercalcemia, Hyperlipidemia, Medications'], ['I - Idiopathic', 'Early onset (<25y) or Late onset (>35y); Tropical pancreatitis'], ['G - Genetic', 'PRSS1 mutation (hereditary), SPINK1 mutation, CFTR mutation, CTRC'], ['A - Autoimmune', 'Type 1 (IgG4-related), Type 2 (IBD-associated)'], ['R - Recurrent/Severe Acute', 'Post-necrotic, Recurrent acute pancreatitis, Vascular disease/Ischemia'], ['O - Obstructive', 'Pancreatic divisum, Tumors, Sphincter of Oddi stenosis, Post-traumatic stricture'], ] tgt = Table(tigar_data, colWidths=[4.5*cm, 10.5*cm]) tgt.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,0), colors.HexColor('#d35400')), ('TEXTCOLOR', (0,0), (-1,0), colors.white), ('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'), ('FONTSIZE', (0,0), (-1,-1), 9), ('FONTNAME', (0,0), (0,-1), 'Helvetica-Bold'), ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.HexColor('#fef0e7'), colors.white]), ('GRID', (0,0), (-1,-1), 0.5, colors.grey), ('TOPPADDING', (0,0), (-1,-1), 3), ('BOTTOMPADDING', (0,0), (-1,-1), 3), ('VALIGN', (0,0), (-1,-1), 'TOP'), ])) story.append(tgt) story.append(Spacer(1, 0.3*cm)) story.append(Paragraph("3. CLINICAL PRESENTATION", h2_style)) story.append(Paragraph( "<b>Typical patient:</b> 35-45 year old male with chronic heavy alcohol use. Presents with chronic / recurrent abdominal pain, " "weight loss, and signs of pancreatic insufficiency (steatorrhea, diabetes).", highlight_style)) cp_features = [ ("Pain", "Chronic epigastric pain, dull/aching, often radiating to back. Worsened by eating. Relieved by sitting forward. Can be episodic or constant."), ("Exocrine insufficiency", "Steatorrhea (fatty, foul-smelling, floating stools), malabsorption, weight loss. Occurs when >90% of exocrine function lost."), ("Endocrine insufficiency", "Diabetes mellitus (brittle type, Type 3c), occurs late in disease."), ("Jaundice", "Biliary obstruction from pancreatic fibrosis/stricture."), ("Weight loss", "Pain after meals + malabsorption = weight loss"), ("Nausea/Vomiting", "Duodenal obstruction in severe cases"), ] for feat, desc in cp_features: story.append(Paragraph(f"<b>• {feat}:</b> {desc}", bullet_style)) story.append(Spacer(1, 0.3*cm)) story.append(Paragraph("4. INVESTIGATIONS FOR CHRONIC PANCREATITIS", h2_style)) cp_inv_data = [ ['Test', 'Finding / Purpose'], ['Serum amylase/lipase', 'Often NORMAL in chronic disease (burnt-out pancreas)'], ['Blood glucose / HbA1c', 'Endocrine insufficiency (diabetes)'], ['Fecal elastase-1', 'Most useful non-invasive test; <200 mcg/g = exocrine insufficiency'], ['72-hour fecal fat', 'Gold standard for steatorrhea; >7g/day = abnormal'], ['Plain X-ray abdomen', 'Pancreatic calcifications (PATHOGNOMONIC of chronic pancreatitis)'], ['Ultrasound', 'Dilated pancreatic duct (>3mm), calcifications, pseudocysts'], ['CT scan (CECT)', 'Calcifications, ductal dilation, atrophy, complications'], ['MRCP', 'Best non-invasive view of pancreatic duct anatomy; "chain of lakes" appearance'], ['ERCP', 'Gold standard for duct changes; Cambridge classification; therapeutic'], ['EUS (Endoscopic USG)', 'Detects early changes; Rosemont criteria (≥4 criteria = chronic pancreatitis)'], ['Secretin stimulation test', 'Direct pancreatic function test; reduced bicarbonate output'], ['IgG4 levels', 'Elevated in autoimmune pancreatitis type 1'], ['Tumor markers (CA 19-9, CEA)', 'To rule out pancreatic cancer'], ] cpinvt = Table(cp_inv_data, colWidths=[5*cm, 10*cm]) cpinvt.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,0), colors.HexColor('#8e44ad')), ('TEXTCOLOR', (0,0), (-1,0), colors.white), ('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'), ('FONTSIZE', (0,0), (-1,-1), 9), ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.HexColor('#f5eef8'), colors.white]), ('GRID', (0,0), (-1,-1), 0.5, colors.grey), ('TOPPADDING', (0,0), (-1,-1), 3), ('BOTTOMPADDING', (0,0), (-1,-1), 3), ('VALIGN', (0,0), (-1,-1), 'TOP'), ])) story.append(cpinvt) story.append(Spacer(1, 0.3*cm)) story.append(Paragraph("5. TREATMENT OF CHRONIC PANCREATITIS", h2_style)) cp_tx = [ ["LIFESTYLE", "Stop alcohol completely. Stop smoking. Low-fat diet."], ["PAIN", "Analgesics (WHO ladder); pregabalin/gabapentin; celiac plexus block (EUS-guided or CT-guided); surgery"], ["EXOCRINE SUPPLEMENTATION", "Pancreatic enzyme replacement therapy (PERT): Creon (pancrelipase). Take with meals. Fat-soluble vitamin supplementation (A, D, E, K)."], ["ENDOCRINE", "Insulin for diabetes (brittle - prone to hypoglycemia; use with care)"], ["ENDOSCOPIC", "ERCP + stenting for ductal strictures; stone extraction with lithotripsy (ESWL)"], ["SURGERY (Main options)", "1. Lateral Pancreaticojejunostomy (Puestow procedure) - for dilated duct >6mm\n2. Whipple's procedure (PPPD) - for head-dominant disease\n3. Beger procedure / Frey procedure - parenchyma-preserving options\n4. Total pancreatectomy with islet cell autotransplant (TP-IAT) - last resort"], ["COMPLICATIONS TREATMENT", "Pseudocyst drainage; biliary stricture: stenting or surgery; duodenal obstruction: gastrojejunostomy; pancreatic cancer surveillance"], ] cptxt = Table(cp_tx, colWidths=[4.5*cm, 10.5*cm]) cptxt.setStyle(TableStyle([ ('FONTNAME', (0,0), (0,-1), 'Helvetica-Bold'), ('FONTSIZE', (0,0), (-1,-1), 9), ('ROWBACKGROUNDS', (0,0), (-1,-1), [colors.HexColor('#fef9e7'), colors.white]), ('GRID', (0,0), (-1,-1), 0.5, colors.grey), ('TOPPADDING', (0,0), (-1,-1), 3), ('BOTTOMPADDING', (0,0), (-1,-1), 3), ('VALIGN', (0,0), (-1,-1), 'TOP'), ])) story.append(cptxt) story.append(PageBreak()) # ============================================================ # PART 3: PANCREATIC ABSCESS # ============================================================ story.append(Paragraph("PART 3: PANCREATIC ABSCESS", h1_style)) story.append(Spacer(1, 0.3*cm)) story.append(Paragraph("1. DEFINITION", h2_style)) story.append(Paragraph( "A pancreatic abscess is a <b>circumscribed intra-abdominal collection of pus</b> in close proximity to the pancreas, " "containing little or no pancreatic necrosis, arising as a consequence of acute pancreatitis or pancreatic trauma. " "Per revised Atlanta Classification, this now falls under <b>Infected Walled-Off Necrosis (Infected WON)</b> in modern terminology.", body_style)) story.append(Paragraph( "⚠️ Important distinction: Pancreatic abscess (pus with little necrosis) vs Infected Pancreatic Necrosis " "(solid/semi-solid necrotic tissue, infected). They differ in prognosis and management.", highlight_style)) story.append(Spacer(1, 0.2*cm)) story.append(Paragraph("2. PATHOPHYSIOLOGY", h2_style)) abs_path = [ ("Origin", "Secondary complication of acute necrotizing pancreatitis, usually developing 4-6 WEEKS after acute episode."), ("Mechanism", "Necrotic pancreatic/peripancreatic tissue becomes infected → liquefaction → abscess formation."), ("Organisms", "Commonly gram-negative: E. coli, Klebsiella, Enterococcus, Pseudomonas, Proteus. Polymicrobial. Also anaerobes."), ("Route of infection", "Translocation of gut bacteria through compromised intestinal barrier (SIRS → gut permeability ↑)"), ("Risk factors", "Severe acute pancreatitis, necrosis extent, delayed intervention, multiple organ failure"), ] for feat, desc in abs_path: story.append(Paragraph(f"<b>• {feat}:</b> {desc}", bullet_style)) story.append(Spacer(1, 0.3*cm)) story.append(Paragraph("3. CLINICAL PRESENTATION", h2_style)) story.append(Paragraph( "<b>Typical scenario:</b> Patient with recent acute pancreatitis (2-6 weeks ago) who was improving but now " "deteriorates with high-grade fever, rigors, increasing abdominal pain, and signs of sepsis.", highlight_style)) abs_pres = [ ['Feature', 'Detail'], ['Timing', '2-6 weeks AFTER acute pancreatitis episode (Late complication)'], ['Fever', 'High-grade (>38.5°C), spiking, with rigors - HALLMARK'], ['Abdominal pain', 'Persistent or worsening epigastric/upper abdominal pain'], ['Abdominal mass', 'Tender epigastric mass may be palpable'], ['Sepsis signs', 'Tachycardia, hypotension, leukocytosis - SIRS criteria met'], ['Nausea/Vomiting', 'Present; may have ileus'], ['Jaundice', 'If abscess compresses biliary system'], ['Deterioration', 'Patient was improving from pancreatitis, then deteriorates = RED FLAG for abscess'], ] absp = Table(abs_pres, colWidths=[4*cm, 11*cm]) absp.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,0), colors.HexColor('#c0392b')), ('TEXTCOLOR', (0,0), (-1,0), colors.white), ('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'), ('FONTSIZE', (0,0), (-1,-1), 9), ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.HexColor('#fdf2f2'), colors.white]), ('GRID', (0,0), (-1,-1), 0.5, colors.grey), ('TOPPADDING', (0,0), (-1,-1), 3), ('BOTTOMPADDING', (0,0), (-1,-1), 3), ('VALIGN', (0,0), (-1,-1), 'TOP'), ])) story.append(absp) story.append(Spacer(1, 0.3*cm)) story.append(Paragraph("4. INVESTIGATIONS", h2_style)) abs_inv = [ ['Test', 'Finding'], ['Blood tests', 'Leukocytosis (WBC >20,000), elevated CRP/procalcitonin, elevated bilirubin, elevated LFTs'], ['Blood cultures', 'Positive in systemic sepsis; guide antibiotics'], ['CT scan (CECT) - GOLD STANDARD', 'Gas bubbles within pancreatic/peripancreatic collection = PATHOGNOMONIC of infected necrosis/abscess. Well-defined collection with thick wall.'], ['CT-guided FNA (Fine Needle Aspiration)', 'Gram stain + culture of aspirated fluid = confirms infection. Guides antibiotic choice.'], ['Ultrasound', 'Detects collection; guides drainage; less sensitive than CT for abscess'], ['MRI', 'Differentiates solid necrosis from fluid; helps plan intervention'], ['Serum amylase', 'May be normal or elevated; not diagnostic for abscess specifically'], ] absinvt = Table(abs_inv, colWidths=[5*cm, 10*cm]) absinvt.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,0), colors.HexColor('#16a085')), ('TEXTCOLOR', (0,0), (-1,0), colors.white), ('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'), ('FONTSIZE', (0,0), (-1,-1), 9), ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.HexColor('#e8f8f5'), colors.white]), ('GRID', (0,0), (-1,-1), 0.5, colors.grey), ('TOPPADDING', (0,0), (-1,-1), 3), ('BOTTOMPADDING', (0,0), (-1,-1), 3), ('VALIGN', (0,0), (-1,-1), 'TOP'), ])) story.append(absinvt) story.append(Spacer(1, 0.3*cm)) story.append(Paragraph("5. TREATMENT (STEP-UP APPROACH - Modern Standard of Care)", h2_style)) story.append(Paragraph("<b>Principle: Drainage + Antibiotics. Minimize surgical trauma. Step-up from least invasive.</b>", highlight_style)) abs_tx_steps = [ ("STEP 1 - ANTIBIOTICS", "Broad-spectrum IV antibiotics with pancreatic penetration. Carbapenems (Imipenem/Meropenem) - best pancreatic penetration. Also: Cefuroxime, Ciprofloxacin + Metronidazole, Piperacillin-Tazobactam."), ("STEP 2 - PERCUTANEOUS DRAINAGE", "CT/USG-guided catheter drainage (PCD) - FIRST-LINE procedure. Placed into abscess cavity. Daily flushes. Drain left until output minimal."), ("STEP 3 - ENDOSCOPIC DRAINAGE", "Endoscopic transmural drainage (EUS-guided cystogastrostomy/cystoduodenostomy) + direct endoscopic necrosectomy (DEN). Now preferred over surgery for WON."), ("STEP 4 - MINIMALLY INVASIVE SURGERY", "Video-assisted retroperitoneal debridement (VARD), laparoscopic necrosectomy. If percutaneous/endoscopic fails."), ("STEP 5 - OPEN SURGICAL NECROSECTOMY", "Last resort. Only when less invasive approaches fail. High morbidity. Involves: open necrosectomy + wide drainage. Options: open packing, closed continuous lavage, planned staged reoperation."), ] for step, desc in abs_tx_steps: story.append(Paragraph(f"<b>{step}:</b> {desc}", bullet_style)) story.append(Spacer(1, 0.2*cm)) story.append(Paragraph("Mortality: Pancreatic abscess: 10-15% | Infected necrosis: 25-50%", highlight_style)) story.append(PageBreak()) # ============================================================ # PART 4: SURGICAL ABSCESS (GENERAL) # ============================================================ story.append(Paragraph("PART 4: SURGICAL ABSCESS (GENERAL - Schwartz's)", h1_style)) story.append(Spacer(1, 0.3*cm)) story.append(Paragraph("1. ANORECTAL ABSCESS & CRYPTOGLANDULAR ABSCESS", h2_style)) story.append(Paragraph("<b>Most common anorectal infection.</b> Originates from infected anal crypts → spreads to adjacent spaces.", body_style)) ar_data = [ ['Type', 'Location', 'Features & Treatment'], ['Perianal Abscess (most common)', 'Superficial, below dentate line', 'Tender perianal swelling; fluctuant. Tx: I&D under LA'], ['Ischiorectal Abscess', 'Ischiorectal fossa', 'Larger, deeper; may present as buttock swelling. Tx: I&D'], ['Intersphincteric Abscess', 'Between internal & external sphincters', 'Severe anal pain; minimal external signs. Tx: Internal sphincterotomy + drainage'], ['Supraelevator Abscess', 'Above levator ani', 'Deep; may present with systemic sepsis. Tx: Dependent on origin; CT/MRI essential'], ] art = Table(ar_data, colWidths=[4*cm, 4*cm, 7*cm]) art.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,0), colors.HexColor('#2c3e50')), ('TEXTCOLOR', (0,0), (-1,0), colors.white), ('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'), ('FONTSIZE', (0,0), (-1,-1), 9), ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.HexColor('#eaf4fb'), colors.white]), ('GRID', (0,0), (-1,-1), 0.5, colors.grey), ('TOPPADDING', (0,0), (-1,-1), 3), ('BOTTOMPADDING', (0,0), (-1,-1), 3), ('VALIGN', (0,0), (-1,-1), 'TOP'), ])) story.append(art) story.append(Spacer(1, 0.3*cm)) story.append(Paragraph("2. SUBPHRENIC ABSCESS", h2_style)) story.append(Paragraph("<b>Definition:</b> Collection of pus between diaphragm and transverse colon/liver.", body_style)) subp = [ ("Causes", "Post-operative (most common): gastrectomy, colectomy, appendicectomy. Also perforated peptic ulcer, trauma."), ("Patient presentation", "Typically 1-2 weeks post-op. Patient has persistent fever, right upper quadrant / left upper quadrant pain, shoulder-tip pain (diaphragmatic irritation), hiccups, restricted chest movement."), ("Signs", "Reduced breath sounds at right base, dullness to percussion, tenderness in upper abdomen, fever >38.5°C"), ("Investigations", "CXR: raised hemidiaphragm, pleural effusion, gas-fluid level under diaphragm. CT scan: GOLD STANDARD - confirms collection. USG: guides drainage."), ("Treatment", "Image-guided percutaneous drainage + IV antibiotics. Surgery if fails."), ] for feat, desc in subp: story.append(Paragraph(f"<b>• {feat}:</b> {desc}", bullet_style)) story.append(Spacer(1, 0.3*cm)) story.append(Paragraph("3. HEMATOGENOUS / METASTATIC ABSCESS", h2_style)) story.append(Paragraph("<b>Definition:</b> Abscess arising from blood-borne spread of infection (e.g., liver abscess from portal pyemia).", body_style)) hem_data = [ ("Common sites", "Liver (most common), Brain, Lung, Spleen"), ("Causes", "Portal pyemia from appendicitis, diverticulitis, IBD. Also dental sepsis, IV drug use, endocarditis."), ("Pyogenic Liver Abscess presentation", "Fever (high, swinging/spiking), right upper quadrant pain, jaundice, hepatomegaly, weight loss. May have shoulder-tip pain."), ("Investigations", "Elevated WBC, LFTs. USG + CT: multiple/solitary hypoechoic collections in liver. Serology for amoebic abscess (ELISA)."), ("Treatment", "USG/CT-guided aspiration + drainage + IV antibiotics. Empirical: piperacillin-tazobactam + metronidazole."), ] for feat, desc in hem_data: story.append(Paragraph(f"<b>• {feat}:</b> {desc}", bullet_style)) story.append(Spacer(1, 0.3*cm)) story.append(Paragraph("4. GENERAL PRINCIPLES OF ABSCESS MANAGEMENT (Surgical)", h2_style)) story.append(Paragraph("<b>Golden rule: UBI PUS, IBI EVACUA - 'Where there is pus, evacuate it!'</b>", highlight_style)) gen_abs = [ ["Diagnosis", "Clinical + imaging (USG/CT). FNA/aspiration for culture."], ["Antibiotics", "Broad-spectrum covering gram-positive, gram-negative, anaerobes. Start empirically, guided by culture."], ["Drainage", "MANDATORY for all abscesses. Options: Incision & Drainage (I&D), Image-guided percutaneous drainage, Endoscopic drainage, Open surgical drainage."], ["Cavity management", "Leave drain/pack. Daily irrigation. Wound care."], ["Source control", "Treat underlying cause (e.g., perforated appendix, Crohn's, diverticulitis)."], ["Monitoring", "Serial CRP, WBC, clinical response. Repeat imaging if not improving."], ] gent = Table(gen_abs, colWidths=[4.5*cm, 10.5*cm]) gent.setStyle(TableStyle([ ('FONTNAME', (0,0), (0,-1), 'Helvetica-Bold'), ('FONTSIZE', (0,0), (-1,-1), 9), ('ROWBACKGROUNDS', (0,0), (-1,-1), [colors.HexColor('#f2f3f4'), colors.white]), ('GRID', (0,0), (-1,-1), 0.5, colors.grey), ('TOPPADDING', (0,0), (-1,-1), 3), ('BOTTOMPADDING', (0,0), (-1,-1), 3), ('VALIGN', (0,0), (-1,-1), 'TOP'), ])) story.append(gent) story.append(Spacer(1, 0.5*cm)) # QUICK REVISION BOX story.append(HRFlowable(width="100%", thickness=2, color=colors.HexColor('#c0392b'))) story.append(Spacer(1, 0.2*cm)) story.append(Paragraph("QUICK REVISION - HIGH YIELD POINTS FOR EXAM", ParagraphStyle('RevTitle', parent=styles['Heading1'], fontSize=13, textColor=colors.HexColor('#c0392b'), alignment=TA_CENTER, fontName='Helvetica-Bold'))) story.append(Spacer(1, 0.2*cm)) quick_rev = [ ["#", "High-Yield Fact"], ["1", "Most common cause of acute pancreatitis: GALLSTONES. Most common in USA: ALCOHOL."], ["2", "Most sensitive & specific enzyme: SERUM LIPASE (not amylase)."], ["3", "Ranson's criteria: <3 = mild, >6 = ~50% mortality."], ["4", "Most important treatment of acute pancreatitis: IV FLUID RESUSCITATION (Lactated Ringer's)."], ["5", "Do NOT routinely give antibiotics in acute pancreatitis."], ["6", "Do NOT 'rest the pancreas' - early ENTERAL nutrition is preferred."], ["7", "Grey Turner's sign = flank bruising. Cullen's sign = periumbilical bruising. Both = hemorrhagic pancreatitis."], ["8", "Pancreatic abscess: Late complication (2-6 weeks). Gas bubbles on CT = PATHOGNOMONIC."], ["9", "Step-up approach for infected necrosis/abscess: PCD → Endoscopic necrosectomy → Open surgery."], ["10", "Pancreatic calcification on X-ray = PATHOGNOMONIC of chronic pancreatitis."], ["11", "Best test for exocrine insufficiency: Fecal elastase-1. Gold standard: 72h fecal fat."], ["12", "Hereditary pancreatitis: PRSS1 mutation (cationic trypsinogen gene), chromosome 7q35."], ["13", "Most common ductal surgery for chronic pancreatitis: Lateral pancreaticojejunostomy (Puestow procedure)."], ["14", "Cholecystectomy after gallstone pancreatitis: Same admission (if possible) or within 2-4 weeks."], ["15", "Ubi pus, ibi evacua = 'Where there is pus, evacuate it' - golden rule of abscess management."], ] qrt = Table(quick_rev, colWidths=[1*cm, 14*cm]) qrt.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,0), colors.HexColor('#c0392b')), ('TEXTCOLOR', (0,0), (-1,0), colors.white), ('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'), ('FONTSIZE', (0,0), (-1,-1), 9), ('FONTNAME', (0,0), (0,-1), 'Helvetica-Bold'), ('TEXTCOLOR', (0,1), (0,-1), colors.HexColor('#c0392b')), ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.HexColor('#fff5f5'), colors.white]), ('GRID', (0,0), (-1,-1), 0.5, colors.grey), ('TOPPADDING', (0,0), (-1,-1), 3), ('BOTTOMPADDING', (0,0), (-1,-1), 3), ('VALIGN', (0,0), (-1,-1), 'TOP'), ])) story.append(qrt) story.append(Spacer(1, 0.3*cm)) story.append(Paragraph("Reference: Schwartz's Principles of Surgery, 11th Edition, Chapter 33 (Pancreas)", ref_style)) # BUILD doc.build(story) print("PDF generated successfully!") PYEOF python3 /tmp/workspace/surgery-quiz/generate_pdf.py
ls -lh /tmp/workspace/surgery-quiz/
Generate a presentations comparing Acute vs Chronic Pancreatitis