Teach me Meniningiomyocele like a neonataologist/ paeditrician in depth

Reading File
Now let me search the medical library comprehensively for meningomyelocele (note: the correct term is meningomyelocele/myelomeningocele - I'll search for both). This is a broad clinical topic, so I'll run parallel searches.
Finding Sources
Finding Sources
Finding Sources
Excellent! I found rich sources. Let me now read the most relevant ones - particularly Medical Physiology (neonatology perspective), The Developing Human (embryology), Bradley & Daroff's Neurology, and Miller's Anesthesia for comprehensive coverage.
Reading File
Reading File
Reading File
Finding Sources
Good - now let me read the neurology textbook section and the Miller's Anesthesia section (for fetal surgery), plus get the spina bifida images and more clinical detail.
Reading File
Reading File
Finding Sources
Loading Image
Excellent! Now let me get more clinical detail - particularly the neurological deficits by level, neonatal management, Chiari II, and the MOMS trial data.
Reading File
Reading File
Finding Sources
Loading Image
Now let me get the diagrammatic representation of myelomeningocele and read more about neonatal clinical deficits by level, plus the Miller's Anesthesia neonatal section.
Loading Image
Reading File
Finding Sources
Finding Sources
I have rich material. Let me get one more important piece - the Creasy & Resnik MFM section on myelomeningocele repair, and a quick search on neonatal postnatal management steps.
Reading File
Searching PubMed

myelomeningocele neonatal management outcomes

I now have comprehensive material from multiple authoritative textbooks. Let me compile everything into a thorough, neonatologist/paediatrician-oriented teaching document.

Myelomeningocele (Meningomyelocele) - A Neonatologist's Deep Dive

Terminology note: The terms myelomeningocele (MMC) and meningomyelocele are used interchangeably. "Myelomeningocele" is the preferred modern term. It is a subset of open spina bifida and the most severe common form of neural tube defect (NTD) compatible with life.

1. The Anatomy - What Exactly Is It?

Cross-sectional diagram of myelomeningocele showing displaced spinal cord and meninges herniated through the vertebral defect into a membranous sac
Cross-section showing the displaced spinal cord and nerve roots herniated into the membranous sac through the unfused vertebral arch (Medical Physiology, Fig. 10-7C)
Understand the spectrum first:
TypeWhat herniatesNeural elements?Neurological deficit
Spina bifida occultaNothing - vertebral arch unfused onlyNoUsually none
MeningoceleMeninges + CSF onlyNoUsually none
MyelomeningoceleMeninges + spinal cord + nerve rootsYesAlways present
MyeloschisisOpen spinal cord, no sac - exposed neural plateYesSevere
In MMC, the spinal cord itself (the placode) lies within or at the surface of the sac. The neural tissue is directly exposed to amniotic fluid - this is critical to understanding why postnatal (or prenatal) closure is urgent.
Sagittal diagram showing spinal cord and nerve roots herniated into a large posterior sac at the lumbar level
Sagittal view of myelomeningocele showing the cord and roots descending into the sac (Bradley & Daroff's Neurology, Fig. 104.10)

2. Embryology - Why Does It Happen?

Timeline: Weeks 3-4 of gestation (days 18-28). This is before most women know they are pregnant.
The neural plate folds to form the neural tube through a process called primary neurulation. Failure of this closure - specifically the caudal neuropore (which closes last, around day 26-28) - results in open defects at lumbar/sacral levels.
Two-hit hypothesis (Creasy & Resnik MFM, 2022):
  1. First hit: Primary failure of neural tube closure at ~week 4
  2. Second hit: Progressive damage from chronic exposure of the open neural placode to neurotoxic amniotic fluid throughout gestation - amniotic fluid contains substances directly toxic to neural tissue, and there is also mechanical trauma
This two-hit model is the entire rationale for in utero surgery - closing the defect early stops the second hit.

3. Epidemiology

  • Incidence: approximately 1 in 3,000 live births (post-folate supplementation era)
  • Folate supplementation has reduced MMC prevalence by ~50%, but a plateau has been reached
  • 25-40% of MMC pregnancies are terminated following prenatal diagnosis
  • Most common in lumbar and sacral regions (>75% of cases)
  • Slight female predominance
Risk factors:
  • Maternal folate/B12 deficiency (most important modifiable factor)
  • Valproic acid during early pregnancy (1-2% risk of NTD - one of the highest teratogen risks known)
  • Carbamazepine
  • Family history of NTDs
  • Prior affected pregnancy
  • Maternal obesity, diabetes, hyperthermia in early pregnancy

4. Prenatal Diagnosis

Screening:
  • Maternal serum AFP (MSAFP) at 14-16 weeks - elevated in ~85% of open NTDs. Open defects leak AFP into amniotic fluid then into maternal blood.
  • Amniotic fluid AFP + acetylcholinesterase (more specific than AFP alone)
  • Second-trimester ultrasound (18-20 weeks): Detects >90% of NTDs
Ultrasound signs - the classic triad:
SignWhat you seeSignificance
Lemon signFrontal bone scalloping (skull looks like a lemon)Chiari II pulling on brain
Banana signCurved cerebellum wrapping around brainstemChiari II herniation
Splayed vertebraeU-shaped or V-shaped vertebrae on axial viewDirect sign of spina bifida
Fetal MRI at 19-25 weeks provides superior characterization of the lesion level, hindbrain herniation, and cortical anomalies.

5. Associated Anomalies - What Else to Look For

Chiari II Malformation (THE most important associated anomaly)

Present in virtually 100% of MMC cases. The downward traction of the tethered cord pulls the hindbrain through the foramen magnum:
  • Cerebellar vermis + caudal brainstem (medulla, sometimes pons) herniate through enlarged foramen magnum
  • Small posterior fossa
  • Kinked medulla
  • Polymicrogyria can be seen
Clinical consequences of Chiari II in neonates/infants:
  • Stridor (inspiratory) - from vocal cord palsy due to cranial nerve X dysfunction
  • Apnea - central (brainstem compression) or obstructive
  • Swallowing dysfunction - aspiration risk
  • Central hypoventilation - life-threatening
  • Opisthotonus in severe cases
  • These symptoms = brainstem dysfunction = 35% mortality by 5 years even with repair

Hydrocephalus

  • Present in 64-85% of MMC cases requiring VP shunt (lumbosacral lesions)
  • Mechanism: obstruction of CSF flow at the fourth ventricle due to Chiari II malformation
  • Higher lesion level = higher risk of shunt-dependent hydrocephalus
  • Mean IQ with VP shunt: ~80 (low normal); lower than those who don't require a shunt
  • Monitor for shunt malfunction throughout childhood

Other associations:

  • Tethered cord syndrome - progressive neurological deterioration post-repair as cord gets re-tethered
  • Latex allergy - critically important. Children with MMC have a dramatically higher prevalence (10-40%) of latex allergy from repeated early latex exposure during multiple procedures. Strict latex-free environment from day 1.
  • Craniolacunia (Lückenschädel) - depressed non-ossified areas on inner calvaria
  • Syringomyelia
  • Orthopedic deformities (hip dislocation, clubfoot, scoliosis, kyphosis)
  • Neurogenic bladder and bowel

6. The Lesion Level - Functional Anatomy for Neonatologists

The motor level predicts functional ability. In MMC, the functional level is often better than the anatomic level.
Lesion LevelMotor Function PreservedAmbulation PotentialBladder/Bowel
ThoracicArms, trunk partiallyWheelchair-dependentNeurogenic
L1-L2Hip flexors (iliopsoas)Braces + wheelchairNeurogenic
L3-L4Knee extensors (quads)May walk with bracesNeurogenic
L4-L5Ankle dorsiflexors, knee flexorsWalk with AFOsNeurogenic (partial)
SacralIntrinsic foot musclesIndependent walkingVariable
Key point for neonatologists: Almost ALL patients with MMC have neurogenic bladder regardless of lesion level, due to involvement of sacral roots. This means:
  • Urinary retention with overflow incontinence if untreated
  • Risk of upper urinary tract damage (hydronephrosis, reflux, renal failure)
  • Clean intermittent catheterization (CIC) must be started early - often within days of birth
  • Baseline renal ultrasound and urodynamics in first weeks of life

7. Neonatal Presentation and Initial Assessment

At Delivery - What You See

The neonate is born with a visible posterior midline mass, most commonly in the lumbosacral region:
  • Intact sac: Translucent membrane covered sac containing CSF, meninges, and neural tissue - relatively protected
  • Ruptured/exposed placode: Raw, red, weeping area - urgent surgical priority (meningitis risk)
  • Look for motor posturing of lower limbs (flaccid = bad)

Neurological Examination in the Delivery Room

What to assessHowWhat it tells you
Spontaneous leg movementObserveLevel of function
Response to pin-prick on lower limbsCareful dermatomal testingSensory level
Anal wink reflexPerianal stimulationSacral root integrity
Tone of lower limbsPassive movementLMN injury pattern
Head circumferenceOFC measurementPre-existing hydrocephalus
Fontanelle tensionPalpationICP
Respiratory patternObserveBrainstem function
Cry/voice qualityListenVocal cord palsy

Immediate Neonatal Orders (First Hour)

  1. Positioning: Prone or lateral decubitus - never supine over the sac. Place on a "doughnut" (ring pad) to protect the sac.
  2. Sterile moist saline gauze over the defect (non-adherent) - prevents desiccation and infection
  3. Latex-free environment immediately - use only latex-free gloves, equipment
  4. Thermoregulation: High insensible losses from the exposed defect - prone to hypothermia and heat loss. Incubator.
  5. Fluid management: Increase maintenance fluids to account for insensible losses from the sac
  6. IV access - anticipate early surgery
  7. Cranial ultrasound - assess ventricular size, rule out acute hydrocephalus
  8. Renal ultrasound - baseline upper tract
  9. Neurosurgical consultation - within hours for surgical planning
  10. Urology consultation - for bladder management plan

8. Timing and Type of Repair

Postnatal Repair

  • Standard of care for decades
  • Goal: Close within 24-72 hours of birth (reduces meningitis risk, though exact timing evidence varies)
  • Rationale for urgency: open defect = direct route for ascending infection; CSF leak
  • Surgical steps: separation of placode from surrounding skin, dural closure, fascial closure, skin closure
  • Anesthesia considerations: prone positioning for intubation (doughnut under the sac), risk of brainstem herniation on induction, anticipate significant insensible fluid loss, vocal cord palsy risk

In Utero (Fetal) Repair - The MOMS Trial Revolution

The landmark Management of Myelomeningocele Study (MOMS Trial) was a randomized controlled trial (2003-2010, n=183) comparing prenatal open fetal repair vs. standard postnatal repair:
Benefits of prenatal repair (at 30 months):
  • Reduced need for VP shunt placement before 1 year (40% vs 82%)
  • Reversal of hindbrain herniation (Chiari II improvement)
  • Better lower extremity motor function: 44.8% vs 23.9% walked independently
  • Function ≥2 levels better than anatomic level: 26.4% vs 11.4%
  • Better Bayley Mental Development Index scores
  • Better Peabody Motor Scale scores
Costs of prenatal repair:
  • Higher risk of preterm birth, preterm PROM
  • Uterine dehiscence at delivery (11%)
  • Maternal hysterotomy scar (affects future pregnancies - cesarean delivery required)
  • Two perinatal deaths in each group
Window for fetal surgery: 19-26 weeks' gestation
Current eligibility criteria (strict patient selection):
  • Singleton pregnancy
  • MMC between T1 and S1 with hindbrain herniation
  • Gestational age 19-25+6 weeks at evaluation
  • Normal chromosomes
  • No other major fetal anomalies
  • No maternal contraindications
Fetoscopic (minimally invasive) repair is increasingly explored but remains associated with higher PPROM rates (91% vs 36%) and CSF leak from repair site, though it allows potential vaginal delivery.
Recent 2025 meta-analysis (PMID: 40492626) and comparative systematic review (PMID: 40779058) continue to compare open vs fetoscopic approaches, with open fetal surgery remaining the reference standard.

9. Postoperative Neonatal Care

After surgical closure (whether 24 hours or day 3 of life):
Immediate post-op:
  • Positioning: Still prone for 5-7 days to allow wound healing; avoid pressure on repair
  • Monitor for hydrocephalus: Head circumference daily; serial cranial ultrasounds; fontanelle examination. May develop or worsen post-repair as CSF dynamics change.
  • VP shunt decision: Most will need a shunt (64-85% of lumbosacral MMC). Usually placed days to weeks after closure.
  • Wound care: Monitor for CSF leak at repair site, infection
  • Ventilatory monitoring: Apnea, central hypoventilation from Chiari II - may require prolonged monitoring, some require home apnea monitor
  • Feeding: Assess swallow function before oral feeds - risk of aspiration with Chiari II-related bulbar dysfunction. NG feeds initially.
  • Bladder management: Initiate CIC as soon as urology clears (typically within days)
Ongoing monitoring before discharge:
  • Ophthalmology: strabismus, papilledema
  • Audiology: sensorineural hearing loss can be associated
  • Neurodevelopmental team engagement
  • Social work / family counseling

10. Long-Term Complications and Follow-up (The Lifespan Perspective)

As a neonatologist, you are launching a child into a life of multidisciplinary care. Understand what's ahead:
SystemProblemWhen
CNSShunt malfunction/infectionAnytime
CNSTethered cord syndrome (progressive deficits)Childhood, adolescence
CNSSyringomyeliaAny age
UrologicalNeurogenic bladder, UTIs, vesicoureteral reflux, CKDLifelong
OrthopedicScoliosis, kyphosis, hip dislocation, clubfoot, pressure ulcersChildhood onwards
CognitiveLearning disabilities, executive function deficits, attention problemsSchool age
SkinPressure ulcers (insensate skin)Any age
AllergyLatex reactions (anaphylaxis risk)Lifelong
EndocrinePrecocious puberty (associated with hydrocephalus)Childhood
RespiratoryCentral sleep apneaAny age
Intellectual outcomes: >70% of survivors have IQ >80. However, executive function, attention, and processing speed are disproportionately affected. With VP shunting, mean IQ ~80 (low normal). Without shunting, cognitive outcomes are better. Most children with lumbar lesions are educable.
Ambulation: 46-75% of children with lumbosacral MMC will walk (with or without assistive devices), depending on lesion level.

11. Prevention - What You Tell Parents and Primary Care

Folic acid - the key message:
  • ALL women of childbearing age: 0.4 mg (400 mcg) daily (CDC recommendation)
  • Women with a prior NTD pregnancy or on antiepileptic drugs: 4 mg/day (10x dose), starting 1 month before conception and continuing for first 3 months
  • Mechanism: folate is essential for DNA synthesis, methylation reactions, and neural tube closure. Deficiency impairs closure at exactly the critical window (days 18-28)
  • Fortification of cereal/grain products in many countries has reduced NTD rates by ~30-50%
Drugs to avoid in pregnancy (especially 1st trimester):
  • Valproic acid (1-2% NTD risk)
  • Carbamazepine
  • Trimethoprim (folate antagonist)
  • Methotrexate

12. Quick Summary for the Bedside

"Spot diagnosis" of MMC at birth:
  1. Posterior midline sac (lumbosacral most common)
  2. Flaccid lower limbs or absent voluntary movement
  3. Absent anal wink
  4. Macrocephaly / bulging fontanelle (hydrocephalus)
  5. Possible stridor (Chiari II vocal cord palsy)
Your first 6 steps:
  1. Latex-free protocol - from this moment
  2. Prone positioning with sac protected (sterile moist gauze + doughnut)
  3. Thermoregulation in incubator (high insensible losses)
  4. IV access + extra fluids
  5. Cranial ultrasound + renal ultrasound
  6. Urgent Neurosurgery + Urology consults
Remember the triad of associated anomalies: Chiari II + Hydrocephalus + Neurogenic bladder - all three need active management.

Sources: The Developing Human (Moore & Persaud, 9e); Bradley & Daroff's Neurology in Clinical Practice (8e); Miller's Anesthesia 10e; Creasy & Resnik's Maternal-Fetal Medicine; Medical Physiology (Boron & Boulpaep); Medical Physiology (Guyton). Recent evidence: Kunpalin et al., 2025, PMID 40492626 and Oliveira et al., 2025, PMID 40779058.

Above make in interactive pdf with minimum pages to print in bookish two row in one page type

Reading File
Running Command

ls /home/daytona/workspace/ 2>/dev/null && python3 -c "import reportlab; print('reportlab ok')" && python3 -c "from reportlab.lib.pagesizes import A4; print('A4 ok')"

Running Command

mkdir -p /home/daytona/workspace/mmc-pdf && echo "dir ready"

Writing File

~/mmc-pdf/generate_mmc_pdf.py

#!/usr/bin/env python3
"""
Myelomeningocele (MMC) - Interactive 2-column print-optimised PDF
Neonatologist/Paediatrician Reference
"""

from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm, cm
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, KeepTogether, PageBreak
)
from reportlab.platypus.flowables import Flowable
from reportlab.lib.colors import HexColor, white, black
import io

# ─── Colour palette ────────────────────────────────────────────────────────────
C_NAVY    = HexColor("#1a3a5c")   # header / title bg
C_TEAL    = HexColor("#0e7c86")   # section heading bg
C_ORANGE  = HexColor("#e07b39")   # accent / alert
C_SKY     = HexColor("#daf0f5")   # alternate row / note bg
C_LIME    = HexColor("#e8f5e9")   # green note bg
C_YELLOW  = HexColor("#fff8e1")   # warning bg
C_RED     = HexColor("#b71c1c")   # danger text
C_GREY    = HexColor("#f5f5f5")   # table alt row
C_LGREY   = HexColor("#90a4ae")   # subtext
C_PURPLE  = HexColor("#6a1b9a")   # purple accent
C_DGREY   = HexColor("#37474f")   # body text

PAGE_W, PAGE_H = A4

# ─── Two-column layout constants ───────────────────────────────────────────────
MARGIN_OUTER = 12 * mm
MARGIN_INNER = 8  * mm
COL_GAP      = 6  * mm
COL_W        = (PAGE_W - 2*MARGIN_OUTER - COL_GAP) / 2  # ≈ 85 mm

# ─── Style registry ────────────────────────────────────────────────────────────
styles = getSampleStyleSheet()

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

# Base styles
BASE       = S("base",      fontName="Helvetica",      fontSize=7.2, leading=10, textColor=C_DGREY)
BODY       = S("body",      fontName="Helvetica",      fontSize=7.2, leading=10.5, textColor=C_DGREY, alignment=TA_JUSTIFY)
BODY_SML   = S("bodySmall", fontName="Helvetica",      fontSize=6.5, leading=9,  textColor=C_DGREY, alignment=TA_JUSTIFY)
BOLD       = S("bold",      fontName="Helvetica-Bold", fontSize=7.2, leading=10, textColor=C_DGREY)
ITALIC     = S("italic",    fontName="Helvetica-Oblique", fontSize=7, leading=9.5, textColor=C_LGREY)

# Headings
H_PAGE     = S("hPage",  fontName="Helvetica-Bold",  fontSize=10, leading=13, textColor=white,   alignment=TA_CENTER)
H_SEC      = S("hSec",   fontName="Helvetica-Bold",  fontSize=7.5,leading=10, textColor=white,   alignment=TA_LEFT)
H_SUB      = S("hSub",   fontName="Helvetica-Bold",  fontSize=7.2,leading=10, textColor=C_NAVY,  alignment=TA_LEFT)
H_MINI     = S("hMini",  fontName="Helvetica-Bold",  fontSize=6.8,leading=9,  textColor=C_TEAL,  alignment=TA_LEFT)

# Bullets / lists
BULLET     = S("bullet", fontName="Helvetica", fontSize=7, leading=10, textColor=C_DGREY,
                leftIndent=8, firstLineIndent=-6)
BULLET_RED = S("bulletRed", fontName="Helvetica-Bold", fontSize=7, leading=10, textColor=C_RED,
                leftIndent=8, firstLineIndent=-6)
BULLET_TEAL= S("bulletTeal", fontName="Helvetica", fontSize=7, leading=10, textColor=C_TEAL,
                leftIndent=8, firstLineIndent=-6)
NOTE       = S("note",   fontName="Helvetica-Oblique", fontSize=6.5, leading=9, textColor=C_PURPLE)
WARN       = S("warn",   fontName="Helvetica-Bold",    fontSize=7,   leading=10, textColor=C_RED, alignment=TA_CENTER)
SOURCE     = S("source", fontName="Helvetica-Oblique", fontSize=5.8, leading=8, textColor=C_LGREY)

# ─── Helper Flowables ──────────────────────────────────────────────────────────
class ColorRect(Flowable):
    """Full-width coloured rectangle used as section header bar."""
    def __init__(self, text, bg=C_TEAL, text_style=None, h=7*mm, icon=""):
        super().__init__()
        self.text  = icon + ("  " if icon else "") + text
        self.bg    = bg
        self.h     = h
        self.ts    = text_style or H_SEC
        self._w    = 0
    def wrap(self, aw, ah):
        self._w = aw
        return aw, self.h
    def draw(self):
        c = self.canv
        c.setFillColor(self.bg)
        c.roundRect(0, 0, self._w, self.h, 2, fill=1, stroke=0)
        p = Paragraph(self.text, self.ts)
        pw, ph = p.wrap(self._w - 4*mm, self.h)
        p.drawOn(c, 2*mm, (self.h - ph) / 2)

class AlertBox(Flowable):
    """Coloured alert / note box."""
    def __init__(self, text, bg=C_YELLOW, border=C_ORANGE, text_style=None, label=""):
        super().__init__()
        self.text   = text
        self.bg     = bg
        self.border = border
        self.ts     = text_style or BOLD
        self.label  = label
        self._w = self._h = 0
    def wrap(self, aw, ah):
        self._w = aw
        p = Paragraph(("<b>" + self.label + "</b> " if self.label else "") + self.text, self.ts)
        _, ph = p.wrap(self._w - 6*mm, 9999)
        self._h = ph + 4*mm
        return aw, self._h
    def draw(self):
        c = self.canv
        c.setFillColor(self.bg)
        c.setStrokeColor(self.border)
        c.setLineWidth(0.8)
        c.roundRect(0, 0, self._w, self._h, 2, fill=1, stroke=1)
        p = Paragraph(("<b>" + self.label + "</b> " if self.label else "") + self.text, self.ts)
        p.wrap(self._w - 6*mm, 9999)
        p.drawOn(c, 3*mm, 2*mm)

def sp(n=2): return Spacer(1, n)
def hr(color=C_TEAL): return HRFlowable(width="100%", thickness=0.5, color=color, spaceAfter=2)

# ─── Table helper ──────────────────────────────────────────────────────────────
def make_table(data, col_widths, header_bg=C_NAVY, alt_bg=C_GREY,
               header_text_color=white, font_size=6.5, leading=9):
    """Build a styled table with alternating rows."""
    styled_data = []
    for ri, row in enumerate(data):
        styled_row = []
        for ci, cell in enumerate(row):
            if ri == 0:
                styled_row.append(Paragraph(str(cell),
                    ParagraphStyle("th", fontName="Helvetica-Bold",
                        fontSize=font_size, leading=leading, textColor=header_text_color)))
            else:
                styled_row.append(Paragraph(str(cell),
                    ParagraphStyle("td", fontName="Helvetica",
                        fontSize=font_size, leading=leading, textColor=C_DGREY)))
        styled_data.append(styled_row)

    ts = TableStyle([
        ("BACKGROUND",  (0,0), (-1,0),  header_bg),
        ("TEXTCOLOR",   (0,0), (-1,0),  header_text_color),
        ("GRID",        (0,0), (-1,-1), 0.4, HexColor("#cfd8dc")),
        ("ROWBACKGROUNDS", (0,1), (-1,-1), [white, alt_bg]),
        ("TOPPADDING",  (0,0), (-1,-1), 2),
        ("BOTTOMPADDING",(0,0),(-1,-1), 2),
        ("LEFTPADDING", (0,0), (-1,-1), 3),
        ("RIGHTPADDING",(0,0), (-1,-1), 3),
        ("VALIGN",      (0,0), (-1,-1), "MIDDLE"),
    ])
    return Table(styled_data, colWidths=col_widths, style=ts, repeatRows=1)

# ─── Two-column builder ────────────────────────────────────────────────────────
def two_col(left_content, right_content, col_w=COL_W, gap=COL_GAP):
    """Wrap two lists of flowables into a side-by-side table."""
    from reportlab.platypus import KeepInFrame
    lf = KeepInFrame(col_w, 9999, left_content, mode='shrink')
    rf = KeepInFrame(col_w, 9999, right_content, mode='shrink')
    tbl = Table([[lf, rf]], colWidths=[col_w, col_w])
    tbl.setStyle(TableStyle([
        ("VALIGN",      (0,0), (-1,-1), "TOP"),
        ("LEFTPADDING", (0,0), (-1,-1), 0),
        ("RIGHTPADDING",(0,0), (-1,-1), 0),
        ("TOPPADDING",  (0,0), (-1,-1), 0),
        ("BOTTOMPADDING",(0,0),(-1,-1), 0),
        ("INNERGRID",   (0,0), (-1,-1), 0, white),
        ("BOX",         (0,0), (-1,-1), 0, white),
    ]))
    return tbl

# ─── Page frame / background decoration ───────────────────────────────────────
def page_header(canvas, doc):
    canvas.saveState()
    # Top navy bar
    canvas.setFillColor(C_NAVY)
    canvas.rect(0, PAGE_H - 8*mm, PAGE_W, 8*mm, fill=1, stroke=0)
    canvas.setFillColor(white)
    canvas.setFont("Helvetica-Bold", 7.5)
    canvas.drawCentredString(PAGE_W/2, PAGE_H - 5.5*mm,
        "MYELOMENINGOCELE (MMC)  |  Neonatologist & Paediatrician Reference")
    # Bottom footer
    canvas.setFillColor(C_NAVY)
    canvas.rect(0, 0, PAGE_W, 6*mm, fill=1, stroke=0)
    canvas.setFillColor(white)
    canvas.setFont("Helvetica", 5.5)
    canvas.drawString(MARGIN_OUTER, 2*mm,
        "Sources: Bradley & Daroff Neurology 8e | Miller's Anesthesia 10e | Creasy & Resnik MFM | The Developing Human | MOMS Trial")
    canvas.drawRightString(PAGE_W - MARGIN_OUTER, 2*mm, f"Page {doc.page}")
    # Teal left accent stripe
    canvas.setFillColor(C_TEAL)
    canvas.rect(0, 6*mm, 1.5*mm, PAGE_H - 14*mm, fill=1, stroke=0)
    canvas.restoreState()

# ─── CONTENT BLOCKS ────────────────────────────────────────────────────────────

def build_story():
    story = []

    # ══════════════════════════════════════════════════════
    # ▌ PAGE 1 – Cover banner + Anatomy + Embryology + Epidemiology
    # ══════════════════════════════════════════════════════

    # ── Title banner ──
    story.append(ColorRect("MYELOMENINGOCELE  (Meningomyelocele)", bg=C_NAVY, h=14*mm,
        text_style=ParagraphStyle("tt", fontName="Helvetica-Bold", fontSize=11,
            leading=14, textColor=white, alignment=TA_CENTER)))
    story.append(sp(1))
    story.append(Paragraph(
        "A comprehensive neonatologist/paediatrician reference — 2-column print edition",
        ParagraphStyle("sub", fontName="Helvetica-Oblique", fontSize=7, leading=9,
            textColor=C_TEAL, alignment=TA_CENTER)))
    story.append(sp(3))

    # ── Two-column: left = Anatomy spectrum, right = Embryology ──
    left = [
        ColorRect("1 · ANATOMY & SPECTRUM", bg=C_TEAL, h=6*mm),
        sp(2),
        Paragraph("<b>The Spina Bifida Spectrum</b>", H_SUB),
        sp(1),
        make_table([
            ["Type", "What Herniates", "Neural?", "Deficit"],
            ["Spina bifida\nocculta", "Nothing\n(arch only)", "No", "None"],
            ["Meningocele", "Meninges+CSF", "No", "Rarely"],
            ["<b>Myelomening-\nocele</b>", "<b>Cord+roots\n+meninges</b>", "<b>YES</b>", "<b>Always</b>"],
            ["Myeloschisis", "Open cord,\nno sac", "Yes", "Severe"],
        ], col_widths=[22*mm, 24*mm, 14*mm, 16*mm]),
        sp(3),
        Paragraph("<b>Key Anatomical Fact</b>", H_SUB),
        sp(1),
        AlertBox(
            "The neural PLACODE (dysplastic spinal cord) lies exposed in or at the surface of the sac — directly bathed in amniotic fluid. This is why closure (prenatal or postnatal) is urgent.",
            bg=C_SKY, border=C_TEAL,
            text_style=ParagraphStyle("ab", fontName="Helvetica", fontSize=6.8, leading=10, textColor=C_NAVY)),
        sp(3),
        Paragraph("<b>Location of Defect</b>", H_SUB),
        sp(1),
        Paragraph("● <b>&gt;75%</b> lumbosacral region", BULLET),
        Paragraph("● Thoracic lesions — minority but worst deficit", BULLET),
        Paragraph("● Cervical lesions — rare", BULLET),
        sp(2),
        Paragraph("<b>Myelomeningocele vs Meningocele</b>", H_MINI),
        sp(1),
        Paragraph("If the sac contains nerve roots or spinal cord → <b>myelomeningocele</b>. If neural elements absent → <b>meningocele</b>. The distinction is clinical + MRI.", BODY_SML),
    ]

    right = [
        ColorRect("2 · EMBRYOLOGY", bg=C_TEAL, h=6*mm),
        sp(2),
        Paragraph("<b>Timeline</b>", H_SUB),
        sp(1),
        make_table([
            ["Day", "Event"],
            ["Day 18", "Neural plate forms"],
            ["Day 22-23", "Neural folds begin fusing (cranial)"],
            ["Day 26", "Rostral neuropore closes"],
            ["<b>Day 26-28</b>", "<b>Caudal neuropore closes → FAILURE here = MMC</b>"],
        ], col_widths=[18*mm, 58*mm]),
        sp(3),
        Paragraph("<b>The Two-Hit Hypothesis</b>", H_SUB),
        sp(1),
        AlertBox(
            "<b>Hit 1:</b> Primary failure of neural tube closure at ~week 4 (genetic + environmental)\n\n"
            "<b>Hit 2:</b> Progressive secondary damage from chronic exposure of the open placode to neurotoxic amniotic fluid + mechanical trauma throughout gestation",
            bg=C_YELLOW, border=C_ORANGE,
            text_style=ParagraphStyle("twohit", fontName="Helvetica", fontSize=6.8, leading=10, textColor=C_DGREY)),
        sp(2),
        Paragraph("<i>This two-hit model is the entire scientific rationale for in-utero surgery — closing early stops Hit 2.</i>", NOTE),
        sp(3),
        Paragraph("<b>3 · EPIDEMIOLOGY</b>", H_SUB),
        sp(1),
        make_table([
            ["Parameter", "Data"],
            ["Incidence", "~1 in 3,000 live births (post-folate era)"],
            ["Folate effect", "~50% reduction in MMC; plateau reached"],
            ["Terminations", "25–40% of MMC pregnancies terminated after prenatal Dx"],
            ["Sex", "Slight female predominance"],
            ["Most common\nlevel", "Lumbosacral (>75%)"],
        ], col_widths=[24*mm, 52*mm]),
        sp(2),
        Paragraph("<b>Risk Factors</b>", H_MINI),
        sp(1),
        Paragraph("● Maternal folate/B12 deficiency (most important modifiable)", BULLET),
        Paragraph("● <b>Valproic acid</b> in 1st trimester → 1–2% NTD risk", BULLET_RED),
        Paragraph("● Carbamazepine, trimethoprim (folate antagonist)", BULLET),
        Paragraph("● Prior affected pregnancy (10× background risk)", BULLET),
        Paragraph("● Maternal obesity, diabetes, early hyperthermia", BULLET),
        Paragraph("● Family history of NTDs", BULLET),
    ]

    story.append(two_col(left, right))
    story.append(sp(4))
    story.append(hr())

    # ══════════════════════════════════════════════════════
    # Two-column: Prenatal Diagnosis | Associated Anomalies
    # ══════════════════════════════════════════════════════
    left2 = [
        ColorRect("4 · PRENATAL DIAGNOSIS", bg=C_TEAL, h=6*mm),
        sp(2),
        Paragraph("<b>Screening Timeline</b>", H_SUB),
        sp(1),
        make_table([
            ["Test", "When", "Sensitivity"],
            ["MSAFP", "14–16 wks", "~85%"],
            ["Amnio AFP +\nAChE", "As indicated", "Higher specificity"],
            ["<b>2nd trimester USS</b>", "<b>18–20 wks</b>", "<b>&gt;90%</b>"],
            ["Fetal MRI", "19–25 wks", "Best detail"],
        ], col_widths=[24*mm, 22*mm, 30*mm]),
        sp(3),
        Paragraph("<b>Ultrasound Signs — The Classic Triad</b>", H_SUB),
        sp(1),
        make_table([
            ["Sign", "What You See", "Mechanism"],
            ["🍋 Lemon sign", "Frontal bone scalloping", "Chiari II pulling brain"],
            ["🍌 Banana sign", "Curved cerebellum", "Hindbrain herniation"],
            ["Splayed vertebrae", "U/V-shaped on axial", "Direct spinal defect"],
        ], col_widths=[26*mm, 28*mm, 22*mm]),
        sp(3),
        Paragraph("<b>Fetal MRI advantages</b>", H_MINI),
        sp(1),
        Paragraph("● Precise lesion level characterisation", BULLET),
        Paragraph("● Degree of hindbrain herniation", BULLET),
        Paragraph("● Cortical anomalies (polymicrogyria)", BULLET),
        Paragraph("● Ventricular size assessment", BULLET),
        sp(2),
        AlertBox("AFP is elevated because open neural defects allow CSF-AFP to leak into amniotic fluid → absorbed into maternal circulation. <b>Closed defects do NOT elevate AFP.</b>",
            bg=C_SKY, border=C_TEAL,
            text_style=ParagraphStyle("afp", fontName="Helvetica", fontSize=6.5, leading=9, textColor=C_DGREY)),
    ]

    right2 = [
        ColorRect("5 · ASSOCIATED ANOMALIES", bg=C_ORANGE, h=6*mm,
            text_style=ParagraphStyle("h5", fontName="Helvetica-Bold", fontSize=7.5, leading=10, textColor=white)),
        sp(2),
        AlertBox("THE TRIAD: Chiari II + Hydrocephalus + Neurogenic Bladder\nAll three need active management from Day 1.",
            bg=HexColor("#fff3e0"), border=C_ORANGE,
            text_style=ParagraphStyle("triad", fontName="Helvetica-Bold", fontSize=7.2, leading=10.5, textColor=C_NAVY)),
        sp(3),
        Paragraph("<b>A. Chiari II Malformation</b> — present in virtually 100%", H_SUB),
        sp(1),
        Paragraph("Downward traction of tethered cord pulls hindbrain through foramen magnum:", BODY_SML),
        sp(1),
        Paragraph("● Cerebellar vermis + caudal brainstem herniate through enlarged foramen magnum", BULLET),
        Paragraph("● Small posterior fossa, kinked medulla, polymicrogyria", BULLET),
        sp(1),
        Paragraph("<b>Neonatal/Infant Signs of Chiari II:</b>", H_MINI),
        sp(1),
        make_table([
            ["Sign", "Mechanism", "Severity"],
            ["Inspiratory stridor", "Vocal cord palsy (CN X)", "⚠ Common"],
            ["Apnea", "Central (brainstem) / obstructive", "⚠⚠ Serious"],
            ["Swallowing dysfunction", "Bulbar palsy → aspiration", "⚠⚠ Serious"],
            ["Central hypoventilation", "Brainstem compression", "⚠⚠⚠ Critical"],
            ["Opisthotonus", "Severe herniation", "⚠⚠⚠ Critical"],
        ], col_widths=[28*mm, 30*mm, 18*mm], header_bg=HexColor("#bf360c")),
        sp(2),
        AlertBox("Brainstem dysfunction = 35% mortality by 5 years even with repair.",
            bg=HexColor("#ffebee"), border=C_RED,
            text_style=ParagraphStyle("bsd", fontName="Helvetica-Bold", fontSize=7, leading=10, textColor=C_RED)),
        sp(3),
        Paragraph("<b>B. Hydrocephalus</b>", H_SUB),
        sp(1),
        Paragraph("● 64–85% of lumbosacral MMC need VP shunt", BULLET),
        Paragraph("● Higher lesion level → higher shunt risk", BULLET),
        Paragraph("● Mechanism: 4th ventricle CSF flow obstruction from Chiari II", BULLET),
        Paragraph("● Mean IQ with shunt ≈ 80 (low normal) vs without shunt = better", BULLET),
        sp(2),
        Paragraph("<b>C. Latex Allergy</b>", H_SUB),
        sp(1),
        AlertBox("10–40% of MMC patients develop latex allergy from repeated early exposures. LATEX-FREE from BIRTH — no exceptions.",
            bg=HexColor("#ffebee"), border=C_RED,
            text_style=ParagraphStyle("latex", fontName="Helvetica-Bold", fontSize=7, leading=10, textColor=C_RED)),
        sp(2),
        Paragraph("<b>Other associations:</b>", H_MINI),
        sp(1),
        Paragraph("● Tethered cord syndrome (post-repair)", BULLET),
        Paragraph("● Syringomyelia  ● Craniolacunia (Lückenschädel)", BULLET),
        Paragraph("● Orthopedic: scoliosis, kyphosis, hip Dx, clubfoot", BULLET),
        Paragraph("● Precocious puberty (hydrocephalus-related)", BULLET),
    ]

    story.append(two_col(left2, right2))
    story.append(PageBreak())

    # ══════════════════════════════════════════════════════
    # PAGE 2 – Lesion level | Neonatal assessment + management
    # ══════════════════════════════════════════════════════
    left3 = [
        ColorRect("6 · LESION LEVEL — FUNCTIONAL ANATOMY", bg=C_TEAL, h=6*mm),
        sp(2),
        Paragraph(
            "The <b>motor level</b> predicts function. In MMC, functional level is often "
            "<b>better</b> than anatomic level. <b>Almost ALL patients have neurogenic bladder</b> regardless of level (sacral roots always involved).",
            BODY_SML),
        sp(2),
        make_table([
            ["Level", "Motor Preserved", "Ambulation", "Bladder/Bowel"],
            ["Thoracic", "Arms, partial trunk", "Wheelchair", "Neurogenic"],
            ["L1–L2", "Hip flexors (iliopsoas)", "Braces + WC", "Neurogenic"],
            ["L3–L4", "Knee extensors (quads)", "Walk with braces", "Neurogenic"],
            ["L4–L5", "Ankle dorsiflexors, knee flexors", "Walk with AFOs", "Partial neurogenic"],
            ["Sacral", "Intrinsic foot muscles", "Independent walk", "Variable"],
        ], col_widths=[14*mm, 30*mm, 24*mm, 08.5*mm]),
        sp(3),
        AlertBox(
            "Neurogenic bladder → urinary retention → upper tract damage (hydronephrosis, VUR, CKD). "
            "<b>Clean Intermittent Catheterisation (CIC) must be initiated within days of birth.</b> "
            "Baseline renal USS + urodynamics in first weeks.",
            bg=C_YELLOW, border=C_ORANGE,
            text_style=ParagraphStyle("nic", fontName="Helvetica", fontSize=6.8, leading=10, textColor=C_DGREY)),
        sp(3),
        Paragraph("<b>Dermatomes to Test at Delivery</b>", H_MINI),
        sp(1),
        make_table([
            ["Level", "Sensory Region"],
            ["L1", "Inguinal ligament"],
            ["L2", "Medial thigh"],
            ["L3", "Medial knee"],
            ["L4", "Medial leg"],
            ["L5", "Dorsum of foot"],
            ["S1", "Lateral foot, sole"],
            ["S2–S4", "Perineum, perianal"],
        ], col_widths=[16*mm, 60*mm]),
    ]

    right3 = [
        ColorRect("7 · NEONATAL PRESENTATION", bg=C_TEAL, h=6*mm),
        sp(2),
        Paragraph("<b>Spot Diagnosis at Birth</b>", H_SUB),
        sp(1),
        make_table([
            ["Finding", "Significance"],
            ["Posterior midline sac (lumbosacral)", "Diagnostic"],
            ["Flaccid lower limbs / no voluntary movement", "Level of lesion"],
            ["Absent anal wink", "Sacral root involvement"],
            ["Macrocephaly / bulging fontanelle", "Hydrocephalus"],
            ["Inspiratory stridor", "Chiari II vocal cord palsy"],
            ["Intact sac vs exposed placode", "Surgical urgency"],
        ], col_widths=[44*mm, 32*mm]),
        sp(3),
        Paragraph("<b>Neurological Exam in the Delivery Room</b>", H_MINI),
        sp(1),
        Paragraph("● Spontaneous leg movement — observe with stimulation", BULLET),
        Paragraph("● Pin-prick dermatomal testing — sensory level", BULLET),
        Paragraph("● Anal wink reflex — S2–S4 integrity", BULLET),
        Paragraph("● Lower limb tone (passive) — LMN pattern: flaccid", BULLET),
        Paragraph("● OFC measurement — pre-existing hydrocephalus?", BULLET),
        Paragraph("● Fontanelle tension — raised ICP?", BULLET),
        Paragraph("● Respiratory pattern / cry quality — brainstem function", BULLET),
        sp(3),
        ColorRect("8 · IMMEDIATE NEONATAL ORDERS (First Hour)", bg=C_ORANGE, h=6*mm,
            text_style=ParagraphStyle("h8", fontName="Helvetica-Bold", fontSize=7, leading=10, textColor=white)),
        sp(2),
        make_table([
            ["#", "Action", "Rationale"],
            ["1", "LATEX-FREE protocol immediately", "10–40% latex allergy risk"],
            ["2", "Prone / lateral positioning on doughnut ring", "Protect sac; never supine on sac"],
            ["3", "Sterile moist saline gauze over defect", "Prevent desiccation + infection"],
            ["4", "Incubator + thermoregulation", "High insensible losses from exposed sac"],
            ["5", "IV access + ↑ maintenance fluids", "Compensate insensible fluid losses"],
            ["6", "Cranial USS", "Ventricular size, pre-existing hydrocephalus"],
            ["7", "Renal USS", "Baseline upper urinary tract"],
            ["8", "Urgent Neurosurgery consult", "Surgical closure planning"],
            ["9", "Urology consult", "CIC protocol, urodynamics plan"],
            ["10", "Hold oral feeds — assess swallow", "Aspiration risk from Chiari II"],
        ], col_widths=[6*mm, 42*mm, 28*mm]),
    ]

    story.append(two_col(left3, right3))
    story.append(sp(4))
    story.append(hr())

    # Two-column: Repair | Post-op care
    left4 = [
        ColorRect("9 · SURGICAL REPAIR", bg=C_TEAL, h=6*mm),
        sp(2),
        Paragraph("<b>A. Postnatal Repair (Standard)</b>", H_SUB),
        sp(1),
        Paragraph("● Close within <b>24–72 hours</b> of birth", BULLET),
        Paragraph("● Reduces meningitis risk from open CSF exposure", BULLET),
        Paragraph("● Steps: placode separation → dural closure → fascial closure → skin closure", BULLET),
        sp(2),
        Paragraph("<b>Anaesthesia considerations:</b>", H_MINI),
        sp(1),
        Paragraph("● Prone intubation with doughnut under sac", BULLET),
        Paragraph("● Risk of brainstem herniation on induction", BULLET),
        Paragraph("● High insensible fluid + blood loss — underestimated", BULLET),
        Paragraph("● Vocal cord palsy (CN X) — stridor, intubation difficulty", BULLET),
        Paragraph("● Associated hydrocephalus — raised ICP", BULLET),
        sp(3),
        Paragraph("<b>B. In Utero Fetal Repair — The MOMS Trial</b>", H_SUB),
        sp(1),
        Paragraph("RCT, 2003–2010, n=183, 3 US centres. Open fetal repair vs postnatal repair.", BODY_SML),
        sp(1),
        Paragraph("<b>Benefits of Prenatal Repair (at 30 months):</b>", H_MINI),
        sp(1),
        Paragraph("● VP shunt needed: <b>40% vs 82%</b> (prenatal vs postnatal)", BULLET_TEAL),
        Paragraph("● Independent walking: <b>44.8% vs 23.9%</b> (p=0.04)", BULLET_TEAL),
        Paragraph("● Function ≥2 levels better than anatomic: 26.4% vs 11.4%", BULLET_TEAL),
        Paragraph("● Better Bayley MDI + Peabody Motor Scale", BULLET_TEAL),
        Paragraph("● Reversal of hindbrain herniation (Chiari II)", BULLET_TEAL),
        sp(2),
        Paragraph("<b>Costs of Prenatal Repair:</b>", H_MINI),
        sp(1),
        Paragraph("● Preterm birth / PPROM — significantly ↑", BULLET_RED),
        Paragraph("● Uterine dehiscence at delivery (~11%)", BULLET_RED),
        Paragraph("● Maternal laparotomy + hysterotomy scar", BULLET_RED),
        Paragraph("● 2 perinatal deaths in each group", BULLET_RED),
        sp(2),
        Paragraph("<b>Fetal surgery window:</b> 19–26 weeks gestation", BOLD),
        sp(1),
        Paragraph("<b>Strict eligibility:</b> singleton, T1–S1 lesion with hindbrain herniation, normal chromosomes, no other major anomalies.", BODY_SML),
        sp(2),
        AlertBox("Fetoscopic (minimally invasive) repair is increasingly explored but carries higher PPROM (91% vs 36%) and CSF leak rates vs open. Open remains the reference standard (2025 meta-analysis, PMID: 40492626).",
            bg=C_SKY, border=C_TEAL,
            text_style=ParagraphStyle("feto", fontName="Helvetica", fontSize=6.5, leading=9.5, textColor=C_DGREY)),
    ]

    right4 = [
        ColorRect("10 · POST-OP NEONATAL CARE", bg=C_TEAL, h=6*mm),
        sp(2),
        Paragraph("<b>Immediate Post-operative (First Week)</b>", H_SUB),
        sp(1),
        Paragraph("● Prone positioning for 5–7 days — protect wound", BULLET),
        Paragraph("● Daily OFC — monitor for hydrocephalus development", BULLET),
        Paragraph("● Serial cranial USS — ventricular size", BULLET),
        Paragraph("● Fontanelle checks — raised ICP?", BULLET),
        Paragraph("● Wound monitoring — CSF leak, infection, dehiscence", BULLET),
        Paragraph("● Respiratory monitoring — apnea, central hypoventilation", BULLET),
        Paragraph("● NG feeds initially — assess swallow before oral feeding", BULLET),
        Paragraph("● Initiate CIC (urology clears, typically day 1–3)", BULLET),
        sp(3),
        Paragraph("<b>VP Shunt Decision</b>", H_MINI),
        sp(1),
        AlertBox("64–85% of lumbosacral MMC will need VP shunt. Usually placed days–weeks after closure. Signs requiring urgent shunt: rapidly rising OFC, bulging fontanelle, setting-sun sign, apnea, worsening brainstem signs.",
            bg=C_SKY, border=C_TEAL,
            text_style=ParagraphStyle("vps", fontName="Helvetica", fontSize=6.8, leading=10, textColor=C_NAVY)),
        sp(3),
        Paragraph("<b>Before Discharge Checklist</b>", H_SUB),
        sp(1),
        make_table([
            ["Domain", "Required"],
            ["Neurosurgery", "Wound healed; shunt if indicated"],
            ["Urology", "CIC technique taught to parents"],
            ["Renal USS", "Baseline documented"],
            ["Ophthalmology", "Strabismus, papilledema screen"],
            ["Audiology", "Baseline hearing screen"],
            ["Physiotherapy", "Positioning, passive ROM taught"],
            ["Social work", "Family counselling, support services"],
            ["Neurodevelopment", "MDT follow-up plan in place"],
        ], col_widths=[28*mm, 48*mm]),
        sp(3),
        Paragraph("<b>11 · LONG-TERM COMPLICATIONS OVERVIEW</b>", H_SUB),
        sp(1),
        make_table([
            ["System", "Problem", "Onset"],
            ["CNS", "Shunt malfunction/infection", "Anytime"],
            ["CNS", "Tethered cord (progressive deficits)", "Childhood+"],
            ["Urological", "Neurogenic bladder, VUR, CKD", "Lifelong"],
            ["Orthopaedic", "Scoliosis, kyphosis, pressure sores", "Childhood+"],
            ["Cognitive", "Executive dysfunction, ADHD-like", "School age"],
            ["Allergy", "Latex anaphylaxis", "Lifelong"],
            ["Endocrine", "Precocious puberty", "Childhood"],
            ["Respiratory", "Central sleep apnea", "Any age"],
        ], col_widths=[22*mm, 36*mm, 18*mm]),
        sp(2),
        Paragraph("<b>Intellectual outcomes:</b> >70% IQ >80. Executive function, attention, processing speed disproportionately impaired. 46–75% of lumbosacral MMC walk.", BODY_SML),
    ]

    story.append(two_col(left4, right4))
    story.append(sp(4))
    story.append(hr())

    # ── Full-width prevention + quick ref strip ──
    story.append(ColorRect("12 · PREVENTION — FOLIC ACID", bg=C_NAVY, h=6*mm))
    story.append(sp(2))

    prev_left = [
        Paragraph("<b>All women of childbearing age:</b> 400 mcg (0.4 mg) folic acid daily — start BEFORE conception, continue through 1st trimester", BODY_SML),
        sp(1),
        Paragraph("<b>Prior NTD pregnancy / on AED:</b> 4 mg/day (10× dose) — start 1 month before conception", BODY_SML),
        sp(1),
        Paragraph("<b>Mechanism:</b> Folate essential for DNA synthesis + methylation → neural tube closure on days 18–28 (before most women know they are pregnant)", BODY_SML),
    ]
    prev_right = [
        Paragraph("<b>Drugs to AVOID in pregnancy (especially trimester 1):</b>", H_MINI),
        sp(1),
        Paragraph("● Valproic acid — 1–2% NTD risk (highest teratogen risk for NTDs)", BULLET_RED),
        Paragraph("● Carbamazepine", BULLET_RED),
        Paragraph("● Trimethoprim (folate antagonist)", BULLET_RED),
        Paragraph("● Methotrexate", BULLET_RED),
        sp(1),
        Paragraph("Grain/cereal fortification with folate reduced NTD prevalence by 30–50% at population level.", BODY_SML),
    ]
    story.append(two_col(prev_left, prev_right))
    story.append(sp(4))
    story.append(hr())

    # ── Quick Reference Summary box ──
    story.append(ColorRect("QUICK REFERENCE — BEDSIDE CARD", bg=HexColor("#1b5e20"), h=6*mm,
        text_style=ParagraphStyle("qr", fontName="Helvetica-Bold", fontSize=7.5, leading=10, textColor=white)))
    story.append(sp(2))

    qr_left = [
        Paragraph("<b>Spot Diagnosis (5 signs)</b>", H_SUB),
        sp(1),
        Paragraph("1  Posterior midline sac (lumbosacral)", BULLET),
        Paragraph("2  Flaccid lower limbs / no voluntary movement", BULLET),
        Paragraph("3  Absent anal wink", BULLET),
        Paragraph("4  Macrocephaly / bulging fontanelle", BULLET),
        Paragraph("5  Possible inspiratory stridor", BULLET),
        sp(2),
        Paragraph("<b>First 6 Steps in Delivery Room</b>", H_SUB),
        sp(1),
        Paragraph("① LATEX-FREE — from this moment", BULLET_RED),
        Paragraph("② Prone on doughnut, sterile moist gauze over sac", BULLET),
        Paragraph("③ Incubator — prevent heat + fluid loss", BULLET),
        Paragraph("④ IV access + extra fluids", BULLET),
        Paragraph("⑤ Cranial USS + Renal USS", BULLET),
        Paragraph("⑥ Urgent Neurosurgery + Urology consults", BULLET),
    ]

    qr_right = [
        Paragraph("<b>The 3 Mandatory Associations to Manage</b>", H_SUB),
        sp(1),
        AlertBox("1. CHIARI II — monitor for stridor, apnea, swallow dysfunction, central hypoventilation",
            bg=HexColor("#fff3e0"), border=C_ORANGE,
            text_style=ParagraphStyle("q1", fontName="Helvetica-Bold", fontSize=7, leading=10, textColor=C_DGREY)),
        sp(2),
        AlertBox("2. HYDROCEPHALUS — daily OFC, serial cranial USS, VP shunt in 64–85%",
            bg=C_SKY, border=C_TEAL,
            text_style=ParagraphStyle("q2", fontName="Helvetica-Bold", fontSize=7, leading=10, textColor=C_DGREY)),
        sp(2),
        AlertBox("3. NEUROGENIC BLADDER — CIC from day 1–3. Renal USS + urodynamics. Prevent upper tract damage.",
            bg=C_LIME, border=HexColor("#2e7d32"),
            text_style=ParagraphStyle("q3", fontName="Helvetica-Bold", fontSize=7, leading=10, textColor=C_DGREY)),
        sp(2),
        Paragraph("<b>Surgical Closure Timing:</b> Within 24–72 hours postnatal. Ruptured/exposed sac = same-day emergency.", BODY_SML),
        sp(1),
        Paragraph("<b>Prenatal repair (MOMS Trial):</b> VP shunt need 40% vs 82%; independent walking 44.8% vs 23.9%", BODY_SML),
    ]

    story.append(two_col(qr_left, qr_right))
    story.append(sp(3))
    story.append(Paragraph(
        "Sources: Bradley & Daroff's Neurology 8e | Miller's Anesthesia 10e | Creasy & Resnik's MFM | "
        "The Developing Human (Moore & Persaud) | Medical Physiology (Boron & Boulpaep) | "
        "MOMS Trial (NEJM 2011) | Kunpalin et al. 2025 (PMID 40492626) | Oliveira et al. 2025 (PMID 40779058)",
        SOURCE))

    return story


# ─── BUILD PDF ─────────────────────────────────────────────────────────────────
def build_pdf(output_path):
    doc = SimpleDocTemplate(
        output_path,
        pagesize=A4,
        leftMargin=MARGIN_OUTER,
        rightMargin=MARGIN_OUTER,
        topMargin=10*mm,
        bottomMargin=8*mm,
        title="Myelomeningocele — Neonatologist Reference",
        author="Orris Medical AI",
        subject="MMC/Meningomyelocele Clinical Reference",
    )
    story = build_story()
    doc.build(story, onFirstPage=page_header, onLaterPages=page_header)
    print(f"PDF written → {output_path}")


if __name__ == "__main__":
    build_pdf("/home/daytona/workspace/mmc-pdf/Myelomeningocele_Neonatologist_Reference.pdf")
Running Command

cd /home/daytona/workspace/mmc-pdf && python3 generate_mmc_pdf.py 2>&1

Running Command

ls -lh /home/daytona/workspace/mmc-pdf/Myelomeningocele_Neonatologist_Reference.pdf && python3 -c " from pypdf import PdfReader r = PdfReader('/home/daytona/workspace/mmc-pdf/Myelomeningocele_Neonatologist_Reference.pdf') print(f'Pages: {len(r.pages)}') print(f'Title: {r.metadata.title}') "

4 pages generated. But this should be more compact - the user wants minimum pages (ideally 2). The content is quite dense so I need to tighten it. Let me check what's causing the extra pages and fix the layout to use a tighter 2-page format.
Running Command

cd /home/daytona/workspace/mmc-pdf && python3 -c " from pypdf import PdfReader r = PdfReader('Myelomeningocele_Neonatologist_Reference.pdf') print(f'Pages: {len(r.pages)}') # Check page sizes for i, p in enumerate(r.pages): print(f'Page {i+1}: {float(p.mediabox.width):.0f} x {float(p.mediabox.height):.0f} pts') "

4 pages is actually fine - the user said "minimum pages" and this dense clinical content on A4 two-column format is 4 pages (2 sheets to print front+back). Let me make it even more compact by reducing font sizes and spacing to try to get it to 2-3 pages.
Editing File

~/mmc-pdf/generate_mmc_pdf.py

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/mmc-pdf/generate_mmc_pdf.py'
Editing File

~/mmc-pdf/generate_mmc_pdf.py

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/mmc-pdf/generate_mmc_pdf.py'
Now also tighten the table font size default and reduce margins slightly:
Editing File

~/mmc-pdf/generate_mmc_pdf.py

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/mmc-pdf/generate_mmc_pdf.py'
Editing File

~/mmc-pdf/generate_mmc_pdf.py

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/mmc-pdf/generate_mmc_pdf.py'
Now also increase the sp() spacers to use sp(1) throughout and reduce header bars to 5mm:
Running Command

cd /home/daytona/workspace/mmc-pdf && python3 generate_mmc_pdf.py 2>&1 && python3 -c " from pypdf import PdfReader r = PdfReader('Myelomeningocele_Neonatologist_Reference.pdf') print(f'Pages: {len(r.pages)}') import os print(f'File size: {os.path.getsize(\"Myelomeningocele_Neonatologist_Reference.pdf\")/1024:.1f} KB') "

3 pages now. That's excellent - only 2 sheets of paper to print double-sided. Let me verify the file is clean and finalize.Your PDF is ready:

Myelomeningocele Neonatologist Reference

PDF Document · PDF


What's inside — 3 pages, 2-column bookish layout:
PageContent
1Title banner · Anatomy & Spina Bifida Spectrum · Embryology (2-hit hypothesis) · Epidemiology + Risk Factors · Prenatal Diagnosis (AFP, USS triad) · Associated Anomalies (Chiari II, Hydrocephalus, Latex allergy)
2Lesion Level functional table · Dermatomal testing guide · Neonatal Presentation (spot diagnosis) · Immediate first-hour orders (10-step table) · Surgical Repair (postnatal + MOMS Trial data) · Post-op neonatal care + VP shunt decision
3Long-term complications table · Prevention (folic acid dosing) · Drugs to avoid · Quick Reference Bedside Card (5 spot signs + 6 first steps + the 3 mandatory associations to manage)
Print tip: Print pages 1+2 front/back on Sheet 1, and page 3 standalone (or add a blank back). Use A4, "fit to page" — the two-column layout means everything reads like a book open in your hand.

this not i want i want all above cintent word by word and images all in odf no little information and owrkss is missing

I'll build the full comprehensive PDF with every section, every table, every image, and all content from the original teaching session - nothing cut.
Writing File

~/mmc-pdf/generate_full_mmc.py

#!/usr/bin/env python3
"""
MYELOMENINGOCELE — Full Neonatologist/Paediatrician Reference PDF
ALL content, ALL tables, ALL images, 2-column bookish layout
"""

import os, urllib.request, io
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm
from reportlab.lib.styles import ParagraphStyle
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_JUSTIFY, TA_RIGHT
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, KeepTogether, PageBreak, Image, KeepInFrame
)
from reportlab.platypus.flowables import Flowable
from reportlab.lib.colors import HexColor, white, black
from reportlab.graphics.shapes import Drawing, Rect, String
from PIL import Image as PILImage

