attachment
attachment

Create a beautiful pdf on long format answers according to the numbers given to each question atleast 1 A4 sheet long Take reference from standard surgery books and also add diagrams or flowchart if any needed

analyse_media
Reading File
Reading File
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Finding Sources
Finding Sources
Running Command

mkdir -p /tmp/workspace/surgery-exam-pdf && ls /tmp/workspace/surgery-exam-pdf/

Writing File

~/surgery-exam-pdf/generate_pdf.py


from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import cm, mm
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, KeepTogether, PageBreak
)
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_JUSTIFY
from reportlab.graphics.shapes import Drawing, Rect, String, Line, Polygon, Circle, Arrow
from reportlab.graphics import renderPDF
from reportlab.platypus.flowables import Flowable
import io

PAGE_W, PAGE_H = A4
MARGIN = 2.0 * cm

# ── colour palette ──────────────────────────────────────────────────────────
C_DARK_BLUE   = colors.HexColor('#1a3a5c')
C_MID_BLUE    = colors.HexColor('#2563a8')
C_LIGHT_BLUE  = colors.HexColor('#dbeafe')
C_GOLD        = colors.HexColor('#b8860b')
C_LIGHT_GOLD  = colors.HexColor('#fff8e1')
C_ACCENT      = colors.HexColor('#e63946')
C_LIGHT_GREEN = colors.HexColor('#d4edda')
C_DARK_GREEN  = colors.HexColor('#155724')
C_LIGHT_GREY  = colors.HexColor('#f4f6f9')
C_BOX_BORDER  = colors.HexColor('#4a90d9')
C_ORANGE      = colors.HexColor('#e67e22')
C_LIGHT_ORANGE= colors.HexColor('#fef3e2')

styles = getSampleStyleSheet()

def make_style(name, parent='Normal', **kw):
    return ParagraphStyle(name=name, parent=styles[parent], **kw)

# ── custom styles ────────────────────────────────────────────────────────────
S_COVER_TITLE   = make_style('CoverTitle', fontSize=28, textColor=colors.white,
                              alignment=TA_CENTER, leading=36, spaceAfter=8, fontName='Helvetica-Bold')
S_COVER_SUB     = make_style('CoverSub',   fontSize=13, textColor=colors.HexColor('#b0cce8'),
                              alignment=TA_CENTER, leading=18, spaceAfter=4)
S_Q_HEADER      = make_style('QHeader',    fontSize=13, textColor=colors.white,
                              fontName='Helvetica-Bold', leading=18, spaceAfter=2, spaceBefore=14)
S_SECTION       = make_style('Section',    fontSize=11.5, textColor=C_DARK_BLUE,
                              fontName='Helvetica-Bold', leading=15, spaceBefore=8, spaceAfter=3)
S_SUB_SECTION   = make_style('SubSection', fontSize=10.5, textColor=C_MID_BLUE,
                              fontName='Helvetica-Bold', leading=14, spaceBefore=5, spaceAfter=2)
S_BODY          = make_style('Body',       fontSize=9.8, leading=14.5, alignment=TA_JUSTIFY,
                              spaceAfter=4, textColor=colors.HexColor('#1a1a1a'))
S_BULLET        = make_style('Bullet',     fontSize=9.8, leading=14, leftIndent=14,
                              spaceAfter=2, textColor=colors.HexColor('#1a1a1a'))
S_TABLE_HDR     = make_style('TblHdr',     fontSize=9, textColor=colors.white,
                              fontName='Helvetica-Bold', alignment=TA_CENTER, leading=12)
S_TABLE_CELL    = make_style('TblCell',    fontSize=8.8, leading=12, alignment=TA_LEFT)
S_MARKS         = make_style('Marks',      fontSize=9, textColor=C_GOLD,
                              fontName='Helvetica-Bold', alignment=TA_LEFT)
S_NOTE          = make_style('Note',       fontSize=8.8, textColor=C_DARK_GREEN,
                              fontName='Helvetica-Oblique', leftIndent=6, leading=13)
S_CAPTION       = make_style('Caption',    fontSize=8.5, textColor=colors.grey,
                              alignment=TA_CENTER, fontName='Helvetica-Oblique', leading=11)

# ─── helper: coloured question banner ────────────────────────────────────────
def q_banner(q_num, title, marks_str):
    data = [[
        Paragraph(f"<b>Q{q_num}.</b>  {title}", S_Q_HEADER),
        Paragraph(f"<b>[{marks_str}]</b>", S_MARKS)
    ]]
    t = Table(data, colWidths=[14.2*cm, 3*cm])
    t.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,-1), C_DARK_BLUE),
        ('ROWBACKGROUNDS', (0,0), (-1,-1), [C_DARK_BLUE]),
        ('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
        ('LEFTPADDING', (0,0), (0,-1), 10),
        ('RIGHTPADDING', (-1,0), (-1,-1), 10),
        ('TOPPADDING', (0,0), (-1,-1), 7),
        ('BOTTOMPADDING', (0,0), (-1,-1), 7),
        ('ROUNDEDCORNERS', [4,4,4,4]),
    ]))
    return t

def sub_banner(letter, text):
    data = [[Paragraph(f"<b>({letter})</b>  {text}", make_style('SB_'+letter,
             fontSize=10, textColor=C_DARK_BLUE, fontName='Helvetica-Bold',
             leading=14, spaceAfter=1))]]
    t = Table(data, colWidths=[17.2*cm])
    t.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,-1), C_LIGHT_BLUE),
        ('LEFTPADDING', (0,0), (-1,-1), 10),
        ('TOPPADDING', (0,0), (-1,-1), 4),
        ('BOTTOMPADDING', (0,0), (-1,-1), 4),
        ('LINEBELOW', (0,0), (-1,-1), 1, C_MID_BLUE),
    ]))
    return t

def info_box(text, bg=C_LIGHT_GOLD, border=C_GOLD):
    data = [[Paragraph(text, make_style('IB', fontSize=9.5, leading=14,
                       textColor=colors.HexColor('#4a4a00'), alignment=TA_JUSTIFY))]]
    t = Table(data, colWidths=[17.2*cm])
    t.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,-1), bg),
        ('BOX', (0,0), (-1,-1), 1, border),
        ('LEFTPADDING', (0,0), (-1,-1), 10),
        ('RIGHTPADDING', (0,0), (-1,-1), 10),
        ('TOPPADDING', (0,0), (-1,-1), 6),
        ('BOTTOMPADDING', (0,0), (-1,-1), 6),
    ]))
    return t

def bullet(text):
    return Paragraph(f"• &nbsp; {text}", S_BULLET)

def subbullet(text):
    return Paragraph(f"&nbsp;&nbsp;&nbsp;– {text}", make_style('SB',
                     fontSize=9.5, leading=13.5, leftIndent=24,
                     spaceAfter=2, textColor=colors.HexColor('#2a2a2a')))

def b(text):
    return Paragraph(text, S_BODY)

def sp(h=0.18):
    return Spacer(1, h*cm)

def section(text):
    return Paragraph(text, S_SECTION)

def subsection(text):
    return Paragraph(text, S_SUB_SECTION)

def hr():
    return HRFlowable(width='100%', thickness=0.5, color=colors.HexColor('#c8d8ec'), spaceAfter=3, spaceBefore=3)

# ─── simple ascii-art flowcharts drawn with ReportLab Tables ─────────────────
def flow_box(text, bg=C_LIGHT_BLUE, border=C_MID_BLUE, width=17.2*cm):
    s = make_style('FB', fontSize=9, leading=12, textColor=C_DARK_BLUE,
                   alignment=TA_CENTER, fontName='Helvetica-Bold')
    data = [[Paragraph(text, s)]]
    t = Table(data, colWidths=[width])
    t.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,-1), bg),
        ('BOX', (0,0), (-1,-1), 1.2, border),
        ('TOPPADDING', (0,0), (-1,-1), 5),
        ('BOTTOMPADDING', (0,0), (-1,-1), 5),
    ]))
    return t

def flow_arrow():
    data = [[Paragraph("▼", make_style('ARR', fontSize=11, alignment=TA_CENTER,
                                        textColor=C_MID_BLUE))]]
    t = Table(data, colWidths=[17.2*cm])
    t.setStyle(TableStyle([
        ('ALIGN', (0,0), (-1,-1), 'CENTER'),
        ('TOPPADDING', (0,0), (-1,-1), 1),
        ('BOTTOMPADDING', (0,0), (-1,-1), 1),
    ]))
    return t

def two_col_table(headers, rows, col_widths=None):
    if col_widths is None:
        col_widths = [5.5*cm, 11.7*cm]
    data = [[Paragraph(h, S_TABLE_HDR) for h in headers]] + \
           [[Paragraph(str(cell), S_TABLE_CELL) for cell in row] for row in rows]
    t = Table(data, colWidths=col_widths)
    t.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,0), C_DARK_BLUE),
        ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, C_LIGHT_GREY]),
        ('GRID', (0,0), (-1,-1), 0.5, colors.HexColor('#b0c4de')),
        ('VALIGN', (0,0), (-1,-1), 'TOP'),
        ('LEFTPADDING', (0,0), (-1,-1), 6),
        ('RIGHTPADDING', (0,0), (-1,-1), 6),
        ('TOPPADDING', (0,0), (-1,-1), 4),
        ('BOTTOMPADDING', (0,0), (-1,-1), 4),
    ]))
    return t

# ════════════════════════════════════════════════════════════════════════════
#  BUILD DOCUMENT
# ════════════════════════════════════════════════════════════════════════════
story = []

