Procedure:operative steps anatomy indications and complications and viva Head & Neck Surgery 1. Superficial Parotidectomy 2. Subtotal Thyroidectomy 3. Hemithyroidectomy 4. Total Thyroidectomy 5. Thyroglossal Cyst Excision (Sistrunk Operation) 6. Neck Dissection (Modified Radical Neck Dissection) 7. Tracheostomy With images AND FLOW CHARTS

Reading File
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Finding Sources
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Here's a summary of what's covered in this complete guide:

What's Included

All 7 procedures are covered with full exam-level depth, sourced from Bailey & Love (28th ed.), Sabiston, Scott-Brown's Otorhinolaryngology, and Mulholland & Greenfield's Surgery:
ProcedureAnatomyIndicationsStepsComplicationsViva Q&A
1. Superficial Parotidectomy5 Q&A
2. Subtotal Thyroidectomy✓ (11 steps)6 Q&A
3. Hemithyroidectomy2 Q&A
4. Total Thyroidectomy2 Q&A
5. Sistrunk Operation✓ (embryology)✓ (7 steps)5 Q&A
6. Modified Radical Neck Dissection✓ (node levels)✓ (9 steps)6 Q&A
7. Tracheostomy✓ (open + PDT)6 Q&A
Key extras included:
  • Robbins cervical node level classification with drainage patterns
  • Thyroidectomy nomenclature comparison (subtotal vs near-total vs total)
  • Parotidectomy types (extracapsular → radical)
  • Decision algorithm flowchart across all 7 procedures
  • High-yield "Key Nerve / Key Step / Classic Complication" summary table

I cants see

Reading File
Running Command

ls /home/daytona/workspace/ 2>/dev/null || mkdir -p /home/daytona/workspace

Running Command

mkdir -p /home/daytona/workspace/head-neck-surgery && python3 -c "from reportlab.lib import colors; print('reportlab ok')"

Writing File

~/head-neck-surgery/generate_pdf.py


from reportlab.lib.pagesizes import A4
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm
from reportlab.lib import colors
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, PageBreak, KeepTogether
)
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus.flowables import HRFlowable

OUTPUT = "/home/daytona/workspace/head-neck-surgery/Head_Neck_Surgery.pdf"

doc = SimpleDocTemplate(
    OUTPUT,
    pagesize=A4,
    rightMargin=1.8*cm,
    leftMargin=1.8*cm,
    topMargin=2*cm,
    bottomMargin=2*cm,
)

W = A4[0] - 3.6*cm  # usable width

# ── Colour palette ──────────────────────────────────────────────────────────
NAVY   = colors.HexColor("#1a2f5a")
TEAL   = colors.HexColor("#0077b6")
LTBLUE = colors.HexColor("#e8f4fd")
ORANGE = colors.HexColor("#e85d04")
GREEN  = colors.HexColor("#1b7a4a")
RED    = colors.HexColor("#c0392b")
LTYELLOW = colors.HexColor("#fffde7")
LTGREEN  = colors.HexColor("#e8f5e9")
LTRED    = colors.HexColor("#fdecea")
GREY   = colors.HexColor("#f5f5f5")
DKGREY = colors.HexColor("#424242")

# ── Styles ───────────────────────────────────────────────────────────────────
base = getSampleStyleSheet()

def S(name, parent="Normal", **kw):
    return ParagraphStyle(name, parent=base[parent], **kw)

cover_title  = S("CoverTitle",  fontSize=28, textColor=colors.white,
                 alignment=TA_CENTER, fontName="Helvetica-Bold", leading=34)
cover_sub    = S("CoverSub",    fontSize=14, textColor=colors.HexColor("#cce8ff"),
                 alignment=TA_CENTER, fontName="Helvetica", leading=18)
proc_title   = S("ProcTitle",   fontSize=18, textColor=colors.white,
                 fontName="Helvetica-Bold", alignment=TA_CENTER, leading=24)
sec_head     = S("SecHead",     fontSize=13, textColor=NAVY,
                 fontName="Helvetica-Bold", spaceBefore=10, spaceAfter=4, leading=16)
sub_head     = S("SubHead",     fontSize=11, textColor=TEAL,
                 fontName="Helvetica-Bold", spaceBefore=6, spaceAfter=3)
body         = S("Body",        fontSize=9.5, leading=13, spaceAfter=4,
                 fontName="Helvetica", textColor=DKGREY)
mono         = S("Mono",        fontSize=8.5, fontName="Courier",
                 leading=12, spaceAfter=2, textColor=colors.HexColor("#1a1a2e"))
bullet_s     = S("BulletS",     fontSize=9.5, leading=13, leftIndent=14,
                 bulletIndent=4, fontName="Helvetica", textColor=DKGREY)
viva_q       = S("VivaQ",       fontSize=9.5, textColor=NAVY,
                 fontName="Helvetica-Bold", leading=13, spaceBefore=5)
viva_a       = S("VivaA",       fontSize=9.5, textColor=DKGREY,
                 fontName="Helvetica", leading=13, leftIndent=10, spaceAfter=5)
step_title   = S("StepTitle",   fontSize=9.5, textColor=GREEN,
                 fontName="Helvetica-Bold", leading=13)
warn_txt     = S("WarnTxt",     fontSize=9.5, textColor=RED,
                 fontName="Helvetica-Bold", leading=13)
caption      = S("Caption",     fontSize=8, textColor=colors.grey,
                 fontName="Helvetica-Oblique", leading=10, alignment=TA_CENTER)
toc_item     = S("TOCItem",     fontSize=11, leading=16, leftIndent=6,
                 fontName="Helvetica", textColor=NAVY)

story = []

# ════════════════════════════════════════════════════════════════════════════
# COVER PAGE
# ════════════════════════════════════════════════════════════════════════════
cover_table = Table(
    [[Paragraph("HEAD & NECK SURGERY", cover_title)],
     [Spacer(1, 0.3*cm)],
     [Paragraph("Complete Operative Guide", cover_sub)],
     [Spacer(1, 0.2*cm)],
     [Paragraph("Procedure · Anatomy · Indications · Operative Steps · Complications · Viva Q&A", cover_sub)],
     [Spacer(1, 0.5*cm)],
     [Paragraph("1. Superficial Parotidectomy", cover_sub)],
     [Paragraph("2. Subtotal Thyroidectomy", cover_sub)],
     [Paragraph("3. Hemithyroidectomy", cover_sub)],
     [Paragraph("4. Total Thyroidectomy", cover_sub)],
     [Paragraph("5. Thyroglossal Cyst Excision (Sistrunk Operation)", cover_sub)],
     [Paragraph("6. Modified Radical Neck Dissection", cover_sub)],
     [Paragraph("7. Tracheostomy", cover_sub)],
     [Spacer(1, 0.8*cm)],
     [Paragraph("Sources: Bailey & Love · Sabiston · Scott-Brown's · Mulholland & Greenfield", caption)],
    ],
    colWidths=[W]
)
cover_table.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,-1), NAVY),
    ("TOPPADDING",    (0,0), (-1,-1), 6),
    ("BOTTOMPADDING", (0,0), (-1,-1), 6),
    ("LEFTPADDING",   (0,0), (-1,-1), 20),
    ("RIGHTPADDING",  (0,0), (-1,-1), 20),
    ("ROUNDEDCORNERS", [8]),
]))
story.append(Spacer(1, 1.5*cm))
story.append(cover_table)
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# HELPERS
# ════════════════════════════════════════════════════════════════════════════
def proc_header(num, title, color=NAVY):
    t = Table(
        [[Paragraph(f"{num}.  {title}", proc_title)]],
        colWidths=[W]
    )
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), color),
        ("TOPPADDING",    (0,0), (-1,-1), 10),
        ("BOTTOMPADDING", (0,0), (-1,-1), 10),
        ("LEFTPADDING",   (0,0), (-1,-1), 12),
        ("ROUNDEDCORNERS", [6]),
    ]))
    return t

def section(txt):
    return Paragraph(txt, sec_head)

def subhead(txt):
    return Paragraph(txt, sub_head)

def p(txt):
    return Paragraph(txt, body)

def bp(txt):
    return Paragraph(f"• {txt}", bullet_s)

def hr():
    return HRFlowable(width="100%", thickness=0.5, color=colors.lightgrey, spaceAfter=4)

def box(rows, col_widths, bg=LTBLUE, header_bg=TEAL, header_color=colors.white):
    """Generic styled table."""
    t = Table(rows, colWidths=col_widths, repeatRows=1)
    style = [
        ("BACKGROUND",    (0,0), (-1,0),  header_bg),
        ("TEXTCOLOR",     (0,0), (-1,0),  header_color),
        ("FONTNAME",      (0,0), (-1,0),  "Helvetica-Bold"),
        ("FONTSIZE",      (0,0), (-1,-1), 9),
        ("ROWBACKGROUNDS",(0,1), (-1,-1), [colors.white, GREY]),
        ("GRID",          (0,0), (-1,-1), 0.4, colors.HexColor("#cccccc")),
        ("TOPPADDING",    (0,0), (-1,-1), 5),
        ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING",   (0,0), (-1,-1), 7),
        ("VALIGN",        (0,0), (-1,-1), "TOP"),
    ]
    t.setStyle(TableStyle(style))
    return t

def steps_table(steps):
    """Numbered operative steps."""
    rows = [["Step", "Action", "Key Points"]]
    for s in steps:
        rows.append(s)
    t = Table(rows, colWidths=[1.2*cm, 5.5*cm, W - 6.7*cm], repeatRows=1)
    t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,0),  GREEN),
        ("TEXTCOLOR",     (0,0), (-1,0),  colors.white),
        ("FONTNAME",      (0,0), (-1,0),  "Helvetica-Bold"),
        ("FONTSIZE",      (0,0), (-1,-1), 8.5),
        ("ROWBACKGROUNDS",(0,1), (-1,-1), [LTGREEN, colors.white]),
        ("GRID",          (0,0), (-1,-1), 0.4, colors.HexColor("#aaaaaa")),
        ("TOPPADDING",    (0,0), (-1,-1), 5),
        ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING",   (0,0), (-1,-1), 6),
        ("VALIGN",        (0,0), (-1,-1), "TOP"),
        ("SPAN",          (0,0), (0,0)),
    ]))
    return t

def comps_table(rows_data):
    rows = [["Timing", "Complication", "Notes"]]
    for r in rows_data:
        rows.append(r)
    t = Table(rows, colWidths=[2.5*cm, 5*cm, W - 7.5*cm], repeatRows=1)
    t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,0),  RED),
        ("TEXTCOLOR",     (0,0), (-1,0),  colors.white),
        ("FONTNAME",      (0,0), (-1,0),  "Helvetica-Bold"),
        ("FONTSIZE",      (0,0), (-1,-1), 8.5),
        ("ROWBACKGROUNDS",(0,1), (-1,-1), [LTRED, colors.white]),
        ("GRID",          (0,0), (-1,-1), 0.4, colors.HexColor("#aaaaaa")),
        ("TOPPADDING",    (0,0), (-1,-1), 5),
        ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING",   (0,0), (-1,-1), 6),
        ("VALIGN",        (0,0), (-1,-1), "TOP"),
    ]))
    return t

def viva(q, a):
    return KeepTogether([
        Paragraph(f"Q: {q}", viva_q),
        Paragraph(f"A: {a}", viva_a),
    ])

def anatomy_box(lines):
    content = "<br/>".join(lines)
    t = Table([[Paragraph(content, mono)]], colWidths=[W])
    t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,-1), LTBLUE),
        ("LEFTPADDING",   (0,0), (-1,-1), 10),
        ("RIGHTPADDING",  (0,0), (-1,-1), 10),
        ("TOPPADDING",    (0,0), (-1,-1), 8),
        ("BOTTOMPADDING", (0,0), (-1,-1), 8),
        ("BOX",           (0,0), (-1,-1), 1, TEAL),
        ("ROUNDEDCORNERS",[4]),
    ]))
    return t

def flowchart_box(lines, bg=LTYELLOW, border=ORANGE):
    content = "<br/>".join(lines)
    t = Table([[Paragraph(content, mono)]], colWidths=[W])
    t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,-1), bg),
        ("LEFTPADDING",   (0,0), (-1,-1), 10),
        ("RIGHTPADDING",  (0,0), (-1,-1), 10),
        ("TOPPADDING",    (0,0), (-1,-1), 8),
        ("BOTTOMPADDING", (0,0), (-1,-1), 8),
        ("BOX",           (0,0), (-1,-1), 1.5, border),
        ("ROUNDEDCORNERS",[4]),
    ]))
    return t

def warn_box(lines, bg=LTRED, border=RED):
    content = "<br/>".join(lines)
    t = Table([[Paragraph(content, body)]], colWidths=[W])
    t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,-1), bg),
        ("LEFTPADDING",   (0,0), (-1,-1), 10),
        ("TOPPADDING",    (0,0), (-1,-1), 8),
        ("BOTTOMPADDING", (0,0), (-1,-1), 8),
        ("BOX",           (0,0), (-1,-1), 1.5, border),
    ]))
    return t

SP = lambda n=0.3: Spacer(1, n*cm)


# ════════════════════════════════════════════════════════════════════════════
# 1. SUPERFICIAL PAROTIDECTOMY
# ════════════════════════════════════════════════════════════════════════════
story.append(proc_header("1", "SUPERFICIAL PAROTIDECTOMY", NAVY))
story.append(SP())

story.append(section("ANATOMY"))
story.append(anatomy_box([
    "PAROTID GLAND",
    "  Weight ~25 g  |  Purely serous secretion  |  Stensen's duct opens at upper 2nd molar",
    "",
    "  FACIAL NERVE divides gland into:",
    "    Superficial lobe (~80%)  ←  lateral to facial nerve plane (Patey's faciovenous plane)",
    "    Deep lobe (~20%)         ←  medial to facial nerve plane",
    "",
    "  BOUNDARIES:  Superior = zygomatic arch  |  Inferior = mastoid + post. belly digastric",
    "               Anterior = masseter + buccinator  |  Posterior = SCM + mastoid",
    "",
    "  FACIAL NERVE LANDMARKS (Antegrade technique):",
    "    1. Tragal (Conley's) pointer  →  FN lies 1 cm DEEP & INFERIOR to tip",
    "    2. Tympanomastoid suture       →  FN exits INFERIOR to this suture",
    "    3. Posterior belly of digastric →  FN identified ABOVE its upper border",
    "    4. Stylomastoid foramen         →  FN exits here",
    "",
    "  OTHER NERVES:  Greater Auricular N (C2/C3) - sensory, on SCM  |  Auriculotemporal N (V3)",
]))
story.append(SP())