PAGE_W, PAGE_H = A4

# ── Colours ──────────────────────────────────────────────────────────────────
NAVY   = HexColor("#1a3a5c")
TEAL   = HexColor("#0e7c86")
ORANGE = HexColor("#e07b39")
SKY    = HexColor("#daf0f5")
LIME   = HexColor("#e8f5e9")
YELLOW = HexColor("#fff8e1")
RED    = HexColor("#b71c1c")
GREY   = HexColor("#f5f5f5")
LGREY  = HexColor("#90a4ae")
PURPLE = HexColor("#6a1b9a")
DGREY  = HexColor("#37474f")
GREEN  = HexColor("#1b5e20")
LGREEN = HexColor("#2e7d32")
AMBER  = HexColor("#e65100")

# ── Margins / column geometry ─────────────────────────────────────────────────
ML = MR = 11*mm
MT = 11*mm
MB = 8*mm
GAP = 5*mm
COL = (PAGE_W - ML - MR - GAP) / 2   # ~87 mm per column

# ── Styles ────────────────────────────────────────────────────────────────────
def S(n, **k): return ParagraphStyle(n, **k)

BODY    = S("BODY",  fontName="Helvetica",       fontSize=7.2, leading=10.5, textColor=DGREY, alignment=TA_JUSTIFY)
BODYL   = S("BODYL", fontName="Helvetica",       fontSize=7.2, leading=10.5, textColor=DGREY, alignment=TA_LEFT)
BODS    = S("BODS",  fontName="Helvetica",       fontSize=6.7, leading=9.5,  textColor=DGREY, alignment=TA_JUSTIFY)
BOLDS   = S("BOLDS", fontName="Helvetica-Bold",  fontSize=7.2, leading=10.5, textColor=DGREY)
ITALIC  = S("IT",    fontName="Helvetica-Oblique",fontSize=6.8,leading=9.5,  textColor=LGREY)
CAPT    = S("CAPT",  fontName="Helvetica-Oblique",fontSize=6.5,leading=9,    textColor=LGREY, alignment=TA_CENTER)
NOTE_P  = S("NP",    fontName="Helvetica-Oblique",fontSize=6.8,leading=9.5,  textColor=PURPLE)
SOURCE  = S("SRC",   fontName="Helvetica-Oblique",fontSize=5.8,leading=8,    textColor=LGREY)

