Practical exam oriented viva Questions which are frequently asked and tricky to remember Creat one pdf for general surgery FAQ VIva

Reading File
Running Command

ls -la /home/daytona/workspace/ 2>/dev/null || echo "workspace empty or not found"

Running Command

mkdir -p /home/daytona/workspace/gen-surgery-viva

Writing File

~/gen-surgery-viva/generate_viva.py

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

OUTPUT_PATH = "/home/daytona/workspace/gen-surgery-viva/General_Surgery_FAQ_Viva.pdf"

# ── Colour palette ──────────────────────────────────────────────────────────
DARK_BLUE   = colors.HexColor("#1A2F5E")
MED_BLUE    = colors.HexColor("#2D5F8A")
LIGHT_BLUE  = colors.HexColor("#D6E8F5")
ACCENT      = colors.HexColor("#E8F0FA")
GOLD        = colors.HexColor("#C9A84C")
RED_ALERT   = colors.HexColor("#C0392B")
GREEN_OK    = colors.HexColor("#1A7A4A")
LIGHT_GREY  = colors.HexColor("#F5F5F5")
MID_GREY    = colors.HexColor("#888888")
WHITE       = colors.white

PAGE_W, PAGE_H = A4

# ── Page numbering ───────────────────────────────────────────────────────────
def add_page_number(canvas_obj, doc):
    canvas_obj.saveState()
    canvas_obj.setFont("Helvetica", 8)
    canvas_obj.setFillColor(MID_GREY)
    canvas_obj.drawString(cm, 1.0 * cm, "General Surgery FAQ Viva  |  Practical Exam Edition")
    canvas_obj.drawRightString(PAGE_W - cm, 1.0 * cm, f"Page {doc.page}")
    canvas_obj.setStrokeColor(LIGHT_BLUE)
    canvas_obj.setLineWidth(0.5)
    canvas_obj.line(cm, 1.5 * cm, PAGE_W - cm, 1.5 * cm)
    canvas_obj.restoreState()

# ── Styles ───────────────────────────────────────────────────────────────────
styles = getSampleStyleSheet()

def S(name, **kw):
    return ParagraphStyle(name, **kw)

title_style = S("CoverTitle",
    fontSize=30, leading=36, textColor=WHITE,
    fontName="Helvetica-Bold", alignment=TA_CENTER)

cover_sub = S("CoverSub",
    fontSize=14, leading=18, textColor=LIGHT_BLUE,
    fontName="Helvetica", alignment=TA_CENTER)

section_head = S("SecHead",
    fontSize=14, leading=18, textColor=WHITE,
    fontName="Helvetica-Bold", alignment=TA_LEFT,
    spaceAfter=2)

q_style = S("QStyle",
    fontSize=10.5, leading=14, textColor=DARK_BLUE,
    fontName="Helvetica-Bold", spaceBefore=6, spaceAfter=2)

a_style = S("AStyle",
    fontSize=10, leading=14, textColor=colors.black,
    fontName="Helvetica", spaceBefore=1, spaceAfter=4,
    leftIndent=10)

tip_style = S("TipStyle",
    fontSize=9.5, leading=13, textColor=GREEN_OK,
    fontName="Helvetica-BoldOblique", leftIndent=8)

warn_style = S("WarnStyle",
    fontSize=9.5, leading=13, textColor=RED_ALERT,
    fontName="Helvetica-BoldOblique", leftIndent=8)

body_style = S("BodyStyle",
    fontSize=10, leading=14, textColor=colors.black,
    fontName="Helvetica", spaceAfter=4)

toc_title = S("TocTitle",
    fontSize=16, leading=20, textColor=DARK_BLUE,
    fontName="Helvetica-Bold", spaceAfter=8)

toc_item = S("TocItem",
    fontSize=11, leading=16, textColor=MED_BLUE,
    fontName="Helvetica", leftIndent=10)

# ── Helper builders ──────────────────────────────────────────────────────────
def section_banner(title, subtitle=""):
    data = [[Paragraph(title, section_head)]]
    if subtitle:
        data[0].append(Paragraph(f"<font color='#D6E8F5' size='9'>{subtitle}</font>", a_style))
    t = Table([[Paragraph(title, section_head)]], colWidths=[PAGE_W - 2*cm])
    t.setStyle(TableStyle([
        ("BACKGROUND",  (0,0), (-1,-1), DARK_BLUE),
        ("TOPPADDING",  (0,0), (-1,-1), 8),
        ("BOTTOMPADDING",(0,0), (-1,-1), 8),
        ("LEFTPADDING", (0,0), (-1,-1), 12),
        ("RIGHTPADDING",(0,0), (-1,-1), 8),
        ("ROUNDEDCORNERS", [4]),
    ]))
    return t

def qa_block(q, a, tip=None, warn=None):
    elems = []
    elems.append(Paragraph(f"Q. {q}", q_style))
    if isinstance(a, list):
        for line in a:
            elems.append(Paragraph(f"• {line}", a_style))
    else:
        elems.append(Paragraph(f"A. {a}", a_style))
    if tip:
        elems.append(Paragraph(f"Tip: {tip}", tip_style))
    if warn:
        elems.append(Paragraph(f"Note: {warn}", warn_style))
    elems.append(HRFlowable(width="100%", thickness=0.4, color=LIGHT_BLUE, spaceAfter=4))
    return KeepTogether(elems)

def mnemonic_box(title, items):
    rows = [[Paragraph(title, S("Mn", fontSize=10, fontName="Helvetica-Bold", textColor=DARK_BLUE))]]
    for item in items:
        rows.append([Paragraph(f"  {item}", S("Mi", fontSize=9.5, fontName="Helvetica", textColor=colors.black, leading=13))])
    t = Table(rows, colWidths=[PAGE_W - 2*cm])
    t.setStyle(TableStyle([
        ("BACKGROUND",  (0,0), (0,0), LIGHT_BLUE),
        ("BACKGROUND",  (0,1), (-1,-1), ACCENT),
        ("TOPPADDING",  (0,0), (-1,-1), 4),
        ("BOTTOMPADDING",(0,0), (-1,-1), 4),
        ("LEFTPADDING", (0,0), (-1,-1), 10),
        ("BOX",         (0,0), (-1,-1), 0.8, MED_BLUE),
        ("LINEBELOW",   (0,0), (0,0), 0.8, MED_BLUE),
    ]))
    return t

def two_col_table(headers, rows):
    col_w = [(PAGE_W - 2*cm) * 0.45, (PAGE_W - 2*cm) * 0.55]
    data = [[Paragraph(h, S("th", fontSize=10, fontName="Helvetica-Bold", textColor=WHITE)) for h in headers]]
    for row in rows:
        data.append([Paragraph(str(c), S("td", fontSize=9.5, fontName="Helvetica", leading=13)) for c in row])
    t = Table(data, colWidths=col_w)
    t.setStyle(TableStyle([
        ("BACKGROUND",  (0,0), (-1,0), MED_BLUE),
        ("ROWBACKGROUNDS",(0,1),(-1,-1),[WHITE, LIGHT_GREY]),
        ("TOPPADDING",  (0,0), (-1,-1), 4),
        ("BOTTOMPADDING",(0,0), (-1,-1), 4),
        ("LEFTPADDING", (0,0), (-1,-1), 6),
        ("GRID",        (0,0), (-1,-1), 0.4, colors.HexColor("#BBBBBB")),
        ("VALIGN",      (0,0), (-1,-1), "TOP"),
    ]))
    return t

# ═══════════════════════════════════════════════════════════════════════════
# CONTENT DATA
# ═══════════════════════════════════════════════════════════════════════════