# ─────────────────────────────────────────────────────────────────────────────
# COVER PAGE
# ─────────────────────────────────────────────────────────────────────────────
cover_bg = Table([['']], colWidths=[17.2*cm], rowHeights=[24*cm])
cover_bg.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,-1), C_DARK_BLUE),
    ('ROUNDEDCORNERS', [6,6,6,6]),
]))

story.append(Spacer(1, 2*cm))
story.append(cover_bg)
story.append(Spacer(1, -23*cm))   # overlap

cv = []
cv.append(Spacer(1, 3.5*cm))
cv.append(Paragraph("SURGERY", S_COVER_TITLE))
cv.append(Paragraph("Comprehensive Exam Answer Booklet", S_COVER_SUB))
cv.append(Spacer(1, 0.4*cm))
cv.append(Paragraph("General Surgery  •  Orthopedics  •  Anatomy  •  Anaesthesia", S_COVER_SUB))
cv.append(Spacer(1, 0.5*cm))

divider_data = [['']]
divider = Table(divider_data, colWidths=[12*cm], rowHeights=[0.08*cm])
divider.setStyle(TableStyle([('BACKGROUND', (0,0), (-1,-1), C_GOLD)]))
cv.append(Table([[divider]], colWidths=[17.2*cm]))
cv.append(Spacer(1, 0.5*cm))

cv.append(Paragraph("Based on: Bailey & Love's Surgery | Current Surgical Therapy | Schwartz's Principles of Surgery", S_COVER_SUB))
cv.append(Spacer(1, 0.5*cm))
cv.append(Paragraph("Questions: Q2 – Q9    |    Long Format Model Answers", S_COVER_SUB))
for c in cv:
    story.append(c)

story.append(Spacer(1, 12*cm))
story.append(PageBreak())

# ────────────────────────────────────────────────────────────────────────────
# Q2 – SURGICAL ANATOMY OF THYROID + THYROIDITIS + HASHIMOTO  [4+4+4=12]
# ────────────────────────────────────────────────────────────────────────────
story.append(q_banner(2,
    "Surgical Anatomy of Thyroid | Types of Thyroiditis | Hashimoto Thyroiditis & Management",
    "Marks: 4+4+4 = 12"))
story.append(sp())

# PART A
story.append(sub_banner("A", "Surgical Anatomy of Thyroid  [4 Marks]"))
story.append(sp(0.15))
story.append(section("Location & Shape"))
story.append(b("The thyroid gland is a butterfly-shaped bilobar endocrine gland situated in the anterior aspect of the neck. It lies in levels II-IV. Each lobe is approximately 5 cm long, 3 cm wide and 2 cm thick. The isthmus connects the two lobes at the 2nd–4th tracheal rings. A pyramidal lobe ascends from the isthmus in about 50% of individuals, representing the remnant of the thyroglossal duct."))
story.append(sp(0.12))

story.append(section("Relationships (Surgically Important)"))
data_rel = [
    ["Structure", "Relationship"],
    ["Anteriorly", "Strap muscles (sternohyoid, sternothyroid, omohyoid), investing layer of deep cervical fascia"],
    ["Posteriorly", "Trachea, oesophagus, RLN in tracheo-oesophageal groove"],
    ["Laterally", "Carotid sheath (CCA, IJV, vagus nerve)"],
    ["Postero-medially", "Parathyroid glands (superior: at junction of upper 1/3 and lower 2/3 of posterior lobe; inferior: variable, often near lower pole)"],
]
t = Table([[Paragraph(d[0], S_TABLE_HDR if i==0 else S_TABLE_CELL),
            Paragraph(d[1], S_TABLE_HDR if i==0 else S_TABLE_CELL)]
           for i, d in enumerate(data_rel)],
          colWidths=[5*cm, 12.2*cm])
t.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), C_DARK_BLUE),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, C_LIGHT_GREY]),
    ('GRID', (0,0), (-1,-1), 0.5, colors.HexColor('#b0c4de')),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
    ('LEFTPADDING', (0,0), (-1,-1), 6),
    ('RIGHTPADDING', (0,0), (-1,-1), 6),
    ('TOPPADDING', (0,0), (-1,-1), 4),
    ('BOTTOMPADDING', (0,0), (-1,-1), 4),
]))
story.append(t)
story.append(sp(0.15))

story.append(section("Blood Supply"))
story.append(bullet("<b>Superior thyroid artery</b> – 1st branch of external carotid artery (ECA)"))
story.append(bullet("<b>Inferior thyroid artery</b> – from thyrocervical trunk of subclavian artery"))
story.append(bullet("<b>Thyroid ima artery</b> – present in ~3% from aortic arch/brachiocephalic; important to ligate before tracheostomy"))
story.append(bullet("<b>Veins</b>: Superior & middle thyroid veins → IJV; inferior thyroid veins → brachiocephalic veins"))
story.append(sp(0.12))

story.append(section("Recurrent Laryngeal Nerve (RLN) – Key Surgical Landmark"))
story.append(b("The RLN runs in the tracheo-oesophageal groove. On the right it loops around the subclavian artery; on the left it loops around the arch of aorta. It enters the larynx posterior to the cricothyroid joint. Injury causes hoarseness (unilateral) or aphonia/respiratory distress (bilateral). It must be identified and preserved during thyroidectomy."))
story.append(sp(0.12))
story.append(section("External Branch of Superior Laryngeal Nerve (EBSLN)"))
story.append(b("Runs with the superior thyroid artery. Injury causes loss of cricothyroid muscle action → monotone voice, loss of high-pitched phonation. The 'opera singer's nerve.'"))
story.append(sp(0.12))

story.append(section("Lymphatic Drainage"))
story.append(bullet("Isthmus & medial lobes → Delphian (prelaryngeal) node, then central compartment (level VI)"))
story.append(bullet("Lateral lobes → levels III, IV, V (jugular chain)"))
story.append(bullet("Lower pole → superior mediastinal nodes"))
story.append(sp(0.15))

# Flowchart: Thyroid blood supply
story.append(section("Diagram: Thyroid Blood Supply Overview"))
fc = [
    ["<b>Superior Thyroid Artery</b><br/>(1st branch of ECA)", "<b>Inferior Thyroid Artery</b><br/>(Thyrocervical trunk → Subclavian)", "<b>Thyroid Ima</b><br/>(Aorta / Brachiocephalic ~3%)"],
]
chart_t = Table(fc, colWidths=[5.5*cm, 6.5*cm, 5.2*cm])
chart_t.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (0,0), colors.HexColor('#3a86ff')),
    ('BACKGROUND', (1,0), (1,0), colors.HexColor('#06d6a0')),
    ('BACKGROUND', (2,0), (2,0), colors.HexColor('#ef476f')),
    ('TEXTCOLOR', (0,0), (-1,-1), colors.white),
    ('FONTNAME', (0,0), (-1,-1), 'Helvetica-Bold'),
    ('FONTSIZE', (0,0), (-1,-1), 8.5),
    ('ALIGN', (0,0), (-1,-1), 'CENTER'),
    ('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
    ('TOPPADDING', (0,0), (-1,-1), 7),
    ('BOTTOMPADDING', (0,0), (-1,-1), 7),
    ('GRID', (0,0), (-1,-1), 1, colors.white),
]))
story.append(chart_t)
story.append(Paragraph("Diagram 1: Arterial supply of thyroid gland", S_CAPTION))
story.append(sp(0.2))
story.append(hr())

# PART B
story.append(sub_banner("B", "Types of Thyroiditis  [4 Marks]"))
story.append(sp(0.15))
types_data = [
    ["Type", "Cause", "Key Features", "Treatment"],
    ["Hashimoto's\n(Chronic autoimmune)", "Autoimmune\n(T-cell mediated)", "Most common; goitre; hypothyroidism; Anti-TPO +ve; Hurthle cells", "Levothyroxine; surgery if mass effect"],
    ["de Quervain's\n(Subacute granulomatous)", "Viral (post URI)", "Painful tender goitre; ESR↑; triphasic thyroid function; self-limiting", "NSAIDs; steroids; beta-blockers"],
    ["Riedel's\n(Fibrous)", "Unknown (IgG4?)", "Woody hard 'stone-like' thyroid; tracheal compression; invasive fibrosis", "Steroids; surgery for decompression"],
    ["Postpartum", "Autoimmune", "Within 1 year postpartum; hyper then hypo phase; Anti-TPO +ve", "Symptomatic; usually resolves"],
    ["Acute Suppurative", "Bacterial\n(S. aureus, Strep)", "Rare; painful abscess; fever; pyriform sinus fistula in children", "IV antibiotics; drainage"],
    ["Silent/Painless", "Autoimmune", "Similar to Hashimoto; transient thyrotoxicosis; no pain", "Beta-blockers; observation"],
]
tt = Table([[Paragraph(d[0], S_TABLE_HDR if i==0 else S_TABLE_CELL),
             Paragraph(d[1], S_TABLE_HDR if i==0 else S_TABLE_CELL),
             Paragraph(d[2], S_TABLE_HDR if i==0 else S_TABLE_CELL),
             Paragraph(d[3], S_TABLE_HDR if i==0 else S_TABLE_CELL)]
            for i, d in enumerate(types_data)],
           colWidths=[4*cm, 3*cm, 6.2*cm, 4*cm])
tt.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), C_DARK_BLUE),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, C_LIGHT_GREY]),
    ('GRID', (0,0), (-1,-1), 0.5, colors.HexColor('#b0c4de')),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
    ('FONTSIZE', (0,1), (-1,-1), 8.5),
    ('LEFTPADDING', (0,0), (-1,-1), 5),
    ('RIGHTPADDING', (0,0), (-1,-1), 5),
    ('TOPPADDING', (0,0), (-1,-1), 4),
    ('BOTTOMPADDING', (0,0), (-1,-1), 4),
]))
story.append(tt)
story.append(sp(0.15))
story.append(hr())

