Varicose vein in depth for 30 marks long question

Reading File
Finding Sources
Finding Sources
Searching PubMed

varicose veins management treatment

Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Loading Image
Loading Image
Reading File
I now have comprehensive material from Bailey & Love, Harrison's, and Schwartz's to write a thorough 30-mark answer. Let me compile everything into a comprehensive, well-structured response.

Varicose Veins - In-Depth (30 Marks)


Definition

Varicose veins are dilated, bulging, tortuous superficial veins measuring at least 3 mm in diameter, containing incompetent (refluxing) valves. The term derives from the Latin varix, meaning "twisted vein." They are distinguished from:
  • Reticular veins: dilated intradermal veins, blue-green, 1-3 mm, do not protrude
  • Telangiectasias (spider/thread veins): <1 mm, near skin surface, forming linear or spider-web patterns
(Harrison's Principles of Internal Medicine, 22nd Ed.)

Clinical Photo

Varicose veins - distribution of incompetent GSV, SSV systems
Fig: (a) left GSV territory varicosities marked for intervention; (b) SSV territory with recent phlebitis; (c) AAGSV territory with gaiter area skin changes. (Bailey & Love, 28th Ed.)

Epidemiology

The adult prevalence of visible varicose veins is 30-50%. Key risk factors include:
FactorDetail
SexHigher prevalence in women than men
AgeIncreases with age - Edinburgh Vein Study: 11.5% (18-24 yrs) rising to 55.7% (55-64 yrs)
PregnancyIncreases risk via hormonal + mechanical effects
Family history~50% of primary varicose veins have a family history
Obesity/BMIHigher BMI associated with greater risk
Prolonged standingInconclusive but likely contributory
EthnicityInfluences prevalence
(Bailey & Love's Short Practice of Surgery, 28th Ed.)

Anatomy Relevant to Varicose Veins

Superficial Venous System

  • Great Saphenous Vein (GSV): longest vein in the body; originates medial foot, ascends anterior to medial malleolus, along medial calf and thigh, drains into the common femoral vein at the saphenofemoral junction (SFJ)
  • Small Saphenous Vein (SSV): originates dorsolateral foot, ascends posterior to lateral malleolus, drains into the popliteal vein at the saphenopopliteal junction (SPJ)

Deep Venous System

  • Paired anterior tibial, posterior tibial, and peroneal veins converge to form the popliteal vein - femoral vein - common femoral vein - external iliac - IVC

Perforating Veins

  • Connect superficial to deep system; normally allow blood flow from superficial to deep; bicuspid valves throughout direct flow centrally
(Harrison's, 22nd Ed.)

Classification

Primary vs. Secondary

Primary varicose veins (~most common):
  • Originate in the superficial system
  • Result from intrinsic weakness of the vein wall, defective valve structure/function, and high intraluminal pressure
  • ~50% have a family history
Secondary varicose veins:
  • Result from deep venous hypertension
  • Causes: deep-vein thrombosis (post-thrombotic syndrome), deep venous obstruction, incompetent perforating veins, arteriovenous fistulas, Klippel-Trenaunay syndrome
(Harrison's 22nd Ed., Bailey & Love 28th Ed.)

CEAP Classification (Clinical-Etiology-Anatomy-Pathophysiology)

The internationally accepted classification system:
Clinical (C):
ClassDescription
C0No visible/palpable signs
C1Telangiectasia or reticular veins
C2Varicose veins
C3Oedema
C4aPigmentation or eczema
C4bLipodermatosclerosis or atrophie blanche
C5Healed venous ulcer
C6Active venous ulcer
Etiology (E): Ec (congenital), Ep (primary), Es (secondary), En (no identifiable cause)
Anatomy (A): As (superficial), Ad (deep), Ap (perforating), An (none identified)
Pathophysiology (P): Pr (reflux), Po (obstruction), Pr,o (both), Pn (none identifiable)
(Bailey & Love, 28th Ed.)

Pathophysiology

The fundamental mechanism is chronic venous hypertension resulting from:

1. Valve Incompetence and Reflux

  • Normal valves direct blood centrally (toward the heart)
  • Valve leaflet failure allows retrograde flow (reflux) when standing
  • Superficial reflux is defined as retrograde flow lasting >0.5 seconds; deep vein reflux >1 second

2. Vein Wall Changes

Progressive changes in the wall include:
  • Inflammatory cell infiltration and activation
  • Dysfunctional smooth muscle cell proliferation
  • Collagen deposition
  • Decreased elastin content
  • Increased matrix metalloproteinases (MMPs)
  • These lead to loss of compliance, dilatation, elongation (causing tortuosity), and secondary valvular dysfunction

3. Downstream Consequences

  • Venous hypertension causes increased capillary pressure
  • Extravasation of fluid, red blood cells, and fibrin into tissues
  • RBC breakdown leads to haemosiderin deposition (pigmentation)
  • Fibrin pericapillary cuffing impairs tissue oxygenation
  • Chronic inflammation leads to lipodermatosclerosis and ulceration
(Bailey & Love, 28th Ed.; Harrison's, 22nd Ed.)

Clinical Features

Symptoms

Patients describe:
  • Aching, heaviness, throbbing, burning, or bursting sensation
  • Symptoms worsen throughout the day and with prolonged standing
  • Relieved by elevation or compression hosiery
  • Itching (more common with complications)
  • Ankle swelling
  • Unsightly cosmetic appearance

Signs

  • Tortuous, dilated subcutaneous veins - visible and palpable
  • GSV incompetence produces medial thigh and calf varicosities
  • SSV incompetence produces posterolateral calf varicosities
  • AAGSV incompetence produces anterolateral thigh and calf varicosities
  • Saphena varix: a painless groin swelling apparent on standing, disappears on lying (can mimic a hernia; impulse on cough)
(Bailey & Love, 28th Ed.)

Complications

Chronic Complications (skin changes)

FeatureDescription
OedemaPitting initially, later non-pitting
HyperpigmentationHaemosiderin deposits from RBC extravasation
Venous eczema (stasis dermatitis)Erythema, weeping, crusting
LipodermatosclerosisInduration + inflammation in lower leg above ankle - "inverted champagne bottle" deformity
Atrophie blancheWhite scar patches with telangiectasias, near medial malleolus
Corona phlebectaticaFan-shaped intradermal veins near ankle/foot
Venous ulcerShallow, irregular border, granulation tissue base, near malleoli - a C6 CEAP lesion

Acute Complications

  1. Superficial vein thrombosis (thrombophlebitis): painful, red, indurated cord along varicosities
  2. Bleeding: from ruptured varicosities - can be severe and alarming (especially at night); first aid is elevation and pressure
  3. Deep vein thrombosis (less common, associated with propagation of SVT)
(Harrison's, 22nd Ed.; Bailey & Love, 28th Ed.)

Investigations

Duplex Ultrasound (Investigation of Choice)

  • Tourniquet tests and handheld Doppler have been abandoned in favour of duplex ultrasound
  • All patients should undergo duplex scanning before intervention
  • Performed with patient standing
  • High-frequency linear array transducer: 7.5-13 MHz
  • Aims to establish:
    1. Presence and distribution of reflux in deep and superficial systems
    2. Exact extent of reflux including affected junctions and perforators
    3. Deep venous obstruction
    4. Suitability of veins for specific treatments (diameter, extent, tortuosity)
    5. Presence of deep venous disease
Mickey Mouse sign: transverse B-mode image at groin shows the common femoral artery (large circle), CFV (medium circle), and GSV (small circle)

Bedside Tests (Historical - now replaced by duplex)

  • Brodie-Trendelenburg test: Leg elevated to empty veins, tourniquet applied to proximal thigh, patient stands. Rapid refilling after tourniquet removal = superficial incompetence. Filling while tourniquet is on = deep venous insufficiency
  • Perthes test: Tourniquet applied, patient walks. If veins empty = deep system patent. If veins distend = deep obstruction

Other Investigations

  • Plethysmography (photoplethysmography/air plethysmography) - assesses overall venous function
  • Venography - reserved for complex/recurrent cases
  • CT/MRI venography - for pelvic venous insufficiency or suspected outflow obstruction
(Bailey & Love, 28th Ed.; Harrison's, 22nd Ed.)

Differential Diagnosis

  • Lymphoedema: non-pitting, no varicosities, Stemmer's sign positive
  • Deep vein thrombosis: acute, painful, warm
  • Congestive cardiac failure: bilateral pitting oedema
  • Hypoalbuminaemia (nephrotic syndrome, liver disease): bilateral oedema
  • Lipoedema: bilateral, spares the foot, painful
  • Arteriovenous fistula (secondary varicosities with bruit/thrill)
  • Klippel-Trenaunay syndrome: port-wine stain + varicosities + limb hypertrophy

Management

Conservative (Non-operative) Management

Indications: mild symptoms, preference, pregnancy, bilateral occlusive deep venous disease, patient unfit for intervention.
  1. Compression hosiery (stockings):
    • Graduated compression: 20-30 mmHg, 30-40 mmHg, 40-50 mmHg
    • Knee-high to waist-high
    • Relieves symptoms in many patients; does not cure the underlying reflux
  2. Lifestyle modifications:
    • Weight reduction
    • Avoid prolonged standing
    • Regular walking (calf muscle pump activation)
    • Leg elevation

Indications for Active Intervention

  • Symptoms worsening or unrelieved by compression
  • Lipodermatosclerosis
  • Venous ulcer (healed C5 or active C6)
  • Recurrent superficial thrombophlebitis
  • Bleeding varicose veins
  • Significant cosmetic concern

Interventional Management Options

1. Endovenous Thermal Ablation (FIRST-LINE - minimally invasive)

A catheter/device is inserted percutaneously into the incompetent vein; tumescent local anaesthetic is injected around the vein (compresses vein, hydro-dissects nerves, acts as heat sink). Thermal energy destroys the vein wall causing permanent occlusion.
Endovenous Laser Ablation (EVLA):
  • Flexible glass fibre inserted into the vein
  • Laser energy (typically 1470 nm wavelength) transmitted to the tip
  • Vigorous thermal energy generation causes vein wall destruction
  • Suitable for any vein accepting a guidewire
  • Higher efficacy in large diameter veins (>15 mm)
  • Requires laser safety protocols
Radiofrequency Ablation (RFA):
  • Uses metal coil catheter (e.g. ClosureFast)
  • Automatic treatment cycle on single button press - shorter learning curve
  • Slightly less pain and bruising post-procedure
  • Less suitable for large diameter veins
Both techniques treat junctional and truncal incompetence only; residual varicosities require adjuvant phlebectomy or sclerotherapy.

2. Foam Sclerotherapy (Ultrasound-Guided Foam Sclerotherapy - UGFS)

  • Sclerosant solution made into foam using Tessari method (1:3 or 1:4 ratio of sclerosant to air oscillated between two syringes via 3-way tap)
  • Common agents: sodium tetradecyl sulfate, polidocanol
  • Destroys venous endothelium; vein fibroses
  • Leg elevated before injection; maximum 10-12 mL per session
  • Advantages: no tumescent anaesthetic, treats tortuous veins, can treat over damaged skin, low cost
  • Disadvantages: lower efficacy than thermal ablation, higher reintervention rates, risk of phlebitis and pigmentation
  • Liquid sclerotherapy used for telangiectasias (smaller concentrations)
(Schwartz's Principles of Surgery, 11th Ed.; Bailey & Love, 28th Ed.)

3. Mechanochemical Ablation (MOCA - e.g., ClariVein)

  • Rotating wire disrupts endothelium mechanically; sclerosant delivered simultaneously
  • No tumescent anaesthetic required
  • Good for smaller veins; does not require thermal energy

4. Cyanoacrylate Glue Ablation (VenaSeal)

  • Medical adhesive injected into the vein, sealing it shut
  • No tumescent anaesthetic
  • No compression hosiery required post-procedure

5. Surgical Treatment (Still indicated in selected cases)

Saphenofemoral Junction (SFJ) Ligation and GSV Stripping:
  • Under general or spinal anaesthesia
  • Groin crease incision to expose SFJ
  • Tributaries ligated (superficial inferior epigastric, superficial circumflex iliac, external pudendal veins)
  • Flush SFJ ligation performed
  • GSV stripped retrogradely to the knee using a stripper
  • Concurrent avulsion phlebectomy (stab avulsion) of varicosities via 2-3 mm incisions
SSV surgery: patient prone; SPJ identified (variable anatomy - duplex marking essential), SPJ ligated, SSV stripped.
(Bailey & Love, 28th Ed.)

Complications of Surgery / Treatment

Complications of Standard Varicose Vein Surgery

ComplicationNotes
HaematomaCommon; groin or along stripped vein
Wound infectionGroin incision especially
DVT/PETED stockings + mobilisation
Saphenous nerve injuryParaesthesia/numbness medial lower leg (GSV stripping below knee)
Sural nerve injurySSV stripping
Common femoral vein/artery injuryRare but serious
Lymphocoele / lymphatic fistulaGroin
RecurrenceDue to neovascularisation in groin, missed sites, new disease
(Bailey & Love, 28th Ed.)

Varicose Veins in Special Circumstances

Varicose Veins and Pregnancy

  • Hormonal changes (progesterone) cause vein wall relaxation
  • IVC compression by gravid uterus raises venous pressure
  • Management: compression hosiery throughout pregnancy; definitive treatment deferred until 3-6 months after delivery

Bleeding Varicose Veins

  • May be life-threatening in elderly patients on anticoagulants
  • First aid: lie patient flat, elevate limb, apply firm pressure
  • Definitive treatment: injection sclerotherapy or surgery

Venous Ulcers

  • C6 CEAP; typically near medial malleolus
  • Shallow, irregular border, granulation tissue base
  • Management: compression bandaging (multilayer), treatment of underlying reflux, wound care
  • Compression increases healing rates (Cochrane Review)
  • Physiotherapy (leg exercises, calf pump activation) also beneficial

Summary Table: Treatment Options

MethodAnaesthesiaMechanismBest For
EVLATumescent LALaser thermalGSV/SSV reflux, large veins
RFATumescent LARadiofrequency thermalGSV/SSV reflux, standard
UGFSNoneChemical endothelial damageTributary veins, recurrences
MOCANoneMechanical + chemicalMid-sized veins
CyanoacrylateNoneMechanical occlusionStraight truncal veins
SurgeryGA/spinalExcision/strippingAny, complex recurrences
CompressionN/ASymptomaticConservative, pregnancy

Recent Evidence (2024-2025)

  • A 2025 systematic review (PMID 41390389) comparing endovenous ablation vs surgical stripping found that endovenous techniques achieve comparable or superior clinical effectiveness with better patient-reported outcomes, supporting their use as first-line intervention.
  • A 2024 systematic review (PMID 39025298) on anatomical reflux patterns confirmed that GSV reflux is the most common pattern in primary chronic venous disease, informing targeted treatment planning.
  • A 2025 systematic review (PMID 40504402) confirms physiotherapy (calf exercises, compression, positioning) improves venous ulcer healing alongside standard wound care.

Key Points for Exam

  1. Varicose veins = dilated superficial veins ≥3 mm with valvular reflux
  2. Prevalence 30-50%; increased risk with female sex, age, pregnancy, family history, obesity
  3. Primary (intrinsic valve/wall defect) vs. secondary (DVT, AV fistula)
  4. CEAP classification C0-C6 is the gold standard for clinical staging
  5. Pathophysiology: valve failure → retrograde flow → chronic venous hypertension → skin changes → ulceration
  6. Investigation of choice: duplex ultrasound standing with augmentation
  7. Management ladder: compression → endovenous thermal ablation (first-line) → foam sclerotherapy → surgery
  8. EVLA and RFA are equally effective; RFA has slightly lower pain; EVLA better for very large veins
  9. Complications include thrombophlebitis, bleeding, chronic skin changes, and venous ulceration
  10. Saphenous nerve injury is the key nerve injury in GSV stripping below the knee

Sources:
  • Bailey & Love's Short Practice of Surgery, 28th Edition
  • Harrison's Principles of Internal Medicine, 22nd Edition (2025)
  • Schwartz's Principles of Surgery, 11th Edition
  • Gray's Anatomy for Students
  • Lim EQ et al. BMC Surg 2025 [PMID 41390389]
  • Tan MKH et al. J Vasc Surg Venous Lymphat Disord 2024 [PMID 39025298]

Create a summary document on varicose vein management algorithms

Asking for Preferences
Reading File
Running Command

mkdir -p /home/daytona/workspace/varicose-vein-doc && ls /home/daytona/workspace/varicose-vein-doc

Writing File

~/varicose-vein-doc/generate_pdf.py

"""
Varicose Vein Management Algorithm - Summary Document PDF Generator
Target audience: Junior doctors / Residents
"""

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

OUTPUT = "/home/daytona/workspace/varicose-vein-doc/Varicose_Vein_Management_Summary.pdf"

# ─── Colour palette ────────────────────────────────────────────────────────────
NAVY       = colors.HexColor("#1A3A5C")
TEAL       = colors.HexColor("#1E7F8C")
LIGHT_TEAL = colors.HexColor("#D6F0F3")
AMBER      = colors.HexColor("#E07B2A")
AMBER_LIGHT= colors.HexColor("#FEF3E8")
RED        = colors.HexColor("#C0392B")
RED_LIGHT  = colors.HexColor("#FDECEA")
GREEN      = colors.HexColor("#1A7A4A")
GREEN_LIGHT= colors.HexColor("#E8F6EE")
GREY_LIGHT = colors.HexColor("#F4F6F8")
GREY_MID   = colors.HexColor("#DEE2E6")
WHITE      = colors.white
BLACK      = colors.HexColor("#1C1C1C")
PURPLE     = colors.HexColor("#6C3483")
PURPLE_LIGHT = colors.HexColor("#F5EEF8")

PAGE_W, PAGE_H = A4
MARGIN = 2 * cm

# ─── Document setup ────────────────────────────────────────────────────────────
doc = SimpleDocTemplate(
    OUTPUT,
    pagesize=A4,
    leftMargin=MARGIN,
    rightMargin=MARGIN,
    topMargin=MARGIN,
    bottomMargin=MARGIN,
    title="Varicose Vein Management Algorithms",
    author="Orris Medical Reference",
)

CONTENT_W = PAGE_W - 2 * MARGIN

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

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

H1 = style("H1", "Heading1", fontSize=22, textColor=WHITE, spaceAfter=4,
           spaceBefore=0, fontName="Helvetica-Bold", leading=28)
H2 = style("H2", "Heading2", fontSize=13, textColor=NAVY, spaceAfter=4,
           spaceBefore=10, fontName="Helvetica-Bold", leading=18, borderPad=2)
H3 = style("H3", "Heading3", fontSize=11, textColor=TEAL, spaceAfter=3,
           spaceBefore=6, fontName="Helvetica-Bold", leading=15)
BODY = style("BODY", fontSize=9.5, textColor=BLACK, spaceAfter=4, leading=14,
             fontName="Helvetica", alignment=TA_JUSTIFY)
BODY_SM = style("BODY_SM", fontSize=8.5, textColor=BLACK, spaceAfter=3,
                leading=12, fontName="Helvetica")
CAPTION = style("CAPTION", fontSize=8, textColor=colors.HexColor("#555555"),
                spaceAfter=2, leading=10, fontName="Helvetica-Oblique",
                alignment=TA_CENTER)
BULLET = style("BULLET", fontSize=9, textColor=BLACK, spaceAfter=2, leading=13,
               fontName="Helvetica", leftIndent=12)
NOTE = style("NOTE", fontSize=8.5, textColor=colors.HexColor("#333333"),
             spaceAfter=2, leading=12, fontName="Helvetica-Oblique",
             leftIndent=8)
LABEL_W = style("LABEL_W", fontSize=9, textColor=WHITE, fontName="Helvetica-Bold",
                leading=12, alignment=TA_CENTER)
LABEL_B = style("LABEL_B", fontSize=8.5, textColor=BLACK, fontName="Helvetica-Bold",
                leading=11, alignment=TA_LEFT)
LABEL_B_C = style("LABEL_B_C", fontSize=8.5, textColor=BLACK, fontName="Helvetica-Bold",
                  leading=11, alignment=TA_CENTER)
CELL = style("CELL", fontSize=8.5, textColor=BLACK, fontName="Helvetica",
             leading=11)
CELL_C = style("CELL_C", fontSize=8.5, textColor=BLACK, fontName="Helvetica",
               leading=11, alignment=TA_CENTER)
CELL_HDR = style("CELL_HDR", fontSize=9, textColor=WHITE, fontName="Helvetica-Bold",
                 leading=12, alignment=TA_CENTER)
FOOTER_ST = style("FOOTER_ST", fontSize=7.5, textColor=colors.HexColor("#888888"),
                  fontName="Helvetica", alignment=TA_CENTER)

# ─── Helper flowables ──────────────────────────────────────────────────────────

def hr(color=GREY_MID, thickness=0.5, spaceB=4, spaceA=4):
    return HRFlowable(width="100%", thickness=thickness, color=color,
                      spaceAfter=spaceA, spaceBefore=spaceB)

def sp(h=4):
    return Spacer(1, h)

def banner(text, bg=NAVY, fg=WHITE, fs=11):
    tbl = Table([[Paragraph(text, style("_BAN", fontSize=fs, textColor=fg,
                                        fontName="Helvetica-Bold", leading=fs+4,
                                        alignment=TA_CENTER))]],
                colWidths=[CONTENT_W])
    tbl.setStyle(TableStyle([
        ("BACKGROUND", (0, 0), (-1, -1), bg),
        ("ROUNDEDCORNERS", [4]),
        ("TOPPADDING", (0, 0), (-1, -1), 7),
        ("BOTTOMPADDING", (0, 0), (-1, -1), 7),
        ("LEFTPADDING", (0, 0), (-1, -1), 10),
        ("RIGHTPADDING", (0, 0), (-1, -1), 10),
    ]))
    return tbl

def info_box(title, items, bg=LIGHT_TEAL, title_bg=TEAL, w=None):
    """Coloured box with a title row and bullet items."""
    w = w or CONTENT_W
    rows = [[Paragraph(title, LABEL_W)]]
    for it in items:
        rows.append([Paragraph(f"• {it}", BODY_SM)])
    tbl = Table(rows, colWidths=[w])
    s = [
        ("BACKGROUND", (0, 0), (-1, 0), title_bg),
        ("BACKGROUND", (0, 1), (-1, -1), bg),
        ("TOPPADDING", (0, 0), (-1, -1), 5),
        ("BOTTOMPADDING", (0, 0), (-1, -1), 5),
        ("LEFTPADDING", (0, 0), (-1, -1), 8),
        ("RIGHTPADDING", (0, 0), (-1, -1), 8),
        ("LINEBELOW", (0, 0), (-1, 0), 0.5, WHITE),
        ("BOX", (0, 0), (-1, -1), 0.8, title_bg),
    ]
    tbl.setStyle(TableStyle(s))
    return tbl

def side_by_side(left, right, lw=None, rw=None, gap=6):
    lw = lw or (CONTENT_W - gap) / 2
    rw = rw or (CONTENT_W - gap) / 2
    tbl = Table([[left, right]], colWidths=[lw, rw], spaceBefore=2, spaceAfter=2)
    tbl.setStyle(TableStyle([
        ("VALIGN", (0, 0), (-1, -1), "TOP"),
        ("LEFTPADDING", (0, 0), (-1, -1), 0),
        ("RIGHTPADDING", (0, 0), (-1, -1), 0),
        ("TOPPADDING", (0, 0), (-1, -1), 0),
        ("BOTTOMPADDING", (0, 0), (-1, -1), 0),
        ("COLPADDING", (0, 0), (0, 0), [0, 0, gap//2, 0]),
    ]))
    return tbl

def algo_step(number, title, desc, bg=LIGHT_TEAL, num_bg=TEAL, w=None):
    w = w or CONTENT_W
    num_w = 22
    rest_w = w - num_w - 4
    inner = Table([
        [Paragraph(str(number), style("_N", fontSize=11, textColor=WHITE,
                                       fontName="Helvetica-Bold", leading=14,
                                       alignment=TA_CENTER)),
         [Paragraph(title, LABEL_B), Paragraph(desc, BODY_SM)]]
    ], colWidths=[num_w, rest_w])
    inner.setStyle(TableStyle([
        ("BACKGROUND", (0, 0), (0, -1), num_bg),
        ("BACKGROUND", (1, 0), (1, -1), bg),
        ("VALIGN", (0, 0), (-1, -1), "MIDDLE"),
        ("TOPPADDING", (0, 0), (-1, -1), 6),
        ("BOTTOMPADDING", (0, 0), (-1, -1), 6),
        ("LEFTPADDING", (0, 0), (0, -1), 4),
        ("RIGHTPADDING", (0, 0), (0, -1), 4),
        ("LEFTPADDING", (1, 0), (1, -1), 8),
        ("RIGHTPADDING", (1, 0), (1, -1), 8),
        ("BOX", (0, 0), (-1, -1), 0.5, num_bg),
    ]))
    return inner

def arrow_down(w=None, color=TEAL):
    w = w or CONTENT_W
    tbl = Table([[Paragraph("▼", style("_ARR", fontSize=14, textColor=color,
                                        alignment=TA_CENTER, leading=16))]],
                colWidths=[w])
    tbl.setStyle(TableStyle([
        ("TOPPADDING", (0, 0), (-1, -1), 1),
        ("BOTTOMPADDING", (0, 0), (-1, -1), 1),
    ]))
    return tbl

# ─── Page template (header/footer) ─────────────────────────────────────────────

def on_page(canvas, doc):
    canvas.saveState()
    # Header bar
    canvas.setFillColor(NAVY)
    canvas.rect(MARGIN, PAGE_H - MARGIN - 10*mm, CONTENT_W, 10*mm, fill=1, stroke=0)
    canvas.setFont("Helvetica-Bold", 9)
    canvas.setFillColor(WHITE)
    canvas.drawString(MARGIN + 5, PAGE_H - MARGIN - 6.5*mm,
                      "VARICOSE VEIN MANAGEMENT ALGORITHMS")
    canvas.setFont("Helvetica", 8)
    canvas.drawRightString(MARGIN + CONTENT_W - 5, PAGE_H - MARGIN - 6.5*mm,
                           "Junior Doctor / Resident Reference")
    # Footer
    canvas.setFont("Helvetica", 7.5)
    canvas.setFillColor(colors.HexColor("#888888"))
    canvas.drawString(MARGIN, MARGIN - 8, "Sources: Bailey & Love 28th Ed | Harrison's 22nd Ed | Schwartz's Surgery 11th Ed")
    canvas.drawRightString(MARGIN + CONTENT_W, MARGIN - 8,
                           f"Page {doc.page}")
    canvas.setStrokeColor(GREY_MID)
    canvas.setLineWidth(0.5)
    canvas.line(MARGIN, MARGIN - 2, MARGIN + CONTENT_W, MARGIN - 2)
    canvas.restoreState()

# ─── Build story ───────────────────────────────────────────────────────────────
story = []

# ══════════════════════════════════════════════════════════════════════
# TITLE PAGE BLOCK
# ══════════════════════════════════════════════════════════════════════
title_tbl = Table([[Paragraph(
    "Varicose Vein Management Algorithms",
    style("_T", fontSize=24, textColor=WHITE, fontName="Helvetica-Bold",
          leading=30, alignment=TA_CENTER)
)], [Paragraph(
    "A structured clinical reference for junior doctors and residents",
    style("_Sub", fontSize=12, textColor=LIGHT_TEAL, fontName="Helvetica",
          leading=16, alignment=TA_CENTER)
)], [Paragraph(
    "Based on Bailey &amp; Love 28th Ed | Harrison's 22nd Ed | Schwartz's Surgery 11th Ed",
    style("_Src", fontSize=9, textColor=colors.HexColor("#A9CCE3"),
          fontName="Helvetica-Oblique", leading=12, alignment=TA_CENTER)
)]],
colWidths=[CONTENT_W])
title_tbl.setStyle(TableStyle([
    ("BACKGROUND", (0, 0), (-1, -1), NAVY),
    ("TOPPADDING", (0, 0), (-1, 0), 18),
    ("BOTTOMPADDING", (0, 0), (-1, 0), 8),
    ("TOPPADDING", (0, 1), (-1, 1), 0),
    ("BOTTOMPADDING", (0, 1), (-1, 1), 6),
    ("TOPPADDING", (0, 2), (-1, 2), 0),
    ("BOTTOMPADDING", (0, 2), (-1, 2), 18),
    ("LEFTPADDING", (0, 0), (-1, -1), 12),
    ("RIGHTPADDING", (0, 0), (-1, -1), 12),
    ("ROUNDEDCORNERS", [6]),
]))
story.append(sp(14))
story.append(title_tbl)
story.append(sp(10))

# ─── Quick reference pills ─────────────────────────────────────────────────────
def pill(text, bg, fg=WHITE, w=None):
    p = Table([[Paragraph(text, style("_P", fontSize=8.5, textColor=fg,
                                       fontName="Helvetica-Bold", leading=11,
                                       alignment=TA_CENTER))]],
              colWidths=[w or 55*mm])
    p.setStyle(TableStyle([
        ("BACKGROUND", (0, 0), (-1, -1), bg),
        ("TOPPADDING", (0, 0), (-1, -1), 4),
        ("BOTTOMPADDING", (0, 0), (-1, -1), 4),
        ("ROUNDEDCORNERS", [4]),
    ]))
    return p

pills = Table([[
    pill("CEAP Classification", TEAL),
    pill("Duplex USS", AMBER),
    pill("Conservative Mx", GREEN),
    pill("Interventional Mx", NAVY),
    pill("Complications", RED),
]], colWidths=[CONTENT_W / 5] * 5, spaceBefore=0, spaceAfter=6)
pills.setStyle(TableStyle([
    ("LEFTPADDING", (0, 0), (-1, -1), 3),
    ("RIGHTPADDING", (0, 0), (-1, -1), 3),
    ("TOPPADDING", (0, 0), (-1, -1), 0),
    ("BOTTOMPADDING", (0, 0), (-1, -1), 0),
]))
story.append(pills)
story.append(sp(4))

# ══════════════════════════════════════════════════════════════════════
# SECTION 1 — DEFINITION & CLASSIFICATION
# ══════════════════════════════════════════════════════════════════════
story.append(banner("1. DEFINITION & CLASSIFICATION", NAVY))
story.append(sp(6))

story.append(Paragraph(
    "Varicose veins are <b>dilated, tortuous superficial veins ≥ 3 mm in diameter</b> containing "
    "incompetent (refluxing) valves. They affect 30–50% of adults and represent the most common "
    "manifestation of chronic venous disease (CVD).",
    BODY))
story.append(sp(4))

# Venous classification table
def_data = [
    [Paragraph("Type", CELL_HDR), Paragraph("Diameter", CELL_HDR),
     Paragraph("Appearance", CELL_HDR), Paragraph("Symptoms", CELL_HDR)],
    [Paragraph("Telangiectasia\n(spider/thread veins)", CELL),
     Paragraph("< 1 mm", CELL_C),
     Paragraph("Linear/web; red-blue, intradermal", CELL),
     Paragraph("Cosmetic only", CELL)],
    [Paragraph("Reticular veins", CELL),
     Paragraph("1–2.9 mm", CELL_C),
     Paragraph("Blue-green, subdermal, non-protuberant", CELL),
     Paragraph("Usually none", CELL)],
    [Paragraph("Varicose veins", CELL),
     Paragraph("≥ 3 mm", CELL_C),
     Paragraph("Tortuous, protuberant, subcutaneous", CELL),
     Paragraph("Aching, heaviness, swelling", CELL)],
]
def_tbl = Table(def_data,
                colWidths=[CONTENT_W * 0.28, CONTENT_W * 0.14,
                           CONTENT_W * 0.35, CONTENT_W * 0.23])
def_tbl.setStyle(TableStyle([
    ("BACKGROUND", (0, 0), (-1, 0), NAVY),
    ("BACKGROUND", (0, 2), (-1, 2), GREY_LIGHT),
    ("GRID", (0, 0), (-1, -1), 0.4, GREY_MID),
    ("TOPPADDING", (0, 0), (-1, -1), 5),
    ("BOTTOMPADDING", (0, 0), (-1, -1), 5),
    ("LEFTPADDING", (0, 0), (-1, -1), 6),
    ("RIGHTPADDING", (0, 0), (-1, -1), 6),
    ("VALIGN", (0, 0), (-1, -1), "MIDDLE"),
]))
story.append(def_tbl)
story.append(sp(8))

# Primary vs Secondary
story.append(H3.clone("H3a").clone("H3b"))
story.append(Paragraph("<b>Primary vs Secondary Varicose Veins</b>", H3))
story.append(sp(3))

pvsec_data = [
    [Paragraph("PRIMARY", CELL_HDR), Paragraph("SECONDARY", CELL_HDR)],
    [Paragraph(
        "• Intrinsic valve/vein wall defect\n"
        "• ~50% have a family history\n"
        "• Associated: age, obesity, pregnancy,\n"
        "  hormonal therapy, prolonged standing\n"
        "• Most common type",
        BODY_SM),
     Paragraph(
        "• Result of venous hypertension\n"
        "• Causes: DVT (post-thrombotic), deep\n"
        "  venous obstruction, incompetent perforators,\n"
        "  AV fistulas, Klippel-Trenaunay syndrome\n"
        "• Must exclude deep disease before treatment",
        BODY_SM)],
]
pvsec_tbl = Table(pvsec_data, colWidths=[CONTENT_W / 2, CONTENT_W / 2])
pvsec_tbl.setStyle(TableStyle([
    ("BACKGROUND", (0, 0), (0, 0), TEAL),
    ("BACKGROUND", (1, 0), (1, 0), AMBER),
    ("BACKGROUND", (0, 1), (0, 1), LIGHT_TEAL),
    ("BACKGROUND", (1, 1), (1, 1), AMBER_LIGHT),
    ("GRID", (0, 0), (-1, -1), 0.4, GREY_MID),
    ("TOPPADDING", (0, 0), (-1, -1), 6),
    ("BOTTOMPADDING", (0, 0), (-1, -1), 6),
    ("LEFTPADDING", (0, 0), (-1, -1), 8),
    ("RIGHTPADDING", (0, 0), (-1, -1), 8),
    ("VALIGN", (0, 0), (-1, -1), "TOP"),
]))
story.append(pvsec_tbl)
story.append(sp(8))

# ══════════════════════════════════════════════════════════════════════
# SECTION 2 — CEAP CLASSIFICATION
# ══════════════════════════════════════════════════════════════════════
story.append(banner("2. CEAP CLASSIFICATION", TEAL))
story.append(sp(6))

story.append(Paragraph(
    "The CEAP system (Clinical-Etiology-Anatomy-Pathophysiology) is the internationally "
    "accepted standard for describing chronic venous disease. The <b>Clinical (C)</b> grade "
    "directly guides management decisions.",
    BODY))
story.append(sp(5))

ceap_data = [
    [Paragraph("Class", CELL_HDR), Paragraph("Description", CELL_HDR),
     Paragraph("Clinical Features", CELL_HDR), Paragraph("Action", CELL_HDR)],
    [Paragraph("C0", LABEL_B_C), Paragraph("No signs", CELL),
     Paragraph("Normal examination", CELL),
     Paragraph("Reassure; lifestyle advice", CELL)],
    [Paragraph("C1", LABEL_B_C), Paragraph("Telangiectasia/\nreticular veins", CELL),
     Paragraph("Spider/thread veins; no oedema", CELL),
     Paragraph("Cosmetic sclerotherapy if desired", CELL)],
    [Paragraph("C2", LABEL_B_C), Paragraph("Varicose veins", CELL),
     Paragraph("Dilated, tortuous veins ≥ 3 mm", CELL),
     Paragraph("Compression ± intervention if symptomatic", CELL)],
    [Paragraph("C3", LABEL_B_C), Paragraph("Oedema", CELL),
     Paragraph("Ankle/leg oedema; no skin changes", CELL),
     Paragraph("Compression; consider intervention", CELL)],
    [Paragraph("C4a", LABEL_B_C), Paragraph("Pigmentation/\nEczema", CELL),
     Paragraph("Haemosiderin deposits; stasis dermatitis", CELL),
     Paragraph("Intervention indicated", CELL)],
    [Paragraph("C4b", LABEL_B_C), Paragraph("Lipodermatosclerosis/\nAtrophie blanche", CELL),
     Paragraph("Skin induration; white scars near malleolus", CELL),
     Paragraph("Urgent intervention", CELL)],
    [Paragraph("C5", LABEL_B_C), Paragraph("Healed venous ulcer", CELL),
     Paragraph("Scar at previous ulcer site", CELL),
     Paragraph("Intervention to prevent recurrence", CELL)],
    [Paragraph("C6", LABEL_B_C), Paragraph("Active venous ulcer", CELL),
     Paragraph("Open ulcer near malleolus", CELL),
     Paragraph("Urgent: compression + wound care + intervention", CELL)],
]
ceap_tbl = Table(ceap_data,
                 colWidths=[CONTENT_W * 0.1, CONTENT_W * 0.22,
                            CONTENT_W * 0.33, CONTENT_W * 0.35])
ceap_colors = [GREY_LIGHT, WHITE, GREY_LIGHT, WHITE, GREY_LIGHT, WHITE, GREY_LIGHT, WHITE]
ceap_style = [
    ("BACKGROUND", (0, 0), (-1, 0), NAVY),
    ("GRID", (0, 0), (-1, -1), 0.4, GREY_MID),
    ("TOPPADDING", (0, 0), (-1, -1), 5),
    ("BOTTOMPADDING", (0, 0), (-1, -1), 5),
    ("LEFTPADDING", (0, 0), (-1, -1), 6),
    ("RIGHTPADDING", (0, 0), (-1, -1), 6),
    ("VALIGN", (0, 0), (-1, -1), "MIDDLE"),
    ("BACKGROUND", (0, 5), (-1, 5), colors.HexColor("#FFF8E7")),
    ("BACKGROUND", (0, 6), (-1, 6), colors.HexColor("#FFF8E7")),
    ("BACKGROUND", (0, 7), (-1, 7), GREEN_LIGHT),
    ("BACKGROUND", (0, 8), (-1, 8), RED_LIGHT),
    ("TEXTCOLOR", (0, 1), (0, -1), NAVY),
    ("FONTNAME", (0, 1), (0, -1), "Helvetica-Bold"),
]
ceap_tbl.setStyle(TableStyle(ceap_style))
story.append(ceap_tbl)
story.append(sp(4))
story.append(Paragraph(
    "<i>Note: CEAP also includes Etiology (Ep primary / Es secondary / Ec congenital), "
    "Anatomy (As superficial / Ad deep / Ap perforating), and Pathophysiology (Pr reflux / "
    "Po obstruction). Document all four elements in referral letters.</i>",
    NOTE))
story.append(sp(8))

# ══════════════════════════════════════════════════════════════════════
# SECTION 3 — ASSESSMENT ALGORITHM
# ══════════════════════════════════════════════════════════════════════
story.append(banner("3. CLINICAL ASSESSMENT ALGORITHM", NAVY))
story.append(sp(8))

# Step-by-step algorithm
steps = [
    ("1", "HISTORY", "Duration, symptoms (aching, heaviness, throbbing, itching, swelling), "
     "effect on QoL, prior DVT/thrombophlebitis, family history, pregnancies, occupational risk, "
     "medications (OCP/HRT)"),
    ("2", "EXAMINATION (Patient Standing)",
     "Inspect for distribution of varicosities. "
     "GSV territory: medial thigh/calf. SSV territory: posterolateral calf. AAGSV: anterolateral "
     "thigh/calf. Check for saphena varix (groin lump, cough impulse). "
     "Document CEAP class (skin changes, ulceration)."),
    ("3", "DUPLEX ULTRASOUND (ALL patients before intervention)",
     "Standing position. 7.5–13 MHz linear probe. Assess SFJ and SPJ competence. Map reflux: "
     ">0.5 sec in superficial veins, >1 sec in deep veins. Identify perforator incompetence. "
     "Exclude deep venous obstruction. Measure vein diameter."),
    ("4", "ASSESS FOR SECONDARY CAUSES",
     "If deep venous disease found: post-thrombotic syndrome? AV fistula? "
     "Pelvic venous insufficiency? Klippel-Trenaunay? Consider CT/MR venography if indicated. "
     "Treatment of secondary varicose veins requires treating the underlying cause first."),
    ("5", "DETERMINE CEAP CLASS & MANAGEMENT PATHWAY",
     "Use CEAP clinical grade to direct management. "
     "C0-C2 asymptomatic: conservative. C2 symptomatic + C3-C6: active intervention pathway."),
]

for s in steps:
    story.append(algo_step(s[0], s[1], s[2]))
    story.append(sp(3))

story.append(sp(4))
story.append(Paragraph(
    "<b>Key Point:</b> Tourniquet tests (Brodie-Trendelenburg, Perthes) and handheld Doppler "
    "have been <b>abandoned</b> in favour of duplex ultrasound. All patients should have "
    "duplex USS before intervention.",
    style("KP", fontSize=9, textColor=NAVY, fontName="Helvetica-Bold",
          leading=13, leftIndent=8, borderPad=5,
          borderColor=TEAL, borderWidth=1)))
story.append(sp(8))

# ══════════════════════════════════════════════════════════════════════
# SECTION 4 — MANAGEMENT ALGORITHM (main flowchart-style)
# ══════════════════════════════════════════════════════════════════════
story.append(PageBreak())
story.append(sp(14))  # space for header
story.append(banner("4. MANAGEMENT ALGORITHM", NAVY))
story.append(sp(6))

# Node styling helper
def flow_node(text, bg, fg=WHITE, w=None, fs=9):
    w = w or CONTENT_W
    t = Table([[Paragraph(text, style("_FN", fontSize=fs, textColor=fg,
                                       fontName="Helvetica-Bold", leading=fs + 3,
                                       alignment=TA_CENTER))]],
              colWidths=[w])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0, 0), (-1, -1), bg),
        ("TOPPADDING", (0, 0), (-1, -1), 7),
        ("BOTTOMPADDING", (0, 0), (-1, -1), 7),
        ("LEFTPADDING", (0, 0), (-1, -1), 10),
        ("RIGHTPADDING", (0, 0), (-1, -1), 10),
        ("BOX", (0, 0), (-1, -1), 0.8, bg),
        ("ROUNDEDCORNERS", [4]),
    ]))
    return t

story.append(flow_node("PATIENT PRESENTS WITH VARICOSE VEINS", NAVY, WHITE))
story.append(arrow_down())
story.append(flow_node("Duplex USS + Clinical Assessment + CEAP Grading", TEAL, WHITE))
story.append(arrow_down())
story.append(sp(2))

# Decision branch
branch_data = [[
    Table([
        [flow_node("ASYMPTOMATIC\nC0–C2", GREY_LIGHT, NAVY, fs=9)],
        [Paragraph("▼", style("_A2", fontSize=14, textColor=GREEN, alignment=TA_CENTER))],
        [flow_node("CONSERVATIVE\nMANAGEMENT", GREEN, WHITE, fs=9)],
        [Paragraph(
            "• Reassurance\n• Compression hosiery\n  (20–30 mmHg graduated)\n"
            "• Weight reduction\n• Regular walking/exercise\n• Leg elevation\n"
            "• Avoid prolonged standing",
            BODY_SM)],
    ], colWidths=[(CONTENT_W - 8) / 2]),
    Table([
        [flow_node("SYMPTOMATIC C2 or\nC3–C6 / Complications", RED_LIGHT, RED, fs=9)],
        [Paragraph("▼", style("_A3", fontSize=14, textColor=AMBER, alignment=TA_CENTER))],
        [flow_node("INDICATIONS FOR\nINTERVENTION", AMBER, WHITE, fs=9)],
        [Paragraph(
            "• Symptoms unrelieved by compression\n• CEAP C3–C6\n"
            "• Lipodermatosclerosis\n• Active/healed venous ulcer\n"
            "• Recurrent superficial thrombophlebitis\n• Bleeding varicosities\n"
            "• Significant cosmetic concern",
            BODY_SM)],
    ], colWidths=[(CONTENT_W - 8) / 2]),
]]
branch_tbl = Table(branch_data, colWidths=[(CONTENT_W - 8) / 2, (CONTENT_W - 8) / 2])
branch_tbl.setStyle(TableStyle([
    ("VALIGN", (0, 0), (-1, -1), "TOP"),
    ("LEFTPADDING", (0, 0), (-1, -1), 0),
    ("RIGHTPADDING", (0, 0), (-1, -1), 0),
    ("TOPPADDING", (0, 0), (-1, -1), 0),
    ("BOTTOMPADDING", (0, 0), (-1, -1), 0),
    ("COLPADDING", (0, 0), (0, 0), [0, 0, 4, 0]),
    ("COLPADDING", (1, 0), (1, 0), [4, 0, 0, 0]),
]))
story.append(branch_tbl)
story.append(sp(8))

# ── Intervention options ────────────────────────────────────────────────────────
story.append(banner("INTERVENTION SELECTION ALGORITHM", TEAL))
story.append(sp(6))

story.append(flow_node("Confirm Intervention is Indicated (see above)", TEAL))
story.append(arrow_down())
story.append(flow_node("Is the deep venous system patent?\n(Exclude post-thrombotic / deep venous obstruction on Duplex)", GREY_LIGHT, NAVY))
story.append(sp(3))

# Yes / No branches
yesno_data = [[
    Table([
        [flow_node("YES — Deep system patent\n(Treat superficial disease)", GREEN, WHITE, fs=9)],
        [Paragraph("▼", style("_A4", fontSize=14, textColor=TEAL, alignment=TA_CENTER))],
        [flow_node("ENDOVENOUS THERMAL ABLATION\n(First-line)", TEAL, WHITE, fs=9)],
        [Paragraph(
            "<b>EVLA</b> (Endovenous Laser Ablation)\n"
            "Wavelength 1470 nm; suitable for any\n"
            "cannulable vein; best for large veins >15 mm\n\n"
            "<b>RFA</b> (Radiofrequency Ablation)\n"
            "ClosureFast; single button treatment cycle;\n"
            "marginally less pain/bruising post-op\n\n"
            "<b>Both require:</b> tumescent LA + compression\n"
            "hosiery 7–14 days post-procedure",
            BODY_SM)],
    ], colWidths=[(CONTENT_W - 8) / 2]),
    Table([
        [flow_node("NO — Deep disease present\n(Caution: don't ablate safety valves)", RED_LIGHT, RED, fs=9)],
        [Paragraph("▼", style("_A5", fontSize=14, textColor=AMBER, alignment=TA_CENTER))],
        [flow_node("SPECIALIST REFERRAL +\nCOMPRESSION ONLY", AMBER, WHITE, fs=9)],
        [Paragraph(
            "Deep venous obstruction may mean\n"
            "superficial varicosities are acting as\n"
            "collaterals — do not ablate without\n"
            "specialist vascular surgery input.\n\n"
            "Post-thrombotic syndrome:\n"
            "Consider anticoagulation +\n"
            "compression; some may have\n"
            "endovenous stenting.",
            BODY_SM)],
    ], colWidths=[(CONTENT_W - 8) / 2]),
]]
yesno_tbl = Table(yesno_data, colWidths=[(CONTENT_W - 8) / 2, (CONTENT_W - 8) / 2])
yesno_tbl.setStyle(TableStyle([
    ("VALIGN", (0, 0), (-1, -1), "TOP"),
    ("LEFTPADDING", (0, 0), (-1, -1), 0),
    ("RIGHTPADDING", (0, 0), (-1, -1), 0),
    ("TOPPADDING", (0, 0), (-1, -1), 0),
    ("BOTTOMPADDING", (0, 0), (-1, -1), 0),
]))
story.append(yesno_tbl)
story.append(sp(6))
story.append(arrow_down(color=NAVY))
story.append(sp(3))
story.append(flow_node(
    "Residual varicosities after truncal ablation:\n"
    "Phlebectomy (stab avulsion) OR Foam Sclerotherapy",
    GREY_LIGHT, NAVY))
story.append(sp(8))

# ══════════════════════════════════════════════════════════════════════
# SECTION 5 — TREATMENT MODALITIES COMPARISON
# ══════════════════════════════════════════════════════════════════════
story.append(PageBreak())
story.append(sp(14))
story.append(banner("5. TREATMENT MODALITIES AT A GLANCE", NAVY))
story.append(sp(6))

mod_data = [
    [Paragraph("Method", CELL_HDR), Paragraph("Mechanism", CELL_HDR),
     Paragraph("Anaesthesia", CELL_HDR), Paragraph("Best For", CELL_HDR),
     Paragraph("Key Points", CELL_HDR)],
    [Paragraph("EVLA\n(Laser)", LABEL_B_C),
     Paragraph("Laser thermal energy (1470 nm)\ndestroys vein wall", CELL),
     Paragraph("Tumescent LA", CELL_C),
     Paragraph("GSV/SSV; veins >15 mm", CELL),
     Paragraph("Highest technical efficacy;\nrequires laser safety protocols;\nmore expensive consumables", CELL)],
    [Paragraph("RFA\n(Radiofrequency)", LABEL_B_C),
     Paragraph("Radiofrequency thermal\ncoagulation of vein wall", CELL),
     Paragraph("Tumescent LA", CELL_C),
     Paragraph("GSV/SSV; standard veins", CELL),
     Paragraph("Single button cycle;\nshorter learning curve;\nmarginal pain/bruising benefit", CELL)],
    [Paragraph("UGFS\n(Foam Sclerotherapy)", LABEL_B_C),
     Paragraph("Sclerosant foam (Tessari method)\ndamages endothelium", CELL),
     Paragraph("None required", CELL_C),
     Paragraph("Tributaries; recurrences;\nulcer-adjacent veins", CELL),
     Paragraph("Max 10–12 mL/session;\nlower efficacy than thermal;\nhigh reintervention rate", CELL)],
    [Paragraph("MOCA\n(ClariVein)", LABEL_B_C),
     Paragraph("Mechanical wire + simultaneous\nsclerosant injection", CELL),
     Paragraph("None required", CELL_C),
     Paragraph("Mid-sized veins", CELL),
     Paragraph("No heat; no tumescent;\ngood for tortuous veins", CELL)],
    [Paragraph("Cyanoacrylate\n(VenaSeal)", LABEL_B_C),
     Paragraph("Medical glue seals\nvein lumen", CELL),
     Paragraph("None required", CELL_C),
     Paragraph("Straight truncal veins", CELL),
     Paragraph("No compression needed post-op;\nallergen risk (rare)", CELL)],
    [Paragraph("Surgery\n(Stripping)", LABEL_B_C),
     Paragraph("SFJ ligation + GSV stripped\nretrogradely to knee", CELL),
     Paragraph("GA or spinal", CELL_C),
     Paragraph("Complex/recurrent;\nany anatomy", CELL),
     Paragraph("Flush SFJ ligation;\nphlebectomy concurrent;\nsaphenous nerve risk below knee", CELL)],
    [Paragraph("Compression\nHosiery", LABEL_B_C),
     Paragraph("Graduated external compression\nreduces venous hypertension", CELL),
     Paragraph("N/A", CELL_C),
     Paragraph("Conservative/pregnancy;\nadj. post-procedure", CELL),
     Paragraph("20–30 / 30–40 / 40–50 mmHg;\nknee-high to waist-high;\ndoes not treat reflux", CELL)],
]
row_bg = [WHITE, GREY_LIGHT, WHITE, GREY_LIGHT, WHITE, GREY_LIGHT, WHITE]
mod_style = [
    ("BACKGROUND", (0, 0), (-1, 0), NAVY),
    ("GRID", (0, 0), (-1, -1), 0.4, GREY_MID),
    ("TOPPADDING", (0, 0), (-1, -1), 5),
    ("BOTTOMPADDING", (0, 0), (-1, -1), 5),
    ("LEFTPADDING", (0, 0), (-1, -1), 6),
    ("RIGHTPADDING", (0, 0), (-1, -1), 6),
    ("VALIGN", (0, 0), (-1, -1), "TOP"),
    ("TEXTCOLOR", (0, 1), (0, -1), NAVY),
    ("FONTNAME", (0, 1), (0, -1), "Helvetica-Bold"),
]
for i, c in enumerate(row_bg):
    mod_style.append(("BACKGROUND", (1, i + 1), (-1, i + 1), c))
mod_tbl = Table(mod_data,
                colWidths=[CONTENT_W * 0.14, CONTENT_W * 0.22,
                           CONTENT_W * 0.12, CONTENT_W * 0.2,
                           CONTENT_W * 0.32])
mod_tbl.setStyle(TableStyle(mod_style))
story.append(mod_tbl)
story.append(sp(8))

# ══════════════════════════════════════════════════════════════════════
# SECTION 6 — SPECIAL SITUATIONS
# ══════════════════════════════════════════════════════════════════════
story.append(banner("6. SPECIAL CLINICAL SITUATIONS", PURPLE))
story.append(sp(6))

special = [
    ("VENOUS ULCER (C5/C6)", PURPLE, PURPLE_LIGHT, [
        "Shallow ulcer near medial malleolus; irregular borders; granulation base",
        "First-line: multilayer compression bandaging (changes weekly) — Cochrane evidence confirms compression increases healing vs no compression",
        "Wound care: moisture-retaining dressings; treat secondary infection",
        "Treat underlying reflux — laser/RFA accelerates ulcer healing and reduces recurrence",
        "Unna's boot: zinc oxide impregnated dressing + elastic wrap; changes weekly",
        "Refer to vascular surgery/tissue viability nurse if not healing in 12 weeks",
    ]),
    ("SUPERFICIAL VEIN THROMBOSIS (Thrombophlebitis)", AMBER, AMBER_LIGHT, [
        "Painful, red, indurated, palpable cord along varicosity",
        "Distinguish from DVT: duplex USS if any doubt (5–10% have concomitant DVT)",
        "Treatment: NSAIDs + topical heparin for symptom relief",
        "Anticoagulation (fondaparinux 2.5 mg daily x 45 days) if thrombus within 3 cm of SFJ",
        "Definitive: treat underlying varicosities once acute episode settled",
    ]),
    ("BLEEDING VARICOSE VEINS", RED, RED_LIGHT, [
        "Can be life-threatening especially in elderly / anticoagulated patients",
        "First aid: LIE PATIENT FLAT, ELEVATE LIMB, apply FIRM DIRECT PRESSURE",
        "Do NOT apply tourniquet — raises venous pressure, worsens bleeding",
        "Definitive: injection sclerotherapy or surgical treatment",
        "If anticoagulated: consider reversal if life-threatening haemorrhage",
    ]),
    ("VARICOSE VEINS IN PREGNANCY", GREEN, GREEN_LIGHT, [
        "Progesterone causes vein wall relaxation; gravid uterus compresses IVC",
        "Manage with graduated compression hosiery (20–30 mmHg) throughout pregnancy",
        "Avoid intervention during pregnancy (increased recurrence risk, DVT risk)",
        "Definitive treatment deferred until 3–6 months post-partum (many improve)",
        "Advise: regular walking, avoid prolonged standing, leg elevation when resting",
    ]),
    ("RECURRENT VARICOSE VEINS", NAVY, LIGHT_TEAL, [
        "Most commonly due to neovascularisation at groin after surgery",
        "Also: missed tributaries/perforators, new disease, inadequate initial treatment",
        "Duplex USS essential — maps recurrent reflux pattern before any re-intervention",
        "Treatment: foam sclerotherapy preferred for neovascular tissue (surgery in fibrous field is hazardous)",
        "Refer to specialist vascular centre for complex recurrence",
    ]),
]

for title, tc, bg, items in special:
    story.append(info_box(title, items, bg=bg, title_bg=tc, w=CONTENT_W))
    story.append(sp(5))

story.append(sp(4))

# ══════════════════════════════════════════════════════════════════════
# SECTION 7 — COMPLICATIONS
# ══════════════════════════════════════════════════════════════════════
story.append(PageBreak())
story.append(sp(14))
story.append(banner("7. COMPLICATIONS OF VARICOSE VEINS & THEIR TREATMENT", RED))
story.append(sp(6))

comp_data = [
    [Paragraph("Complication", CELL_HDR), Paragraph("Notes", CELL_HDR),
     Paragraph("Management", CELL_HDR)],
    # Chronic
    [Paragraph("Oedema (C3)", CELL),
     Paragraph("Pitting initially; later non-pitting; lymphoedema may develop", CELL),
     Paragraph("Compression hosiery; treat underlying reflux", CELL)],
    [Paragraph("Hyperpigmentation\n(C4a)", CELL),
     Paragraph("Haemosiderin from RBC extravasation; permanent once established", CELL),
     Paragraph("Treat reflux to prevent progression; camouflage", CELL)],
    [Paragraph("Venous eczema\n(C4a)", CELL),
     Paragraph("Stasis dermatitis; erythema, weeping, pruritus", CELL),
     Paragraph("Topical steroids; emollients; compression; treat reflux", CELL)],
    [Paragraph("Lipodermatosclerosis\n(C4b)", CELL),
     Paragraph("Induration + inflammation lower leg; 'inverted champagne bottle'", CELL),
     Paragraph("Urgent intervention; some changes irreversible", CELL)],
    [Paragraph("Atrophie blanche\n(C4b)", CELL),
     Paragraph("White scars + telangiectasias near medial malleolus", CELL),
     Paragraph("Compression; treat reflux; wound care if ulcerates", CELL)],
    [Paragraph("Venous ulcer\n(C5/C6)", CELL),
     Paragraph("Near malleoli; shallow, irregular; granulation base; exudate", CELL),
     Paragraph("Multilayer compression + wound care + reflux treatment", CELL)],
    # Acute
    [Paragraph("Superficial vein\nthrombosis", CELL),
     Paragraph("Painful cord; check for DVT within 3 cm of SFJ", CELL),
     Paragraph("NSAIDs; fondaparinux if near SFJ; treat varicosities", CELL)],
    [Paragraph("Bleeding", CELL),
     Paragraph("Spontaneous from thin-walled vein; life-threatening in elderly", CELL),
     Paragraph("Lie flat, elevate, pressure; sclerotherapy/surgery", CELL)],
    # Post-treatment
    [Paragraph("Saphenous nerve\ninjury (surgery)", CELL),
     Paragraph("Medial lower leg paraesthesia; if GSV stripped below knee", CELL),
     Paragraph("Usually temporary; avoid stripping below knee", CELL)],
    [Paragraph("Sural nerve injury\n(surgery)", CELL),
     Paragraph("Lateral foot numbness; SSV stripping", CELL),
     Paragraph("Careful dissection; duplex-guided SPJ marking", CELL)],
    [Paragraph("DVT/PE\n(any treatment)", CELL),
     Paragraph("Risk low with current techniques; higher post-surgical", CELL),
     Paragraph("TED stockings + early mobilisation; anticoagulate if occurs", CELL)],
    [Paragraph("Recurrence", CELL),
     Paragraph("Neovascularisation in groin; missed tributaries; new disease", CELL),
     Paragraph("Foam sclerotherapy for neovascular disease; duplex-guided", CELL)],
]
comp_style = [
    ("BACKGROUND", (0, 0), (-1, 0), RED),
    ("GRID", (0, 0), (-1, -1), 0.4, GREY_MID),
    ("TOPPADDING", (0, 0), (-1, -1), 5),
    ("BOTTOMPADDING", (0, 0), (-1, -1), 5),
    ("LEFTPADDING", (0, 0), (-1, -1), 6),
    ("RIGHTPADDING", (0, 0), (-1, -1), 6),
    ("VALIGN", (0, 0), (-1, -1), "TOP"),
    ("BACKGROUND", (0, 7), (-1, 8), colors.HexColor("#FEF5E7")),  # acute orange tint
    ("BACKGROUND", (0, 9), (-1, -1), colors.HexColor("#F8F9FA")),  # post-treatment grey
]
for i in [1, 3, 5, 7, 9, 11]:
    comp_style.append(("BACKGROUND", (0, i), (-1, i), GREY_LIGHT))
comp_tbl = Table(comp_data,
                 colWidths=[CONTENT_W * 0.22, CONTENT_W * 0.42, CONTENT_W * 0.36])
comp_tbl.setStyle(TableStyle(comp_style))
story.append(comp_tbl)
story.append(sp(8))

# ══════════════════════════════════════════════════════════════════════
# SECTION 8 — QUICK REFERENCE: DUPLEX USS PROTOCOL
# ══════════════════════════════════════════════════════════════════════
story.append(banner("8. DUPLEX ULTRASOUND QUICK REFERENCE", TEAL))
story.append(sp(6))

uss_left = Table([
    [Paragraph("PROTOCOL CHECKLIST", LABEL_W)],
    [Paragraph(
        "□  Patient STANDING (mandatory)\n"
        "□  Linear probe 7.5–13 MHz\n"
        "□  Optimise B-mode: lumen appears as dark void\n"
        "□  Blue = antegrade (normal); Red = retrograde (reflux)\n"
        "□  Augment flow with calf squeeze\n"
        "□  Start at groin: identify 'Mickey Mouse' sign\n"
        "   (CFA + CFV + GSV in transverse)\n"
        "□  Assess SFJ competence\n"
        "□  Map full GSV in saphenous fascia compartment\n"
        "□  Assess SPJ and SSV\n"
        "□  Identify incompetent perforators\n"
        "□  Exclude deep venous obstruction\n"
        "□  Measure vein diameter at SFJ/SPJ and mid-thigh",
        BODY_SM)],
], colWidths=[(CONTENT_W - 6) / 2])
uss_left.setStyle(TableStyle([
    ("BACKGROUND", (0, 0), (-1, 0), TEAL),
    ("BACKGROUND", (0, 1), (-1, 1), LIGHT_TEAL),
    ("TOPPADDING", (0, 0), (-1, -1), 6),
    ("BOTTOMPADDING", (0, 0), (-1, -1), 6),
    ("LEFTPADDING", (0, 0), (-1, -1), 8),
    ("RIGHTPADDING", (0, 0), (-1, -1), 8),
    ("BOX", (0, 0), (-1, -1), 0.5, TEAL),
]))

uss_right = Table([
    [Paragraph("REFLUX DEFINITIONS", LABEL_W)],
    [Paragraph(
        "<b>Superficial / crural vein reflux:</b>\n"
        "Retrograde flow > 0.5 seconds\n\n"
        "<b>Proximal deep vein reflux:</b>\n"
        "Retrograde flow > 1.0 second\n\n"
        "<b>Elicitation techniques:</b>\n"
        "• Calf/foot squeeze and release\n"
        "• Pneumatic cuff deflation\n"
        "• Active foot dorsiflexion\n"
        "• Valsalva manoeuvre\n\n"
        "<b>Diameter thresholds:</b>\n"
        "• GSV >5 mm at SFJ: significant reflux\n"
        "• Perforator >3.5 mm + reflux: incompetent",
        BODY_SM)],
], colWidths=[(CONTENT_W - 6) / 2])
uss_right.setStyle(TableStyle([
    ("BACKGROUND", (0, 0), (-1, 0), NAVY),
    ("BACKGROUND", (0, 1), (-1, 1), GREY_LIGHT),
    ("TOPPADDING", (0, 0), (-1, -1), 6),
    ("BOTTOMPADDING", (0, 0), (-1, -1), 6),
    ("LEFTPADDING", (0, 0), (-1, -1), 8),
    ("RIGHTPADDING", (0, 0), (-1, -1), 8),
    ("BOX", (0, 0), (-1, -1), 0.5, NAVY),
]))

uss_row = Table([[uss_left, uss_right]],
                colWidths=[(CONTENT_W - 6) / 2, (CONTENT_W - 6) / 2])
uss_row.setStyle(TableStyle([
    ("VALIGN", (0, 0), (-1, -1), "TOP"),
    ("LEFTPADDING", (0, 0), (-1, -1), 0),
    ("RIGHTPADDING", (0, 0), (-1, -1), 0),
    ("COLPADDING", (0, 0), (0, 0), [0, 0, 3, 0]),
    ("COLPADDING", (1, 0), (1, 0), [3, 0, 0, 0]),
]))
story.append(uss_row)
story.append(sp(8))

# ══════════════════════════════════════════════════════════════════════
# SECTION 9 — KEY FACTS & EXAM REMINDERS
# ══════════════════════════════════════════════════════════════════════
story.append(banner("9. KEY FACTS & CLINICAL PEARLS", AMBER))
story.append(sp(6))

pearls = [
    ("Definition", "VVs = dilated superficial vein ≥ 3 mm + valvular reflux"),
    ("Prevalence", "30–50% adults; Edinburgh Vein Study: 11.5% at 18–24 yrs → 55.7% at 55–64 yrs"),
    ("Investigation", "Duplex USS is gold standard — tourniquet tests and handheld Doppler are ABANDONED"),
    ("CEAP", "C0–C2 asymptomatic = conservative; C2 symptomatic + C3–C6 = intervention"),
    ("First-line intervention", "Endovenous thermal ablation (EVLA or RFA) — superior to surgery for most patients"),
    ("EVLA vs RFA", "Equal efficacy; EVLA better for large veins >15 mm; RFA has slightly easier learning curve"),
    ("Foam sclerotherapy", "Tessari method; max 10–12 mL/session; lower efficacy than thermal but adjuvant utility"),
    ("Surgery", "Flush SFJ ligation + retrograde GSV stripping to knee; flush ligation reduces neovascularisation"),
    ("Nerve injury", "Saphenous nerve at risk with GSV stripping below knee (medial lower leg)"),
    ("Saphena varix", "Painless groin lump; disappears lying down; cough impulse — can mimic femoral hernia"),
    ("Bleeding VVs", "Lie flat + elevate + direct pressure — NOT tourniquet; often occurs in elderly at night"),
    ("Pregnancy", "Compression only during pregnancy; defer definitive treatment 3–6 months post-partum"),
    ("Venous ulcer", "Near medial malleolus; treat with multilayer compression + treat underlying reflux"),
    ("SVT near SFJ", "Fondaparinux 2.5 mg daily x 45 days if thrombus within 3 cm of SFJ (risk DVT propagation)"),
    ("2025 evidence", "Systematic review (PMID 41390389, BMC Surg 2025): endovenous ablation = superior/equivalent to surgery with better patient-reported outcomes"),
]

pearl_rows = [[
    Paragraph(p[0], style("_PK", fontSize=8.5, textColor=AMBER,
                           fontName="Helvetica-Bold", leading=11)),
    Paragraph(p[1], BODY_SM)
] for p in pearls]

pearl_tbl = Table(pearl_rows,
                  colWidths=[CONTENT_W * 0.22, CONTENT_W * 0.78])
ps = [
    ("GRID", (0, 0), (-1, -1), 0.3, GREY_MID),
    ("TOPPADDING", (0, 0), (-1, -1), 4),
    ("BOTTOMPADDING", (0, 0), (-1, -1), 4),
    ("LEFTPADDING", (0, 0), (-1, -1), 6),
    ("RIGHTPADDING", (0, 0), (-1, -1), 6),
    ("VALIGN", (0, 0), (-1, -1), "MIDDLE"),
]
for i in range(0, len(pearls), 2):
    ps.append(("BACKGROUND", (0, i), (-1, i), AMBER_LIGHT))
pearl_tbl.setStyle(TableStyle(ps))
story.append(pearl_tbl)
story.append(sp(6))

# ─── References ─────────────────────────────────────────────────────────────────
story.append(hr(GREY_MID, thickness=0.5))
story.append(sp(4))
story.append(Paragraph("<b>References:</b>", BODY_SM))
refs = [
    "Bailey &amp; Love's Short Practice of Surgery, 28th Edition, Chapter 62",
    "Harrison's Principles of Internal Medicine, 22nd Edition (2025), Chapter 293",
    "Schwartz's Principles of Surgery, 11th Edition, Chapter 24",
    "Gray's Anatomy for Students, 4th Edition",
    "Lim EQ et al. Endovenous ablation vs surgical stripping in varicose vein management. BMC Surg 2025 [PMID 41390389]",
    "Tan MKH et al. Anatomical reflux patterns in primary chronic venous disease. J Vasc Surg Venous Lymphat Disord 2024 [PMID 39025298]",
    "Medeiros S et al. Physiotherapy in venous ulcer management. J Wound Care 2025 [PMID 40504402]",
]
for r in refs:
    story.append(Paragraph(f"• {r}", NOTE))

# ─── Build ────────────────────────────────────────────────────────────────────
doc.build(story, onFirstPage=on_page, onLaterPages=on_page)
print(f"PDF generated: {OUTPUT}")
Running Command

cd /home/daytona/workspace/varicose-vein-doc && python generate_pdf.py 2>&1

Editing File

~/varicose-vein-doc/generate_pdf.py

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/varicose-vein-doc/generate_pdf.py'
Running Command

cd /home/daytona/workspace/varicose-vein-doc && python generate_pdf.py 2>&1

Running Command

ls -lh /home/daytona/workspace/varicose-vein-doc/Varicose_Vein_Management_Summary.pdf

Your PDF is ready for download:

Varicose Vein Management Summary

PDF Document · PDF


Here's what's inside the document (4 pages, professionally formatted for junior doctors/residents):
Page 1
  • Title block with colour-coded section pills
  • Section 1 - Definition & Classification: venous spectrum table (telangiectasia → reticular → varicose), primary vs secondary side-by-side comparison boxes
Page 2
  • Section 2 - CEAP Classification: full C0–C6 table with colour-coding (red for C6, green for C5, amber for C4) and management actions per class
  • Section 3 - Clinical Assessment Algorithm: 5 step-by-step numbered flowchart steps (History → Examination → Duplex USS → Secondary causes → CEAP grading) with a clinical pearl banner on duplex replacing tourniquet tests
Page 3
  • Section 4 - Management Algorithm: visual flowchart-style layout - conservative vs intervention branches, deep system patent/obstructed decision tree, intervention selection
  • Section 5 - Treatment Modalities Table: EVLA, RFA, UGFS, MOCA, VenaSeal, Surgery, Compression - mechanism, anaesthesia, best use, key points
Page 4
  • Section 6 - Special Situations: colour-coded boxes for venous ulcer, thrombophlebitis, bleeding varicosities, pregnancy, recurrence
  • Section 7 - Complications Table: chronic + acute + post-treatment complications with management
  • Section 8 - Duplex USS Quick Reference: protocol checklist + reflux definitions side-by-side
  • Section 9 - Clinical Pearls: 15 high-yield facts including 2025 evidence (PMID 41390389)
  • References from Bailey & Love 28th Ed, Harrison's 22nd Ed, Schwartz's 11th Ed

Generate a case-based exam question worksheet on varicose vein management

Asking for Preferences
Running Command

ls /home/daytona/workspace/varicose-vein-doc/

Writing File

~/varicose-vein-doc/generate_worksheet.py

"""
Varicose Vein Management - USMLE-Style SBA Case-Based Exam Worksheet
PDF Generator using ReportLab
"""

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

OUTPUT = "/home/daytona/workspace/varicose-vein-doc/Varicose_Vein_Worksheet.pdf"

PAGE_W, PAGE_H = A4
MARGIN = 2 * cm
CONTENT_W = PAGE_W - 2 * MARGIN

# ─── Colours ──────────────────────────────────────────────────────────────────
NAVY       = colors.HexColor("#1A3A5C")
TEAL       = colors.HexColor("#1E7F8C")
LIGHT_TEAL = colors.HexColor("#D6F0F3")
AMBER      = colors.HexColor("#E07B2A")
AMBER_LIGHT= colors.HexColor("#FEF3E8")
RED        = colors.HexColor("#C0392B")
RED_LIGHT  = colors.HexColor("#FDECEA")
GREEN      = colors.HexColor("#1A7A4A")
GREEN_LIGHT= colors.HexColor("#E8F6EE")
GREY_LIGHT = colors.HexColor("#F4F6F8")
GREY_MID   = colors.HexColor("#DEE2E6")
PURPLE     = colors.HexColor("#6C3483")
PURPLE_LIGHT = colors.HexColor("#F5EEF8")
WHITE      = colors.white
BLACK      = colors.HexColor("#1C1C1C")

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

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

BODY    = S("BODY", fontSize=9.5, leading=14, textColor=BLACK,
            fontName="Helvetica", spaceAfter=4, alignment=TA_JUSTIFY)
BODY_SM = S("BODY_SM", fontSize=9, leading=13, textColor=BLACK,
            fontName="Helvetica", spaceAfter=3)
BOLD    = S("BOLD", fontSize=9.5, leading=14, textColor=BLACK,
            fontName="Helvetica-Bold", spaceAfter=4)
CASE_HDR= S("CASE_HDR", fontSize=10, leading=14, textColor=WHITE,
            fontName="Helvetica-Bold", spaceAfter=0)
CASE_TXT= S("CASE_TXT", fontSize=9.5, leading=14, textColor=BLACK,
            fontName="Helvetica", spaceAfter=3, alignment=TA_JUSTIFY)
Q_NUM   = S("Q_NUM", fontSize=10, leading=14, textColor=NAVY,
            fontName="Helvetica-Bold", spaceAfter=3)
OPT     = S("OPT", fontSize=9.5, leading=13, textColor=BLACK,
            fontName="Helvetica", spaceAfter=2, leftIndent=6)
ANS_HDR = S("ANS_HDR", fontSize=10, leading=14, textColor=WHITE,
            fontName="Helvetica-Bold")
ANS_LBL = S("ANS_LBL", fontSize=9.5, leading=13, textColor=GREEN,
            fontName="Helvetica-Bold", spaceAfter=2)
ANS_WRONG= S("ANS_WRONG", fontSize=9, leading=12, textColor=RED,
             fontName="Helvetica", spaceAfter=2)
ANS_EXP = S("ANS_EXP", fontSize=9, leading=13, textColor=BLACK,
            fontName="Helvetica", spaceAfter=3, alignment=TA_JUSTIFY)
CELL    = S("CELL", fontSize=8.5, leading=11, textColor=BLACK,
            fontName="Helvetica")
CELL_B  = S("CELL_B", fontSize=8.5, leading=11, textColor=BLACK,
            fontName="Helvetica-Bold")
NOTE    = S("NOTE", fontSize=8, leading=11, textColor=colors.HexColor("#555555"),
            fontName="Helvetica-Oblique")
FOOTER  = S("FOOTER", fontSize=7.5, leading=10,
            textColor=colors.HexColor("#888888"),
            fontName="Helvetica", alignment=TA_CENTER)
TAG     = S("TAG", fontSize=7.5, leading=10, textColor=TEAL,
            fontName="Helvetica-Bold")

# ─── Page callbacks ────────────────────────────────────────────────────────────
def on_page(canvas, doc):
    canvas.saveState()
    canvas.setFillColor(NAVY)
    canvas.rect(MARGIN, PAGE_H - MARGIN - 10*mm, CONTENT_W, 10*mm, fill=1, stroke=0)
    canvas.setFont("Helvetica-Bold", 9)
    canvas.setFillColor(WHITE)
    canvas.drawString(MARGIN + 5, PAGE_H - MARGIN - 6.5*mm,
                      "VARICOSE VEIN MANAGEMENT — USMLE-STYLE SBA WORKSHEET")
    canvas.setFont("Helvetica", 8)
    canvas.drawRightString(MARGIN + CONTENT_W - 5, PAGE_H - MARGIN - 6.5*mm,
                           "Case-Based Clinical Examination")
    canvas.setFont("Helvetica", 7.5)
    canvas.setFillColor(colors.HexColor("#888888"))
    canvas.drawString(MARGIN, MARGIN - 8,
                      "Sources: Bailey & Love 28th Ed | Harrison's 22nd Ed | Schwartz's Surgery 11th Ed")
    canvas.drawRightString(MARGIN + CONTENT_W, MARGIN - 8, f"Page {doc.page}")
    canvas.setStrokeColor(GREY_MID)
    canvas.setLineWidth(0.5)
    canvas.line(MARGIN, MARGIN - 2, MARGIN + CONTENT_W, MARGIN - 2)
    canvas.restoreState()

# ─── Helpers ──────────────────────────────────────────────────────────────────
def sp(h=6): return Spacer(1, h)
def hr(c=GREY_MID, t=0.5): return HRFlowable(width="100%", thickness=t, color=c,
                                               spaceAfter=4, spaceBefore=4)

def banner(text, bg=NAVY, fg=WHITE, fs=11):
    t = Table([[Paragraph(text, S("_B", fontSize=fs, textColor=fg,
                                   fontName="Helvetica-Bold", leading=fs+4,
                                   alignment=TA_CENTER))]],
              colWidths=[CONTENT_W])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0, 0), (-1, -1), bg),
        ("TOPPADDING", (0, 0), (-1, -1), 8),
        ("BOTTOMPADDING", (0, 0), (-1, -1), 8),
        ("LEFTPADDING", (0, 0), (-1, -1), 10),
        ("RIGHTPADDING", (0, 0), (-1, -1), 10),
        ("ROUNDEDCORNERS", [4]),
    ]))
    return t