sections = []   # list of (section_title, [story elements])

# ── 1. HERNIA ──────────────────────────────────────────────────────────────
hernia = []
hernia.append(section_banner("1. HERNIA", "Inguinal • Femoral • Umbilical • Incisional"))
hernia.append(Spacer(1, 4))

hernia.append(qa_block(
    "What is Hesselbach's triangle and its boundaries?",
    ["Medially: Lateral border of rectus abdominis",
     "Inferiorly: Inguinal ligament (Poupart's)",
     "Laterally: Inferior epigastric vessels",
     "Direct hernias pass through this triangle medial to inferior epigastric vessels"],
    tip="RIME mnemonic: Rectus, Inguinal ligament, Mid-epigastric vessels"
))

hernia.append(qa_block(
    "Distinguish direct vs indirect inguinal hernia - key surgical points",
    ["Indirect: Passes through deep ring (lateral to inferior epigastric vessels), covered by all 3 spermatic fascias, enters scrotum, congenital (patent processus vaginalis)",
     "Direct: Passes through Hesselbach's triangle (medial to vessels), covered only by transversalis fascia + peritoneum, rarely enters scrotum, acquired (weak posterior wall)",
     "On finger in ring: Direct reduces straight back; Indirect returns from lateral side"],
    tip="'DIrect = medial; inDIrect = lateral to epigastric'"
))

hernia.append(qa_block(
    "Why is femoral hernia more prone to strangulation than inguinal hernia?",
    "The femoral canal has rigid unyielding walls on 3 sides (inguinal ligament anteriorly, lacunar ligament medially, Cooper's ligament posteriorly and pectineal fascia laterally), making it the narrowest of all hernia orifices - hence highest rate of strangulation (~40%).",
    warn="Femoral hernia = surgical emergency more often; always operate promptly."
))

hernia.append(qa_block(
    "What is a Richter's hernia? Why is it dangerous?",
    "Only part of the bowel wall (usually antimesenteric) is caught in the hernial sac - NOT the full lumen. Dangerous because: no bowel obstruction occurs (lumen intact), so no colic/vomiting - patient presents late with gangrenous patch of bowel only.",
    warn="Obstruction signs may be absent despite strangulation - missed easily!"
))

hernia.append(qa_block(
    "Enumerate the contents of the inguinal canal",
    ["Males: Spermatic cord (vas deferens, testicular/cremasteric/vasal vessels, genital branch of genitofemoral nerve, lymphatics, processus vaginalis remnant)",
     "Females: Round ligament of uterus + ilioinguinal nerve (in both sexes)"],
    tip="'3 arteries, 3 fascial layers, 3 nerves' - learn the spermatic cord layers"
))

hernia.append(qa_block(
    "What is Lichtenstein repair? Name the mesh used.",
    ["Tension-free mesh repair - gold standard for inguinal hernia",
     "Polypropylene mesh (non-absorbable) placed in preperitoneal/inguinal space",
     "Recurrence <1% vs 10-15% with tissue repairs",
     "Can be done under local anaesthesia",
     "Slit in mesh accommodates spermatic cord"],
    tip="'Lichtenstein = tension-free mesh' - always say this first"
))

hernia.append(qa_block(
    "What is a sliding hernia (hernia-en-glissade)?",
    "Part of the wall of the hernial sac is formed by a viscus (caecum on the right, sigmoid colon on the left). The viscus has 'slid' down, so its posterior wall forms part of the sac. Risk: inadvertent injury to bowel during sac dissection.",
    warn="Never blindly ligate the sac base - check for sliding viscus first"
))

hernia.append(mnemonic_box("Hernia Eponyms - High Yield Viva",
    ["Littre's hernia - Meckel's diverticulum in sac",
     "Maydl's hernia (W-hernia) - 2 loops of bowel; middle loop strangulates inside abdomen",
     "Amyand's hernia - Appendix in inguinal hernia sac",
     "Obturator hernia - Howship-Romberg sign (pain inner thigh, medial rotation relieves)",
     "Spigelian hernia - Through Spigelian fascia, lateral to rectus; 'hidden' hernia",
     "Richter's hernia - Partial bowel wall only in sac",
     "Pantaloon hernia - Combined direct + indirect hernia straddles epigastric vessels"]))

hernia.append(Spacer(1, 6))
sections.append(("1. Hernia", hernia))

# ── 2. THYROID ────────────────────────────────────────────────────────────
thyroid = []
thyroid.append(section_banner("2. THYROID GLAND", "Swellings • Surgical Anatomy • Thyroidectomy"))
thyroid.append(Spacer(1, 4))

thyroid.append(qa_block(
    "Why does a thyroid swelling move on swallowing?",
    "The thyroid gland is enclosed within the pretracheal fascia (investing layer of deep cervical fascia). When swallowing, the larynx and trachea move upward and the fascia - along with the attached thyroid - is carried upward with it.",
    tip="Key word: 'pretracheal fascia' attachment - examiner loves this"
))

thyroid.append(qa_block(
    "Enumerate the relations of the recurrent laryngeal nerve (RLN)",
    ["Lies in the tracheoesophageal groove",
     "Crosses the inferior thyroid artery (may pass anterior, posterior, or between branches)",
     "Enters larynx deep to lower border of inferior constrictor at cricothyroid joint",
     "Right RLN: hooks around right subclavian artery (more oblique course, more at risk)",
     "Left RLN: hooks around arch of aorta (longer course in chest)"],
    warn="RLN injury causes hoarseness (unilateral) or respiratory distress (bilateral)"
))

thyroid.append(qa_block(
    "What is Berry's ligament (suspensory ligament of Berry)?",
    "Dense condensation of pretracheal fascia that firmly anchors the posteromedial thyroid to the cricoid cartilage and upper tracheal rings. The RLN passes in close proximity or through it - this is the most common site of RLN injury during thyroidectomy.",
    warn="NEVER clamp blindly near Berry's ligament"
))

thyroid.append(qa_block(
    "What are the clinical features of RLN vs superior laryngeal nerve (SLN) injury?",
    ["RLN injury (unilateral): Hoarseness, weak voice",
     "RLN injury (bilateral): Respiratory distress, stridor - EMERGENCY tracheostomy",
     "External branch of SLN injury: Loss of high-pitched phonation (cricothyroid paralysis) - 'singer's nerve'",
     "Internal branch of SLN: Loss of sensation above vocal cords - aspiration risk"],
    tip="SLN injury - ask 'can you sing a high note?' - Semon's law for progressive lesions"
))

thyroid.append(qa_block(
    "What is the blood supply of the parathyroid glands and why does it matter during thyroidectomy?",
    "Both superior and inferior parathyroids are predominantly supplied by the inferior thyroid artery. During thyroidectomy, the inferior thyroid artery must be ligated close to the gland (not at its main trunk) to preserve parathyroid blood supply. Inadvertent parathyroidectomy or devascularization causes hypoparathyroidism (hypocalcemia - tetany).",
    tip="Tetany post-thyroidectomy = hypoparathyroidism until proven otherwise"
))

thyroid.append(qa_block(
    "What is Pemberton's sign?",
    "Elevation of both arms above the head causes flushing of face, cyanosis, and raised JVP (due to thoracic inlet obstruction) - seen in retrosternal goitre. The goitre impacts the thoracic inlet as the arms are raised.",
    tip="'Arms up = face goes red and engorged' = retrosternal goitre"
))