# PART C
story.append(sub_banner("C", "Hashimoto Thyroiditis – Pathology & Management  [4 Marks]"))
story.append(sp(0.15))
story.append(subsection("Definition"))
story.append(b("Hashimoto thyroiditis (HT) is the most common cause of hypothyroidism in iodine-replete countries. It is a T-cell–mediated autoimmune destruction of thyroid follicular cells. Prevalence: 1-2% of the population; women:men = 7:1. (Source: Current Surgical Therapy 14e)"))

story.append(subsection("Pathogenesis"))
story.append(bullet("Molecular mimicry or dysregulation of regulatory T-cells triggers autoreactive CD4+ and CD8+ T-cells"))
story.append(bullet("B-cells produce anti-TPO (antimicrosomal) and anti-thyroglobulin antibodies"))
story.append(bullet("Cytokine-mediated apoptosis of follicular cells → lymphocytic infiltration → germinal centres → fibrosis"))
story.append(bullet("Hurthle (Askanazy) cell metaplasia – oncocytic change of follicular epithelium (pathognomonic)"))

story.append(subsection("Clinical Features"))
story.append(bullet("Painless diffuse firm goitre (rubbery in consistency)"))
story.append(bullet("Symptoms of <b>hypothyroidism</b>: fatigue, weight gain, constipation, cold intolerance, bradycardia, dry skin"))
story.append(bullet("'<b>Hashitoxicosis</b>': Transient hyperthyroidism due to follicular disruption releasing stored T3/T4"))
story.append(bullet("Increased risk of <b>thyroid lymphoma</b> (primary B-cell MALT type)"))
story.append(bullet("Associated with other autoimmune diseases: Type 1 DM, SLE, Sjögren, pernicious anaemia"))

story.append(subsection("Investigations"))
story.append(bullet("Anti-TPO antibodies (most sensitive; >90% +ve)"))
story.append(bullet("Anti-thyroglobulin antibodies"))
story.append(bullet("TFTs: TSH ↑, Free T4 ↓ (hypothyroid state)"))
story.append(bullet("Ultrasound: heterogeneous gland with pseudonodules, ↓ echogenicity"))
story.append(bullet("FNAC: lymphocytes, Hurthle cells, follicular cells → Bethesda II (benign)"))

story.append(subsection("Management"))

# Management flowchart
story.append(flow_box("HASHIMOTO THYROIDITIS – CONFIRMED (Anti-TPO +ve, ↑TSH)", C_LIGHT_BLUE, C_MID_BLUE))
story.append(flow_arrow())
fc2_data = [
    ["<b>Subclinical Hypothyroid</b>\n(TSH 4.5-10; asymptomatic)", "<b>Overt Hypothyroid</b>\n(TSH >10 or symptomatic)", "<b>Euthyroid</b>\n(incidental finding)"],
]
chart_t2 = Table(fc2_data, colWidths=[5.5*cm, 5.7*cm, 6*cm])
chart_t2.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (0,0), colors.HexColor('#f9c74f')),
    ('BACKGROUND', (1,0), (1,0), colors.HexColor('#f94144')),
    ('BACKGROUND', (2,0), (2,0), colors.HexColor('#43aa8b')),
    ('TEXTCOLOR', (0,0), (-1,-1), colors.white),
    ('FONTNAME', (0,0), (-1,-1), 'Helvetica-Bold'),
    ('FONTSIZE', (0,0), (-1,-1), 8.5),
    ('ALIGN', (0,0), (-1,-1), 'CENTER'),
    ('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
    ('TOPPADDING', (0,0), (-1,-1), 8),
    ('BOTTOMPADDING', (0,0), (-1,-1), 8),
    ('GRID', (0,0), (-1,-1), 1, colors.white),
]))
story.append(chart_t2)
story.append(flow_arrow())

fc3_data = [
    ["Observe / repeat TFTs\nin 6 months", "Levothyroxine\n(1.6 mcg/kg/day)\nTarget TSH: 0.5-2.5", "Annual TFTs\nNo treatment needed"],
]
chart_t3 = Table(fc3_data, colWidths=[5.5*cm, 5.7*cm, 6*cm])
chart_t3.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (0,0), colors.HexColor('#f9c74f')),
    ('BACKGROUND', (1,0), (1,0), colors.HexColor('#f94144')),
    ('BACKGROUND', (2,0), (2,0), colors.HexColor('#43aa8b')),
    ('TEXTCOLOR', (0,0), (-1,-1), colors.white),
    ('FONTSIZE', (0,0), (-1,-1), 8.5),
    ('ALIGN', (0,0), (-1,-1), 'CENTER'),
    ('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
    ('TOPPADDING', (0,0), (-1,-1), 7),
    ('BOTTOMPADDING', (0,0), (-1,-1), 7),
    ('GRID', (0,0), (-1,-1), 1, colors.white),
]))
story.append(chart_t3)
story.append(sp(0.1))
story.append(flow_box("SURGICAL INDICATIONS: Compressive symptoms | Suspected malignancy | Large goitre not responding to levothyroxine | Thyroid lymphoma", C_LIGHT_ORANGE, C_ORANGE))
story.append(Paragraph("Flowchart 1: Management algorithm for Hashimoto Thyroiditis", S_CAPTION))
story.append(sp(0.2))
story.append(info_box("🔑 Key Fact (Bailey & Love): Hashimoto thyroiditis is the most common cause of hypothyroidism in iodine-replete nations. Anti-TPO antibodies are the hallmark diagnostic test. Levothyroxine is the mainstay of medical management."))
story.append(PageBreak())

# ────────────────────────────────────────────────────────────────────────────
# Q3 – SHORT NOTES [4 each = 20]
# ────────────────────────────────────────────────────────────────────────────
story.append(q_banner(3, "Short Notes — 5 Topics", "4 Marks Each = 20"))
story.append(sp())

# (a) Mondor's disease
story.append(sub_banner("a", "Mondor's Disease of Breast"))
story.append(sp(0.12))
story.append(b("<b>Definition:</b> Superficial thrombophlebitis of the subcutaneous veins of the breast/anterior chest wall, predominantly the <b>thoracoepigastric vein</b> or lateral thoracic vein."))
story.append(bullet("<b>Aetiology:</b> Trauma, tight bra, post-lumpectomy, breast augmentation, strenuous activity, hypercoagulable states, malignancy (rarely)"))
story.append(bullet("<b>Presentation:</b> Cord-like subcutaneous induration/tenderness over breast or chest wall; overlying skin puckering forming a 'cord' visible on stretching the arm. No lymphadenopathy."))
story.append(bullet("<b>Investigations:</b> Doppler USS to confirm venous thrombosis; mammogram to exclude malignancy"))
story.append(bullet("<b>Treatment:</b> Conservative – NSAIDs, warm compresses; resolves spontaneously in 6-8 weeks"))
story.append(bullet("<b>Importance:</b> Skin tethering mimics carcinoma; must exclude malignancy underlying the lesion"))
story.append(info_box("Mondor's: Subcutaneous phlebitis of breast veins → cord-like induration → self-limiting. Exclude malignancy. Treat with NSAIDs."))
story.append(sp(0.15))

# (b) Thyroglossal Cyst
story.append(sub_banner("b", "Thyroglossal Cyst"))
story.append(sp(0.12))
story.append(b("<b>Embryology:</b> The thyroid descends from the foramen caecum at the base of tongue to its final position by week 7, along the thyroglossal duct. Failure of obliteration → thyroglossal cyst."))
story.append(bullet("<b>Position:</b> Midline neck, most commonly at or below the hyoid bone (65%). Can be suprahyoid (20%) or at thyroid cartilage level (15%)"))
story.append(bullet("<b>Moves with swallowing AND tongue protrusion</b> (due to attachment to hyoid via duct) — distinguishing feature from other neck swellings"))
story.append(bullet("<b>Contents:</b> Mucus-secreting epithelium; may contain thyroid tissue"))
story.append(bullet("<b>Complications:</b> Infection → abscess; rarely papillary thyroid carcinoma (1%)"))
story.append(bullet("<b>Investigations:</b> Ultrasound; thyroid scan (ensure ectopic thyroid is not the only functioning tissue)"))
story.append(bullet("<b>Treatment:</b> <b>Sistrunk's operation</b> – excision of cyst + central portion of hyoid bone + tract up to foramen caecum; recurrence rate <3% with Sistrunk vs 50-80% without"))
story.append(info_box("Key: Moves with swallowing + tongue protrusion. Treatment = Sistrunk's operation (excision + central hyoid + duct tract to foramen caecum)."))
story.append(sp(0.15))

# (c) Wilkie's Syndrome
story.append(sub_banner("c", "Wilkie's Syndrome (Superior Mesenteric Artery Syndrome)"))
story.append(sp(0.12))
story.append(b("<b>Definition:</b> Compression of the 3rd part of duodenum between the Superior Mesenteric Artery (SMA) anteriorly and the aorta/vertebral column posteriorly, causing proximal duodenal obstruction."))
story.append(bullet("<b>Aetiology:</b> Loss of mesenteric fat pad reducing the aortomesenteric angle (<25°; normal 38-65°). Causes: rapid weight loss, prolonged bed rest, malnutrition, eating disorders (anorexia), spinal surgery, body casting"))
story.append(bullet("<b>Symptoms:</b> Postprandial nausea, bilious vomiting (non-feculent), epigastric pain, early satiety, weight loss, relief in prone/left lateral decubitus position"))
story.append(bullet("<b>Diagnosis:</b> Upper GI barium showing 'to-and-fro' sign at D3; CT angiography shows aortomesenteric angle <25° and decreased distance <8mm"))
story.append(bullet("<b>Management:</b>"))
story.append(subbullet("Conservative: NG tube, parenteral/enteral nutrition (via post-ligament of Treitz tube), prone position, weight gain"))
story.append(subbullet("Surgical: Strong's procedure (duodenojejunostomy) or division of ligament of Treitz; laparoscopic approach preferred"))
story.append(info_box("Wilkie's Syndrome = SMA compresses D3. Barium shows to-and-fro peristalsis. Surgery = duodenojejunostomy (Strong's procedure)."))
story.append(sp(0.15))