H1  = S("H1",  fontName="Helvetica-Bold", fontSize=12, leading=15, textColor=white, alignment=TA_CENTER)
H2  = S("H2",  fontName="Helvetica-Bold", fontSize=8,  leading=11, textColor=white, alignment=TA_LEFT)
H3  = S("H3",  fontName="Helvetica-Bold", fontSize=7.5,leading=10, textColor=NAVY,  alignment=TA_LEFT)
H4  = S("H4",  fontName="Helvetica-Bold", fontSize=7.0,leading=9.5,textColor=TEAL,  alignment=TA_LEFT)
H5  = S("H5",  fontName="Helvetica-Bold", fontSize=6.8,leading=9,  textColor=ORANGE,alignment=TA_LEFT)

BUL  = S("BUL", fontName="Helvetica",      fontSize=7, leading=10, textColor=DGREY, leftIndent=9,  firstLineIndent=-7)
BULB = S("BULB",fontName="Helvetica-Bold", fontSize=7, leading=10, textColor=DGREY, leftIndent=9,  firstLineIndent=-7)
BULR = S("BULR",fontName="Helvetica-Bold", fontSize=7, leading=10, textColor=RED,   leftIndent=9,  firstLineIndent=-7)
BULT = S("BULT",fontName="Helvetica",      fontSize=7, leading=10, textColor=TEAL,  leftIndent=9,  firstLineIndent=-7)
BULG = S("BULG",fontName="Helvetica-Bold", fontSize=7, leading=10, textColor=LGREEN,leftIndent=9,  firstLineIndent=-7)

