~/spina-bifida-notes/generate_pdf.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_JUSTIFY
from reportlab.platypus import (
SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
HRFlowable, PageBreak, KeepTogether
)
from reportlab.platypus.flowables import BalancedColumns
from reportlab.lib.colors import HexColor
import urllib.request
import io
OUTPUT = "/home/daytona/workspace/spina-bifida-notes/Spina_Bifida_Notes.pdf"
# ── Colour palette ──────────────────────────────────────────────
C_DARK = HexColor("#1A237E") # deep navy
C_MID = HexColor("#283593") # mid navy
C_ACCENT = HexColor("#0288D1") # teal-blue
C_LIGHT = HexColor("#E3F2FD") # very light blue tint
C_GREEN = HexColor("#1B5E20") # dark green for pearls
C_GLIGHT = HexColor("#E8F5E9") # light green bg
C_WARN = HexColor("#B71C1C") # red for warnings
C_WLIGHT = HexColor("#FFEBEE") # light red bg
C_TABLE_H= HexColor("#1565C0") # table header
C_ALT = HexColor("#EFF3FB") # alternating row
C_GREY = HexColor("#546E7A") # muted grey text
C_HR = HexColor("#90CAF9") # divider line
# ── Document ─────────────────────────────────────────────────────
doc = SimpleDocTemplate(
OUTPUT,
pagesize=A4,
leftMargin=14*mm, rightMargin=14*mm,
topMargin=16*mm, bottomMargin=14*mm,
title="Spina Bifida – Paediatric & Neonatal Notes",
author="Orris Medical AI"
)
W = A4[0] - 28*mm # usable width
# ── Styles ───────────────────────────────────────────────────────
base = getSampleStyleSheet()
def S(name, **kw):
return ParagraphStyle(name, **kw)
sTitle = S("sTitle", fontSize=20, textColor=colors.white, leading=26,
alignment=TA_CENTER, fontName="Helvetica-Bold", spaceAfter=2)
sSubtitle = S("sSubtitle", fontSize=10, textColor=HexColor("#BBDEFB"),
alignment=TA_CENTER, fontName="Helvetica", leading=14)
sH1 = S("sH1", fontSize=12, textColor=colors.white, leading=16,
fontName="Helvetica-Bold", spaceBefore=6, spaceAfter=2)
sH2 = S("sH2", fontSize=10.5, textColor=C_MID, leading=14,
fontName="Helvetica-Bold", spaceBefore=5, spaceAfter=2)
sH3 = S("sH3", fontSize=9.5, textColor=C_DARK, leading=13,
fontName="Helvetica-Bold", spaceBefore=4, spaceAfter=1)
sBody = S("sBody", fontSize=8.5, textColor=HexColor("#212121"), leading=12,
fontName="Helvetica", spaceAfter=3, alignment=TA_JUSTIFY)
sBullet = S("sBullet", fontSize=8.5, textColor=HexColor("#212121"), leading=11.5,
fontName="Helvetica", leftIndent=10, spaceAfter=1.5,
bulletIndent=2, alignment=TA_LEFT)
sPearl = S("sPearl", fontSize=8.5, textColor=C_GREEN, leading=12,
fontName="Helvetica-BoldOblique", leftIndent=6, spaceAfter=2)
sWarn = S("sWarn", fontSize=8.5, textColor=C_WARN, leading=12,
fontName="Helvetica-Bold", leftIndent=6, spaceAfter=2)
sSmall = S("sSmall", fontSize=7.5, textColor=C_GREY, leading=11,
fontName="Helvetica", spaceAfter=1)
sFooter= S("sFooter", fontSize=7, textColor=C_GREY, leading=10,
fontName="Helvetica", alignment=TA_CENTER)
sTH = S("sTH", fontSize=8, textColor=colors.white, leading=10,
fontName="Helvetica-Bold", alignment=TA_CENTER)
sTD = S("sTD", fontSize=8, textColor=HexColor("#1A237E"), leading=10,
fontName="Helvetica", alignment=TA_LEFT)
sTD2= S("sTD2", fontSize=8, textColor=HexColor("#212121"), leading=10,
fontName="Helvetica", alignment=TA_LEFT)
sCode = S("sCode", fontSize=7.5, textColor=HexColor("#263238"), leading=11,
fontName="Courier", leftIndent=8, backColor=HexColor("#F5F5F5"),
spaceAfter=2)
# ── Helpers ───────────────────────────────────────────────────────
def hr(): return HRFlowable(width="100%", thickness=0.6, color=C_HR, spaceAfter=3, spaceBefore=2)
def section_header(text):
"""Full-width dark banner with white heading."""
t = Table([[Paragraph(text, sH1)]], colWidths=[W])
t.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), C_DARK),
("LEFTPADDING", (0,0), (-1,-1), 7),
("RIGHTPADDING", (0,0), (-1,-1), 7),
("TOPPADDING", (0,0), (-1,-1), 5),
("BOTTOMPADDING",(0,0), (-1,-1), 5),
("ROWBACKGROUNDS", (0,0), (-1,-1), [C_DARK]),
]))
return t
def sub_header(text):
t = Table([[Paragraph(text, sH2)]], colWidths=[W])
t.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), C_LIGHT),
("LEFTPADDING", (0,0), (-1,-1), 6),
("TOPPADDING", (0,0), (-1,-1), 3),
("BOTTOMPADDING",(0,0), (-1,-1), 3),
("LINEBELOW", (0,0), (-1,-1), 1.2, C_ACCENT),
]))
return t
def pearl_box(text):
t = Table([[Paragraph("★ " + text, sPearl)]], colWidths=[W])
t.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), C_GLIGHT),
("LEFTPADDING", (0,0), (-1,-1), 8),
("RIGHTPADDING", (0,0), (-1,-1), 8),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING",(0,0), (-1,-1), 4),
("ROUNDEDCORNERS", [4]),
("BOX", (0,0), (-1,-1), 0.8, C_GREEN),
]))
return t
def warn_box(text):
t = Table([[Paragraph("⚠ " + text, sWarn)]], colWidths=[W])
t.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), C_WLIGHT),
("LEFTPADDING", (0,0), (-1,-1), 8),
("RIGHTPADDING", (0,0), (-1,-1), 8),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING",(0,0), (-1,-1), 4),
("BOX", (0,0), (-1,-1), 0.8, C_WARN),
]))
return t
def make_table(headers, rows, col_widths=None):
hrow = [Paragraph(h, sTH) for h in headers]
data = [hrow]
for i, row in enumerate(rows):
style = sTD if i % 2 == 0 else sTD2
data.append([Paragraph(str(c), style) for c in row])
if col_widths is None:
col_widths = [W / len(headers)] * len(headers)
tbl = Table(data, colWidths=col_widths, repeatRows=1)
row_styles = [
("BACKGROUND", (0,0), (-1,0), C_TABLE_H),
("TEXTCOLOR", (0,0), (-1,0), colors.white),
("GRID", (0,0), (-1,-1), 0.4, HexColor("#B0BEC5")),
("LEFTPADDING", (0,0), (-1,-1), 5),
("RIGHTPADDING", (0,0), (-1,-1), 5),
("TOPPADDING", (0,0), (-1,-1), 3),
("BOTTOMPADDING",(0,0), (-1,-1), 3),
("VALIGN", (0,0), (-1,-1), "TOP"),
]
for i in range(1, len(data)):
if i % 2 == 0:
row_styles.append(("BACKGROUND", (0,i), (-1,i), C_ALT))
tbl.setStyle(TableStyle(row_styles))
return tbl
def B(text): return Paragraph("<bullet>•</bullet> " + text, sBullet)
def P(text): return Paragraph(text, sBody)
def SP(n=3): return Spacer(1, n*mm)
# ═══════════════════════════════════════════════════════════════
# BUILD CONTENT
# ═══════════════════════════════════════════════════════════════
story = []
# ─── COVER BANNER ─────────────────────────────────────────────
cover = Table([
[Paragraph("SPINA BIFIDA", sTitle)],
[Paragraph("In-Depth Clinical Notes for Paediatricians & Neonatologists", sSubtitle)],
[Paragraph("Compiled from: Goldman-Cecil Medicine • Creasy & Resnik MFM • Miller's Anesthesia • Bailey & Love • Bradley & Daroff's Neurology • Campbell-Walsh Urology | July 2026", sSmall)],
], colWidths=[W])
cover.setStyle(TableStyle([
("BACKGROUND", (0,0), (0,1), C_DARK),
("BACKGROUND", (0,2), (0,2), C_MID),
("LEFTPADDING", (0,0), (-1,-1), 10),
("RIGHTPADDING", (0,0), (-1,-1), 10),
("TOPPADDING", (0,0), (0,1), 8),
("BOTTOMPADDING",(0,1), (0,1), 8),
("TOPPADDING", (0,2), (0,2), 4),
("BOTTOMPADDING",(0,2), (0,2), 4),
]))
story += [cover, SP(4)]
# ═══ PART 1: EMBRYOLOGY ═══════════════════════════════════════
story += [section_header("PART 1 — EMBRYOLOGY"), SP(2)]
story += [sub_header("Normal Neural Tube Closure"), SP(1)]
story += [
P("During <b>weeks 3-4 of gestation</b>, the neural plate folds to form the neural tube via <b>primary neurulation</b>. This proceeds in a 'zipper' fashion from the cervical region bidirectionally. The anterior neuropore closes ~day 24; the <b>posterior neuropore closes ~day 26</b>. Spina bifida results from failure of posterior neuropore closure."),
SP(2),
sub_header("Two-Hit Hypothesis (Pathomechanism of MMC)"),
SP(1),
make_table(["Hit", "Description", "Timing"],
[
["Hit 1 (Primary)", "Failure of spinal canal closure — the anatomical malformation", "4th gestational week"],
["Hit 2 (Secondary)", "Progressive neural damage from exposure to amniotic fluid (neurotoxic + direct trauma)", "Ongoing throughout gestation"],
], [35*mm, 100*mm, 45*mm]),
SP(2),
pearl_box("The Two-Hit Hypothesis is the entire scientific rationale for fetal surgery — closing the defect in utero stops Hit 2 and preserves neurological function."),
SP(2),
P("<b>Sonic hedgehog (SHH) signalling</b> is critical for separation of the respiratory/GI tracts from the neural tube. Doxorubicin in animal models disrupts this pathway and produces NTDs experimentally."),
SP(3),
]
# ═══ PART 2: CLASSIFICATION ═══════════════════════════════════
story += [section_header("PART 2 — CLASSIFICATION"), SP(2)]
story += [
make_table(["Type", "Description", "Skin cover?", "Neural tissue?", "Freq."],
[
["Spina Bifida Occulta", "Failure of vertebral arch fusion only; no herniation", "Yes (intact)", "None", "~10% population"],
["Meningocele", "Meninges + CSF herniate through bony defect", "Yes (skin)", "Absent from sac", "Uncommon"],
["Myelocele", "Neural plate flush with skin surface; no cyst", "No (open)", "Exposed, flush", "Rare"],
["Myelomeningocele (MMC)", "Meninges + spinal cord/nerve roots in sac; sac protrudes", "No (open)", "In sac", "MOST COMMON severe form"],
], [42*mm, 70*mm, 22*mm, 28*mm, 30*mm]),
SP(3),
]
story += [sub_header("Spina Bifida Occulta — Cutaneous Markers (Always Examine the Back!)"), SP(1)]
story += [
P("Any dorsal midline skin finding warrants spinal MRI to exclude occult dysraphism and tethered cord:"),
]
cutaneous = [
"Asymmetrical gluteal fold", "Dermal sinus or dimple (above gluteal cleft)",
"Hairy tuft (hypertrichosis)", "Hemangioma", "Lipoma",
"Nevus", "Pilonidal sinus", "Rudimentary tail", "Spinal aplasia cutis"
]
# 3-column layout for cutaneous markers
col_data = []
for i in range(0, len(cutaneous), 3):
row = cutaneous[i:i+3]
while len(row) < 3:
row.append("")
col_data.append([Paragraph("<bullet>•</bullet> " + r, sBullet) if r else Paragraph("", sBullet) for r in row])
ct = Table(col_data, colWidths=[W/3]*3)
ct.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), C_LIGHT),
("LEFTPADDING", (0,0), (-1,-1), 5),
("TOPPADDING", (0,0), (-1,-1), 2),
("BOTTOMPADDING",(0,0),(-1,-1), 2),
("GRID", (0,0), (-1,-1), 0.3, HexColor("#B0BEC5")),
]))
story += [ct, SP(2),
warn_box("A sacral dimple ABOVE the gluteal cleft or > 5 mm deep requires MRI. A dimple AT the base of the gluteal cleft in an otherwise normal infant is usually benign."),
SP(3),
]
# ═══ PART 3: EPIDEMIOLOGY ══════════════════════════════════════
story += [section_header("PART 3 — EPIDEMIOLOGY"), SP(2)]
story += [
make_table(["Parameter", "Data"],
[
["Global incidence", "~1 per 1,000 births"],
["US incidence (post-folate fortification)", "~0.6 per 1,000 births"],
["Sex", "Females slightly more affected"],
["Folate supplementation impact", "~50% reduction in MMC incidence"],
["Hydrocephalus requiring VP shunt", "64–85% of lumbosacral MMC (81% overall)"],
["5-year mortality (neonatal repair)", "~7.9% (79 per 1,000)"],
["Mortality with brainstem dysfunction", "~35%"],
["IQ >80 in long-term survivors", ">70%"],
["Live independently as adults", "Only ~37%"],
], [80*mm, 110*mm]),
SP(3),
]
# ═══ PART 4: PRENATAL SCREENING ════════════════════════════════
story += [section_header("PART 4 — PRENATAL SCREENING & DIAGNOSIS"), SP(2)]
story += [sub_header("Maternal Serum / Amniotic Fluid"), SP(1)]
story += [
B("Elevated <b>maternal serum alpha-fetoprotein (MSAFP)</b> — AFP leaks from the open neural defect into amniotic fluid and then maternal serum"),
B("Abnormal AFP triggers <b>amniocentesis</b>: measure amniotic AFP + <b>acetylcholinesterase</b>"),
B("Acetylcholinesterase is <i>specific</i> for open NTDs (absent in normal amniotic fluid)"),
SP(2),
sub_header("Fetal Ultrasound — Second Trimester Signs"),
SP(1),
make_table(["Ultrasound Sign", "Significance"],
[
["Lemon sign", "Bifrontal skull indentation on axial view — Chiari II traction on frontal bones"],
["Banana sign", "Curved/obliterated cerebellum — Chiari II cerebellar herniation"],
["U-shaped splayed posterior elements", "On axial spine view — unfused laminae at the defect level"],
["Dorsal cystic mass (lumbosacral)", "The meningeal sac protruding through the defect"],
["Ventriculomegaly", "Secondary hydrocephalus from Chiari II CSF obstruction"],
["Absent/small cisterna magna", "Posterior fossa crowding from Chiari II"],
["Low-lying conus medullaris", "Tethered cord (below L2 on MRI/US)"],
["Polyhydramnios", "Less common than in EA; can occur with severe NTD"],
], [55*mm, 125*mm]),
SP(2),
pearl_box("Fetal vertebral column is detectable on US from 10–12 weeks. Chiari II is almost invariably present between 19–25 weeks — its ABSENCE should make you reconsider the diagnosis."),
SP(2),
sub_header("Fetal MRI"), SP(1),
B("Better delineation of lesion level, brain anatomy, Chiari II severity, and associated anomalies"),
B("Guides prenatal counselling and surgical planning (fetal vs. postnatal repair)"),
SP(3),
]
# ═══ PART 5: ASSOCIATED CONDITIONS ════════════════════════════
story += [section_header("PART 5 — ASSOCIATED CONDITIONS"), SP(2)]
story += [sub_header("5A. Arnold-Chiari Type II Malformation"), SP(1)]
story += [
P("<b>Mechanism:</b> Open spinal defect → chronic CSF leak → reduced posterior fossa pressure → small posterior fossa → cerebellar vermis and caudal brainstem (medulla ± pons) herniate caudally through the foramen magnum."),
SP(1),
make_table(["Feature", "Detail"],
[
["Prevalence", "Present in virtually 100% of MMC; clinically significant in ~35%"],
["Detectable on imaging", "Almost invariably 19–25 weeks' gestation (fetal MRI/US)"],
["Structures herniated", "Cerebellar vermis, medulla, sometimes pons"],
["Associated brain findings", "Polymicrogyria, small posterior fossa, kink in medulla, absent corpus callosum"],
["Hydrocephalus", "CSF flow blocked at 4th ventricle → secondary hydrocephalus"],
["Syringomyelia", "CSF tracking into central canal"],
["VP shunt need", ">80% require lifelong shunting; 50% have shunt complications year 1"],
], [55*mm, 125*mm]),
SP(2),
warn_box("Neonatal red flags for SYMPTOMATIC Chiari II: stridor (vocal cord paralysis), apnea/bradycardia, dysphagia/aspiration, weak cry, opisthotonos, central hypoventilation. Mortality 35% if brainstem dysfunction present."),
SP(2),
]
story += [sub_header("5B. Hydrocephalus"), SP(1)]
story += [
B("64–85% of lumbosacral MMC patients require a <b>VP shunt</b>"),
B("Mean IQ with VP shunt: <b>~80</b> (low-normal); worse than non-shunted patients"),
B("50% of shunted children have shunt complications in the first year"),
B("<b>Monitor:</b> daily head circumference, serial cranial ultrasounds, fontanelle tension"),
B("Consult neurosurgery promptly for progressive ventriculomegaly"),
SP(2),
]
story += [sub_header("5C. Tethered Cord Syndrome"), SP(1)]
story += [
P("Spinal cord abnormally attached at repair site. Presents with <b>progressive</b> neurological deterioration (worsening gait, back pain, scoliosis, worsening bladder dysfunction) as child grows. MRI shows low-lying conus (below L2) with thickened filum terminale. Treatment: surgical detethering."),
SP(3),
]
# ═══ PART 6: NEUROLOGICAL DEFICIT BY LEVEL ════════════════════
story += [section_header("PART 6 — NEUROLOGICAL DEFICIT BY LESION LEVEL"), SP(2)]
story += [
make_table(["Level", "Motor Function", "Ambulation Expected"],
[
["Thoracic", "Total paralysis below lesion; no hip/knee/ankle control", "Wheelchair dependent"],
["High Lumbar (L1–L2)", "Hip flexion only; no knee extension or ankle control", "Wheelchair; KAFO + crutches possible"],
["Mid Lumbar (L3)", "Knee extension present; no ankle dorsiflexion or plantarflexion", "Short-distance ambulation with AFOs"],
["Low Lumbar (L4–L5)", "Ankle dorsiflexion present; weak plantarflexion", "Community ambulation with AFOs"],
["Sacral (S1–S2)", "Near-normal lower limb strength; sphincter dysfunction", "Independent ambulation; CIC required"],
], [30*mm, 95*mm, 65*mm]),
SP(2),
pearl_box("Neurological deficits at birth are IRREVERSIBLE with postnatal repair. Surgery prevents further deterioration — it does NOT restore lost function. This is why fetal surgery (stopping Hit 2) is so valuable."),
SP(2),
warn_box("Higher lesion level = greater disability. Thoracic and high lumbar lesions carry the worst functional prognosis."),
SP(3),
]
# ═══ PART 7: NEONATAL ASSESSMENT & IMMEDIATE MANAGEMENT ═══════
story += [section_header("PART 7 — NEONATAL ASSESSMENT & IMMEDIATE MANAGEMENT"), SP(2)]
story += [sub_header("Delivery Planning"), SP(1)]
story += [
B("Planned <b>caesarean section BEFORE onset of labour</b> — reduces exposure of open neural elements to birth canal trauma"),
B("Improved neurological outcomes vs. vaginal delivery or CS after labour onset"),
B("Deliver at a centre with <b>immediate neurosurgical capability</b>"),
SP(2),
]
story += [sub_header("Systematic Neonatal Examination"), SP(1)]
story += [
P("<b>1. Inspect the lesion:</b> Site, size, vertebral level (count from sacrum), skin cover (intact vs. open), CSF leakage (infection risk), visibility of neural placode."),
P("<b>2. Neurological assessment:</b> Lower limb tone, spontaneous movement, response to pin-prick at successive dermatomal levels (defines sensory level), anal wink reflex (S3–S5), cremasteric reflex."),
P("<b>3. Head:</b> Measure occipitofrontal circumference (OFC) — baseline for hydrocephalus monitoring. Palpate fontanelle. Arrange cranial ultrasound."),
P("<b>4. Associated anomalies:</b> Club foot (equinovarus), hip dislocation, kyphoscoliosis, renal — palpate kidneys, arrange renal ultrasound."),
SP(2),
]
story += [sub_header("Immediate Actions — Hour 0 Protocol"), SP(1)]
story += [
make_table(["Priority", "Action", "Why"],
[
["1 — Sac protection", "Cover with warm saline-soaked sterile gauze + waterproof dressing", "Prevent desiccation and infection; maintain moisture"],
["2 — Position", "PRONE or lateral decubitus — NEVER supine", "Supine = pressure on sac = rupture + cord compression"],
["3 — Temperature", "Warm environment, radiant warmer, cover exposed area", "Open lesion = massive transepidermal heat + water loss"],
["4 — IV access + fluids", "Peripheral IV; maintenance fluid (account for extra insensible losses)", "Compensation for fluid loss through lesion"],
["5 — Antibiotics", "Broad-spectrum IV (cephalosporin + aminoglycoside or ampicillin + gentamicin)", "Meningitis prophylaxis; especially if CSF leaking"],
["6 — Neurosurgery", "Urgent consult; aim for closure within 24–72 hours", "Every hour of delay increases meningitis risk"],
["7 — Cranial US", "Same-day study", "Baseline ventricular size for hydrocephalus monitoring"],
["8 — Renal US", "Day 1", "Baseline upper tracts; part of VACTERL-like screen"],
["9 — Urology", "Consult Day 1; plan urodynamics + start CIC in first week", "Prophylactic renal protection — do not wait for symptoms"],
["10 — Orthopaedics", "Foot and hip examination; splinting for equinovarus", "Early intervention improves long-term ambulation"],
["11 — NPO", "If surgery planned imminently", "Preoperative preparation"],
], [35*mm, 85*mm, 70*mm]),
SP(2),
warn_box("An open MMC is a direct portal for meningitis. Time to closure must be minimised. Delay beyond 72 hours is associated with significantly higher infection rates and worse outcomes."),
SP(3),
]
# ═══ PART 8: SURGICAL MANAGEMENT ══════════════════════════════
story += [section_header("PART 8 — SURGICAL MANAGEMENT"), SP(2)]
story += [sub_header("Postnatal Surgical Repair"), SP(1)]
story += [
P("<b>Goals:</b> (1) Close skin over neural placode, (2) Prevent CSF leak and meningitis, (3) Untether the cord from the wound edges, (4) Preserve remaining neurological function."),
P("<b>Technique:</b> Neurosurgical dissection of neural placode from surrounding skin → reconstitution of dura → multi-layer closure (dura, fascia, skin). VP shunt placed concurrently or at same admission in ~70–85%."),
SP(2),
]
story += [sub_header("Fetal Surgery — The MOMS Trial"), SP(1)]
story += [
P("Randomised, prospective, 3 US centres, 2003–2010, n=183. Compared <b>open in-utero repair (19–26 weeks)</b> vs standard postnatal repair."),
SP(1),
make_table(["Outcome", "Fetal Surgery", "Postnatal Surgery", "Result"],
[
["VP shunt required by 12 months", "40%", "82%", "p < 0.001 — Fetal better"],
["Hindbrain herniation reversal", "Significant", "No change", "Fetal better"],
["Independent walking at 30 months", "44.8%", "23.9%", "p = 0.04 — Fetal better"],
["Function ≥2 levels better than expected", "26.4%", "11.4%", "Fetal better"],
["Preterm birth / PPROM", "Higher", "Lower", "Fetal worse — trade-off"],
["Maternal uterine dehiscence", "Higher", "Lower", "Fetal worse — trade-off"],
], [70*mm, 25*mm, 30*mm, 65*mm]),
SP(2),
pearl_box("10-year follow-up (pretrial cohort n=54): Improved functional, behavioural, and motor outcomes — especially in children who did NOT require VP shunting. 2025 meta-analyses confirm these benefits. (Kunpalin et al. Ultrasound Obstet Gynecol 2025, PMID 40492626; Torres et al. Childs Nerv Syst 2025, PMID 41398113)"),
SP(2),
sub_header("Eligibility Criteria for Fetal MMC Repair"), SP(1),
make_table(["Criterion", "Detail"],
[
["Gestational age", "19–26 weeks"],
["Lesion level", "T1 to S1"],
["Brain finding", "Chiari II malformation on MRI"],
["Karyotype", "Normal (46,XX or 46,XY)"],
["Other anomalies", "None (isolated MMC)"],
["Pregnancy", "Singleton"],
["Centre requirement", "Specialist high-volume centre only — NOT generalizable"],
], [50*mm, 140*mm]),
SP(2),
sub_header("Fetoscopic (Minimally Invasive) Repair"), SP(1),
P("Emerging technique. Reduces maternal morbidity and may allow vaginal delivery. Phase I trials (n=10) showed improved hindbrain herniation and motor function but 100% PPROM rate and mean delivery at 32 weeks. Two-port fetoscopic technique with partial CO2 insufflation shows improving results. Not yet standard of care — offered at select centres."),
SP(3),
]
# ═══ PART 9: NEUROGENIC BLADDER & BOWEL ═══════════════════════
story += [section_header("PART 9 — NEUROGENIC BLADDER & BOWEL"), SP(2)]
story += [sub_header("Why This Is the Most Important Long-Term Issue"), SP(1)]
story += [
P("Bladder dysfunction is the <b>leading cause of long-term morbidity and mortality</b> in MMC survivors. High intravesical pressures → hydronephrosis → renal scarring → renal failure. <b>Most kidney damage is preventable with early CIC.</b>"),
SP(1),
sub_header("Neurogenic Bladder — Assessment"),
SP(1),
B("<b>Urodynamic study</b> (bladder pressure-volume study) — mandatory; characterises storage and emptying function"),
B("<b>Renal + bladder ultrasound</b> — baseline upper tract evaluation; repeat every 6–12 months"),
B("<b>VCUG</b> if VUR suspected (elevated bladder pressures predispose to reflux)"),
SP(2),
sub_header("Treatment"),
SP(1),
make_table(["Treatment", "Indication / Details"],
[
["Clean Intermittent Catheterisation (CIC)", "Cornerstone. Start in neonatal period. Parents taught first; child self-catheterises from ~5–6 years. 40–80% develop asymptomatic bacteriuria — does NOT require antibiotics unless symptomatic."],
["Anticholinergics (oxybutynin)", "Bladder overactivity + detrusor hypertonia. Reduces intravesical pressure, protects upper tracts. VUR resolved/improved in 44–79% when overactivity treated."],
["Prophylactic antibiotics", "NOT routinely recommended. No long-term benefit; increases bacterial resistance. Stopping prophylaxis reduces resistance (Zegers et al. 2017)."],
["Bladder augmentation (cystoplasty)", "Surgical — for refractory high-pressure bladder unresponsive to medical therapy"],
["Mitrofanoff procedure", "Creates continent catheterisable channel (appendix) for patients who cannot catheterise urethrally"],
["Botulinum toxin (intravesical)", "Alternative to augmentation for overactive detrusor"],
], [55*mm, 135*mm]),
SP(2),
warn_box("ASB (asymptomatic bacteriuria) in CIC patients does NOT require treatment. Treat only symptomatic UTI (fever, systemic signs, new haematuria). Blanket antibiotic use drives resistance."),
SP(2),
sub_header("Neurogenic Bowel"), SP(1),
B("Loss of voluntary anal sphincter control (S2–S4 lesions) → constipation + overflow incontinence"),
B("Bowel program: scheduled toileting, high-fibre diet, osmotic laxatives"),
B("Rectal irrigation (e.g. Peristeen) for refractory constipation"),
B("Malone antegrade continence enema (ACE/MACE procedure) — surgical option for older children"),
SP(3),
]
# ═══ PART 10: ORTHOPAEDIC COMPLICATIONS ═══════════════════════
story += [section_header("PART 10 — ORTHOPAEDIC COMPLICATIONS"), SP(2)]
story += [
make_table(["Complication", "Notes", "Management"],
[
["Club foot (equinovarus)", "Most common; present at birth from muscle imbalance (unopposed plantarflexion)", "Ponseti serial casting; AFOs; surgery if resistant"],
["Hip dislocation", "Muscle imbalance (flexors without extensors); unilateral or bilateral", "Orthopaedic assessment; less aggressive than idiopathic DDH"],
["Neuromuscular scoliosis", "Progressive; worsened by tethered cord; common at thoracic/high lumbar levels", "Bracing; posterior spinal fusion when curves > 40–50°"],
["Congenital kyphosis", "Rigid angular kyphosis at birth especially thoracolumbar; can cause skin breakdown over sac", "Surgical correction; resection of kyphus at time of MMC repair"],
["Pathological fractures", "Osteoporosis from immobility + denervation; painless swelling in insensate limb", "Soft tissue swelling without pain in anaesthetic limb — X-ray, splint"],
["Pressure sores", "Sensory loss means child cannot feel pressure ischaemia", "Regular repositioning; appropriate wheelchair seating; skin checks"],
], [42*mm, 78*mm, 70*mm]),
SP(3),
]
# ═══ PART 11: COGNITIVE & NEURODEVELOPMENTAL OUTCOMES ══════════
story += [section_header("PART 11 — COGNITIVE & NEURODEVELOPMENTAL OUTCOMES"), SP(2)]
story += [
make_table(["Domain", "Detail"],
[
["IQ", ">70% of MMC survivors have IQ >80; mean IQ with VP shunt ~80 (low-normal)"],
["Independent living", "Only ~37% of adults with MMC live independently"],
["Cognitive profile", "Executive dysfunction, slow processing speed, poor visual-motor integration, arithmetic difficulty"],
["'Cocktail party speech'", "Fluent, verbose speech but poor comprehension and shallow content — can mask cognitive deficits"],
["Predictor of cognition", "VP shunt requirement is the strongest predictor — shunted children do worse"],
["Intervention", "Early speech therapy, OT, PT, and educational support significantly improve outcomes"],
], [55*mm, 135*mm]),
SP(3),
]
# ═══ PART 12: PREVENTION ══════════════════════════════════════
story += [section_header("PART 12 — PREVENTION & RECURRENCE"), SP(2)]
story += [
make_table(["Scenario", "Folic Acid Dose", "Timing"],
[
["All women of reproductive age", "400 mcg (0.4 mg) daily", "Periconceptionally and through first trimester"],
["Previous NTD-affected pregnancy", "4–5 mg daily", "Start 3 months BEFORE conception; continue through T1"],
["Antiepileptic drugs / diabetes / obesity", "4–5 mg daily", "Start 3 months before conception"],
["Population-level", "Folate fortification of bread/grain (USA since 1998)", "Ongoing; ~50% reduction in NTD incidence"],
], [55*mm, 60*mm, 75*mm]),
SP(2),
sub_header("Recurrence Risk"),
SP(1),
make_table(["Situation", "Risk"],
[
["General population (no family history)", "~1 in 1,000"],
["One previously affected child", "2–3%"],
["Two previously affected children", "~10%"],
["Affected parent", "~4%"],
["Affected sibling (not child)", "~2–3%"],
], [100*mm, 90*mm]),
SP(3),
]
# ═══ PART 13: MDT TEAM ════════════════════════════════════════
story += [section_header("PART 13 — MULTIDISCIPLINARY TEAM (MDT) ROLES"), SP(2)]
story += [
make_table(["Specialty", "Role"],
[
["Neonatology", "Initial stabilisation, sac protection, early CIC, antibiotic prophylaxis, hydrocephalus monitoring, neurodevelopmental follow-up"],
["Neurosurgery", "MMC closure, VP shunt, tethered cord release, Chiari decompression"],
["Urology / Nephrology", "Urodynamics, CIC programme, renal surveillance, upper tract protection, surgical options (augmentation, Mitrofanoff)"],
["Orthopaedics", "Club foot, hip dislocation, scoliosis/kyphosis correction, fracture management"],
["Physiotherapy", "Mobility, gait training, splinting, orthotics (AFOs, KAFOs)"],
["Occupational Therapy", "ADLs, hand function, school adaptations, independent catheterisation"],
["Developmental Paediatrics", "IQ/cognitive assessment, learning support, behavioural issues"],
["Dietetics", "Obesity prevention (immobility + denervated limbs = high risk), bowel diet"],
["Neurology", "Seizure management, Chiari II symptoms"],
["Psychology / Psychiatry", "Mental health (depression and anxiety are elevated in adolescents with MMC)"],
["Social work", "Family support, disability services, transition planning to adult care"],
], [45*mm, 145*mm]),
SP(3),
]
# ═══ PART 14: PROGNOSIS SUMMARY ═══════════════════════════════
story += [section_header("PART 14 — PROGNOSIS SUMMARY"), SP(2)]
story += [
make_table(["Domain", "Outcome"],
[
["Survival to adulthood", "~85–90% with modern care; 14% mortality by age 5"],
["With brainstem dysfunction (Chiari II)", "~35% mortality — highest-risk group"],
["Ambulation", "~50% of all MMC patients achieve community ambulation (level-dependent)"],
["Continence", "Rarely achieved without CIC + bowel program; most require lifelong management"],
["Cognition", "IQ >80 in >70%; only 37% independent as adults"],
["Quality of life", "Self-reported QoL surprisingly positive; greatest predictors: lesion level, shunt complications, social support"],
["Renal outcome", "Preventable with early CIC; renal failure historically major cause of adult death"],
], [55*mm, 135*mm]),
SP(3),
]
# ═══ QUICK REFERENCE TABLE ════════════════════════════════════
story += [section_header("QUICK REFERENCE — NEONATAL CLINICAL PEARLS"), SP(2)]
story += [
make_table(["Scenario", "Action / Key Point"],
[
["Open MMC at birth", "PRONE + warm moist sterile dressing + IV antibiotics + urgent neurosurgery within 24–72 h"],
["CSF leaking from sac", "Emergency — meningitis imminent. Stat neurosurgical consultation. Intensify antibiotics."],
["Hairy tuft / sacral dimple above gluteal cleft", "Spinal MRI to exclude occult dysraphism and tethered cord"],
["Stridor + apnea post-MMC repair", "Think SYMPTOMATIC CHIARI II — brainstem compression. Posterior fossa decompression."],
["Progressive macrocephaly / full fontanelle", "Hydrocephalus — urgent cranial US + neurosurgical review for VP shunt"],
["All MMC neonates, bladder", "Start CIC within first week regardless of apparent bladder function — prophylactic renal protection"],
["Asymptomatic bacteriuria on CIC", "Do NOT treat — no antibiotics unless symptomatic UTI"],
["Prenatal diagnosis at 19–26 weeks", "Refer to fetal surgery centre; counsel about MOMS trial evidence"],
["Family counselling post-delivery", "5 mg folic acid starting 3 months before next conception"],
["Painless swollen limb in MMC child", "Pathological fracture — X-ray; diagnose clinically in insensate limb"],
], [70*mm, 120*mm]),
SP(4),
]
# ─── SOURCES ──────────────────────────────────────────────────
story.append(hr())
sources = (
"<b>Sources:</b> The Developing Human: Clinically Oriented Embryology (Moore et al.) | "
"Bradley & Daroff's Neurology in Clinical Practice (7e) | "
"Miller's Anesthesia 10e | "
"Creasy & Resnik's Maternal-Fetal Medicine (8e) | "
"Goldman-Cecil Medicine (International Ed.) | "
"Bailey & Love's Short Practice of Surgery (28e) | "
"Campbell-Walsh Urology (4th ed.) | "
"Kunpalin et al. Ultrasound Obstet Gynecol 2025 (PMID 40492626) | "
"Torres et al. Childs Nerv Syst 2025 (PMID 41398113) | "
"de Oliveira Manduca Palmiero et al. Childs Nerv Syst 2025 (PMID 41342964)"
)
story.append(Paragraph(sources, sSmall))
story.append(SP(1))
story.append(Paragraph("Generated by Orris Medical AI — For educational purposes only. Always verify against current clinical guidelines.", sFooter))
# ─── BUILD ────────────────────────────────────────────────────
doc.build(story)
print("PDF created:", OUTPUT)