# (d) Gastrinomas
story.append(sub_banner("d", "Gastrinomas (Zollinger-Ellison Syndrome)"))
story.append(sp(0.12))
story.append(b("<b>Definition:</b> Gastrin-secreting neuroendocrine tumours causing Zollinger-Ellison Syndrome (ZES) – characterised by recurrent severe peptic ulcers, diarrhoea, and elevated serum gastrin."))
story.append(bullet("<b>Location:</b> 'Gastrinoma Triangle' (Passaro's triangle) – bounded by junction of cystic duct/CBD, junction of D2/D3, and neck of pancreas. 90% found here. 25-30% in duodenum (most common site), 25% pancreas"))
story.append(bullet("<b>Features of ZES:</b> Multiple/recurrent peptic ulcers (especially post-bulbar, jejunal), chronic watery diarrhoea, malabsorption, oesophageal ulceration"))
story.append(bullet("<b>Association with MEN-1:</b> 25% of gastrinomas are part of MEN-1 (parathyroid, pituitary, pancreatic islet cell tumours) — must screen"))
story.append(bullet("<b>Diagnosis:</b> Fasting serum gastrin >1000 pg/mL (diagnostic); Secretin stimulation test (paradoxical ↑ in gastrin ≥200 pg/mL); octreotide scan / PET-CT for localisation"))
story.append(bullet("<b>Treatment:</b> High-dose PPI (omeprazole 60-120mg/day) for acid control; surgical resection if sporadic, solitary, and no MEN-1; somatostatin analogues for metastatic disease"))
story.append(info_box("ZES triad: Severe peptic ulcers + diarrhoea + elevated gastrin. Test: secretin stimulation. Locate in Passaro's triangle. Treat: PPI + surgery."))
story.append(sp(0.15))

# (e) Hernia en Glissade
story.append(sub_banner("e", "Hernia en Glissade (Sliding Hernia)"))
story.append(sp(0.12))
story.append(b("<b>Definition:</b> A sliding hernia is one in which part of the wall of the hernia sac is formed by the viscus itself. Unlike a true hernia, the organ 'slides' partially out of its retroperitoneal or subperitoneal position."))
story.append(bullet("<b>Common viscera involved:</b> Caecum (right side), Sigmoid colon (left side), Urinary bladder (direct inguinal hernias)"))
story.append(bullet("<b>Mechanism:</b> The posterior wall of the hernia sac is replaced by the retroperitoneal organ (e.g., caecum). Only the anterior aspect is covered by peritoneum"))
story.append(bullet("<b>Importance:</b> The visceral component MUST NOT be excised as it is part of the hernia sac → inadvertent enterotomy or cystotomy risk"))
story.append(bullet("<b>Surgical implications:</b> During repair, the sliding component is reduced, the sac is inverted/ligated, and a standard mesh repair (Lichtenstein) is performed. The viscus must be recognized and preserved."))
story.append(bullet("<b>Diagnosis:</b> Usually identified intraoperatively; CT may show sliding component preoperatively"))
story.append(info_box("Sliding hernia: viscus forms part of sac wall. Never excise sac blindly — may injure caecum, sigmoid, or bladder. Reduce viscus, then repair."))
story.append(PageBreak())

# ────────────────────────────────────────────────────────────────────────────
# Q4 – EXPLAIN WHY [4 each = 12]
# ────────────────────────────────────────────────────────────────────────────
story.append(q_banner(4, "Explain Why — 3 Concepts", "4 Marks Each = 12"))
story.append(sp())

# (a) Duodenum removed with Whipple's
story.append(sub_banner("a", "Why is the Duodenum Removed During Whipple's Procedure Along with Pancreas?"))
story.append(sp(0.12))
story.append(b("The Whipple procedure (pancreaticoduodenectomy) removes the head of pancreas, entire duodenum, distal stomach, gallbladder and distal CBD. The duodenum is inseparably removed for the following reasons:"))
story.append(bullet("<b>1. Shared Blood Supply:</b> The duodenum (D1–D4) receives its blood supply almost exclusively from branches of the <b>gastroduodenal artery (GDA)</b> via the anterior and posterior superior pancreaticoduodenal arteries, and from the inferior pancreaticoduodenal artery (from SMA). Both GDA and these arcades lie at the pancreatico-duodenal junction. Devascularization of the duodenum is inevitable when the pancreatic head is removed."))
story.append(bullet("<b>2. Anatomical Intimacy:</b> The 2nd part of duodenum wraps around the head of pancreas ('C-loop'). It cannot be separated from the pancreatic head without violating its vascularity and structural integrity."))
story.append(bullet("<b>3. Biliopancreatic Drainage:</b> The ampulla of Vater (where CBD + pancreatic duct drain) is embedded in the medial wall of D2. The common channel must be resected with the specimen."))
story.append(bullet("<b>4. Oncological Clearance:</b> For pancreatic head/ampullary/duodenal/CBD tumours, the duodenum is part of the resection margin. Leaving it behind would compromise R0 resection."))
story.append(sp(0.1))
# Diagram
story.append(flow_box("HEAD OF PANCREAS + DUODENUM (D1–D4) + DISTAL CBD + GALLBLADDER + DISTAL STOMACH", C_LIGHT_BLUE, C_MID_BLUE))
story.append(flow_arrow())
story.append(flow_box("SHARED BLOOD SUPPLY via GDA branches (Superior & Inferior Pancreaticoduodenal Arteries)", C_LIGHT_GOLD, C_GOLD))
story.append(flow_arrow())
story.append(flow_box("Duodenum CANNOT survive without pancreatic head → En-bloc removal mandatory", C_LIGHT_ORANGE, C_ORANGE))
story.append(Paragraph("Flowchart 2: Rationale for duodenal removal in Whipple's procedure", S_CAPTION))
story.append(sp(0.15))

# (b) Low malignancy in small intestine
story.append(sub_banner("b", "Why is the Incidence of Malignancy Relatively Less in the Small Intestine?"))
story.append(sp(0.12))
story.append(b("Despite the small intestine comprising ~75% of GI tract length and ~90% of mucosal surface area, it accounts for only 3-6% of GI malignancies. Several protective mechanisms operate:"))
story.append(bullet("<b>1. Rapid Transit Time:</b> Small intestinal transit is rapid (3-5 hours vs 72 hours in colon), minimising exposure of mucosa to dietary carcinogens"))
story.append(bullet("<b>2. Alkaline pH:</b> Bile and pancreatic juice make the small intestinal lumen alkaline, unfavourable for bacterial growth and generation of carcinogens (unlike the acidic/neutral colon)"))
story.append(bullet("<b>3. Liquid Content:</b> Fluid chyme causes less mechanical trauma to the mucosa compared to solid faeces in the colon"))
story.append(bullet("<b>4. Rich Immunological Defence:</b> Highest concentration of IgA-secreting plasma cells and GALT (gut-associated lymphoid tissue) → immune surveillance against malignant transformation"))
story.append(bullet("<b>5. High Benzpyrene Hydroxylase Activity:</b> Rapid detoxification of ingested carcinogens by the small intestinal mucosa"))
story.append(bullet("<b>6. Rapid Cell Turnover:</b> Rapid mucosal regeneration limits carcinogen-cell contact time"))
story.append(bullet("<b>7. Low Bacterial Concentration:</b> Sparse microbiome in small intestine (unlike dense colonic flora) reduces secondary bile acid conversion and carcinogen production"))
story.append(info_box("Mnemonic – 'RABBIT': Rapid transit, Alkaline pH, Benzpyrene hydroxylase, Bile dilution, Immunological defence (IgA/GALT), Thin watery content."))
story.append(sp(0.15))

# (c) Irreducible hernia – earlier surgery
story.append(sub_banner("c", "Why Should Irreducible Hernia Be Managed Surgically Earlier Than Reducible Hernia?"))
story.append(sp(0.12))
story.append(b("An irreducible (incarcerated) hernia cannot be returned to the abdominal cavity. It demands earlier surgical intervention for the following critical reasons:"))
story.append(bullet("<b>1. Risk of Strangulation:</b> Incarceration → pressure on neck of sac → venous congestion → arterial ischaemia → strangulation. Strangulation occurs in 5-10% within 3 months of incarceration. Strangulated hernias carry 20-30% mortality."))
story.append(bullet("<b>2. Bowel Obstruction:</b> Incarcerated bowel in hernia sac leads to intestinal obstruction – vomiting, absolute constipation, distension – a surgical emergency"))
story.append(bullet("<b>3. Irreversible Ischaemia:</b> After 6 hours of strangulation → full-thickness bowel necrosis → perforation → faecal peritonitis → sepsis → multi-organ failure"))
story.append(bullet("<b>4. Richter's Hernia Risk:</b> Only part of bowel wall may be in sac (Richter's) – obstruction may be absent but strangulation can still occur silently"))
story.append(bullet("<b>5. Contrast with Reducible:</b> Reducible hernias have free neck, return spontaneously, no vascular compromise → elective repair feasible. Time allows optimisation of patient fitness."))
story.append(sp(0.1))
story.append(flow_box("IRREDUCIBLE (INCARCERATED) HERNIA", colors.HexColor('#ffe0e0'), C_ACCENT))
story.append(flow_arrow())
story.append(flow_box("Venous outflow obstruction → Oedema → Arterial occlusion", colors.HexColor('#ffeecc'), C_ORANGE))
story.append(flow_arrow())
story.append(flow_box("STRANGULATION: Ischaemia → Gangrene → Perforation → Peritonitis → Death", colors.HexColor('#ffe0e0'), C_ACCENT))
story.append(Paragraph("Flowchart 3: Progression of incarcerated hernia to strangulation", S_CAPTION))
story.append(PageBreak())

