Make MS surgery level notes for Diabetic foot theory exam

Reading File
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Searching the Web

diabetic foot MS surgery theory exam notes classification management 2024

Searching PubMed

"diabetic foot" AND management AND classification

I now have enough information to write comprehensive MS Surgery level notes. Let me compile them:

DIABETIC FOOT - MS Surgery Theory Notes


1. DEFINITION

Diabetic foot refers to a spectrum of pathological conditions affecting the foot in patients with diabetes mellitus, resulting from the combined effects of peripheral neuropathy, peripheral arterial disease (PAD), and susceptibility to infection - leading to ulceration, deep space infection, osteomyelitis, gangrene, and ultimately amputation.

2. EPIDEMIOLOGY & IMPORTANCE

  • Lifetime risk of foot ulcer in diabetics: 15-25%
  • 85% of all diabetes-related lower limb amputations are preceded by a foot ulcer
  • Diabetics have 15-46x higher risk of lower limb amputation vs non-diabetics
  • Annual incidence of foot ulcer: ~2% of diabetic population
  • 5-year mortality after major amputation: ~50% (worse than most cancers)
  • Global burden: ~1 amputation every 20 seconds due to diabetic foot

3. PATHOPHYSIOLOGY (TRIAD)

A. Peripheral Neuropathy (most important - present in ~50%)

Types and consequences:
TypeEffect
Sensory neuropathyLoss of pain, pressure, temperature - "silent injury"
Motor neuropathyIntrinsic muscle wasting → claw toes, high arch → abnormal pressure points
Autonomic neuropathyAnhidrosis → dry cracked skin; arteriovenous shunting → warm bounding pulses but poor tissue nutrition
  • Semmes-Weinstein 10g monofilament test - loss of protective sensation
  • Charcot neuroarthropathy (CN) - destructive, painless joint disease from repeated trauma + autonomic dysfunction