thyroid.append(qa_block(
    "Classify thyroid cancers by frequency and prognosis",
    ["Papillary (80%): Best prognosis; lymphatic spread; psammoma bodies; RET/PTC mutation",
     "Follicular (10%): Haematogenous spread (bone, lung); capsular/vascular invasion defines it",
     "Hurthle cell: Variant of follicular; radioresistant",
     "Medullary (5%): Parafollicular C-cells; calcitonin marker; MEN2A/2B association",
     "Anaplastic (<1%): Worst prognosis; rapidly fatal; no effective treatment"],
    tip="'PFHMA' or 'Pretty Fine Hair Makes Anarchy'"
))

thyroid.append(two_col_table(
    ["Feature", "Papillary vs Follicular"],
    [["Spread", "Papillary: Lymphatic | Follicular: Haematogenous"],
     ["Marker", "Papillary: Thyroglobulin | Follicular: Thyroglobulin"],
     ["FNAC diagnosis", "Papillary: Yes (nuclear features) | Follicular: No (needs histology)"],
     ["Mutation", "Papillary: RET/PTC, BRAF | Follicular: RAS, PAX8-PPAR"],
     ["Prognosis", "Papillary: Excellent | Follicular: Good"]]
))

thyroid.append(Spacer(1, 6))
sections.append(("2. Thyroid", thyroid))

# ── 3. BREAST ─────────────────────────────────────────────────────────────
breast = []
breast.append(section_banner("3. BREAST", "Lumps • Carcinoma • Surgical Procedures"))
breast.append(Spacer(1, 4))

breast.append(qa_block(
    "What is triple assessment of a breast lump?",
    ["Clinical examination (history + palpation)",
     "Imaging: Ultrasound (<35 yrs) / Mammogram (>35 yrs) ± MRI",
     "Histopathology: FNAC (cytology) or Core needle biopsy (preferred - gives architecture)"],
    tip="All three must agree - discordance requires further workup"
))

breast.append(qa_block(
    "What is the significance of Paget's disease of the nipple?",
    "Eczematous change of nipple/areola caused by intraepithelial spread of underlying ductal carcinoma in situ (DCIS) or invasive ductal carcinoma. Paget cells (large cells with pale cytoplasm) in the epidermis. Differs from eczema: starts at nipple, unilateral, does not respond to steroids.",
    warn="Always biopsy eczematous nipple changes in women >40 to exclude Paget's"
))

breast.append(qa_block(
    "Describe the lymphatic drainage of the breast - levels",
    ["Level I: Lateral to pectoralis minor (anterior/low axillary)",
     "Level II: Behind pectoralis minor (central axillary)",
     "Level III: Medial to pectoralis minor (apical axillary) - also called infraclavicular",
     "Internal mammary nodes: medial quadrant tumours",
     "Rotter's nodes (interpectoral): Batson's plexus for vertebral spread"],
    tip="Level I removed in standard axillary clearance; all 3 levels in radical mastectomy"
))

breast.append(qa_block(
    "What is sentinel lymph node biopsy (SLNB) and when is it indicated?",
    ["Sentinel node = first lymph node draining the tumour",
     "Identified using blue dye (Patent Blue V) and/or radioisotope (Technetium-99m)",
     "Indicated: Clinically node-negative, operable breast cancer",
     "If SLNB negative: Avoids full axillary dissection (prevents lymphoedema)",
     "If SLNB positive: Proceed to axillary lymph node dissection"],
    tip="ALND avoided in ~70% of cases with negative sentinel node"
))

breast.append(qa_block(
    "What are the boundaries of the axilla and its contents?",
    ["Anterior wall: Pectoralis major + minor",
     "Posterior wall: Subscapularis, teres major, latissimus dorsi",
     "Medial wall: Serratus anterior on ribs 1-4",
     "Lateral wall: Intertubercular groove of humerus",
     "Contents: Axillary vessels, brachial plexus, 15-30 lymph nodes, fat"],
    tip="Long thoracic nerve (serratus anterior) + thoracodorsal nerve (latissimus) at risk in axillary clearance"
))

breast.append(qa_block(
    "What is winged scapula and which nerve is injured?",
    "Long thoracic nerve of Bell (C5,6,7) injury during axillary dissection causes paralysis of serratus anterior. The medial border of scapula becomes prominent (winged) especially when patient pushes arms forward against a wall.",
    warn="Avoidable: identify and protect long thoracic nerve along chest wall during ALND"
))

breast.append(mnemonic_box("Breast Carcinoma - Must Know Facts",
    ["Most common: Invasive ductal carcinoma (IDC) = 75-80%",
     "Peau d'orange: Lymphatic oedema of skin - suggests T4b (locally advanced)",
     "Inflammatory carcinoma: Diffuse erythema, no palpable lump - T4d; worst prognosis",
     "ER+/HER2-: Hormonal therapy (tamoxifen/aromatase inhibitors)",
     "HER2+: Trastuzumab (Herceptin)",
     "Triple negative: Chemotherapy only; worst prognosis among subtypes",
     "BRCA1 mutation: Triple-negative, medullary type common",
     "BRCA2 mutation: ER+ luminal type; also male breast cancer"]))

breast.append(Spacer(1, 6))
sections.append(("3. Breast", breast))

# ── 4. APPENDIX ──────────────────────────────────────────────────────────
appendix = []
appendix.append(section_banner("4. APPENDIX & ACUTE ABDOMEN", "Appendicitis • Peritonitis • Scoring"))
appendix.append(Spacer(1, 4))

appendix.append(qa_block(
    "What is McBurney's point and Lanz's point?",
    ["McBurney's point: Junction of medial 2/3 and lateral 1/3 of line joining umbilicus to right ASIS",
     "Lanz's point: Junction of right 1/3 and middle 1/3 of line joining two ASISs",
     "McBurney's point = site of maximum tenderness in appendicitis",
     "Lanz incision follows skin crease - better cosmesis (preferred in women)"],
    tip="McBurney = 1/3 from ASIS; Lanz = transverse at ASIS level"
))

appendix.append(qa_block(
    "Enumerate the Alvarado score (MANTRELS)",
    ["M - Migration of pain to RIF (1 point)",
     "A - Anorexia (1 point)",
     "N - Nausea/vomiting (1 point)",
     "T - Tenderness in RIF (2 points)",
     "R - Rebound tenderness (1 point)",
     "E - Elevated temperature >37.3°C (1 point)",
     "L - Leucocytosis >10,000 (2 points)",
     "S - Shift to left (1 point). Total = 10",
     "Score <5: Unlikely appendicitis; 5-6: Equivocal; 7-10: Likely appendicitis"],
    tip="MANTRELS = 10 points; 7+ = operate"
))

appendix.append(qa_block(
    "What are Rovsing's sign, Psoas sign, and Obturator sign?",
    ["Rovsing's sign: Pressure in LIF causes pain in RIF (referred tenderness - peritoneal irritation)",
     "Psoas sign: Extension of right hip causes RIF pain - retrocaecal appendicitis lies on psoas",
     "Obturator sign: Internal rotation of flexed right hip causes RIF pain - pelvic appendicitis"],
    tip="Signs suggest position of appendix: retrocaecal = psoas; pelvic = obturator"
))

appendix.append(qa_block(
    "What is an appendix mass and how is it managed?",
    ["Appendix mass: Omentum + bowel wall off a perforated/inflamed appendix (3-5 days after onset)",
     "Ohsun's regimen (conservative): IV antibiotics, monitor size with USS",
     "Indication to abandon conservative: Not resolving/increasing in size, systemically unwell",
     "Interval appendicectomy: 6-8 weeks later (controversial; some advocate no interval op)"],
    tip="Appendix mass ≠ operate immediately; Appendix abscess = need drainage"
))