# ────────────────────────────────────────────────────────────────────────────
# Q5 – SHORT NOTES [3 each = 15]
# ────────────────────────────────────────────────────────────────────────────
story.append(q_banner(5, "Short Notes — 5 Topics", "3 Marks Each = 15"))
story.append(sp())

# (a) Menetrier's Disease
story.append(sub_banner("a", "Menetrier's Disease"))
story.append(sp(0.12))
story.append(b("<b>Definition:</b> Rare hyperplastic gastropathy characterised by giant rugal folds in the gastric body/fundus (>10mm wide), foveolar hyperplasia, oxyntic gland atrophy, and protein-losing gastropathy."))
story.append(bullet("<b>Pathogenesis:</b> Overexpression of TGF-α → ligand for EGFR → excessive foveolar cell proliferation → mucous cell hyperplasia at expense of parietal cells"))
story.append(bullet("<b>Clinical features:</b> Epigastric pain, nausea, vomiting, hypoalbuminaemia (protein loss), peripheral oedema, weight loss, anaemia"))
story.append(bullet("<b>Investigations:</b> Endoscopy (giant rugae in fundus/body, sparing antrum); deep mucosal biopsy (essential); serum albumin ↓; faecal α1-antitrypsin ↑"))
story.append(bullet("<b>Treatment:</b> High-protein diet; Cetuximab (anti-EGFR monoclonal antibody); H. pylori eradication if positive; total gastrectomy for severe cases or malignant transformation"))
story.append(bullet("<b>Complication:</b> Malignant transformation to gastric adenocarcinoma (2-10%)"))
story.append(sp(0.15))

# (b) Duct Ectasia
story.append(sub_banner("b", "Duct Ectasia of Breast"))
story.append(sp(0.12))
story.append(b("<b>Definition:</b> Dilatation and shortening of the major lactiferous ducts in the subareolar region with periductal inflammation and fibrosis."))
story.append(bullet("<b>Pathogenesis:</b> Stagnation of duct secretions → chemical irritation → periductal inflammation (periductal mastitis) → fibrosis → duct shortening"))
story.append(bullet("<b>Clinical features:</b> Greenish/multicoloured nipple discharge (bilateral), nipple retraction (slit-like, transverse – differentiates from malignancy which is central retraction), periareolar inflammation, palpable thickened ducts, palpable mass"))
story.append(bullet("<b>Age:</b> Usually peri/postmenopausal women"))
story.append(bullet("<b>Investigations:</b> Mammogram (dilated ducts, calcifications); ductoscopy; biopsy if discrete mass"))
story.append(bullet("<b>Treatment:</b> Conservative if asymptomatic; Hadfield's operation (total duct excision / Adair-Patey) for persistent discharge or retraction; antibiotics for acute periductal mastitis"))
story.append(info_box("Duct ectasia vs malignancy: Duct ectasia → slit-like transverse nipple retraction, multicoloured discharge. Malignancy → central deep retraction, blood-stained discharge."))
story.append(sp(0.15))

# (c) Meckel's Diverticulum
story.append(sub_banner("c", "Meckel's Diverticulum"))
story.append(sp(0.12))
story.append(b("<b>Definition:</b> The most common congenital anomaly of the GI tract; remnant of the vitello-intestinal (omphalomesenteric) duct that normally obliterates by week 7 of gestation."))
story.append(info_box("Rule of 2's: 2% of population | 2 feet from ileocecal valve | 2 inches long | 2:1 male:female ratio | 2 types of ectopic mucosa | Presents in first 2 years of life"))
story.append(bullet("<b>Ectopic tissue:</b> Gastric mucosa (most common, 50%); pancreatic, colonic or duodenal mucosa"))
story.append(bullet("<b>Complications:</b>"))
story.append(subbullet("Haemorrhage (most common in children): due to gastric mucosa secreting acid → ileal ulceration"))
story.append(subbullet("Intestinal obstruction (most common in adults): volvulus, intussusception (apex acts as lead point), littre's hernia"))
story.append(subbullet("Meckel's diverticulitis: mimics acute appendicitis; pain in umbilical/right iliac fossa"))
story.append(subbullet("Perforation; Littre's hernia (Meckel's in hernia sac)"))
story.append(bullet("<b>Investigation:</b> Technetium-99m pertechnetate scan (<b>Meckel's scan</b>) – identifies ectopic gastric mucosa (sensitivity 85% in children); CT abdomen; capsule endoscopy"))
story.append(bullet("<b>Treatment:</b> Symptomatic Meckel's → Meckel's diverticulectomy or segmental small bowel resection (if base >1/3 bowel diameter, or mesodiverticular band present)"))
story.append(sp(0.15))

# (d) Marjolin's Ulcer
story.append(sub_banner("d", "Marjolin Ulcer"))
story.append(sp(0.12))
story.append(b("<b>Definition:</b> Malignant transformation (usually squamous cell carcinoma) arising in a pre-existing chronic scar, ulcer, or wound. Named after French surgeon Jean-Nicolas Marjolin (1828)."))
story.append(bullet("<b>Common precursors:</b> Burn scars (most common), venous ulcers, osteomyelitis sinuses, radiation scars, pressure sores, lupus vulgaris, fistula tracts"))
story.append(bullet("<b>Latency period:</b> Average 30-35 years after initial injury (range: months to >50 years); longer in burn scars"))
story.append(bullet("<b>Features of the ulcer:</b> Everted, indurated, irregular edge; base of granulation tissue; painless (due to destroyed nerve endings in scar); no regional lymphadenopathy (due to blocked lymphatics in scar tissue)"))
story.append(bullet("<b>Pathogenesis:</b> Chronic inflammation → DNA mutation → epithelial dysplasia → SCC. Absence of immune surveillance in avascular scar tissue."))
story.append(bullet("<b>Investigations:</b> Biopsy (wedge biopsy from edge); CT for lymph node involvement; PET-CT for staging"))
story.append(bullet("<b>Treatment:</b> Wide local excision with 2-3 cm margins; sentinel lymph node biopsy; reconstruction with skin graft/flap; radiotherapy for unresectable cases"))
story.append(info_box("Marjolin's ulcer: SCC in chronic scar. Painless (scar = no nerves). No early lymph node spread (lymphatics blocked). Biopsy the edge. Wide excision is treatment."))
story.append(sp(0.15))

# (e) Phylloides Tumour
story.append(sub_banner("e", "Phylloides Tumour (Cystosarcoma Phylloides)"))
story.append(sp(0.12))
story.append(b("<b>Definition:</b> A fibroepithelial tumour of the breast arising from periductal stroma with leaf-like architecture. It accounts for <1% of all breast tumours. Age: typically 40-50 years (older than fibroadenoma)."))
story.append(bullet("<b>Classification:</b> Benign (60-70%), Borderline (15%), Malignant (10-25%) – based on stromal cellularity, mitoses/HPF, atypia, infiltrative margins"))
story.append(bullet("<b>Clinical features:</b> Large, rapidly growing breast mass; skin stretched, prominent veins; rarely fixation; skin rarely ulcerated"))
story.append(bullet("<b>Radiology:</b> Ultrasound: large lobulated hypoechoic mass with cystic spaces; Mammogram: dense lobulated opacity; MRI for extent assessment"))
story.append(bullet("<b>Diagnosis:</b> Core needle biopsy (FNAC inadequate – misses stromal component)"))

pf_data = [
    ["Feature", "Phylloides", "Fibroadenoma"],
    ["Age", "40-50 years", "15-35 years"],
    ["Growth", "Rapid", "Slow"],
    ["Size", "Often >3 cm", "Usually <3 cm"],
    ["Stroma", "Hypercellular, overgrown", "Normal pericanalicular"],
    ["Recurrence", "Yes (20-30%)", "Rare"],
    ["Malignancy", "10-25% malignant potential", "Almost never"],
]
pt = Table([[Paragraph(d[0], S_TABLE_HDR if i==0 else S_TABLE_CELL),
             Paragraph(d[1], S_TABLE_HDR if i==0 else S_TABLE_CELL),
             Paragraph(d[2], S_TABLE_HDR if i==0 else S_TABLE_CELL)]
            for i, d in enumerate(pf_data)],
           colWidths=[4*cm, 6.5*cm, 6.7*cm])
pt.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), C_DARK_BLUE),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, C_LIGHT_GREY]),
    ('GRID', (0,0), (-1,-1), 0.5, colors.HexColor('#b0c4de')),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
    ('LEFTPADDING', (0,0), (-1,-1), 5),
    ('RIGHTPADDING', (0,0), (-1,-1), 5),
    ('TOPPADDING', (0,0), (-1,-1), 4),
    ('BOTTOMPADDING', (0,0), (-1,-1), 4),
]))
story.append(pt)
story.append(bullet("<b>Treatment:</b> Wide local excision with 1-2 cm clear margins for benign/borderline; mastectomy for large/malignant tumours. Axillary dissection NOT routine (rare nodal spread; metastasis is haematogenous to lungs)."))
story.append(PageBreak())