story.append(section("INDICATIONS"))
story.append(box(
    [["Benign", "Malignant"],
     ["Pleomorphic adenoma (70% of all parotid tumours)", "Mucoepidermoid carcinoma"],
     ["Warthin's tumour (bilateral in 10%)", "Adenoid cystic carcinoma"],
     ["Monomorphic adenoma", "Acinic cell carcinoma"],
     ["Chronic/recurrent parotitis", "Carcinoma ex pleomorphic adenoma"],
     ["Parotid abscess (unresponsive)", "Primary squamous cell carcinoma"],
    ],
    [W/2, W/2]
))
story.append(SP(0.3))
story.append(p("<b>Types of parotidectomy (conservative → radical):</b> Extracapsular dissection → Adequate parotidectomy → <b>Superficial parotidectomy</b> → Total conservative parotidectomy → Radical parotidectomy"))
story.append(SP())

story.append(section("OPERATIVE STEPS"))
story.append(steps_table([
    ["1", "Positioning", "GA (NO long-acting paralysis - need FN monitoring). Reverse Trendelenburg. Head turned contralateral."],
    ["2", "Incision", "Modified Blair (lazy-S): pre-auricular → below ear lobe → neck crease. OR facelift incision (better cosmesis). Infiltrate 1:100,000 adrenaline."],
    ["3", "Skin flap elevation", "Raise subplatysmal flap containing subcutaneous tissue + SMAS. Do NOT go onto masseteric fascia (risk FN branches)."],
    ["4", "Parotid mobilisation", "Dissect SCM-parotid fascial plane. Identify + preserve posterior branch of Greater Auricular N. Mobilise off SCM, mastoid tip, tragal cartilage. Identify tympanomastoid suture."],
    ["5", "Facial nerve ID", "ANTEGRADE: Find trunk using landmarks (tragal pointer → 1 cm deep & inferior). Use nerve stimulator. Never cut unidentified structures in this area."],
    ["6", "FN dissection", "Split gland along FN plane using fine mosquito forceps PARALLEL to nerve. Dissect trunk → divisions → branches. Superficial lobe lifted off nerve."],
    ["7", "Gland removal", "Remove superficial lobe lateral to FN. Ligate Stensen's duct."],
    ["8", "Closure", "Haemostasis. Suction drain. Platysma closure. Skin closure."],
]))
story.append(SP())

story.append(section("COMPLICATIONS"))
story.append(comps_table([
    ["Immediate", "Haemorrhage / haematoma", "Return to theatre"],
    ["Immediate", "Facial nerve injury", "Temporary neuropraxia most common; permanent <1%"],
    ["Early", "Wound infection / salivary fistula", "Antibiotics; pressure dressing"],
    ["Late", "FREY'S SYNDROME", "Gustatory sweating - aberrant reinnervation of sweat glands by parasympathetic fibres. Incidence up to 40%. Dx: Minor's starch-iodine test. Rx: Botulinum toxin or tympanic neurectomy."],
    ["Late", "Permanent facial palsy", "<1% with careful technique"],
    ["Late", "Numbness (Greater Auricular N)", "Ear lobe numbness expected; posterior branch preservation reduces extent"],
    ["Late", "Tumour recurrence", "High risk if pleomorphic adenoma capsule ruptured (satellite nodules)"],
]))
story.append(SP())

story.append(section("VIVA QUESTIONS"))
story.append(viva("What is the most important structure during parotidectomy?",
    "The facial nerve (CN VII). It exits the stylomastoid foramen and divides into upper temporofacial and lower cervicofacial divisions within the gland. Damage causes facial palsy."))
story.append(viva("What is Frey's syndrome?",
    "Gustatory sweating after parotidectomy. Parasympathetic secretomotor fibres (CN IX via auriculotemporal nerve) aberrantly reinnervate sweat glands in the skin flap. Incidence up to 40%. Diagnosed with Minor's starch-iodine test. Treated with botulinum toxin injection."))
story.append(viva("Why must the patient NOT be paralysed?",
    "To allow intraoperative facial nerve monitoring - touching the nerve causes visible facial muscle twitch, alerting the surgeon."))
story.append(viva("What is Patey's faciovenous plane?",
    "A surgical plane defined by the retromandibular vein, which lies just deep to the facial nerve and acts as a marker for safe dissection."))
story.append(viva("What is the risk of recurrence if pleomorphic adenoma capsule is breached?",
    "Capsule rupture leads to satellite tumour deposits and high recurrence rates - up to 40% if spilled. This is the main reason formal parotidectomy is preferred over enucleation."))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# 2-4. THYROIDECTOMY (combined anatomy, then separate indications)
# ════════════════════════════════════════════════════════════════════════════
story.append(proc_header("2-4", "THYROIDECTOMY (Subtotal / Hemi / Total)", TEAL))
story.append(SP())

story.append(section("ANATOMY"))
story.append(anatomy_box([
    "THYROID GLAND:  Butterfly-shaped, ~20-25 g.  Right lobe + Left lobe (each 4x2x2 cm) + Isthmus",
    "  Isthmus overlies 2nd-4th tracheal rings.  Pyramidal lobe present in ~80% (cephalad from isthmus).",
    "",
    "  BLOOD SUPPLY:",
    "    Superior thyroid artery  ←  External carotid artery (1st branch)",
    "    Inferior thyroid artery  ←  Thyrocervical trunk  ←  Subclavian artery",
    "    Thyroidea ima artery (10%)  ←  Aortic arch / brachiocephalic  [MIDLINE - danger!]",
    "",
    "  VENOUS DRAINAGE:",
    "    Superior thyroid vein   →  Internal jugular vein",
    "    Middle thyroid vein     →  Internal jugular vein  [ligated first during mobilisation]",
    "    Inferior thyroid veins  →  Brachiocephalic vein",
    "",
    "  CRITICAL NERVE RELATIONS:",
    "    RECURRENT LARYNGEAL NERVE (RLN):",
    "      Runs in tracheoesophageal groove.  MOST VULNERABLE at Berry's ligament.",
    "      Right RLN loops around subclavian artery.",
    "      Left RLN loops around aortic arch (longer course).",
    "      Supplies ALL intrinsic laryngeal muscles EXCEPT cricothyroid.",
    "      Non-recurrent RLN (0.5-1%) - RIGHT side only - anomalous subclavian artery.",
    "",
    "    EXTERNAL BRANCH of SUPERIOR LARYNGEAL NERVE (EBSLN):",
    "      Runs with superior thyroid vessels.  Supplies cricothyroid muscle.",
    "      Injury: loss of high-pitched voice / vocal fatigue.",
    "",
    "  PARATHYROID GLANDS: 4 glands (2 superior + 2 inferior)",
    "    All supplied by inferior thyroid artery branches.",
    "    Superior glands: behind upper pole, more constant position.",
    "    Inferior glands: variable (can be in thymus/mediastinum).",
]))
story.append(SP())

story.append(section("NOMENCLATURE"))
story.append(flowchart_box([
    "EXTENT OF RESECTION (least → most):",
    "",
    "  Isthmusectomy      →  Isthmus + pyramidal lobe only",
    "  Hemithyroidectomy  →  One entire lobe + isthmus (± pyramidal lobe)",
    "  Subtotal           →  Bilateral resection; leave 3-5 g each side",
    "  Near-total         →  Leave < 1 g at Berry's ligament",
    "  Total              →  All visible thyroid tissue removed",
]))
story.append(SP())

# Indications table (3 columns for 3 operations)
story.append(section("INDICATIONS BY PROCEDURE"))
story.append(box(
    [["HEMITHYROIDECTOMY", "SUBTOTAL THYROIDECTOMY", "TOTAL THYROIDECTOMY"],
     ["Solitary thyroid nodule (benign or indeterminate FNA)",
      "Graves' disease (bilateral toxic) - antithyroid drugs failed",
      "Thyroid cancer (papillary >4 cm, follicular with vascular invasion, medullary, anaplastic)"],
     ["Low-risk papillary carcinoma T1/T2 (<4 cm, unifocal)",
      "Bilateral toxic multinodular goitre",
      "Large bilateral multinodular goitre with compressive symptoms"],
     ["Diagnostic lobectomy (indeterminate cytology Bethesda III/IV)",
      "Non-toxic bilateral multinodular goitre (large)",
      "Graves' disease (severe ophthalmopathy / relapse)"],
     ["Unilateral multinodular goitre",
      "Cosmetically disfiguring goitre",
      "Prophylactic: RET mutation (MEN2A/2B)"],
     ["Unilateral toxic nodule",
      "",
      "Substernal / retrosternal goitre"],
    ],
    [W/3, W/3, W/3]
))
story.append(SP())

story.append(section("OPERATIVE STEPS (Common to All Thyroidectomies)"))
story.append(steps_table([
    ["Pre-op", "Preparation", "Euthyroid state (Lugol's iodine x10d for Graves'). Laryngoscopy (document cord status). Calcium/PTH baseline. Ultrasound ± FNA."],
    ["1", "Positioning", "Supine. Neck extended (sandbag under shoulders). Arms tucked."],
    ["2", "Kocher incision", "Transverse collar incision 2-3 cm above sternal notch. Length 4-6 cm. Skin → subcutaneous → platysma."],
    ["3", "Flap elevation", "Superior flap to thyroid cartilage notch. Inferior flap to sternal notch. Avascular plane superficial to strap muscles."],
    ["4", "Strap muscles", "Split in midline (linea alba cervicis). May divide transversely for large goitre."],
    ["5", "Gland exposure", "Retract strap muscles laterally. Ligate MIDDLE THYROID VEIN (first vascular step). Rotate gland medially."],
    ["6", "Superior pole", "Ligate SUPERIOR THYROID ARTERY close to gland (protects EBSLN). Divide superior thyroid veins."],
    ["7", "RLN identification", "Locate RLN in tracheoesophageal groove. Trace to laryngeal entry. Most vulnerable at Berry's ligament. Confirm with nerve monitor."],
    ["8", "Parathyroid preservation", "Identify all 4 parathyroids. Preserve blood supply by ligating ITA LATERAL to gland (not at trunk). Devascularised gland → autotransplant to SCM."],
    ["9", "Berry's ligament", "Carefully divide (RLN closest here). Use fine dissection - do not grasp blindly."],
    ["10", "Gland removal", "HEMI: divide isthmus lateral to midline. SUBTOTAL: leave 3-5g bilaterally. TOTAL: remove all visible tissue."],
    ["11", "Closure", "Valsalva to check haemostasis. Strap muscles approximated (leave small opening inferiorly). Platysma + skin closure. Drain only if significant ooze."],
]))
story.append(SP())

story.append(section("COMPLICATIONS"))
story.append(comps_table([
    ["EMERGENCY", "Neck haematoma (airway compression)", "Open wound at bedside IMMEDIATELY. Emergency re-intubation or tracheostomy. Risk 0.5-1%."],
    ["EMERGENCY", "Bilateral RLN injury", "Immediate airway obstruction. Emergency tracheostomy."],
    ["Early/Late", "Hypocalcaemia (hypoparathyroidism)", "Most common serious complication of total thyroidectomy. Temporary up to 30%; permanent 1-3%. Symptoms: perioral tingling, Chvostek's, Trousseau's. Rx: IV calcium gluconate → oral Ca + Vit D."],
    ["Early/Late", "RLN injury (unilateral)", "Hoarseness, aspiration. Temporary (neuropraxia) resolves weeks-months. Permanent 1%."],
    ["Early/Late", "EBSLN injury", "Loss of high-pitched voice / vocal fatigue. 'Surgeon's nerve.'"],
    ["Post-op", "Thyroid storm", "In inadequately prepared hyperthyroid patient. Tachycardia, hyperpyrexia, agitation. Rx: beta-blockers + hydration + antithyroid drugs + steroids."],
    ["Late", "Hypothyroidism", "Expected after total/near-total → lifelong levothyroxine."],
]))
story.append(SP())

story.append(section("VIVA QUESTIONS"))
story.append(viva("Where is the RLN most at risk?",
    "At the ligament of Berry, where the nerve passes close to the posterior thyroid surface just before entering the larynx."))
story.append(viva("What is the non-recurrent laryngeal nerve?",
    "A rare variant (~0.5-1%), right side only, associated with anomalous right subclavian artery. The nerve passes directly from vagus to larynx without looping - extremely vulnerable to injury if not anticipated."))
story.append(viva("How do you protect the EBSLN?",
    "Ligate the superior thyroid artery as close to the gland as possible - not en masse. The EBSLN runs with the superior thyroid vascular pedicle."))
story.append(viva("What is Chvostek's vs Trousseau's sign?",
    "Chvostek: tap facial nerve at parotid → ipsilateral facial twitch (hypocalcaemia). Trousseau: BP cuff above systolic for 3 min → carpal spasm (more specific for hypocalcaemia)."))
story.append(viva("What is the PTH intraoperative predictor of hypocalcaemia?",
    "Intraoperative PTH < 10 pg/mL immediately after gland removal strongly predicts postoperative hypocalcaemia. Some centres use this to guide prophylactic calcium supplementation."))
story.append(viva("When is hemithyroidectomy oncologically adequate for thyroid cancer?",
    "For low-risk differentiated thyroid cancer: T1/T2 (<4 cm), unifocal, no extrathyroidal extension, no nodal/distant metastasis, no high-risk histology (e.g., tall cell, diffuse sclerosing). ATA guidelines support lobectomy for these cases."))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# 5. SISTRUNK OPERATION
# ════════════════════════════════════════════════════════════════════════════
story.append(proc_header("5", "THYROGLOSSAL CYST EXCISION — Sistrunk Operation", colors.HexColor("#6a0572")))
story.append(SP())