appendix.append(qa_block(
    "What is the position of the appendix and which is most common?",
    ["Retrocaecal (most common): 64-65% - classic psoas irritation",
     "Pelvic: 30% - diarrhoea, frequency, obturator sign",
     "Pre-ileal / Post-ileal: ~2%",
     "Paracolic: ~2%",
     "Subcaecal: ~1%"],
    tip="'Retrocaecal is MOST common' - examiners check this every time"
))

appendix.append(Spacer(1, 6))
sections.append(("4. Appendix", appendix))

# ── 5. GIT – UPPER ────────────────────────────────────────────────────────
upper_git = []
upper_git.append(section_banner("5. UPPER GI SURGERY", "Peptic Ulcer • GERD • Oesophagus"))
upper_git.append(Spacer(1, 4))

upper_git.append(qa_block(
    "What is Billroth I vs Billroth II gastrectomy?",
    ["Billroth I (Gastroduodenostomy): Distal stomach removed, gastric remnant anastomosed directly to duodenum. Used for pyloric/antral ulcers. More physiological (food passes through duodenum).",
     "Billroth II (Gastrojejunostomy): Distal stomach removed, duodenal stump closed (Hartmann's pouch), gastric remnant anastomosed to proximal jejunum. Used when duodenum is scarred/difficult.",
     "Roux-en-Y: Modification to prevent alkaline bile reflux"],
    tip="Billroth I = end-to-end to duodenum; BII = end-to-side to jejunum"
))

upper_git.append(qa_block(
    "What is dumping syndrome - early vs late?",
    ["Early dumping (20-30 min after eating): Rapid gastric emptying → hyperosmolar food enters jejunum → fluid shift into gut → tachycardia, sweating, diarrhoea, abdominal cramps",
     "Late dumping (2-3 hours after eating): Reactive hypoglycaemia - rapid glucose absorption → excess insulin → hypoglycaemia → anxiety, sweating, trembling",
     "Management: Small frequent meals, avoid fluid with meals, lie down after eating, octreotide in severe cases"],
    tip="Early = vasomotor; Late = hypoglycaemia - timing is the key differentiator"
))

upper_git.append(qa_block(
    "Enumerate complications of peptic ulcer disease",
    ["Bleeding (most common complication) - haematemesis/melaena",
     "Perforation (most common cause of peritonitis) - 'knife-like' pain, board-rigid abdomen, free gas under diaphragm on erect CXR",
     "Pyloric stenosis/obstruction - succussion splash, projectile vomiting, hypochloraemic hypokalaemic metabolic alkalosis",
     "Malignant change - gastric ulcer only (duodenal ulcer does not turn malignant)"],
    tip="'BPOM' - Bleeding, Perforation, Obstruction, Malignancy"
))

upper_git.append(qa_block(
    "What electrolyte abnormality occurs in pyloric stenosis and why?",
    "Hypochloraemic, hypokalaemic metabolic alkalosis. Mechanism: Repeated vomiting of HCl-rich gastric juice → loss of H+ and Cl- → metabolic alkalosis → kidney excretes HCO3- with Na+ (to maintain pH) → hyponatraemia → kidney sacrifices K+ to retain Na+ (aldosterone effect) → hypokalaemia. Paradoxical aciduria: Despite alkalosis, kidneys excrete acidic urine (K+ depletion forces H+ secretion).",
    warn="Correct electrolytes BEFORE surgery - never rush to theatre in unresuscitated pyloric stenosis"
))

upper_git.append(qa_block(
    "What are the features of oesophageal carcinoma by type?",
    ["Squamous cell carcinoma (SCC): Upper 2/3 of oesophagus; associated with smoking, alcohol, achalasia, Plummer-Vinson syndrome, hot beverages",
     "Adenocarcinoma: Lower 1/3 / GOJ; associated with Barrett's oesophagus, GORD, obesity",
     "Barrett's oesophagus: Metaplasia of squamous → columnar epithelium (intestinal type); pre-malignant",
     "Surgical treatment: Ivor Lewis oesophagogastrectomy (right thoracotomy + laparotomy)"],
    tip="Barrett's = columnar metaplasia due to acid reflux = risk of adenocarcinoma"
))

upper_git.append(Spacer(1, 6))
sections.append(("5. Upper GI", upper_git))

# ── 6. COLORECTAL ────────────────────────────────────────────────────────
colorectal = []
colorectal.append(section_banner("6. COLORECTAL SURGERY", "Cancer • Stomas • IBD • Haemorrhoids"))
colorectal.append(Spacer(1, 4))

colorectal.append(qa_block(
    "Classify haemorrhoids and their treatment",
    ["1st degree: Bleeding only - no prolapse (medical: high fibre, topical)",
     "2nd degree: Prolapse on straining, spontaneous reduction (injection sclerotherapy / banding)",
     "3rd degree: Prolapse requiring manual reduction (banding / haemorrhoidectomy)",
     "4th degree: Irreducible prolapse (haemorrhoidectomy - Milligan-Morgan or STARR)",
     "Above dentate line: Internal haemorrhoids (not painful - no somatic innervation)",
     "Below dentate line: External haemorrhoids (PAINFUL - somatic innervation)"],
    tip="'2nd-degree responds to injection; 3rd/4th need surgery'"
))

colorectal.append(qa_block(
    "What is the difference between Dukes and TNM staging for colorectal cancer?",
    ["Dukes A: Confined to bowel wall (T1/T2, N0, M0) - 85% 5-yr survival",
     "Dukes B: Through bowel wall, no nodes (T3/T4, N0, M0) - 65% survival",
     "Dukes C1: Nodes involved, highest node negative (N1, M0) - 35% survival",
     "Dukes C2: Highest node positive (N2, M0) - 20% survival",
     "Dukes D: Distant metastases (M1) - <5% survival"],
    tip="Examiner often asks 'which has best prognosis?' = Dukes A"
))

colorectal.append(qa_block(
    "Define the types of stomas - differences between colostomy and ileostomy",
    ["Ileostomy: Ileum; RIGHT iliac fossa; spout (projected 2-3 cm) to prevent alkaline effluent excoriating skin; liquid output",
     "Colostomy: Colon; usually LEFT iliac fossa (sigmoid); flush with skin; semi-solid/solid output",
     "Loop stoma: Temporary; has proximal (functioning) and distal (defunctioned) limbs",
     "End stoma: Permanent (e.g. after AP resection)"],
    tip="Ileostomy = SPOUT (liquid + corrosive); Colostomy = FLUSH (formed)"
))

colorectal.append(qa_block(
    "What is Hartmann's procedure?",
    "Sigmoid/upper rectal resection with formation of end colostomy and closure of rectal stump (no anastomosis). Used in emergency (perforated sigmoid diverticulitis, obstructing sigmoid cancer) when primary anastomosis is unsafe. Reversal in 3-6 months if patient fit.",
    tip="Hartmann's = emergency sigmoid resection + end colostomy + rectal stump closure"
))

colorectal.append(qa_block(
    "What is total mesorectal excision (TME)?",
    "Sharp dissection of the rectum along the avascular embryological plane (between visceral and parietal pelvic fascia) removing the mesorectum as an intact unit. This reduces local recurrence from 30% to <8%. Principle: No violation of the mesorectal envelope - ensures clear circumferential resection margin (CRM).",
    tip="TME = gold standard for rectal cancer; check CRM on histology"
))