# ────────────────────────────────────────────────────────────────────────────
# Q6 – MONITORING UNDER GA  [6 marks]
# ────────────────────────────────────────────────────────────────────────────
story.append(q_banner(6, "Methods of Monitoring Patient Under General Anaesthesia", "6 Marks"))
story.append(sp())
story.append(b("Patient monitoring during general anaesthesia aims to detect early physiological derangements. The ASA (American Society of Anesthesiologists) mandates <b>basic standards</b> of intraoperative monitoring."))
story.append(sp(0.1))

mon_data = [
    ["Parameter", "Method / Device", "Normal Values / Significance"],
    ["Oxygenation", "Pulse oximetry (SpO2)\nInspired O2 analyser", "SpO2 ≥ 95%; FiO2 ≥ 21%. Detects hypoxia before cyanosis visible"],
    ["Ventilation", "Capnography (EtCO2)\nRespiratory rate\nTidal volume", "EtCO2: 35-45 mmHg. Confirms ETT placement; detects bronchospasm, PE, air embolism"],
    ["Circulation", "ECG (continuous)\nNon-invasive BP (NIBP)\nInvasive arterial line (IBP)", "HR 60-100/min; SBP >90; IBP for major surgery, beat-to-beat monitoring"],
    ["Temperature", "Nasopharyngeal / rectal probe\nOesophageal probe", "Core temp 36.5-37.5°C; prevent hypothermia → coagulopathy, shivering"],
    ["Neuromuscular", "Train-of-Four (TOF) monitor\nTwitch monitor on ulnar nerve", "Assess depth of NMJ blockade; guide reversal of muscle relaxants"],
    ["Depth of Anaesthesia", "BIS (Bispectral Index)\nEntropy monitoring\nMAC (for volatile agents)", "BIS 40-60 = adequate depth; prevents awareness under anaesthesia"],
    ["Fluid Status / Output", "Urinary catheter (UO)\nCVP (central venous pressure)", "UO ≥ 0.5 mL/kg/h; CVP 5-12 cmH2O; assess euvolaemia"],
    ["Blood Gas / Labs", "ABG (arterial blood gas)\nPOCT (near-patient testing)", "PaO2, PaCO2, pH, lactate, Hb; guide ventilation and resuscitation"],
]
mt = Table([[Paragraph(d[0], S_TABLE_HDR if i==0 else S_TABLE_CELL),
             Paragraph(d[1], S_TABLE_HDR if i==0 else S_TABLE_CELL),
             Paragraph(d[2], S_TABLE_HDR if i==0 else S_TABLE_CELL)]
            for i, d in enumerate(mon_data)],
           colWidths=[3.5*cm, 6.2*cm, 7.5*cm])
mt.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), C_DARK_BLUE),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, C_LIGHT_GREY]),
    ('GRID', (0,0), (-1,-1), 0.5, colors.HexColor('#b0c4de')),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
    ('FONTSIZE', (0,1), (-1,-1), 8.5),
    ('LEFTPADDING', (0,0), (-1,-1), 5),
    ('RIGHTPADDING', (0,0), (-1,-1), 5),
    ('TOPPADDING', (0,0), (-1,-1), 4),
    ('BOTTOMPADDING', (0,0), (-1,-1), 4),
]))
story.append(mt)
story.append(sp(0.15))
story.append(info_box("<b>ASA Basic Monitoring Standards:</b> (1) Qualified anaesthesia provider present. (2) Continuous ECG. (3) Pulse oximetry. (4) NIBP q5min. (5) Capnography for intubated patients. All are mandatory."))
story.append(PageBreak())

# ────────────────────────────────────────────────────────────────────────────
# Q7 – SHORT NOTES  [2+3=5]
# ────────────────────────────────────────────────────────────────────────────
story.append(q_banner(7, "Short Notes – Breast", "2 + 3 = 5 Marks"))
story.append(sp())

# (a) Lymphatic drainage
story.append(sub_banner("a", "Lymphatic Drainage of Breast  [2 Marks]"))
story.append(sp(0.12))
story.append(b("The lymphatics of the breast drain in multiple directions. Knowledge is critical for understanding breast cancer spread and axillary dissection."))
story.append(bullet("<b>Axillary nodes (75-80%):</b> Main drainage route. Pectoral (anterior) → Central → Apical (Rotter's between pectorals). Divided into:"))
story.append(subbullet("Level I: Lateral to pectoralis minor"))
story.append(subbullet("Level II: Behind pectoralis minor (includes Rotter's interpectoral nodes)"))
story.append(subbullet("Level III (Infraclavicular): Medial to pectoralis minor – highest axillary level"))
story.append(bullet("<b>Internal mammary nodes (20-25%):</b> Medial breast drains → parasternal nodes along internal mammary artery (levels 1-3 intercostal spaces). Clinically significant for inner quadrant tumours."))
story.append(bullet("<b>Supraclavicular nodes:</b> Tertiary drainage from apical axillary nodes; involvement = N3 disease (Stage IIIC)"))
story.append(bullet("<b>Cross-drainage:</b> Small amount crosses midline to contralateral nodes"))
story.append(sp(0.15))

# (b) TNM staging
story.append(sub_banner("b", "TNM Staging of Breast Cancer  [3 Marks]"))
story.append(sp(0.12))
tnm_t = [
    ["T Stage", "Description"],
    ["Tx / T0", "Primary tumour cannot be assessed / No evidence of primary"],
    ["Tis", "Carcinoma in situ (DCIS, LCIS, Paget's without tumour)"],
    ["T1", "Tumour ≤20 mm (T1a ≤5mm, T1b 5-10mm, T1c 10-20mm)"],
    ["T2", "Tumour >20 mm but ≤50 mm"],
    ["T3", "Tumour >50 mm"],
    ["T4", "Any size with direct extension to chest wall (T4a), skin (T4b), both (T4c), inflammatory carcinoma (T4d)"],
]
tnm_n = [
    ["N Stage", "Description"],
    ["N0", "No regional lymph node metastasis"],
    ["N1", "1-3 axillary nodes (Level I/II), or internal mammary (IM) node (clinically occult)"],
    ["N2", "4-9 axillary nodes, or clinically detected IM nodes"],
    ["N3", "≥10 axillary nodes, or infraclavicular (Level III), or supra-clavicular nodes, or IM + axillary"],
]
tnm_m = [
    ["M Stage", "Description"],
    ["M0", "No distant metastasis"],
    ["M1", "Distant metastasis present (bone, liver, lung, brain)"],
]
for tbl_data in [tnm_t, tnm_n, tnm_m]:
    t = Table([[Paragraph(d[0], S_TABLE_HDR if i==0 else S_TABLE_CELL),
                Paragraph(d[1], S_TABLE_HDR if i==0 else S_TABLE_CELL)]
               for i, d in enumerate(tbl_data)],
              colWidths=[3.5*cm, 13.7*cm])
    t.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,0), C_MID_BLUE),
        ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, C_LIGHT_GREY]),
        ('GRID', (0,0), (-1,-1), 0.5, colors.HexColor('#b0c4de')),
        ('VALIGN', (0,0), (-1,-1), 'TOP'),
        ('LEFTPADDING', (0,0), (-1,-1), 6),
        ('RIGHTPADDING', (0,0), (-1,-1), 6),
        ('TOPPADDING', (0,0), (-1,-1), 3),
        ('BOTTOMPADDING', (0,0), (-1,-1), 3),
    ]))
    story.append(t)
    story.append(sp(0.1))

stage_data = [
    ["Clinical Stage", "TNM", "Notes"],
    ["Stage 0", "Tis N0 M0", "In situ disease"],
    ["Stage IA", "T1 N0 M0", "Excellent prognosis, 5YS ~99%"],
    ["Stage IB", "T0-1 N1mi M0", "Micrometastasis"],
    ["Stage IIA", "T0-2 N0-1 M0", "Localised"],
    ["Stage IIB", "T2-3 N0-1 M0", "Locally advanced"],
    ["Stage IIIA-C", "T any, N2-3, M0", "Locally advanced; neoadjuvant chemo considered"],
    ["Stage IV", "Any T, Any N, M1", "Metastatic; palliative intent"],
]
st = Table([[Paragraph(d[0], S_TABLE_HDR if i==0 else S_TABLE_CELL),
             Paragraph(d[1], S_TABLE_HDR if i==0 else S_TABLE_CELL),
             Paragraph(d[2], S_TABLE_HDR if i==0 else S_TABLE_CELL)]
            for i, d in enumerate(stage_data)],
           colWidths=[3.5*cm, 5*cm, 8.7*cm])
st.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), C_DARK_BLUE),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, C_LIGHT_GREY]),
    ('GRID', (0,0), (-1,-1), 0.5, colors.HexColor('#b0c4de')),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
    ('LEFTPADDING', (0,0), (-1,-1), 5),
    ('RIGHTPADDING', (0,0), (-1,-1), 5),
    ('TOPPADDING', (0,0), (-1,-1), 4),
    ('BOTTOMPADDING', (0,0), (-1,-1), 4),
]))
story.append(st)
story.append(PageBreak())

# ────────────────────────────────────────────────────────────────────────────
# Q8 – SUPRACONDYLAR FRACTURE HUMERUS  [5 marks]
# ────────────────────────────────────────────────────────────────────────────
story.append(q_banner(8, "Supracondylar Fracture of Humerus – Mechanism, Classification, Management & Complications", "5 Marks"))
story.append(sp())