story.append(section("ANATOMY & EMBRYOLOGY"))
story.append(anatomy_box([
    "THYROGLOSSAL DUCT EMBRYOLOGY:",
    "  Week 4:  Endodermal pit at base of tongue (foramen cecum) - thyroid primordium descends",
    "  Week 5:  Thyroglossal duct becomes solid; starts to obliterate",
    "  Week 7:  Hyoid bone forms - INTERSECTS the tract (divides it into supra/infrahyoid)",
    "  Week 10: Thyroid reaches final position (C5-T1), duct obliterates completely",
    "",
    "  ABNORMAL: Epithelial remnant persists → THYROGLOSSAL DUCT CYST",
    "",
    "  CYST LOCATIONS (frequency):",
    "    Suprahyoid: 25%  |  At hyoid: 10%  |  Infrahyoid (subhyoid): 65% [MOST COMMON]",
    "    Intralingual: rare",
    "",
    "  CLINICAL SIGN: Moves on SWALLOWING + TONGUE PROTRUSION (tethered to foramen cecum)",
    "",
    "  DIFFERENTIAL DIAGNOSIS of midline neck swelling:",
    "    Thyroglossal cyst | Dermoid cyst | Submental LN | Lipoma | Thyroid isthmus mass",
]))
story.append(SP())

story.append(section("INDICATIONS"))
for txt in [
    "Symptomatic thyroglossal duct cyst (pain, swelling, discomfort)",
    "Recurrent infection (the original indication described by Sistrunk in 1920)",
    "Established or draining fistula to skin",
    "Risk of malignancy (~1% of cysts harbour papillary thyroid carcinoma)",
    "Cosmetic/patient preference",
]:
    story.append(bp(txt))
story.append(SP(0.2))
story.append(warn_box([
    "⚠ MANDATORY PRE-OP: Thyroid ultrasound to confirm orthotopic thyroid gland is present. "
    "If the cyst is the only functioning thyroid tissue, excision will cause hypothyroidism."
]))
story.append(SP())

story.append(section("OPERATIVE STEPS"))
story.append(steps_table([
    ["1", "Positioning", "Supine. Neck extended. GA."],
    ["2", "Incision", "Transverse skin crease incision directly over the cyst. If infected/fistula: ellipse around fistula opening."],
    ["3", "Cyst dissection", "Carefully dissect cyst from surrounding tissue. AVOID RUPTURE - spillage causes high recurrence. Identify strap muscles, preserve."],
    ["4", "Tract tracing", "Trace tract superiorly toward hyoid. Take wide core of tissue (1 cm) AROUND the tract (not just visible duct - microscopic branches present)."],
    ["5", "HYOID RESECTION (KEY STEP)", "Detach supra- and infrahyoid muscles. Resect CENTRAL BODY of hyoid bone between the greater horns. This step is ESSENTIAL - failure to remove hyoid = 80% recurrence vs <4% with Sistrunk."],
    ["6", "To foramen cecum", "Continue cephalad dissection. Include a core of tongue base muscle (strap of tissue). Trace tract to foramen cecum. Suture-ligate stump at tongue base."],
    ["7", "Closure", "Reapproximate suprahyoid muscles. Drain only if infected cyst. Subcuticular skin closure."],
]))
story.append(SP())

story.append(section("COMPLICATIONS"))
story.append(comps_table([
    ["Most common", "Recurrence", "3-4% with proper Sistrunk; 80% if hyoid NOT removed"],
    ["Early", "Wound infection", "Especially after previously infected cyst"],
    ["Early", "Haematoma", "Rare"],
    ["Late", "Hypoglossal nerve injury (CN XII)", "If dissection extends too lateral; tongue deviation"],
    ["Late", "Hypothyroidism", "If cyst was the only functioning thyroid tissue (check USS pre-op)"],
    ["Late", "Orocutaneous fistula", "Rare - if tongue base suture fails"],
    ["Rare", "Malignant change", "~1% papillary thyroid carcinoma in cyst wall"],
]))
story.append(SP())

story.append(section("VIVA QUESTIONS"))
story.append(viva("What is the most important step in the Sistrunk operation?",
    "Excision of the central body of the hyoid bone. This is the step that reduces recurrence from ~80% (cyst alone) to <4%."))
story.append(viva("Why does the cyst move with tongue protrusion?",
    "The tract is tethered to the foramen cecum at the base of the tongue via the thyroglossal duct remnant."))
story.append(viva("What investigation is mandatory before excision?",
    "Thyroid ultrasound to confirm presence of a normal orthotopic thyroid gland. The cyst may be the patient's only thyroid tissue."))
story.append(viva("What malignancy arises in thyroglossal cysts?",
    "Papillary thyroid carcinoma in ~1% of cases. The Sistrunk procedure alone is usually sufficient treatment when confined to the cyst."))
story.append(viva("What is the Sistrunk procedure vs extended Sistrunk?",
    "Standard Sistrunk: cyst + tract + central hyoid. Extended Sistrunk (for recurrence or suspected malignancy): wider excision including more tongue base muscle coring up to the foramen cecum."))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# 6. MODIFIED RADICAL NECK DISSECTION
# ════════════════════════════════════════════════════════════════════════════
story.append(proc_header("6", "MODIFIED RADICAL NECK DISSECTION (MRND)", colors.HexColor("#c75000")))
story.append(SP())

story.append(section("ANATOMY — CERVICAL LYMPH NODE LEVELS (Robbins Classification)"))
story.append(anatomy_box([
    "LEVEL I:   Submental (IA) + Submandibular (IB)",
    "           Bounded by: anterior/posterior belly digastric + mandible inferior border",
    "",
    "LEVEL II:  Upper Jugular (IJV nodes)  — Skull base to hyoid bone",
    "           IIA: anterior to spinal accessory nerve  |  IIB: posterior",
    "",
    "LEVEL III: Middle Jugular — Hyoid to cricoid cartilage",
    "",
    "LEVEL IV:  Lower Jugular — Cricoid to clavicle",
    "",
    "LEVEL V:   Posterior Triangle",
    "           VA: superior (above SAN)  |  VB: inferior (below SAN)",
    "           Bounded by: SCM, trapezius, clavicle",
    "",
    "LEVEL VI:  Central compartment — between carotid arteries, hyoid to sternal notch",
    "           (Pretracheal + paratracheal + Delphian nodes)",
    "",
    "DRAINAGE PATTERNS:",
    "  Oral cavity   → Levels I, II, III (±IV)",
    "  Oropharynx    → Levels II, III, IV",
    "  Larynx/Hypopharynx → Levels II, III, IV",
    "  Thyroid       → Level VI ± III, IV",
    "  Nasopharynx   → Levels II, III, IV, V",
]))
story.append(SP())

story.append(section("TYPES OF NECK DISSECTION"))
story.append(flowchart_box([
    "RADICAL (Crile, 1906):  Levels I-V + sacrifice SCM + IJV + Spinal Accessory Nerve",
    "  → Rarely used now; only if structures directly invaded",
    "",
    "MODIFIED RADICAL (MRND):  Levels I-V + PRESERVE ≥1 of: SCM / IJV / SAN",
    "  Type I   = SAN preserved",
    "  Type II  = SAN + IJV preserved",
    "  Type III = SAN + IJV + SCM preserved (= Functional neck dissection)",
    "",
    "SELECTIVE:  Only at-risk nodal levels cleared",
    "  Supraomohyoid ND (Levels I-III)  → oral cavity",
    "  Lateral ND (Levels II-IV)         → oropharynx / larynx / hypopharynx",
    "  Central ND (Level VI)             → thyroid cancer",
    "  Posterolateral ND (II-V)          → posterior scalp / skin cancers",
    "",
    "EXTENDED:  Additional non-lymphatic structures (carotid, skin, mediastinum)",
    "",
    "THRESHOLD FOR ELECTIVE ND:  > 15% risk of occult nodal metastasis",
]))
story.append(SP())

story.append(section("OPERATIVE STEPS"))
story.append(steps_table([
    ["1", "Positioning", "Supine. Head turned contralateral. Shoulder roll."],
    ["2", "Incision", "MacFee (2 parallel horizontal lines - preferred - avoids tip necrosis). Or Schobinger. AVOID Y or T-type."],
    ["3", "Skin flap elevation", "Subplatysmal flaps. Superior to mandible. Inferior to clavicle. Identify + preserve marginal mandibular nerve in upper flap."],
    ["4", "Level I (Submandibular)", "Identify marginal mandibular nerve (elevated in upper flap). Remove submandibular gland + perifacial nodes. Ligate Wharton's duct."],
    ["5", "Level II-IV (Jugular chain)", "Boundaries: posterior belly digastric/mastoid (sup) → clavicle (inf) → strap muscles (ant) → posterior SCM (post). Depth: cervical sensory rootlets (III), deep cervical fascia (II, IV). Sweep en bloc specimen."],
    ["6", "SAN identification", "Find CN XI just above Erb's point (junction upper/middle 1/3 SCM posterior border). Dissect to trapezius entry. PRESERVE."],
    ["7", "Level V (Posterior triangle)", "Remove nodes between: trapezius (posterior), SCM (anterior), clavicle (inferior). Preserve SAN throughout."],
    ["8", "Level VI (Central)", "For thyroid cancer. Between carotid arteries. Preserve both RLNs. Identify all parathyroids."],
    ["9", "Closure", "Control thoracic duct (left side) if identified / chyle leak present. 2 x suction drains. Platysma + skin closure."],
]))
story.append(SP())

story.append(section("STRUCTURES TO PRESERVE IN MRND"))
story.append(box(
    [["Structure", "Location", "Injury Result"],
     ["Spinal Accessory N (CN XI)", "Exits SCM at Erb's point, crosses posterior triangle to trapezius", "Shoulder drop, inability to abduct arm >90°, scapular winging"],
     ["Marginal Mandibular N (VII)", "Below mandible in upper flap, near facial artery", "Ipsilateral lip depressor weakness (asymmetric smile)"],
     ["Phrenic Nerve", "On anterior scalene muscle deep to deep cervical fascia", "Ipsilateral diaphragm paralysis"],
     ["Brachial Plexus", "Deep to posterior triangle fat (deep fascial layer)", "Arm weakness / numbness"],
     ["Vagus Nerve", "In carotid sheath between IJV and CCA", "Voice changes, cardiac arrhythmias"],
     ["Hypoglossal N (CN XII)", "Level IB/II - hooks around occipital artery", "Tongue deviation to ipsilateral side"],
     ["Thoracic Duct", "Left neck only - enters at IJV-subclavian junction", "Chylous fistula (milky drain output)"],
    ],
    [3*cm, 5*cm, W - 8*cm]
))
story.append(SP())

story.append(section("COMPLICATIONS"))
story.append(comps_table([
    ["Nerve", "CN XI injury (shoulder drop)", "Most common permanent functional deficit"],
    ["Nerve", "Marginal mandibular N injury", "Lip asymmetry"],
    ["Nerve", "Phrenic N injury", "Diaphragm paralysis"],
    ["Vascular", "Carotid blowout syndrome", "Life-threatening - post-RT + wound breakdown"],
    ["Vascular", "Haematoma / air embolism", "IJV injury - occlude immediately"],
    ["Lymphatic", "Chylous fistula", ">500 mL/day → re-explore and ligate. Conservative: low-fat/MCT diet + pressure dressing."],
    ["Lymphatic", "Facial oedema", "Especially bilateral dissections; NEVER ligate bilateral IJV simultaneously"],
    ["Other", "Horner's syndrome", "Sympathetic chain injury: ptosis + miosis + anhidrosis"],
    ["Devastating", "Bilateral IJV ligation", "Fatal cerebral venous hypertension - NEVER perform bilateral ND simultaneously"],
]))
story.append(SP())

story.append(section("VIVA QUESTIONS"))
story.append(viva("Difference between radical and modified radical neck dissection?",
    "Radical ND (Crile 1906) removes levels I-V + SCM + IJV + spinal accessory nerve. MRND preserves one or more of these three structures. Type III MRND (preserving all three = functional ND) is equivalent oncologically to radical ND for N+ necks from most H&N primaries."))
story.append(viva("Why is bilateral radical neck dissection dangerous?",
    "Bilateral IJV ligation causes cerebral venous hypertension, fatal cerebral oedema, and blindness. Must always be staged with at least 3-6 weeks between sides."))
story.append(viva("What is Erb's point and why is it important?",
    "The point on the posterior SCM border (junction upper/middle thirds) where CN XI exits and multiple sensory nerve cutaneous branches (great auricular, lesser occipital, transverse cervical, supraclavicular - C2-C4) converge. Critical landmark for SAN identification in neck dissection."))
story.append(viva("What is a chylous fistula and how is it managed?",
    "Injury to the thoracic duct (left) or right lymphatic duct - milky, triglyceride-rich drain output (>110 mg/dL). Conservative management: low-fat / medium-chain triglyceride diet, octreotide, pressure dressing. Surgical ligation if >500 mL/day or persistent beyond 2 weeks."))
story.append(viva("What is the elective neck dissection threshold?",
    "If risk of occult nodal metastasis exceeds 15-20%, elective neck treatment (dissection or radiotherapy) is performed on the clinically N0 neck."))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# 7. TRACHEOSTOMY
# ════════════════════════════════════════════════════════════════════════════
story.append(proc_header("7", "TRACHEOSTOMY", colors.HexColor("#1b7a4a")))
story.append(SP())

story.append(section("ANATOMY"))
story.append(anatomy_box([
    "TRACHEA: ~10-12 cm long.  16-20 C-shaped cartilaginous rings.",
    "",
    "KEY LEVELS:",
    "  Cricoid cartilage  →  C6  (highest safe point - 'never above cricoid')",
    "  Thyroid isthmus    →  overlies rings 2-4",
    "  TRACHEOSTOMY ENTRY → rings 2-3 or 3-4  [SAFE ZONE]",
    "  Sternal notch      →  T2  (below = danger of brachiocephalic vessels)",
    "",
    "LAYERS ENCOUNTERED (anterior midline):",
    "  Skin → Subcutaneous fat → Platysma → Deep cervical fascia",
    "  → Strap muscles (separate in midline) → Thyroid isthmus",
    "  → Pretracheal fat → Tracheal rings",
    "",
    "VASCULAR DANGERS:",
    "  Anterior jugular veins  →  midline joining (jugular arch) - ligate if encountered",
    "  Thyroidea ima artery (10%)  →  midline, from aortic arch  [MAJOR BLEEDING RISK]",
    "  Brachiocephalic artery  →  RIGHT of midline, rises anterior to trachea (low incisions)",
    "",
    "RULES:",
    "  Too HIGH (ring 1 / subglottic)  →  Subglottic stenosis",
    "  Too LOW (ring 5+)               →  Brachiocephalic artery erosion / fistula",
]))
story.append(SP())