def case_box(case_num, title, vignette, difficulty, topic_tag):
    """Render the clinical vignette box."""
    diff_color = {"Easy": GREEN, "Medium": AMBER, "Hard": RED}.get(difficulty, TEAL)
    header_row = [
        Paragraph(f"CASE {case_num}  |  {title}", CASE_HDR),
        Paragraph(f"{difficulty}  |  {topic_tag}", S("_TG", fontSize=8.5, textColor=WHITE,
                  fontName="Helvetica", leading=11, alignment=TA_RIGHT))
    ]
    t = Table([header_row, [Paragraph(vignette, CASE_TXT), ""]],
              colWidths=[CONTENT_W * 0.70, CONTENT_W * 0.30])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0, 0), (-1, 0), diff_color),
        ("BACKGROUND", (0, 1), (-1, 1), GREY_LIGHT),
        ("SPAN", (0, 1), (1, 1)),
        ("TOPPADDING", (0, 0), (-1, -1), 6),
        ("BOTTOMPADDING", (0, 0), (-1, -1), 6),
        ("LEFTPADDING", (0, 0), (-1, -1), 8),
        ("RIGHTPADDING", (0, 0), (-1, -1), 8),
        ("VALIGN", (0, 0), (-1, -1), "MIDDLE"),
        ("BOX", (0, 0), (-1, -1), 0.8, diff_color),
    ]))
    return t