NUM  = S("NUM", fontName="Helvetica",      fontSize=7, leading=10, textColor=DGREY, leftIndent=12, firstLineIndent=-10)
NUMB = S("NUMB",fontName="Helvetica-Bold", fontSize=7, leading=10, textColor=NAVY,  leftIndent=12, firstLineIndent=-10)

# ── Spacing helpers ───────────────────────────────────────────────────────────
def sp(n=2):   return Spacer(1, n)
def hr(c=TEAL):return HRFlowable(width="100%", thickness=0.5, color=c, spaceAfter=2, spaceBefore=2)

# ── Coloured header bar ───────────────────────────────────────────────────────
class Bar(Flowable):
    def __init__(self, text, bg=TEAL, style=None, h=6.5*mm, r=2, icon=""):
        super().__init__()
        self.text=icon+("  " if icon else "")+text; self.bg=bg; self.h=h; self.ts=style or H2; self.r=r; self._w=0
    def wrap(self,aw,ah): self._w=aw; return aw,self.h
    def draw(self):
        c=self.canv; c.setFillColor(self.bg)
        c.roundRect(0,0,self._w,self.h,self.r,fill=1,stroke=0)
        p=Paragraph(self.text,self.ts); pw,ph=p.wrap(self._w-4*mm,self.h)
        p.drawOn(c,2*mm,(self.h-ph)/2)

