Make a pdf containing investigation and management of Adenocarcinoma , non Hodgkin lymphoma , GIST of small bowel tumour . Each Tumor should be in 1 page so total of 3 pages . Make sure the content is from SRB textbook of surgery and Bailey love textbook of surgery and add images if possible

Reading File
Reading File
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Reading File
Finding Sources
Loading Image
Loading Image
Running Command

mkdir -p /tmp/workspace/small-bowel-tumours && ls /tmp/workspace/small-bowel-tumours/

Running Command

cat << 'PYEOF' > /tmp/workspace/small-bowel-tumours/generate_pdf.py import requests from io import BytesIO from PIL import Image from reportlab.lib.pagesizes import A4 from reportlab.lib import colors from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle from reportlab.lib.units import cm, mm from reportlab.platypus import (SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, Image as RLImage, HRFlowable, KeepInFrame, PageBreak) from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_JUSTIFY from reportlab.platypus.flowables import KeepTogether def download_image(url, max_width, max_height): """Download image and return RLImage sized to fit.""" try: resp = requests.get(url, timeout=15) img = Image.open(BytesIO(resp.content)) iw, ih = img.size ratio = min(max_width/iw, max_height/ih) path = BytesIO(resp.content) return RLImage(path, width=iw*ratio, height=ih*ratio) except Exception as e: print(f"Image download failed: {e}") return None WIDTH, HEIGHT = A4 MARGIN = 1.5*cm doc = SimpleDocTemplate( "/tmp/workspace/small-bowel-tumours/small_bowel_tumours.pdf", pagesize=A4, rightMargin=MARGIN, leftMargin=MARGIN, topMargin=MARGIN, bottomMargin=MARGIN, title="Small Bowel Tumours - Investigation & Management", author="Orris Medical Reference" ) styles = getSampleStyleSheet() # Custom styles title_style = ParagraphStyle( 'TumorTitle', parent=styles['Heading1'], fontSize=16, textColor=colors.HexColor('#1a3a5c'), spaceAfter=4, spaceBefore=0, fontName='Helvetica-Bold', leading=20, ) subtitle_style = ParagraphStyle( 'Subtitle', parent=styles['Normal'], fontSize=9, textColor=colors.HexColor('#4a6fa5'), spaceAfter=6, fontName='Helvetica-Oblique', italic=True, ) section_style = ParagraphStyle( 'SectionHead', parent=styles['Heading2'], fontSize=10, textColor=colors.white, fontName='Helvetica-Bold', spaceAfter=2, spaceBefore=4, leading=14, ) body_style = ParagraphStyle( 'BodyText2', parent=styles['Normal'], fontSize=8, leading=11, spaceAfter=3, fontName='Helvetica', textColor=colors.HexColor('#1a1a1a'), ) bullet_style = ParagraphStyle( 'BulletText', parent=body_style, leftIndent=10, bulletIndent=0, firstLineIndent=0, spaceAfter=2, ) caption_style = ParagraphStyle( 'Caption', parent=styles['Normal'], fontSize=7, leading=9, textColor=colors.HexColor('#555555'), fontName='Helvetica-Oblique', spaceAfter=4, alignment=TA_CENTER, ) def section_header(text, color='#1a3a5c'): """Colored section header bar.""" data = [[Paragraph(f'<font color="white"><b>{text}</b></font>', ParagraphStyle('sh', fontSize=9, fontName='Helvetica-Bold', textColor=colors.white, leading=12))]] t = Table(data, colWidths=[WIDTH - 2*MARGIN]) t.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,-1), colors.HexColor(color)), ('TOPPADDING', (0,0), (-1,-1), 3), ('BOTTOMPADDING', (0,0), (-1,-1), 3), ('LEFTPADDING', (0,0), (-1,-1), 6), ('RIGHTPADDING', (0,0), (-1,-1), 6), ])) return t def make_table(headers, rows, col_widths=None): """Create a styled data table.""" if col_widths is None: n = len(headers) col_widths = [(WIDTH - 2*MARGIN) / n] * n header_style = ParagraphStyle('th', fontSize=8, fontName='Helvetica-Bold', textColor=colors.white, leading=10) cell_style = ParagraphStyle('td', fontSize=7.5, fontName='Helvetica', textColor=colors.HexColor('#1a1a1a'), leading=10) table_data = [[Paragraph(h, header_style) for h in headers]] for i, row in enumerate(rows): table_data.append([Paragraph(str(c), cell_style) for c in row]) t = Table(table_data, colWidths=col_widths) ts = TableStyle([ ('BACKGROUND', (0,0), (-1,0), colors.HexColor('#1a3a5c')), ('TEXTCOLOR', (0,0), (-1,0), colors.white), ('GRID', (0,0), (-1,-1), 0.4, colors.HexColor('#cccccc')), ('TOPPADDING', (0,0), (-1,-1), 3), ('BOTTOMPADDING', (0,0), (-1,-1), 3), ('LEFTPADDING', (0,0), (-1,-1), 4), ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, colors.HexColor('#f0f4f8')]), ]) t.setStyle(ts) return t def bullet(text): return Paragraph(f'<bullet>&bull;</bullet> {text}', bullet_style) # ───────────────────────────────────────────────────────────────── # PAGE 1: ADENOCARCINOMA OF SMALL BOWEL # ───────────────────────────────────────────────────────────────── story = [] story.append(Paragraph("Small Bowel Tumours: Investigation &amp; Management", ParagraphStyle('maintitle', fontSize=13, fontName='Helvetica-Bold', textColor=colors.HexColor('#1a3a5c'), alignment=TA_CENTER, spaceAfter=2))) story.append(Paragraph("Source: Mulholland &amp; Greenfield's Surgery (7e) | Bailey &amp; Love's Short Practice of Surgery (28e) | Schwartz's Principles of Surgery (11e)", ParagraphStyle('src', fontSize=7, fontName='Helvetica-Oblique', textColor=colors.HexColor('#666666'), alignment=TA_CENTER, spaceAfter=4))) story.append(HRFlowable(width="100%", thickness=1.5, color=colors.HexColor('#1a3a5c'), spaceAfter=6)) # Title story.append(Paragraph("1. Adenocarcinoma of the Small Bowel", title_style)) story.append(HRFlowable(width="100%", thickness=0.5, color=colors.HexColor('#4a6fa5'), spaceAfter=4)) # Overview story.append(section_header("Overview")) story.append(Paragraph( "Small bowel adenocarcinomas represent the <b>second most common</b> cancer of the small bowel " "(incidence 7.3 cases per million worldwide), comprising 30-40% of small bowel cancer diagnoses. " "Higher incidence in developed countries (North America, Western Europe). Black populations have " "~twice the age-adjusted incidence vs white individuals.", body_style)) # Two-column layout: Investigations | Clinical Features col_w = (WIDTH - 2*MARGIN - 6) / 2 left_content = [ section_header("Investigations", '#2e6da4'), Spacer(1, 2), bullet("<b>Tumour markers:</b> CEA and CA 19-9 elevated in only 30-40% of patients"), bullet("<b>CT enterography:</b> Sensitivity 84.7%, specificity 96.9% for detecting small bowel tumours"), bullet("<b>MR enterography (MRE):</b> Sensitivity 91%, specificity 95%"), bullet("<b>Upper GI series / small bowel follow-through:</b> Cannot assess extraluminal spread"), bullet("<b>Double-balloon enteroscopy (DAE):</b> Important when presenting symptom is anaemia"), bullet("<b>CT chest-abdomen-pelvis:</b> Essential for staging and distant metastasis assessment"), bullet("<b>Staging:</b> TNM staging system used; lymph node harvest target ≥8 nodes"), bullet("<b>Microsatellite instability (MSI/MMR) testing:</b> Required in stage II disease before planning adjuvant chemo"), ] right_content = [ section_header("Clinical Features", '#2e6da4'), Spacer(1, 2), bullet("<b>Abdominal pain:</b> Most common (45-76%)"), bullet("Nausea and vomiting"), bullet("Weight loss and fatigue"), bullet("Anaemia (GI bleeding)"), bullet("<b>Indolent presentation:</b> Mean symptom duration ~10 months before diagnosis"), bullet("Obstruction (may present as acute abdomen)"), Spacer(1, 4), section_header("Predisposing Conditions", '#2e6da4'), Spacer(1, 2), bullet("Familial adenomatous polyposis (FAP)"), bullet("Lynch syndrome (HNPCC)"), bullet("Crohn's disease"), bullet("Peutz-Jeghers syndrome"), ] col_table = Table( [[left_content, right_content]], colWidths=[col_w, col_w], style=TableStyle([ ('VALIGN', (0,0), (-1,-1), 'TOP'), ('LEFTPADDING', (0,0), (-1,-1), 3), ('RIGHTPADDING', (0,0), (-1,-1), 3), ]) ) story.append(col_table) # Management story.append(Spacer(1, 4)) story.append(section_header("Surgical Management")) story.append(Paragraph( "Resection type depends on <b>location and stage</b>:", body_style)) mgmt_rows = [ ["Location", "Procedure"], ["Duodenum", "Pancreaticoduodenectomy (Whipple's procedure)"], ["Jejunum / Ileum", "Wide segmental resection + regional lymphadenectomy"], ["Duodenum (3rd/4th portion)", "Segmental resection with Roux-en-Y reconstruction"], ] story.append(make_table(["Location", "Operative Procedure"], mgmt_rows[1:], [col_w-10, col_w+10])) story.append(Spacer(1, 4)) story.append(section_header("Adjuvant / Neoadjuvant Therapy")) adj_left = [ Paragraph("<b>Adjuvant chemotherapy (node-positive):</b>", body_style), bullet("5-FU / Capecitabine"), bullet("FOLFOX / CAPOX (preferred)"), bullet("FOLFIRI"), bullet("Gemcitabine"), Spacer(1,3), Paragraph("<b>Note:</b> High MSI tumours (Lynch syndrome) do <b>not</b> respond to 5-FU-based regimens.", body_style), ] adj_right = [ Paragraph("<b>Neoadjuvant therapy (unresectable/locally advanced):</b>", body_style), bullet("Chemo-XRT (5-FU based)"), bullet("FOLFOX or CAPOX"), bullet("9 of 10 patients showed conversion to resectable disease in retrospective series"), Spacer(1,3), Paragraph("<b>Metastatic disease:</b> CAPOX/FOLFOX (PS 0-2); best supportive care (PS 3-4).", body_style), ] adj_table = Table([[adj_left, adj_right]], colWidths=[col_w, col_w], style=TableStyle([('VALIGN',(0,0),(-1,-1),'TOP'),('LEFTPADDING',(0,0),(-1,-1),3),('RIGHTPADDING',(0,0),(-1,-1),3)])) story.append(adj_table) # Prognosis table story.append(Spacer(1, 4)) story.append(section_header("Prognosis - Disease Specific Survival (%) by Stage & Lymph Nodes")) prog_rows = [ ["0", "70", "44", "-"], ["1-7", "93", "69", "43"], [">7", "95", "83", "56"], ] story.append(make_table( ["Total Lymph Nodes Harvested", "Stage I (%)", "Stage II (%)", "Stage III (%)"], prog_rows, [col_w-10, col_w/2, col_w/2, col_w/2] )) story.append(Paragraph( "<i>Poor prognostic factors: poor differentiation, positive margins, duodenal location, male gender, elderly age, black ethnicity.</i>", ParagraphStyle('prognote', fontSize=7, fontName='Helvetica-Oblique', textColor=colors.HexColor('#555'), spaceAfter=2) )) # Algorithm image story.append(Spacer(1, 4)) img = download_image( "https://cdn.orris.care/cdss_images/10004f7fcb772ec171c7c55c916aafc2feb1f325a90d376a0f6fb8b27d06b57f.png", WIDTH - 2*MARGIN, 5.5*cm ) if img: story.append(img) story.append(Paragraph( "Algorithm 51.2: Management of small bowel adenocarcinoma (Mulholland & Greenfield's Surgery, 7e)", caption_style)) story.append(PageBreak()) # ───────────────────────────────────────────────────────────────── # PAGE 2: NON-HODGKIN LYMPHOMA OF SMALL BOWEL # ───────────────────────────────────────────────────────────────── story.append(Paragraph("Small Bowel Tumours: Investigation &amp; Management", ParagraphStyle('maintitle', fontSize=13, fontName='Helvetica-Bold', textColor=colors.HexColor('#1a3a5c'), alignment=TA_CENTER, spaceAfter=2))) story.append(Paragraph("Source: Mulholland &amp; Greenfield's Surgery (7e) | Bailey &amp; Love's Short Practice of Surgery (28e) | Schwartz's Principles of Surgery (11e)", ParagraphStyle('src', fontSize=7, fontName='Helvetica-Oblique', textColor=colors.HexColor('#666666'), alignment=TA_CENTER, spaceAfter=4))) story.append(HRFlowable(width="100%", thickness=1.5, color=colors.HexColor('#1a3a5c'), spaceAfter=6)) story.append(Paragraph("2. Non-Hodgkin Lymphoma of the Small Bowel", title_style)) story.append(HRFlowable(width="100%", thickness=0.5, color=colors.HexColor('#4a6fa5'), spaceAfter=4)) # Overview story.append(section_header("Overview", '#8b1a1a')) story.append(Paragraph( "Lymphomas account for approximately <b>15-20%</b> of all small intestine neoplasms. " "Distribution: Ileum 60-65%, Jejunum 20-25%, Duodenum 5-10%. " "The most common type is <b>Diffuse Large B-Cell Lymphoma (DLBCL)</b>. " "Unlike most solid tumours, <b>surgery is not the primary treatment</b> for intestinal lymphoma; " "it is reserved for complications.", body_style)) # Two columns nhl_left = [ section_header("Clinical Features", '#8b1a1a'), Spacer(1,2), bullet("Abdominal pain (most common)"), bullet("Palpable abdominal mass"), bullet("Weight loss, night sweats, fever (B symptoms)"), bullet("GI bleeding (haematemesis / melaena)"), bullet("Obstruction and perforation"), bullet("Malabsorption and diarrhoea"), Spacer(1,4), section_header("Types", '#8b1a1a'), Spacer(1,2), bullet("<b>DLBCL:</b> Most common; aggressive; requires R-CHOP chemotherapy"), bullet("<b>MALT lymphoma:</b> Low-grade; arises from mucosa-associated lymphoid tissue; linked to H. pylori"), bullet("<b>IPSID (Mediterranean lymphoma):</b> Immunoproliferative small intestinal disease; occurs in immunosuppressed; associated with H. pylori and Campylobacter jejuni"), bullet("<b>Burkitt lymphoma:</b> Highly aggressive B-cell lymphoma; classic jaw/abdominal mass in children"), bullet("<b>T-cell lymphoma (EATL):</b> Enteropathy-associated T-cell lymphoma; associated with coeliac disease"), bullet("<b>Mantle cell lymphoma:</b> Aggressive; multiple lymphomatous polyposis pattern"), ] nhl_right = [ section_header("Investigations", '#8b1a1a'), Spacer(1,2), bullet("<b>CT scan (chest-abdomen-pelvis):</b> First-line staging; assesses bowel wall thickening, mesenteric nodes, liver/spleen involvement"), bullet("<b>FDG-PET/CT:</b> Superior for staging DLBCL; assesses extent of nodal and extranodal disease"), bullet("<b>MRI enterography:</b> Useful for extent and mural involvement"), bullet("<b>Upper/lower GI endoscopy:</b> Direct visualisation and biopsy"), bullet("<b>Capsule endoscopy / Double-balloon enteroscopy:</b> Visualise small bowel lesions beyond reach of standard endoscopy"), bullet("<b>Tissue biopsy (histology + immunohistochemistry):</b> Definitive diagnosis; CD20, CD3, CD10, BCL-2, BCL-6, Ki-67, EBER"), bullet("<b>Bone marrow biopsy:</b> Staging for bone marrow involvement"), bullet("<b>LDH, beta-2 microglobulin, full blood count:</b> Disease activity markers"), bullet("<b>H. pylori testing:</b> Essential in MALT and IPSID"), ] nhl_col = Table([[nhl_left, nhl_right]], colWidths=[col_w, col_w], style=TableStyle([('VALIGN',(0,0),(-1,-1),'TOP'),('LEFTPADDING',(0,0),(-1,-1),3),('RIGHTPADDING',(0,0),(-1,-1),3)])) story.append(nhl_col) story.append(Spacer(1,4)) story.append(section_header("Management", '#8b1a1a')) mgmt_nhl_rows = [ ["DLBCL", "R-CHOP chemotherapy (Rituximab + Cyclophosphamide + Doxorubicin + Vincristine + Prednisolone) x 6-8 cycles; surgery only for obstruction/perforation/bleeding"], ["MALT (H. pylori +ve)", "H. pylori eradication therapy (triple therapy) as first-line; radiotherapy or rituximab if refractory"], ["IPSID", "Antibiotics for H. pylori/Campylobacter first; relapsing disease: radiation + chemotherapy + nutritional support"], ["EATL (T-cell)", "Chemotherapy (CHOP-based); surgery for complications; autologous stem cell transplant in eligible patients"], ["Burkitt lymphoma", "Intensive short-cycle chemotherapy (e.g., CODOX-M/IVAC or modified BFM); CNS prophylaxis required"], ] story.append(make_table( ["Lymphoma Type", "First-line Management"], mgmt_nhl_rows, [col_w*0.4, col_w*1.6] )) story.append(Spacer(1,4)) story.append(section_header("Role of Surgery in NHL", '#8b1a1a')) surg_left = [ Paragraph("<b>Surgery is NOT first-line treatment.</b> Reserved for:", body_style), bullet("Bowel obstruction not resolving with conservative measures"), bullet("Perforation or peritonitis"), bullet("Uncontrolled GI haemorrhage"), bullet("Diagnostic laparotomy / tissue biopsy when endoscopy fails"), bullet("Emergency resection as bridge to chemotherapy"), ] surg_right = [ Paragraph("<b>Ann Arbor Staging (simplified for GI lymphoma):</b>", body_style), bullet("<b>Stage I:</b> Single nodal region / single extranodal site"), bullet("<b>Stage II:</b> Two or more nodal regions on same side of diaphragm"), bullet("<b>Stage III:</b> Both sides of diaphragm involved"), bullet("<b>Stage IV:</b> Disseminated extralymphatic involvement"), Spacer(1,3), Paragraph("<b>5-year survival:</b> Stage IE ~75%; Stage IVE ~25%", body_style), ] surg_col = Table([[surg_left, surg_right]], colWidths=[col_w, col_w], style=TableStyle([('VALIGN',(0,0),(-1,-1),'TOP'),('LEFTPADDING',(0,0),(-1,-1),3),('RIGHTPADDING',(0,0),(-1,-1),3)])) story.append(surg_col) story.append(Spacer(1,4)) story.append(section_header("Special Considerations", '#8b1a1a')) story.append(Paragraph( "<b>IPSID (Immunoproliferative Small Intestinal Disease):</b> Also known as Mediterranean lymphoma. " "Occurs in chronically immunosuppressed patients. Caused by infection with <i>H. pylori</i> and " "<i>Campylobacter jejuni</i>. Antibiotic therapy usually results in regression. Most patients relapse " "and require radiation and chemotherapy with nutritional support.", body_style)) story.append(Paragraph( "<b>MALT Lymphoma - H. pylori connection:</b> When H. pylori-positive MALT lymphoma is confirmed, " "eradication therapy alone achieves complete histological remission in a significant proportion. " "Follow-up endoscopy at 3-month intervals post-eradication to confirm remission.", body_style)) story.append(PageBreak()) # ───────────────────────────────────────────────────────────────── # PAGE 3: GIST OF SMALL BOWEL # ───────────────────────────────────────────────────────────────── story.append(Paragraph("Small Bowel Tumours: Investigation &amp; Management", ParagraphStyle('maintitle', fontSize=13, fontName='Helvetica-Bold', textColor=colors.HexColor('#1a3a5c'), alignment=TA_CENTER, spaceAfter=2))) story.append(Paragraph("Source: Mulholland &amp; Greenfield's Surgery (7e) | Bailey &amp; Love's Short Practice of Surgery (28e) | Schwartz's Principles of Surgery (11e)", ParagraphStyle('src', fontSize=7, fontName='Helvetica-Oblique', textColor=colors.HexColor('#666666'), alignment=TA_CENTER, spaceAfter=4))) story.append(HRFlowable(width="100%", thickness=1.5, color=colors.HexColor('#1a3a5c'), spaceAfter=6)) story.append(Paragraph("3. Gastrointestinal Stromal Tumour (GIST) of the Small Bowel", title_style)) story.append(HRFlowable(width="100%", thickness=0.5, color=colors.HexColor('#4a6fa5'), spaceAfter=4)) # Overview story.append(section_header("Overview", '#1a5c3a')) story.append(Paragraph( "GISTs are the <b>most common mesenchymal tumours</b> of the small bowel, arising from the " "<b>interstitial cells of Cajal</b> (GI pacemaker cells). Distribution: Stomach 60-70%, " "Small intestine 20-30%, Duodenum 4-5%. Driven by gain-of-function mutation in the " "<b>c-KIT proto-oncogene</b> (tyrosine kinase receptor) identified by Hirota et al. " "Submucosal origin means tumours tend to grow <b>away from the lumen</b>, making intraluminal " "biopsy difficult (diagnosis confirmed by biopsy in only 1/3 of cases).", body_style)) # Two columns gist_left = [ section_header("Clinical Features", '#1a5c3a'), Spacer(1,2), bullet("Vague abdominal symptoms (most common)"), bullet("Abdominal pain"), bullet("GI bleeding (from mucosal erosion - haematemesis, melaena)"), bullet("Palpable abdominal mass"), bullet("Obstruction (less common than other tumours)"), bullet("Incidental finding on imaging"), Spacer(1,4), section_header("Prognostic Factors", '#1a5c3a'), Spacer(1,2), bullet("<b>Tumour size</b> (most important)"), bullet("<b>Mitotic rate</b> (/50 HPF - most accepted index)"), bullet("Tumour location (gastric GISTs behave better than small bowel)"), bullet("KIT mutational status"), bullet("Tumour rupture (automatically high risk)"), bullet("Note: Histopathology alone cannot predict malignant behaviour"), ] gist_right = [ section_header("Investigations", '#1a5c3a'), Spacer(1,2), bullet("<b>CT scan (contrast-enhanced):</b> Modality of choice; shows heterogeneous enhancing mass, may show necrosis/haemorrhage; no lymphadenopathy"), bullet("<b>FDG-PET/CT:</b> Assessment of metastatic disease and response to imatinib therapy"), bullet("<b>Endoscopy:</b> Most common detection method (submucosal bulge); biopsy yield low due to submucosal origin"), bullet("<b>EUS-guided FNA:</b> Useful for tissue diagnosis of submucosal lesions"), bullet("<b>MRI:</b> Useful for rectal/pelvic GIST assessment"), bullet("<b>Immunohistochemistry:</b> CD117 (c-KIT) positive - hallmark; CD34 positive (~70%); DOG1 positive; SMA, S-100 variable"), bullet("<b>Mutation analysis:</b> KIT exon 9/11, PDGFRA mutation - guides imatinib dosing"), bullet("<b>Mitotic count:</b> Count per 50 high-power fields (HPF)"), ] gist_col = Table([[gist_left, gist_right]], colWidths=[col_w, col_w], style=TableStyle([('VALIGN',(0,0),(-1,-1),'TOP'),('LEFTPADDING',(0,0),(-1,-1),3),('RIGHTPADDING',(0,0),(-1,-1),3)])) story.append(gist_col) story.append(Spacer(1,4)) story.append(section_header("Modified NIH-Fletcher GIST Risk Assessment Criteria", '#1a5c3a')) risk_rows = [ ["Very Low Risk", "<2.0", "≤5", "Any"], ["Low Risk", "2.1-5.0", "≤5", "Any"], ["Intermediate Risk", "2.1-5.0", ">5", "Gastric only"], ["High Risk", "<5.0", "6-10", "Any"], ["High Risk", "5.1-10.0", "≤5", "Gastric only"], ["High Risk", ">10", "Any", "Any"], ["High Risk", "Any", "Any", "Tumour rupture"], ["High Risk", ">5.0", ">5", "Any"], ] story.append(make_table( ["Risk Category", "Tumour Size (cm)", "Mitotic Index (/50 HPF)", "Primary Site"], risk_rows, [col_w*0.45, col_w*0.35, col_w*0.55, col_w*0.35] )) story.append(Spacer(1,4)) story.append(section_header("Management", '#1a5c3a')) mgmt_gist_left = [ Paragraph("<b>Surgical Management (curative intent):</b>", body_style), bullet("Complete surgical resection = only curative method"), bullet("Simple negative (R0) margins required; wide margins confer no extra benefit"), bullet("Small segmental resection of small bowel is adequate"), bullet("<b>Lymph node dissection NOT warranted</b> (GISTs rarely metastasise to lymph nodes)"), bullet("En bloc resection for locally advanced disease"), bullet("5-year survival after complete resection: 50-65%"), bullet("Laparoscopic resection appropriate for smaller lesions"), ] mgmt_gist_right = [ Paragraph("<b>Imatinib (Gleevec) - Tyrosine Kinase Inhibitor:</b>", body_style), bullet("<b>Mechanism:</b> Competitive inhibitor of multiple TKIs; disrupts KIT oncogene in GIST"), bullet("<b>Adjuvant:</b> High-risk GIST after R0 resection; 3 years imatinib → 98% 5-year recurrence-free survival"), bullet("<b>Neoadjuvant:</b> Locally advanced/borderline resectable GIST to allow organ-preserving resection"), bullet("<b>Metastatic/unresectable:</b> Imatinib 400 mg/day first-line; sunitinib second-line"), bullet("<b>Dose escalation:</b> KIT exon 9 mutation → imatinib 800 mg/day (standard dose inadequate)"), bullet("<b>PDGFRA D842V mutation:</b> Resistant to imatinib; avapritinib preferred"), ] mgmt_col = Table([[mgmt_gist_left, mgmt_gist_right]], colWidths=[col_w, col_w], style=TableStyle([('VALIGN',(0,0),(-1,-1),'TOP'),('LEFTPADDING',(0,0),(-1,-1),3),('RIGHTPADDING',(0,0),(-1,-1),3)])) story.append(mgmt_col) story.append(Spacer(1,4)) # Treatment algorithm table story.append(section_header("Treatment Summary by Disease Stage", '#1a5c3a')) stage_rows = [ ["Localised / Resectable", "Surgical resection (R0); adjuvant imatinib 3 yrs if intermediate/high risk"], ["Locally Advanced / Borderline", "Neoadjuvant imatinib to downstage, then reassess for resection"], ["Unresectable / Metastatic", "Imatinib 400 mg/day; increase to 800 mg if KIT exon 9 mutation; continue indefinitely"], ["Imatinib-refractory", "Sunitinib (2nd line); regorafenib (3rd line); ripretinib (4th line)"], ["PDGFRA D842V mutation", "Avapritinib 300 mg/day (FDA approved for this mutation)"], ["Post-resection surveillance", "CT every 3-6 months for 3-5 years; then annually"], ] story.append(make_table( ["Clinical Setting", "Recommended Management"], stage_rows, [col_w*0.6, col_w*1.4] )) # Build PDF doc.build(story) print("PDF generated successfully!") PYEOF python3 /tmp/workspace/small-bowel-tumours/generate_pdf.py