def question_block(q_num, question_text, options, total_q_num):
    """Render a single question with A-E options."""
    items = [
        Paragraph(f"Q{total_q_num}. {question_text}", Q_NUM),
    ]
    letters = ["A", "B", "C", "D", "E"]
    for i, opt in enumerate(options):
        items.append(Paragraph(f"({letters[i]})  {opt}", OPT))
    items.append(sp(4))
    return items

def answer_block(total_q_num, correct, correct_text, explanation, wrong_explanations=None):
    """Render the answer and explanation block."""
    rows = [
        [Paragraph(f"Q{total_q_num} — Answer: ({correct}) {correct_text}", ANS_HDR)],
        [Paragraph(explanation, ANS_EXP)],
    ]
    if wrong_explanations:
        for letter, text in wrong_explanations.items():
            rows.append([Paragraph(f"✗ ({letter}) {text}", ANS_WRONG)])

    t = Table(rows, colWidths=[CONTENT_W])
    s = TableStyle([
        ("BACKGROUND", (0, 0), (-1, 0), GREEN),
        ("BACKGROUND", (0, 1), (-1, 1), GREEN_LIGHT),
        ("TOPPADDING", (0, 0), (-1, -1), 5),
        ("BOTTOMPADDING", (0, 0), (-1, -1), 5),
        ("LEFTPADDING", (0, 0), (-1, -1), 8),
        ("RIGHTPADDING", (0, 0), (-1, -1), 8),
        ("BOX", (0, 0), (-1, -1), 0.6, GREEN),
        ("LINEBELOW", (0, 0), (-1, 0), 0.5, WHITE),
    ])
    if wrong_explanations:
        for i in range(2, 2 + len(wrong_explanations)):
            s.add("BACKGROUND", (0, i), (-1, i), RED_LIGHT if i % 2 == 0 else colors.HexColor("#FDECEA"))
    t.setStyle(s)
    return t