story.append(section("Definition & Epidemiology"))
story.append(b("Supracondylar fracture of the humerus is a fracture occurring above the condyles of the humerus through the thin supracondylar region. It is the most common elbow fracture in children (60% of all paediatric elbow fractures), with peak incidence between 5-8 years. The thin cortex at the olecranon and coronoid fossae creates a weak point."))

story.append(section("Mechanism of Injury"))
story.append(bullet("<b>Extension type (97-98%):</b> Fall on outstretched hand (FOOSH) with elbow extended → hyperextension force → distal fragment displaced posteriorly"))
story.append(bullet("<b>Flexion type (2-3%):</b> Direct blow to posterior elbow or fall on flexed elbow → distal fragment displaced anteriorly"))

story.append(section("Classification – Gartland Classification (Extension Type)"))
gartland = [
    ["Type", "Description", "X-ray Finding", "Management"],
    ["Type I", "Undisplaced / minimal displacement", "Anterior humeral line through middle 1/3 of capitellum", "Collar & cuff / Backslab × 3 weeks"],
    ["Type II", "Displaced with posterior cortex intact", "ALH misses capitellum; posterior cortex hinged", "Closed reduction + above-elbow cast; K-wire if unstable"],
    ["Type III", "Completely displaced; no cortical contact", "Complete displacement; medial/lateral displacement", "Closed reduction + percutaneous K-wire fixation (CRPP) + cast"],
    ["Type IV\n(Wilkins)", "Multi-directional instability (360° rotational)", "Unstable in flexion AND extension", "CRPP or open reduction"],
]
gt = Table([[Paragraph(d[0], S_TABLE_HDR if i==0 else S_TABLE_CELL),
             Paragraph(d[1], S_TABLE_HDR if i==0 else S_TABLE_CELL),
             Paragraph(d[2], S_TABLE_HDR if i==0 else S_TABLE_CELL),
             Paragraph(d[3], S_TABLE_HDR if i==0 else S_TABLE_CELL)]
            for i, d in enumerate(gartland)],
           colWidths=[2*cm, 4*cm, 5*cm, 6.2*cm])
gt.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), C_DARK_BLUE),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, C_LIGHT_GREY]),
    ('GRID', (0,0), (-1,-1), 0.5, colors.HexColor('#b0c4de')),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
    ('FONTSIZE', (0,0), (-1,-1), 8.5),
    ('LEFTPADDING', (0,0), (-1,-1), 5),
    ('RIGHTPADDING', (0,0), (-1,-1), 5),
    ('TOPPADDING', (0,0), (-1,-1), 4),
    ('BOTTOMPADDING', (0,0), (-1,-1), 4),
]))
story.append(gt)
story.append(sp(0.15))

story.append(section("Management Flowchart"))
story.append(flow_box("SUSPECTED SUPRACONDYLAR FRACTURE\nX-Ray AP + Lateral → Anterior humeral line assessment", C_LIGHT_BLUE, C_MID_BLUE))
story.append(flow_arrow())
fc_sc = [
    ["<b>Type I</b>\nUndisplaced", "<b>Type II</b>\nPosterior cortex intact", "<b>Type III / IV</b>\nFully displaced"],
]
chart_sc = Table(fc_sc, colWidths=[5.5*cm, 5.5*cm, 6.2*cm])
chart_sc.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (0,0), C_DARK_GREEN),
    ('BACKGROUND', (1,0), (1,0), colors.HexColor('#e67e22')),
    ('BACKGROUND', (2,0), (2,0), colors.HexColor('#c0392b')),
    ('TEXTCOLOR', (0,0), (-1,-1), colors.white),
    ('FONTNAME', (0,0), (-1,-1), 'Helvetica-Bold'),
    ('FONTSIZE', (0,0), (-1,-1), 8.5),
    ('ALIGN', (0,0), (-1,-1), 'CENTER'),
    ('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
    ('TOPPADDING', (0,0), (-1,-1), 8),
    ('BOTTOMPADDING', (0,0), (-1,-1), 8),
    ('GRID', (0,0), (-1,-1), 1, colors.white),
]))
story.append(chart_sc)
story.append(flow_arrow())
fc_sc2 = [
    ["Collar & cuff\n3 weeks", "Closed Reduction\n+ AE cast or K-wires\nif unstable", "CRPP under GA\nDivergent K-wires\n+ AE cast 3-4 wks"],
]
chart_sc2 = Table(fc_sc2, colWidths=[5.5*cm, 5.5*cm, 6.2*cm])
chart_sc2.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (0,0), C_DARK_GREEN),
    ('BACKGROUND', (1,0), (1,0), colors.HexColor('#e67e22')),
    ('BACKGROUND', (2,0), (2,0), colors.HexColor('#c0392b')),
    ('TEXTCOLOR', (0,0), (-1,-1), colors.white),
    ('FONTSIZE', (0,0), (-1,-1), 8.5),
    ('ALIGN', (0,0), (-1,-1), 'CENTER'),
    ('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
    ('TOPPADDING', (0,0), (-1,-1), 8),
    ('BOTTOMPADDING', (0,0), (-1,-1), 8),
    ('GRID', (0,0), (-1,-1), 1, colors.white),
]))
story.append(chart_sc2)
story.append(Paragraph("Flowchart 4: Management of supracondylar fracture humerus (Gartland classification)", S_CAPTION))
story.append(sp(0.15))

story.append(section("Complications"))
comp_data = [
    ["Early", "Late"],
    ["Vascular injury: Brachial artery (5-10%) — white pulseless hand = surgical emergency", "Cubitus varus ('Gunstock deformity') — most common late complication; due to malunion in medial tilt"],
    ["Anterior interosseous nerve (AIN) palsy — most common nerve injury; weakness of FPL, FDP to index", "Volkmann's Ischaemic Contracture — compartment syndrome → forearm flexor fibrosis → finger contracture"],
    ["Radial nerve palsy, Median nerve palsy, Ulnar nerve injury", "Myositis ossificans — post-traumatic periarticular calcification; avoid aggressive physiotherapy"],
    ["Compartment syndrome of forearm", "Stiffness of elbow, avascular necrosis of capitellum (rare)"],
]
ct = Table([[Paragraph(d[0], S_TABLE_HDR if i==0 else S_TABLE_CELL),
             Paragraph(d[1], S_TABLE_HDR if i==0 else S_TABLE_CELL)]
            for i, d in enumerate(comp_data)],
           colWidths=[8.5*cm, 8.7*cm])
ct.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), C_ACCENT),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, C_LIGHT_GREY]),
    ('GRID', (0,0), (-1,-1), 0.5, colors.HexColor('#f0a0a0')),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
    ('FONTSIZE', (0,0), (-1,-1), 8.5),
    ('LEFTPADDING', (0,0), (-1,-1), 6),
    ('RIGHTPADDING', (0,0), (-1,-1), 6),
    ('TOPPADDING', (0,0), (-1,-1), 4),
    ('BOTTOMPADDING', (0,0), (-1,-1), 4),
]))
story.append(ct)
story.append(sp(0.1))
story.append(info_box("Surgical Emergency: White pulseless hand after supracondylar fracture → urgent reduction. If pulse does not return → explore brachial artery. 'Pink pulseless hand' → reduce + stabilize first; observe perfusion."))
story.append(PageBreak())

# ────────────────────────────────────────────────────────────────────────────
# Q9 – PRE-HOSPITAL CARE, TRIAGE  [5 marks]
# ────────────────────────────────────────────────────────────────────────────
story.append(q_banner(9, "Pre-Hospital Care & Casualty Management of Trauma Victim – Principles of Triage", "5 Marks"))
story.append(sp())

story.append(section("Pre-Hospital Care – Principles (ATLS Framework)"))
story.append(b("The <b>Advanced Trauma Life Support (ATLS)</b> protocol, developed by the American College of Surgeons, provides a systematic approach to trauma. The principle of 'Treat the greatest threat to life first' governs prehospital care."))
story.append(sp(0.1))

story.append(subsection("Primary Survey – ABCDE"))
story.append(flow_box("A – Airway with C-spine Control", colors.HexColor('#e8f5e9'), C_DARK_GREEN))
story.append(flow_arrow())
story.append(flow_box("B – Breathing and Ventilation (look/listen/feel; tension pneumothorax? → needle decompression)", colors.HexColor('#e3f2fd'), C_MID_BLUE))
story.append(flow_arrow())
story.append(flow_box("C – Circulation with Haemorrhage Control (IV access, fluid, tourniquet, direct pressure)", colors.HexColor('#fff8e1'), C_GOLD))
story.append(flow_arrow())
story.append(flow_box("D – Disability (GCS, pupils, glucose, focal neuro deficit)", colors.HexColor('#fce4ec'), C_ACCENT))
story.append(flow_arrow())
story.append(flow_box("E – Exposure & Environment Control (undress completely; prevent hypothermia)", colors.HexColor('#f3e5f5'), colors.purple))
story.append(Paragraph("Flowchart 5: ATLS Primary Survey – ABCDE sequence", S_CAPTION))
story.append(sp(0.15))

story.append(subsection("On-scene Pre-hospital Interventions"))
story.append(bullet("Secure scene safety; call emergency services; do not move patient until spine immobilised unless life-threatening"))
story.append(bullet("Haemorrhage control: Direct pressure, tourniquet (extremity bleeds), wound packing (junctional)"))
story.append(bullet("Airway: Manual manoeuvres (chin lift/jaw thrust); OPA/NPA; BVM ventilation; avoid neck manipulation"))
story.append(bullet("Cervical spine immobilisation: Hard collar + manual in-line stabilisation (MILS) until cleared"))
story.append(bullet("IV access: Two large-bore (16G) peripheral IVs en route; isotonic fluid (limited if penetrating trauma)"))
story.append(bullet("Monitoring: Pulse oximetry, ECG, NIBP, GCS tracking"))
story.append(bullet("'<b>Scoop and run</b>' vs '<b>Stay and play</b>': Penetrating trauma → rapid transport; blunt polytrauma → stabilise before transport"))
story.append(sp(0.15))