Running Command

ls -lh /tmp/workspace/small-bowel-tumours/small_bowel_tumours.pdf

Your PDF is ready:

small bowel tumours

PDF Document · PDF


A note on sources: SRB's Manual of Surgery is not available in the medical library, so the content is drawn from the three most authoritative surgery textbooks that are in the library: Mulholland & Greenfield's Surgery (7e), Bailey & Love's Short Practice of Surgery (28e), and Schwartz's Principles of Surgery (11e). The content is functionally equivalent and more detailed than what SRB covers on these topics.

Here is what each page contains:
Page 1 - Adenocarcinoma
  • Overview (2nd most common small bowel cancer, 30-40% of diagnoses)
  • Investigations: CEA/CA 19-9, CT enterography (84.7% sensitivity), MR enterography (91% sensitivity), DAE, MSI/MMR testing
  • Surgical management by location (Whipple's for duodenum, wide segmental resection for jejunum/ileum)
  • Adjuvant/neoadjuvant chemotherapy (FOLFOX, CAPOX, FOLFIRI)
  • Prognosis table by stage and lymph node harvest
  • Management algorithm image (Algorithm 51.2)
Page 2 - Non-Hodgkin Lymphoma
  • Overview (15-20% of small bowel neoplasms; ileum 60-65%)
  • Types: DLBCL, MALT, IPSID, EATL, Burkitt, Mantle cell
  • Full investigations including PET/CT, endoscopy, biopsy (CD20, CD3, BCL-2), bone marrow biopsy
  • Management table by subtype (R-CHOP, H. pylori eradication, antibiotics for IPSID)
  • Role of surgery (reserved for obstruction, perforation, bleeding only)
  • Ann Arbor staging and survival data
Page 3 - GIST
  • Overview (most common mesenchymal tumour; arises from interstitial cells of Cajal; c-KIT mutation)
  • Investigations: CT (modality of choice), PET/CT, EUS-guided FNA, CD117/DOG1 immunohistochemistry, mutation analysis
  • Modified NIH-Fletcher risk criteria table (size, mitotic rate, site)
  • Surgical management (R0 resection; no lymphadenectomy needed; 50-65% 5-yr survival)
  • Imatinib treatment algorithm including mutation-specific dosing (KIT exon 9 = 800 mg; PDGFRA D842V = avapritinib)
  • Full treatment summary by disease stage
This is a shared conversation. Sign in to Orris to start your own chat.