# ─── QUESTIONS DATA ────────────────────────────────────────────────────────────
# Each entry: (case_num, case_title, vignette, difficulty, tag,
#              q_num_in_case, question, [options A-E],
#              correct_letter, correct_text, explanation, {wrong explanations})

QUESTIONS = [

    # ─── CASE 1 ───────────────────────────────────────────────────────────────
    {
        "case_num": 1,
        "case_title": "Middle-Aged Woman with Leg Heaviness",
        "vignette": (
            "A 48-year-old woman presents to the surgical outpatient clinic with a "
            "6-month history of aching, heaviness, and throbbing in her left leg, "
            "worsening throughout the day and relieved by elevation. She has had two "
            "pregnancies. Examination reveals tortuous, dilated veins along the medial "
            "aspect of the left thigh and calf. There is no skin discolouration, "
            "oedema, or ulceration. She is otherwise well."
        ),
        "difficulty": "Easy",
        "tag": "Diagnosis / CEAP",
        "questions": [
            {
                "q": "Which of the following is the most likely CEAP clinical classification for this patient?",
                "options": [
                    "C1 — Telangiectasias",
                    "C2 — Varicose veins",
                    "C3 — Oedema",
                    "C4a — Pigmentation",
                    "C6 — Active venous ulcer",
                ],
                "correct": "B",
                "correct_text": "C2 — Varicose veins",
                "explanation": (
                    "The patient has dilated, tortuous superficial veins ≥ 3 mm in diameter "
                    "with no skin changes or oedema, placing her at CEAP C2. "
                    "C1 refers to telangiectasias/reticular veins (<3 mm, non-protuberant). "
                    "C3 requires oedema, C4a requires pigmentation or eczema, and C6 requires "
                    "an active ulcer — none of which are present. "
                    "The medial thigh/calf distribution strongly suggests great saphenous vein (GSV) territory incompetence."
                ),
                "wrong": {
                    "A": "C1 is for telangiectasias (<1 mm) and reticular veins (1-3 mm) — these veins are clearly ≥3 mm and protuberant.",
                    "C": "C3 requires documented oedema — absent here.",
                    "D": "C4a requires pigmentation/eczema — the skin is normal.",
                    "E": "C6 is an active venous ulcer — not present.",
                },
            },
            {
                "q": "Which investigation is most appropriate before offering any intervention?",
                "options": [
                    "Brodie-Trendelenburg tourniquet test",
                    "Handheld continuous-wave Doppler",
                    "Duplex ultrasound scanning",
                    "Ascending venography",
                    "Air plethysmography",
                ],
                "correct": "C",
                "correct_text": "Duplex ultrasound scanning",
                "explanation": (
                    "Duplex ultrasound is the gold-standard investigation for varicose veins prior to intervention. "
                    "It maps the exact distribution of reflux, assesses junctional competence (SFJ/SPJ), "
                    "identifies incompetent perforators, and excludes deep venous disease. "
                    "Both tourniquet tests (Brodie-Trendelenburg) and handheld Doppler have been "
                    "ABANDONED in favour of duplex USS. Venography is reserved for complex deep venous "
                    "disease. Plethysmography provides overall functional assessment but not anatomical mapping."
                ),
                "wrong": {
                    "A": "The Brodie-Trendelenburg test is now abandoned — duplex USS gives far superior anatomical information.",
                    "B": "Handheld Doppler has been replaced by duplex USS in modern practice.",
                    "D": "Ascending venography is invasive and reserved for complex deep venous obstruction cases.",
                    "E": "Plethysmography assesses overall venous function but cannot map reflux for treatment planning.",
                },
            },
        ],
    },

    # ─── CASE 2 ───────────────────────────────────────────────────────────────
    {
        "case_num": 2,
        "case_title": "Man with Leg Varicosities and Skin Changes",
        "vignette": (
            "A 62-year-old man presents with a 10-year history of bilateral leg varicose veins. "
            "He now reports worsening ankle swelling and itching. On examination, there are "
            "extensive varicosities bilaterally. The skin around both medial malleoli shows "
            "brownish discolouration, induration, and a firm, woody texture. There is no "
            "open ulceration. He has been wearing compression stockings with partial symptom "
            "relief. Duplex ultrasound confirms bilateral GSV reflux with patent deep venous systems."
        ),
        "difficulty": "Medium",
        "tag": "CEAP / Indications for Tx",
        "questions": [
            {
                "q": "What is the CEAP clinical grade for the skin findings described (induration and hyperpigmentation without ulceration)?",
                "options": [
                    "C3",
                    "C4a",
                    "C4b",
                    "C5",
                    "C6",
                ],
                "correct": "C",
                "correct_text": "C4b",
                "explanation": (
                    "The combination of skin induration (lipodermatosclerosis) and brownish discolouration "
                    "(haemosiderin pigmentation) without ulceration corresponds to CEAP C4b. "
                    "C4a covers pigmentation OR eczema alone. C4b specifically includes lipodermatosclerosis "
                    "and/or atrophie blanche. C5 would require a healed ulcer scar. "
                    "C6 requires an active open ulcer. Lipodermatosclerosis carries high risk of progression "
                    "to ulceration and represents a strong indication for intervention."
                ),
                "wrong": {
                    "A": "C3 is oedema only — no skin changes are present in C3.",
                    "B": "C4a covers pigmentation/eczema alone, not lipodermatosclerosis.",
                    "D": "C5 requires a healed venous ulcer scar — not described here.",
                    "E": "C6 requires an active, open venous ulcer — the skin is intact.",
                },
            },
            {
                "q": "Given the duplex findings, what is the most appropriate next step in management?",
                "options": [
                    "Continue compression stockings indefinitely and reassess in 12 months",
                    "Refer for endovenous thermal ablation (EVLA or RFA)",
                    "Prescribe leg elevation and weight loss programme only",
                    "Perform ascending venography to further characterise the deep system",
                    "Initiate long-term anticoagulation with rivaroxaban",
                ],
                "correct": "B",
                "correct_text": "Refer for endovenous thermal ablation (EVLA or RFA)",
                "explanation": (
                    "C4b disease (lipodermatosclerosis) is a strong indication for active intervention. "
                    "With a patent deep venous system confirmed on duplex, endovenous thermal ablation "
                    "(EVLA or RFA) is the first-line intervention — minimally invasive, performed under "
                    "tumescent local anaesthesia, with superior outcomes and fewer complications than surgery. "
                    "Continued compression alone is inadequate at C4b as skin changes and ulceration risk "
                    "are high. There is no indication for anticoagulation or venography here."
                ),
                "wrong": {
                    "A": "C4b warrants active intervention — compression alone will not reverse lipodermatosclerosis and carries high ulceration risk.",
                    "C": "Lifestyle measures alone are insufficient at CEAP C4b.",
                    "D": "Deep venous system is already confirmed patent on duplex — venography adds nothing.",
                    "E": "Anticoagulation has no role in uncomplicated varicose vein disease.",
                },
            },
        ],
    },

    # ─── CASE 3 ───────────────────────────────────────────────────────────────
    {
        "case_num": 3,
        "case_title": "Young Woman with Painful Red Cord on the Calf",
        "vignette": (
            "A 34-year-old woman presents to the emergency department with a 3-day history of "
            "painful redness and swelling along the posterior aspect of her right calf. She has "
            "known varicose veins in the small saphenous vein (SSV) territory. On examination, "
            "there is a palpable, tender cord along the posteromedial calf with overlying erythema. "
            "The foot is warm with normal pulses. She is systemically well. Duplex ultrasound "
            "shows acute thrombosis of the SSV extending to within 2.5 cm of the saphenopopliteal "
            "junction (SPJ)."
        ),
        "difficulty": "Medium",
        "tag": "Thrombophlebitis",
        "questions": [
            {
                "q": "Which of the following is the most appropriate immediate management?",
                "options": [
                    "NSAIDs alone and discharge with GP follow-up",
                    "Intravenous heparin infusion and hospital admission",
                    "Fondaparinux 2.5 mg subcutaneously daily for 45 days",
                    "Emergency surgical ligation of the SSV at the SPJ",
                    "Compression stockings and topical diclofenac only",
                ],
                "correct": "C",
                "correct_text": "Fondaparinux 2.5 mg subcutaneously daily for 45 days",
                "explanation": (
                    "When superficial vein thrombosis (SVT) extends to within 3 cm of a major junction "
                    "(here the SPJ at <2.5 cm), there is significant risk of propagation into the deep "
                    "venous system causing DVT/PE. Current evidence and guidelines recommend "
                    "fondaparinux 2.5 mg SC daily for 45 days in this scenario. "
                    "NSAIDs alone are adequate only for SVT remote from junctions. "
                    "IV heparin is reserved for confirmed DVT. Emergency surgery is not indicated. "
                    "The same principle applies to SVT within 3 cm of the SFJ in the GSV."
                ),
                "wrong": {
                    "A": "NSAIDs alone are insufficient when thrombus is this close (<3 cm) to the SPJ — risk of deep venous propagation is substantial.",
                    "B": "IV heparin is for confirmed DVT, not superficial vein thrombosis at junction.",
                    "D": "Emergency surgery is not indicated for SVT — anticoagulation is the treatment.",
                    "E": "Topical treatment and compression alone are insufficient given the proximity to the junction.",
                },
            },
        ],
    },

    # ─── CASE 4 ───────────────────────────────────────────────────────────────
    {
        "case_num": 4,
        "case_title": "Elderly Man with Sudden Profuse Leg Bleeding",
        "vignette": (
            "A 78-year-old man on warfarin for atrial fibrillation is brought to the emergency "
            "department by ambulance after his wife found him on the floor with profuse bleeding "
            "from a ruptured varicose vein on his right lower leg. The bleeding started "
            "spontaneously during the night. On arrival, his blood pressure is 95/60 mmHg and "
            "heart rate is 112 bpm. There is significant blood loss from a venous blowout "
            "on the medial lower leg. His INR was 3.8 two days ago."
        ),
        "difficulty": "Hard",
        "tag": "Complications / Emergency",
        "questions": [
            {
                "q": "What is the single most important immediate first-aid intervention for controlling this bleeding?",
                "options": [
                    "Apply a tourniquet to the thigh above the bleeding point",
                    "Lay the patient flat, elevate the leg, and apply firm direct pressure",
                    "Inject sclerosant directly into the bleeding vein",
                    "Apply a pneumatic compression device to the whole leg",
                    "Perform immediate surgical ligation of the bleeding vessel",
                ],
                "correct": "B",
                "correct_text": "Lay the patient flat, elevate the leg, and apply firm direct pressure",
                "explanation": (
                    "Bleeding varicose veins can be life-threatening, particularly in elderly "
                    "patients on anticoagulation. The immediate first-aid principle is: "
                    "LIE FLAT, ELEVATE THE LIMB, APPLY FIRM DIRECT PRESSURE. "
                    "Elevation reduces venous pressure in the varicosity dramatically and often "
                    "stops bleeding alone. A tourniquet is CONTRAINDICATED — it increases distal venous "
                    "pressure, worsening haemorrhage. Sclerotherapy/surgery are definitive treatments, "
                    "not emergency measures. Pneumatic compression devices are not appropriate here."
                ),
                "wrong": {
                    "A": "A tourniquet RAISES venous pressure distal to it and will WORSEN the bleeding — this is a common dangerous error.",
                    "C": "Sclerotherapy is a definitive treatment, not an emergency first-aid measure.",
                    "D": "Pneumatic compression devices are not standard emergency management for this scenario.",
                    "E": "Surgery is a definitive option but not the immediate first step — stabilise first.",
                },
            },
            {
                "q": "After haemorrhage control, what is the most appropriate definitive management of the varicose vein?",
                "options": [
                    "Life-long warfarin with no further vein treatment",
                    "Foam sclerotherapy or surgical treatment of the underlying varicosities",
                    "Bilateral saphenous vein stripping at the same admission",
                    "Long-term elastic compression only — intervention is contraindicated in anticoagulated patients",
                    "Radiofrequency ablation performed within 24 hours",
                ],
                "correct": "B",
                "correct_text": "Foam sclerotherapy or surgical treatment of the underlying varicosities",
                "explanation": (
                    "After the acute bleed is controlled and the patient is stabilised, the underlying "
                    "varicosities must be treated to prevent recurrence — which can be fatal in elderly "
                    "anticoagulated patients. Foam sclerotherapy is the preferred option as it can be "
                    "done under LA without GA risk, or surgery can be performed electively. "
                    "Anticoagulation is NOT a contraindication to varicose vein treatment — it may need "
                    "temporary bridging/adjustment peri-procedure. Immediate bilateral surgery during the "
                    "same admission in a haemodynamically unstable patient is inappropriate. "
                    "Compression alone leaves the patient at ongoing risk of re-bleeding."
                ),
                "wrong": {
                    "A": "Anticoagulation addresses atrial fibrillation, not the varicose vein — re-bleeding risk remains high.",
                    "C": "Bilateral surgery in the same admission of an unstable, anticoagulated elderly patient is unsafe.",
                    "D": "Anticoagulation is not a permanent contraindication — it can be managed peri-procedure.",
                    "E": "Immediate RFA within 24 hours is inappropriate — stabilise and plan electively.",
                },
            },
        ],
    },

    # ─── CASE 5 ───────────────────────────────────────────────────────────────
    {
        "case_num": 5,
        "case_title": "Pregnant Woman with New Varicose Veins",
        "vignette": (
            "A 29-year-old woman at 22 weeks gestation presents to her GP with bilateral "
            "varicose veins that developed during this pregnancy. She complains of aching "
            "and heaviness, especially at the end of the day. She has no previous history "
            "of DVT. On examination, there are prominent bilateral medial varicosities. "
            "The skin is normal. She asks whether the veins can be 'lasered'."
        ),
        "difficulty": "Easy",
        "tag": "Pregnancy / Conservative",
        "questions": [
            {
                "q": "What is the most appropriate management at this stage?",
                "options": [
                    "Endovenous laser ablation (EVLA) of the GSV bilaterally now",
                    "Foam sclerotherapy at 28 weeks gestation",
                    "Graduated compression hosiery (20–30 mmHg) and lifestyle advice",
                    "Surgical stripping under spinal anaesthesia at 32 weeks",
                    "Initiate low-molecular-weight heparin prophylaxis",
                ],
                "correct": "C",
                "correct_text": "Graduated compression hosiery (20–30 mmHg) and lifestyle advice",
                "explanation": (
                    "Varicose veins commonly develop or worsen in pregnancy due to progesterone-induced "
                    "vein wall relaxation and IVC compression by the gravid uterus. "
                    "Definitive intervention (laser, RFA, sclerotherapy, surgery) is deferred until "
                    "3–6 months post-partum for two reasons: (1) many veins improve after delivery, "
                    "(2) recurrence rate is higher if treated during pregnancy. "
                    "Graduated compression hosiery (20–30 mmHg) provides effective symptomatic relief "
                    "and is safe throughout pregnancy. Lifestyle advice includes regular walking, "
                    "avoiding prolonged standing, and leg elevation. "
                    "LMWH is for DVT prophylaxis/treatment, not uncomplicated varicose veins."
                ),
                "wrong": {
                    "A": "EVLA during pregnancy is contraindicated — treat post-partum.",
                    "B": "Foam sclerotherapy is contraindicated during pregnancy.",
                    "D": "Surgery is deferred until after delivery.",
                    "E": "LMWH is for DVT — this patient has no DVT signs and uncomplicated varicosities.",
                },
            },
        ],
    },

    # ─── CASE 6 ───────────────────────────────────────────────────────────────
    {
        "case_num": 6,
        "case_title": "Man with Non-Healing Ulcer Near the Medial Malleolus",
        "vignette": (
            "A 70-year-old retired teacher presents with a 6-week history of a non-healing wound "
            "near the right medial malleolus. The ulcer is shallow, approximately 3×2 cm, with an "
            "irregular border, a base of granulation tissue, and moderate exudate. There is "
            "surrounding hyperpigmentation and mild induration. He has known varicose veins for "
            "20 years. Peripheral pulses are present. ABPI is 0.9. Duplex USS confirms GSV "
            "reflux with a patent deep system."
        ),
        "difficulty": "Medium",
        "tag": "Venous Ulcer",
        "questions": [
            {
                "q": "Which of the following is the most appropriate initial management strategy?",
                "options": [
                    "Oral antibiotics for 4 weeks and topical antiseptic dressings",
                    "Multilayer compression bandaging plus wound care",
                    "Immediate split-skin grafting to the ulcer base",
                    "Elevation only — compression is contraindicated with an ABPI of 0.9",
                    "Oral corticosteroids to reduce periulcer inflammation",
                ],
                "correct": "B",
                "correct_text": "Multilayer compression bandaging plus wound care",
                "explanation": (
                    "This is a classic venous ulcer (C6 CEAP): medial malleolus location, shallow, "
                    "irregular border, granulation tissue base, surrounding lipodermatosclerosis. "
                    "The cornerstone of treatment is multilayer graduated compression bandaging "
                    "(changed weekly), which increases healing rates vs no compression (Cochrane evidence). "
                    "ABPI 0.9 is in the normal range (>0.8), so compression is SAFE. "
                    "Compression is contraindicated only if ABPI <0.5 (severe arterial disease). "
                    "Wound care (moisture-retaining dressings) addresses the local wound environment. "
                    "Antibiotics are reserved for clinically infected ulcers. "
                    "Skin grafting is considered for large, non-healing ulcers after reflux is treated. "
                    "Steroids have no role in venous ulcer management."
                ),
                "wrong": {
                    "A": "Antibiotics are only for infected ulcers — no signs of infection are described.",
                    "C": "Split-skin grafting is a late option for large non-healing ulcers — not first-line.",
                    "D": "ABPI 0.9 is normal — compression is safe and is the most important treatment.",
                    "E": "Corticosteroids are not part of venous ulcer management.",
                },
            },
            {
                "q": "In addition to wound care and compression, what treatment most effectively reduces ulcer recurrence in this patient?",
                "options": [
                    "Lifelong warfarin anticoagulation",
                    "Endovenous ablation of the incompetent GSV",
                    "Daily aspirin 75 mg",
                    "Pentoxifylline oral therapy only",
                    "Below-knee amputation",
                ],
                "correct": "B",
                "correct_text": "Endovenous ablation of the incompetent GSV",
                "explanation": (
                    "The underlying pathology driving the venous ulcer is GSV reflux causing venous "
                    "hypertension. Treating the reflux (EVLA/RFA of the incompetent GSV) not only "
                    "accelerates ulcer healing but dramatically reduces recurrence. "
                    "Multiple RCTs have demonstrated that treatment of superficial reflux in "
                    "patients with venous ulcers significantly lowers recurrence rates. "
                    "Warfarin has no role in venous ulcer disease. "
                    "Aspirin may have a small adjuvant benefit but is not the primary treatment. "
                    "Pentoxifylline is a vasodilator sometimes used adjunctively in refractory ulcers "
                    "but is not the primary treatment to reduce recurrence. "
                    "Amputation is inappropriate."
                ),
                "wrong": {
                    "A": "Anticoagulation is not indicated for venous ulcer disease without concurrent DVT/thrombophilia.",
                    "C": "Aspirin has limited evidence as an adjunct but does not address the underlying reflux.",
                    "D": "Pentoxifylline is an adjunct only — ablation of the reflux is the definitive recurrence prevention.",
                    "E": "Amputation has absolutely no role here.",
                },
            },
        ],
    },

    # ─── CASE 7 ───────────────────────────────────────────────────────────────
    {
        "case_num": 7,
        "case_title": "Post-operative Complications after Varicose Vein Surgery",
        "vignette": (
            "A 55-year-old woman underwent saphenofemoral junction (SFJ) ligation and great "
            "saphenous vein (GSV) stripping to the ankle under general anaesthesia 3 days ago. "
            "She now complains of numbness and tingling on the medial aspect of the right lower "
            "leg and foot, extending to the great toe. There is no foot drop. The wound is "
            "healing well with no signs of infection."
        ),
        "difficulty": "Medium",
        "tag": "Surgical Complications",
        "questions": [
            {
                "q": "Which nerve has most likely been injured during this procedure?",
                "options": [
                    "Common peroneal nerve",
                    "Sural nerve",
                    "Femoral nerve",
                    "Saphenous nerve",
                    "Tibial nerve",
                ],
                "correct": "D",
                "correct_text": "Saphenous nerve",
                "explanation": (
                    "The saphenous nerve is the cutaneous branch of the femoral nerve. It runs in "
                    "close proximity to the great saphenous vein in the lower leg, and is at "
                    "significant risk during GSV stripping below the knee. "
                    "It supplies sensation to the medial lower leg and medial border of the foot "
                    "to the great toe — exactly the distribution described. "
                    "This is a well-recognised complication of stripping the GSV below the knee, "
                    "which is why many surgeons strip only to the knee. The injury is usually a "
                    "neuropraxia and recovers over weeks to months. "
                    "The sural nerve is at risk during SSV stripping and supplies the lateral foot. "
                    "The common peroneal nerve injury causes foot drop — absent here."
                ),
                "wrong": {
                    "A": "Common peroneal nerve injury causes foot drop and lateral leg/dorsum of foot sensory loss — not described.",
                    "B": "The sural nerve supplies the lateral foot/heel and is at risk during SSV operations, not GSV.",
                    "C": "Femoral nerve injury causes quadriceps weakness — not described.",
                    "E": "Tibial nerve injury causes plantar sensory loss and toe flexor weakness.",
                },
            },
        ],
    },

    # ─── CASE 8 ───────────────────────────────────────────────────────────────
    {
        "case_num": 8,
        "case_title": "Choosing Between EVLA and Foam Sclerotherapy",
        "vignette": (
            "A 45-year-old man has symptomatic varicose veins secondary to great saphenous vein "
            "(GSV) reflux from the saphenofemoral junction. Duplex USS shows a 7 mm GSV with "
            "reflux throughout its length to below the knee, with numerous large tributary "
            "varicosities in the medial calf. The deep venous system is patent. He is fit and "
            "well and wants the 'best available treatment'. He works as a schoolteacher and needs "
            "a short recovery time."
        ),
        "difficulty": "Hard",
        "tag": "Intervention Choice",
        "questions": [
            {
                "q": "Which treatment approach is most appropriate as first-line intervention for the truncal GSV reflux?",
                "options": [
                    "Foam sclerotherapy (UGFS) to the full GSV length",
                    "Endovenous thermal ablation (EVLA or RFA) of the GSV",
                    "Compression hosiery for 6 months followed by reassessment",
                    "Open surgical SFJ ligation and GSV stripping under GA",
                    "Cyanoacrylate glue injection to the superficial tributaries only",
                ],
                "correct": "B",
                "correct_text": "Endovenous thermal ablation (EVLA or RFA) of the GSV",
                "explanation": (
                    "Endovenous thermal ablation (EVLA or RFA) is the first-line treatment for "
                    "truncal GSV reflux in a fit patient with a patent deep system. "
                    "Compared to foam sclerotherapy, thermal ablation has significantly higher "
                    "technical success rates, lower reintervention rates, and equivalent/better "
                    "clinical outcomes (confirmed by BMC Surg 2025 systematic review, PMID 41390389). "
                    "Compared to surgery, thermal ablation offers equivalent efficacy with faster "
                    "return to work, no GA, and fewer complications. "
                    "Foam sclerotherapy is better suited to tributaries, small/tortuous veins, "
                    "recurrent disease, or as an adjunct. Compression alone at C2 symptomatic is insufficient. "
                    "Surgery remains an option but is not first-line for straightforward truncal reflux."
                ),
                "wrong": {
                    "A": "UGFS has significantly lower efficacy for truncal GSV ablation and higher reintervention rates — not first-line for a 7 mm GSV.",
                    "C": "Symptoms are present and intervention is indicated — compression alone is not adequate first-line for symptomatic C2.",
                    "D": "Surgery is an option but thermal ablation gives equivalent results with shorter recovery — preferred for a teacher needing quick return to work.",
                    "E": "Cyanoacrylate to tributaries alone does not address the truncal GSV reflux driving the whole system.",
                },
            },
            {
                "q": "Following truncal GSV ablation, the tributary varicosities in the medial calf persist. What is the most appropriate management?",
                "options": [
                    "Reassure — all tributaries will disappear within 2 weeks",
                    "Repeat duplex USS and plan avulsion phlebectomy or foam sclerotherapy",
                    "Apply compression stockings for 1 year and observe",
                    "Perform formal GSV stripping now as thermal ablation has failed",
                    "Anticoagulate with LMWH to dissolve the residual varicosities",
                ],
                "correct": "B",
                "correct_text": "Repeat duplex USS and plan avulsion phlebectomy or foam sclerotherapy",
                "explanation": (
                    "Endovenous thermal ablation treats truncal and junctional reflux only — it does not "
                    "directly treat the tributary varicosities. After truncal ablation, tributaries can "
                    "be managed either concomitantly (at the same session) or sequentially. "
                    "Sequential management involves waiting 6–12 weeks for some tributaries to involute "
                    "spontaneously, then treating residual varicosities by: "
                    "(1) Avulsion phlebectomy (stab avulsion through 2-3 mm incisions under tumescent LA), or "
                    "(2) Foam sclerotherapy under ultrasound guidance. "
                    "Some tributaries do involute but it is not universal within 2 weeks. "
                    "Formal stripping is not indicated if thermal ablation was technically successful. "
                    "LMWH has no role in treating varicosities."
                ),
                "wrong": {
                    "A": "While some tributaries may involute, it is not reliable within 2 weeks — active management should be planned.",
                    "C": "A year of observation is excessive — most residual tributaries are treated at 6–12 weeks.",
                    "D": "Thermal ablation has not 'failed' — tributaries are a separate treatment target from the truncal vein.",
                    "E": "LMWH does not treat varicose veins — it is an anticoagulant.",
                },
            },
        ],
    },

    # ─── CASE 9 ───────────────────────────────────────────────────────────────
    {
        "case_num": 9,
        "case_title": "Groin Lump in a Woman with Varicose Veins",
        "vignette": (
            "A 52-year-old woman is referred to the surgical outpatient clinic with a lump in "
            "her right groin. She noticed it about 6 months ago. The lump appears when she "
            "stands up and disappears completely when she lies down. It is painless and soft. "
            "On coughing, a transmitted impulse is felt. She has known varicose veins in the "
            "right medial thigh. There is no bowel disturbance. On examination, the lump is "
            "located just below the inguinal ligament, medial to the femoral artery."
        ),
        "difficulty": "Medium",
        "tag": "Saphena Varix / DDx",
        "questions": [
            {
                "q": "What is the most likely diagnosis?",
                "options": [
                    "Femoral hernia",
                    "Inguinal hernia",
                    "Saphena varix",
                    "Inguinal lymphadenopathy",
                    "Lipoma of the groin",
                ],
                "correct": "C",
                "correct_text": "Saphena varix",
                "explanation": (
                    "A saphena varix is a dilatation of the great saphenous vein at the saphenofemoral "
                    "junction (SFJ). It presents as a soft, compressible, painless groin lump that: "
                    "• Appears on STANDING and disappears on LYING (consistent with venous filling) "
                    "• Has a COUGH IMPULSE (transmitted via venous pressure) "
                    "• Is located at the SFJ — just below the inguinal ligament, medial to the femoral artery "
                    "• Is associated with ipsilateral GSV varicosities "
                    "It mimics a femoral hernia but can be distinguished by: complete disappearance "
                    "on lying down (hernias usually require manual reduction), bluish colour, and "
                    "association with varicosities. Duplex USS confirms the diagnosis. "
                    "Treatment is SFJ ligation as part of varicose vein surgery."
                ),
                "wrong": {
                    "A": "Femoral hernia is found below the inguinal ligament but does not disappear completely on lying down without manual reduction, and is not typically associated with varicosities.",
                    "B": "Inguinal hernia is above the inguinal ligament.",
                    "D": "Lymph nodes are firm, discrete, and do not disappear on lying down.",
                    "E": "Lipomas are not pulsatile/compressible, do not disappear on lying down, and have no cough impulse.",
                },
            },
        ],
    },

    # ─── CASE 10 ─────────────────────────────────────────────────────────────
    {
        "case_num": 10,
        "case_title": "Recurrent Varicose Veins After Previous Surgery",
        "vignette": (
            "A 58-year-old man underwent SFJ ligation and GSV stripping 8 years ago for "
            "symptomatic varicose veins. He now re-presents with recurrent varicosities in the "
            "right medial thigh and calf, similar to before. Duplex USS shows a cluster of "
            "small tortuous new veins arising directly from the old SFJ ligation site, "
            "with no identifiable GSV remnant. The deep system is patent."
        ),
        "difficulty": "Hard",
        "tag": "Recurrence / Neovascularisation",
        "questions": [
            {
                "q": "What is the most likely mechanism of recurrence in this patient?",
                "options": [
                    "Incomplete stripping of the GSV at initial operation",
                    "Progression of isolated perforator incompetence",
                    "Neovascularisation at the site of the previous SFJ ligation",
                    "Development of new primary varicose veins in the SSV territory",
                    "Post-thrombotic syndrome causing secondary varicosities",
                ],
                "correct": "C",
                "correct_text": "Neovascularisation at the site of the previous SFJ ligation",
                "explanation": (
                    "The most common cause of recurrent varicose veins after SFJ ligation and "
                    "stripping is NEOVASCULARISATION — the growth of multiple small, tortuous new "
                    "venous channels at the groin ligation site. This is a recognised biological "
                    "response to surgical trauma and inflammation. "
                    "The duplex finding of 'small tortuous new veins from the SFJ site with no GSV "
                    "remnant' is pathognomonic of neovascularisation. "
                    "Neovascular recurrence is best managed with foam sclerotherapy "
                    "(not repeat surgery — operating in a previously dissected, fibrotic groin "
                    "carries high risk of femoral vessel injury). "
                    "Some surgeons believe ligation distal to the tributaries may reduce neovascularisation "
                    "risk, though evidence is limited."
                ),
                "wrong": {
                    "A": "Incomplete stripping would leave a GSV remnant with reflux — duplex shows no GSV remnant here.",
                    "B": "Perforator incompetence causes venous hypertension but not the specific groin cluster pattern described.",
                    "D": "SSV territory varicosities would be posterolateral — the distribution is medial thigh/calf consistent with GSV territory.",
                    "E": "Post-thrombotic syndrome would require history of DVT and deep venous changes on duplex.",
                },
            },
            {
                "q": "What is the preferred treatment for this recurrence?",
                "options": [
                    "Repeat SFJ ligation and re-stripping under general anaesthesia",
                    "Long-term compression hosiery — further intervention is not recommended",
                    "Ultrasound-guided foam sclerotherapy (UGFS) to the neovascular tissue",
                    "Endovenous laser ablation of the neovascular channels",
                    "Anticoagulation with direct oral anticoagulants",
                ],
                "correct": "C",
                "correct_text": "Ultrasound-guided foam sclerotherapy (UGFS) to the neovascular tissue",
                "explanation": (
                    "For neovascular recurrence at the groin, foam sclerotherapy (UGFS) is the "
                    "preferred treatment. Reasons include: "
                    "• Neovascular channels are small and tortuous — foam sclerotherapy can navigate them "
                    "• Re-operating in a fibrotic groin after previous dissection carries high risk of "
                    "injury to the femoral vein and artery (serious complication) "
                    "• Endovenous laser requires a cannulable vein of sufficient diameter — difficult in "
                    "small neovascular channels "
                    "• Foam sclerotherapy has been shown to be effective and safe in this context "
                    "Compression alone is inadequate for symptomatic recurrence. "
                    "Anticoagulation has no role."
                ),
                "wrong": {
                    "A": "Re-surgery in a fibrotic groin risks femoral vessel injury — foam sclerotherapy is strongly preferred.",
                    "B": "Symptomatic recurrence should be treated — compression alone is insufficient.",
                    "D": "EVLA requires a catheterisable vein of adequate size — neovascular channels are too small and tortuous.",
                    "E": "DOACs have no role in treating varicose veins.",
                },
            },
        ],
    },
]