story.append(section("INDICATIONS & CONTRAINDICATIONS"))
story.append(box(
    [["INDICATIONS", "RELATIVE CONTRAINDICATIONS"],
     ["Upper airway obstruction:\n• Significant maxillofacial trauma\n• Angioedema\n• Upper airway tumours\n• Infection (Ludwig's angina)",
      "Recent anterior neck surgery (<7 days)"],
     ["Neurological inability to protect airway:\n• Brain injury (acute or progressive)\n• Spinal cord injury (incl. halo)\n• Severe agitation / delirium\n• Prolonged altered mental status",
      "High ventilator settings:\n• FiO2 >50%\n• PEEP >10 cmH2O"],
     ["Prolonged mechanical ventilation\n(>7-10 days anticipated)",
      "Haemodynamic instability\nSignificant bleeding risk"],
     ["Difficult / failed airway",
      "Elevated intracranial pressure"],
     ["Weaning assistance / bronchial toilet",
      "Local infection / tumour at site\nPredicted early mortality"],
    ],
    [W/2, W/2]
))
story.append(SP())

story.append(section("OPERATIVE STEPS — OPEN SURGICAL TRACHEOSTOMY"))
story.append(steps_table([
    ["Pre-op", "Preparation", "ETT in situ. Pre-oxygenate 100% O2. IV access + monitoring. Anaesthetist scrubbed in."],
    ["1", "Positioning", "Supine. Neck extended (shoulder roll / ring under head). Cricoid and sternal notch palpated."],
    ["2", "Incision", "Horizontal incision 2 cm below cricoid cartilage. Length 2-3 cm in skin crease. Vertical midline in emergencies."],
    ["3", "Dissection to trachea", "Divide subcutaneous fat. Retract platysma. Separate strap muscles in midline. Retract thyroid isthmus superiorly OR divide and ligate. Identify trachea by palpation."],
    ["4", "Confirm trachea", "Aspirate air with syringe. Confirm rings by palpation."],
    ["5", "Tracheal entry", "Options: (1) Vertical incision between rings 2-3 and 3-4; (2) Cruciate incision; (3) Bjork flap (inferior U-based, sutured to skin - aids tube change, risk tracheomalacia); (4) Window excision (Grillo). Anaesthetist withdraws ETT to just above entry site."],
    ["6", "Tube insertion", "Insert cuffed tracheostomy tube. Inflate cuff. Confirm: capnography + bilateral auscultation + SpO2."],
    ["7", "Fixation", "Secure with neck tapes. Suture flanges to skin. Loose skin closure around tube. Apply dressing."],
]))
story.append(SP())

story.append(p("<b>PERCUTANEOUS DILATATIONAL TRACHEOSTOMY (PDT - Ciaglia technique):</b>"))
story.append(bp("Seldinger technique under bronchoscopic guidance in ICU."))
story.append(bp("ETT withdrawn to subglottis under direct bronchoscopic vision."))
story.append(bp("Needle puncture → guidewire → serial dilators → tracheostomy tube over wire."))
story.append(bp("Advantages: bedside ICU, decreased wound infection, lower cost, equivalent safety."))
story.append(bp("Disadvantages: not for difficult anatomy, obesity, coagulopathy, paediatric, emergency."))
story.append(SP())

story.append(section("COMPLICATIONS"))
story.append(comps_table([
    ["Immediate", "Haemorrhage", "Thyroid vessels, anterior jugular v., thyroidea ima a."],
    ["Immediate", "Hypoxia / loss of airway", "During procedure - have ENT surgeon scrubbed + plan B"],
    ["Immediate", "Oesophageal placement", "Must confirm with capnography before securing"],
    ["Immediate", "Pneumothorax", "Especially in children (high mediastinum)"],
    ["Immediate", "Air embolism", "IJV or great vein injury"],
    ["Early", "Tube displacement", "First 3-5 days: tract not mature. Oral re-intubation required."],
    ["Early", "Subcutaneous emphysema", "Air tracking in pretracheal fascia"],
    ["Early", "Wound infection / haematoma", "Antibiotics; drainage"],
    ["Late", "SUBGLOTTIC / TRACHEAL STENOSIS", "Most serious late complication. Caused by: high placement, cuff overinflation (>30 mmHg), excessive tracheal resection. Rx: dilation, laser, tracheal resection + anastomosis."],
    ["Late", "TRACHEO-INNOMINATE FISTULA", "Rare but FATAL. Brachiocephalic artery erosion (tracheostomy too low). Presents as sentinel bleed 3-6 weeks post-op. Emergency: hyperinflate cuff + digital pressure through stoma + emergency OR for ligation."],
    ["Late", "Tracheo-oesophageal fistula", "Posterior wall erosion; tube cuff pressure, posterior tracheal wall injury"],
    ["Late", "Persistent tracheocutaneous fistula", "After decannulation - close surgically if persistent"],
    ["Late", "Tracheomalacia", "Cartilage destruction; causes expiratory collapse"],
]))
story.append(SP())

story.append(section("VIVA QUESTIONS"))
story.append(viva("Between which tracheal rings is tracheostomy made?",
    "Between the 2nd and 3rd, or 3rd and 4th tracheal rings. Above ring 2 risks subglottic stenosis. Below ring 5 risks brachiocephalic artery erosion and tracheo-innominate fistula."))
story.append(viva("What is the most serious late complication of tracheostomy?",
    "Tracheo-innominate (brachiocephalic) artery fistula. Presents as a sentinel bleed 3-6 weeks post-tracheostomy. Initial management: hyperinflate tracheostomy cuff, digital compression through the stoma, emergency surgery."))
story.append(viva("What is a Bjork flap?",
    "An inferior-based U-shaped flap of tracheal anterior wall sutured to the skin at the tracheostomy site. Facilitates emergency re-insertion if tube dislodges, but risks tracheomalacia and is less favoured now."))
story.append(viva("Advantages of PDT over open tracheostomy?",
    "Decreased wound infection rate, lower cost, can be performed at the bedside in ICU, equivalent mortality and complication rates per meta-analysis. Not suitable for difficult anatomy, obesity, coagulopathy, emergency situations, or children."))
story.append(viva("How do you manage accidental decannulation in the first 5 days?",
    "In the first 3-5 days the tract is immature and will close rapidly. Do NOT attempt blind re-insertion. Orally intubate immediately and call experienced help. After 7 days, tract is mature and tube can be replaced through the stoma."))
story.append(viva("What is the thyroidea ima artery?",
    "A midline artery present in ~10% of patients, arising from the aortic arch or brachiocephalic trunk. It runs directly superiorly in the midline and can cause major intraoperative haemorrhage during tracheostomy if not recognised."))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# SUMMARY COMPARISON TABLES
# ════════════════════════════════════════════════════════════════════════════
story.append(proc_header("SUMMARY", "HIGH-YIELD COMPARISON TABLES", colors.HexColor("#2c3e50")))
story.append(SP())

story.append(section("PROCEDURE QUICK REFERENCE"))
story.append(box(
    [["Procedure", "Key Anatomy", "Key Nerve at Risk", "Critical Step", "Classic Complication"],
     ["Superficial Parotidectomy", "Facial nerve in gland", "CN VII (Facial)", "Identify FN at tragal pointer", "Frey's Syndrome"],
     ["Subtotal Thyroidectomy", "RLN in TE groove", "RLN + EBSLN", "Identify RLN before ITA ligation", "Hypocalcaemia"],
     ["Hemithyroidectomy", "RLN (unilateral)", "Ipsilateral RLN", "Divide isthmus lateral to midline", "Hypothyroidism (30% risk)"],
     ["Total Thyroidectomy", "Bilateral RLN + 4 parathyroids", "Bilateral RLN + parathyroids", "Preserve all 4 parathyroids", "Permanent hypoparathyroidism"],
     ["Sistrunk Operation", "Hyoid bone + thyroglossal tract", "CN XII (Hypoglossal)", "Remove central hyoid body", "Recurrence (if hyoid spared)"],
     ["MRND", "5 nodal levels + 3 key structures", "CN XI (Spinal Accessory)", "Identify SAN at Erb's point", "Shoulder drop (SAN injury)"],
     ["Tracheostomy", "Rings 2-4 + TE vasculature", "Brachiocephalic artery (low incision)", "Enter between rings 2-4", "Tracheo-innominate fistula"],
    ],
    [3.5*cm, 3*cm, 3*cm, 3.5*cm, W - 13*cm]
))
story.append(SP())

story.append(section("DECISION FLOWCHART"))
story.append(flowchart_box([
    "PAROTID MASS",
    "  ├─ Superficial lobe only (benign)           → SUPERFICIAL PAROTIDECTOMY",
    "  ├─ Deep + superficial, FN intact             → TOTAL CONSERVATIVE PAROTIDECTOMY",
    "  └─ FN involved / malignant + N+ neck         → RADICAL PAROTIDECTOMY + NECK DISSECTION",
    "",
    "THYROID PATHOLOGY",
    "  ├─ Unilateral nodule / indeterminate FNA     → HEMITHYROIDECTOMY",
    "  ├─ Bilateral Graves / large bilateral goitre → SUBTOTAL THYROIDECTOMY",
    "  ├─ Cancer >4cm / bilateral / medullary       → TOTAL THYROIDECTOMY",
    "  └─ RET mutation (MEN2)                       → PROPHYLACTIC TOTAL THYROIDECTOMY",
    "",
    "MIDLINE NECK MASS (moves with swallowing + tongue protrusion)",
    "  └─ Confirm orthotopic thyroid on USS, then  → SISTRUNK OPERATION",
    "       KEY: Remove cyst + tract + central hyoid body",
    "",
    "HEAD & NECK MALIGNANCY - NECK",
    "  ├─ N+ neck                                   → MODIFIED RADICAL NECK DISSECTION (I-V)",
    "  ├─ N0 oral cavity (risk >15%)                → SELECTIVE ND (Levels I-III)",
    "  ├─ N0 oropharynx/larynx (risk >15%)          → SELECTIVE ND (Levels II-IV)",
    "  └─ Thyroid cancer                            → CENTRAL ND (Level VI) ± lateral",
    "",
    "AIRWAY MANAGEMENT",
    "  ├─ Emergency                                  → OPEN SURGICAL TRACHEOSTOMY (vertical)",
    "  └─ Elective ICU prolonged ventilation         → PERCUTANEOUS DILATATIONAL TRACHEOSTOMY",
]))
story.append(SP())

story.append(section("MEMORABLE FACTS FOR VIVA"))
story.append(box(
    [["Fact", "Detail"],
     ["Frey's syndrome incidence", "Up to 40% after parotidectomy"],
     ["RLN most vulnerable point", "Ligament of Berry"],
     ["Non-recurrent RLN", "Right side only (~0.5-1%) - anomalous subclavian artery"],
     ["Sistrunk described", "1920 - resection of cyst + hyoid central body"],
     ["Recurrence without hyoid removal", "~80% vs <4% with Sistrunk"],
     ["Neck dissection first described", "George Crile, 1906 (radical ND)"],
     ["MRND Type III (functional ND)", "Preserves SCM + IJV + SAN = equivalent to radical ND"],
     ["Bilateral IJV ligation", "FATAL - cerebral venous hypertension"],
     ["Tracheostomy safe zone", "Rings 2-4 (between cricoid and ring 5)"],
     ["Tracheo-innominate fistula timing", "Sentinel bleed at 3-6 weeks post-tracheostomy"],
     ["Thyroidea ima artery", "Present in 10%, arises from aortic arch, in midline - danger!"],
     ["Erb's point", "Junction upper/middle 1/3 SCM posterior border - CN XI exits here"],
     ["Elective ND threshold", ">15% risk of occult nodal metastasis"],
     ["Chylous fistula threshold for surgery", ">500 mL/day or not resolving with conservative measures"],
    ],
    [5*cm, W - 5*cm]
))
story.append(SP())
story.append(p("<i>Sources: Scott-Brown's Otorhinolaryngology Head & Neck Surgery; Sabiston Textbook of Surgery; Bailey & Love's Short Practice of Surgery (28th ed.); Mulholland & Greenfield's Surgery (7th ed.)</i>"))

# ── Build PDF ─────────────────────────────────────────────────────────────
doc.build(story)
print(f"PDF created: {OUTPUT}")
Running Command

cd /home/daytona/workspace/head-neck-surgery && python3 generate_pdf.py 2>&1

Running Command

ls -lh /home/daytona/workspace/head-neck-surgery/Head_Neck_Surgery.pdf

Your PDF is ready! Download it here:

Head Neck Surgery

PDF Document · PDF


What's inside the PDF (fully formatted, colour-coded, printable):
SectionContent
Cover pageAll 7 procedures listed
Each procedureColour-coded header (navy/teal/green/orange/purple)
Anatomy boxesBlue-bordered monospace diagrams
Indications tablesColour-banded comparison tables
Operative stepsGreen step-by-step tables (Step / Action / Key Points)
ComplicationsRed-coded tables (Immediate / Early / Late)
Viva Q&ABold Q + indented A for every procedure
Decision flowchartYellow bordered algorithm covering all 7 procedures
Final summaryHigh-yield comparison table + memorable facts table
The PDF uses A4 size - open, zoom in, and it will be fully legible. Let me know if you want any section expanded, a specific procedure in more detail, or a PPTX version instead.

With operative images

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

mkdir -p /home/daytona/workspace/head-neck-surgery/images && cd /home/daytona/workspace/head-neck-surgery/images && \ curl -s -o parotid_incision.png "https://cdn.orris.care/cdss_images/4eaa522d77261cba2e72352773e2a40472f27ea84c9e77bd45d55cdc4db010e0.png" && \ curl -s -o parotid_subplatysmal.png "https://cdn.orris.care/cdss_images/52f689b6b0e4fd2cad083f4a7a5cdb55332da278a2d268c125d22079ccc59bb7.png" && \ curl -s -o parotid_greater_auricular.png "https://cdn.orris.care/cdss_images/2090b53148e90ca14505559d18834f297af0ab9514d6898774cffed00bb90f35.png" && \ curl -s -o parotid_tragal_pointer.png "https://cdn.orris.care/cdss_images/de5dda2a2b1b66a4091a039601e48e028550302ff0f0d17e692b947d74aa136f.png" && \ curl -s -o parotid_pateys_plane.png "https://cdn.orris.care/cdss_images/2e6635f7b08e040e76fb2b8abcdb78faf46e148c7d5821d8bd135f6e84deef4b.png" && \ curl -s -o parotid_centripetal.png "https://cdn.orris.care/cdss_images/57a0508536f7eed7daa36a3bcabbdb4edb6bfb0d77b16e7c46c8646b84821d65.png" && \ curl -s -o parotid_duct_ligation.png "https://cdn.orris.care/cdss_images/fbe23532edb2ebfc3eb026df09d19d6dbef5ccc040d7e5d1e38d715cd618f48f.png" && \ echo "Parotid images done"