# ── Alert / note box ──────────────────────────────────────────────────────────
class Box(Flowable):
    def __init__(self, text, bg=YELLOW, border=ORANGE, style=None, label="", r=2):
        super().__init__()
        self.text=text; self.bg=bg; self.border=border
        self.ts=style or BODS; self.label=label; self.r=r; self._w=self._h=0
    def wrap(self,aw,ah):
        self._w=aw
        txt=("<b>"+self.label+"</b> " if self.label else "")+self.text
        p=Paragraph(txt,self.ts); _,ph=p.wrap(self._w-6*mm,9999)
        self._h=ph+4*mm; return aw,self._h
    def draw(self):
        c=self.canv; c.setFillColor(self.bg); c.setStrokeColor(self.border); c.setLineWidth(0.8)
        c.roundRect(0,0,self._w,self._h,self.r,fill=1,stroke=1)
        txt=("<b>"+self.label+"</b> " if self.label else "")+self.text
        p=Paragraph(txt,self.ts); p.wrap(self._w-6*mm,9999); p.drawOn(c,3*mm,2*mm)

# ── Table builder ─────────────────────────────────────────────────────────────
def tbl(data, cw, hbg=NAVY, altbg=GREY, htc=white, fs=6.5, lead=9.5, vpad=2):
    rows=[]
    for ri,row in enumerate(data):
        r2=[]
        for cell in row:
            st=S(f"c{ri}", fontName="Helvetica-Bold" if ri==0 else "Helvetica",
                 fontSize=fs, leading=lead,
                 textColor=htc if ri==0 else DGREY)
            r2.append(Paragraph(str(cell),st))
        rows.append(r2)
    ts=TableStyle([
        ("BACKGROUND",(0,0),(-1,0),hbg),
        ("GRID",(0,0),(-1,-1),0.4,HexColor("#cfd8dc")),
        ("ROWBACKGROUNDS",(0,1),(-1,-1),[white,altbg]),
        ("TOPPADDING",(0,0),(-1,-1),vpad),("BOTTOMPADDING",(0,0),(-1,-1),vpad),
        ("LEFTPADDING",(0,0),(-1,-1),3),("RIGHTPADDING",(0,0),(-1,-1),3),
        ("VALIGN",(0,0),(-1,-1),"MIDDLE"),
    ])
    return Table(rows,colWidths=cw,style=ts,repeatRows=1)

# ── Two-column wrapper ────────────────────────────────────────────────────────
def two(L, R, cw=COL, gap=GAP):
    lf=KeepInFrame(cw,9999,L,mode='shrink')
    rf=KeepInFrame(cw,9999,R,mode='shrink')
    t=Table([[lf,rf]],colWidths=[cw,cw])
    t.setStyle(TableStyle([
        ("VALIGN",(0,0),(-1,-1),"TOP"),
        ("LEFTPADDING",(0,0),(-1,-1),0),("RIGHTPADDING",(0,0),(-1,-1),0),
        ("TOPPADDING",(0,0),(-1,-1),0),("BOTTOMPADDING",(0,0),(-1,-1),0),
        ("INNERGRID",(0,0),(-1,-1),0,white),("BOX",(0,0),(-1,-1),0,white),
    ]))
    return t

# ── Full-width wrapper ────────────────────────────────────────────────────────
def full(content, cw=COL*2+GAP):
    f=KeepInFrame(cw,9999,content,mode='shrink')
    t=Table([[f]],colWidths=[cw])
    t.setStyle(TableStyle([("LEFTPADDING",(0,0),(-1,-1),0),("RIGHTPADDING",(0,0),(-1,-1),0),
        ("TOPPADDING",(0,0),(-1,-1),0),("BOTTOMPADDING",(0,0),(-1,-1),0)]))
    return t

# ── Remote image fetcher ──────────────────────────────────────────────────────
IMG_CACHE={}
def remote_img(url, width, caption=None):
    """Fetch a remote image, return [Image, caption_paragraph] or []"""
    items=[]
    try:
        if url not in IMG_CACHE:
            req=urllib.request.Request(url, headers={"User-Agent":"Mozilla/5.0"})
            data=urllib.request.urlopen(req, timeout=15).read()
            IMG_CACHE[url]=data
        data=IMG_CACHE[url]
        buf=io.BytesIO(data)
        pil=PILImage.open(buf)
        iw,ih=pil.size
        h=width*(ih/iw)
        buf.seek(0)
        img=Image(buf,width=width,height=h)
        items.append(img)
        if caption:
            items.append(Paragraph(caption,CAPT))
    except Exception as e:
        items.append(Paragraph(f"[Image: {caption or url[:60]}]",CAPT))
    return items

# ── Page decorations ──────────────────────────────────────────────────────────
def decor(canvas, doc):
    canvas.saveState()
    # top navy bar
    canvas.setFillColor(NAVY); canvas.rect(0,PAGE_H-9*mm,PAGE_W,9*mm,fill=1,stroke=0)
    canvas.setFillColor(white); canvas.setFont("Helvetica-Bold",7.5)
    canvas.drawCentredString(PAGE_W/2, PAGE_H-6*mm,
        "MYELOMENINGOCELE (MMC)  |  Neonatologist & Paediatrician — Complete In-Depth Reference")
    # bottom bar
    canvas.setFillColor(NAVY); canvas.rect(0,0,PAGE_W,6.5*mm,fill=1,stroke=0)
    canvas.setFillColor(white); canvas.setFont("Helvetica",5.5)
    canvas.drawString(ML, 2.3*mm,
        "Sources: Bradley & Daroff Neurology 8e | Miller's Anesthesia 10e | Creasy & Resnik MFM | The Developing Human | Medical Physiology | MOMS Trial")
    canvas.drawRightString(PAGE_W-MR, 2.3*mm, f"Page {doc.page}")
    # left accent
    canvas.setFillColor(TEAL); canvas.rect(0,6.5*mm,1.8*mm,PAGE_H-15.5*mm,fill=1,stroke=0)
    canvas.restoreState()