B. Peripheral Arterial Disease

  • Affects tibial and peroneal arteries preferentially (below-knee disease)
  • Unlike atherosclerosis elsewhere - medial calcinosis (Monckeberg's) → non-compressible vessels → falsely elevated ABPI (>1.3)
  • ABI: Normal >0.9; Mild ischemia 0.5-0.9; Severe <0.5; Critical <0.3
  • Ischemia makes ulcers more likely to progress to gangrene

C. Infection

  • Diminished immunological response (impaired PMN chemotaxis, phagocytosis, intracellular killing)
  • Common organisms: Staphylococcus aureus (most common), Streptococcus, Gram-negatives, anaerobes in deep/necrotic infections - typically polymicrobial
  • MRSA increasingly prevalent
  • Infection progresses along fascial planes → deep space infections, necrotizing fasciitis
  • Osteomyelitis - complicates 20% of moderate and 50-60% of severe ulcers

4. TYPES OF DIABETIC FOOT

FeatureNeuropathic FootIschemic FootNeuroischemic (Mixed)
Prevalence35%15%50%
TemperatureWarmColdCool
PulsesPresent, boundingAbsentReduced
SensationAbsentRelatively preservedReduced
Ulcer sitePlantar (pressure points)Margins, tips of toes, heelVariable
Ulcer appearancePunched-out, callusedPale, poor granulationMixed
PainPainlessPainful (rest pain)Variable
SweatingAbsentPresentReduced
DeformityPresent (Charcot)Less commonVariable

5. CLASSIFICATION SYSTEMS

A. Wagner Classification (Most Commonly Asked)

GradeDescription
0Intact skin; pre-ulcerative lesion; deformity/callus
1Superficial ulcer - skin/subcutaneous tissue only
2Deep ulcer - penetrating to tendon, capsule, or bone
3Deep ulcer + abscess, osteomyelitis, or septic arthritis
4Localized gangrene (toes/forefoot)
5Extensive gangrene of the entire foot
Grades 0-2: Conservative/local surgery Grades 3-4: Aggressive debridement, drainage, possible limited amputation Grade 5: Major amputation

B. University of Texas (UT) Classification (Better for predicting outcome)

  • Two axes: Grade (0-3) based on depth + Stage (A-D) based on ischemia/infection
  • Grade 0: Pre/post-ulcerative lesion; Grade 1: Superficial; Grade 2: Tendon/capsule; Grade 3: Bone/joint
  • Stage A: No infection/ischemia; B: Infection; C: Ischemia; D: Both

C. SINBAD Score (IWGDF recommended for audit)

  • S - Site (forefoot vs other); I - Ischemia; N - Neuropathy; B - Bacterial infection; A - Area (>1cm²); D - Depth (subcutaneous or deeper)
  • Score 0-6; higher score = worse prognosis

D. IDSA / IWGDF Infection Classification

SeverityDefinition
UninfectedNo systemic/local signs
Mild2+ signs of inflammation; <2cm cellulitis; superficial only
ModerateCellulitis >2cm; lymphangitis; deep fascia involvement; deep abscess; joint/bone infection
SevereSystemic signs (SIRS) - fever, tachycardia, leukocytosis, metabolic instability

6. CLINICAL FEATURES

History

  • Duration of diabetes, glycemic control (HbA1c)
  • Symptoms of neuropathy: burning, tingling, numbness
  • Claudication, rest pain (PAD)
  • Mechanism of ulcer: pressure, trauma, footwear
  • Previous ulcers/amputations

Examination

Local:
  • Site, size, shape, depth of ulcer
  • Base: granulation vs slough vs necrosis
  • Edges: punched out (neuropathic) vs undermined (infected) vs sloping (healing)
  • Surrounding skin: callus, cellulitis, lymphangitis
  • Discharge: serous, purulent, foul-smelling
  • Probing to bone (PTB test - if positive, ~89% specific for osteomyelitis)
  • Deformity: claw toes, Charcot foot
Vascular:
  • Foot pulses: dorsalis pedis + posterior tibial
  • Capillary refill time
  • Temperature gradient
  • ABI measurement
Neurological:
  • 10g Semmes-Weinstein monofilament (5 sites per foot)
  • Vibration (128 Hz tuning fork)
  • Ankle reflexes
  • Proprioception

7. INVESTIGATIONS

Bedside/Basic

  • Blood glucose, HbA1c
  • CBC - leukocytosis (may be absent even in severe infection in diabetics)
  • Renal function tests, electrolytes (nephropathy)
  • Coagulation profile
  • ESR, CRP, Procalcitonin (infection markers)

Microbiological

  • Wound swab/deep tissue culture before antibiotics
  • Bone biopsy - gold standard for osteomyelitis causative organism
  • Probe-to-bone test

Vascular Assessment

  • ABI (ABPI) - unreliable if >1.3 (medial calcinosis)
  • Toe-Brachial Index (TBI) - more reliable; <0.7 = ischemia
  • Duplex USG - maps arterial occlusion
  • CT Angiography / MR Angiography - gold standard preoperative vascular mapping
  • Transcutaneous oxygen pressure (TcPO2) - <30 mmHg = poor healing; >40 mmHg = good healing

Imaging for Osteomyelitis

  • X-ray - first line; shows periosteal reaction, cortical destruction, sequestrum (late: 2-3 weeks lag)
  • MRI - gold standard for osteomyelitis; shows bone marrow edema early; best for extent
  • Tc-99m bone scan - sensitive but not specific
  • WBC labeled scan (Indium-111 or Tc-HMPAO) - more specific
  • PET-CT - best specificity; increasingly used

8. MANAGEMENT

Multidisciplinary Team (MDT)

Diabetologist, Vascular surgeon, Orthopedic/General surgeon, Podiatrist, Microbiologist, Dietitian, Orthotist, Physiotherapist, Nurse specialist

General Measures

  • Glycemic control - target HbA1c <7%; insulin preferred inpatient
  • Nutritional optimization (albumin, protein)
  • Smoking cessation
  • Statin, antiplatelet therapy (if PAD)
  • Pressure offloading

A. LOCAL WOUND CARE

Debridement

  • Sharp/surgical debridement - most effective; removes slough, necrotic tissue, callus; converts chronic wound to acute
  • Enzymatic debridement (collagenase)
  • Autolytic (hydrogel dressings)
  • Larval therapy (maggots) - excellent for infected necrotic wounds, release collagenase
  • Hydrosurgical (Versajet)

Wound Dressings

Wound TypeDressing
Dry/necroticHydrogel, hydrocolloid
ExudativeFoam, alginate
InfectedSilver-containing, iodine-based
SloughyHydrocolloid, DACC-coated
GranulatingNon-adherent, foam

Negative Pressure Wound Therapy (NPWT/VAC)

  • Promotes granulation, reduces edema, removes exudate
  • 125 mmHg suction, continuous or intermittent
  • Indicated post-debridement, post-amputation wound, pre-graft bed preparation
  • Contraindicated in untreated osteomyelitis, necrotic tissue, malignancy

Growth Factors / Adjuncts

  • PDGF (Becaplermin) - FDA approved for neuropathic ulcers
  • Hyperbaric oxygen therapy (HBOT) - increases TcPO2; used for Wagner 3-4 non-revascularizable lesions; 90-min sessions, 20-40 sessions
  • Platelet-rich plasma (PRP)
  • Bioengineered skin substitutes (Dermagraft, Apligraf)

B. OFFLOADING

Most important treatment for neuropathic plantar ulcers:
MethodComments
Total Contact Cast (TCC)Gold standard; reduces plantar pressure by 84-92%
Removable Cast Walker (RCW/iTCC)Less effective (patient non-compliance)
Therapeutic footwearPrevention, grade 0-1
Bed rest / crutchesShort-term only
Surgical offloadingTendon lengthening, exostectomy

C. ANTIBIOTIC THERAPY (IWGDF/IDSA 2023)

Mild infection:
  • Oral antibiotics covering Gram-positive cocci
  • Amoxicillin-clavulanate OR Cefalexin + Metronidazole
  • Duration: 1-2 weeks
Moderate infection:
  • Oral or IV; broader spectrum covering Gram-positives + Gram-negatives
  • Amoxicillin-clavulanate IV / Piperacillin-tazobactam / Ceftriaxone + Metronidazole
  • Duration: 2-4 weeks
Severe infection:
  • IV, empiric broad spectrum: Piperacillin-tazobactam ± Vancomycin (if MRSA suspected)
  • If MRSA: Vancomycin, Daptomycin, Linezolid
  • Duration: 2-4 weeks (longer if osteomyelitis: 4-6 weeks)
Osteomyelitis:
  • IV initially → oral step-down based on culture
  • 6 weeks if no surgery; shorter (2 weeks) if involved bone resected with margins

D. VASCULAR INTERVENTION

Indications for revascularization:
  • ABI <0.5, TcPO2 <30 mmHg, severe ischemia (rest pain, tissue loss)
  • Before any major reconstruction or amputation attempt
Options:
ProcedureIndication
Percutaneous transluminal angioplasty (PTA) ± stentingFirst choice for short segment iliac/femoral disease
Bypass surgeryLong-segment occlusion; distal bypass (popliteal, tibial, peroneal) using autologous great saphenous vein
EndarterectomyCommon/superficial femoral artery disease
EndovascularTibial balloon angioplasty - "angiosome-based" revascularization
  • Angiosome concept: Each artery supplies a 3D block of tissue; direct revascularization of the angiosome containing the ulcer gives best healing
  • If no revascularization possible → amputation at lowest viable level

E. SURGICAL MANAGEMENT

Conservative/Minor Surgery

  1. Incision & drainage (I&D) - for abscess; avoid tourniquet; allow drainage
  2. Ray amputation - removal of toe + metatarsal shaft; for localized gangrene/osteomyelitis of single ray
  3. Toe amputation (disarticulation) - for isolated gangrenous digit
  4. Sesamoidectomy - if ulcer under sesamoid
  5. Metatarsal head resection - for plantar ulcer under MT head

Plastic Surgical Reconstruction (after wound bed prepared)

  • Split-skin grafting (SSG)
  • Local flaps: plantar rotation flap, V-Y advancement
  • Free flaps (microsurgical) - for large defects with adequate vasculature
  • Dermal substitutes + SSG

Major Amputations - Levels & Indications

LevelIndication
Transmetatarsal (TMA)Forefoot gangrene with viable heel and dorsum
Syme'sDistal tibial amputation; useful in select neuropathic patients
Below-knee (BK) / TranstibialMost functional major amputation; requires patent popliteal artery; 5-cm minimum stump
Knee disarticulationAlternative when BK not possible
Above-knee (AK) / TransfemoralLast resort; higher energy requirement; poor rehab in elderly
Guillotine amputation - emergency, open amputation for uncontrolled spreading sepsis/gas gangrene; followed by formal closure after infection control.
Principles of amputation in diabetics:
  • Preserve maximum length compatible with healing
  • Must ensure adequate blood supply at level chosen
  • TcPO2 >40 mmHg at level = adequate for healing
  • No tension on flaps; no tourniquet (relative contraindication)
  • Antibiotic cover perioperatively
  • Aim for primary closure where possible

9. CHARCOT NEUROARTHROPATHY (Charcot Foot)

Definition

Progressive, destructive arthropathy of bone and joint caused by loss of protective sensation + continued weight-bearing

Pathophysiology (Two theories)

  1. Neurotraumatic: Repeated micro-trauma due to loss of sensation → fractures and ligament laxity
  2. Neurovascular: Autonomic dysfunction → AV shunting → hyperemia → osteoclast activation → bone resorption

Stages (Eichenholtz Classification)

StageNameFeatures
0At-risk / ProdromalWarm, red, swollen foot; X-ray normal; MRI shows edema
IFragmentation / DevelopmentBony fragmentation, subluxation, dislocation
IICoalescenceAbsorption of fine debris, sclerosis begins
IIIReconstruction / ConsolidationRemodeling, fibrosis, new bone formation

Acute Charcot - "The Rocker-Bottom Foot"

  • Midfoot (Lisfranc/Chopart) most commonly affected
  • Painless swelling, warmth, erythema - often misdiagnosed as cellulitis
  • Distinguish from infection: no systemic signs; bilateral skin temperature difference >2°C is diagnostic
  • Offloading immediately to prevent progression

Management

  • Stage 0-I: Immobilization in TCC; non-weight bearing; bisphosphonates (IV pamidronate - reduce bone resorption)
  • Stage II-III: Continue offloading; custom footwear
  • Surgical indications: unstable deformity, ulceration over bony prominence, recurrent ulcers
  • Surgery: Exostectomy, Arthrodesis (with intramedullary nails/external fixator)

10. DIABETIC FOOT OSTEOMYELITIS

Diagnosis

  • Clinical: Sausage digit, exposed bone, ulcer >2cm², non-healing ulcer
  • Probe-to-bone (PTB) test: Sensitivity 60-66%, Specificity 85-89%; positive predictive value high in high-prevalence settings
  • X-ray: Bony destruction (late sign - 50% bone must be destroyed before visible)
  • MRI: Most sensitive and specific imaging; shows marrow changes early
  • Bone biopsy + culture: Gold standard for diagnosis AND microorganism identification

Treatment

  • Medical: 6-week IV/oral antibiotics based on bone biopsy culture
  • Surgical: Resection of infected bone → shorter antibiotic course (2 weeks); better outcomes
  • Small bones (toe phalanges, metatarsals): surgical resection often definitive
  • Larger bones: debridement + prolonged antibiotics

11. PREVENTION

Primary Prevention

  • Patient education: foot inspection daily, appropriate footwear, avoid barefoot walking
  • Annual foot examination by HCP
  • Glycemic control (HbA1c <7%)

Secondary Prevention (post-ulcer)

  • Custom therapeutic footwear (reduces recurrence from 58% to 28%)
  • Regular podiatry review
  • TCC for active offloading

IWGDF Risk Classification for Screening Frequency

CategoryFeaturesReview Frequency
0No neuropathy, no PADOnce a year
1Peripheral neuropathyEvery 6 months
2Neuropathy + PAD/deformityEvery 3 months
3Previous ulcer/amputationEvery 1-3 months

12. HIGH-YIELD EXAM POINTS

  1. Most common cause of non-traumatic lower limb amputation - Diabetes mellitus
  2. Most important single factor in diabetic foot - Peripheral neuropathy (NOT ischemia alone)
  3. Gold standard offloading - Total Contact Cast (TCC)
  4. Gold standard for osteomyelitis diagnosis - MRI (imaging) / Bone biopsy (microorganism)
  5. Probe-to-bone test positive = suspect osteomyelitis
  6. Wagner Grade 3 = Deep ulcer + osteomyelitis/abscess
  7. ABPI >1.3 = False high (medial calcinosis) → use TBI instead
  8. TcPO2 <30 mmHg = Poor healing; >40 mmHg = adequate for healing/amputation
  9. Guillotine amputation = Emergency for life-threatening sepsis; closed later
  10. Most common organisms - Staphylococcus aureus (mild); Polymicrobial (severe)
  11. Charcot foot - Acute phase: warm, red, swollen, X-ray normal → MRI early
  12. Most functional major amputation - Below-knee (transtibial)
  13. Great saphenous vein is preferred conduit for distal bypass
  14. PDGF (Becaplermin) - only FDA-approved growth factor for neuropathic DFU
  15. Angiosome-based revascularization - direct supply to wound angiosome improves healing
  16. HBOT - indicated Wagner 3-4 with non-revascularizable ischemia
  17. IWGDF/IDSA 2023 - current gold-standard guidelines for diabetic foot infection classification and management

13. DIFFERENTIAL DIAGNOSIS OF DIABETIC FOOT ULCER

ConditionDistinguishing Feature
Venous ulcerGaiter area (medial malleolus), irregular edges, lipodermatosclerosis, normal pulses
Arterial ulcerPainful, punched-out, pale base, distal, absent pulses
Marjolin's ulcerLong-standing, everted edges, induration, malignant transformation
Tropical ulcerYoung, malnourished, Fusospirochetal organisms
Pressure soreBony prominence, immobile patient

14. EXAM QUESTION FORMATS

Common long question: "A 60-year-old diabetic presents with infected foot ulcer on plantar aspect. Describe clinical features, investigation, and management."
Answer framework:
  1. Brief intro + types of diabetic foot
  2. Wagner classification
  3. Examination: local (site, size, depth, base, edges, discharge, probe-to-bone) + vascular + neurological
  4. Investigations: glucose/HbA1c, CBC, wound culture, X-ray, MRI, ABI/TBI
  5. Management: MDT, glycemic control, debridement, antibiotics (IDSA severity-based), offloading, vascular assessment ± revascularization, wound care (NPWT, dressings), amputation if needed
  6. Charcot foot if asked separately
Common short notes: Wagner classification | Charcot foot | Osteomyelitis in DM | Guillotine amputation | HBOT in diabetic foot | Offloading devices

References: IWGDF Guidelines 2023 (Schaper et al., Senneville et al.), Wagner Classification (1979), UT Classification (Lavery 1996), Monteiro-Soares Systematic Review DMRR 2024 [PMID 37132179], IWGDF/IDSA 2023 Guidelines [PMID 37779323]

Generate a quick reference PDF with Wagner grades and surgical algorithms

Reading File
Running Command

ls -la /tmp/workspace/ 2>/dev/null || mkdir -p /tmp/workspace && echo "workspace ready"

Running Command

mkdir -p /tmp/workspace/diabetic-foot && cat > /tmp/workspace/diabetic-foot/generate_pdf.py << 'PYEOF' from reportlab.lib.pagesizes import A4 from reportlab.lib import colors from reportlab.lib.units import mm, cm from reportlab.platypus import ( SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, HRFlowable, KeepTogether ) from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY from reportlab.platypus.flowables import HRFlowable from reportlab.graphics.shapes import Drawing, Rect, String, Arrow, Line, Polygon from reportlab.graphics import renderPDF from reportlab.graphics.shapes import Drawing, Rect, String, Line, Polygon, Group from reportlab.platypus import Flowable # ── Color palette ─────────────────────────────────────────────────────────── DARK_BLUE = colors.HexColor('#1a3a5c') MED_BLUE = colors.HexColor('#2a6099') LIGHT_BLUE = colors.HexColor('#d6e8f7') ACCENT_TEAL = colors.HexColor('#1a8a8a') TEAL_LIGHT = colors.HexColor('#d0f0f0') RED = colors.HexColor('#c0392b') RED_LIGHT = colors.HexColor('#fde8e6') ORANGE = colors.HexColor('#e07b00') ORANGE_LIGHT= colors.HexColor('#fff0d6') GREEN = colors.HexColor('#1a7a3a') GREEN_LIGHT = colors.HexColor('#d6f0e0') YELLOW = colors.HexColor('#b8860b') YELLOW_LIGHT= colors.HexColor('#fffacd') PURPLE = colors.HexColor('#6a3d9a') PURPLE_LIGHT= colors.HexColor('#ede0f7') GREY = colors.HexColor('#f5f5f5') DARK_GREY = colors.HexColor('#555555') WHITE = colors.white BLACK = colors.black W, H = A4 # ── Document ──────────────────────────────────────────────────────────────── doc = SimpleDocTemplate( '/tmp/workspace/diabetic-foot/Diabetic_Foot_Quick_Reference.pdf', pagesize=A4, leftMargin=15*mm, rightMargin=15*mm, topMargin=15*mm, bottomMargin=15*mm, ) styles = getSampleStyleSheet() def S(name, **kw): return ParagraphStyle(name, **kw) hdr_style = S('HDR', fontName='Helvetica-Bold', fontSize=18, textColor=WHITE, alignment=TA_CENTER, spaceAfter=0, leading=22) sub_hdr = S('SUB', fontName='Helvetica-Bold', fontSize=10, textColor=WHITE, alignment=TA_CENTER, spaceAfter=0) sec_title = S('SEC', fontName='Helvetica-Bold', fontSize=11, textColor=WHITE, spaceBefore=6, spaceAfter=4, leading=14) body = S('BODY', fontName='Helvetica', fontSize=8.5, textColor=BLACK, leading=12, spaceAfter=2) body_bold = S('BB', fontName='Helvetica-Bold', fontSize=8.5, textColor=BLACK, leading=12, spaceAfter=2) small = S('SM', fontName='Helvetica', fontSize=7.5, textColor=DARK_GREY, leading=10, spaceAfter=1) small_bold= S('SMB', fontName='Helvetica-Bold', fontSize=7.5, textColor=DARK_BLUE, leading=10, spaceAfter=1) foot_ref = S('FR', fontName='Helvetica-Oblique', fontSize=7, textColor=DARK_GREY, alignment=TA_CENTER) story = [] # ═══════════════════════════════════════════════════════════════════════════ # HEADER BANNER # ═══════════════════════════════════════════════════════════════════════════ class ColorBox(Flowable): def __init__(self, w, h, fill, radius=4): self.bw, self.bh, self.fill, self.radius = w, h, fill, radius def draw(self): self.canv.setFillColor(self.fill) self.canv.roundRect(0, 0, self.bw, self.bh, self.radius, fill=1, stroke=0) def wrap(self, *args): return self.bw, self.bh header_table = Table( [[Paragraph('DIABETIC FOOT', hdr_style)], [Paragraph('Wagner Classification &amp; Surgical Algorithm | MS Surgery Quick Reference', sub_hdr)], [Paragraph('IWGDF 2023 · Wagner (1979) · IDSA Classification', S('ref2', fontName='Helvetica-Oblique', fontSize=8, textColor=colors.HexColor('#b0d4f0'), alignment=TA_CENTER))]], colWidths=[W - 30*mm], rowHeights=[14*mm, 8*mm, 6*mm] ) header_table.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,-1), DARK_BLUE), ('TOPPADDING', (0,0), (0,0), 6), ('BOTTOMPADDING', (0,-1), (-1,-1), 4), ('LEFTPADDING', (0,0), (-1,-1), 8), ('RIGHTPADDING', (0,0), (-1,-1), 8), ('ROUNDEDCORNERS', [6]), ])) story.append(header_table) story.append(Spacer(1, 5*mm)) # ═══════════════════════════════════════════════════════════════════════════ # SECTION HEADER helper # ═══════════════════════════════════════════════════════════════════════════ def section_header(text, color=DARK_BLUE): t = Table([[Paragraph(text, sec_title)]], colWidths=[W - 30*mm]) t.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,-1), color), ('TOPPADDING', (0,0), (-1,-1), 4), ('BOTTOMPADDING', (0,0), (-1,-1), 4), ('LEFTPADDING', (0,0), (-1,-1), 8), ('ROUNDEDCORNERS', [4]), ])) return t # ═══════════════════════════════════════════════════════════════════════════ # SECTION 1 ── Wagner Classification # ═══════════════════════════════════════════════════════════════════════════ story.append(section_header('▶ WAGNER CLASSIFICATION OF DIABETIC FOOT')) story.append(Spacer(1, 2*mm)) GRADE_COLORS = [ (GREEN, GREEN_LIGHT, 'GRADE 0', 'Pre-ulcerative lesion', '• Intact skin\n• Callus, deformity, bony prominence\n• No open wound', 'Therapeutic footwear\nRegular podiatry\nPatient education'), (ACCENT_TEAL, TEAL_LIGHT, 'GRADE 1', 'Superficial ulcer', '• Full-thickness skin break\n• No subcutaneous involvement\n• Plantar or dorsal surface', 'Sharp debridement\nTotal Contact Cast (TCC)\nDressings + offloading'), (YELLOW, YELLOW_LIGHT, 'GRADE 2', 'Deep ulcer — tendon/capsule/bone', '• Penetrates to tendon, joint capsule\n• No abscess / osteomyelitis\n• Often probes to bone', 'Debridement + wound care\nAntibiotics (culture-guided)\nMRI to rule out OM\nVascular assessment'), (ORANGE, ORANGE_LIGHT, 'GRADE 3', 'Deep ulcer + abscess / osteomyelitis', '• Osteomyelitis or septic arthritis\n• Deep space abscess\n• Probe-to-bone positive', 'IV antibiotics (broad-spectrum)\nSurgical debridement / I&D\nBone resection / ray amputation\nHBOT adjunct'), (RED, RED_LIGHT, 'GRADE 4', 'Localised gangrene', '• Toe / forefoot gangrene\n• Proximal tissues viable\n• May have wet or dry gangrene', 'Revascularisation if feasible\nRay / toe / TMA amputation\nIV antibiotics\nGuillotine if severe sepsis'), (colors.HexColor('#7b1a1a'), colors.HexColor('#f0d0d0'), 'GRADE 5', 'Extensive / whole-foot gangrene', '• Entire foot involved\n• Non-salvageable foot\n• Systemic sepsis common', 'Below-knee OR above-knee\namputation\nStabilise sepsis first\nGuillotine → formal closure'), ] grade_rows = [] for (hc, bc, grade, title, desc, mgmt) in GRADE_COLORS: grade_cell = Paragraph(f'<b>{grade}</b>', S('GC', fontName='Helvetica-Bold', fontSize=11, textColor=WHITE, alignment=TA_CENTER, leading=13)) title_cell = Paragraph(f'<b>{title}</b>', S('TC', fontName='Helvetica-Bold', fontSize=9, textColor=hc, leading=11)) desc_cell = Paragraph(desc.replace('\n', '<br/>'), S('DC', fontName='Helvetica', fontSize=8, textColor=BLACK, leading=11)) mgmt_cell = Paragraph(mgmt.replace('\n', '<br/>'), S('MC', fontName='Helvetica', fontSize=8, textColor=BLACK, leading=11)) grade_rows.append([grade_cell, title_cell, desc_cell, mgmt_cell]) wagner_table = Table( [['', Paragraph('<b>Presentation</b>', S('TH', fontName='Helvetica-Bold', fontSize=8.5, textColor=DARK_BLUE)), Paragraph('<b>Clinical Features</b>', S('TH', fontName='Helvetica-Bold', fontSize=8.5, textColor=DARK_BLUE)), Paragraph('<b>Management</b>', S('TH', fontName='Helvetica-Bold', fontSize=8.5, textColor=DARK_BLUE))]] + grade_rows, colWidths=[22*mm, 40*mm, 62*mm, 52*mm], rowHeights=[7*mm] + [17*mm]*6 ) ts = TableStyle([ ('BACKGROUND', (0,0), (-1,0), GREY), ('GRID', (0,0), (-1,-1), 0.5, colors.HexColor('#cccccc')), ('VALIGN', (0,0), (-1,-1), 'MIDDLE'), ('TOPPADDING', (0,0), (-1,-1), 4), ('BOTTOMPADDING', (0,0), (-1,-1), 4), ('LEFTPADDING', (0,0), (-1,-1), 5), ('RIGHTPADDING', (0,0), (-1,-1), 5), ('ROWBACKGROUNDS', (0,0), (-1,0), [GREY]), ]) for i, (hc, bc, *_) in enumerate(GRADE_COLORS, start=1): ts.add('BACKGROUND', (0, i), (0, i), hc) ts.add('BACKGROUND', (1, i), (-1, i), bc) wagner_table.setStyle(ts) story.append(wagner_table) story.append(Spacer(1, 4*mm)) # ═══════════════════════════════════════════════════════════════════════════ # SECTION 2 ── Surgical Algorithm (flow diagram as table-based flowchart) # ═══════════════════════════════════════════════════════════════════════════ story.append(section_header('▶ SURGICAL MANAGEMENT ALGORITHM', MED_BLUE)) story.append(Spacer(1, 2*mm)) def box(text, bg, fg=WHITE, fs=8, bold=True, w=None): fn = 'Helvetica-Bold' if bold else 'Helvetica' p = Paragraph(text, S('BX', fontName=fn, fontSize=fs, textColor=fg, alignment=TA_CENTER, leading=fs+2)) t = Table([[p]], colWidths=[w] if w else None) t.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,-1), bg), ('TOPPADDING', (0,0), (-1,-1), 5), ('BOTTOMPADDING', (0,0), (-1,-1), 5), ('LEFTPADDING', (0,0), (-1,-1), 5), ('RIGHTPADDING', (0,0), (-1,-1), 5), ('ROUNDEDCORNERS', [4]), ])) return t arrow = Paragraph('▼', S('AR', fontName='Helvetica-Bold', fontSize=11, textColor=DARK_GREY, alignment=TA_CENTER)) # Row 1: Entry algo_row1 = Table( [[box('DIABETIC FOOT ULCER PRESENTATION', DARK_BLUE, WHITE, fs=9, w=155*mm)]], colWidths=[W - 30*mm] ) algo_row1.setStyle(TableStyle([('ALIGN', (0,0), (-1,-1), 'CENTER')])) # Row 2: Assess infection severity story.append(algo_row1) story.append(Spacer(1, 1.5*mm)) story.append(Paragraph('▼', S('AR', fontName='Helvetica-Bold', fontSize=11, textColor=DARK_GREY, alignment=TA_CENTER))) story.append(Spacer(1, 1*mm)) assess_table = Table( [[Paragraph('<b>STEP 1: Assess Infection Severity (IDSA Classification)</b>', S('ST', fontName='Helvetica-Bold', fontSize=8.5, textColor=DARK_BLUE, alignment=TA_CENTER))]], colWidths=[W - 30*mm] ) assess_table.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,-1), LIGHT_BLUE), ('TOPPADDING', (0,0), (-1,-1), 4), ('BOTTOMPADDING', (0,0), (-1,-1), 4), ('LEFTPADDING', (0,0), (-1,-1), 6), ('GRID', (0,0), (-1,-1), 0.5, MED_BLUE), ])) story.append(assess_table) story.append(Spacer(1, 1.5*mm)) infect_data = [ [Paragraph('<b>Uninfected</b>', S('IH', fontName='Helvetica-Bold', fontSize=8, textColor=GREEN, alignment=TA_CENTER)), Paragraph('<b>Mild</b>', S('IH', fontName='Helvetica-Bold', fontSize=8, textColor=YELLOW, alignment=TA_CENTER)), Paragraph('<b>Moderate</b>', S('IH', fontName='Helvetica-Bold', fontSize=8, textColor=ORANGE, alignment=TA_CENTER)), Paragraph('<b>Severe</b>', S('IH', fontName='Helvetica-Bold', fontSize=8, textColor=RED, alignment=TA_CENTER))], [Paragraph('No signs of\ninflammation', S('IC', fontName='Helvetica', fontSize=7.5, textColor=BLACK, alignment=TA_CENTER, leading=10)), Paragraph('&lt;2cm cellulitis\nSuperficial only\nNo systemic signs', S('IC', fontName='Helvetica', fontSize=7.5, textColor=BLACK, alignment=TA_CENTER, leading=10)), Paragraph('&gt;2cm cellulitis\nDeep fascia/bone\nAbscess/joint', S('IC', fontName='Helvetica', fontSize=7.5, textColor=BLACK, alignment=TA_CENTER, leading=10)), Paragraph('SIRS criteria\nFever, tachy,\nleukocytosis', S('IC', fontName='Helvetica', fontSize=7.5, textColor=BLACK, alignment=TA_CENTER, leading=10))], [Paragraph('Local wound care\nOffloading only', S('IM', fontName='Helvetica', fontSize=7.5, textColor=GREEN, alignment=TA_CENTER, leading=10)), Paragraph('Oral antibiotics\n1–2 weeks\nDebridement', S('IM', fontName='Helvetica', fontSize=7.5, textColor=YELLOW, alignment=TA_CENTER, leading=10)), Paragraph('IV antibiotics\nSurgical drainage\n± Bone biopsy', S('IM', fontName='Helvetica', fontSize=7.5, textColor=ORANGE, alignment=TA_CENTER, leading=10)), Paragraph('IV broad spectrum\nICU if unstable\nEmergency surgery', S('IM', fontName='Helvetica', fontSize=7.5, textColor=RED, alignment=TA_CENTER, leading=10))], ] infect_table = Table(infect_data, colWidths=[40*mm]*4, rowHeights=[8*mm, 14*mm, 14*mm]) infect_table.setStyle(TableStyle([ ('BACKGROUND', (0,0), (0,-1), GREEN_LIGHT), ('BACKGROUND', (1,0), (1,-1), YELLOW_LIGHT), ('BACKGROUND', (2,0), (2,-1), ORANGE_LIGHT), ('BACKGROUND', (3,0), (3,-1), RED_LIGHT), ('GRID', (0,0), (-1,-1), 0.5, colors.HexColor('#cccccc')), ('VALIGN', (0,0), (-1,-1), 'MIDDLE'), ('TOPPADDING', (0,0), (-1,-1), 3), ('BOTTOMPADDING', (0,0), (-1,-1), 3), ])) story.append(infect_table) story.append(Spacer(1, 1.5*mm)) story.append(Paragraph('▼', S('AR2', fontName='Helvetica-Bold', fontSize=11, textColor=DARK_GREY, alignment=TA_CENTER))) story.append(Spacer(1, 1*mm)) # Step 2: Vascular vasc_hdr = Table([[Paragraph('<b>STEP 2: Vascular Assessment</b>', S('VH', fontName='Helvetica-Bold', fontSize=8.5, textColor=DARK_BLUE, alignment=TA_CENTER))]], colWidths=[W - 30*mm]) vasc_hdr.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,-1), LIGHT_BLUE), ('TOPPADDING', (0,0), (-1,-1), 4), ('BOTTOMPADDING', (0,0), (-1,-1), 4), ('GRID', (0,0), (-1,-1), 0.5, MED_BLUE), ])) story.append(vasc_hdr) story.append(Spacer(1, 1.5*mm)) vasc_data = [ [Paragraph('<b>ABI &gt; 0.9\n(Normal)</b>', S('VA', fontName='Helvetica-Bold', fontSize=8, textColor=GREEN, alignment=TA_CENTER, leading=11)), Paragraph('<b>ABI 0.5–0.9\n(Mild–Moderate)</b>', S('VA', fontName='Helvetica-Bold', fontSize=8, textColor=YELLOW, alignment=TA_CENTER, leading=11)), Paragraph('<b>ABI &lt; 0.5 OR\nTcPO₂ &lt; 30 mmHg</b>', S('VA', fontName='Helvetica-Bold', fontSize=8, textColor=RED, alignment=TA_CENTER, leading=11)), Paragraph('<b>ABI &gt; 1.3\n(Non-compressible)</b>', S('VA', fontName='Helvetica-Bold', fontSize=8, textColor=PURPLE, alignment=TA_CENTER, leading=11))], [Paragraph('Proceed with\nwound surgery', S('VB', fontName='Helvetica', fontSize=7.5, textColor=BLACK, alignment=TA_CENTER, leading=10)), Paragraph('Duplex USS\nOptimise risk\nConsider PTA', S('VB', fontName='Helvetica', fontSize=7.5, textColor=BLACK, alignment=TA_CENTER, leading=10)), Paragraph('CT/MR Angio\nRevascularise first:\nPTA or Bypass', S('VB', fontName='Helvetica', fontSize=7.5, textColor=BLACK, alignment=TA_CENTER, leading=10)), Paragraph('Use Toe-Brachial\nIndex (TBI)\nor TcPO₂', S('VB', fontName='Helvetica', fontSize=7.5, textColor=BLACK, alignment=TA_CENTER, leading=10))], ] vasc_table = Table(vasc_data, colWidths=[40*mm]*4, rowHeights=[13*mm, 13*mm]) vasc_table.setStyle(TableStyle([ ('BACKGROUND', (0,0), (0,-1), GREEN_LIGHT), ('BACKGROUND', (1,0), (1,-1), YELLOW_LIGHT), ('BACKGROUND', (2,0), (2,-1), RED_LIGHT), ('BACKGROUND', (3,0), (3,-1), PURPLE_LIGHT), ('GRID', (0,0), (-1,-1), 0.5, colors.HexColor('#cccccc')), ('VALIGN', (0,0), (-1,-1), 'MIDDLE'), ('TOPPADDING', (0,0), (-1,-1), 3), ('BOTTOMPADDING', (0,0), (-1,-1), 3), ])) story.append(vasc_table) story.append(Spacer(1, 1.5*mm)) story.append(Paragraph('▼', S('AR3', fontName='Helvetica-Bold', fontSize=11, textColor=DARK_GREY, alignment=TA_CENTER))) story.append(Spacer(1, 1*mm)) # Step 3: Surgical decision by Wagner grade surg_hdr = Table([[Paragraph('<b>STEP 3: Surgical Decision by Wagner Grade</b>', S('SH', fontName='Helvetica-Bold', fontSize=8.5, textColor=DARK_BLUE, alignment=TA_CENTER))]], colWidths=[W - 30*mm]) surg_hdr.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,-1), LIGHT_BLUE), ('TOPPADDING', (0,0), (-1,-1), 4), ('BOTTOMPADDING', (0,0), (-1,-1), 4), ('GRID', (0,0), (-1,-1), 0.5, MED_BLUE), ])) story.append(surg_hdr) story.append(Spacer(1, 1.5*mm)) surg_data = [ [Paragraph('<b>W0–W1</b>', S('SG', fontName='Helvetica-Bold', fontSize=8.5, textColor=GREEN, alignment=TA_CENTER)), Paragraph('<b>W2</b>', S('SG', fontName='Helvetica-Bold', fontSize=8.5, textColor=ACCENT_TEAL, alignment=TA_CENTER)), Paragraph('<b>W3</b>', S('SG', fontName='Helvetica-Bold', fontSize=8.5, textColor=ORANGE, alignment=TA_CENTER)), Paragraph('<b>W4</b>', S('SG', fontName='Helvetica-Bold', fontSize=8.5, textColor=RED, alignment=TA_CENTER)), Paragraph('<b>W5</b>', S('SG', fontName='Helvetica-Bold', fontSize=8.5, textColor=colors.HexColor('#7b1a1a'), alignment=TA_CENTER))], [Paragraph('Conservative\n• Sharp debridement\n• TCC offloading\n• Therapeutic shoes\n• Wound dressings', S('SB', fontName='Helvetica', fontSize=7.2, textColor=BLACK, leading=10)), Paragraph('Local surgery\n• Deep debridement\n• Remove necrotic\n tendon/capsule\n• MRI ± bone biopsy', S('SB', fontName='Helvetica', fontSize=7.2, textColor=BLACK, leading=10)), Paragraph('Definitive surgery\n• I&D abscess\n• Bone resection\n• Ray amputation\n• IV abx 4-6 wks', S('SB', fontName='Helvetica', fontSize=7.2, textColor=BLACK, leading=10)), Paragraph('Limited amputation\n• Toe disarticulation\n• Ray amputation\n• TMA (forefoot)\n• ± Revascularise first', S('SB', fontName='Helvetica', fontSize=7.2, textColor=BLACK, leading=10)), Paragraph('Major amputation\n• Below-knee (BKA)\n• Above-knee (AKA)\n• Guillotine if sepsis\n• Stump closure later', S('SB', fontName='Helvetica', fontSize=7.2, textColor=BLACK, leading=10))], ] surg_table = Table(surg_data, colWidths=[32*mm]*5, rowHeights=[8*mm, 26*mm]) surg_table.setStyle(TableStyle([ ('BACKGROUND', (0,0), (0,-1), GREEN_LIGHT), ('BACKGROUND', (1,0), (1,-1), TEAL_LIGHT), ('BACKGROUND', (2,0), (2,-1), ORANGE_LIGHT), ('BACKGROUND', (3,0), (3,-1), RED_LIGHT), ('BACKGROUND', (4,0), (4,-1), colors.HexColor('#f0d0d0')), ('GRID', (0,0), (-1,-1), 0.5, colors.HexColor('#cccccc')), ('VALIGN', (0,0), (-1,-1), 'TOP'), ('TOPPADDING', (0,0), (-1,-1), 4), ('BOTTOMPADDING', (0,0), (-1,-1), 4), ('LEFTPADDING', (0,0), (-1,-1), 4), ])) story.append(surg_table) story.append(Spacer(1, 1.5*mm)) story.append(Paragraph('▼', S('AR4', fontName='Helvetica-Bold', fontSize=11, textColor=DARK_GREY, alignment=TA_CENTER))) story.append(Spacer(1, 1*mm)) # Step 4: Wound closure closure_hdr = Table([[Paragraph('<b>STEP 4: Wound Closure / Reconstruction</b>', S('CH', fontName='Helvetica-Bold', fontSize=8.5, textColor=DARK_BLUE, alignment=TA_CENTER))]], colWidths=[W - 30*mm]) closure_hdr.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,-1), LIGHT_BLUE), ('TOPPADDING', (0,0), (-1,-1), 4), ('BOTTOMPADDING', (0,0), (-1,-1), 4), ('GRID', (0,0), (-1,-1), 0.5, MED_BLUE), ])) story.append(closure_hdr) story.append(Spacer(1, 1.5*mm)) closure_data = [[ Paragraph('<b>Primary Closure</b>\nClean wounds\nNo tension\nGood vascularity', S('CL', fontName='Helvetica', fontSize=8, textColor=BLACK, alignment=TA_CENTER, leading=11)), Paragraph('<b>Secondary Intention</b>\nInfected wounds\nPoor vascularity\nSmall defects', S('CL', fontName='Helvetica', fontSize=8, textColor=BLACK, alignment=TA_CENTER, leading=11)), Paragraph('<b>NPWT (VAC)</b>\nPost-debridement\nPre-graft prep\n125 mmHg', S('CL', fontName='Helvetica', fontSize=8, textColor=BLACK, alignment=TA_CENTER, leading=11)), Paragraph('<b>Split Skin Graft</b>\nGranulating base\nLarge defects\nAfter vascularisation', S('CL', fontName='Helvetica', fontSize=8, textColor=BLACK, alignment=TA_CENTER, leading=11)), Paragraph('<b>Flap / Free Flap</b>\nLarge/complex\nWeight-bearing\nAreas', S('CL', fontName='Helvetica', fontSize=8, textColor=BLACK, alignment=TA_CENTER, leading=11)), ]] closure_table = Table(closure_data, colWidths=[32*mm]*5, rowHeights=[18*mm]) closure_table.setStyle(TableStyle([ ('BACKGROUND', (0,0), (0,-1), GREEN_LIGHT), ('BACKGROUND', (1,0), (1,-1), LIGHT_BLUE), ('BACKGROUND', (2,0), (2,-1), TEAL_LIGHT), ('BACKGROUND', (3,0), (3,-1), YELLOW_LIGHT), ('BACKGROUND', (4,0), (4,-1), PURPLE_LIGHT), ('GRID', (0,0), (-1,-1), 0.5, colors.HexColor('#cccccc')), ('VALIGN', (0,0), (-1,-1), 'MIDDLE'), ('TOPPADDING', (0,0), (-1,-1), 4), ('BOTTOMPADDING', (0,0), (-1,-1), 4), ])) story.append(closure_table) story.append(Spacer(1, 4*mm)) # ═══════════════════════════════════════════════════════════════════════════ # SECTION 3 ── Amputation levels # ═══════════════════════════════════════════════════════════════════════════ story.append(section_header('▶ AMPUTATION LEVELS & SELECTION CRITERIA', ACCENT_TEAL)) story.append(Spacer(1, 2*mm)) amp_data = [ [Paragraph('<b>Level</b>', S('AH', fontName='Helvetica-Bold', fontSize=8.5, textColor=WHITE)), Paragraph('<b>Indication</b>', S('AH', fontName='Helvetica-Bold', fontSize=8.5, textColor=WHITE)), Paragraph('<b>Requirement</b>', S('AH', fontName='Helvetica-Bold', fontSize=8.5, textColor=WHITE)), Paragraph('<b>Key Points</b>', S('AH', fontName='Helvetica-Bold', fontSize=8.5, textColor=WHITE))], [Paragraph('<b>Toe disarticulation</b>', S('AL', fontName='Helvetica-Bold', fontSize=8, textColor=DARK_BLUE)), Paragraph('Isolated gangrenous digit', S('AB', fontName='Helvetica', fontSize=8, textColor=BLACK)), Paragraph('Viable skin margins\nNo spreading infection', S('AB', fontName='Helvetica', fontSize=8, textColor=BLACK, leading=10)), Paragraph('Most conservative\nPreserves foot function', S('AB', fontName='Helvetica', fontSize=8, textColor=BLACK, leading=10))], [Paragraph('<b>Ray amputation</b>', S('AL', fontName='Helvetica-Bold', fontSize=8, textColor=DARK_BLUE)), Paragraph('Single ray osteomyelitis\nor gangrene', S('AB', fontName='Helvetica', fontSize=8, textColor=BLACK, leading=10)), Paragraph('Adjacent rays viable\nNo proximal infection', S('AB', fontName='Helvetica', fontSize=8, textColor=BLACK, leading=10)), Paragraph('Toe + metatarsal shaft\nResects entire ray', S('AB', fontName='Helvetica', fontSize=8, textColor=BLACK, leading=10))], [Paragraph('<b>TMA (Trans-\nmetatarsal)</b>', S('AL', fontName='Helvetica-Bold', fontSize=8, textColor=DARK_BLUE, leading=10)), Paragraph('Forefoot gangrene\nMultiple ray disease', S('AB', fontName='Helvetica', fontSize=8, textColor=BLACK, leading=10)), Paragraph('Viable heel/dorsum\nTcPO₂ &gt;40 mmHg', S('AB', fontName='Helvetica', fontSize=8, textColor=BLACK, leading=10)), Paragraph('Good functional result\nRevascularise first if needed', S('AB', fontName='Helvetica', fontSize=8, textColor=BLACK, leading=10))], [Paragraph("<b>Syme's amputation</b>", S('AL', fontName='Helvetica-Bold', fontSize=8, textColor=DARK_BLUE)), Paragraph('Distal foot disease\nNeuropathic (select cases)', S('AB', fontName='Helvetica', fontSize=8, textColor=BLACK, leading=10)), Paragraph('Viable heel pad\nGood vascularity', S('AB', fontName='Helvetica', fontSize=8, textColor=BLACK, leading=10)), Paragraph('End-bearing stump\nSimple prosthesis', S('AB', fontName='Helvetica', fontSize=8, textColor=BLACK, leading=10))], [Paragraph('<b>Below-knee (BKA)\n★ PREFERRED</b>', S('AL', fontName='Helvetica-Bold', fontSize=8, textColor=GREEN, leading=10)), Paragraph('Extensive foot disease\nUnsalvageable foot', S('AB', fontName='Helvetica', fontSize=8, textColor=BLACK, leading=10)), Paragraph('Patent popliteal artery\nMinimum 5 cm stump\nTcPO₂ &gt;40 mmHg', S('AB', fontName='Helvetica', fontSize=8, textColor=BLACK, leading=10)), Paragraph('Most functional major amp\nLow rehabilitation energy\nProsthesis fitting easier', S('AB', fontName='Helvetica', fontSize=8, textColor=BLACK, leading=10))], [Paragraph('<b>Above-knee (AKA)</b>', S('AL', fontName='Helvetica-Bold', fontSize=8, textColor=RED)), Paragraph('BKA not feasible\nKnee joint involved', S('AB', fontName='Helvetica', fontSize=8, textColor=BLACK, leading=10)), Paragraph('Last resort\nHigher mortality', S('AB', fontName='Helvetica', fontSize=8, textColor=BLACK, leading=10)), Paragraph('3x more energy needed\nPoor rehab in elderly/obese', S('AB', fontName='Helvetica', fontSize=8, textColor=BLACK, leading=10))], [Paragraph('<b>Guillotine\n(Emergency)</b>', S('AL', fontName='Helvetica-Bold', fontSize=8, textColor=RED, leading=10)), Paragraph('Uncontrolled spreading sepsis\nGas gangrene', S('AB', fontName='Helvetica', fontSize=8, textColor=BLACK, leading=10)), Paragraph('Life-saving\nOpen wound', S('AB', fontName='Helvetica', fontSize=8, textColor=BLACK, leading=10)), Paragraph('Followed by formal\namputation after 48-72h\nonce sepsis controlled', S('AB', fontName='Helvetica', fontSize=8, textColor=BLACK, leading=10))], ] amp_table = Table(amp_data, colWidths=[35*mm, 45*mm, 45*mm, 51*mm]) amp_ts = TableStyle([ ('BACKGROUND', (0,0), (-1,0), ACCENT_TEAL), ('TEXTCOLOR', (0,0), (-1,0), WHITE), ('GRID', (0,0), (-1,-1), 0.5, colors.HexColor('#cccccc')), ('VALIGN', (0,0), (-1,-1), 'MIDDLE'), ('TOPPADDING', (0,0), (-1,-1), 4), ('BOTTOMPADDING', (0,0), (-1,-1), 4), ('LEFTPADDING', (0,0), (-1,-1), 5), ('ROWBACKGROUNDS', (0,1), (-1,-1), [WHITE, GREY]), ]) # highlight BKA row (index 5 in data = row 5) amp_ts.add('BACKGROUND', (0,5), (-1,5), colors.HexColor('#e8f8ee')) amp_ts.add('BACKGROUND', (0,7), (-1,7), RED_LIGHT) amp_table.setStyle(amp_ts) story.append(amp_table) story.append(Spacer(1, 4*mm)) # ═══════════════════════════════════════════════════════════════════════════ # SECTION 4 ── Key Investigations # ═══════════════════════════════════════════════════════════════════════════ story.append(section_header('▶ KEY INVESTIGATIONS AT A GLANCE', PURPLE)) story.append(Spacer(1, 2*mm)) inv_data = [ [Paragraph('<b>Investigation</b>', S('IH2', fontName='Helvetica-Bold', fontSize=8.5, textColor=WHITE)), Paragraph('<b>Indication</b>', S('IH2', fontName='Helvetica-Bold', fontSize=8.5, textColor=WHITE)), Paragraph('<b>Critical Value / Interpretation</b>', S('IH2', fontName='Helvetica-Bold', fontSize=8.5, textColor=WHITE))], [Paragraph('HbA1c', S('IN', fontName='Helvetica-Bold', fontSize=8, textColor=DARK_BLUE)), Paragraph('Glycaemic control', small), Paragraph('Target &lt;7%; &gt;9% = poorly controlled', small)], [Paragraph('Wound culture + sensitivity', S('IN', fontName='Helvetica-Bold', fontSize=8, textColor=DARK_BLUE)), Paragraph('Guide antibiotic therapy', small), Paragraph('Deep tissue &gt; swab; take before antibiotics', small)], [Paragraph('Probe-to-bone test', S('IN', fontName='Helvetica-Bold', fontSize=8, textColor=DARK_BLUE)), Paragraph('Screen for osteomyelitis', small), Paragraph('Positive (metal probe hits bone) → 89% specific for OM', small)], [Paragraph('X-ray foot', S('IN', fontName='Helvetica-Bold', fontSize=8, textColor=DARK_BLUE)), Paragraph('First-line imaging', small), Paragraph('2–3 week lag; shows periosteal rxn, cortical destruction late', small)], [Paragraph('MRI foot ★ Gold standard', S('IN', fontName='Helvetica-Bold', fontSize=8, textColor=GREEN)), Paragraph('Osteomyelitis extent\nCharcot staging', small), Paragraph('Best sensitivity + specificity; shows bone marrow oedema early', small)], [Paragraph('ABI (ABPI)', S('IN', fontName='Helvetica-Bold', fontSize=8, textColor=DARK_BLUE)), Paragraph('Vascular screening', small), Paragraph('&lt;0.9 ischemia | &lt;0.5 severe | &gt;1.3 non-compressible (use TBI)', small)], [Paragraph('TcPO₂', S('IN', fontName='Helvetica-Bold', fontSize=8, textColor=DARK_BLUE)), Paragraph('Tissue oxygenation\nAmputation level', small), Paragraph('&lt;30 mmHg poor healing | &gt;40 mmHg adequate for healing/amp', small)], [Paragraph('CT / MR Angiography', S('IN', fontName='Helvetica-Bold', fontSize=8, textColor=DARK_BLUE)), Paragraph('Pre-revascularisation\nplanning', small), Paragraph('Gold standard vascular map; identifies tibial/peroneal disease', small)], [Paragraph('Bone biopsy + culture', S('IN', fontName='Helvetica-Bold', fontSize=8, textColor=GREEN)), Paragraph('Confirm OM organism', small), Paragraph('Gold standard for causative organism in osteomyelitis', small)], ] inv_table = Table(inv_data, colWidths=[45*mm, 45*mm, 86*mm]) inv_ts = TableStyle([ ('BACKGROUND', (0,0), (-1,0), PURPLE), ('TEXTCOLOR', (0,0), (-1,0), WHITE), ('GRID', (0,0), (-1,-1), 0.5, colors.HexColor('#cccccc')), ('VALIGN', (0,0), (-1,-1), 'MIDDLE'), ('TOPPADDING', (0,0), (-1,-1), 3), ('BOTTOMPADDING', (0,0), (-1,-1), 3), ('LEFTPADDING', (0,0), (-1,-1), 5), ('ROWBACKGROUNDS', (0,1), (-1,-1), [WHITE, GREY]), ]) inv_table.setStyle(inv_ts) story.append(inv_table) story.append(Spacer(1, 4*mm)) # ═══════════════════════════════════════════════════════════════════════════ # SECTION 5 ── High-yield exam box # ═══════════════════════════════════════════════════════════════════════════ exam_points = [ ('Most common cause of non-traumatic lower limb amputation', 'Diabetes mellitus'), ('Gold standard offloading for neuropathic plantar ulcer', 'Total Contact Cast (TCC)'), ('Gold standard imaging for osteomyelitis', 'MRI (early); Bone biopsy (organism)'), ('Wagner Grade with osteomyelitis/abscess', 'Grade 3'), ('ABI >1.3 means', 'Non-compressible vessels (medial calcinosis) → use TBI'), ('TcPO₂ threshold for wound healing', '>40 mmHg adequate; <30 mmHg = poor'), ('Most functional major amputation', 'Below-knee (transtibial)'), ('Preferred bypass conduit', 'Autologous great saphenous vein'), ('Emergency amputation for life-threatening sepsis', 'Guillotine amputation → formal closure later'), ('Most common organism in diabetic foot', 'Staph aureus (mild); Polymicrobial (severe)'), ('Only FDA-approved growth factor for DFU', 'PDGF – Becaplermin'), ('Current guidelines', 'IWGDF 2023 / IDSA 2023'), ] story.append(section_header('▶ HIGH-YIELD EXAM PEARLS', colors.HexColor('#8b1a1a'))) story.append(Spacer(1, 2*mm)) exam_rows = [[ Paragraph('<b>Key Point</b>', S('EH', fontName='Helvetica-Bold', fontSize=8.5, textColor=colors.HexColor('#8b1a1a'))), Paragraph('<b>Answer</b>', S('EH', fontName='Helvetica-Bold', fontSize=8.5, textColor=colors.HexColor('#8b1a1a'))), ]] for q, a in exam_points: exam_rows.append([ Paragraph(q, S('EQ', fontName='Helvetica', fontSize=8, textColor=BLACK, leading=11)), Paragraph(f'<b>{a}</b>', S('EA', fontName='Helvetica-Bold', fontSize=8, textColor=colors.HexColor('#8b1a1a'), leading=11)), ]) exam_table = Table(exam_rows, colWidths=[90*mm, 86*mm]) exam_table.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,0), colors.HexColor('#fce8e8')), ('GRID', (0,0), (-1,-1), 0.5, colors.HexColor('#e0a0a0')), ('VALIGN', (0,0), (-1,-1), 'MIDDLE'), ('TOPPADDING', (0,0), (-1,-1), 3), ('BOTTOMPADDING', (0,0), (-1,-1), 3), ('LEFTPADDING', (0,0), (-1,-1), 6), ('ROWBACKGROUNDS', (0,1), (-1,-1), [WHITE, colors.HexColor('#fff5f5')]), ])) story.append(exam_table) story.append(Spacer(1, 4*mm)) # Footer story.append(HRFlowable(width='100%', thickness=0.5, color=DARK_GREY)) story.append(Spacer(1, 1*mm)) story.append(Paragraph( 'References: Wagner FW (1979) · IWGDF Guidelines 2023 (Schaper et al.) · IWGDF/IDSA 2023 (Senneville et al.) · ' 'UT Classification (Lavery 1996) · WIfI Classification (Mills 2014) | MS Surgery Quick Reference | © 2026', foot_ref )) doc.build(story) print("PDF generated successfully!") PYEOF echo "Script written"

Running Command

cd /tmp/workspace/diabetic-foot && python generate_pdf.py

Editing File

~/diabetic-foot/generate_pdf.py

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

cd /tmp/workspace/diabetic-foot && python generate_pdf.py

Running Command

ls -lh /tmp/workspace/diabetic-foot/Diabetic_Foot_Quick_Reference.pdf

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

Diabetic Foot Quick Reference

PDF Document · PDF


What's inside the PDF (A4, colour-coded, print-ready):
1. Wagner Classification Table - all 6 grades (0-5) in a colour-coded grid with:
  • Grade colour coding (green → dark red severity scale)
  • Presentation + clinical features per grade
  • Management column per grade
2. Surgical Management Algorithm (Step-by-step flowchart):
  • Step 1 - IDSA infection severity (Uninfected → Mild → Moderate → Severe) with actions
  • Step 2 - Vascular assessment (ABI cut-offs, TcPO₂, what to do at each level)
  • Step 3 - Surgical decision matrix by Wagner grade (W0-1 through W5)
  • Step 4 - Wound closure options (primary → SSG → free flap ladder)
3. Amputation Levels & Selection Criteria - toe through guillotine, with BKA highlighted as preferred, indication + requirement + key points per level
4. Key Investigations at a Glance - HbA1c, probe-to-bone, MRI, ABI, TcPO₂, bone biopsy with critical values
5. High-Yield Exam Pearls - 12 must-know Q&A pairs in a red-accented table
References: IWGDF 2023, IDSA 2023, Wagner 1979, UT Classification (Lavery 1996)

Make a long question answer for exam for this topic which I can download as notes

Reading File
Running Command

ls -la /tmp/workspace/diabetic-foot/

Writing File

~/diabetic-foot/generate_notes.py

from docx import Document
from docx.shared import Pt, Inches, RGBColor, Cm
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.oxml.ns import qn
from docx.oxml import OxmlElement
import copy

doc = Document()

# ── Page margins ────────────────────────────────────────────────────────────
section = doc.sections[0]
section.page_width  = Inches(8.27)   # A4
section.page_height = Inches(11.69)
section.left_margin   = Cm(2.2)
section.right_margin  = Cm(2.2)
section.top_margin    = Cm(2)
section.bottom_margin = Cm(2)

# ── Colour palette ──────────────────────────────────────────────────────────
C_DARK_BLUE  = RGBColor(0x1A, 0x3A, 0x5C)
C_MED_BLUE   = RGBColor(0x2A, 0x60, 0x99)
C_TEAL       = RGBColor(0x1A, 0x8A, 0x8A)
C_RED        = RGBColor(0xC0, 0x39, 0x2B)
C_ORANGE     = RGBColor(0xE0, 0x7B, 0x00)
C_GREEN      = RGBColor(0x1A, 0x7A, 0x3A)
C_PURPLE     = RGBColor(0x6A, 0x3D, 0x9A)
C_WHITE      = RGBColor(0xFF, 0xFF, 0xFF)
C_LIGHT_GREY = RGBColor(0xF0, 0xF0, 0xF0)
C_DARK_GREY  = RGBColor(0x44, 0x44, 0x44)
C_GOLD       = RGBColor(0xB8, 0x73, 0x00)

# ── Helper: set paragraph shading ───────────────────────────────────────────
def shade_paragraph(para, hex_fill):
    pPr = para._p.get_or_add_pPr()
    shd = OxmlElement('w:shd')
    shd.set(qn('w:val'), 'clear')
    shd.set(qn('w:color'), 'auto')
    shd.set(qn('w:fill'), hex_fill)
    pPr.append(shd)

def shade_cell(cell, hex_fill):
    tc = cell._tc
    tcPr = tc.get_or_add_tcPr()
    shd = OxmlElement('w:shd')
    shd.set(qn('w:val'), 'clear')
    shd.set(qn('w:color'), 'auto')
    shd.set(qn('w:fill'), hex_fill)
    tcPr.append(shd)

def set_cell_border(cell, **kwargs):
    tc = cell._tc
    tcPr = tc.get_or_add_tcPr()
    tcBorders = OxmlElement('w:tcBorders')
    for edge in ('top','left','bottom','right','insideH','insideV'):
        if edge in kwargs:
            tag = OxmlElement(f'w:{edge}')
            tag.set(qn('w:val'), kwargs[edge].get('val','single'))
            tag.set(qn('w:sz'),  str(kwargs[edge].get('sz', 4)))
            tag.set(qn('w:space'), '0')
            tag.set(qn('w:color'), kwargs[edge].get('color','000000'))
            tcBorders.append(tag)
    tcPr.append(tcBorders)

def para_spacing(para, before=0, after=0, line=None):
    pPr = para._p.get_or_add_pPr()
    pSpacing = OxmlElement('w:spacing')
    pSpacing.set(qn('w:before'), str(before))
    pSpacing.set(qn('w:after'),  str(after))
    if line:
        pSpacing.set(qn('w:line'), str(line))
        pSpacing.set(qn('w:lineRule'), 'auto')
    pPr.append(pSpacing)

# ── Helper: add a run with formatting ───────────────────────────────────────
def add_run(para, text, bold=False, italic=False, color=None, size=None, underline=False):
    run = para.add_run(text)
    run.bold = bold
    run.italic = italic
    run.underline = underline
    if color:
        run.font.color.rgb = color
    if size:
        run.font.size = Pt(size)
    return run

# ── Styles setup ─────────────────────────────────────────────────────────────
normal_style = doc.styles['Normal']
normal_style.font.name = 'Calibri'
normal_style.font.size = Pt(11)

# ════════════════════════════════════════════════════════════════════════════
#  COVER / TITLE BLOCK
# ════════════════════════════════════════════════════════════════════════════
cover = doc.add_paragraph()
cover.alignment = WD_ALIGN_PARAGRAPH.CENTER
shade_paragraph(cover, '1A3A5C')
para_spacing(cover, before=120, after=60)
add_run(cover, 'DIABETIC FOOT', bold=True, color=C_WHITE, size=22)

sub = doc.add_paragraph()
sub.alignment = WD_ALIGN_PARAGRAPH.CENTER
shade_paragraph(sub, '1A3A5C')
para_spacing(sub, before=0, after=80)
add_run(sub, 'MS Surgery | Long Question-Answer Theory Notes', bold=False, color=RGBColor(0xB0,0xD4,0xF0), size=12)

tag = doc.add_paragraph()
tag.alignment = WD_ALIGN_PARAGRAPH.CENTER
shade_paragraph(tag, '1A3A5C')
para_spacing(tag, before=0, after=120)
add_run(tag, 'IWGDF 2023  ·  IDSA 2023  ·  Wagner Classification  ·  Complete Theory Notes', italic=True, color=RGBColor(0x90,0xB8,0xD8), size=9)

doc.add_paragraph()  # spacer

# ════════════════════════════════════════════════════════════════════════════
# Helper: Question header banner
# ════════════════════════════════════════════════════════════════════════════
q_counter = [0]

def question_banner(text):
    q_counter[0] += 1
    p = doc.add_paragraph()
    shade_paragraph(p, '2A6099')
    para_spacing(p, before=200, after=40)
    add_run(p, f'  Q{q_counter[0]}.  {text}', bold=True, color=C_WHITE, size=12)

def answer_label():
    p = doc.add_paragraph()
    shade_paragraph(p, 'D6E8F7')
    para_spacing(p, before=0, after=40)
    add_run(p, '  ANSWER', bold=True, color=C_DARK_BLUE, size=10)

def section_sub(text, color_hex='1A8A8A'):
    p = doc.add_paragraph()
    shade_paragraph(p, color_hex)
    para_spacing(p, before=100, after=40)
    add_run(p, f'  {text}', bold=True, color=C_WHITE, size=10)
    return p

def bullet(text, level=1, bold_prefix=None):
    p = doc.add_paragraph(style='List Bullet')
    p.paragraph_format.left_indent = Cm(0.5 * level)
    p.paragraph_format.space_after = Pt(2)
    if bold_prefix:
        add_run(p, bold_prefix, bold=True, color=C_DARK_BLUE, size=10.5)
        add_run(p, text, size=10.5)
    else:
        add_run(p, text, size=10.5)
    return p

def body(text, bold=False, color=None):
    p = doc.add_paragraph()
    para_spacing(p, before=20, after=20)
    add_run(p, text, bold=bold, color=color, size=10.5)
    return p

def note_box(text):
    p = doc.add_paragraph()
    shade_paragraph(p, 'FFF9E6')
    para_spacing(p, before=60, after=60)
    add_run(p, '  ★  ' + text, bold=True, color=C_GOLD, size=10)

def add_table(headers, rows, col_widths, hdr_color='1A3A5C'):
    tbl = doc.add_table(rows=1+len(rows), cols=len(headers))
    tbl.style = 'Table Grid'
    # Header row
    hdr_row = tbl.rows[0]
    for i, h in enumerate(headers):
        cell = hdr_row.cells[i]
        shade_cell(cell, hdr_color)
        p = cell.paragraphs[0]
        p.alignment = WD_ALIGN_PARAGRAPH.CENTER
        add_run(p, h, bold=True, color=C_WHITE, size=9.5)
        cell.width = Cm(col_widths[i])
    # Data rows
    for ri, row in enumerate(rows):
        tr = tbl.rows[ri+1]
        bg = 'F5F9FF' if ri % 2 == 0 else 'FFFFFF'
        for ci, val in enumerate(row):
            cell = tr.cells[ci]
            shade_cell(cell, bg)
            p = cell.paragraphs[0]
            if isinstance(val, tuple):
                add_run(p, val[0], bold=True, color=C_DARK_BLUE, size=9.5)
                add_run(p, val[1], size=9.5)
            else:
                add_run(p, val, size=9.5)
    doc.add_paragraph()

# ════════════════════════════════════════════════════════════════════════════
# Q1 ── Classic 10-marker: A 60-year-old diabetic with plantar ulcer
# ════════════════════════════════════════════════════════════════════════════
question_banner('A 60-year-old diabetic male presents with a painless non-healing ulcer on the plantar aspect of right foot for 3 months. Describe the pathophysiology, clinical evaluation, and management.')
answer_label()

section_sub('INTRODUCTION', '1A3A5C')
body('Diabetic foot refers to the spectrum of foot pathology in diabetes mellitus resulting from the triad of peripheral neuropathy, peripheral arterial disease (PAD), and susceptibility to infection. It is the most common cause of non-traumatic lower limb amputation worldwide, with 15-25% of diabetics developing a foot ulcer in their lifetime.')

section_sub('PATHOPHYSIOLOGY — THE TRIAD', '1A3A5C')

bullet('PERIPHERAL NEUROPATHY (most important factor; present in ~50% of diabetics):', bold_prefix='1. ')
bullet('Sensory neuropathy: loss of pain, temperature, pressure → "silent" repeated injury', level=2)
bullet('Motor neuropathy: intrinsic muscle wasting → claw/hammer toes, prominent MT heads → abnormal plantar pressure points', level=2)
bullet('Autonomic neuropathy: anhidrosis → dry, cracked skin (portal of entry); AV shunting → warm bounding pulses but poor nutritive flow', level=2)

bullet('PERIPHERAL ARTERIAL DISEASE (PAD):', bold_prefix='2. ')
bullet('Preferentially affects tibial and peroneal arteries (infrapopliteal / below-knee disease)', level=2)
bullet('Medial calcinosis (Monckeberg\'s) → non-compressible vessels → falsely elevated ABI (>1.3)', level=2)
bullet('Ischemia renders ulcers non-healing and predisposes to gangrene', level=2)

bullet('INFECTION:', bold_prefix='3. ')
bullet('Impaired PMN chemotaxis, phagocytosis, intracellular killing → diminished host defense', level=2)
bullet('Most common organism: Staphylococcus aureus (mild); typically polymicrobial in severe/deep infections', level=2)
bullet('Spreads along fascial planes → deep space infection, necrotizing fasciitis, osteomyelitis', level=2)

note_box('Exam Pearl: The term "neuropathic ulcer" applies when neuropathy predominates; "neuroischemic" (commonest, ~50%) when both are present.')

section_sub('CLINICAL EVALUATION', '2A6099')
body('History:', bold=True)
bullet('Duration of diabetes and glycemic control (HbA1c values)', level=1)
bullet('Symptoms: burning/tingling/numbness (neuropathy); claudication/rest pain (ischemia)', level=1)
bullet('Mechanism of ulcer: pressure, trauma, ill-fitting footwear', level=1)
bullet('Previous ulcers, hospitalizations, amputations', level=1)
bullet('Medications, smoking history, renal/cardiac status', level=1)

body('Local Examination of Ulcer (SITE, SIZE, SHAPE, DEPTH, BASE, EDGE, DISCHARGE):', bold=True)
bullet('Site: plantar surface (neuropathic) vs toe margins/heel (ischemic)', level=1)
bullet('Edges: punched-out with callus (neuropathic) vs irregular, sloping (ischemic) vs undermined (infected)', level=1)
bullet('Base: granulation tissue / slough / necrosis / visible tendon or bone', level=1)
bullet('Probe-to-bone (PTB) test: metal probe reaches bone → ~89% specific for osteomyelitis', level=1)
bullet('Surrounding skin: callus, cellulitis, lymphangitis, crepitus (gas)', level=1)
bullet('Discharge: serous / purulent / foul-smelling (anaerobic)', level=1)

body('Vascular Examination:', bold=True)
bullet('Foot pulses: dorsalis pedis + posterior tibial (absent in ischemic)', level=1)
bullet('Capillary refill time (>3 sec = abnormal)', level=1)
bullet('Temperature gradient, Buerger\'s test', level=1)
bullet('ABI measurement (unreliable if >1.3 due to medial calcinosis → use Toe-Brachial Index)', level=1)

body('Neurological Examination:', bold=True)
bullet('10g Semmes-Weinstein monofilament: 5 standard plantar sites — tests protective sensation', level=1)
bullet('128 Hz tuning fork — vibration sense', level=1)
bullet('Ankle reflexes, proprioception', level=1)
bullet('Look for deformity: claw toes, Charcot foot (rocker-bottom)', level=1)

add_table(
    ['Feature', 'Neuropathic Foot', 'Ischemic Foot', 'Neuroischemic'],
    [
        ['Temperature', 'Warm', 'Cold', 'Cool'],
        ['Pulses', 'Present, bounding', 'Absent', 'Reduced'],
        ['Sensation', 'Absent', 'Relatively preserved', 'Reduced'],
        ['Ulcer site', 'Plantar (pressure)', 'Tip of toes, heel', 'Variable'],
        ['Pain', 'Painless', 'Painful (rest pain)', 'Variable'],
        ['Deformity', 'Common (Charcot)', 'Less common', 'Variable'],
        ['Prevalence', '35%', '15%', '50%'],
    ],
    [4.5, 4, 4, 4.5],
    hdr_color='1A3A5C'
)

section_sub('WAGNER CLASSIFICATION (Most Important for Exam)', 'C0392B')
add_table(
    ['Grade', 'Description', 'Management Summary'],
    [
        [('Grade 0', ''), 'Intact skin; callus, deformity; pre-ulcerative', 'Therapeutic footwear, podiatry, education'],
        [('Grade 1', ''), 'Superficial ulcer — skin/subcutaneous only', 'Sharp debridement, TCC offloading, dressings'],
        [('Grade 2', ''), 'Deep ulcer penetrating to tendon/capsule/bone', 'Deep debridement, wound care, MRI, antibiotics'],
        [('Grade 3', ''), 'Deep ulcer + abscess / osteomyelitis / septic arthritis', 'IV antibiotics, I&D, bone resection, ray amputation'],
        [('Grade 4', ''), 'Localized gangrene — toes or forefoot', 'Revascularize if feasible, limited amputation'],
        [('Grade 5', ''), 'Extensive gangrene of entire foot', 'Below-knee or above-knee amputation'],
    ],
    [2.5, 6.5, 7],
    hdr_color='C0392B'
)

section_sub('INVESTIGATIONS', '6A3D9A')
body('Baseline Labs:', bold=True)
bullet('Blood glucose (fasting + post-prandial), HbA1c — target <7%', level=1)
bullet('Complete blood count (leukocytosis may be absent even in severe infection in diabetics)', level=1)
bullet('Renal function tests, electrolytes (diabetic nephropathy)', level=1)
bullet('ESR, CRP, Procalcitonin — infection and monitoring markers', level=1)
bullet('Serum albumin — nutritional status (hypoalbuminemia impairs healing)', level=1)

body('Microbiological:', bold=True)
bullet('Deep tissue swab / tissue biopsy culture + sensitivity (before starting antibiotics)', level=1)
bullet('Bone biopsy: gold standard for osteomyelitis causative organism and antibiotic sensitivity', level=1)

body('Imaging:', bold=True)
add_table(
    ['Investigation', 'Indication', 'Key Interpretation'],
    [
        ['X-ray foot (AP + lateral)', 'First-line; gas, foreign body, cortical destruction', '2-3 week lag; 50% bone loss needed before visible'],
        ['MRI foot ★', 'Gold standard for osteomyelitis extent and Charcot staging', 'Shows marrow oedema early; best sensitivity+specificity'],
        ['Tc-99m bone scan', 'Sensitive for OM but non-specific', 'False positive in neuropathic/Charcot'],
        ['WBC-labeled scan', 'More specific for infection', 'Used when MRI contraindicated'],
        ['PET-CT', 'Best specificity for chronic OM', 'Increasingly used; expensive'],
    ],
    [4, 5.5, 6.5],
    hdr_color='6A3D9A'
)

body('Vascular Investigations:', bold=True)
add_table(
    ['Test', 'Normal', 'Abnormal / Critical'],
    [
        ['ABI (ABPI)', '>0.9', '<0.9 ischemia; <0.5 severe; >1.3 non-compressible (medial calcinosis)'],
        ['Toe-Brachial Index (TBI)', '>0.7', '<0.7 = ischemia; more reliable in diabetics'],
        ['TcPO₂', '>40 mmHg', '<30 mmHg = poor healing; <20 = critical ischemia'],
        ['Duplex USS', 'Normal flow', 'Maps stenosis/occlusion; non-invasive'],
        ['CT / MR Angiography', 'Patent vessels', 'Gold standard pre-revascularization map'],
    ],
    [4, 3.5, 8.5],
    hdr_color='6A3D9A'
)

section_sub('MANAGEMENT — MULTIDISCIPLINARY APPROACH', '1A7A3A')
note_box('MDT: Diabetologist, Vascular surgeon, Orthopedic/General surgeon, Podiatrist, Microbiologist, Dietitian, Orthotist, Nurse specialist')

body('A. General/Systemic Measures:', bold=True, color=C_DARK_BLUE)
bullet('Glycemic control: IV insulin infusion (inpatient); target HbA1c <7%', level=1)
bullet('Nutritional optimization: protein supplement; treat hypoalbuminemia', level=1)
bullet('Smoking cessation, statin therapy, antiplatelet agents (if PAD)', level=1)
bullet('DVT prophylaxis during prolonged immobilization', level=1)

body('B. Offloading (Critical for Neuropathic Plantar Ulcers):', bold=True, color=C_DARK_BLUE)
add_table(
    ['Method', 'Efficacy', 'Notes'],
    [
        ['Total Contact Cast (TCC) ★', 'Gold standard — reduces plantar pressure 84-92%', 'Cannot be removed by patient; ensures compliance'],
        ['Removable Cast Walker (RCW)', 'Good but patient can remove', 'Convert to iTCC by wrapping to improve compliance'],
        ['Therapeutic footwear', 'Prevention + grade 0-1', 'Custom-molded insoles, depth shoes'],
        ['Surgical offloading', 'Permanent', 'Achilles tendon lengthening, metatarsal head resection, exostectomy'],
    ],
    [4.5, 5, 6.5],
    hdr_color='1A7A3A'
)

body('C. Local Wound Care:', bold=True, color=C_DARK_BLUE)
bullet('Sharp/surgical debridement: most effective; removes callus, slough, necrotic tissue; converts chronic to acute wound', level=1)
bullet('Wound dressings: hydrogel (dry wounds); foam/alginate (exudative); silver/iodine (infected); non-adherent (granulating)', level=1)
bullet('Negative Pressure Wound Therapy (NPWT/VAC): 125 mmHg; promotes granulation, removes exudate; use post-debridement, pre-graft bed preparation', level=1)
bullet('Growth factors: PDGF (Becaplermin) — only FDA-approved growth factor for neuropathic DFU', level=1)
bullet('Hyperbaric Oxygen Therapy (HBOT): 100% O₂ at 2-3 ATA; 90-min sessions, 20-40 total; for Wagner 3-4 with non-revascularizable ischemia', level=1)
bullet('Larval therapy (maggots): secretes collagenase; excellent for infected necrotic wounds', level=1)

body('D. Antibiotic Therapy (IWGDF/IDSA 2023):', bold=True, color=C_DARK_BLUE)
add_table(
    ['Severity', 'Route', 'Regimen', 'Duration'],
    [
        ['Mild', 'Oral', 'Amoxicillin-clavulanate OR Cefalexin + Metronidazole', '1-2 weeks'],
        ['Moderate', 'Oral/IV', 'Amoxicillin-clavulanate IV / Pip-Tazo / Ceftriaxone + Metro', '2-4 weeks'],
        ['Severe', 'IV', 'Piperacillin-tazobactam ± Vancomycin (if MRSA suspected)', '2-4 weeks'],
        ['Osteomyelitis (no surgery)', 'IV → Oral', 'Culture-guided; fluoroquinolone-based if Gram-negative', '6 weeks total'],
        ['Osteomyelitis (bone resected)', 'IV → Oral', 'Culture-guided; margins clear', '2 weeks post-resection'],
    ],
    [3, 1.5, 6, 2.5],
    hdr_color='1A3A5C'
)

body('E. Vascular Intervention:', bold=True, color=C_DARK_BLUE)
bullet('Revascularize before any major reconstruction or amputation', level=1)
bullet('Percutaneous Transluminal Angioplasty (PTA) ± stenting: first choice for short-segment iliac/femoral disease', level=1)
bullet('Bypass surgery: for long-segment occlusion; distal bypass (popliteal, tibial, peroneal); preferred conduit = autologous great saphenous vein', level=1)
bullet('Angiosome concept: direct revascularization of the angiosome containing the ulcer gives best healing outcomes', level=1)
note_box('TcPO₂ >40 mmHg = adequate for wound healing / amputation stump healing')

body('F. Surgical Management:', bold=True, color=C_DARK_BLUE)
bullet('Incision & Drainage (I&D): for abscess; open approach, no tourniquet; allow dependent drainage', level=1)
bullet('Debridement + bone resection: for osteomyelitis with infected bone', level=1)
bullet('Ray amputation: removal of toe + metatarsal shaft; for single-ray disease', level=1)
bullet('Transmetatarsal amputation (TMA): forefoot gangrene with viable heel/dorsum', level=1)
bullet('Below-knee amputation (BKA): most functional major amputation; needs patent popliteal artery; minimum 5 cm stump; TcPO₂ >40 mmHg at level', level=1)
bullet('Above-knee amputation (AKA): last resort; 3x higher energy to walk; poor rehab in elderly', level=1)
bullet('Guillotine amputation: emergency open amputation for uncontrolled sepsis / gas gangrene; closed formally after 48-72h when sepsis controlled', level=1)

body('G. Wound Closure (Reconstructive Ladder):', bold=True, color=C_DARK_BLUE)
bullet('Primary closure: clean wounds, good vascularity, no tension', level=1)
bullet('Secondary intention: infected/small wounds', level=1)
bullet('NPWT (VAC): bridge to surgery; prepare graft bed', level=1)
bullet('Split skin graft (SSG): on granulating wound bed with adequate vascularity', level=1)
bullet('Local flap (plantar rotation, V-Y advancement): weight-bearing areas', level=1)
bullet('Free flap (microsurgical): large complex defects with adequate recipient vessels', level=1)

doc.add_paragraph()

# ════════════════════════════════════════════════════════════════════════════
# Q2 ── Wagner Classification
# ════════════════════════════════════════════════════════════════════════════
question_banner('Write short notes on the Wagner Classification of Diabetic Foot. How does it guide management?')
answer_label()
section_sub('INTRODUCTION', '1A3A5C')
body('The Wagner Classification (1979) is the most widely used and exam-asked system for grading diabetic foot ulcers. It grades severity from 0 (intact skin at risk) to 5 (whole-foot gangrene) based on depth of ulceration and presence of infection/gangrene.')

section_sub('WAGNER GRADES WITH MANAGEMENT', 'C0392B')
add_table(
    ['Grade', 'Description', 'Pathology', 'Surgical/Medical Management'],
    [
        [('Grade 0', ''), 'Pre-ulcerative / intact skin', 'Callus, deformity, bony prominence', 'Therapeutic footwear; callus shaving; patient education; regular podiatry'],
        [('Grade 1', ''), 'Superficial ulcer', 'Epidermis + dermis only; no deeper penetration', 'Sharp debridement; TCC (gold standard offloading); moist wound dressings'],
        [('Grade 2', ''), 'Deep ulcer (tendon/capsule/bone)', 'Full thickness; exposes tendon, capsule, or cortex; no OM', 'Deep surgical debridement; wound care; MRI to exclude OM; culture-guided oral antibiotics'],
        [('Grade 3', ''), 'Deep ulcer + abscess/osteomyelitis', 'OM or septic arthritis or deep space abscess', 'IV antibiotics; I&D of abscess; bone resection / ray amputation; HBOT adjunct; 4-6 week abx course'],
        [('Grade 4', ''), 'Localised gangrene', 'Toe/forefoot gangrene; proximal tissue viable', 'Revascularize first if possible; toe/ray/TMA amputation; IV antibiotics; guillotine if life-threatening sepsis'],
        [('Grade 5', ''), 'Extensive / whole-foot gangrene', 'Entire foot unsalvageable; systemic sepsis', 'Below-knee (preferred) or above-knee amputation after haemodynamic stabilization'],
    ],
    [2, 3.5, 4.5, 6],
    hdr_color='C0392B'
)
note_box('Key: Grades 0-2 = conservative/local surgery. Grade 3-4 = aggressive surgical debridement ± limited amputation. Grade 5 = major amputation.')
body('Limitations of Wagner Classification:', bold=True)
bullet('Does not separately score ischemia or infection (addressed by the University of Texas / IWGDF classification)', level=1)
bullet('University of Texas (UT) Classification adds a Stage axis (A=none, B=infection, C=ischemia, D=both) to Wagner\'s Grade (0-3) — better prognostic accuracy', level=1)
doc.add_paragraph()

# ════════════════════════════════════════════════════════════════════════════
# Q3 ── Charcot Foot
# ════════════════════════════════════════════════════════════════════════════
question_banner('Describe Charcot neuroarthropathy (Charcot foot). How will you diagnose and manage it?')
answer_label()
section_sub('DEFINITION', '1A3A5C')
body('Charcot neuroarthropathy (CN) is a progressive, painless, destructive arthropathy affecting bones and joints of the foot in patients with peripheral neuropathy (most commonly diabetic), caused by repeated micro-trauma in the absence of protective pain sensation, leading to progressive bone and joint destruction.')

section_sub('PATHOPHYSIOLOGY', '1A3A5C')
bullet('Neurotraumatic theory: loss of protective sensation → repeated micro-fractures and ligament damage from normal activity', level=1)
bullet('Neurovascular theory: autonomic dysfunction → sympathetic denervation → arteriovenous shunting → hyperemia → osteoclast activation (via RANKL) → accelerated bone resorption', level=1)
bullet('Most commonly affects the midfoot (Lisfranc / Chopart joints) → "rocker-bottom" deformity', level=1)
bullet('Leads to bony prominences → plantar ulceration', level=1)

section_sub('EICHENHOLTZ CLASSIFICATION', '2A6099')
add_table(
    ['Stage', 'Name', 'Clinical Features', 'Imaging', 'Management'],
    [
        ['Stage 0', 'Prodromal / At-risk', 'Warm, red, swollen foot; unilateral; pain absent or mild', 'X-ray normal; MRI: bone marrow oedema', 'Non-weight bearing; TCC immediately; bisphosphonates'],
        ['Stage I', 'Fragmentation / Development', 'Acute inflammation persists; increasing deformity', 'Bony fragmentation, subluxation, dislocation, periarticular debris', 'Immobilization in TCC; strict non-weight-bearing'],
        ['Stage II', 'Coalescence', 'Decreased warmth and swelling', 'Absorption of debris; sclerosis begins; new bone formation', 'Transition to total contact walker; custom footwear'],
        ['Stage III', 'Reconstruction / Consolidation', 'Stable foot; cool; residual deformity', 'Remodeling, fibrosis, bony fusion, fixed deformity', 'Custom footwear; exostectomy or arthrodesis if ulceration/instability'],
    ],
    [2, 3.5, 5, 3.5, 5.5],
    hdr_color='2A6099'
)

section_sub('DIAGNOSIS', '6A3D9A')
body('Acute Charcot is commonly misdiagnosed as cellulitis. Key distinguishing features:')
bullet('No systemic signs (afebrile, normal WBC) unlike cellulitis', level=1)
bullet('Bilateral foot temperature difference >2°C (infrared thermometry) suggests active Charcot vs contralateral foot', level=1)
bullet('Bounding pulses (intact circulation due to AV shunting)', level=1)
bullet('MRI: definitive early diagnosis — shows bone marrow oedema, micro-fractures, ligamentous disruption', level=1)
bullet('X-ray: often normal in Stage 0 (early); useful from Stage I', level=1)
note_box('Remember: "Hot, red, swollen foot in a diabetic with normal X-ray and absent pain = Charcot foot until proven otherwise"')

section_sub('MANAGEMENT', '1A7A3A')
body('Non-surgical (Stages 0-II):')
bullet('Immediate offloading: non-weight bearing TCC — must start in Stage 0 to prevent progression to Stage I', level=1)
bullet('Bisphosphonates (IV pamidronate 90mg single dose): inhibit osteoclast activity; reduce inflammation; evidence strongest in acute phase', level=1)
bullet('Continue TCC until skin temperature normalizes (<2°C difference bilaterally); typically 4-12 months', level=1)
bullet('Transition to total contact walker → custom therapeutic footwear', level=1)
body('Surgical (Stage III / Complications):')
bullet('Indications: unstable deformity risking ulceration, recurrent plantar ulcers, non-reconstructable deformity', level=1)
bullet('Exostectomy: removal of bony prominence causing ulceration', level=1)
bullet('Arthrodesis (fusion): for unstable midfoot or ankle; using intramedullary nails, plate fixation, or Ilizarov external fixator ("bolt of lightning" technique)', level=1)
doc.add_paragraph()

# ════════════════════════════════════════════════════════════════════════════
# Q4 ── Diabetic Foot Osteomyelitis
# ════════════════════════════════════════════════════════════════════════════
question_banner('Discuss the diagnosis and management of osteomyelitis in diabetic foot.')
answer_label()
section_sub('INCIDENCE AND IMPORTANCE', '1A3A5C')
body('Osteomyelitis (OM) complicates 20% of moderate and 50-60% of severe diabetic foot infections. It is the most common reason for major amputation and prolonged hospitalization. Wagner Grade 3 = deep ulcer + osteomyelitis/abscess.')

section_sub('CLINICAL FEATURES SUGGESTING OSTEOMYELITIS', 'C0392B')
bullet('"Sausage digit" — diffusely swollen toe', level=1)
bullet('Exposed bone at the ulcer base', level=1)
bullet('Ulcer diameter >2 cm or depth >3 mm', level=1)
bullet('Non-healing ulcer after 6 weeks of optimal care', level=1)
bullet('Overlying ulcer directly above a bony prominence', level=1)
bullet('Probe-to-bone (PTB) test positive: sensitivity 60-66%, specificity 85-89%', level=1)
note_box('PTB Test: Use a sterile metal probe through ulcer — if hard resistance (bone) felt = osteomyelitis until proven otherwise. Positive = high PPV in high-prevalence settings.')

section_sub('INVESTIGATIONS', '6A3D9A')
add_table(
    ['Investigation', 'Sensitivity', 'Specificity', 'Role / Notes'],
    [
        ['Plain X-ray', '54%', '68%', 'First line; late finding (2-3 weeks); periosteal reaction, cortical destruction, sequestrum'],
        ['MRI ★ Gold standard (imaging)', '90%', '83%', 'Shows bone marrow oedema early; delineates extent; guides surgical resection'],
        ['Tc-99m bone scan', '86%', '45%', 'Sensitive but non-specific; false positive with Charcot, fracture'],
        ['WBC-labeled scan', '74%', '68%', 'More specific; combined with Tc-bone scan improves specificity'],
        ['PET-CT', '81%', '83%', 'Best specificity; increasing use in chronic/recurrent OM'],
        ['ESR >70 mm/hr + CRP + CXR', 'Moderate', 'Good combination', 'Combined with clinical: high suspicion index'],
        ['Bone biopsy + culture ★ Gold standard (organism)', '—', '—', 'Definitive: identifies causative organism; guides targeted antibiotics; percutaneous or open'],
    ],
    [4.5, 2.5, 2.5, 6.5],
    hdr_color='6A3D9A'
)

section_sub('MANAGEMENT', '1A7A3A')
body('Two approaches — Medical vs Surgical:')
add_table(
    ['Approach', 'Indication', 'Regimen', 'Duration', 'Outcome'],
    [
        ['Medical (antibiotics alone)', 'Non-surgical candidates; forefoot OM with intact vascularity; patient preference', 'IV antibiotics → oral step-down based on bone biopsy culture; fluoroquinolones (good bone penetration) for Gram-negatives', '6 weeks total', 'Remission in ~65%; relapse common'],
        ['Surgical (bone resection) ★', 'Preferred where feasible', 'Resect infected bone with clean margins (ray/partial foot amputation) + 2 weeks antibiotics post-resection', '2 weeks post-op', 'Better cure rates; shorter antibiotic course'],
    ],
    [3, 4, 5.5, 2, 2.5],
    hdr_color='1A7A3A'
)
note_box('Key exam point: Surgical resection of osteomyelitic bone = only 2 weeks antibiotics post-op (vs 6 weeks if no surgery).')
doc.add_paragraph()

# ════════════════════════════════════════════════════════════════════════════
# Q5 ── Amputation levels
# ════════════════════════════════════════════════════════════════════════════
question_banner('Discuss the levels of amputation used in diabetic foot disease. What are the general principles of amputation in diabetics?')
answer_label()
section_sub('GENERAL PRINCIPLES OF AMPUTATION IN DIABETICS', '1A3A5C')
bullet('Preserve maximum viable tissue compatible with primary healing', level=1)
bullet('TcPO₂ >40 mmHg at the proposed level ensures adequate healing; <30 mmHg = poor prognosis', level=1)
bullet('Revascularize BEFORE amputation if indicated — improves stump healing and allows more distal amputation', level=1)
bullet('Avoid tourniquet (relative contraindication — impairs intraoperative perfusion assessment)', level=1)
bullet('No-tension skin closure; fashioned flaps must cover stump without tension', level=1)
bullet('Perioperative antibiotics (continue based on culture sensitivity)', level=1)
bullet('Guillotine amputation first for life-threatening sepsis → formal closure after 48-72h when infection controlled', level=1)

section_sub('LEVELS OF AMPUTATION (Distal to Proximal)', '2A6099')
add_table(
    ['Level', 'Indication', 'Key Requirements', 'Functional Outcome'],
    [
        ['Toe disarticulation', 'Isolated gangrenous/OM digit', 'Viable skin margins; no spreading infection', 'Most conservative; minimal functional loss'],
        ['Ray amputation', 'Single ray (toe + MT) disease — OM or gangrene', 'Adjacent rays viable; no proximal spread', 'Good function; minor gait alteration'],
        ['Transmetatarsal amputation (TMA)', 'Forefoot gangrene; multiple ray disease', 'Viable heel and dorsal skin; TcPO₂ >40 mmHg; patent posterior tibial artery', 'Excellent function with custom shoe and filler'],
        ["Syme's amputation", 'Distal foot disease; select neuropathic patients', 'Viable heel fat pad; adequate vascularity', 'End-bearing stump; simple prosthesis'],
        ['Below-knee (BKA) / Transtibial ★', 'Extensive foot / ankle disease; TMA not feasible', 'Patent popliteal artery; minimum 5 cm stump; TcPO₂ >40 mmHg at level', 'MOST FUNCTIONAL major amputation; 25% extra metabolic energy to walk; prosthesis easily fitted'],
        ['Knee disarticulation', 'BKA not feasible; diseased proximal tibia', 'Viable flaps over femoral condyles', 'Long lever arm; better prosthesis control than AKA'],
        ['Above-knee (AKA) / Transfemoral', 'BKA cannot heal; knee joint disease', 'Last resort; higher post-op mortality', '60-80% extra metabolic energy; poor rehab in elderly/obese; high 5-year mortality'],
        ['Guillotine (emergency)', 'Uncontrolled gas gangrene / spreading sepsis', 'Life-saving measure; open wound intentionally', 'Followed by formal amputation closure after 48-72h; patient must be haemodynamically stable'],
    ],
    [4, 4, 5, 4],
    hdr_color='2A6099'
)
note_box('Below-knee amputation is the most functional major amputation. Always attempt to preserve the knee joint.')

section_sub('REHABILITATION POST-AMPUTATION', '1A7A3A')
bullet('BKA: prosthesis fitting at 6-8 weeks; most patients achieve community ambulation', level=1)
bullet('AKA: 60-80% extra energy expenditure; prosthesis training; many elderly patients become wheelchair-dependent', level=1)
bullet('Stump care: compression bandaging; physiotherapy; contralateral foot protection (high risk for second amputation)', level=1)
bullet('Psychological support and diabetic team follow-up essential', level=1)
doc.add_paragraph()

# ════════════════════════════════════════════════════════════════════════════
# Q6 ── IDSA Infection Classification
# ════════════════════════════════════════════════════════════════════════════
question_banner('Classify diabetic foot infection according to IDSA/IWGDF 2023 criteria and outline antibiotic management for each class.')
answer_label()
section_sub('IDSA / IWGDF 2023 INFECTION CLASSIFICATION', 'C0392B')
add_table(
    ['Class', 'Severity', 'Clinical Definition', 'Key Features'],
    [
        ['Class 1', 'Uninfected', 'No systemic or local signs of infection', 'Wound colonized; do NOT start antibiotics; wound care only'],
        ['Class 2', 'Mild', '≥2 signs of inflammation (warmth, erythema, pain, tenderness, induration, purulent discharge); cellulitis <2 cm around ulcer; superficial; no systemic involvement', 'Oral antibiotics for 1-2 weeks; outpatient management usually adequate'],
        ['Class 3', 'Moderate', 'Cellulitis >2 cm from ulcer edge; OR lymphangitis; OR deep tissue involvement (fascia, tendon, muscle, joint, bone); OR abscess; NO systemic signs', 'IV antibiotics; hospitalization; surgical drainage; bone biopsy if OM suspected; 2-4 weeks'],
        ['Class 4', 'Severe', 'Any infection WITH systemic inflammatory response syndrome (SIRS): ≥2 of — temp >38°C or <36°C; HR >90; RR >20 or PaCO₂ <32; WBC >12,000 or <4,000', 'IV broad-spectrum antibiotics; ICU if unstable; urgent surgical debridement/amputation; 2-4 weeks'],
    ],
    [2, 2.5, 6.5, 5],
    hdr_color='C0392B'
)
note_box('Infection ≠ colonization. Clinical signs of infection (≥2 criteria) are required — do NOT diagnose infection by swab culture alone (IWGDF 2023).')
body('Antibiotic Regimens (IWGDF/IDSA 2023):')
add_table(
    ['Severity', 'Route', 'First-line Regimen', 'MRSA suspected → Add'],
    [
        ['Mild (Class 2)', 'Oral', 'Amoxicillin-clavulanate 625mg TDS\nOR Cefalexin 500mg QDS + Metronidazole', 'Doxycycline or Co-trimoxazole'],
        ['Moderate (Class 3)', 'IV or oral', 'Amoxicillin-clavulanate IV 1.2g TDS\nOR Piperacillin-tazobactam 4.5g TDS\nOR Ceftriaxone 1-2g OD + Metronidazole 500mg TDS', 'Vancomycin 15-20 mg/kg BD\nOR Daptomycin'],
        ['Severe (Class 4)', 'IV', 'Piperacillin-tazobactam 4.5g TDS\nOR Imipenem-cilastatin (if ESBL suspected)', 'Vancomycin + cover for GNB\nLinezolid (oral bioavailability = IV)'],
        ['Osteomyelitis (no surgery)', 'IV → PO', 'Culture-guided; fluoroquinolones (ciprofloxacin/levofloxacin) for Gram-negatives; rifampicin combination for staph (bone penetration)', '6 weeks total'],
        ['Osteomyelitis (post-resection)', 'IV → PO', 'Culture-guided; shorter course acceptable', '2 weeks post-op only'],
    ],
    [2.5, 1.5, 7, 5],
    hdr_color='1A3A5C'
)
doc.add_paragraph()

# ════════════════════════════════════════════════════════════════════════════
# Q7 ── Vascular assessment & revascularization
# ════════════════════════════════════════════════════════════════════════════
question_banner('How do you assess the vascular status of a diabetic foot? Discuss the indications and options for revascularization.')
answer_label()
section_sub('WHY VASCULAR ASSESSMENT IS CRITICAL', '1A3A5C')
body('PAD affects 15-25% of diabetics with foot ulcers. Unlike typical atherosclerosis, diabetic PAD preferentially involves infrapopliteal (tibial/peroneal) arteries with medial calcinosis (Monckeberg\'s) — making ABI unreliable. Without revascularization, ischemic ulcers will not heal regardless of other treatment.')

section_sub('CLINICAL ASSESSMENT', '2A6099')
bullet('Palpation of foot pulses (dorsalis pedis, posterior tibial)', level=1)
bullet('Capillary refill time (>3 sec = abnormal)', level=1)
bullet('Buerger\'s angle: elevation pallor <25° = critical ischemia', level=1)
bullet('Temperature gradient: cool extremity with dependent rubor', level=1)

section_sub('NON-INVASIVE VASCULAR TESTS', '2A6099')
add_table(
    ['Test', 'Method', 'Interpretation', 'Limitation in Diabetics'],
    [
        ['ABI (ABPI)', 'Ankle systolic pressure / brachial systolic pressure', '>0.9 normal; 0.5-0.9 mild-mod ischemia; <0.5 severe; <0.3 critical; >1.3 non-compressible', 'Medial calcinosis → falsely elevated (>1.3) in 20-30% diabetics'],
        ['Toe-Brachial Index (TBI)', 'Toe systolic pressure / brachial pressure (digital photoplethysmography)', '>0.7 normal; <0.7 ischemia; <0.3 critical; absolute toe pressure <30 mmHg = critical', 'More reliable than ABI in diabetics; toes rarely calcified'],
        ['TcPO₂', 'Transcutaneous O₂ tension at dorsum of foot', '>40 mmHg: adequate healing; 30-40: borderline; <30: poor healing; <20: critical ischemia', 'Affected by oedema, inflammation; need calibration'],
        ['Duplex Ultrasound', 'B-mode + Doppler flow mapping', 'Identifies stenosis/occlusion level; velocity ratios', 'Operator-dependent; calcified vessels reduce quality'],
        ['CT Angiography ★', 'Contrast-enhanced CT with 3D reconstruction', 'Gold standard map; shows tibial/peroneal disease precisely', 'Contrast nephrotoxicity; radiation; calcification artifact'],
        ['MR Angiography', 'Gadolinium-enhanced MRI', 'No radiation; good soft tissue detail', 'Gadolinium risk in renal impairment (NSF); longer time'],
    ],
    [3.5, 4, 5.5, 4],
    hdr_color='2A6099'
)

section_sub('REVASCULARIZATION OPTIONS', '1A7A3A')
add_table(
    ['Procedure', 'Indication', 'Key Points'],
    [
        ['PTA (Percutaneous Transluminal Angioplasty) ± stenting', 'Short-segment stenosis (iliac, femoral, popliteal, tibial)', 'First-line endovascular; can do tibial balloon angioplasty; less invasive; can be repeated'],
        ['Bypass surgery (distal bypass)', 'Long-segment occlusion; tibial/peroneal target vessels; endovascular failure', 'Great saphenous vein (in-situ or reversed) is gold standard conduit; synthetic (PTFE) if vein unavailable; patency better with vein'],
        ['Endarterectomy', 'Common/superficial femoral artery stenosis', 'Open surgical; good for localized disease'],
        ['Angiosome-directed revascularization', 'All revascularization planning', 'Each artery supplies a 3D angiosome; direct revascularization of the angiosome containing the wound improves healing vs indirect'],
    ],
    [4.5, 5, 6.5],
    hdr_color='1A7A3A'
)
note_box('If no revascularization possible (non-reconstructable disease) → amputation at the lowest viable level. HBOT can be adjunct for borderline ischemic wounds.')
doc.add_paragraph()

# ════════════════════════════════════════════════════════════════════════════
# Q8 ── Prevention
# ════════════════════════════════════════════════════════════════════════════
question_banner('Discuss the prevention of diabetic foot ulcers and screening protocol.')
answer_label()
section_sub('PRIMARY PREVENTION', '1A7A3A')
bullet('Glycemic control: HbA1c <7% — slows neuropathy progression (UKPDS, DCCT evidence)', level=1)
bullet('Patient education: daily foot self-inspection; avoid barefoot walking; inspect shoes before wearing; proper nail care', level=1)
bullet('Appropriate footwear: well-fitting, soft leather, roomy toe box; avoid narrow/pointed/high-heeled shoes', level=1)
bullet('Annual comprehensive foot examination by healthcare professional', level=1)

section_sub('IWGDF RISK STRATIFICATION & SCREENING FREQUENCY', '2A6099')
add_table(
    ['IWGDF Category', 'Risk Factors Present', 'Review Frequency'],
    [
        ['Category 0', 'No neuropathy, no PAD, no foot deformity', 'Once a year'],
        ['Category 1', 'Peripheral neuropathy (±mild deformity)', 'Every 6 months'],
        ['Category 2', 'Peripheral neuropathy + PAD or foot deformity', 'Every 3 months'],
        ['Category 3', 'Previous foot ulcer OR previous amputation', 'Every 1-3 months'],
    ],
    [3.5, 8.5, 4],
    hdr_color='2A6099'
)

section_sub('SECONDARY PREVENTION (Post-ulcer Recurrence)', '1A7A3A')
bullet('Custom therapeutic footwear: reduces recurrence from 58% to 28% at 2 years', level=1)
bullet('Regular podiatry review: callus removal, nail care', level=1)
bullet('Patient adherence monitoring: pressure-sensing insoles detect dangerous hot-spots', level=1)
bullet('TCC for any new plantar ulcer immediately — do not delay offloading', level=1)
bullet('Screen and treat PAD aggressively in patients with history of ulceration', level=1)

section_sub('COMPREHENSIVE FOOT EXAMINATION COMPONENTS', '6A3D9A')
bullet('Dermatological: skin integrity, callus, maceration, nail changes, tinea pedis', level=1)
bullet('Musculoskeletal: deformity (claw toes, Charcot, hallux valgus), range of motion, limited joint mobility', level=1)
bullet('Neurological: 10g monofilament (5 sites), vibration (128 Hz), pin-prick, ankle reflexes', level=1)
bullet('Vascular: pedal pulses, capillary refill, ABI, TBI (if pulses absent)', level=1)
doc.add_paragraph()

# ════════════════════════════════════════════════════════════════════════════
# Q9 ── Short notes cluster
# ════════════════════════════════════════════════════════════════════════════
question_banner('Write short notes on: (a) Total Contact Cast  (b) Hyperbaric Oxygen Therapy  (c) Guillotine amputation  (d) Probe-to-bone test')
answer_label()

section_sub('(a) TOTAL CONTACT CAST (TCC)', '1A3A5C')
body('Gold standard offloading device for neuropathic plantar diabetic foot ulcers (IWGDF 2023).')
bullet('Mechanism: redistributes plantar pressure evenly across entire foot surface; reduces forefoot plantar pressure by 84-92%', level=1)
bullet('Construction: fiberglass or plaster cast applied over thin cotton/foam padding; molds to entire plantar surface; non-removable (ensures compliance)', level=1)
bullet('Changed every 1-2 weeks; wound inspected at each change', level=1)
bullet('Contraindications: active infection/abscess (must treat first), severe ischemia (ABI <0.5), poor skin integrity, unreliable patient', level=1)
bullet('Healing rates with TCC: 73-100% for neuropathic plantar ulcers vs 50% with standard care', level=1)
bullet('Drawback: non-removable; skin breakdown if not properly applied; requires trained staff', level=1)
note_box('Removable cast walkers are equally effective if made irremovable (iTCC) by wrapping with a cohesive bandage.')

section_sub('(b) HYPERBARIC OXYGEN THERAPY (HBOT)', '2A6099')
body('Administration of 100% oxygen at 2-3 atmospheres absolute (ATA) pressure in a hyperbaric chamber.')
bullet('Mechanism: raises tissue PaO₂ dramatically; stimulates angiogenesis (HIF-1α); enhances neutrophil bactericidal activity; reduces oedema; promotes collagen synthesis', level=1)
bullet('Protocol: 90-minute sessions; 20-40 sessions total (daily, 5 days/week)', level=1)
bullet('Indications in diabetic foot: Wagner Grade 3-4 with critical/non-revascularizable ischemia; non-healing ulcers with TcPO₂ <30 mmHg that rises to >200 mmHg under HBOT (predictive of response)', level=1)
bullet('Evidence: COCHRANE review — HBOT reduces major amputation risk (NNT ~4-5 for salvage) in severe ischemic DFU', level=1)
bullet('Contraindications: untreated pneumothorax, recent ear/sinus surgery, claustrophobia, active chemotherapy with bleomycin/adriamycin', level=1)
bullet('Side effects: barotrauma, oxygen toxicity (seizures rare), reversible visual changes', level=1)

section_sub('(c) GUILLOTINE AMPUTATION', '1A7A3A')
body('Emergency open amputation performed as a life-saving measure for uncontrolled spreading infection.')
bullet('Indications: advancing gas gangrene (Clostridium, mixed anaerobes); necrotizing fasciitis not controlled by debridement; septic shock from foot source; rapid proximal spread', level=1)
bullet('Technique: rapid transection of all tissues at required level (no flap fashioning); wound left OPEN intentionally; packed with antiseptic gauze', level=1)
bullet('Goal: rapidly remove infected source; save life; haemodynamic stabilization', level=1)
bullet('Followed by: ICU management; IV antibiotics; resuscitation; formal amputation with proper flap closure after 48-72 hours when patient stable and infection controlled', level=1)
bullet('Must ensure: level chosen above all visible gangrene/infection; correct level established later at formal closure', level=1)

section_sub('(d) PROBE-TO-BONE (PTB) TEST', 'C0392B')
body('Bedside clinical test for diagnosis of osteomyelitis in diabetic foot ulcer.')
bullet('Technique: sterile blunt metal probe (or sterile cotton swab holder) inserted gently through the ulcer base — if hard, gritty resistance consistent with bone is felt = positive', level=1)
bullet('Sensitivity: 60-66%; Specificity: 85-89%', level=1)
bullet('Positive Predictive Value (PPV): ~89% in high-prevalence setting (severe/deep ulcer)', level=1)
bullet('Negative Predictive Value (NPV): 56% in high-prevalence, ~98% in low-prevalence settings', level=1)
bullet('Interpretation: positive PTB + clinical suspicion → treat as osteomyelitis and proceed to MRI and bone biopsy', level=1)
bullet('Low-tech, rapid, free, no radiation — ideal bedside screening test', level=1)
note_box('Positive PTB + ESR >70 mm/hr = high predictive value for osteomyelitis even without imaging.')
doc.add_paragraph()

# ════════════════════════════════════════════════════════════════════════════
# Q10 ── Differential diagnosis
# ════════════════════════════════════════════════════════════════════════════
question_banner('What are the differential diagnoses of a diabetic foot ulcer? How will you differentiate them?')
answer_label()
section_sub('DIFFERENTIAL DIAGNOSIS', '1A3A5C')
add_table(
    ['Condition', 'Site', 'Distinguishing Feature', 'Diagnosis'],
    [
        ['Neuropathic DFU', 'Plantar surface, pressure points', 'Painless; callus; bounding pulses; absent sensation; warm foot', '10g monofilament; NCS/EMG'],
        ['Ischemic ulcer (arterial)', 'Tip of toes, heel, lateral margin', 'Painful; pale, necrotic base; absent pulses; cold foot; rest pain at night', 'ABI <0.5; CT angiography'],
        ['Venous ulcer', 'Medial gaiter area (above medial malleolus)', 'Irregular edges; lipodermatosclerosis; haemosiderin staining; normal pulses; associated varicosities', 'Duplex USS for venous insufficiency'],
        ["Marjolin's ulcer", 'Long-standing wound/scar', 'Everted, indurated, rolled edges; bleeds easily; in scar tissue; malodorous', 'Biopsy — SCC'],
        ['Tropical ulcer', 'Lower leg / foot (young, malnourished)', 'Rapid onset; foul-smelling; Fusospirochetal organisms; painful', 'Gram stain, culture; dark-field microscopy'],
        ['Pressure sore', 'Heel, lateral malleolus, bony prominence', 'Immobile patient; associated with prolonged pressure; graded I-IV', 'Clinical; assess depth with staging'],
        ['Rheumatoid vasculitic ulcer', 'Digital tips, lower leg', 'RA on background; punched-out; digital vasculitis; positive RF/anti-CCP', 'Serology; skin biopsy'],
        ['Pyoderma gangrenosum', 'Lower leg', 'Violaceous, undermined, overhanging edges; painful; associated with IBD/RA', 'Biopsy; pathergy test; exclude infection'],
    ],
    [4, 3.5, 6.5, 3],
    hdr_color='1A3A5C'
)
doc.add_paragraph()

# ════════════════════════════════════════════════════════════════════════════
# HIGH-YIELD EXAM REVISION TABLE
# ════════════════════════════════════════════════════════════════════════════
p = doc.add_paragraph()
shade_paragraph(p, '8B1A1A')
para_spacing(p, before=200, after=60)
add_run(p, '  ★  HIGH-YIELD EXAM REVISION — MUST-KNOW FACTS', bold=True, color=C_WHITE, size=12)

add_table(
    ['Key Point', 'Answer / Fact'],
    [
        ['Most common cause of non-traumatic lower limb amputation', 'Diabetes mellitus'],
        ['Most important single pathological factor in diabetic foot', 'Peripheral neuropathy (NOT ischemia alone)'],
        ['Most common type of diabetic foot (mixed)', 'Neuroischemic foot (~50%)'],
        ['Gold standard offloading for neuropathic plantar ulcer', 'Total Contact Cast (TCC)'],
        ['Wagner Grade with osteomyelitis / abscess', 'Grade 3'],
        ['Gold standard imaging for osteomyelitis', 'MRI (imaging) + Bone biopsy (organism identification)'],
        ['ABI >1.3 interpretation', 'Non-compressible vessels due to medial calcinosis → use Toe-Brachial Index (TBI)'],
        ['TcPO₂ thresholds', '<30 mmHg = poor healing; >40 mmHg = adequate for healing / amputation level'],
        ['PTB test: sensitivity / specificity', 'Sensitivity 60-66%; Specificity 85-89%'],
        ['Most functional major amputation', 'Below-knee (transtibial) amputation'],
        ['Preferred bypass conduit for distal bypass', 'Autologous great saphenous vein'],
        ['Emergency amputation for uncontrolled sepsis', 'Guillotine amputation → formal closure at 48-72h'],
        ['Most common organism (mild DFI)', 'Staphylococcus aureus'],
        ['Organisms in severe DFI', 'Polymicrobial (Gram-pos + Gram-neg + anaerobes)'],
        ['Only FDA-approved growth factor for DFU', 'PDGF — Becaplermin'],
        ['HBOT indication in diabetic foot', 'Wagner 3-4; non-revascularizable ischemia; TcPO₂ responds to HBOT challenge'],
        ['Charcot foot: classic presentation', 'Hot, red, swollen foot; normal X-ray; absent pain → Stage 0'],
        ['Bisphosphonate used in Charcot foot', 'IV Pamidronate 90 mg (single dose) — acute phase'],
        ['Osteomyelitis — antibiotic duration (no surgery)', '6 weeks total'],
        ['Osteomyelitis — antibiotic duration (bone resected)', '2 weeks post-resection only'],
        ['SINBAD scoring', 'Site, Ischemia, Neuropathy, Bacterial infection, Area, Depth (0-6)'],
        ['Current gold-standard guidelines', 'IWGDF 2023 / IDSA 2023 (Senneville et al.)'],
        ['IWGDF Category 3 review frequency', 'Every 1-3 months (previous ulcer or amputation)'],
        ['Angiosome concept', 'Direct revascularization of the wound-specific angiosome improves healing vs indirect'],
        ['5-year mortality after major amputation in diabetics', '~50% (worse prognosis than most cancers)'],
    ],
    [8, 9],
    hdr_color='8B1A1A'
)

# Footer
from docx.oxml.ns import qn as ns_qn
footer_para = doc.add_paragraph()
para_spacing(footer_para, before=200, after=0)
footer_para.alignment = WD_ALIGN_PARAGRAPH.CENTER
add_run(footer_para,
        'References: Wagner FW (1979) · IWGDF Guidelines 2023 · IWGDF/IDSA 2023 (Senneville et al.) · '
        'Wagner Classification · UT Classification (Lavery 1996) · WIfI Classification (Mills 2014)\n'
        'Compiled for MS Surgery Theory Examination  |  © 2026',
        italic=True, color=C_DARK_GREY, size=8)

out = '/tmp/workspace/diabetic-foot/Diabetic_Foot_LongQA_Notes.docx'
doc.save(out)
print(f"Saved: {out}")
Running Command

cd /tmp/workspace/diabetic-foot && python generate_notes.py 2>&1

Running Command

ls -lh /tmp/workspace/diabetic-foot/Diabetic_Foot_LongQA_Notes.docx

Your notes document is ready for download:

Diabetic Foot LongQA Notes

Word Document · DOCX


What's inside (57 KB, fully formatted Word document):
The document has a dark-blue title banner followed by 10 exam-ready long questions with complete model answers, each with colour-coded section headers, tables, and highlighted exam pearls:
Q#Question
Q1Classic 10-marker: 60-yr-old diabetic with plantar ulcer — pathophysiology, clinical evaluation, full management (covers Wagner, investigations, MDT, antibiotics, surgery, reconstruction)
Q2Wagner Classification — all 6 grades with management, limitations, comparison with UT classification
Q3Charcot Neuroarthropathy — pathophysiology, Eichenholtz staging, diagnosis (vs cellulitis), management (TCC + bisphosphonates + surgery)
Q4Osteomyelitis in diabetic foot — clinical signs, PTB test, imaging comparison table, medical vs surgical treatment
Q5Amputation levels — all 8 levels from toe disarticulation to guillotine, principles, functional outcomes
Q6IDSA/IWGDF 2023 Infection Classification — Class 1-4 with antibiotic regimens for each severity
Q7Vascular assessment + revascularization — ABI, TBI, TcPO₂ tables, PTA vs bypass, angiosome concept
Q8Prevention + IWGDF Risk Stratification + screening frequency table
Q9Short notes: TCC / HBOT / Guillotine amputation / Probe-to-bone test
Q10Differential diagnosis of foot ulcer (8 conditions, comparison table)
Final section: 25-point High-Yield Exam Revision table with key facts + answers — all in a red-accented box.
This is a shared conversation. Sign in to Orris to start your own chat.