# ─── Build PDF ─────────────────────────────────────────────────────────────────
doc = SimpleDocTemplate(
    OUTPUT, pagesize=A4,
    leftMargin=MARGIN, rightMargin=MARGIN,
    topMargin=MARGIN, bottomMargin=MARGIN,
    title="Varicose Vein Management - USMLE SBA Worksheet",
    author="Orris Medical Reference",
)

story = []

# ── Title block ────────────────────────────────────────────────────────────────
title_tbl = Table([[
    Paragraph("Varicose Vein Management",
              S("_TT", fontSize=22, textColor=WHITE, fontName="Helvetica-Bold",
                leading=26, alignment=TA_CENTER)),
    ]], colWidths=[CONTENT_W])
title_tbl.setStyle(TableStyle([
    ("BACKGROUND", (0, 0), (-1, -1), NAVY),
    ("TOPPADDING", (0, 0), (-1, -1), 14),
    ("BOTTOMPADDING", (0, 0), (-1, -1), 4),
    ("ROUNDEDCORNERS", [6]),
]))
subtitle_tbl = Table([[
    Paragraph("USMLE-Style Single Best Answer  |  Case-Based Clinical Examination",
              S("_ST", fontSize=12, textColor=WHITE, fontName="Helvetica",
                leading=16, alignment=TA_CENTER)),
    ]], colWidths=[CONTENT_W])