colorectal.append(two_col_table(
    ["Feature", "Crohn's vs Ulcerative Colitis"],
    [["Distribution", "Crohn's: Skip lesions, any part of GIT | UC: Continuous, rectum upwards"],
     ["Depth", "Crohn's: Transmural ('cobblestone', fistulae) | UC: Mucosa + submucosa only"],
     ["Pathology", "Crohn's: Granulomas, rose-thorn ulcers | UC: Crypt abscesses, pseudopolyps"],
     ["Malignancy risk", "Crohn's: Slightly increased | UC: Significantly increased"],
     ["Surgery", "Crohn's: Conservative resection; recurs | UC: Total colectomy = curative"]]
))

colorectal.append(Spacer(1, 6))
sections.append(("6. Colorectal", colorectal))

# ── 7. HEPATOBILIARY ─────────────────────────────────────────────────────
hpb = []
hpb.append(section_banner("7. HEPATOBILIARY SURGERY", "Gallstones • Jaundice • Portal Hypertension"))
hpb.append(Spacer(1, 4))

hpb.append(qa_block(
    "What are Charcot's triad and Reynold's pentad?",
    ["Charcot's triad (ascending cholangitis): Pain + Jaundice + Fever with rigors",
     "Reynold's pentad (severe/toxic cholangitis): Charcot's triad + Hypotension + Altered mental status",
     "Cause: Obstruction of CBD with infection (E. coli, Klebsiella, Enterococcus)",
     "Treatment: Urgent ERCP decompression + IV antibiotics"],
    warn="Reynold's pentad = EMERGENCY - septic shock from biliary obstruction"
))

hpb.append(qa_block(
    "Classify jaundice and key differentiating features",
    ["Pre-hepatic (haemolytic): Unconjugated bilirubin ↑, no bilirubinuria, urobilinogen ↑; dark urine negative",
     "Hepatic (hepatocellular): Mixed hyper-bilirubinemia; ALT/AST markedly ↑; bilirubinuria present",
     "Post-hepatic (obstructive): Conjugated bilirubin ↑; ALP/GGT markedly ↑; pale stools, dark urine, pruritus; bilirubinuria present"],
    tip="'Pre = unconjugated = no bilirubinuria; Post = conjugated = dark urine + pale stools'"
))

hpb.append(qa_block(
    "Describe Calot's triangle - what structures are found there?",
    ["Boundaries: Cystic duct (inferiorly), common hepatic duct (medially), inferior surface of liver (superiorly)",
     "Contents: Cystic artery (usually a branch of right hepatic artery), cystic lymph node (Lund's node / Mascagni's node)",
     "Critical View of Safety (CVS): Two structures entering gallbladder must be clearly seen before clipping - essential step in laparoscopic cholecystectomy"],
    warn="Failure to achieve CVS = most common cause of bile duct injury"
))

hpb.append(qa_block(
    "What is Murphy's sign and how is it elicited?",
    "Hook the fingers under the right costal margin at the MCL and ask the patient to take a deep breath in. As the inflamed gallbladder descends to meet the fingers, the patient catches their breath (inspiratory arrest) due to pain. Positive = acute cholecystitis. Sonographic Murphy's sign: Same tenderness with USS probe over gallbladder.",
    tip="'Inspiratory arrest' is the key phrase - not just tenderness"
))

hpb.append(qa_block(
    "What are the causes and features of portal hypertension?",
    ["Pre-hepatic: Portal/splenic vein thrombosis",
     "Intra-hepatic (most common): Cirrhosis (alcoholic, viral hepatitis, PBC)",
     "Post-hepatic: Budd-Chiari syndrome, CCF",
     "Features: Splenomegaly, ascites, varices (oesophageal, rectal, caput medusae), hepatic encephalopathy",
     "Normal portal pressure: 5-10 mmHg; hypertension: >12 mmHg",
     "Variceal bleeding management: Terlipressin + endoscopic banding/sclerotherapy; TIPS if refractory"],
    tip="Portal HTN normal pressure = 5-10 mmHg; varices bleed at >12 mmHg"
))

hpb.append(Spacer(1, 6))
sections.append(("7. Hepatobiliary", hpb))

# ── 8. PERIPHERAL VASCULAR ───────────────────────────────────────────────
pvd = []
pvd.append(section_banner("8. VASCULAR SURGERY", "PAD • Varicose Veins • Aneurysms • Amputations"))
pvd.append(Spacer(1, 4))

pvd.append(qa_block(
    "Classify peripheral arterial disease - Fontaine vs Rutherford classification",
    ["Fontaine I: Asymptomatic",
     "Fontaine IIa: Intermittent claudication >200m",
     "Fontaine IIb: Intermittent claudication <200m",
     "Fontaine III: Rest pain",
     "Fontaine IV: Tissue loss/gangrene",
     "Critical limb ischemia: Rest pain >2 weeks OR tissue loss (Fontaine III/IV)"],
    tip="Fontaine III/IV = critical ischaemia = vascular emergency within days"
))

pvd.append(qa_block(
    "What is the Ankle Brachial Pressure Index (ABPI) and how is it interpreted?",
    ["ABPI = Ankle systolic BP / Brachial systolic BP",
     "Normal: 0.9-1.3",
     ">1.3: Calcified/non-compressible vessels (DM, renal failure) - unreliable",
     "0.5-0.9: Intermittent claudication",
     "<0.5: Critical ischaemia / rest pain",
     "<0.3: Impending gangrene / severe ischaemia"],
    tip="ABPI <0.9 = arterial disease; <0.5 = critical ischaemia"
))

pvd.append(qa_block(
    "What are the 6 Ps of acute limb ischaemia?",
    ["Pain (sudden, severe)", "Pallor", "Pulselessness",
     "Paraesthesia (indicates nerve ischaemia - urgent)", "Paralysis (indicates muscle ischaemia - very urgent)",
     "Perishing cold (Poikilothermia)",
     "Paraesthesia and paralysis = neuromuscular involvement = surgical emergency within 4-6 hours"],
    warn="Paralysis = most grave sign - irreversible ischaemia imminent"
))

pvd.append(qa_block(
    "Classify aortic aneurysms - indications for AAA repair",
    ["Definition: Permanent dilatation >1.5x normal diameter; Aorta normal = 2 cm; AAA = >3 cm",
     "Elective repair: AAA >5.5 cm in men; >5.0 cm in women; OR expansion >1 cm/year OR symptomatic",
     "EVAR (Endovascular): Lower short-term mortality; suitable anatomy required",
     "Open repair: Young fit patients; unfavourable anatomy; better long-term outcome",
     "Ruptured AAA: 80% mortality overall; emergency EVAR or open repair"],
    warn="Ruptured AAA classic triad: Severe back/abdominal pain + hypotension + pulsatile mass"
))

pvd.append(qa_block(
    "Trendelenburg test for varicose veins - what does it test?",
    ["Tests: Competence of saphenofemoral junction (SFJ) and sapheno-popliteal junction (SPJ)",
     "Tourniquet at groin: Empty veins on elevation, release → rapid filling from below = perforator incompetence",
     "Release tourniquet: Rapid filling from above = SFJ incompetence",
     "Duplex USS has largely replaced clinical tourniquet tests in practice"],
    tip="'Tourniquet controls the junction being tested' is the key principle"
))

pvd.append(Spacer(1, 6))
sections.append(("8. Vascular", pvd))

# ── 9. UROLOGY ────────────────────────────────────────────────────────────
urology = []
urology.append(section_banner("9. UROLOGY & RELATED TOPICS", "Renal • Bladder • Prostate • Testis"))
urology.append(Spacer(1, 4))