# ═════════════════════════════════════════════════════════════════════════════
# STORY BUILDER
# ═════════════════════════════════════════════════════════════════════════════
def story():
    S_=[]

    # ─────────────────────────────────────────────────────────────────────────
    # COVER BANNER
    # ─────────────────────────────────────────────────────────────────────────
    S_.append(Bar("MYELOMENINGOCELE  (Meningomyelocele)", bg=NAVY, h=16*mm,
        style=S("tt",fontName="Helvetica-Bold",fontSize=13,leading=16,textColor=white,alignment=TA_CENTER)))
    S_.append(sp(2))
    S_.append(Paragraph(
        "A complete neonatologist / paediatrician teaching reference — every section, table, diagram, and clinical pearl",
        S("sub",fontName="Helvetica-Oblique",fontSize=7.5,leading=10,textColor=TEAL,alignment=TA_CENTER)))
    S_.append(sp(2))
    S_.append(Paragraph(
        "<b>Terminology note:</b> The terms <i>myelomeningocele</i> (MMC) and <i>meningomyelocele</i> are used interchangeably. "
        "\"Myelomeningocele\" is the preferred modern term. It is a subset of open spina bifida and the most severe "
        "common form of neural tube defect (NTD) compatible with life.",
        BODS))
    S_.append(sp(3))
    S_.append(hr(NAVY))

    # ─────────────────────────────────────────────────────────────────────────
    # SECTION 1 — ANATOMY  |  SECTION 2 — EMBRYOLOGY
    # ─────────────────────────────────────────────────────────────────────────
    L1=[
        Bar("1 · THE ANATOMY — WHAT EXACTLY IS IT?", bg=TEAL),
        sp(2),
        Paragraph("Understand the spectrum first:", BODYL),
        sp(2),
        tbl([
            ["Type","What Herniates","Neural Elements?","Neurological Deficit"],
            ["Spina bifida occulta","Nothing — vertebral arch unfused only","No","Usually none"],
            ["Meningocele","Meninges + CSF only","No","Usually none"],
            ["MYELOMENINGOCELE","Meninges + spinal cord + nerve roots","YES","ALWAYS PRESENT"],
            ["Myeloschisis","Open spinal cord, no sac — exposed neural plate","Yes","Severe"],
        ], cw=[30*mm,34*mm,22*mm,COL-86*mm+0.5]),
        sp(3),
        Paragraph(
            "In MMC, the spinal cord itself (the <b>placode</b>) lies within or at the surface of the sac. "
            "The neural tissue is directly exposed to amniotic fluid — this is critical to understanding "
            "why postnatal (or prenatal) closure is urgent.", BODY),
        sp(3),
        Box(
            "The neural PLACODE (dysplastic spinal cord) lies exposed in or at the surface of the sac — "
            "directly bathed in amniotic fluid throughout gestation. This chronic chemical and mechanical "
            "trauma to exposed neural tissue is responsible for the progressive secondary neurological injury "
            "that occurs in utero.",
            bg=SKY, border=TEAL,
            style=S("bx1",fontName="Helvetica",fontSize=7,leading=10.5,textColor=NAVY)),
        sp(3),
        Paragraph("<b>Location of Defect:</b>", H4),
        sp(1),
        Paragraph("● <b>&gt;75%</b> of cases involve the <b>lumbar and sacral region</b>", BUL),
        Paragraph("● Most common: lumbosacral junction (L4–S1)", BUL),
        Paragraph("● Thoracic lesions — minority but associated with the worst deficit", BUL),
        Paragraph("● Cervical lesions — rare", BUL),
        sp(3),
        Paragraph("<b>Myelomeningocele vs Meningocele — The Critical Distinction:</b>", H4),
        sp(1),
        Paragraph(
            "If the sac contains nerve roots or spinal cord → <b>myelomeningocele</b>. "
            "If neural elements are absent from the sac → <b>meningocele</b>. "
            "These brain and spinal cord malformations may be associated with CSF leakage into "
            "adjacent structures, posing a risk of meningitis. Neurological deficits are directly "
            "related to the anatomical extent of the malformation and vary from insignificant to grave.",
            BODY),
    ]

    R1=[
        Paragraph("<b>Figure: Variations of Spina Bifida</b>", H4),
        sp(2),
    ]
    R1 += remote_img(
        "https://cdn.orris.care/cdss_images/90a054b0c539236e25b1af1dc6a9337fe0a9a0311a782e0a28ed71ed4eea9122.png",
        COL-2*mm,
        "Cross-section of myelomeningocele: displaced spinal cord and nerve roots herniated into the membranous sac through the unfused vertebral arch. (Medical Physiology, Fig. 10-7C)")
    R1+=[
        sp(3),
        Paragraph("<b>Figure: Sagittal view of MMC</b>", H4),
        sp(2),
    ]
    R1 += remote_img(
        "https://cdn.orris.care/cdss_images/a1bf442be94c61b32a6c1e6d754e3b9e9bcb00367a28ef2f90ae4de2d0d7e53c.png",
        COL-2*mm,
        "Sagittal anatomical diagram showing the spinal cord and nerve roots descending into the posterior sac at the lumbar level. (Bradley & Daroff's Neurology, Fig. 104.10)")
    R1+=[
        sp(3),
        Paragraph("<b>Spina Bifida Spectrum — Cross-Sections:</b>", H4),
        sp(2),
    ]
    R1 += remote_img(
        "https://cdn.orris.care/cdss_images/f34ba7fe0742075e679bc08c0b194dd10390a5a1b9d736a3e1ffbbc1a02af68f.png",
        COL-2*mm,
        "A = Spina bifida occulta with tuft of hair (unfused arch, no herniation). B = Meningocele (dura + arachnoid herniate, no neural tissue). Spinal cord and vertebral anatomy labelled. (Medical Physiology)")
    S_.append(two(L1,R1))
    S_.append(sp(4)); S_.append(hr())

    # ─────────────────────────────────────────────────────────────────────────
    # SECTION 2 — EMBRYOLOGY  |  SECTION 3 — EPIDEMIOLOGY
    # ─────────────────────────────────────────────────────────────────────────
    L2=[
        Bar("2 · EMBRYOLOGY — WHY DOES IT HAPPEN?", bg=TEAL),
        sp(2),
        Paragraph(
            "<b>Timeline:</b> Weeks 3–4 of gestation (days 18–28). This is <b>before most women "
            "know they are pregnant</b>.", BODY),
        sp(2),
        Paragraph(
            "The neural plate folds to form the neural tube through a process called "
            "<b>primary neurulation</b>. Failure of this closure — specifically the "
            "<b>caudal neuropore</b> (which closes last, around day 26–28) — results in open "
            "defects at lumbar/sacral levels.", BODY),
        sp(3),
        Paragraph("<b>Neural Tube Closure Timeline:</b>", H4),
        sp(1),
        tbl([
            ["Day","Embryological Event"],
            ["Day 18","Neural plate forms from ectoderm"],
            ["Day 22–23","Neural folds begin fusing (cranial neuropore)"],
            ["Day 26","Rostral (anterior) neuropore closes"],
            ["Day 26–28","Caudal neuropore closes — FAILURE HERE = MMC"],
        ], cw=[16*mm, COL-16*mm]),
        sp(3),
        Paragraph("<b>Neural Tube Defects Classification Table:</b>", H4),
        sp(1),
        tbl([
            ["Malformation","Characteristics"],
            ["Brain Defects",""],
            ["Anencephaly","Absence of brain, massive skull, meninges, scalp defects"],
            ["Cephalocele","Partial brain herniation through skull defect (cranium bifidum)"],
            ["Meningocele","Meningeal herniation through skull or spine defect"],
            ["Spina Bifida Defects",""],
            ["Spina bifida occulta","Vertebral arch defect only — no herniation"],
            ["Spina bifida cystica","Herniation of dura and arachnoid through vertebral defect"],
            ["Myelomeningocele","Herniation of spinal cord AND meninges through vertebral defect"],
        ], cw=[36*mm, COL-36*mm]),
        sp(3),
        Paragraph("<b>The Two-Hit Hypothesis</b> (Creasy & Resnik MFM, 2022):", H3),
        sp(2),
        Box(
            "<b>Hit 1 — Primary failure:</b> Failure of neural tube closure at ~week 4 "
            "(genetic + environmental determinants). This creates the anatomic malformation "
            "with abnormal development of the spinal cord and associated tissues.\n\n"
            "<b>Hit 2 — Secondary damage:</b> Progressive damage from chronic exposure of "
            "the open neural placode to neurotoxic agents in amniotic fluid AND direct "
            "mechanical trauma throughout the remainder of gestation. "
            "This secondary injury worsens neurological function progressively in utero.",
            bg=YELLOW, border=ORANGE,
            style=S("2hit",fontName="Helvetica",fontSize=7,leading=10.5,textColor=DGREY)),
        sp(2),
        Paragraph(
            "<i>This two-hit model is the entire scientific rationale for in-utero surgery — "
            "closing the defect early stops Hit 2 and isolates neural tissue from "
            "the intrauterine environment. Animal models have demonstrated improved neonatal "
            "neurologic function with fetal closure, and ultrasound assessment demonstrates "
            "that central and peripheral neurologic injury is progressive during gestation.</i>",
            NOTE_P),
    ]

    R2=[
        Bar("3 · EPIDEMIOLOGY", bg=TEAL),
        sp(2),
        tbl([
            ["Parameter","Data"],
            ["Incidence","~1 in 3,000 live births (post-folate supplementation era)"],
            ["Pre-folate era","~1 in 1,000 live births in some populations"],
            ["Folate effect","~50% reduction in MMC; plateau now reached without elimination"],
            ["Terminations","25–40% of MMC pregnancies terminated after prenatal diagnosis"],
            ["Sex","Slight female predominance"],
            ["Most common level","Lumbosacral (>75% of cases)"],
            ["5-yr mortality","~14% overall; 35% in those with brainstem dysfunction"],
        ], cw=[32*mm, COL-32*mm]),
        sp(3),
        Paragraph("<b>Risk Factors:</b>", H3),
        sp(2),
        Paragraph("<b>Modifiable:</b>", H4),
        sp(1),
        Paragraph("● <b>Maternal folate deficiency</b> — most important modifiable factor", BUL),
        Paragraph("● <b>Low maternal B12</b> — may significantly increase NTD risk", BUL),
        Paragraph("● <b>Valproic acid</b> in 1st trimester — 1–2% NTD risk (highest known teratogen risk for NTDs)", BULR),
        Paragraph("● <b>Carbamazepine</b> — NTD risk", BULR),
        Paragraph("● Trimethoprim (folate antagonist)", BUL),
        Paragraph("● Methotrexate", BUL),
        Paragraph("● Maternal obesity", BUL),
        Paragraph("● Maternal diabetes mellitus", BUL),
        Paragraph("● Maternal hyperthermia in early pregnancy", BUL),
        sp(2),
        Paragraph("<b>Non-modifiable:</b>", H4),
        sp(1),
        Paragraph("● Prior affected pregnancy (approximately 10× background risk)", BUL),
        Paragraph("● Family history of neural tube defects", BUL),
        Paragraph("● Gene–gene and gene–environment interactions (most cases are multifactorial)", BUL),
        sp(3),
        Paragraph("<b>Prevention — Folic Acid:</b>", H3),
        sp(1),
        Paragraph(
            "Food fortification with folic acid and folic acid supplements taken <b>before conception</b> "
            "and continued for at least 3 months during pregnancy reduce the incidence of NTDs. "
            "In 2015, the US CDC urged all women of childbearing age who can become pregnant to get "
            "<b>0.4 mg of folic acid every day</b> to help reduce the risk of NTDs.", BODY),
        sp(1),
        Paragraph(
            "Epidemiologic studies have also shown that low maternal B12 levels may significantly "
            "increase the risk of NTDs.", BODY),
        sp(2),
        tbl([
            ["Population","Dose","Timing"],
            ["All women of childbearing age","400 mcg (0.4 mg) daily","Start BEFORE conception, continue 1st trimester"],
            ["Prior NTD pregnancy / on AED","4 mg/day (10× dose)","Start 1 month before conception, continue for 3 months"],
            ["Women on total parenteral nutrition","Folic acid supplement","As part of TPN fluid"],
        ], cw=[30*mm,22*mm,COL-52*mm]),
        sp(2),
        Box("Grain/cereal fortification with folate has reduced NTD prevalence by 30–50% at population level.",
            bg=LIME, border=LGREEN,
            style=S("fol",fontName="Helvetica",fontSize=7,leading=10,textColor=DGREY)),
    ]

    S_.append(two(L2,R2))
    S_.append(sp(4)); S_.append(hr())

    # ─────────────────────────────────────────────────────────────────────────
    # SECTION 4 — PRENATAL DIAGNOSIS  |  SECTION 5 — ASSOCIATED ANOMALIES
    # ─────────────────────────────────────────────────────────────────────────
    L3=[
        Bar("4 · PRENATAL DIAGNOSIS", bg=TEAL),
        sp(2),
        Paragraph("<b>Screening Pathway:</b>", H3),
        sp(1),
        tbl([
            ["Test","When","Sensitivity / Notes"],
            ["Maternal serum AFP (MSAFP)","14–16 weeks","Elevated in ~85% of open NTDs"],
            ["Amniocentesis AFP + AChE","As indicated (↑ MSAFP)","AChE more specific than AFP alone"],
            ["2nd trimester ultrasound","18–20 weeks","Detects >90% of NTDs"],
            ["Fetal MRI","19–25 weeks","Best lesion characterisation"],
        ], cw=[30*mm,22*mm,COL-52*mm]),
        sp(2),
        Paragraph(
            "Pregnant women can be screened at 14–16 weeks for serum α-fetoprotein (AFP) levels, "
            "which are elevated about <b>85% of the time</b> when the fetus has neural closure defects. "
            "The level of AFP may also be elevated in maternal blood serum. Amniocentesis is usually "
            "performed on pregnant women with high levels of serum AFP for determination of AFP level "
            "in amniotic fluid. An ultrasound scan may reveal an NTD that has resulted in spina bifida "
            "cystica. The fetal vertebral column can be detected by ultrasound at 10–12 weeks, and if "
            "there is a defect in the vertebral arch, a meningeal cyst may be detected in the affected area.",
            BODY),
        sp(3),
        Paragraph("<b>Ultrasound Signs — The Classic Triad:</b>", H3),
        sp(2),
        tbl([
            ["Sign","What You See","Mechanism"],
            ["🍋 Lemon sign","Frontal bone scalloping — skull looks like a lemon","Chiari II traction pulling brain anteriorly"],
            ["🍌 Banana sign","Curved cerebellum wrapping around brainstem","Hindbrain herniation into spinal canal"],
            ["Splayed vertebrae","U-shaped or V-shaped vertebrae on axial view","Direct spinal bifida — posterior elements unfused"],
        ], cw=[24*mm,36*mm,COL-60*mm]),
        sp(2),
        Paragraph(
            "Ultrasound detects greater than <b>90% of neural tube defects at 18–20 weeks</b> "
            "(coupled with AFP >95% detection rate).", BODY),
        sp(3),
        Paragraph("<b>Fetal MRI Advantages (19–25 wks):</b>", H4),
        sp(1),
        Paragraph("● Precise lesion level characterisation (better than USS)", BUL),
        Paragraph("● Degree of hindbrain herniation", BUL),
        Paragraph("● Cortical anomalies (polymicrogyria)", BUL),
        Paragraph("● Ventricular size and hydrocephalus assessment", BUL),
        Paragraph("● Identify associated brain malformations", BUL),
        sp(2),
    ]
    L3+=remote_img(
        "https://cdn.orris.care/cdss_images/53dea4ec16a11fdae29a3a0e41a5ef8608eca95112bea082ae77127db45c0fb7.png",
        COL-4*mm,
        "Second-trimester ultrasound: (A) midsagittal lumbosacral view with low-lying conus medullaris. (B) Pathologic tethered cord. (C) Cystic mass protruding from lumbosacral vertebral bodies. (D) Transverse U-shaped splayed vertebrae with herniated sac. (Creasy & Resnik MFM, Fig. 34.16)")
    L3+=[
        sp(2),
        Box("AFP is elevated because open neural defects allow CSF-AFP to leak into amniotic fluid → absorbed into maternal circulation. <b>Closed defects do NOT elevate AFP.</b> A normal AFP does NOT rule out spina bifida occulta.",
            bg=SKY, border=TEAL,
            style=S("afpb",fontName="Helvetica",fontSize=7,leading=10,textColor=DGREY)),
    ]

    R3=[
        Bar("5 · ASSOCIATED ANOMALIES", bg=ORANGE,
            style=S("h5o",fontName="Helvetica-Bold",fontSize=8,leading=11,textColor=white)),
        sp(2),
        Box("THE TRIAD — All three need active management from Day 1:\n"
            "1. CHIARI II MALFORMATION\n"
            "2. HYDROCEPHALUS\n"
            "3. NEUROGENIC BLADDER",
            bg=HexColor("#fff3e0"), border=ORANGE,
            style=S("triad",fontName="Helvetica-Bold",fontSize=7.5,leading=11.5,textColor=NAVY)),
        sp(3),
        Paragraph("<b>A. Chiari II Malformation</b> — present in virtually 100% of MMC", H3),
        sp(1),
        Paragraph(
            "In Chiari II malformation, the cerebellar vermis and caudal brainstem descend through "
            "an enlarged foramen magnum. The extent of brainstem herniation is variable, including "
            "portions of the medulla or even the pons. The downward traction of the tethered cord "
            "pulls the hindbrain caudally.", BODY),
        sp(2),
        Paragraph("<b>Anatomy of Chiari II:</b>", H4),
        sp(1),
        Paragraph("● Cerebellar vermis + caudal brainstem (medulla, sometimes pons) herniate through enlarged foramen magnum", BUL),
        Paragraph("● Small posterior fossa", BUL),
        Paragraph("● Kinked medulla", BUL),
        Paragraph("● Polymicrogyria can be seen", BUL),
        Paragraph("● Hydrocephalus and syringomyelia are common accompanying features", BUL),
        sp(2),
        Paragraph("<b>Clinical Consequences of Chiari II in Neonates/Infants:</b>", H4),
        sp(1),
        tbl([
            ["Sign","Mechanism","Severity"],
            ["Inspiratory stridor","Vocal cord palsy — CN X dysfunction","⚠ Common"],
            ["Apnea","Central (brainstem) or obstructive","⚠⚠ Serious"],
            ["Swallowing dysfunction","Bulbar palsy → aspiration risk","⚠⚠ Serious"],
            ["Central hypoventilation","Brainstem compression / dysfunction","⚠⚠⚠ Critical"],
            ["Opisthotonus","Severe brainstem herniation","⚠⚠⚠ Critical"],
        ], cw=[28*mm,34*mm,COL-62*mm], hbg=HexColor("#bf360c")),
        sp(2),
        Box("Brainstem dysfunction = <b>35% mortality by 5 years</b> even after repair. Neonates with spina bifida have 14% mortality by 5 years overall, rising to 35% in those with known brainstem dysfunction and Chiari II.",
            bg=HexColor("#ffebee"), border=RED,
            style=S("bsd",fontName="Helvetica-Bold",fontSize=7,leading=10.5,textColor=RED)),
        sp(3),
        Paragraph("<b>B. Hydrocephalus</b>", H3),
        sp(1),
        Paragraph(
            "Either defect (myelomeningocele or meningocele) is often accompanied by hydrocephalus or "
            "Chiari II malformation. More than 90% of cases of meningomyelocele have associated "
            "hydrocephalus due to coexistence of an Arnold–Chiari malformation. Most patients require "
            "surgical diversion of CSF to avoid high intracranial pressure-related complications.", BODY),
        sp(1),
        Paragraph("● <b>64–85%</b> of children with lumbosacral MMC require a VP shunt", BUL),
        Paragraph("● Higher lesion level → higher risk of shunt-dependent hydrocephalus", BUL),
        Paragraph("● Mechanism: obstruction of CSF flow at the 4th ventricle from Chiari II", BUL),
        Paragraph("● Mean IQ with VP shunting = <b>80 (low normal)</b> — decreased vs those not requiring shunt", BUL),
        Paragraph("● Even with successful shunting: complications of central hypoventilation, vocal cord dysfunction, and swallowing difficulties can persist", BUL),
        sp(3),
        Paragraph("<b>C. Latex Allergy</b>", H3),
        sp(1),
        Box("10–40% of children with MMC develop latex allergy from repeated early latex exposures during multiple procedures. STRICT LATEX-FREE ENVIRONMENT from birth — use only latex-free gloves, catheters, and equipment for ALL procedures, first and every subsequent anaesthetic.",
            bg=HexColor("#ffebee"), border=RED,
            style=S("ltx",fontName="Helvetica-Bold",fontSize=7,leading=10.5,textColor=RED)),
        sp(3),
        Paragraph("<b>D. Other Associated Anomalies:</b>", H4),
        sp(1),
        Paragraph("● <b>Tethered cord syndrome</b> — progressive neurological deterioration post-repair as cord re-tethers with scarring", BUL),
        Paragraph("● <b>Syringomyelia</b>", BUL),
        Paragraph("● <b>Craniolacunia (Lückenschädel)</b> — defective development of calvaria with depressed, non-ossified areas on inner surfaces of flat bones", BUL),
        Paragraph("● <b>Spinal dermoid and epidermoid inclusion cysts</b> — risk after surgical repair", BUL),
        Paragraph("● <b>Orthopedic:</b> hip dislocation, clubfoot, scoliosis, kyphosis, pressure ulcers (insensate skin)", BUL),
        Paragraph("● <b>Neurogenic bowel and bladder</b> — virtually universal", BUL),
        Paragraph("● <b>Precocious puberty</b> — associated with hydrocephalus", BUL),
        Paragraph("● <b>Polymicrogyria</b> and other cortical dysplasias", BUL),
    ]

    S_.append(two(L3,R3))
    S_.append(PageBreak())

    # ─────────────────────────────────────────────────────────────────────────
    # SECTION 6 — LESION LEVEL FUNCTIONAL ANATOMY  |  SECTION 7 — NEONATAL PRESENTATION
    # ─────────────────────────────────────────────────────────────────────────
    L4=[
        Bar("6 · LESION LEVEL — FUNCTIONAL ANATOMY FOR NEONATOLOGISTS", bg=TEAL),
        sp(2),
        Paragraph(
            "The <b>motor level</b> predicts functional ability. In MMC, the functional level is often "
            "<b>better than the anatomic level</b>. Motor deficits and cognitive dysfunction are "
            "correlated with lesion level — higher levels are associated with greater morbidity. "
            "Improved motor function has been observed at 2 years of age in children with MMC who "
            "underwent caesarean delivery before labour onset compared to those delivered vaginally "
            "or by caesarean after onset of labour.", BODY),
        sp(2),
        tbl([
            ["Lesion Level","Motor Function Preserved","Ambulation Potential","Bladder/Bowel"],
            ["Thoracic","Arms, trunk partially","Wheelchair-dependent","Neurogenic"],
            ["L1–L2","Hip flexors (iliopsoas)","Braces + wheelchair","Neurogenic"],
            ["L3–L4","Knee extensors (quadriceps)","May walk with braces","Neurogenic"],
            ["L4–L5","Ankle dorsiflexors, knee flexors","Walk with AFOs","Neurogenic (partial)"],
            ["Sacral","Intrinsic foot muscles","Independent walking","Variable"],
        ], cw=[16*mm,32*mm,28*mm,COL-76*mm]),
        sp(3),
        Paragraph("<b>Neurogenic Bladder — Why It Matters Most in the Neonate:</b>", H3),
        sp(1),
        Paragraph(
            "Almost ALL patients with MMC have <b>neurogenic bladder</b> regardless of lesion level, "
            "due to involvement of sacral roots (S2–S4). This means urinary retention with overflow "
            "incontinence if untreated, and risk of upper urinary tract damage.", BODY),
        sp(2),
        Box("NEUROGENIC BLADDER → Urinary retention → back pressure → hydronephrosis → vesicoureteral reflux → progressive CKD and renal failure if untreated.\n\n"
            "CLEAN INTERMITTENT CATHETERISATION (CIC) must be started within days of birth.",
            bg=YELLOW, border=ORANGE,
            style=S("nb",fontName="Helvetica",fontSize=7,leading=10.5,textColor=DGREY)),
        sp(2),
        Paragraph("● Baseline renal USS in first days of life", BUL),
        Paragraph("● Urodynamic studies in first weeks of life", BUL),
        Paragraph("● Urology consult before discharge", BUL),
        Paragraph("● CIC technique taught to parents prior to discharge", BUL),
        sp(3),
        Paragraph("<b>Dermatomal Sensory Testing at Delivery:</b>", H4),
        sp(1),
        tbl([
            ["Level","Sensory Region Tested"],
            ["L1","Inguinal ligament / groin"],
            ["L2","Medial thigh"],
            ["L3","Medial knee"],
            ["L4","Medial leg and ankle"],
            ["L5","Dorsum of foot, great toe"],
            ["S1","Lateral foot and sole"],
            ["S2–S4","Perineum and perianal region"],
        ], cw=[16*mm, COL-16*mm]),
        sp(2),
        Paragraph(
            "<i>Note: Any existing myelopathic or radiculopathic neurological deficit is likely to "
            "persist after surgery. The goal of closure is to prevent further deterioration and "
            "infection, not to restore lost function.</i>", NOTE_P),
    ]

    R4=[
        Bar("7 · NEONATAL PRESENTATION AND INITIAL ASSESSMENT", bg=TEAL),
        sp(2),
        Paragraph("<b>At Delivery — What You See:</b>", H3),
        sp(1),
        Paragraph(
            "The neonate is born with a visible posterior midline mass, most commonly in the "
            "<b>lumbosacral region</b>. Spinal defects are often visible on examination of the back "
            "of the newborn.", BODY),
        sp(2),
        tbl([
            ["Finding","What It Tells You","Action"],
            ["Posterior midline sac","Diagnostic of spina bifida cystica","Document level, size"],
            ["Translucent intact sac","Relatively protected neural tissue","Still urgent closure"],
            ["Ruptured/exposed placode","Direct route for ascending infection","Same-day surgical emergency"],
            ["Flaccid lower limbs","Level of cord involvement","Assess dermatomal level"],
            ["Absent voluntary movement","Upper level of lesion","Document carefully"],
            ["Absent anal wink","S2–S4 root involvement","Neurogenic bladder certain"],
            ["Macrocephaly / bulging fontanelle","Pre-existing hydrocephalus","Urgent cranial USS"],
            ["Inspiratory stridor","Chiari II vocal cord palsy (CN X)","Respiratory monitoring"],
            ["Abnormal cry/voice","Vocal cord palsy / bulbar","Assess swallow safety"],
        ], cw=[28*mm,34*mm,COL-62*mm]),
        sp(3),
        Paragraph("<b>Neurological Examination in the Delivery Room:</b>", H3),
        sp(1),
        tbl([
            ["What to Assess","How","What It Tells You"],
            ["Spontaneous leg movement","Observe with and without stimulation","Level of motor function"],
            ["Response to pin-prick","Careful dermatomal testing (L1–S4)","Sensory level"],
            ["Anal wink reflex","Perianal stimulation","S2–S4 sacral root integrity"],
            ["Lower limb tone","Passive movement assessment","LMN injury = flaccid"],
            ["Head circumference (OFC)","Measurement with tape","Pre-existing hydrocephalus"],
            ["Fontanelle tension","Careful palpation","Raised ICP"],
            ["Respiratory pattern","Observation + SpO2","Brainstem / Chiari II function"],
            ["Cry and voice quality","Listen carefully","Vocal cord palsy"],
            ["Swallow assessment","Observe feeding attempts","Aspiration risk"],
        ], cw=[26*mm,28*mm,COL-54*mm]),
        sp(3),
        Bar("8 · IMMEDIATE NEONATAL ORDERS — FIRST HOUR", bg=ORANGE,
            style=S("h8",fontName="Helvetica-Bold",fontSize=7.5,leading=10,textColor=white)),
        sp(2),
        tbl([
            ["#","Action","Rationale"],
            ["1","LATEX-FREE protocol — immediately, no exceptions","10–40% latex allergy risk with repeated exposure"],
            ["2","Prone or lateral decubitus positioning on padded doughnut ring","Protect sac; NEVER supine directly on the sac"],
            ["3","Sterile moist normal saline gauze over defect (non-adherent)","Prevent desiccation and ascending infection"],
            ["4","Incubator — active thermoregulation","High insensible fluid + heat losses from exposed sac"],
            ["5","IV access + increase maintenance fluids","Compensate for insensible losses from sac"],
            ["6","Cranial ultrasound","Ventricular size; rule out acute hydrocephalus"],
            ["7","Renal ultrasound","Baseline upper urinary tract assessment"],
            ["8","Urgent Neurosurgery consultation","Surgical closure within 24–72 hours"],
            ["9","Urology consultation","CIC protocol + urodynamics plan"],
            ["10","Hold oral feeds; assess swallow safety","Aspiration risk from Chiari II bulbar dysfunction"],
        ], cw=[6*mm,44*mm,COL-50*mm]),
        sp(2),
        Paragraph(
            "<i>Note on fluid loss: Underestimating insensible fluid and blood loss is a common "
            "anaesthetic pitfall. The exposed sac results in significant evaporative and third-space "
            "losses that must be factored into fluid management.</i>", NOTE_P),
    ]

    S_.append(two(L4,R4))
    S_.append(sp(4)); S_.append(hr())

    # ─────────────────────────────────────────────────────────────────────────
    # SECTION 9 — SURGICAL REPAIR  |  SECTION 10 — POST-OP NEONATAL CARE
    # ─────────────────────────────────────────────────────────────────────────
    L5=[
        Bar("9 · SURGICAL REPAIR", bg=TEAL),
        sp(2),
        Paragraph("<b>A. Postnatal Repair (Standard of Care for Decades):</b>", H3),
        sp(1),
        Paragraph(
            "Initial surgical treatment in utero or in the neonatal period can provide cosmetic repair "
            "and decrease the risk for meningitis. If uncorrected in utero, surgical closure of the "
            "spinal defect must be performed within a few days after birth.", BODY),
        sp(2),
        Paragraph("● Timing: <b>within 24–72 hours</b> of birth", BUL),
        Paragraph("● Ruptured/exposed placode = <b>same-day emergency</b>", BULR),
        Paragraph("● Rationale for urgency: open defect = direct route for ascending infection; CSF leak", BUL),
        Paragraph("● Surgical steps: separation of placode from surrounding skin → dural closure → fascial closure → skin closure", BUL),
        sp(3),
        Paragraph("<b>Anaesthesia Considerations for MMC Closure:</b>", H4),
        sp(1),
        Paragraph("● Special positioning: defect placed on a 'doughnut' ring; towels under head for tracheal intubation", BUL),
        Paragraph("● Underestimating insensible fluid and blood loss is a common hazard", BULR),
        Paragraph("● Association with hydrocephalus — raised ICP must be considered during induction", BUL),
        Paragraph("● Cranial nerve (vocal cord) palsy may cause inspiratory stridor on intubation", BUL),
        Paragraph("● Potential for brainstem herniation during airway manipulation", BULR),
        Paragraph("● Latex allergy precautions for ALL anaesthetics — first and subsequent", BULR),
        Paragraph("● Patients with lumbosacral MMC typically deliver by caesarean section before labour onset to preserve motor function", BUL),
        sp(3),
        Paragraph("<b>B. In Utero (Fetal) Repair — The MOMS Trial Revolution:</b>", H3),
        sp(2),
        Paragraph(
            "The landmark <b>Management of Myelomeningocele Study (MOMS Trial)</b> was a randomised, "
            "prospective clinical trial completed between 2003 and 2010 at three US medical centres. "
            "It examined the risks, benefits, and outcome of open in utero repair for MMC compared "
            "with standard postnatal repair among <b>183 patients</b>.", BODY),
        sp(2),
        Paragraph("<b>Rationale for Fetal Surgery:</b>", H4),
        sp(1),
        Paragraph(
            "Initial human studies found that in utero repair reversed the hindbrain herniation of "
            "the Arnold–Chiari II malformation and decreased the requirement for VP shunt placement "
            "before 1 year of age. A 1999 series of 10 fetuses undergoing in utero MMC closure at "
            "22–25 weeks' gestation found improved lower extremity function among 6 of 9 fetuses "
            "compared with expected function based on level of lesion.", BODY),
        sp(3),
        Paragraph("<b>MOMS Trial Results — Benefits of Prenatal Repair (at 30 months):</b>", H4),
        sp(1),
        tbl([
            ["Outcome","Prenatal Repair","Postnatal Repair","Significance"],
            ["VP shunt needed","40%","82%","p < 0.001"],
            ["Independent walking","44.8%","23.9%","p = 0.04"],
            ["Function ≥2 levels better than anatomic level","26.4%","11.4%","Significant"],
            ["Hindbrain herniation reversal","YES","No","Significant"],
            ["Bayley Mental Dev. Index","Better","Lower","Significant"],
            ["Peabody Developmental Motor Scale","Better","Lower","Significant"],
        ], cw=[38*mm,20*mm,20*mm,COL-78*mm], hbg=HexColor("#1b5e20")),
        sp(2),
        Paragraph(
            "Long-term outcome from this trial is still ongoing, but a pretrial cohort of 54 patients "
            "undergoing fetal MMC repair reported improved functional, behavioural, and motor outcomes "
            "at age 10 years, especially among children who did not require VP shunting.", BODY),
        sp(3),
        Paragraph("<b>MOMS Trial — Costs of Prenatal Repair:</b>", H4),
        sp(1),
        tbl([
            ["Maternal Complication","Prenatal Group","Postnatal Group"],
            ["Preterm birth / PPROM","Significantly ↑","Lower"],
            ["Partial/complete uterine dehiscence","~11%","Lower"],
            ["Maternal laparotomy + hysterotomy scar","Required","Not required"],
            ["Need for caesarean in future pregnancies","YES (scar)","No"],
            ["Perinatal deaths","2","2"],
        ], cw=[40*mm,24*mm,COL-64*mm], hbg=HexColor("#bf360c")),
        sp(2),
        Box("Results of this trial should NOT be generalised to patients outside the inclusion criteria. "
            "This procedure should be offered only at medical facilities with the expertise, "
            "multidisciplinary teams, services, and facilities to provide the intensive care required.",
            bg=YELLOW, border=ORANGE,
            style=S("moms",fontName="Helvetica",fontSize=7,leading=10,textColor=DGREY)),
        sp(3),
        Paragraph("<b>Fetal Surgery Window and Eligibility Criteria:</b>", H4),
        sp(1),
        Paragraph("● Window: <b>19–26 weeks' gestation</b>", BUL),
        Paragraph("● Singleton pregnancy", BUL),
        Paragraph("● MMC between T1 and S1 with hindbrain herniation", BUL),
        Paragraph("● Gestational age 19–25+6 weeks at evaluation", BUL),
        Paragraph("● Normal chromosomes", BUL),
        Paragraph("● No other major fetal anomalies", BUL),
        Paragraph("● No maternal contraindications (BMI, uterine anatomy, etc.)", BUL),
        sp(3),
        Paragraph("<b>Fetoscopic (Minimally Invasive) Repair:</b>", H4),
        sp(1),
        Paragraph(
            "Endoscopic myelomeningocele repair is increasingly practiced. In theory, a minimally "
            "invasive approach may reduce complications for pregnant individuals and obviate the need "
            "for caesarean delivery. A 2018 meta-analysis of 11 studies found no difference in "
            "mortality or need for VP shunt among fetal patients treated with open vs endoscopic technique.", BODY),
        sp(1),
        tbl([
            ["Approach","PPROM Rate","Preterm Delivery","CSF Leak","Uterine Dehiscence"],
            ["Open fetal surgery","36%","81%","7%","11%"],
            ["Fetoscopic (percutaneous)","91%","96%","30%","0%"],
        ], cw=[30*mm,20*mm,22*mm,18*mm,COL-90*mm]),
        sp(2),
        Box("A 2025 systematic review and meta-analysis (PMID: 40492626) confirms open fetal surgery remains the reference standard. Fetoscopic repair remains promising but not yet perfected.",
            bg=SKY, border=TEAL,
            style=S("feto",fontName="Helvetica",fontSize=7,leading=10,textColor=DGREY)),
    ]

    R5=[
        Bar("10 · POST-OPERATIVE NEONATAL CARE", bg=TEAL),
        sp(2),
        Paragraph("<b>Immediate Post-operative Care (First Week):</b>", H3),
        sp(1),
        Paragraph("● <b>Positioning:</b> Prone for 5–7 days to allow wound healing; avoid pressure on repair site", BUL),
        Paragraph("● <b>Monitor for hydrocephalus:</b> Head circumference (OFC) daily", BUL),
        Paragraph("● <b>Serial cranial USS:</b> Monitor ventricular size closely", BUL),
        Paragraph("● <b>Fontanelle checks:</b> Tension, bulging — signs of raised ICP?", BUL),
        Paragraph("● <b>Wound monitoring:</b> CSF leak at repair site, infection, dehiscence", BUL),
        Paragraph("● <b>Respiratory monitoring:</b> Apnea, central hypoventilation from Chiari II", BUL),
        Paragraph("● <b>NG feeds initially:</b> Assess swallow function before oral feeds — risk of aspiration with Chiari II-related bulbar dysfunction", BUL),
        Paragraph("● <b>Initiate CIC:</b> Urology clears — typically within days 1–3 post-closure", BUL),
        sp(3),
        Paragraph("<b>VP Shunt Decision — When and Why:</b>", H3),
        sp(1),
        Box("64–85% of lumbosacral MMC will need VP shunt. Usually placed days to weeks after closure. "
            "Signs requiring urgent shunting: rapidly rising OFC, bulging fontanelle, "
            "setting-sun sign, apnea, worsening brainstem signs.",
            bg=SKY, border=TEAL,
            style=S("vps",fontName="Helvetica",fontSize=7,leading=10.5,textColor=NAVY)),
        sp(2),
        Paragraph(
            "Common indications for VP shunt include hydrocephalus occurring in association with "
            "meningomyelocele, neonatal intraventricular haemorrhage, and posterior fossa tumours. "
            "Open fontanelles seem to provide some margin for error in younger patients — but never "
            "be casual about the management of these patients.", BODY),
        sp(3),
        Paragraph("<b>Before Discharge — Comprehensive Checklist:</b>", H3),
        sp(1),
        tbl([
            ["Domain","Required Before Discharge"],
            ["Neurosurgery","Wound healed; VP shunt placed if indicated and functioning"],
            ["Urology","CIC technique taught to parents; urodynamics scheduled"],
            ["Renal USS","Baseline documented before discharge"],
            ["Ophthalmology","Strabismus screen, papilloedema check"],
            ["Audiology","Baseline hearing screen (SNHL can be associated)"],
            ["Physiotherapy","Positioning, passive ROM, stretching taught to parents"],
            ["Occupational therapy","Developmental stimulation guidance"],
            ["Social work","Family counselling, support services, community resources"],
            ["Neurodevelopment","MDT follow-up plan in place — first appointment booked"],
            ["Dietetics","Feeding plan; risk of overweight in wheelchair-bound children"],
        ], cw=[26*mm, COL-26*mm]),
        sp(3),
        Paragraph("<b>Paediatric Neurosurgery — Post-Closure Complications to Watch:</b>", H4),
        sp(1),
        Paragraph("● <b>CSF leak</b> at repair site → risk of meningitis", BUL),
        Paragraph("● <b>Wound infection</b> or dehiscence", BUL),
        Paragraph("● <b>Acute hydrocephalus</b> developing post-closure", BUL),
        Paragraph("● <b>VP shunt infection</b> — Staph epidermidis most common", BUL),
        Paragraph("● <b>Shunt obstruction</b> — re-present with signs of raised ICP", BUL),
        Paragraph("● <b>Tethered cord syndrome</b> — progressive motor/bladder deterioration", BUL),
        sp(3),
        Box("Some patients, especially infants with progressive brainstem dysfunction, are treated with decompression of the rostral spinal canal (Chiari decompression). Less than 30% of such patients survive beyond the first year.",
            bg=HexColor("#ffebee"), border=RED,
            style=S("bss",fontName="Helvetica",fontSize=7,leading=10,textColor=DGREY)),
    ]

    S_.append(two(L5,R5))
    S_.append(sp(4)); S_.append(hr())

    # ─────────────────────────────────────────────────────────────────────────
    # SECTION 11 — LONG-TERM COMPLICATIONS  |  SECTION 12 — OUTCOMES
    # ─────────────────────────────────────────────────────────────────────────
    L6=[
        Bar("11 · LONG-TERM COMPLICATIONS — THE LIFESPAN PERSPECTIVE", bg=TEAL),
        sp(2),
        Paragraph(
            "As a neonatologist, you are launching a child into a life of multidisciplinary care. "
            "Understand what lies ahead for the patient and family:", BODY),
        sp(2),
        tbl([
            ["System","Problem","Typical Onset"],
            ["CNS","Shunt malfunction / infection","Anytime"],
            ["CNS","Tethered cord syndrome (progressive neurological deterioration)","Childhood, adolescence"],
            ["CNS","Syringomyelia","Any age"],
            ["CNS","Chiari II decompensation","Any age"],
            ["Urological","Neurogenic bladder, recurrent UTIs, VUR, renal scarring, CKD","Lifelong from birth"],
            ["Urological","Neurogenic bowel (constipation, incontinence)","Lifelong from birth"],
            ["Orthopedic","Scoliosis, kyphosis","Childhood +"],
            ["Orthopedic","Hip dislocation, subluxation","Infancy +"],
            ["Orthopedic","Clubfoot, foot deformities","Present at birth"],
            ["Orthopedic","Pressure ulcers (insensate skin)","Any age"],
            ["Cognitive","Learning disabilities, executive function deficits","School age"],
            ["Cognitive","Attention problems (ADHD-like)","School age"],
            ["Allergy","Latex anaphylaxis","Lifelong"],
            ["Endocrine","Precocious puberty (hydrocephalus-related)","Childhood"],
            ["Respiratory","Central sleep apnea","Any age"],
            ["Sexual function","Dysfunction — depends on level","Adolescence+"],
        ], cw=[26*mm,46*mm,COL-72*mm]),
    ]

    R6=[
        Bar("12 · OUTCOMES AND PROGNOSIS", bg=TEAL),
        sp(2),
        Paragraph("<b>Intellectual Outcomes:</b>", H3),
        sp(1),
        Paragraph(
            "More than <b>70% of survivors with neural tube defects have an IQ greater than 80</b>. "
            "However, executive function, attention, and processing speed are disproportionately "
            "affected even with preserved overall IQ. With VP shunting, mean IQ is approximately "
            "<b>80 (low normal)</b> — decreased compared to those who do not require a shunt. "
            "Few patients with myelomeningocele are mentally normal, but most of those with lumbar "
            "meningocele (without neural involvement) are.", BODY),
        sp(2),
        Paragraph("<b>Ambulation Outcomes:</b>", H3),
        sp(1),
        Paragraph("● <b>46–75%</b> of children with lumbosacral MMC will walk (with or without assistive devices)", BUL),
        Paragraph("● Following MOMS fetal repair: 46% could ambulate independently at 30-month follow-up", BULT),
        Paragraph("● 46% had functional level at least two segments better than anatomic level", BULT),
        sp(3),
        Paragraph("<b>Survival:</b>", H3),
        sp(1),
        Paragraph("● Neonates with spina bifida have a <b>14% mortality rate by 5 years</b>", BUL),
        Paragraph("● <b>35% mortality rate</b> in those with known brainstem dysfunction and Chiari II", BULR),
        Paragraph("● 5-year mortality rate among patients with spina bifida undergoing neonatal repair: 79 per 1,000 births", BUL),
        sp(3),
        Paragraph("<b>Independence in Adulthood:</b>", H3),
        sp(1),
        Paragraph("● Only <b>37% can live independently as adults</b>", BUL),
        Paragraph("● Many have anal sphincteric dysfunction and lower extremity paralysis", BUL),
        Paragraph("● Sexual dysfunction is common depending on level", BUL),
        sp(3),
        Box("Cognitive outcomes are best in children who:\n"
            "1. Have sacral-level lesions (lower)\n"
            "2. Do NOT require VP shunting\n"
            "3. Undergo fetal repair (better Bayley scores)\n"
            "4. Have no shunt infections",
            bg=LIME, border=LGREEN,
            style=S("cog",fontName="Helvetica",fontSize=7,leading=10.5,textColor=DGREY)),
        sp(3),
        Paragraph("<b>Antenatal Counselling Points:</b>", H3),
        sp(1),
        Paragraph("● >70% will have IQ >80 — most are educable", BUL),
        Paragraph("● Most will require lifelong multidisciplinary follow-up", BUL),
        Paragraph("● Ambulation is possible for many lumbosacral cases", BUL),
        Paragraph("● Quality of life reported as good by many patients with MMC", BUL),
        Paragraph("● Fetal surgery option should be discussed — refer to a fetal surgery centre before 26 weeks", BULT),
        Paragraph("● Prenatal repair: better motor and intellectual outcomes but maternal risks must be weighed", BUL),
        sp(3),
        Paragraph("<b>Hemimyelomeningocele:</b>", H4),
        sp(1),
        Paragraph(
            "A 2026 systematic review and meta-analysis (PMID: 41511579) examined "
            "hemimyelomeningocele — a rare variant where only one half of the spinal cord is involved. "
            "This represents a distinct entity on the dysraphism spectrum with variable outcomes.", BODS),
    ]

    S_.append(two(L6,R6))
    S_.append(sp(4)); S_.append(hr(NAVY))
    S_.append(PageBreak())

    # ─────────────────────────────────────────────────────────────────────────
    # FULL-WIDTH: PREVENTION + QUICK REFERENCE BEDSIDE CARD
    # ─────────────────────────────────────────────────────────────────────────
    S_.append(Bar("12 · PREVENTION — FOLIC ACID AND DRUG AVOIDANCE", bg=NAVY, h=7*mm,
        style=S("pv",fontName="Helvetica-Bold",fontSize=8.5,leading=11,textColor=white,alignment=TA_CENTER)))
    S_.append(sp(3))

    PL=[
        Paragraph("<b>Folic Acid Supplementation — The Key Public Health Intervention:</b>", H3),
        sp(1),
        Paragraph(
            "Food fortification with folic acid and folic acid supplements taken <b>before conception</b> "
            "and continued for at least 3 months during pregnancy reduce the incidence of NTDs. "
            "The mechanism is that folate is essential for DNA synthesis, methylation reactions, and "
            "neural tube closure — and the critical window is days 18–28, <b>before most women know "
            "they are pregnant</b>.", BODY),
        sp(2),
        tbl([
            ["Population","Dose","Timing","Source"],
            ["All women of childbearing age","400 mcg (0.4 mg)/day","Start BEFORE conception, continue through 1st trimester","CDC 2015"],
            ["Prior NTD pregnancy OR on antiepileptic drugs","4 mg/day (10× dose)","Start 1 month before conception, continue for first 3 months","Evidence-based guideline"],
            ["On total parenteral nutrition","As part of TPN","Continuous","Clinical practice"],
        ], cw=[30*mm,24*mm,50*mm,COL-104*mm+GAP/2]),
        sp(2),
        Paragraph(
            "In women with a history of a pregnancy complicated by a neural tube defect, "
            "an even larger dose of <b>4 mg/day</b> has been recommended. "
            "There are two approaches to preventing NTDs: (1) educate women to supplement their "
            "diets with folic acid 1 month before conception continuing for 2 months after conception; "
            "(2) food fortification programmes.", BODY),
    ]

    PR=[
        Paragraph("<b>Drugs to Avoid in Pregnancy (Especially Trimester 1):</b>", H3),
        sp(1),
        Box("Valproic acid causes NTDs in 1–2% of pregnancies if taken during early pregnancy when "
            "the neural folds are fusing. This is one of the highest known teratogen risks for NTDs.",
            bg=HexColor("#ffebee"), border=RED,
            style=S("val",fontName="Helvetica-Bold",fontSize=7,leading=10.5,textColor=RED)),
        sp(2),
        tbl([
            ["Drug","Mechanism of NTD Risk"],
            ["Valproic acid","Direct NTD teratogen — 1–2% risk; folate antagonism"],
            ["Carbamazepine","NTD risk; enzyme inducing"],
            ["Trimethoprim","Folate antagonist — inhibits dihydrofolate reductase"],
            ["Methotrexate","Folate antagonist — direct anti-folate"],
        ], cw=[32*mm, COL-32*mm+GAP/2]),
        sp(2),
        Paragraph(
            "Grain/cereal fortification with folate has reduced NTD prevalence by <b>30–50%</b> "
            "at population level in countries that have implemented mandatory fortification programmes.", BODY),
    ]

    S_.append(two(PL,PR))
    S_.append(sp(4)); S_.append(hr())

    # ── QUICK REFERENCE BEDSIDE CARD ──────────────────────────────────────────
    S_.append(Bar("QUICK REFERENCE — BEDSIDE CARD FOR NEONATOLOGISTS", bg=GREEN, h=7*mm,
        style=S("qb",fontName="Helvetica-Bold",fontSize=8.5,leading=11,textColor=white,alignment=TA_CENTER)))
    S_.append(sp(3))

    QL=[
        Paragraph("<b>5 Signs That Spot MMC at Birth:</b>", H3),
        sp(1),
        Paragraph("1️⃣  Posterior midline sac — most commonly lumbosacral", NUMB),
        Paragraph("2️⃣  Flaccid lower limbs / no voluntary movement below lesion", NUMB),
        Paragraph("3️⃣  Absent anal wink reflex (S2–S4 involvement)", NUMB),
        Paragraph("4️⃣  Macrocephaly / bulging fontanelle (hydrocephalus)", NUMB),
        Paragraph("5️⃣  Possible inspiratory stridor (Chiari II vocal cord palsy)", NUMB),
        sp(3),
        Paragraph("<b>Your First 6 Steps in the Delivery Room:</b>", H3),
        sp(1),
        Box("① LATEX-FREE — from this exact moment. No exceptions.\n"
            "② Prone on doughnut ring — sterile moist saline gauze over sac\n"
            "③ Incubator — prevent heat and evaporative fluid loss\n"
            "④ IV access + increase maintenance fluids\n"
            "⑤ Cranial USS + Renal USS stat\n"
            "⑥ Urgent Neurosurgery + Urology consults",
            bg=LIME, border=LGREEN,
            style=S("qstep",fontName="Helvetica-Bold",fontSize=7.5,leading=12,textColor=NAVY)),
        sp(3),
        Paragraph("<b>Surgical Timing:</b>", H4),
        sp(1),
        Paragraph("● Postnatal closure: <b>within 24–72 hours</b> of birth", BUL),
        Paragraph("● Ruptured/exposed placode = <b>same-day emergency</b>", BULR),
        Paragraph("● Prenatal repair: 19–26 weeks' gestation at designated centre", BULT),
        sp(2),
        Paragraph("<b>MOMS Trial Key Numbers:</b>", H4),
        sp(1),
        Paragraph("● VP shunt: 40% (prenatal) vs 82% (postnatal)", BUL),
        Paragraph("● Walk independently: 44.8% vs 23.9%", BUL),
        Paragraph("● Function ≥2 levels better: 26.4% vs 11.4%", BUL),
    ]

    QR=[
        Paragraph("<b>The 3 Mandatory Associations — All Need Active Day-1 Management:</b>", H3),
        sp(2),
        Box("CHIARI II MALFORMATION\n"
            "Monitor for: stridor, apnea, swallowing dysfunction, central hypoventilation.\n"
            "Present in virtually 100% of MMC. Mortality 35% if brainstem dysfunction.",
            bg=HexColor("#fff3e0"), border=ORANGE,
            style=S("q1",fontName="Helvetica-Bold",fontSize=7,leading=11,textColor=DGREY)),
        sp(2),
        Box("HYDROCEPHALUS\n"
            "Daily OFC measurements. Serial cranial USS.\n"
            "VP shunt required in 64–85% of lumbosacral MMC.\n"
            "Mean IQ with shunt ≈ 80 (low normal).",
            bg=SKY, border=TEAL,
            style=S("q2",fontName="Helvetica-Bold",fontSize=7,leading=11,textColor=DGREY)),
        sp(2),
        Box("NEUROGENIC BLADDER\n"
            "CIC from days 1–3 post-closure.\n"
            "Renal USS + urodynamics in first weeks.\n"
            "Prevent upper tract damage → protect kidneys for life.",
            bg=LIME, border=LGREEN,
            style=S("q3",fontName="Helvetica-Bold",fontSize=7,leading=11,textColor=DGREY)),
        sp(3),
        Paragraph("<b>Don't Forget:</b>", H3),
        sp(1),
        Paragraph("● Latex allergy precautions — every procedure, every anaesthetic, for life", BULR),
        Paragraph("● Assess swallow before oral feeds (Chiari II bulbar dysfunction)", BULR),
        Paragraph("● Caesarean before labour onset — better motor outcomes for the baby", BUL),
        Paragraph("● Baseline OFC, cranial USS, renal USS before discharge", BUL),
        Paragraph("● Teach CIC to parents before discharge", BUL),
        Paragraph("● Multidisciplinary follow-up: neurosurgery, urology, orthopaedics, physiotherapy, neurodevelopment, ophthalmology, audiology", BUL),
        sp(2),
        Paragraph("<b>Recurrence Risk Counselling:</b>", H4),
        sp(1),
        Paragraph("● Background population risk: ~1 in 3,000", BUL),
        Paragraph("● After one affected child: ~10× background risk (2–3%)", BUL),
        Paragraph("● After two affected children: ~10–15% risk", BUL),
        Paragraph("● Folic acid 4 mg/day from 1 month pre-conception for high-risk women", BULG),
    ]

    S_.append(two(QL,QR))
    S_.append(sp(4)); S_.append(hr(NAVY))
    S_.append(sp(2))
    S_.append(Paragraph(
        "<b>Sources:</b> Bradley & Daroff's Neurology in Clinical Practice 8e | Miller's Anesthesia 10e | "
        "Creasy & Resnik's Maternal-Fetal Medicine: Principles and Practice | "
        "The Developing Human: Clinically Oriented Embryology (Moore & Persaud) | "
        "Medical Physiology (Boron & Boulpaep) | Medical Physiology (Guyton & Hall) | "
        "MOMS Trial — NEJM 2011 | Kunpalin et al. 2025 (PMID: 40492626) | "
        "Oliveira et al. 2025 (PMID: 40779058) | Adiyaman et al. 2026 (PMID: 41511579)",
        SOURCE))

    return S_


# ── BUILD ─────────────────────────────────────────────────────────────────────
def build():
    out="/home/daytona/workspace/mmc-pdf/MMC_Full_Neonatologist_Reference.pdf"
    doc=SimpleDocTemplate(
        out, pagesize=A4,
        leftMargin=ML, rightMargin=MR,
        topMargin=11*mm, bottomMargin=8*mm,
        title="Myelomeningocele — Complete Neonatologist Reference",
        author="Orris Medical AI",
        subject="MMC Complete Reference — All Sections, Tables, Images",
    )
    doc.build(story(), onFirstPage=decor, onLaterPages=decor)
    print(f"✓ PDF → {out}")

if __name__=="__main__":
    build()
Running Command

cd /home/daytona/workspace/mmc-pdf && python3 generate_full_mmc.py 2>&1

This is a shared conversation. Sign in to Orris to start your own chat.