subtitle_tbl.setStyle(TableStyle([
    ("BACKGROUND", (0, 0), (-1, -1), NAVY),
    ("TOPPADDING", (0, 0), (-1, -1), 2),
    ("BOTTOMPADDING", (0, 0), (-1, -1), 8),
    ("ROUNDEDCORNERS", [6]),
]))
story.append(sp(14))
story.append(title_tbl)
story.append(subtitle_tbl)
story.append(sp(4))

# Stats row
stats = Table([[
    Paragraph("10 Cases", S("_SC", fontSize=9, textColor=TEAL, fontName="Helvetica-Bold",
                             alignment=TA_CENTER)),
    Paragraph("15 Questions", S("_SC2", fontSize=9, textColor=AMBER, fontName="Helvetica-Bold",
                                 alignment=TA_CENTER)),
    Paragraph("Easy / Medium / Hard", S("_SC3", fontSize=9, textColor=RED, fontName="Helvetica-Bold",
                                         alignment=TA_CENTER)),
    Paragraph("Full Answer Key", S("_SC4", fontSize=9, textColor=GREEN, fontName="Helvetica-Bold",
                                    alignment=TA_CENTER)),
]], colWidths=[CONTENT_W/4]*4)
stats.setStyle(TableStyle([
    ("BACKGROUND", (0, 0), (-1, -1), GREY_LIGHT),
    ("TOPPADDING", (0, 0), (-1, -1), 5),
    ("BOTTOMPADDING", (0, 0), (-1, -1), 5),
    ("GRID", (0, 0), (-1, -1), 0.3, GREY_MID),
    ("BOX", (0, 0), (-1, -1), 0.5, GREY_MID),
]))
story.append(stats)
story.append(sp(4))
story.append(Paragraph(
    "<i>Instructions: For each clinical vignette, select the SINGLE BEST ANSWER. "
    "Answers with detailed explanations follow the question section.</i>",
    S("_INST", fontSize=9, textColor=colors.HexColor("#555555"), fontName="Helvetica-Oblique",
      leading=13, alignment=TA_CENTER)))