urology.append(qa_block(
    "What are the features of testicular torsion vs epididymo-orchitis?",
    ["Testicular torsion: Sudden onset, young (peak 13-25 yrs), elevated testis, horizontal lie (bell-clapper deformity), absent cremasteric reflex, Prehn's sign negative (elevation worsens pain)",
     "Epididymo-orchitis: Gradual onset, older age (or sexually active), tender epididymis, Prehn's sign positive (elevation relieves pain), urethral discharge, pyuria"],
    warn="Never delay for USS if torsion suspected - explore immediately; 'time is testis' (viable up to 6 hrs)"
))

urology.append(qa_block(
    "What is PSA and its interpretation?",
    ["PSA: Prostate-specific antigen; serine protease produced by prostate epithelium",
     "Normal: <4 ng/mL (age-adjusted values more accurate)",
     "Elevated PSA causes: BPH, prostatitis, prostate cancer, recent ejaculation, urethral instrumentation",
     "PSA density, PSA velocity, free/total PSA ratio improve specificity",
     "Screening remains controversial (false positives lead to unnecessary biopsies)"],
    tip="PSA is ORGAN-specific, not CANCER-specific - BPH is most common cause of mild elevation"
))

urology.append(qa_block(
    "What is the presentation and management of ureteric colic?",
    ["Presentation: Severe colicky loin-to-groin pain, writhing in pain (unlike peritonitis - keeps still), haematuria, nausea/vomiting",
     "Most common stone: Calcium oxalate (80%), uric acid (5-10%)",
     "Investigation: CT KUB (gold standard, non-contrast), USS if pregnant",
     "Treatment: <5 mm = conservative (NSAIDs + fluids + alpha-blocker); >10 mm = ureteroscopy/ESWL; >2 cm in kidney = PCNL",
     "Indications for urgent drainage: Obstruction + infection (pyonephrosis) = EMERGENCY"],
    tip="'Loin to groin = ureteric colic' - haematuria confirms; MSU to exclude infection"
))

urology.append(Spacer(1, 6))
sections.append(("9. Urology", urology))

# ── 10. ENDOCRINE & MISCELLANEOUS ─────────────────────────────────────────
endo = []
endo.append(section_banner("10. ENDOCRINE & MISCELLANEOUS", "Adrenal • MEN • Spleen • Principles"))
endo.append(Spacer(1, 4))

endo.append(qa_block(
    "What is a phaeochromocytoma - the 10% tumour?",
    ["10% bilateral, 10% malignant, 10% extra-adrenal (paraganglioma), 10% in children, 10% familial",
     "Symptoms: Paroxysmal hypertension, headache, sweating, palpitations, pallor (not flushing)",
     "Investigation: 24-hr urinary catecholamines/metanephrines (most sensitive); MIBG scan for extra-adrenal",
     "Associated: MEN2A/2B, VHL, NF-1",
     "Pre-op: Alpha-blockade (phenoxybenzamine) FIRST, then beta-blockade; NEVER beta first alone"],
    warn="Beta-blocker without alpha-blockade = hypertensive crisis (unopposed alpha stimulation)"
))

endo.append(qa_block(
    "What is MEN (Multiple Endocrine Neoplasia)?",
    ["MEN1 (Wermer's syndrome): Parathyroid (HPT) + Pituitary + Pancreatic islets (Zollinger-Ellison, insulinoma) - '3 Ps'",
     "MEN2A (Sipple's): Medullary thyroid cancer + Phaeochromocytoma + Parathyroid - 'MTC + Pheo + Parathyroid'",
     "MEN2B: MTC + Pheo + Mucosal neuromas + Marfanoid habitus (NO parathyroid)"],
    tip="MEN1 = 3 Ps; MEN2A = MTC + Pheo + Parathyroid; 2B = 2A minus parathyroid + neuromas"
))

endo.append(qa_block(
    "What are the indications for splenectomy and post-splenectomy precautions?",
    ["Indications: Trauma (most common emergency), ITP refractory to steroids, hereditary spherocytosis, haemolytic anaemia, hypersplenism, staging (rare now), splenic artery aneurysm",
     "Post-splenectomy complications: OPSI (Overwhelming Post-Splenectomy Infection) - especially S. pneumoniae, H. influenzae, N. meningitidis",
     "Prevention: Vaccinate 2 weeks pre-op (or 2 weeks post-op if emergency) against pneumococcus, Hib, meningococcus",
     "Long-term penicillin V prophylaxis for 2 years (or lifelong in children/immunocompromised)"],
    warn="OPSI carries 50-80% mortality - VACCINATE BEFORE ELECTIVE SPLENECTOMY"
))

endo.append(qa_block(
    "What is Conn's syndrome vs Cushing's syndrome?",
    ["Conn's (Primary hyperaldosteronism): Adrenal adenoma producing excess aldosterone; hypertension + hypokalaemia + metabolic alkalosis; low renin; treatment: adrenalectomy or spironolactone",
     "Cushing's (excess cortisol): Causes: ACTH-dependent (pituitary - Cushing's disease 70%; ectopic ACTH 10%) or ACTH-independent (adrenal adenoma/carcinoma 20%)",
     "Cushing's features: Central obesity, moon face, buffalo hump, striae, thin skin, hypertension, DM, osteoporosis"],
    tip="Conn's = low K + high BP + low renin; Cushing's = cortisol excess = buffalo hump"
))

endo.append(qa_block(
    "What are the surgical principles of wound healing?",
    ["Primary intention: Clean wound, edges approximated, minimal scarring",
     "Secondary intention: Wound left open, heals by granulation + contraction + epithelialisation",
     "Tertiary/Delayed primary closure: Wound initially left open (contaminated), closed at 4-5 days after clean",
     "Phases: Inflammatory (0-5 days) → Proliferative (5 days - 3 weeks) → Remodelling (3 weeks - 2 years)",
     "Factors impairing healing: DM, malnutrition (especially Vit C, zinc, protein deficiency), steroids, infection, poor blood supply, anaemia"],
    tip="'DAMNIT' - DM, Anaemia, Malnutrition, Necrosis, Infection, Tissue necrosis"
))

endo.append(Spacer(1, 6))
sections.append(("10. Endocrine/Misc", endo))

# ── 11. SURGICAL ANATOMY QUICKFIRE ────────────────────────────────────────
anatomy = []
anatomy.append(section_banner("11. SURGICAL ANATOMY QUICKFIRE", "Nerves • Spaces • Landmarks"))
anatomy.append(Spacer(1, 4))

anatomy.append(two_col_table(
    ["Structure / Question", "Key Answer"],
    [["McBurney's point", "2/3 from umbilicus to right ASIS (1/3 from ASIS)"],
     ["Surface marking of appendix", "McBurney's point; also 3 taeniae coli of caecum converge on its base"],
     ["Nerve at risk in McBurney's incision", "Ilioinguinal nerve (L1)"],
     ["Nerve at risk in axillary clearance", "Long thoracic nerve (Bell) → winged scapula; Thoracodorsal → LD"],
     ["Nerve at risk in thyroidectomy", "RLN (hoarseness); External SLN (singer's voice loss)"],
     ["Nerve at risk in parotidectomy", "Facial nerve (VII) → facial palsy"],
     ["Nerve at risk in posterior triangle neck dissection", "Accessory nerve (XI) → trapezius wasting, drooping shoulder"],
     ["Nerve at risk in inguinal hernia repair", "Ilioinguinal, iliohypogastric, genitofemoral nerves"],
     ["Deep ring location", "1.25 cm above midpoint of inguinal ligament"],
     ["Femoral triangle boundaries", "Inguinal ligament (above), sartorius (lateral), adductor longus (medial)"],
     ["Contents of femoral sheath", "Femoral artery, vein, femoral canal (lymphatics) - NO femoral nerve"],
     ["Adductor (Hunter's) canal", "Contains femoral artery/vein, saphenous nerve, nerve to vastus medialis"],
     ["Foramen of Winslow (epiploic)", "Into lesser sac: Portal vein, hepatic artery, CBD"],
     ["Portal vein formation", "Junction of superior mesenteric vein + splenic vein"],
     ["Blood supply of rectum", "Superior rectal (IMA), middle rectal (internal iliac), inferior rectal (pudendal)"],
     ["Junction of hindgut/midgut", "Junction of proximal 2/3 and distal 1/3 of transverse colon (L3)"]
]))

