answer the esophageal obstruction according to uhs standard books of surgery
| Disorder | Features |
|---|---|
| Nutcracker Esophagus | High amplitude, uncoordinated contractions of smooth muscle. Barium swallow may be normal; manometry required for diagnosis. |
| Diffuse Esophageal Spasm (Corkscrew Esophagus) | Repetitive, simultaneous contractions of distal esophageal smooth muscle; contractions of normal amplitude. Classic corkscrew pattern on barium swallow. |
| LES Dysfunction / Achalasia | High resting LES pressure or incomplete relaxation. May occur in isolation or accompany nutcracker esophagus or DES. |
| Cause | Key Features |
|---|---|
| Benign Peptic Stricture | Most common benign stricture. Fibrous thickening of submucosa + muscularis propria atrophy. Caused by GERD, irradiation, or caustic (lye) injury. Progressive dysphagia to solids. Appetite and weight maintained. |
| Esophageal Webs | Uncommon ledge-like mucosal protrusions. Females >40 years. In upper esophagus, may be part of Plummer-Vinson syndrome (iron deficiency anemia + glossitis + cheilosis). Nonprogressive dysphagia to solids. |
| Esophageal Rings (Schatzki Rings) | Circumferential, thicker than webs. Include mucosa + submucosa ± muscularis propria. A rings (squamous mucosa, above GEJ) vs B rings (at squamocolumnar junction). |
| Zenker's Diverticulum | Pharyngoesophageal diverticulum above the upper esophageal sphincter. Caused by cricopharyngeus muscle spasm. Develops after age 50. Symptoms: regurgitation, halitosis, aspiration. |
| Epiphrenic Diverticulum | Just above LES, associated with dysmotility. |
| Achalasia | Failure of LES to relax + absent peristalsis. Dysphagia to both solids and liquids. |
| Extrinsic Compression | Goitre, mediastinal masses, aortic arch abnormalities (dysphagia lusoria). |
| Investigation | Purpose |
|---|---|
| Barium Swallow (Upper GI Series) | First-line investigation. Shows site, length, and nature of obstruction. "Bird-beak" deformity in achalasia; "corkscrew" in DES; mucosal irregularity in carcinoma. |
| Endoscopy (OGD/EGD) | Essential - allows direct visualization, biopsy, and tissue diagnosis. |
| Endoscopic Ultrasonography (EUS) | Best method to determine depth of invasion (T-staging) and lymph node status in esophageal cancer. Most reliable staging tool. |
| CT Chest/Abdomen | Assessment of lymph nodes, mediastinal invasion, distant metastases. |
| PET Scan | Detection of distant metastases; guides management. |
| Esophageal Manometry | Required for diagnosis of motility disorders (nutcracker esophagus, DES, achalasia). |
| Bronchoscopy | To exclude tracheobronchial invasion before esophagectomy. |
| Complication | Notes |
|---|---|
| Aspiration pneumonia | From food retention above obstruction |
| Malnutrition / Cachexia | Especially malignant obstruction |
| Tracheoesophageal fistula | Malignant invasion into tracheobronchial tree |
| Hemorrhage | Erosion into aorta or pulmonary vessels |
| Recurrent laryngeal nerve palsy | Hoarseness |
| Mediastinitis / abscess | From perforation or esophageal leak |
| Pulmonary metastases / systemic spread | Advanced cancer |
make a pdf of above answer
ls -la /tmp/workspace/ 2>/dev/null || mkdir -p /tmp/workspace && echo "workspace ready"
mkdir -p /tmp/workspace/esophageal-obstruction && cat > /tmp/workspace/esophageal-obstruction/generate_pdf.py << 'PYEOF' from reportlab.lib.pagesizes import A4 from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle from reportlab.lib.units import cm, mm from reportlab.lib import colors from reportlab.platypus import (SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, HRFlowable, KeepTogether) from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_JUSTIFY OUTPUT = "/tmp/workspace/esophageal-obstruction/Esophageal_Obstruction_S2-019.pdf" doc = SimpleDocTemplate( OUTPUT, pagesize=A4, rightMargin=2*cm, leftMargin=2*cm, topMargin=2.2*cm, bottomMargin=2.2*cm, title="Esophageal Obstruction (S2-019)", author="UHS Surgery Notes" ) # ── colour palette ────────────────────────────────────────────────────────── NAVY = colors.HexColor("#1a3355") TEAL = colors.HexColor("#0b7c8a") LTBLUE = colors.HexColor("#ddeef5") AMBER = colors.HexColor("#f4a628") LTAMBER = colors.HexColor("#fff4de") GREY = colors.HexColor("#555555") LTGREY = colors.HexColor("#f5f5f5") WHITE = colors.white DARKGREY = colors.HexColor("#333333") styles = getSampleStyleSheet() def S(name, **kw): s = ParagraphStyle(name, **kw) return s # ── custom styles ──────────────────────────────────────────────────────────── title_style = S("DocTitle", fontName="Helvetica-Bold", fontSize=20, textColor=WHITE, spaceAfter=4, alignment=TA_CENTER, leading=26) subtitle_style = S("DocSubtitle", fontName="Helvetica", fontSize=11, textColor=colors.HexColor("#c8dff0"), spaceAfter=2, alignment=TA_CENTER, leading=14) h1 = S("H1", fontName="Helvetica-Bold", fontSize=13, textColor=WHITE, spaceBefore=8, spaceAfter=4, leading=16, leftIndent=0, backColor=NAVY, borderPad=(5, 5, 5, 5)) h2 = S("H2", fontName="Helvetica-Bold", fontSize=11, textColor=NAVY, spaceBefore=6, spaceAfter=3, leading=14) h3 = S("H3", fontName="Helvetica-BoldOblique", fontSize=10, textColor=TEAL, spaceBefore=4, spaceAfter=2, leading=13) body = S("Body", fontName="Helvetica", fontSize=9.5, textColor=DARKGREY, spaceBefore=2, spaceAfter=2, leading=14, alignment=TA_JUSTIFY) bullet = S("Bullet", fontName="Helvetica", fontSize=9.5, textColor=DARKGREY, spaceBefore=1, spaceAfter=1, leading=13, leftIndent=14, firstLineIndent=-10) bullet2 = S("Bullet2", fontName="Helvetica", fontSize=9, textColor=DARKGREY, spaceBefore=1, spaceAfter=1, leading=12, leftIndent=26, firstLineIndent=-10) note_style = S("Note", fontName="Helvetica-Oblique", fontSize=8.5, textColor=GREY, spaceBefore=4, spaceAfter=2, leading=12, alignment=TA_CENTER) tbl_header = S("TblHdr", fontName="Helvetica-Bold", fontSize=9, textColor=WHITE, leading=12) tbl_cell = S("TblCell", fontName="Helvetica", fontSize=9, textColor=DARKGREY, leading=12) # ── helpers ────────────────────────────────────────────────────────────────── def H(txt, style=h1, pad=True): if style == h1: # Wrap in a shaded box via a 1-col table t = Table([[Paragraph(f" {txt}", style)]], colWidths=[17*cm]) t.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,-1), NAVY), ('ROWPADDING', (0,0), (-1,-1), 5), ('TOPPADDING', (0,0), (-1,-1), 6), ('BOTTOMPADDING', (0,0), (-1,-1), 6), ('LEFTPADDING', (0,0), (-1,-1), 8), ])) return t return Paragraph(txt, style) def B(txt, level=1): prefix = "•" if level == 1 else "–" st = bullet if level == 1 else bullet2 return Paragraph(f"{prefix} {txt}", st) def P(txt): return Paragraph(txt, body) def SP(n=0.3): return Spacer(1, n*cm) def HR(): return HRFlowable(width="100%", thickness=0.5, color=colors.HexColor("#cccccc"), spaceAfter=4, spaceBefore=4) def make_table(header_row, data_rows, col_widths=None): rows = [[Paragraph(c, tbl_header) for c in header_row]] for row in data_rows: rows.append([Paragraph(c, tbl_cell) for c in row]) if col_widths is None: n = len(header_row) col_widths = [17*cm / n] * n t = Table(rows, colWidths=col_widths, repeatRows=1) t.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,0), TEAL), ('TEXTCOLOR', (0,0), (-1,0), WHITE), ('ROWBACKGROUNDS',(0,1), (-1,-1), [WHITE, LTBLUE]), ('GRID', (0,0), (-1,-1), 0.4, colors.HexColor("#aac8d8")), ('VALIGN', (0,0), (-1,-1), 'TOP'), ('TOPPADDING', (0,0), (-1,-1), 4), ('BOTTOMPADDING', (0,0), (-1,-1), 4), ('LEFTPADDING', (0,0), (-1,-1), 5), ('RIGHTPADDING', (0,0), (-1,-1), 5), ])) return t def callout(text, bg=LTAMBER, border=AMBER): t = Table([[Paragraph(text, body)]], colWidths=[17*cm]) t.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,-1), bg), ('BOX', (0,0), (-1,-1), 1.5, border), ('TOPPADDING', (0,0), (-1,-1), 6), ('BOTTOMPADDING', (0,0), (-1,-1), 6), ('LEFTPADDING', (0,0), (-1,-1), 10), ('RIGHTPADDING', (0,0), (-1,-1), 10), ])) return t # ── cover banner ───────────────────────────────────────────────────────────── def cover_banner(): banner = Table([[ Paragraph("Esophageal Obstruction", title_style), Paragraph("S2-019", title_style), ]], colWidths=[12*cm, 5*cm]) banner.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,-1), NAVY), ('TOPPADDING', (0,0), (-1,-1), 14), ('BOTTOMPADDING', (0,0), (-1,-1), 14), ('LEFTPADDING', (0,0), (-1,-1), 12), ('RIGHTPADDING', (0,0), (-1,-1), 12), ('VALIGN', (0,0), (-1,-1), 'MIDDLE'), ])) return banner # ═══════════════════════════════════════════════════════════════════════════ # BUILD STORY # ═══════════════════════════════════════════════════════════════════════════ story = [] # ── Cover ─────────────────────────────────────────────────────────────────── story.append(cover_banner()) story.append(SP(0.2)) story.append(Paragraph("UHS Standard Surgery Notes | Based on: Schwartz's 11e, Robbins PBD, Bailey & Love, Rosen's EM, Sleisenger & Fordtran's", note_style)) story.append(SP(0.5)) story.append(HR()) story.append(SP(0.3)) # ── 1. Definition ───────────────────────────────────────────────────────── story.append(H("1. Definition")) story.append(SP(0.2)) story.append(P( "The primary function of the esophagus is to deliver ingested food and fluids to the stomach. " "This can be impeded by <b>physical (mechanical) obstruction</b> or <b>functional obstruction</b> " "(disruption of coordinated peristalsis). " "<i>— Robbins Pathologic Basis of Disease</i>" )) story.append(SP(0.3)) # ── 2. Causes ───────────────────────────────────────────────────────────── story.append(H("2. Causes of Esophageal Obstruction")) story.append(SP(0.2)) story.append(Paragraph("A. Benign Causes", h2)) story.append(Paragraph("i. Functional (Motility Disorders)", h3)) story.append(SP(0.1)) motility_data = [ ["Nutcracker Esophagus", "High amplitude, uncoordinated contractions of smooth muscle. Barium swallow may be normal; manometry required for diagnosis."], ["Diffuse Esophageal Spasm\n(Corkscrew Esophagus)", "Repetitive, simultaneous contractions of distal esophageal smooth muscle; contractions of normal amplitude. Classic corkscrew pattern on barium swallow."], ["LES Dysfunction / Achalasia", "High resting LES pressure or incomplete relaxation. May occur in isolation or accompany nutcracker esophagus or DES. Dysphagia to both solids and liquids from onset."], ] story.append(make_table(["Disorder","Features"], motility_data, [5.5*cm, 11.5*cm])) story.append(SP(0.3)) story.append(Paragraph("ii. Mechanical Benign Causes", h3)) story.append(SP(0.1)) mech_data = [ ["Benign Peptic Stricture", "Most common benign stricture. Fibrous thickening of submucosa + muscularis propria atrophy. Caused by GERD, irradiation, or caustic (lye) injury. Progressive dysphagia to solids. Appetite and weight maintained."], ["Esophageal Webs", "Uncommon ledge-like mucosal protrusions. Females >40 years. In upper esophagus, part of Plummer-Vinson syndrome (iron deficiency anaemia + glossitis + cheilosis). Nonprogressive dysphagia to solids."], ["Esophageal Rings\n(Schatzki Rings)", "Circumferential, thicker than webs. Include mucosa + submucosa ± muscularis propria. A rings (squamous mucosa, above GEJ) vs B rings (at squamocolumnar junction)."], ["Zenker's Diverticulum", "Pharyngoesophageal diverticulum above upper esophageal sphincter. Caused by cricopharyngeus muscle spasm/dysfunction. Develops after age 50. Symptoms: regurgitation, halitosis, aspiration."], ["Epiphrenic Diverticulum", "Just above LES, associated with dysmotility."], ["Extrinsic Compression", "Goitre, mediastinal masses, aortic arch abnormalities (dysphagia lusoria), lymphadenopathy."], ] story.append(make_table(["Cause","Key Features"], mech_data, [5*cm, 12*cm])) story.append(SP(0.3)) story.append(Paragraph("B. Malignant Causes", h2)) story.append(SP(0.1)) mal_data = [ ["Squamous Cell Carcinoma (SCC)", "Predominant in developing countries. Associated with: smoking, alcohol, achalasia, lye strictures, tylosis (palmoplantar hyperkeratosis), HPV. Common in upper and mid-thoracic esophagus."], ["Adenocarcinoma", "Now >50% of esophageal cancer in Western countries. Arises in Barrett's mucosa (complication of GERD). One of the most dramatic epidemiological shifts in human neoplasia. Common in lower esophagus and GEJ."], ["Extrinsic Malignancy", "Mediastinal or pulmonary malignancies compressing the esophagus from outside."], ] story.append(make_table(["Type","Features"], mal_data, [5*cm, 12*cm])) story.append(SP(0.2)) story.append(callout( "<b>Key fact (Schwartz's):</b> Barrett's esophagus (BE) develops in 10-15% of GERD patients. " "Risk of adenocarcinoma in BE = 1 in 100-200 patient-years of follow-up — " "40-60× higher than the general population." )) story.append(SP(0.4)) # ── 3. Clinical Features ─────────────────────────────────────────────────── story.append(H("3. Clinical Features")) story.append(SP(0.2)) story.append(Paragraph("A. Dysphagia — Cardinal Symptom", h2)) clin_data = [ ["Progressive dysphagia: solids → liquids", "Mechanical obstruction (benign or malignant stricture)"], ["Dysphagia to both solids AND liquids from onset", "Motility disorder (achalasia, DES)"], ["Intermittent, nonprogressive dysphagia", "Webs / Schatzki rings"], ["Regurgitation of undigested food + halitosis", "Zenker's diverticulum"], ] story.append(make_table(["Pattern","Likely Cause"], clin_data, [8.5*cm, 8.5*cm])) story.append(SP(0.3)) story.append(Paragraph("B. Features of Malignant Obstruction (Esophageal Carcinoma)", h2)) story.append(SP(0.1)) story.append(B("<b>Dysphagia</b> — presents late because absence of serosa allows smooth muscle to dilate until >60% of circumference is infiltrated. (Schwartz's)")) story.append(B("<b>Anorexia and weight loss</b> — often precede dysphagia in cardia tumors")) story.append(B("<b>Odynophagia</b> — pain on swallowing")) story.append(B("<b>Hoarseness/voice change</b> — left recurrent laryngeal nerve invasion")) story.append(B("<b>Stridor + tracheoesophageal fistula</b> — tracheobronchial invasion (more common in SCC)")) story.append(B("<b>Cough, choking, aspiration pneumonia</b> — from fistula or retained food above obstruction")) story.append(B("<b>Bone pain or jaundice</b> — distant metastases")) story.append(B("<b>Back pain at presentation</b> — usually distant metastasis or celiac encasement")) story.append(B("<b>Horner's syndrome</b> — mediastinal invasion")) story.append(SP(0.3)) story.append(Paragraph("C. Features of Benign Obstruction", h2)) story.append(B("Patients <b>maintain appetite and weight</b> (in contrast to malignant stricture)")) story.append(B("Regurgitation of undigested food (Zenker's diverticulum)")) story.append(B("Iron deficiency anaemia + glossitis + cheilosis = Plummer-Vinson syndrome (associated with cervical webs)")) story.append(SP(0.4)) # ── 4. Diagnostic Approach ───────────────────────────────────────────────── story.append(H("4. Diagnostic Approach")) story.append(SP(0.2)) diag_data = [ ["Barium Swallow", "First-line investigation. Shows site, length, nature of obstruction. 'Bird-beak' in achalasia; 'corkscrew' in DES; mucosal irregularity in carcinoma; shelf-like lesion for webs/rings."], ["Endoscopy (OGD/EGD)", "Essential — allows direct visualization, biopsy, and tissue diagnosis. Also therapeutic (dilatation, stenting, EMR)."], ["Endoscopic Ultrasonography (EUS)", "Best method to determine depth of invasion (T-staging) and LN status in esophageal cancer. Most reliable preoperative staging tool. (Schwartz's)"], ["CT Chest/Abdomen/Pelvis", "Assessment of lymph nodes, mediastinal invasion, liver/lung metastases."], ["PET Scan", "Detection of occult distant metastases. Guides decision between curative vs palliative intent."], ["Esophageal Manometry", "Required for diagnosis of motility disorders (nutcracker esophagus, DES, achalasia). Not informative for mechanical obstruction."], ["Bronchoscopy", "Mandatory before esophagectomy to exclude tracheobronchial invasion (especially for mid-esophageal SCC)."], ["FBC, LFTs, Albumin, LDH", "Baseline nutritional status. Albumin <3.5 g/dL = high complication risk. Weight loss >20 lbs = poor prognosis."], ] story.append(make_table(["Investigation","Purpose"], diag_data, [5*cm, 12*cm])) story.append(SP(0.2)) story.append(callout( "<b>Clinical Staging — Contraindications to Curative Surgery:</b> Recurrent nerve paralysis, " "Horner's syndrome, persistent spinal pain, diaphragm paralysis, fistula formation, " "malignant pleural effusion, tumour >8 cm, >4 enlarged LNs on CT, weight loss >20 lbs with hypoalbuminaemia. " "<i>— Schwartz's Principles of Surgery 11th Ed.</i>" )) story.append(SP(0.4)) # ── 5. Management ───────────────────────────────────────────────────────── story.append(H("5. Principles of Management")) story.append(SP(0.2)) story.append(Paragraph("A. Non-Surgical Management", h2)) story.append(Paragraph("i. Endoscopic / Minimally Invasive", h3)) story.append(B("<b>Esophageal dilatation</b> (bougienage / balloon dilatation) — for benign and malignant strictures")) story.append(B("<b>Esophageal stent (SEMS)</b> — self-expanding metal stent; immediate palliation of malignant dysphagia")) story.append(B("<b>Botulinum toxin injection into LES</b> — temporary relief in achalasia and LES outflow obstruction")) story.append(B("<b>Endoscopic mucosal resection (EMR)</b> — for early mucosal cancers (Tis/T1a)")) story.append(B("<b>Endoscopic submucosal dissection (ESD)</b> — en-bloc resection of early cancers")) story.append(B("<b>Pneumatic dilation</b> — first-line endoscopic treatment for achalasia")) story.append(SP(0.2)) story.append(Paragraph("ii. Medical / Adjuvant", h3)) story.append(B("<b>Neoadjuvant chemoradiation</b> (cisplatin + 5-FU or carboplatin + paclitaxel) — for locally advanced esophageal cancer; improves resectability")) story.append(B("<b>Proton pump inhibitors (PPIs)</b> — benign peptic strictures (treat underlying GERD); reduce re-stricturing")) story.append(B("<b>Calcium channel blockers / nitrates</b> — for DES/nutcracker esophagus (smooth muscle relaxants)")) story.append(B("<b>Nutritional support</b> — feeding jejunostomy or NG tube prior to surgery; nutritional status is the most predictive factor for postoperative complications (Schwartz's)")) story.append(SP(0.3)) story.append(Paragraph("B. Surgical Management", h2)) story.append(Paragraph("i. Surgery for Benign Obstruction", h3)) story.append(B("<b>Heller's cardiomyotomy</b> (laparoscopic or open) — treatment of choice for achalasia; division of LES muscle")) story.append(B("<b>Cricopharyngeal myotomy ± diverticulectomy</b> — for Zenker's diverticulum; endoscopic stapling also effective")) story.append(B("<b>Stricturoplasty / esophagoplasty</b> — for short benign strictures not amenable to dilatation")) story.append(SP(0.2)) story.append(Paragraph("ii. Surgery for Malignant Obstruction — Stage-Based Approach", h3)) stage_data = [ ["Early (T1-T2, N0)", "Esophagectomy with curative intent"], ["Locally Advanced (T1-3, N1)", "Neoadjuvant chemoradiation THEN esophagectomy"], ["Disseminated (any T, any N, M1)", "Palliation: stenting, chemoradiation, laser ablation"], ] story.append(make_table(["Stage","Management"], stage_data, [5*cm, 12*cm])) story.append(SP(0.2)) story.append(Paragraph("iii. Types of Esophagectomy", h3)) esoph_data = [ ["Transhiatal Esophagectomy (THE)", "Laparotomy + cervical incision; avoids thoracotomy. Preferred in poor pulmonary reserve. Higher risk of anastomotic leak, less LN dissection."], ["Ivor-Lewis Esophagectomy", "Right thoracotomy + laparotomy. Used for mid/lower esophageal tumours. Better lymph node dissection. Intrathoracic anastomosis."], ["McKeown (3-field) Esophagectomy", "Cervical + thoracic + abdominal approach. Used for upper thoracic/cervical esophageal tumours. Maximum LN dissection."], ["Minimally Invasive (MIE)", "Laparoscopic + thoracoscopic. Reduces morbidity vs open surgery while maintaining oncologic equivalence."], ] story.append(make_table(["Procedure","Details"], esoph_data, [5*cm, 12*cm])) story.append(SP(0.2)) story.append(callout( "<b>Preoperative Assessment for Esophagectomy (Schwartz's):</b><br/>" "• FEV1 ≥2 L ideal; FEV1 <1.25 L = high risk (40% risk of respiratory death within 4 years) — consider transhiatal approach<br/>" "• Resting ejection fraction <40% is ominous<br/>" "• Albumin <3.5 g/dL + weight loss >20 lbs = significantly higher complication and mortality rate<br/>" "• Patients who can climb 3 flights of stairs without stopping generally tolerate 2-field open esophagectomy" )) story.append(SP(0.4)) # ── 6. Complications ────────────────────────────────────────────────────── story.append(H("6. Complications of Esophageal Obstruction")) story.append(SP(0.2)) comp_data = [ ["Aspiration pneumonia", "Food retention above obstruction aspirated into lungs"], ["Malnutrition / Cachexia", "Progressive weight loss; worst in malignant obstruction"], ["Tracheoesophageal Fistula", "Malignant invasion into tracheobronchial tree; severe aspiration"], ["Hemorrhage", "Erosion of tumour into aorta or pulmonary vessels; rare but catastrophic"], ["Recurrent laryngeal nerve palsy", "Hoarseness; left nerve most commonly affected"], ["Mediastinitis / Abscess", "From esophageal perforation, anastomotic leak, or fistula"], ["Systemic Metastases", "Liver (jaundice), bone (pain), lung, cervical LNs"], ["Postoperative leak/fistula", "Most feared complication of esophagectomy; requires re-operation"], ] story.append(make_table(["Complication","Notes"], comp_data, [6*cm, 11*cm])) story.append(SP(0.4)) # ── 7. Esophageal Perforation ───────────────────────────────────────────── story.append(H("7. Esophageal Perforation (S2-019 Curriculum)")) story.append(SP(0.2)) story.append(Paragraph("A. Causes", h2)) cause_data = [ ["Iatrogenic (MOST COMMON)", "• Endoscopy/esophagoscopy\n• Balloon dilatation (achalasia)\n• Bougienage (peptic stricture)\n• Sclerotherapy for variceal bleeding\n• Anastomotic leak post-surgery"], ["Spontaneous — Boerhaave Syndrome", "Massive increase in intraesophageal pressure during forceful retching/vomiting. Free passage of esophageal contents into pleural/mediastinal space. Left-sided tear at lower third of esophagus."], ["Trauma", "Blunt/penetrating chest or neck trauma; foreign body ingestion"], ["Other", "Erosion by adjacent malignancy; infection; postoperative anastomotic breakdown"], ] story.append(make_table(["Cause","Details"], cause_data, [5*cm, 12*cm])) story.append(SP(0.3)) story.append(Paragraph("B. Clinical Signs", h2)) story.append(callout( "<b>Mackler's Triad (Boerhaave Syndrome):</b> (1) Forceful vomiting → (2) Severe chest/epigastric pain → (3) Subcutaneous emphysema in neck/chest" )) story.append(SP(0.1)) story.append(B("Sudden severe <b>chest or epigastric pain</b> after vomiting/straining")) story.append(B("<b>Subcutaneous emphysema</b> in neck and chest (crepitus on palpation)")) story.append(B("<b>Hamman's sign</b> — crunching sound on auscultation (pneumomediastinum)")) story.append(B("<b>Mediastinitis</b> — fever, tachycardia, septic shock (develops within hours)")) story.append(B("Left-sided <b>pleural effusion</b> ± hydropneumothorax")) story.append(B("Dysphagia, odynophagia, drooling (cervical perforation)")) story.append(SP(0.3)) story.append(Paragraph("C. Diagnosis", h2)) diag2_data = [ ["Water-soluble contrast swallow\n(Gastrografin)", "FIRST-LINE when perforation suspected. Confirms leak and its location. DO NOT use barium — causes severe chemical mediastinitis."], ["CT Chest with contrast", "Shows pneumomediastinum, pleural effusion, extravasation, extent of contamination. Most informative for surgical planning."], ["CXR", "Pneumomediastinum, subcutaneous emphysema, widened mediastinum, left pleural effusion, pneumothorax."], ["Endoscopy", "Used cautiously; can confirm perforation but risks extending it. Use only if contrast study inconclusive."], ] story.append(make_table(["Investigation","Notes"], diag2_data, [5.5*cm, 11.5*cm])) story.append(SP(0.3)) story.append(Paragraph("D. Management", h2)) story.append(B("<b>Resuscitation</b> — IV fluids, NPO (nil by mouth)")) story.append(B("<b>Broad-spectrum IV antibiotics</b> — vancomycin 15 mg/kg + piperacillin 3.375 g (cover gram-positive, gram-negative, and anaerobes)")) story.append(B("<b>Early surgical consultation</b> in the majority of cases")) story.append(B("<b>NG tube / nasojejunal tube</b> — decompression and enteral nutrition")) story.append(SP(0.1)) story.append(Paragraph("Conservative Management (select cases only):", h3)) story.append(B("Small, <b>contained</b> perforation in a <b>stable</b> patient")) story.append(B("NPO + IV antibiotics + parenteral nutrition + close clinical monitoring")) story.append(B("Surgeon readily available for conversion to operative management")) story.append(SP(0.1)) story.append(Paragraph("Surgical Management:", h3)) surgery_data = [ ["Primary repair + drainage", "Ideal if performed within 24 hours. Debride necrotic tissue, close perforation in two layers, drain mediastinum/pleura. Reinforce with viable tissue (pleural flap, omental wrap)."], ["T-tube drainage", "For late presentations (>24-48 h) where primary repair is not feasible due to friable, inflamed tissue."], ["Esophageal stenting", "Endoscopic SEMS placement as alternative to surgery in select stable patients. Bridges to definitive repair. (Sleisenger & Fordtran's)"], ["Esophagectomy", "Reserved for: perforation in setting of esophageal cancer, failure of other measures, or severe contamination/necrosis."], ["Mediastinal debridement", "May require repeat procedures + serial CT scans to ensure resolution of mediastinal sepsis (Schwartz's)."], ] story.append(make_table(["Option","Indication / Details"], surgery_data, [5*cm, 12*cm])) story.append(SP(0.4)) # ── 8. Preventive Measures ──────────────────────────────────────────────── story.append(H("8. Preventive Measures")) story.append(SP(0.2)) story.append(B("<b>Barrett's esophagus surveillance</b> — endoscopy every 3-5 years to detect early adenocarcinoma")) story.append(B("<b>GERD management</b> — PPIs prevent peptic stricture formation and Barrett's progression")) story.append(B("<b>Caustic ingestion prevention</b> — child-proof containers; emergency decontamination protocols")) story.append(B("<b>Safe endoscopic technique</b> — gentle scope passage, avoid excessive force; fluoroscopic guidance for difficult strictures")) story.append(B("<b>Smoking and alcohol cessation</b> — primary prevention of squamous cell carcinoma")) story.append(B("<b>Iron supplementation</b> in Plummer-Vinson syndrome — prevents web progression and associated malignancy risk")) story.append(B("<b>Weight management</b> — reduces GERD, lowers adenocarcinoma risk")) story.append(B("<b>Helicobacter pylori eradication</b> — reduces gastric acid load and GERD")) story.append(SP(0.4)) # ── Footer note ───────────────────────────────────────────────────────────── story.append(HR()) story.append(Paragraph( "Sources: Schwartz's Principles of Surgery 11th Ed. | Robbins & Cotran Pathologic Basis of Disease | " "Rosen's Emergency Medicine | Sleisenger & Fordtran's GI & Liver Disease | Bailey & Love's Surgery", note_style )) story.append(Paragraph("Generated by Orris AI | UHS S2-019 Surgery Curriculum", note_style)) # ── Build ──────────────────────────────────────────────────────────────────── doc.build(story) print(f"PDF created: {OUTPUT}") PYEOF echo "Script written"
cd /tmp/workspace/esophageal-obstruction && python generate_pdf.py
ls -lh /tmp/workspace/esophageal-obstruction/Esophageal_Obstruction_S2-019.pdf
Esophageal Obstruction S2 019
PDF Document · PDF