story.append(section("TRIAGE – Principles and Systems"))
story.append(b("<b>Definition:</b> Triage (French: 'to sort') is the process of rapidly sorting casualties to allocate limited medical resources most effectively. The goal is maximum benefit for the greatest number."))
story.append(sp(0.1))

story.append(subsection("START Triage System (Simple Triage and Rapid Treatment)"))
story.append(b("Assessment of: <b>R</b>espiration → <b>P</b>erfusion → <b>M</b>ental status (RPM)"))

triage_data = [
    ["Category", "Colour", "Status", "Action"],
    ["T1 – Immediate", "RED", "Life-threatening but salvageable; airway obstruction, uncontrolled bleed, tension pneumo", "Treat immediately; first priority"],
    ["T2 – Delayed", "YELLOW", "Serious but stable; can wait 30-60 min without threat to life; fractures, burns <20% BSA", "Treat within 1 hour"],
    ["T3 – Minor (Walking wounded)", "GREEN", "Minor injuries; can walk; no immediate threat", "Self-help; treat last"],
    ["T4 – Expectant", "BLACK", "Unsurvivable or moribund; profound shock + severe CNS injury; burns >80% BSA", "Comfort care only"],
    ["Dead", "BLACK (plain)", "Confirmed death", "Do not resuscitate"],
]
tr = Table([[Paragraph(d[0], S_TABLE_HDR if i==0 else S_TABLE_CELL),
             Paragraph(d[1], make_style('TrC'+str(i), fontSize=8.5,
                       textColor={'RED': C_ACCENT, 'YELLOW': colors.HexColor('#e67e22'),
                                  'GREEN': C_DARK_GREEN, 'BLACK (plain)': colors.black,
                                  'BLACK': colors.HexColor('#333333')}.get(d[1], colors.black),
                       fontName='Helvetica-Bold', alignment=TA_CENTER) if i>0 else S_TABLE_HDR),
             Paragraph(d[2], S_TABLE_HDR if i==0 else S_TABLE_CELL),
             Paragraph(d[3], S_TABLE_HDR if i==0 else S_TABLE_CELL)]
            for i, d in enumerate(triage_data)],
           colWidths=[3.5*cm, 2*cm, 7.5*cm, 4.2*cm])
tr.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), C_DARK_BLUE),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, C_LIGHT_GREY]),
    ('GRID', (0,0), (-1,-1), 0.5, colors.HexColor('#b0c4de')),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
    ('FONTSIZE', (0,0), (-1,-1), 8.5),
    ('LEFTPADDING', (0,0), (-1,-1), 5),
    ('RIGHTPADDING', (0,0), (-1,-1), 5),
    ('TOPPADDING', (0,0), (-1,-1), 4),
    ('BOTTOMPADDING', (0,0), (-1,-1), 4),
]))
story.append(tr)
story.append(sp(0.15))

story.append(subsection("Triage in MCI (Mass Casualty Incident) – SALT Triage"))
story.append(bullet("<b>S</b>ort → <b>A</b>ssess → <b>L</b>ifesaving interventions → <b>T</b>reatment/transport"))
story.append(bullet("Global sorting: Walk (T3) → Wave/purposeful movement (T2) → Still (T1/T4)"))
story.append(bullet("Lifesaving interventions on site: Airway open, 2 rescue breaths, haemorrhage control, auto-injector antidotes (CBRN)"))
story.append(sp(0.1))
story.append(info_box("<b>Golden Hour Principle:</b> Definitive surgical care within 60 minutes of injury dramatically reduces mortality from haemorrhagic shock and traumatic brain injury. Pre-hospital care must minimise on-scene time ('Load and Go' philosophy for penetrating trauma)."))
story.append(sp(0.15))

story.append(section("Casualty Management in Hospital – Overview"))
story.append(bullet("<b>Trauma team activation</b>: Led by trauma team leader; simultaneous evaluation"))
story.append(bullet("<b>Primary survey + Resuscitation</b> simultaneously"))
story.append(bullet("<b>Secondary survey</b>: Head-to-toe examination; AMPLE history (Allergies, Medications, Past hx, Last meal, Events)"))
story.append(bullet("<b>Tertiary survey</b>: 24h post-admission re-assessment; identifies missed injuries"))
story.append(bullet("<b>Damage Control Surgery (DCS)</b>: Abbreviated initial surgery to control haemorrhage/contamination → ICU resuscitation → definitive surgery 24-48h later"))
story.append(sp(0.15))
story.append(info_box("Lethal Triad of Trauma: Hypothermia + Acidosis + Coagulopathy → Each worsens the other → Death. Damage control resuscitation targets all three."))

# ─── FOOTER / REFERENCES ─────────────────────────────────────────────────────
story.append(PageBreak())
story.append(Paragraph("References & Sources", S_SECTION))
refs = [
    "Bailey & Love's Short Practice of Surgery, 28th Edition (2023)",
    "Schwartz's Principles of Surgery, 11th Edition",
    "Current Surgical Therapy, 14th Edition – Cameron",
    "Sabiston Textbook of Surgery, 21st Edition",
    "ATLS: Advanced Trauma Life Support, 10th Edition – American College of Surgeons",
    "Robbins & Cotran Pathologic Basis of Disease, 10th Edition",
    "Sleisenger & Fordtran's Gastrointestinal and Liver Disease, 11th Edition",
    "TNM Classification: AJCC Cancer Staging Manual, 8th Edition (2017)",
    "ASA Standards for Basic Anesthetic Monitoring – American Society of Anesthesiologists",
    "START Triage System – Loma Linda University Medical Center, 1983",
]
for ref in refs:
    story.append(bullet(ref))

# ─── BUILD PDF ────────────────────────────────────────────────────────────────
doc = SimpleDocTemplate(
    '/tmp/workspace/surgery-exam-pdf/Surgery_Exam_Answers.pdf',
    pagesize=A4,
    leftMargin=MARGIN, rightMargin=MARGIN,
    topMargin=MARGIN, bottomMargin=MARGIN + 0.5*cm,
    title="Surgery Exam – Comprehensive Model Answers",
    author="Orris Medical AI"
)

def add_page_numbers(canvas, doc):
    canvas.saveState()
    canvas.setFont('Helvetica', 8)
    canvas.setFillColor(colors.HexColor('#666666'))
    canvas.drawCentredString(PAGE_W/2, 1.0*cm, f"Surgery Exam Answers  |  Page {doc.page}")
    canvas.restoreState()

doc.build(story, onFirstPage=add_page_numbers, onLaterPages=add_page_numbers)
print("PDF generated successfully!")
Running Command

cd /tmp/workspace/surgery-exam-pdf && python generate_pdf.py 2>&1

Editing File

~/surgery-exam-pdf/generate_pdf.py

Successfully replaced 1 instance(s) of the string in '/tmp/workspace/surgery-exam-pdf/generate_pdf.py'
Running Command

cd /tmp/workspace/surgery-exam-pdf && python generate_pdf.py 2>&1

Running Command

ls -lh /tmp/workspace/surgery-exam-pdf/Surgery_Exam_Answers.pdf

Your comprehensive Surgery Exam Answer PDF is ready! Here's the download link:

Surgery Exam Answers

PDF Document · PDF


Here is a summary of what's included in the PDF:
Cover Page — Professional dark-blue surgical exam cover with book references.

Q2 (12 Marks) — Thyroid
  • Surgical anatomy: relationships table, blood supply (3-column colour diagram), RLN, EBSLN, lymphatics
  • Types of thyroiditis: 6-row colour table (Hashimoto, de Quervain, Riedel, Postpartum, Acute, Silent)
  • Hashimoto: pathogenesis, clinical features, investigations, full management flowchart with treatment branches
Q3 (20 Marks) — Short Notes (4 each)
  • Mondor's disease | Thyroglossal cyst (Sistrunk's op) | Wilkie's Syndrome | Gastrinomas/ZES (Passaro's triangle) | Hernia en glissade
Q4 (12 Marks) — Explain Why (4 each)
  • Duodenum in Whipple's: shared GDA vasculature, anatomical intimacy, ampulla, oncological clearance — with flowchart
  • Low malignancy in small intestine: RABBIT mnemonic (7 reasons)
  • Irreducible hernia: strangulation progression flowchart
Q5 (15 Marks) — Short Notes (3 each)
  • Menetrier's disease | Duct ectasia (Hadfield's op) | Meckel's diverticulum (Rule of 2's) | Marjolin's ulcer | Phylloides tumour — with comparison table vs fibroadenoma
Q6 (6 Marks) — GA Monitoring
  • Full 8-parameter table: Oxygenation, Ventilation, Circulation, Temperature, NMJ, Depth of Anaesthesia, Fluid status, Blood gas
Q7 (5 Marks) — Breast
  • Lymphatic drainage: axillary levels I/II/III, internal mammary, supraclavicular
  • TNM staging: full T/N/M tables + clinical stage grouping
Q8 (5 Marks) — Supracondylar Fracture
  • Gartland classification (Types I-IV), management flowchart, early/late complications table (Volkmann's, cubitus varus, AIN palsy, brachial artery injury)
Q9 (5 Marks) — Trauma & Triage
  • ATLS ABCDE flowchart, pre-hospital principles, START triage 4-colour system table, SALT triage, Golden Hour, lethal triad
References — 10 standard surgery books cited.
This is a shared conversation. Sign in to Orris to start your own chat.