anatomy.append(Spacer(1, 10))
sections.append(("11. Anatomy Quickfire", anatomy))

# ── 12. TRICKY VIVA KILLER QUESTIONS ─────────────────────────────────────
killers = []
killers.append(section_banner("12. TRICKY VIVA KILLER QUESTIONS", "Most Frequently Caught-Out Topics"))
killers.append(Spacer(1, 4))

killers.append(qa_block(
    "Which operation is 'curative' for Hirschsprung's disease?",
    "Swenson's pull-through operation (or Duhamel/Soave variants) - removal of the aganglionic segment. Hirschsprung's = absence of ganglion cells (Meissner's submucosal + Auerbach's myenteric plexus) in the rectum/sigmoid. Presents as failure to pass meconium within 48 hrs of birth.",
    tip="Hirschsprung = aganglionosis; absent ganglion cells on rectal biopsy is diagnostic"
))

killers.append(qa_block(
    "What is the difference between strangulation and obstruction?",
    ["Obstruction: Lumen is blocked; bowel viable; pain is colicky; no peritoneal signs",
     "Strangulation: Blood supply compromised in addition to obstruction; continuous pain; peritoneal signs; systemic toxicity",
     "Strangulation converts obstruction from 'urgent' to 'emergency'",
     "Signs of strangulation: Fever, tachycardia, peritonism, raised WCC, raised lactate"],
    warn="Closed loop obstruction (e.g. sigmoid volvulus with competent ileocaecal valve) strangulates rapidly"
))

killers.append(qa_block(
    "What is the CEPOD (NCEPOD) classification of operations?",
    ["Immediate/Emergency (Category 1): Life/limb threat - within minutes (e.g. ruptured AAA)",
     "Urgent (Category 2): Organ/life threat - within hours (e.g. perforated viscus, obstructed hernia)",
     "Expedited (Category 3): Stable but requires early treatment - within days (e.g. bowel obstruction without compromise)",
     "Elective (Category 4): Planned/scheduled - any time"],
    tip="Examiners love 'urgent vs emergency vs elective' distinction - know the time frames"
))

killers.append(qa_block(
    "What is the difference between gangrene and necrosis?",
    ["Necrosis: Cell/tissue death (may be any type - coagulative, liquefactive etc.)",
     "Gangrene: Necrosis of tissue with putrefaction (bacterial decomposition); implies macroscopic visible tissue death",
     "Dry gangrene: Ischaemic; no bacteria; mummified; clear demarcation line",
     "Wet gangrene: Bacterial invasion + oedema; no clear line; rapidly spreading; EMERGENCY",
     "Gas gangrene: Clostridium perfringens; gas in tissues (crepitus); surgical emergency - debridement + penicillin + hyperbaric O2"],
    warn="Wet or gas gangrene = surgical emergency; do not wait for demarcation"
))

killers.append(qa_block(
    "What is the difference between transposition and transplantation flaps?",
    ["Transposition flap: Flap rotated sideways from adjacent area on a pivot point (e.g. Z-plasty, rhomboid flap)",
     "Transposition includes: Random pattern (angiosome not required) vs Axial pattern (based on named vessel)",
     "Free flap: Tissue completely detached and blood supply restored via microvascular anastomosis",
     "Pedicle flap: Tissue moved with its blood supply intact (e.g. pedicled TRAM for breast reconstruction)"],
    tip="Random flap = 1:1 length:width ratio; Axial = can be longer if based on named artery"
))

killers.append(qa_block(
    "What is the difference between colicky and constant abdominal pain?",
    ["Colicky (visceral): Waves of pain from hollow viscus obstruction (bowel, ureter, biliary); patient moves around; no tenderness between waves",
     "Constant (somatic/peritoneal): Parietal peritoneum irritation; patient lies still; tenderness + guarding + rigidity",
     "Mixed: Biliary/renal colic becomes constant if complicated (cholecystitis, pyelonephritis)",
     "Board-like rigidity: Perforated viscus - involuntary generalised guarding"],
    tip="'Patient writhing = colic; Patient lying still = peritonitis'"
))

killers.append(qa_block(
    "What is Courvoisier's law and its exceptions?",
    "In the presence of painless obstructive jaundice, if the gallbladder is palpable, the obstruction is unlikely to be due to gallstones. This is because chronic gallstone disease causes a fibrosed, shrunken, non-distensible gallbladder. Exceptions: Double pathology (mucocele + stone in CBD); empyema of gallbladder with CBD stone; Mirizzi syndrome.",
    warn="Palpable GB + painless jaundice = carcinoma of head of pancreas until proven otherwise"
))

killers.append(qa_block(
    "What is the 'Second hit' hypothesis in surgical critical care?",
    "A 'first hit' (trauma, major surgery, sepsis) primes the immune system (neutrophils activated). A subsequent smaller 'second hit' (aspiration, blood transfusion, further infection) then triggers massive disproportionate immune activation leading to SIRS/ARDS/MOF. Explains why patients deteriorate after initial improvement.",
    tip="This explains ARDS developing 3-5 days post-trauma/surgery - not just the injury alone"
))

killers.append(Spacer(1, 6))
sections.append(("12. Killer Questions", killers))

# ═══════════════════════════════════════════════════════════════════════════
# BUILD PDF
# ═══════════════════════════════════════════════════════════════════════════