Running Command

cd /home/daytona/workspace/head-neck-surgery/images && \ curl -s -o thyroid_incision.png "https://cdn.orris.care/cdss_images/806ca072da4addcee06a570c479f03ce041a587234c653254ecb939fde802143.png" && \ curl -s -o thyroid_superior_pole.png "https://cdn.orris.care/cdss_images/4f6e138765e651f8fe54e5345ca861ba097939da28ac223819c39bd67a4b97cf.png" && \ curl -s -o thyroid_mobilisation.png "https://cdn.orris.care/cdss_images/caa83070b322fb42dd4b4ae132c695c19c857bee2dc4b27d8c1bfac34a205b49.png" && \ curl -s -o thyroid_ebsln.png "https://cdn.orris.care/cdss_images/cf26d1f339fb446a1be3365e9cc529a01d84891ff252ab38ff916a7e99cae7e1.png" && \ curl -s -o thyroid_rln_parathyroid.png "https://cdn.orris.care/cdss_images/514769266889909e019b1104d3b13a119eb37f64885ae1e0bb61e92424dd3dee.png" && \ curl -s -o thyroid_berry_ligament.png "https://cdn.orris.care/cdss_images/8a32e93a580a62137985a4f001b6e0b7fc8b5fda7e244d16e7ad8cf717188786.png" && \ curl -s -o thyroid_ectopic.png "https://cdn.orris.care/cdss_images/a24cb50424a16322f22ae7e21430ad44d49d164053613d3012a9d68d854214ae.png" && \ curl -s -o neck_dissection_intraop.png "https://cdn.orris.care/cdss_images/6541025f9c81efa82853e1d2e91a6138da34dbc92825c3ec8da296f4b43399c1.png" && \ echo "done"

Writing File

~/head-neck-surgery/generate_pdf_with_images.py


from reportlab.lib.pagesizes import A4
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm
from reportlab.lib import colors
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, PageBreak, KeepTogether, Image
)
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
import os

OUTPUT = "/home/daytona/workspace/head-neck-surgery/Head_Neck_Surgery_WITH_IMAGES.pdf"
IMG_DIR = "/home/daytona/workspace/head-neck-surgery/images/"

W, H = A4
MW = W - 3.6*cm  # usable width

# ── Colours ─────────────────────────────────────────────────────────────────
NAVY    = colors.HexColor("#1a2f5a")
TEAL    = colors.HexColor("#0077b6")
LTBLUE  = colors.HexColor("#e8f4fd")
ORANGE  = colors.HexColor("#e85d04")
GREEN   = colors.HexColor("#1b7a4a")
RED     = colors.HexColor("#c0392b")
PURPLE  = colors.HexColor("#6a0572")
BROWN   = colors.HexColor("#c75000")
DKSLATE = colors.HexColor("#2c3e50")
LTGREEN = colors.HexColor("#e8f5e9")
LTRED   = colors.HexColor("#fdecea")
LTYELLOW= colors.HexColor("#fffde7")
GREY    = colors.HexColor("#f5f5f5")
DKGREY  = colors.HexColor("#424242")

# ── Styles ───────────────────────────────────────────────────────────────────
base = getSampleStyleSheet()
def S(name, parent="Normal", **kw):
    return ParagraphStyle(name, parent=base[parent], **kw)

cover_title = S("CT", fontSize=30, textColor=colors.white,
                alignment=TA_CENTER, fontName="Helvetica-Bold", leading=36)
cover_sub   = S("CS", fontSize=13, textColor=colors.HexColor("#cce8ff"),
                alignment=TA_CENTER, fontName="Helvetica", leading=17)
proc_title  = S("PT", fontSize=17, textColor=colors.white,
                fontName="Helvetica-Bold", alignment=TA_CENTER, leading=22)
sec_head    = S("SH", fontSize=12, textColor=NAVY,
                fontName="Helvetica-Bold", spaceBefore=8, spaceAfter=3, leading=15)
sub_head    = S("SUB", fontSize=10.5, textColor=TEAL,
                fontName="Helvetica-Bold", spaceBefore=5, spaceAfter=2)
body        = S("BD", fontSize=9, leading=12, spaceAfter=3,
                fontName="Helvetica", textColor=DKGREY)
mono        = S("MN", fontSize=8, fontName="Courier",
                leading=11, spaceAfter=2, textColor=colors.HexColor("#1a1a2e"))
bullet_s    = S("BL", fontSize=9, leading=12, leftIndent=12,
                fontName="Helvetica", textColor=DKGREY)
viva_q      = S("VQ", fontSize=9.5, textColor=NAVY,
                fontName="Helvetica-Bold", leading=13, spaceBefore=4)
viva_a      = S("VA", fontSize=9, textColor=DKGREY,
                fontName="Helvetica", leading=12, leftIndent=10, spaceAfter=4)
caption_s   = S("CAP", fontSize=7.5, textColor=colors.grey,
                fontName="Helvetica-Oblique", leading=10, alignment=TA_CENTER)
img_label   = S("IL", fontSize=8.5, textColor=TEAL,
                fontName="Helvetica-Bold", alignment=TA_CENTER, spaceAfter=2)

story = []
doc = SimpleDocTemplate(OUTPUT, pagesize=A4,
                        rightMargin=1.8*cm, leftMargin=1.8*cm,
                        topMargin=1.8*cm, bottomMargin=1.8*cm)

# ── Helpers ──────────────────────────────────────────────────────────────────
SP = lambda n=0.3: Spacer(1, n*cm)

def img(fname, width=MW, caption_txt="", max_h=None):
    path = IMG_DIR + fname
    if not os.path.exists(path):
        return Paragraph(f"[Image: {fname}]", caption_s)
    from PIL import Image as PILImage
    try:
        with PILImage.open(path) as im:
            iw, ih = im.size
        ratio = ih / iw
        w = min(width, MW)
        h = w * ratio
        if max_h and h > max_h:
            h = max_h
            w = h / ratio
        elems = [Image(path, width=w, height=h)]
        if caption_txt:
            elems.append(Paragraph(caption_txt, caption_s))
        return KeepTogether(elems)
    except Exception as e:
        return Paragraph(f"[Image error: {e}]", caption_s)

def img_row(files_captions, widths=None):
    """Side-by-side images."""
    n = len(files_captions)
    cell_w = MW / n - 0.1*cm
    cells = []
    for fname, cap in files_captions:
        path = IMG_DIR + fname
        cell_parts = []
        if os.path.exists(path):
            try:
                from PIL import Image as PILImage
                with PILImage.open(path) as im:
                    iw, ih = im.size
                ratio = ih / iw
                h = min(cell_w * ratio, 6*cm)
                w = h / ratio
                cell_parts.append(Image(path, width=w, height=h))
            except:
                cell_parts.append(Paragraph(f"[{fname}]", caption_s))
        if cap:
            cell_parts.append(Paragraph(cap, caption_s))
        cells.append(cell_parts)
    t = Table([cells], colWidths=[MW/n]*n)
    t.setStyle(TableStyle([
        ("VALIGN", (0,0), (-1,-1), "TOP"),
        ("ALIGN",  (0,0), (-1,-1), "CENTER"),
        ("LEFTPADDING",  (0,0), (-1,-1), 4),
        ("RIGHTPADDING", (0,0), (-1,-1), 4),
    ]))
    return t

def proc_header(num, title, color=NAVY):
    t = Table([[Paragraph(f"{num}  {title}", proc_title)]], colWidths=[MW])
    t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,-1), color),
        ("TOPPADDING",    (0,0), (-1,-1), 10),
        ("BOTTOMPADDING", (0,0), (-1,-1), 10),
        ("LEFTPADDING",   (0,0), (-1,-1), 14),
        ("ROUNDEDCORNERS",[6]),
    ]))
    return t

def section(txt, color=NAVY):
    return Paragraph(f'<font color="#{color.hexval()[1:]}"><b>{txt}</b></font>', sec_head)

def anatomy_box(lines):
    content = "<br/>".join(lines)
    t = Table([[Paragraph(content, mono)]], colWidths=[MW])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), LTBLUE),
        ("LEFTPADDING", (0,0), (-1,-1), 10),
        ("TOPPADDING",  (0,0), (-1,-1), 8),
        ("BOTTOMPADDING",(0,0),(-1,-1), 8),
        ("BOX", (0,0), (-1,-1), 1, TEAL),
    ]))
    return t

def flowchart_box(lines, bg=LTYELLOW, border=ORANGE):
    content = "<br/>".join(lines)
    t = Table([[Paragraph(content, mono)]], colWidths=[MW])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), bg),
        ("LEFTPADDING", (0,0), (-1,-1), 10),
        ("TOPPADDING",  (0,0), (-1,-1), 8),
        ("BOTTOMPADDING",(0,0),(-1,-1), 8),
        ("BOX", (0,0), (-1,-1), 1.5, border),
    ]))
    return t

def warn_box(text):
    t = Table([[Paragraph(text, body)]], colWidths=[MW])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), LTRED),
        ("LEFTPADDING", (0,0), (-1,-1), 10),
        ("TOPPADDING",  (0,0), (-1,-1), 8),
        ("BOTTOMPADDING",(0,0),(-1,-1), 8),
        ("BOX", (0,0), (-1,-1), 1.5, RED),
    ]))
    return t

def tbl(rows, col_widths, header_bg=TEAL):
    t = Table(rows, colWidths=col_widths, repeatRows=1)
    t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,0),  header_bg),
        ("TEXTCOLOR",     (0,0), (-1,0),  colors.white),
        ("FONTNAME",      (0,0), (-1,0),  "Helvetica-Bold"),
        ("FONTSIZE",      (0,0), (-1,-1), 8.5),
        ("ROWBACKGROUNDS",(0,1), (-1,-1), [colors.white, GREY]),
        ("GRID",          (0,0), (-1,-1), 0.4, colors.HexColor("#cccccc")),
        ("TOPPADDING",    (0,0), (-1,-1), 4),
        ("BOTTOMPADDING", (0,0), (-1,-1), 4),
        ("LEFTPADDING",   (0,0), (-1,-1), 6),
        ("VALIGN",        (0,0), (-1,-1), "TOP"),
    ]))
    return t

def steps_tbl(steps):
    rows = [["Step", "Action", "Key Points"]]
    rows += steps
    t = Table(rows, colWidths=[1.1*cm, 4.8*cm, MW-5.9*cm], repeatRows=1)
    t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,0),  GREEN),
        ("TEXTCOLOR",     (0,0), (-1,0),  colors.white),
        ("FONTNAME",      (0,0), (-1,0),  "Helvetica-Bold"),
        ("FONTSIZE",      (0,0), (-1,-1), 8.5),
        ("ROWBACKGROUNDS",(0,1), (-1,-1), [LTGREEN, colors.white]),
        ("GRID",          (0,0), (-1,-1), 0.4, colors.HexColor("#aaaaaa")),
        ("TOPPADDING",    (0,0), (-1,-1), 4),
        ("BOTTOMPADDING", (0,0), (-1,-1), 4),
        ("LEFTPADDING",   (0,0), (-1,-1), 5),
        ("VALIGN",        (0,0), (-1,-1), "TOP"),
    ]))
    return t

def comps_tbl(rows_data):
    rows = [["Timing", "Complication", "Management / Notes"]]
    rows += rows_data
    t = Table(rows, colWidths=[2.2*cm, 4.8*cm, MW-7*cm], repeatRows=1)
    t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,0),  RED),
        ("TEXTCOLOR",     (0,0), (-1,0),  colors.white),
        ("FONTNAME",      (0,0), (-1,0),  "Helvetica-Bold"),
        ("FONTSIZE",      (0,0), (-1,-1), 8.5),
        ("ROWBACKGROUNDS",(0,1), (-1,-1), [LTRED, colors.white]),
        ("GRID",          (0,0), (-1,-1), 0.4, colors.HexColor("#aaaaaa")),
        ("TOPPADDING",    (0,0), (-1,-1), 4),
        ("BOTTOMPADDING", (0,0), (-1,-1), 4),
        ("LEFTPADDING",   (0,0), (-1,-1), 5),
        ("VALIGN",        (0,0), (-1,-1), "TOP"),
    ]))
    return t

def viva(q, a):
    return KeepTogether([
        Paragraph(f"Q: {q}", viva_q),
        Paragraph(f"A: {a}", viva_a),
    ])

def bp(txt):
    return Paragraph(f"• {txt}", bullet_s)

def p(txt):
    return Paragraph(txt, body)

# ════════════════════════════════════════════════════════════════════════════
# COVER
# ════════════════════════════════════════════════════════════════════════════
cover_tbl = Table([
    [Paragraph("HEAD & NECK SURGERY", cover_title)],
    [SP(0.2)],
    [Paragraph("Complete Operative Guide with Images", cover_sub)],
    [SP(0.15)],
    [Paragraph("Procedure · Anatomy · Indications · Operative Steps · Complications · Viva Q&A", cover_sub)],
    [SP(0.4)],
    [Paragraph("1.  Superficial Parotidectomy", cover_sub)],
    [Paragraph("2.  Subtotal Thyroidectomy", cover_sub)],
    [Paragraph("3.  Hemithyroidectomy", cover_sub)],
    [Paragraph("4.  Total Thyroidectomy", cover_sub)],
    [Paragraph("5.  Thyroglossal Cyst Excision — Sistrunk Operation", cover_sub)],
    [Paragraph("6.  Modified Radical Neck Dissection", cover_sub)],
    [Paragraph("7.  Tracheostomy", cover_sub)],
    [SP(0.6)],
    [Paragraph("Sources: Bailey & Love · Sabiston · Scott-Brown's · Mulholland & Greenfield", caption_s)],
], colWidths=[MW])
cover_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,-1), NAVY),
    ("TOPPADDING",    (0,0), (-1,-1), 6),
    ("BOTTOMPADDING", (0,0), (-1,-1), 6),
    ("LEFTPADDING",   (0,0), (-1,-1), 20),
    ("RIGHTPADDING",  (0,0), (-1,-1), 20),
]))
story += [SP(1.5), cover_tbl, PageBreak()]