story.append(sp(8))

# ── PART 1: ALL QUESTIONS ──────────────────────────────────────────────────────
story.append(banner("PART I — CLINICAL QUESTIONS", NAVY))
story.append(sp(8))

global_q_num = 1

# Track mapping for answer key
q_map = []  # list of (global_q_num, case_num, case_title, q_data)

for case in QUESTIONS:
    story.append(case_box(case["case_num"], case["case_title"],
                          case["vignette"], case["difficulty"], case["tag"]))
    story.append(sp(5))
    for q in case["questions"]:
        q_map.append((global_q_num, case["case_num"], case["case_title"], q))
        for item in question_block(case["case_num"], q["q"], q["options"], global_q_num):
            story.append(item)
        story.append(sp(3))
        global_q_num += 1
    story.append(hr())
    story.append(sp(5))

# ── PART 2: ANSWER KEY ────────────────────────────────────────────────────────
story.append(PageBreak())
story.append(sp(14))
story.append(banner("PART II — ANSWER KEY WITH EXPLANATIONS", NAVY))
story.append(sp(6))

# Quick answer grid
grid_data = [
    [Paragraph("Q", S("_GH", fontSize=9, textColor=WHITE, fontName="Helvetica-Bold",
                        alignment=TA_CENTER))] +
    [Paragraph(str(i+1), S("_GH2", fontSize=8.5, textColor=WHITE, fontName="Helvetica-Bold",
                             alignment=TA_CENTER)) for i in range(len(q_map))]
]
grid_data.append(
    [Paragraph("Ans", S("_GA", fontSize=9, textColor=NAVY, fontName="Helvetica-Bold",
                          alignment=TA_CENTER))] +
    [Paragraph(q[3]["correct"], S("_GAns", fontSize=9, textColor=GREEN,
                                   fontName="Helvetica-Bold", alignment=TA_CENTER))
     for q in q_map]
)
total_qs = len(q_map)
col_w = (CONTENT_W - 30*mm) / total_qs
grid_tbl = Table(grid_data, colWidths=[30*mm] + [col_w]*total_qs)
grid_tbl.setStyle(TableStyle([
    ("BACKGROUND", (0, 0), (-1, 0), NAVY),
    ("BACKGROUND", (0, 1), (-1, 1), GREY_LIGHT),
    ("GRID", (0, 0), (-1, -1), 0.4, GREY_MID),
    ("TOPPADDING", (0, 0), (-1, -1), 4),
    ("BOTTOMPADDING", (0, 0), (-1, -1), 4),
    ("VALIGN", (0, 0), (-1, -1), "MIDDLE"),
]))
story.append(Paragraph("<b>Quick Reference Answer Grid:</b>", BODY_SM))
story.append(sp(3))
story.append(grid_tbl)
story.append(sp(10))
story.append(hr(NAVY, 1.0))
story.append(sp(8))