def build_pdf():
    doc = SimpleDocTemplate(
        OUTPUT_PATH,
        pagesize=A4,
        leftMargin=cm, rightMargin=cm,
        topMargin=1.8*cm, bottomMargin=2*cm,
        title="General Surgery FAQ Viva",
        author="Orris Medical"
    )

    story = []

    # ── Cover Page ──────────────────────────────────────────────────────────
    story.append(Spacer(1, 1.5*cm))

    # Cover box
    cover_data = [
        [Paragraph("GENERAL SURGERY", S("ct", fontSize=32, fontName="Helvetica-Bold",
                   textColor=WHITE, alignment=TA_CENTER, leading=36))],
        [Paragraph("FAQ VIVA", S("ct2", fontSize=26, fontName="Helvetica-Bold",
                   textColor=GOLD, alignment=TA_CENTER, leading=30))],
        [Spacer(1, 4)],
        [Paragraph("Practical Exam Oriented", S("cs", fontSize=14, fontName="Helvetica",
                   textColor=LIGHT_BLUE, alignment=TA_CENTER))],
        [Paragraph("Frequently Asked &amp; Tricky-to-Remember Questions", S("cs2", fontSize=11,
                   fontName="Helvetica", textColor=LIGHT_BLUE, alignment=TA_CENTER))],
        [Spacer(1, 6)],
        [HRFlowable(width="80%", thickness=1, color=GOLD, hAlign="CENTER")],
        [Spacer(1, 4)],
        [Paragraph("12 Topics  •  120+ Questions  •  High-Yield Mnemonics  •  Tables", S("cs3",
                   fontSize=10, fontName="Helvetica-Oblique", textColor=colors.HexColor("#AACCEE"),
                   alignment=TA_CENTER))],
        [Spacer(1, 4)],
        [Paragraph("Edition: June 2026", S("ed", fontSize=9, fontName="Helvetica",
                   textColor=MID_GREY, alignment=TA_CENTER))],
    ]
    cover_table = Table(cover_data, colWidths=[PAGE_W - 2*cm])
    cover_table.setStyle(TableStyle([
        ("BACKGROUND",  (0,0), (-1,-1), DARK_BLUE),
        ("TOPPADDING",  (0,0), (-1,-1), 10),
        ("BOTTOMPADDING",(0,0), (-1,-1), 10),
        ("LEFTPADDING", (0,0), (-1,-1), 20),
        ("RIGHTPADDING",(0,0), (-1,-1), 20),
    ]))
    story.append(cover_table)
    story.append(Spacer(1, 0.8*cm))

    # Intro note
    intro = Table([[Paragraph(
        "<b>How to use this guide:</b> Each question mimics the style examiners use in MBBS/MS/DNB practicals. "
        "The answers are concise but complete. <b>Tips</b> (green) highlight exam-catching phrases. "
        "<b>Notes</b> (red) flag common mistakes and danger zones. Mnemonics are boxed for quick review.",
        S("intro", fontSize=9.5, fontName="Helvetica", leading=13, textColor=DARK_BLUE)
    )]], colWidths=[PAGE_W - 2*cm])
    intro.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), ACCENT),
        ("BOX",        (0,0), (-1,-1), 1, MED_BLUE),
        ("TOPPADDING",  (0,0), (-1,-1), 8),
        ("BOTTOMPADDING",(0,0), (-1,-1), 8),
        ("LEFTPADDING", (0,0), (-1,-1), 10),
    ]))
    story.append(intro)
    story.append(PageBreak())

    # ── Table of Contents ───────────────────────────────────────────────────
    story.append(Paragraph("Table of Contents", toc_title))
    story.append(HRFlowable(width="100%", thickness=1.5, color=DARK_BLUE, spaceAfter=8))
    toc_items = [
        "1. Hernia (Inguinal, Femoral, Umbilical, Incisional, Eponyms)",
        "2. Thyroid Gland (Anatomy, Swellings, Thyroid Cancers)",
        "3. Breast (Triple Assessment, Lymph Nodes, Carcinoma)",
        "4. Appendix & Acute Abdomen (Scoring, Signs, Positions)",
        "5. Upper GI Surgery (Peptic Ulcer, Dumping, Oesophagus)",
        "6. Colorectal Surgery (Haemorrhoids, Cancer Staging, IBD, Stomas)",
        "7. Hepatobiliary Surgery (Gallstones, Jaundice, Portal Hypertension)",
        "8. Vascular Surgery (PAD, ABPI, 6 Ps, AAA, Varicose Veins)",
        "9. Urology (Testicular Torsion, PSA, Ureteric Colic)",
        "10. Endocrine & Miscellaneous (Phaeochromocytoma, MEN, Spleen, Wound Healing)",
        "11. Surgical Anatomy Quickfire Table (Nerves, Landmarks, Spaces)",
        "12. Tricky Viva Killer Questions (Most Frequently Caught-Out Topics)",
    ]
    for item in toc_items:
        story.append(Paragraph(item, toc_item))
        story.append(Spacer(1, 3))
    story.append(PageBreak())

    # ── All sections ────────────────────────────────────────────────────────
    for title, elems in sections:
        for elem in elems:
            story.append(elem)
        story.append(PageBreak())

    # ── Back cover note ─────────────────────────────────────────────────────
    story.append(Spacer(1, 2*cm))
    back_data = [[Paragraph(
        "<b>Quick Revision Reminders</b><br/><br/>"
        "1. Always give anatomical boundaries when asked about any triangle/space.<br/>"
        "2. For any nerve injury question - state the nerve, the result, and how to protect it.<br/>"
        "3. For any cancer - staging, spread, treatment, and prognosis are expected.<br/>"
        "4. For any emergency (torsion, strangulated hernia, ruptured AAA) - say 'emergency surgery' first.<br/>"
        "5. For jaundice - always classify (pre/hepatic/post) before differentiating.<br/>"
        "6. Electrolyte disturbances in pyloric stenosis and vomiting are HIGH YIELD.<br/>"
        "7. Always mention CVS (Critical View of Safety) in laparoscopic cholecystectomy.<br/>"
        "8. Margins in cancer surgery: 1 cm clear margin for most; 2 cm for melanoma &gt;2 mm thick.<br/>",
        S("back", fontSize=10, fontName="Helvetica", leading=15, textColor=DARK_BLUE)
    )]]
    back_table = Table(back_data, colWidths=[PAGE_W - 2*cm])
    back_table.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), ACCENT),
        ("BOX",        (0,0), (-1,-1), 1.5, DARK_BLUE),
        ("TOPPADDING",  (0,0), (-1,-1), 14),
        ("BOTTOMPADDING",(0,0), (-1,-1), 14),
        ("LEFTPADDING", (0,0), (-1,-1), 14),
        ("RIGHTPADDING",(0,0), (-1,-1), 14),
    ]))
    story.append(back_table)

    doc.build(story, onFirstPage=add_page_number, onLaterPages=add_page_number)
    print(f"PDF created: {OUTPUT_PATH}")

build_pdf()
Running Command

cd /home/daytona/workspace/gen-surgery-viva && python generate_viva.py 2>&1

Running Command

ls -lh /home/daytona/workspace/gen-surgery-viva/General_Surgery_FAQ_Viva.pdf

Your PDF is ready! Here's your download link:

General Surgery FAQ Viva

PDF Document · PDF


What's Inside (12 Sections, 120+ Q&As)

#TopicKey Highlights
1HerniaHesselbach's triangle, direct vs indirect, Richter's, sliding, all eponyms (Littre, Maydl, Amyand, Pantaloon)
2ThyroidBerry's ligament, RLN/SLN injury, Pemberton's sign, thyroid cancer classification with mutations
3BreastTriple assessment, Paget's disease, axillary levels, SLNB, winged scapula, BRCA1 vs BRCA2
4AppendixMcBurney's vs Lanz's, Alvarado/MANTRELS score, Rovsing/Psoas/Obturator signs, appendix positions
5Upper GIBillroth I vs II, early vs late dumping, peptic ulcer complications, pyloric stenosis electrolytes, Barrett's
6ColorectalHaemorrhoid grading, Dukes staging, colostomy vs ileostomy, Hartmann's, TME, Crohn's vs UC table
7HepatobiliaryCharcot's triad vs Reynold's pentad, jaundice classification, Calot's triangle, Murphy's sign, portal HTN
8VascularFontaine classification, ABPI interpretation, 6 Ps of acute ischaemia, AAA repair thresholds, Trendelenburg test
9UrologyTesticular torsion vs epididymo-orchitis, PSA interpretation, ureteric colic management
10Endocrine/MiscPhaeochromocytoma (10% rule), MEN1/2A/2B, post-splenectomy care, Conn's vs Cushing's, wound healing
11Anatomy QuickfireFull table - nerves at risk in every operation, triangles, canals, blood supplies
12Killer QuestionsCourvoisier's law, CEPOD classification, gangrene types, second-hit hypothesis, strangulation vs obstruction
Design features: Green tips for exam phrases to use, red warnings for dangerous mistakes, blue mnemonic boxes, comparison tables, and a quick revision checklist at the end. Good luck in your viva!
This is a shared conversation. Sign in to Orris to start your own chat.