# ════════════════════════════════════════════════════════════════════════════
# 1. SUPERFICIAL PAROTIDECTOMY
# ════════════════════════════════════════════════════════════════════════════
story.append(proc_header("1.", "SUPERFICIAL PAROTIDECTOMY", NAVY))
story.append(SP())

story.append(section("ANATOMY", NAVY))
story.append(anatomy_box([
    "PAROTID GLAND  |  Weight ~25 g  |  Purely serous  |  Stensen's duct → upper 2nd molar",
    "",
    "  FACIAL NERVE divides gland:",
    "    Superficial lobe (~80%) = lateral to FN (Patey's faciovenous plane)",
    "    Deep lobe      (~20%) = medial to FN",
    "",
    "  LANDMARKS for Facial Nerve (Antegrade technique):",
    "    1. Tragal (Conley's) pointer  →  FN = 1 cm DEEP & INFERIOR to tip",
    "    2. Tympanomastoid suture       →  FN exits INFERIOR to this suture line",
    "    3. Posterior belly of digastric →  FN identified ABOVE its upper border",
    "    4. Stylomastoid foramen         →  FN exits here (CN VII origin)",
    "",
    "  OTHER NERVES:  Greater Auricular N (C2/C3)  |  Auriculotemporal N (V3)",
    "  KEY VEIN:      Retromandibular vein = Patey's faciovenous plane marker",
]))
story.append(SP())

story.append(section("INDICATIONS", NAVY))
story.append(tbl(
    [["Benign Indications", "Malignant Indications"],
     ["Pleomorphic adenoma (70% of parotid tumours)", "Mucoepidermoid carcinoma"],
     ["Warthin's tumour (bilateral in 10%)", "Adenoid cystic carcinoma"],
     ["Monomorphic adenoma", "Acinic cell carcinoma"],
     ["Chronic / recurrent parotitis", "Carcinoma ex pleomorphic adenoma"],
     ["Parotid abscess", "Primary squamous cell carcinoma"],
    ], [MW/2, MW/2]
))
story.append(SP())

story.append(section("OPERATIVE STEPS WITH IMAGES", NAVY))
story.append(steps_tbl([
    ["1", "Positioning", "GA — NO long-acting paralytic (need FN monitoring). Reverse Trendelenburg. Head turned to contralateral side."],
    ["2", "Incision", "Modified Blair / lazy-S: pre-auricular → below ear lobe → neck crease. OR facelift incision. Infiltrate 1:100,000 adrenaline."],
    ["3", "Skin flap elevation", "Subplatysmal flap raised containing subcutaneous tissue + SMAS layer. Identify external jugular vein. Do NOT go onto masseteric fascia."],
    ["4", "Parotid mobilisation", "Dissect SCM-parotid fascial plane. Identify + preserve posterior branch of Greater Auricular N. Mobilise off SCM, mastoid tip, tragal cartilage. Expose tympanomastoid suture."],
    ["5", "Facial nerve ID", "ANTEGRADE: Find trunk at tragal pointer (1 cm deep & inferior). Confirm with nerve stimulator. Never cut unidentified structures."],
    ["6", "FN dissection (Patey's plane)", "Fine mosquito forceps parallel to nerve. Dissect trunk → divisions → branches. Superficial lobe lifted off nerve centripetally toward parotid duct."],
    ["7", "Gland removal", "Superficial lobe removed lateral to FN. Ligate and divide Stensen's duct."],
    ["8", "Closure", "Haemostasis. Suction drain. Platysma + skin closure."],
]))
story.append(SP())

# PAROTID IMAGES - 2x3 grid
story.append(Paragraph("<b>Operative Photographs — Superficial Parotidectomy</b>", sub_head))
story.append(img_row([
    ("parotid_incision.png", "(a) Modified Blair & retroauricular incision planning"),
    ("parotid_subplatysmal.png", "(b) Subplatysmal flap elevation; external jugular vein preserved"),
    ("parotid_greater_auricular.png", "(c) Greater auricular nerve traced to ear lobule"),
]))
story.append(SP(0.3))
story.append(img_row([
    ("parotid_tragal_pointer.png", "(d) Tragal pointer, mastoid tip, digastric — landmarks for facial nerve at stylomastoid foramen"),
    ("parotid_pateys_plane.png", "(e) Dissection in Patey's fascia — nerve branches from trunk to periphery"),
    ("parotid_centripetal.png", "(f) Centripetal dissection — cervicomandibular division identified"),
]))
story.append(SP(0.3))
story.append(img_row([
    ("parotid_duct_ligation.png", "(g) Ligation of Stensen's (parotid) duct"),
], widths=[MW/3]))
story.append(SP(0.2))
story.append(p("<i>Figures from Bailey & Love's Short Practice of Surgery 28th ed. — Fig 54.12 (a-g): Steps of superficial parotidectomy.</i>"))
story.append(SP())

story.append(section("COMPLICATIONS", NAVY))
story.append(comps_tbl([
    ["Immediate", "Haemorrhage / haematoma", "Return to theatre if expanding"],
    ["Immediate", "Facial nerve injury", "Temporary neuropraxia most common; permanent <1%"],
    ["Early", "Salivary fistula / wound infection", "Pressure dressing; antibiotics"],
    ["Late", "FREY'S SYNDROME", "Gustatory sweating. Aberrant parasympathetic reinnervation (CN IX via auriculotemporal N → sweat glands). Incidence up to 40%. Dx: Minor's starch-iodine test. Rx: Botulinum toxin."],
    ["Late", "Permanent facial palsy", "<1% with careful technique"],
    ["Late", "Ear lobe numbness", "Greater auricular N sacrifice (posterior branch preservation reduces this)"],
    ["Late", "Tumour recurrence", "High risk if pleomorphic adenoma capsule ruptured"],
]))
story.append(SP())

story.append(section("VIVA Q&A", NAVY))
story.append(viva("What is the most important structure during parotidectomy?",
    "The facial nerve (CN VII). It exits the stylomastoid foramen and divides into upper temporofacial and lower cervicofacial divisions within the gland. Damage causes facial palsy."))
story.append(viva("What is Frey's syndrome and how is it tested?",
    "Gustatory sweating after parotidectomy — parasympathetic fibres (CN IX via auriculotemporal nerve) aberrantly reinnervate skin sweat glands. Diagnosed with Minor's starch-iodine test (skin turns black over affected area while eating). Treated with botulinum toxin injection."))
story.append(viva("Why must the patient NOT be paralysed?",
    "To allow intraoperative facial nerve monitoring — touching the nerve causes visible facial muscle twitch."))
story.append(viva("What is Patey's faciovenous plane?",
    "The surgical plane defined by the retromandibular vein, which lies just deep to the facial nerve and acts as a safe dissection marker."))
story.append(viva("What happens if the pleomorphic adenoma capsule is breached?",
    "Satellite tumour deposits are seeded, with recurrence rates up to 40%. This is why formal parotidectomy is preferred over enucleation."))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# 2-4. THYROIDECTOMY
# ════════════════════════════════════════════════════════════════════════════
story.append(proc_header("2–4.", "THYROIDECTOMY  (Subtotal / Hemi / Total)", TEAL))
story.append(SP())

story.append(section("ANATOMY", TEAL))
story.append(anatomy_box([
    "THYROID:  Butterfly-shaped, ~20-25 g.  Right lobe + Left lobe + Isthmus (overlies rings 2-4)",
    "  Pyramidal lobe in ~80% (cephalad from isthmus, may reach hyoid).",
    "",
    "  BLOOD SUPPLY:",
    "    Superior thyroid artery  ←  External carotid (1st branch)",
    "    Inferior thyroid artery  ←  Thyrocervical trunk ← Subclavian",
    "    Thyroidea ima artery (10%)  ←  Aortic arch / brachiocephalic  [MIDLINE — hazard!]",
    "",
    "  CRITICAL NERVES:",
    "    RLN: tracheoesophageal groove. MOST VULNERABLE at Berry's ligament.",
    "      Right loops around subclavian  |  Left loops around aortic arch (longer).",
    "      Supplies ALL laryngeal muscles EXCEPT cricothyroid.",
    "      Non-recurrent RLN (0.5-1%) — right side only — anomalous subclavian artery.",
    "    EBSLN: runs with superior thyroid vessels → supplies cricothyroid.",
    "      Injury = loss of high-pitched voice.",
    "",
    "  PARATHYROIDS: 4 glands — all supplied by inferior thyroid artery branches.",
    "    Superior: behind upper pole (more constant).",
    "    Inferior: variable (can be in thymus / mediastinum).",
]))
story.append(SP())

story.append(section("INDICATIONS BY PROCEDURE", TEAL))
story.append(tbl(
    [["HEMITHYROIDECTOMY", "SUBTOTAL THYROIDECTOMY", "TOTAL THYROIDECTOMY"],
     ["Solitary thyroid nodule (benign/indeterminate FNA)",
      "Graves' disease (bilateral toxic) — antithyroid drugs failed",
      "Thyroid cancer (papillary >4 cm, follicular, medullary, anaplastic)"],
     ["Low-risk papillary Ca: T1/T2 <4 cm, unifocal",
      "Bilateral toxic multinodular goitre",
      "Large bilateral goitre with compressive symptoms"],
     ["Diagnostic lobectomy (Bethesda III/IV)",
      "Non-toxic bilateral large goitre",
      "Graves' (severe ophthalmopathy / relapse)"],
     ["Unilateral multinodular goitre",
      "Cosmetically disfiguring goitre",
      "Prophylactic: RET mutation (MEN2A/2B)"],
    ], [MW/3, MW/3, MW/3]
))
story.append(SP())

story.append(section("OPERATIVE STEPS WITH IMAGES", TEAL))
story.append(steps_tbl([
    ["Pre-op", "Preparation", "Euthyroid state (Lugol's iodine ×10d for Graves'). Laryngoscopy. Calcium/PTH baseline. USS ± FNA."],
    ["1", "Positioning", "Supine. Neck extended (shoulder roll + head ring). Arms tucked. 20° head-up tilt."],
    ["2", "Kocher incision", "Transverse collar incision 2-3 cm above sternal notch. Length 4-5 cm in a skin crease. Skin → subcutaneous → platysma."],
    ["3", "Flap elevation", "Subplatysmal flaps: superior to thyroid notch, inferior to sternal notch. Identify anterior jugular veins."],
    ["4", "Strap muscles", "Separate in midline (linea alba cervicis). May divide transversely if large goitre."],
    ["5", "Middle thyroid vein", "Ligate and divide (first vascular step). Allows medial rotation of lobe."],
    ["6", "Superior pole", "Ligate SUPERIOR THYROID ARTERY individually, close to gland (protects EBSLN). Divide superior thyroid veins."],
    ["7", "RLN identification", "Locate in tracheoesophageal groove. Trace to laryngeal entry. Neuromonitoring recommended. Most vulnerable at Berry's ligament."],
    ["8", "Parathyroid preservation", "Identify all 4 parathyroids. Ligate ITA lateral to gland (not at trunk) to preserve parathyroid supply. Devascularised → autotransplant to SCM."],
    ["9", "Berry's ligament", "Carefully divide with fine dissection — RLN closest and most at risk here."],
    ["10", "Gland removal", "HEMI: divide isthmus lateral to midline. SUBTOTAL: leave 3-5 g bilaterally. TOTAL: all visible tissue removed."],
    ["11", "Closure", "Valsalva to confirm haemostasis. Reapproximate strap muscles. Platysma + subcuticular skin closure. Drain only if needed."],
]))
story.append(SP())

# THYROID IMAGES
story.append(Paragraph("<b>Operative Illustrations — Thyroidectomy Steps</b>", sub_head))
story.append(img_row([
    ("thyroid_incision.png", "Step 2-5: Kocher incision and strap muscle separation; middle thyroid vein ligation (Sabiston Atlas)"),
    ("thyroid_ebsln.png", "Step 6: Superior pole vessels ligated individually close to gland to protect EBSLN (Sabiston Atlas)"),
]))
story.append(SP(0.3))
story.append(img_row([
    ("thyroid_superior_pole.png", "Step 6-7: Superior pole mobilisation and approach to inferior thyroid artery / RLN"),
    ("thyroid_mobilisation.png", "Step 7-8: Gland retracted medially — exposing RLN, ITA and parathyroids posteriorly"),
]))
story.append(SP(0.3))
story.append(img_row([
    ("thyroid_rln_parathyroid.png", "Step 7-8: RLN passes deep to ITA; parathyroids mobilised on vascular pedicle (Sabiston Atlas Fig 73.31)"),
    ("thyroid_berry_ligament.png", "Step 9: Dividing Berry's ligament — RLN at maximum vulnerability; inferior thyroid veins ligated (Sabiston Atlas Fig 73.32)"),
]))
story.append(SP(0.2))
story.append(p("<i>Figures from Sabiston Textbook of Surgery — operative illustrations of thyroidectomy technique.</i>"))
story.append(SP())

# Thyroglossal / ectopic image
story.append(Paragraph("<b>Thyroglossal Duct Anatomy & Ectopic Thyroid Sites</b>", sub_head))
story.append(img("thyroid_ectopic.png", width=MW*0.75,
    caption_txt="Schema of common midline ectopic thyroid masses and embryological elements of thyroid development (Sabiston Fig 73.1). Relevant to thyroglossal cyst excision."))
story.append(SP())

story.append(section("COMPLICATIONS", TEAL))
story.append(comps_tbl([
    ["EMERGENCY", "Neck haematoma (airway compression)", "Open wound AT BEDSIDE IMMEDIATELY. Emergency re-intubation / tracheostomy. Risk 0.5-1%."],
    ["EMERGENCY", "Bilateral RLN injury", "Immediate airway obstruction — emergency tracheostomy."],
    ["Early/Late", "Hypocalcaemia (hypoparathyroidism)", "Temporary up to 30%; permanent 1-3%. Perioral tingling, Chvostek's, Trousseau's. Rx: IV calcium gluconate → oral Ca + Vit D."],
    ["Early/Late", "Unilateral RLN injury", "Hoarseness, aspiration. Temporary neuropraxia resolves in weeks-months. Permanent 1%."],
    ["Early/Late", "EBSLN injury", "Loss of high-pitched voice / vocal fatigue."],
    ["Post-op", "Thyroid storm", "Inadequately prepared hyperthyroid patient — tachycardia, hyperpyrexia. Rx: beta-blockers + antithyroid drugs + steroids."],
    ["Late", "Hypothyroidism", "Expected after total thyroidectomy — lifelong levothyroxine."],
]))
story.append(SP())