# Detailed answers
for gq, case_num, case_title, q_data in q_map:
    story.append(answer_block(
        gq, q_data["correct"], q_data["correct_text"],
        q_data["explanation"],
        q_data.get("wrong", {})
    ))
    story.append(sp(6))

# ── Scoring guide ─────────────────────────────────────────────────────────────
story.append(hr(GREY_MID))
story.append(sp(4))
score_data = [
    [Paragraph("Score", S("_SH", fontSize=9, textColor=WHITE, fontName="Helvetica-Bold",
                            alignment=TA_CENTER)),
     Paragraph("Performance", S("_SH", fontSize=9, textColor=WHITE, fontName="Helvetica-Bold",
                                 alignment=TA_CENTER)),
     Paragraph("Recommendation", S("_SH", fontSize=9, textColor=WHITE, fontName="Helvetica-Bold",
                                    alignment=TA_CENTER))],
    [Paragraph("13–15 / 15", CELL), Paragraph("Excellent", CELL),
     Paragraph("Ready for clinical practice — review any missed questions", CELL)],
    [Paragraph("10–12 / 15", CELL), Paragraph("Good", CELL),
     Paragraph("Revise CEAP classification, treatment selection, and complications", CELL)],
    [Paragraph("7–9 / 15", CELL), Paragraph("Average", CELL),
     Paragraph("Re-read the management algorithm document and re-attempt", CELL)],
    [Paragraph("< 7 / 15", CELL), Paragraph("Needs Improvement", CELL),
     Paragraph("Systematic revision required — start with anatomy and pathophysiology", CELL)],
]
score_tbl = Table(score_data,
                  colWidths=[CONTENT_W * 0.20, CONTENT_W * 0.20, CONTENT_W * 0.60])
score_tbl.setStyle(TableStyle([
    ("BACKGROUND", (0, 0), (-1, 0), NAVY),
    ("BACKGROUND", (0, 1), (-1, 1), GREEN_LIGHT),
    ("BACKGROUND", (0, 2), (-1, 2), LIGHT_TEAL),
    ("BACKGROUND", (0, 3), (-1, 3), AMBER_LIGHT),
    ("BACKGROUND", (0, 4), (-1, 4), RED_LIGHT),
    ("GRID", (0, 0), (-1, -1), 0.4, GREY_MID),
    ("TOPPADDING", (0, 0), (-1, -1), 5),
    ("BOTTOMPADDING", (0, 0), (-1, -1), 5),
    ("LEFTPADDING", (0, 0), (-1, -1), 8),
    ("RIGHTPADDING", (0, 0), (-1, -1), 8),
    ("VALIGN", (0, 0), (-1, -1), "MIDDLE"),
    ("FONTNAME", (0, 1), (1, -1), "Helvetica-Bold"),
]))
story.append(Paragraph("<b>Self-Assessment Scoring Guide:</b>", BOLD))
story.append(sp(3))
story.append(score_tbl)
story.append(sp(6))

# References
story.append(hr(GREY_MID, 0.5))
story.append(sp(4))
story.append(Paragraph("<b>References:</b>", BODY_SM))
for ref in [
    "Bailey &amp; Love's Short Practice of Surgery, 28th Edition — Chapter 62: Venous Disorders",
    "Harrison's Principles of Internal Medicine, 22nd Edition (2025) — Chapter 293: Chronic Venous Disease",
    "Schwartz's Principles of Surgery, 11th Edition — Chapter 24: Venous and Lymphatic Disease",
    "Lim EQ et al. BMC Surg 2025 — Endovenous ablation vs surgical stripping [PMID 41390389]",
    "Tan MKH et al. J Vasc Surg Venous Lymphat Disord 2024 — Reflux patterns in CVD [PMID 39025298]",
]:
    story.append(Paragraph(f"• {ref}", NOTE))

# Build
doc.build(story, onFirstPage=on_page, onLaterPages=on_page)
print(f"Worksheet PDF generated: {OUTPUT}")
Running Command

cd /home/daytona/workspace/varicose-vein-doc && python generate_worksheet.py 2>&1

Running Command

ls -lh /home/daytona/workspace/varicose-vein-doc/Varicose_Vein_Worksheet.pdf

Your worksheet is ready:

Varicose Vein Worksheet

PDF Document · PDF


Here's what the worksheet contains:

Structure

Part I - Clinical Questions (all cases together for exam simulation) Part II - Answer Key with Explanations (on a separate page)

The 10 Cases & 15 Questions

CaseVignetteDifficultyTopic
148F, medial thigh varicosities, 2 pregnanciesEasyCEAP Dx + Investigation
262M, lipodermatosclerosis, partial compression reliefMediumCEAP C4b + Intervention
334F, SVT extending to within 2.5 cm of SPJMediumThrombophlebitis
478M on warfarin, profuse spontaneous bleedHardEmergency management
529F, 22 weeks pregnant, new varicositiesEasyPregnancy / Conservative
670M, medial malleolus ulcer, ABPI 0.9MediumVenous ulcer (x2 Qs)
7Post-op numbness medial lower leg after GSV strippingMediumSurgical complications
845M, 7mm GSV reflux, needs quick return to workHardEVLA vs UGFS + tributaries
952F, painless groin lump, appears on standingMediumSaphena varix DDx
1058M, recurrent varicosities 8 years post-surgeryHardNeovascularisation (x2 Qs)

Answer Key Features

  • Quick reference answer grid at the top (all 15 answers at a glance)
  • Full explanation for each correct answer (mechanism + clinical reasoning)
  • Explanation for each distractor (why each wrong option is wrong)
  • Self-assessment scoring guide (Excellent/Good/Average/Needs Improvement)
  • Referenced to Bailey & Love, Harrison's, Schwartz's, and 2024-25 PubMed evidence
This is a shared conversation. Sign in to Orris to start your own chat.