story.append(section("VIVA Q&A", TEAL))
story.append(viva("Where is the RLN most at risk?",
    "At the ligament of Berry, where the nerve passes close to the posterior thyroid surface just before entering the larynx."))
story.append(viva("What is the non-recurrent laryngeal nerve?",
    "Rare variant (~0.5-1%), right side only, with anomalous right subclavian artery. The nerve passes directly from vagus to larynx — extremely vulnerable if not anticipated."))
story.append(viva("How do you protect the EBSLN?",
    "Ligate the superior thyroid artery as close to the gland as possible — not en masse, as the EBSLN runs with the vascular pedicle."))
story.append(viva("What is Chvostek's vs Trousseau's sign?",
    "Chvostek: tap facial nerve at parotid → ipsilateral facial twitch. Trousseau: BP cuff above systolic for 3 min → carpal spasm (more specific for hypocalcaemia)."))
story.append(viva("When is hemithyroidectomy oncologically adequate for thyroid cancer?",
    "Low-risk DTC: T1/T2 (<4 cm), unifocal, no extrathyroidal extension, no nodal/distant metastasis, no high-risk histology. ATA guidelines support lobectomy for these cases."))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# 5. SISTRUNK OPERATION
# ════════════════════════════════════════════════════════════════════════════
story.append(proc_header("5.", "THYROGLOSSAL CYST EXCISION — Sistrunk Operation", PURPLE))
story.append(SP())

story.append(section("EMBRYOLOGY & ANATOMY", PURPLE))
story.append(anatomy_box([
    "EMBRYOLOGY OF THYROGLOSSAL DUCT:",
    "  Week 4:  Endodermal pit (foramen cecum, tongue base) — thyroid primordium descends",
    "  Week 5:  Thyroglossal duct solid; starts obliteration",
    "  Week 7:  Hyoid bone forms — INTERSECTS the tract (divides into supra/infrahyoid segments)",
    "  Normal:  Duct obliterates completely",
    "  Abnormal: Epithelial remnant persists → THYROGLOSSAL DUCT CYST",
    "",
    "  CYST LOCATION (frequency):",
    "    Suprahyoid 25%  |  At hyoid 10%  |  Infrahyoid 65% [MOST COMMON]",
    "",
    "  CLINICAL SIGN: Moves on SWALLOWING + TONGUE PROTRUSION (tethered to foramen cecum)",
    "",
    "  DIFFERENTIAL: Dermoid cyst | Submental LN | Lipoma | Thyroid isthmus mass",
]))
story.append(SP())

story.append(section("INDICATIONS", PURPLE))
for t in ["Symptomatic thyroglossal duct cyst",
          "Recurrent infection (original indication — Sistrunk, 1920)",
          "Established or draining skin fistula",
          "Risk of malignancy (~1% harbour papillary thyroid carcinoma)",
          "Cosmetic / patient preference"]:
    story.append(bp(t))
story.append(SP(0.2))
story.append(warn_box("⚠  MANDATORY PRE-OP: Thyroid ultrasound to confirm orthotopic thyroid gland. "
    "If cyst = only functioning thyroid tissue, excision causes hypothyroidism."))
story.append(SP())

story.append(section("OPERATIVE STEPS", PURPLE))
story.append(steps_tbl([
    ["1", "Positioning", "Supine. Neck extended. GA."],
    ["2", "Incision", "Transverse skin crease incision over the cyst. If fistula present: ellipse around opening."],
    ["3", "Cyst dissection", "Carefully dissect cyst from surrounding tissue. AVOID RUPTURE — spillage causes recurrence. Preserve strap muscles."],
    ["4", "Tract tracing", "Trace tract superiorly toward hyoid. Take wide 1 cm core of tissue AROUND the tract (microscopic branches present in surrounding tissue)."],
    ["5", "HYOID RESECTION ← KEY STEP", "Detach supra- and infrahyoid muscles. Resect CENTRAL BODY of hyoid between greater horns. ESSENTIAL: failure to remove hyoid = ~80% recurrence vs <4% with Sistrunk."],
    ["6", "To foramen cecum", "Continue cephalad. Include a cuff of tongue base muscle. Trace to foramen cecum. Suture-ligate stump at tongue base."],
    ["7", "Closure", "Reapproximate suprahyoid muscles. Drain only if infected cyst. Subcuticular skin closure."],
]))
story.append(SP())

story.append(section("COMPLICATIONS", PURPLE))
story.append(comps_tbl([
    ["Most common", "Recurrence", "3-4% with proper Sistrunk. ~80% if hyoid NOT removed."],
    ["Early", "Wound infection", "Especially after previously infected cyst"],
    ["Late", "Hypoglossal nerve (CN XII) injury", "If dissection extends too lateral — tongue deviation"],
    ["Late", "Hypothyroidism", "If cyst was only functioning thyroid tissue"],
    ["Late", "Orocutaneous fistula", "If tongue base suture fails"],
    ["Rare", "Malignant change", "~1% — papillary thyroid carcinoma in cyst wall"],
]))
story.append(SP())

story.append(section("VIVA Q&A", PURPLE))
story.append(viva("What is the most important step in the Sistrunk operation?",
    "Excision of the central body of the hyoid bone. Reduces recurrence from ~80% to <4%."))
story.append(viva("Why does the cyst move with tongue protrusion?",
    "Tethered to the foramen cecum at the tongue base via the thyroglossal duct remnant."))
story.append(viva("Mandatory pre-op investigation?",
    "Thyroid ultrasound — to confirm presence of normal orthotopic thyroid. The cyst may be the patient's only thyroid tissue."))
story.append(viva("What malignancy arises in thyroglossal cysts?",
    "Papillary thyroid carcinoma in ~1%. Sistrunk procedure alone is usually sufficient when confined to the cyst."))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# 6. MODIFIED RADICAL NECK DISSECTION
# ════════════════════════════════════════════════════════════════════════════
story.append(proc_header("6.", "MODIFIED RADICAL NECK DISSECTION", BROWN))
story.append(SP())

story.append(section("ANATOMY — CERVICAL LYMPH NODE LEVELS (Robbins)", BROWN))
story.append(anatomy_box([
    "LEVEL I:   Submental (IA) + Submandibular (IB) — digastric bellies + mandible",
    "LEVEL II:  Upper Jugular — skull base to hyoid",
    "           IIA: anterior to SAN  |  IIB: posterior to SAN",
    "LEVEL III: Middle Jugular — hyoid to cricoid",
    "LEVEL IV:  Lower Jugular — cricoid to clavicle",
    "LEVEL V:   Posterior Triangle — SCM, trapezius, clavicle",
    "           VA: above SAN  |  VB: below SAN",
    "LEVEL VI:  Central compartment — between carotid arteries, hyoid to sternal notch",
    "",
    "DRAINAGE PATTERNS:",
    "  Oral cavity        → I, II, III (±IV)",
    "  Oropharynx/Larynx  → II, III, IV",
    "  Thyroid            → VI ± III, IV",
    "  Nasopharynx        → II, III, IV, V",
    "",
    "ELECTIVE ND THRESHOLD: > 15% risk of occult nodal metastasis",
]))
story.append(SP())

story.append(section("TYPES OF NECK DISSECTION", BROWN))
story.append(flowchart_box([
    "RADICAL (Crile, 1906):  Levels I-V + sacrifice SCM + IJV + SAN",
    "  — used only when structures directly invaded",
    "",
    "MODIFIED RADICAL (MRND):  Levels I-V + PRESERVE ≥1 of: SCM / IJV / SAN",
    "  Type I   = SAN preserved",
    "  Type II  = SAN + IJV preserved",
    "  Type III = SAN + IJV + SCM preserved (= Functional neck dissection)",
    "",
    "SELECTIVE:  Only at-risk nodal levels",
    "  Supraomohyoid ND (I-III)   → oral cavity",
    "  Lateral ND (II-IV)          → oropharynx / larynx / hypopharynx",
    "  Central ND (VI)             → thyroid cancer",
    "",
    "EXTENDED:  Additional structures involved (carotid, skin, mediastinum)",
], bg=colors.HexColor("#fff3e0"), border=BROWN))
story.append(SP())

story.append(section("OPERATIVE STEPS WITH IMAGE", BROWN))
story.append(steps_tbl([
    ["1", "Positioning", "Supine. Head turned contralateral. Shoulder roll."],
    ["2", "Incision", "MacFee (2 parallel horizontal lines — avoids tip necrosis). AVOID Y or T-type."],
    ["3", "Flap elevation", "Subplatysmal flaps. Superior to mandible. Inferior to clavicle. Preserve marginal mandibular nerve in upper flap."],
    ["4", "Level I", "Identify marginal mandibular nerve. Remove submandibular gland + perifacial nodes. Ligate Wharton's duct."],
    ["5", "Levels II-IV (Jugular chain)", "Boundaries: digastric/mastoid (sup) → clavicle (inf) → strap muscles (ant) → posterior SCM (post). Depth: cervical sensory rootlets / deep cervical fascia. Sweep en bloc."],
    ["6", "SAN identification", "Find CN XI above Erb's point (upper/middle 1/3 posterior SCM border). Trace to trapezius. PRESERVE."],
    ["7", "Level V", "Remove nodes between trapezius (post), SCM (ant), clavicle (inf). Preserve SAN throughout."],
    ["8", "Level VI (thyroid Ca)", "Between carotid arteries. Preserve both RLNs. Identify parathyroids."],
    ["9", "Closure", "Control thoracic duct (left side) if leak. 2 × suction drains. Platysma + skin."],
]))
story.append(SP())

# NECK DISSECTION IMAGE
story.append(Paragraph("<b>Intraoperative Photograph — Selective Neck Dissection (Levels II-IV)</b>", sub_head))
story.append(img("neck_dissection_intraop.png", width=MW*0.85,
    caption_txt="Intraoperative photo after right selective levels II-IV neck dissection. Preserved structures: internal jugular vein (IJV), "
    "common carotid artery (CCA), spinal accessory nerve (large arrow), SCM, cervical sensory rootlets (small arrows). "
    "Forceps highlights external carotid artery. Permanent tracheostomy visible (laryngectomy patient). "
    "(Mulholland & Greenfield Fig 41.10)"))
story.append(SP())

story.append(section("KEY STRUCTURES TO PRESERVE", BROWN))
story.append(tbl(
    [["Structure", "Location / Landmark", "Injury Consequence"],
     ["Spinal Accessory N (CN XI)", "Exits SCM at Erb's point → posterior triangle → trapezius", "Shoulder drop, arm abduction <90°, scapular winging"],
     ["Marginal Mandibular N (VII)", "Below mandible in upper flap near facial artery", "Ipsilateral lip depressor weakness"],
     ["Phrenic Nerve", "On anterior scalene deep to deep cervical fascia", "Ipsilateral diaphragm paralysis"],
     ["Brachial Plexus", "Deep to posterior triangle (deep fascial layer)", "Arm weakness / numbness"],
     ["Vagus Nerve", "In carotid sheath — between IJV and CCA", "Voice changes, cardiac arrhythmias"],
     ["Hypoglossal N (CN XII)", "Level IB/II — hooks around occipital artery", "Tongue deviation ipsilaterally"],
     ["Thoracic Duct", "LEFT neck only — enters IJV-subclavian junction", "Chylous fistula (milky drain output)"],
    ], [3*cm, 4.5*cm, MW-7.5*cm]
))
story.append(SP())

story.append(section("COMPLICATIONS", BROWN))
story.append(comps_tbl([
    ["Nerve", "CN XI injury (shoulder drop)", "Most common permanent functional deficit after MRND"],
    ["Nerve", "Marginal mandibular N", "Lip asymmetry"],
    ["Vascular", "Carotid blowout syndrome", "Post-RT + wound breakdown — life-threatening"],
    ["Vascular", "Haematoma / air embolism", "IJV injury — occlude immediately"],
    ["Lymphatic", "Chylous fistula", "Conservative: MCT diet + pressure. Surgical if >500 mL/day."],
    ["Lymphatic", "Facial oedema", "Especially bilateral dissections"],
    ["FATAL", "Bilateral IJV ligation", "Cerebral venous hypertension — NEVER ligate both simultaneously"],
    ["Other", "Horner's syndrome", "Sympathetic chain: ptosis + miosis + anhidrosis"],
]))
story.append(SP())

story.append(section("VIVA Q&A", BROWN))
story.append(viva("Difference between radical and modified radical neck dissection?",
    "Radical ND (Crile 1906) removes levels I-V + SCM + IJV + spinal accessory nerve. MRND preserves one or more of these three structures. Oncologically equivalent to radical ND for most N+ head and neck primaries."))
story.append(viva("Why is bilateral radical neck dissection dangerous?",
    "Bilateral IJV ligation causes cerebral venous hypertension, fatal cerebral oedema, and blindness. Must be staged with at least 3-6 weeks between sides."))
story.append(viva("What is Erb's point?",
    "Junction of upper and middle thirds of the posterior SCM border — where CN XI exits and cutaneous cervical nerves (C2-C4) converge. Critical landmark for SAN preservation."))
story.append(viva("What is a chylous fistula and how is it managed?",
    "Thoracic duct (left) or right lymphatic duct injury — milky, triglyceride-rich drain output (>110 mg/dL). Conservative: low-fat / MCT diet + octreotide + pressure. Surgical ligation if >500 mL/day or not resolving."))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# 7. TRACHEOSTOMY
# ════════════════════════════════════════════════════════════════════════════
story.append(proc_header("7.", "TRACHEOSTOMY", GREEN))
story.append(SP())

story.append(section("ANATOMY", GREEN))
story.append(anatomy_box([
    "TRACHEA: ~10-12 cm.  16-20 C-shaped cartilaginous rings.",
    "",
    "KEY LEVELS:",
    "  Cricoid cartilage    → C6  (highest safe level — NEVER above cricoid)",
    "  Thyroid isthmus      → overlies rings 2-4",
    "  TRACHEOSTOMY ENTRY  → rings 2-3 or 3-4  [SAFE ZONE]",
    "  Sternal notch        → T2  (below = brachiocephalic vessel danger)",
    "",
    "LAYERS ENCOUNTERED (anterior midline):",
    "  Skin → Subcutaneous fat → Platysma → Deep cervical fascia",
    "  → Strap muscles (separate midline) → Thyroid isthmus",
    "  → Pretracheal fat → Tracheal rings",
    "",
    "VASCULAR DANGERS:",
    "  Anterior jugular veins — midline jugular arch — ligate if encountered",
    "  Thyroidea ima artery (10%) — midline from aortic arch  [MAJOR BLEEDING RISK]",
    "  Brachiocephalic artery — RIGHT of midline, rises anterior to trachea (low incisions)",
    "",
    "TOO HIGH (subglottic):  → Subglottic stenosis",
    "TOO LOW (ring 5+):      → Brachiocephalic artery erosion / tracheo-innominate fistula",
]))
story.append(SP())

story.append(section("INDICATIONS & CONTRAINDICATIONS", GREEN))
story.append(tbl(
    [["INDICATIONS", "RELATIVE CONTRAINDICATIONS"],
     ["Upper airway obstruction:\n• Maxillofacial trauma\n• Angioedema\n• Laryngeal / pharyngeal tumours\n• Ludwig's angina",
      "Recent anterior neck surgery (<7 days)"],
     ["Neurological airway failure:\n• Brain injury (acute/progressive)\n• Spinal cord injury\n• Severe agitation / delirium\n• Prolonged altered mental status",
      "High ventilator settings:\nFiO2 >50% | PEEP >10 cmH2O"],
     ["Prolonged mechanical ventilation\n(>7-10 days anticipated)",
      "Haemodynamic instability\nSignificant coagulopathy"],
     ["Difficult / failed airway",
      "Elevated intracranial pressure"],
     ["Weaning / bronchial toilet",
      "Local infection or tumour at site\nPredicted early mortality"],
    ], [MW/2, MW/2]
))
story.append(SP())

story.append(section("OPERATIVE STEPS — OPEN SURGICAL TRACHEOSTOMY", GREEN))
story.append(steps_tbl([
    ["Pre-op", "Preparation", "ETT in situ. Pre-oxygenate 100% O2. IV access. Anaesthetist scrubbed in. Confirm rings by palpation."],
    ["1", "Positioning", "Supine. Neck extended (shoulder roll). Cricoid and sternal notch palpated and marked."],
    ["2", "Incision", "Horizontal incision 2 cm below cricoid cartilage, 2-3 cm length in skin crease. Vertical midline for emergencies."],
    ["3", "Dissection to trachea", "Divide subcutaneous fat. Retract platysma. Separate strap muscles in midline. Retract thyroid isthmus superiorly OR divide and ligate it. Confirm trachea by palpation."],
    ["4", "Confirm trachea", "Aspirate air with syringe before incising. Confirm by feel of cartilaginous rings."],
    ["5", "Tracheal entry options", "(1) Vertical incision rings 2-3 to 3-4 [classical]. (2) Cruciate incision. (3) Bjork flap — inferior U-based, sutured to skin [aids tube change, risk tracheomalacia]. (4) Window excision (Grillo). Anaesthetist withdraws ETT to just above entry."],
    ["6", "Tube insertion", "Insert cuffed tracheostomy tube. Inflate cuff. CONFIRM: capnography + bilateral chest auscultation + SpO2 rise."],
    ["7", "Fixation", "Neck tapes. Suture flanges to skin. Loose skin closure around tube. Apply dressing."],
]))
story.append(SP())

story.append(section("PERCUTANEOUS DILATATIONAL TRACHEOSTOMY (PDT)", GREEN))
for t in [
    "Seldinger technique under bronchoscopic guidance in ICU (Ciaglia technique, 1985).",
    "ETT withdrawn to subglottis under bronchoscopic vision.",
    "Needle puncture → guidewire → serial dilators → tracheostomy tube over wire.",
    "<b>Advantages:</b> bedside ICU, decreased wound infection, lower cost, equivalent safety to open.",
    "<b>Disadvantages:</b> not for difficult anatomy, coagulopathy, obesity, paediatrics, emergency.",
]:
    story.append(bp(t))
story.append(SP())

story.append(section("COMPLICATIONS", GREEN))
story.append(comps_tbl([
    ["Immediate", "Haemorrhage", "Thyroid vessels, anterior jugular vein, thyroidea ima artery"],
    ["Immediate", "Oesophageal placement", "MUST confirm with capnography before securing tube"],
    ["Immediate", "Pneumothorax", "Especially in children (high mediastinum). Check CXR post-op."],
    ["Immediate", "Hypoxia / loss of airway", "During procedure — have ENT surgeon present + Plan B ready"],
    ["Early", "Tube displacement (1st 3-5d)", "Tract immature — do NOT attempt blind re-insertion; intubate orally"],
    ["Early", "Subcutaneous emphysema", "Air tracking in pretracheal fascia"],
    ["Early", "Wound infection / haematoma", "Antibiotics; drainage"],
    ["Late", "SUBGLOTTIC STENOSIS", "Most serious late complication. High placement, cuff overinflation (>30 mmHg), excess tracheal resection. Rx: dilation, laser, tracheal resection + anastomosis."],
    ["Late", "TRACHEO-INNOMINATE FISTULA", "FATAL — brachiocephalic artery erosion (tube too low). Sentinel bleed at 3-6 weeks. Emergency: hyperinflate cuff + digital pressure through stoma + emergency OR."],
    ["Late", "Tracheo-oesophageal fistula", "Posterior wall erosion from cuff over-pressure"],
    ["Late", "Tracheomalacia", "Cartilage destruction — expiratory collapse"],
    ["Late", "Persistent tracheocutaneous fistula", "After decannulation — surgical closure if persistent"],
]))
story.append(SP())

story.append(section("VIVA Q&A", GREEN))
story.append(viva("Between which tracheal rings is tracheostomy made?",
    "Between the 2nd and 3rd, or 3rd and 4th tracheal rings. Above ring 2 risks subglottic stenosis. Below ring 5 risks brachiocephalic artery erosion."))
story.append(viva("What is the most serious late complication of tracheostomy?",
    "Tracheo-innominate (brachiocephalic) artery fistula — presents as sentinel bleed 3-6 weeks post-op. Management: hyperinflate cuff, digital compression through stoma, emergency surgery."))
story.append(viva("What is a Bjork flap?",
    "Inferior-based U-shaped flap of tracheal anterior wall sutured to skin — facilitates emergency re-insertion if tube dislodges, but risks tracheomalacia."))
story.append(viva("Advantages of PDT over open tracheostomy?",
    "Decreased wound infection rate, lower cost, bedside ICU performance, equivalent mortality and complication rates. Not suitable for difficult anatomy, coagulopathy, emergency, or paediatric cases."))
story.append(viva("How do you manage accidental decannulation in the first 5 days?",
    "Tract not yet mature — do NOT attempt blind re-insertion through stoma. Oral intubation first, then senior help for formal re-tracheostomy. After 7 days, tube can be replaced through the mature stoma."))
story.append(viva("What is the thyroidea ima artery?",
    "Present in ~10% — arises from aortic arch / brachiocephalic, runs in the midline superiorly. Directly in the tracheostomy field — can cause major bleeding if not recognised."))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# SUMMARY PAGE
# ════════════════════════════════════════════════════════════════════════════
story.append(proc_header("SUMMARY", "HIGH-YIELD QUICK REFERENCE", DKSLATE))
story.append(SP())

story.append(section("PROCEDURE COMPARISON TABLE", DKSLATE))
story.append(tbl(
    [["Procedure", "Key Nerve at Risk", "Critical Step", "Classic Complication"],
     ["Superficial Parotidectomy", "CN VII (Facial)", "Identify FN at tragal pointer", "Frey's Syndrome"],
     ["Subtotal Thyroidectomy", "RLN + EBSLN", "Identify RLN before ITA ligation", "Hypocalcaemia"],
     ["Hemithyroidectomy", "Ipsilateral RLN", "Divide isthmus lateral to midline", "Hypothyroidism (30%)"],
     ["Total Thyroidectomy", "Bilateral RLN + parathyroids", "Preserve all 4 parathyroids", "Permanent hypoparathyroidism"],
     ["Sistrunk Operation", "CN XII (Hypoglossal)", "Remove central hyoid body", "Recurrence if hyoid spared"],
     ["MRND", "CN XI (Spinal Accessory)", "Identify SAN at Erb's point", "Shoulder drop"],
     ["Tracheostomy", "Brachiocephalic artery (low)", "Enter between rings 2-4", "Tracheo-innominate fistula"],
    ], [4.5*cm, 4*cm, 4.5*cm, MW-13*cm]
))
story.append(SP())

story.append(section("DECISION FLOWCHART", DKSLATE))
story.append(flowchart_box([
    "PAROTID MASS",
    "  Superficial lobe only (benign)            → SUPERFICIAL PAROTIDECTOMY",
    "  Deep + superficial, FN intact              → TOTAL CONSERVATIVE PAROTIDECTOMY",
    "  FN involved / malignant / N+ neck          → RADICAL PAROTIDECTOMY + NECK DISSECTION",
    "",
    "THYROID PATHOLOGY",
    "  Unilateral nodule / indeterminate FNA      → HEMITHYROIDECTOMY",
    "  Bilateral Graves / bilateral large goitre  → SUBTOTAL THYROIDECTOMY",
    "  Cancer >4cm / bilateral / medullary        → TOTAL THYROIDECTOMY",
    "  RET mutation (MEN2A / MEN2B)               → PROPHYLACTIC TOTAL THYROIDECTOMY",
    "",
    "MIDLINE NECK MASS (moves on swallowing + tongue protrusion, child/young adult)",
    "  Confirm orthotopic thyroid on USS then     → SISTRUNK OPERATION",
    "    KEY: Remove cyst + tract + central hyoid body",
    "",
    "HEAD & NECK MALIGNANCY — NECK",
    "  N+ neck                                    → MODIFIED RADICAL ND (Levels I-V)",
    "  N0 oral cavity (>15% occult risk)          → SELECTIVE ND (Levels I-III)",
    "  N0 oropharynx/larynx (>15%)                → SELECTIVE ND (Levels II-IV)",
    "  Thyroid cancer                             → CENTRAL ND (Level VI) ± lateral",
    "",
    "AIRWAY",
    "  Emergency                                  → OPEN SURGICAL TRACHEOSTOMY",
    "  Elective ICU / prolonged ventilation       → PERCUTANEOUS DILATATIONAL TRACHEOSTOMY",
], bg=LTBLUE, border=NAVY))
story.append(SP())

story.append(section("MEMORABLE NUMBERS", DKSLATE))
story.append(tbl(
    [["Fact", "Number / Detail"],
     ["Frey's syndrome incidence after parotidectomy", "Up to 40%"],
     ["Pleomorphic adenoma: % of all parotid tumours", "~70%"],
     ["Recurrence of thyroglossal cyst WITHOUT hyoid removal", "~80%"],
     ["Recurrence of thyroglossal cyst WITH Sistrunk (hyoid removed)", "<4%"],
     ["Malignancy in thyroglossal cyst (type)", "~1% — papillary thyroid carcinoma"],
     ["Permanent hypoparathyroidism after total thyroidectomy", "1-3%"],
     ["Temporary hypocalcaemia after total thyroidectomy", "Up to 30%"],
     ["Permanent RLN injury after thyroidectomy", "~1%"],
     ["Non-recurrent laryngeal nerve incidence", "0.5-1% (right side only)"],
     ["Neck haematoma after thyroidectomy", "0.5-1%"],
     ["Tracheo-innominate fistula sentinel bleed timing", "3-6 weeks post-tracheostomy"],
     ["Thyroidea ima artery prevalence", "~10%"],
     ["Elective neck dissection threshold", ">15% occult nodal metastasis risk"],
     ["Chylous fistula surgical threshold", ">500 mL/day or not responding to conservative Rx"],
     ["Neck dissection first described by", "George Crile, 1906 (Radical ND)"],
     ["Sistrunk operation first described", "1920"],
     ["Tracheostomy safe zone — tracheal rings", "Rings 2-4 (between cricoid and ring 5)"],
    ], [8*cm, MW-8*cm]
))

story.append(SP(0.5))
story.append(p("<i>Sources: Scott-Brown's Otorhinolaryngology Head & Neck Surgery; Sabiston Textbook of Surgery; "
    "Bailey & Love's Short Practice of Surgery (28th ed.); Mulholland & Greenfield's Surgery (7th ed.)</i>"))

# ── Build ─────────────────────────────────────────────────────────────────
doc.build(story)
print(f"PDF created: {OUTPUT}")
Running Command

cd /home/daytona/workspace/head-neck-surgery && python3 generate_pdf_with_images.py 2>&1

Editing File

~/head-neck-surgery/generate_pdf_with_images.py

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/head-neck-surgery/generate_pdf_with_images.py'
Running Command

cd /home/daytona/workspace/head-neck-surgery && python3 generate_pdf_with_images.py 2>&1

Running Command

ls -lh /home/daytona/workspace/head-neck-surgery/Head_Neck_Surgery_WITH_IMAGES.pdf

Your PDF with operative images is ready — 17 MB, fully illustrated!

Head Neck Surgery WITH IMAGES

PDF Document · PDF


What's included with images:
ProcedureImages Embedded
Superficial Parotidectomy7 operative photos (a-g): incision planning, subplatysmal flap, greater auricular nerve, tragal pointer + digastric landmarks, Patey's plane dissection, centripetal nerve dissection, parotid duct ligation
Thyroidectomy (2-4)6 operative illustrations: Kocher incision + strap muscle separation, superior pole mobilisation, EBSLN protection, RLN + ITA + parathyroid anatomy, Berry's ligament division
Thyroglossal Cyst (Sistrunk)Ectopic thyroid / thyroglossal duct anatomy diagram
MRNDIntraoperative photo of completed selective neck dissection (levels II-IV) showing preserved IJV, CCA, spinal accessory nerve
All proceduresColour-coded headers, anatomy boxes, operative steps tables, complications tables, viva Q&A, decision flowchart, summary comparison table
All images are sourced directly from Bailey & Love (28th ed.), Sabiston Textbook of Surgery, and Mulholland & Greenfield's Surgery textbook libraries.
This is a shared conversation. Sign in to Orris to start your own chat.