Management of ca cervix in pregnancy, stage wise and trimester wise,. Dwtailed overview using tables and flow chart s. Using latest guidelines.

Reading File
Finding Sources
Searching PubMed

"cervical cancer" AND pregnancy AND management

Searching the Web

cervical cancer pregnancy management guidelines 2024 2025 FIGO ESGO stage trimester

Reading File
Reading Article

PMID: 40707270

Reading Article

PMID: 39216500

Reading Web Page

https://www.mdpi.com/2072-6694/16/14/2541

Reading File
Searching the Web

ESGO INCIP 2025 cervical cancer pregnancy treatment algorithm neoadjuvant chemotherapy trachelectomy

Reading Web Page

https://obgyn.onlinelibrary.wiley.com/doi/10.1002/ijgo.70277

Finding Sources
Reading File

Cervical Cancer in Pregnancy (CCIP) - Comprehensive Management Overview

Sources: Berek & Novak's Gynecology; Creasy & Resnik's Maternal-Fetal Medicine; ESGO/ESTRO/ESP 2023 Guidelines; ESGO/INCIP 2025 Guidelines (PMID 40707270); ESGO/ESHRE/ESGE Fertility-Sparing Guidelines 2024 (PMID 39216500); NCCN 2024

Background & Epidemiology

  • Incidence: ~1.2 per 10,000 pregnancies (most common gynecologic malignancy diagnosed in pregnancy)
  • Cervical cancer is the most frequent gynecologic malignancy in pregnancy alongside breast cancer, melanoma, and lymphoma
  • Most cases diagnosed during routine first-trimester cervical screening
  • Diagnosis is often delayed - bleeding is attributed to obstetric causes
  • Clinical stage is the most important prognostic factor; OS is slightly better in pregnancy due to higher proportion of stage I disease
  • Postpartum diagnosis is associated with more advanced stage and worse prognosis

Staging (FIGO 2018 - Used Throughout)

FIGO StageDescription
IA1Microscopic invasion ≤3 mm depth, ≤7 mm width
IA2Microscopic invasion 3-5 mm depth, ≤7 mm width
IB1Clinically visible, ≤2 cm or microscopic >IA2
IB2Clinically visible, 2-4 cm
IB3Clinically visible, >4 cm
IIAExtension to upper 2/3 vagina, no parametrium
IIBParametrial involvement
IIIA/BLower vagina or pelvic wall / hydronephrosis
IVA/BBladder/rectum / distant metastases

Key Diagnostic Principles During Pregnancy

InvestigationRecommendation
Pap smearAt FIRST prenatal visit for all patients
ColposcopySafe in all trimesters; avoid endocervical curettage
Cervical biopsySafe; perform for grossly suspicious lesions
Conization (diagnostic)AVOID in 1st trimester (abortion rate up to 33%); only if colposcopy consistent with cancer or strong cytologic evidence; prefer 2nd trimester
MRI (without gadolinium)Preferred imaging - safe in all trimesters for staging
Chest X-ray + abdominal shieldAcceptable for staging
CT abdomen/pelvisLimited use (fetal radiation ~1-2 cGy); use only when essential
PET scanAvoid - limited safety data in pregnancy
Sentinel lymph node biopsyFeasible with 99mTc alone (without blue dye); ESGO/INCIP 2025 supports this
AmniocentesisFor fetal lung maturity assessment before early delivery

MASTER TABLE: Stage-Wise and Trimester-Wise Management

FIGO Stage IA1 (≤3 mm invasion, No LVSI)

TrimesterDesire to Continue PregnancyManagement
1st (< 14 wks)YesClose surveillance; avoid conization if possible; repeat biopsy/colposcopy in 2nd trimester
1stNoTermination of pregnancy + type I hysterectomy (or cold knife conization if fertility desired)
2nd (14-28 wks)YesObservation; conization only if cancer cannot be excluded; follow to term
3rd (> 28 wks)YesObserve to fetal maturity; Cesarean section + simple hysterectomy at 34-37 wks OR allow vaginal delivery then treat 6 wks postpartum
AnyLVSI presentUpgrade management to IA2/IB1 protocol
Key points: Patients with <3 mm invasion and no LVSI may be followed to term. Vaginal delivery historically permitted but C-section now strongly preferred (vaginal delivery was most significant predictor of recurrence in multivariate analysis).

FIGO Stage IA2 (3-5 mm invasion, with/without LVSI)

TrimesterDesire to Continue PregnancyManagement
1stYesSurveillance; lymph node assessment (sentinel node biopsy with 99mTc); if nodes negative - follow to term
1stNoImmediate termination + modified radical hysterectomy + pelvic lymphadenectomy
2ndYesSentinel lymph node assessment; if negative - delay to fetal maturity
3rdYesDeliver when fetal lung maturity confirmed (amniocentesis); Cesarean + modified radical hysterectomy + pelvic lymphadenectomy
Any - Nodes positive--Terminate pregnancy (if <22 wks) or deliver early + chemoradiation

FIGO Stage IB1 / IB2 (up to 4 cm)

TrimesterDesire to Continue PregnancyManagement
1st trimesterYesGravid radical hysterectomy + pelvic lymphadenectomy (in situ fetus) is feasible; OR lymph node assessment first - if negative, NACT from ≥14 wks then radical trachelectomy (experimental/fertility-sparing)
1st trimesterNoTherapeutic abortion then radical hysterectomy + pelvic LN dissection as per non-pregnant guidelines
2nd trimester (14-22 wks)YesGravid radical hysterectomy OR NACT (platinum-based, paclitaxel/carboplatin q3 weekly from ≥14 wks) until fetal maturity; Cesarean at ≥32-34 wks then definitive surgery
2nd trimester (22-28 wks)YesNACT preferred (paclitaxel/carboplatin weekly or q3 weekly); serial US/MRI to monitor; Cesarean at 32-34 wks + radical hysterectomy + pelvic LND
3rd trimester (28-32 wks)YesNACT to delay delivery to ≥32 wks; Cesarean then immediate radical hysterectomy
3rd trimester (>32-34 wks)YesDeliver now (fetal viability assured); Cesarean + radical hysterectomy + pelvic LND at same sitting
Any - Nodes positive--Immediate treatment without delay; terminate if <22 wks
IB3 (>4 cm): Usually treated as locally advanced disease (see IIB below); NACT often needed; pregnancy termination typically required <22 wks.

FIGO Stage IIA

TrimesterManagement
1stImmediate therapy: terminate pregnancy + radical hysterectomy OR chemoradiation if surgical risk high
2nd (<22 wks)Immediate therapy; chemoradiation or surgery without preserving pregnancy
2nd (>22 wks)Individualized: NACT to buy time to ≥32 wks, then Cesarean + definitive therapy; only if patient insists and nodal status negative
3rdDeliver early when viable (32-34 wks); Cesarean + stage-appropriate management

FIGO Stage IIB-IIIB (Locally Advanced)

TrimesterManagement
1st trimesterImmediate chemoradiation (external beam + brachytherapy + concurrent cisplatin weekly 40 mg/m²); fetal loss will occur
2nd trimester (<22 wks)Immediate treatment = chemoradiation; abortion will occur spontaneously or therapeutic
2nd trimester (>22 wks)Extremely difficult. If patient refuses termination: NACT (paclitaxel/carboplatin) to buy time to ≥32 wks; deliver by Cesarean then chemoradiation. Only in select cases with close monitoring.
3rd trimester (>28-32 wks)Deliver immediately (Cesarean at ≥32 wks); begin definitive chemoradiation postpartum
AdjuvantCisplatin-based concurrent chemoradiation ± brachytherapy as per non-pregnant guidelines postpartum

FIGO Stage IVA / IVB (Metastatic / Distant)

TrimesterManagement
Any trimesterImmediate systemic chemotherapy (palliative intent); pregnancy termination strongly advised; radiation if pelvic control needed; no delay acceptable
3rd trimesterDeliver by Cesarean then initiate systemic therapy; individualize per performance status

Neoadjuvant Chemotherapy (NACT) in Pregnancy - Key Facts

ParameterDetail
When to startNo earlier than 14 weeks gestation (organogenesis complete)
Preferred regimen (ESGO/INCIP 2025)Paclitaxel/Carboplatin - weekly OR q3-weekly
AlternativeCisplatin-based regimens
PurposeControl disease progression while allowing fetal maturity
Last cycle≥3 weeks before planned delivery (bone marrow recovery)
MonitoringSerial MRI (no gadolinium) and transvaginal/transrectal ultrasound every 4-6 wks
ContraindicationsKnown hypersensitivity; severe hepatic dysfunction
Fetal effectsLow birth weight risk; avoid <14 wks (teratogenesis risk)

Mode of Delivery - Critical Considerations

ConsiderationEvidence/Recommendation
Cesarean sectionStrongly preferred for all stages (ESGO 2023, NCCN 2024, Creasy & Resnik)
Vaginal delivery riskVaginal delivery is the most significant predictor of recurrence (multivariate analysis, 56 cases)
Recurrence pattern after vaginal deliveryPredominantly distant metastases
Episiotomy site recurrenceRare but reported - inspect closely at follow-up
Optimal gestational age for delivery≥32 weeks preferred; ≥34 weeks ideal
At C-sectionPerform definitive cancer surgery at same sitting if possible

FLOWCHART 1: Initial Assessment of Cervical Cancer Diagnosed in Pregnancy

CERVICAL CANCER DIAGNOSED IN PREGNANCY
               |
               v
    [Multidisciplinary Team Assessment]
    (Gynecologic Oncologist + Perinatologist +
     Neonatologist + Radiation Oncologist)
               |
       +-------+-------+
       |               |
  STAGING           COUNSELING
  (MRI pelvis,    (Maternal prognosis,
  CXR, clinical   fetal status,
  exam, SLN if    gestational age,
  indicated)      desire to continue
                  pregnancy)
               |
       +-------v-------+
       |               |
  FIGO Stage?      Gestational Age?
  IA1/IA2/IB1      1st vs 2nd vs 3rd
  vs IB2-IVB       Trimester

FLOWCHART 2: Management by Gestational Age

GESTATIONAL AGE AT DIAGNOSIS
          |
    +-----+------+-------+
    |             |       |
1st TRIMESTER  2nd TRIM  3rd TRIM
(<14 wks)    (14-28 wks) (>28 wks)
    |             |          |
    v             v          v
Immediate      Node       Fetal
treatment     assessment   maturity
required if  +NACT from   assessment
>IA1, or     14 wks if    (amniocentesis)
terminate    desired         |
pregnancy         |          v
    |             v       Deliver at
    v         Delay to   32-34 wks
Surgery or   ≥32 wks     Cesarean +
CRT without  by Cesarean  definitive
delay         + surgery    surgery

FLOWCHART 3: Stage-Based Algorithm (Condensed)

STAGE IA1 (no LVSI)
  → Follow to term → Cesarean preferred → Postpartum Rx

STAGE IA1 (LVSI+) / IA2
  → SLN assessment → Nodes negative? → NACT ± delay to term
  → Nodes positive? → Immediate treatment (terminate if <22 wks)

STAGE IB1–IB2
  → 1st/early 2nd trimester: Gravid radical hysterectomy OR NACT
  → Late 2nd/3rd: NACT → Cesarean ≥32 wks → Radical hysterectomy

STAGE IB3–IIA
  → <22 wks: Immediate treatment (termination)
  → >22 wks: NACT bridge → Cesarean ≥32 wks → Definitive CRT

STAGE IIB–IV
  → <22 wks: Immediate CRT (terminate)
  → >28 wks: Early delivery → Postpartum CRT
  → Concurrent cisplatin 40 mg/m² weekly + EBRT + brachytherapy

TABLE: Fertility-Sparing Options by Stage (ESGO/ESHRE/ESGE 2024)

StageOptionConditions
IA1 (no LVSI)Conization/LLETZNegative margins; followed to term
IA1 (LVSI+) / IA2Simple/modified radical trachelectomyNodes negative; tumor <2 cm
IB1 (≤2 cm)Radical trachelectomy (vaginal or abdominal)Nodes negative; no LVSI; squamous/adenocarcinoma
IB2 (2-4 cm)NACT + radical trachelectomyExperimental; specialized centers only
Any - Nodes positiveNo fertility sparingTerminate + definitive treatment

TABLE: Chemotherapy Safety in Pregnancy

DrugSafety ProfileNotes
CisplatinModerate risk; ototoxicity in neonateAvoid 1st trimester; usable ≥14 wks
CarboplatinPreferred platinum in pregnancyBetter tolerated than cisplatin
PaclitaxelLimited but acceptable dataPreferred taxane; ESGO/INCIP 2025 first choice
VincristineSome data; limited use in cervical caAvoid 1st trimester
BleomycinCaution; pulmonary toxicityLimited experience
BevacizumabCONTRAINDICATEDAnti-angiogenic; fetal harm
PembrolizumabCONTRAINDICATED in pregnancyImmunotherapy - risk of fetal rejection
5-FUAvoid in 1st trimesterLimited cervical cancer data

TABLE: Radiation Therapy in Pregnancy

SituationRecommendation
1st/2nd trimester - advanced stageExternal beam RT + concurrent cisplatin; fetal loss anticipated (spontaneous abortion or therapeutic)
3rd trimesterAvoid; deliver first then initiate CRT postpartum
BrachytherapyPost-delivery only (never in pregnancy)
Fetal dose thresholdDeterministic effects > 10 cGy; CRT doses far exceed this
Anatomic distortionUterine enlargement alters optimal RT field planning

TABLE: Surveillance/Monitoring During Conservative Management

ParameterFrequency
Clinical exam + colposcopyEvery 4-8 weeks during pregnancy
MRI (without gadolinium)Every 6-8 weeks to assess disease progression
Transv. ultrasoundEvery 4 weeks (ESGO/INCIP 2025: suitable for NACT response assessment)
Fetal wellbeingStandard obstetric protocol
Amniocentesis for lung maturityAt 32-34 weeks when planning early delivery
Tumor markers (SCC, CEA)Baseline + monitoring

TABLE: Postpartum Management by Stage

Stage at DiagnosisPostpartum Management
IA1 (no LVSI)Simple hysterectomy (6 wks postpartum) if no further fertility desired; or conization if fertility desired
IA2Modified radical hysterectomy + pelvic LND
IB1-IB2Radical hysterectomy + pelvic LND ± adjuvant CRT based on pathology
IB3-IIARadical hysterectomy or definitive CRT per non-pregnant guidelines
IIB-IVAChemoradiation (EBRT + brachytherapy + weekly cisplatin)
IVBSystemic chemotherapy ± pembrolizumab (if PD-L1 positive)

Special Clinical Scenarios

Patient Refuses Treatment/Termination

  • Thoroughly document counseling
  • Multidisciplinary input mandatory
  • NACT from ≥14 wks may bridge to fetal viability
  • ESGO/INCIP 2025: "Delay of therapy is acceptable in carefully selected patients with stage IA-IB2 disease if nodes are negative; individualize with shared decision-making"
  • Maximum safe delay: up to 32 weeks for stage I-II without compromise in most series

Lymph Node Positivity - The Critical Decision Point

Lymph Node Assessment
       |
  +----+----+
  |         |
NODE      NODE
NEGATIVE  POSITIVE
  |         |
Preserve  Terminate
pregnancy   pregnancy
consider    (if <22 wks)
NACT/      + immediate
surgery     treatment

Postpartum Diagnosis (Within 6 Months of Delivery)

  • Associated with more advanced stage
  • Significantly worse prognosis than during pregnancy
  • Treat per standard non-pregnant guidelines immediately

Summary Quick-Reference Card

Stage1st Trimester (<14 wks)2nd Trimester (14-28 wks)3rd Trimester (>28 wks)
IA1 (no LVSI)Observe/colposcopyObserve; conize only if neededObserve to term; C-section ± postpartum Rx
IA1 (LVSI+)/IA2SLN + observe if N(-); terminate if N(+)SLN + NACT if N(-); immediate Rx if N(+)Deliver at 32-34 wks; C-section + surgery
IB1-IB2Gravid radical hysterectomy OR NACT from 14 wksNACT from 14-16 wks; deliver ≥32 wksNACT → deliver 32-34 wks → radical hysterectomy
IB3-IIATerminate + surgery or CRTTerminate <22 wks; NACT + bridge >22 wksDeliver 32-34 wks; postpartum CRT
IIB-IVATerminate + immediate CRTTerminate <22 wks; urgent CRTDeliver early → immediate postpartum CRT
IVBSystemic chemo; terminateSystemic chemo; discuss pregnancyDeliver immediately; systemic chemo

Key Guideline References

  1. ESGO/ESTRO/ESP 2023 Guidelines - Cervical cancer management including pregnancy section (Cibula et al., Int J Gynecol Cancer 2023; PMID via doi:10.1136/ijgc-2023-004429)
  2. ESGO/INCIP 2025 Guidelines - Gynecological cancers during pregnancy (Amant et al., Int J Gynecol Cancer 2025; PMID 40707270) - most current comprehensive guideline
  3. ESGO/ESHRE/ESGE 2024 - Fertility-sparing treatment in cervical cancer (Morice et al., Lancet Oncol 2024; PMID 39216500)
  4. FIGO 2018 Staging - Now incorporates imaging and surgical pathology findings
  5. NCCN 2024 - Cervical cancer guidelines with pregnancy section
  6. Berek & Novak's Gynecology - Cervical Cancer During Pregnancy, p. 2270-2271
  7. Creasy & Resnik's Maternal-Fetal Medicine - Cervical Carcinoma in Pregnancy, p. 1352-1353

Critical Clinical Principles (ESGO/INCIP 2025):
  1. All CCIP should be managed at specialized, high-volume centers
  2. Multidisciplinary team (gynecologic oncologist + perinatologist + neonatologist + radiation oncologist + psychologist) is mandatory
  3. Lymph node status is the single most critical factor determining whether pregnancy can be preserved
  4. NACT (paclitaxel/carboplatin, weekly preferred) should not start before 14 weeks gestation
  5. Target delivery at ≥32 weeks whenever possible
  6. Cesarean section is the strongly preferred mode of delivery for all stages (vaginal delivery significantly increases recurrence risk)
  7. Mode of delivery (C-section) + definitive cancer surgery at the same sitting when feasible
  8. Spontaneous (vaginal) delivery has a negative prognostic impact and must be avoided in CCIP

Not able to download as pdf

Reading File
Running Command

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

Running Command

mkdir -p /tmp/workspace/ccip && python3 -c "from reportlab.platypus import SimpleDocTemplate; print('reportlab ok')"

Writing File

~/ccip/generate_ccip_pdf.py

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

OUTPUT = "/tmp/workspace/ccip/CCIP_Management_Guide.pdf"

# ── Colours ──────────────────────────────────────────────────────────────────
DARK_BLUE   = colors.HexColor("#1A3A5C")
MED_BLUE    = colors.HexColor("#2C6FAC")
LIGHT_BLUE  = colors.HexColor("#D6E8F7")
TEAL        = colors.HexColor("#17737A")
TEAL_LIGHT  = colors.HexColor("#D0F0F2")
RED         = colors.HexColor("#C0392B")
RED_LIGHT   = colors.HexColor("#FADBD8")
ORANGE      = colors.HexColor("#D35400")
ORANGE_LIGHT= colors.HexColor("#FDEBD0")
GREEN       = colors.HexColor("#1D6A39")
GREEN_LIGHT = colors.HexColor("#D5F5E3")
PURPLE      = colors.HexColor("#6C3483")
PURPLE_LIGHT= colors.HexColor("#E8DAEF")
GREY_HEADER = colors.HexColor("#2C3E50")
GREY_LIGHT  = colors.HexColor("#ECF0F1")
GREY_MID    = colors.HexColor("#BDC3C7")
WHITE       = colors.white
YELLOW_LIGHT= colors.HexColor("#FEF9E7")

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

def style(name, **kw):
    base = styles[name] if name in styles else styles["Normal"]
    return ParagraphStyle(name + str(id(kw)), parent=base, **kw)

TITLE_S   = style("Normal", fontSize=22, textColor=WHITE, leading=28,
                  alignment=TA_CENTER, fontName="Helvetica-Bold")
SUB_S     = style("Normal", fontSize=12, textColor=LIGHT_BLUE, leading=18,
                  alignment=TA_CENTER, fontName="Helvetica-Oblique")
H1        = style("Normal", fontSize=14, textColor=WHITE, leading=18,
                  fontName="Helvetica-Bold", spaceAfter=2)
H2        = style("Normal", fontSize=11, textColor=DARK_BLUE, leading=15,
                  fontName="Helvetica-Bold", spaceBefore=8, spaceAfter=3)
H3        = style("Normal", fontSize=10, textColor=TEAL, leading=14,
                  fontName="Helvetica-Bold", spaceBefore=4, spaceAfter=2)
BODY      = style("Normal", fontSize=8.5, leading=12, fontName="Helvetica",
                  spaceAfter=2)
BODY_SM   = style("Normal", fontSize=7.5, leading=11, fontName="Helvetica")
BOLD_SM   = style("Normal", fontSize=7.5, leading=11, fontName="Helvetica-Bold")
CELL_H    = style("Normal", fontSize=8, leading=11, textColor=WHITE,
                  fontName="Helvetica-Bold", alignment=TA_CENTER)
CELL_B    = style("Normal", fontSize=7.5, leading=10.5, fontName="Helvetica",
                  alignment=TA_LEFT)
CELL_C    = style("Normal", fontSize=7.5, leading=10.5, fontName="Helvetica",
                  alignment=TA_CENTER)
FOOT_S    = style("Normal", fontSize=7, textColor=colors.grey, leading=10,
                  alignment=TA_CENTER)
BOX_S     = style("Normal", fontSize=8, leading=12, fontName="Helvetica",
                  textColor=DARK_BLUE)
WARN_S    = style("Normal", fontSize=8, leading=12, fontName="Helvetica-Bold",
                  textColor=RED)
NOTE_S    = style("Normal", fontSize=7.5, leading=11, fontName="Helvetica-Oblique",
                  textColor=GREY_HEADER)

# ── Helper Flowables ──────────────────────────────────────────────────────────
def sp(h=4): return Spacer(1, h)

def section_header(text, bg=DARK_BLUE):
    data = [[Paragraph(text, H1)]]
    t = Table(data, colWidths=[17.5*cm])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), bg),
        ("TOPPADDING",    (0,0), (-1,-1), 6),
        ("BOTTOMPADDING", (0,0), (-1,-1), 6),
        ("LEFTPADDING",   (0,0), (-1,-1), 10),
        ("ROUNDEDCORNERS", [4,4,4,4]),
    ]))
    return t

def info_box(text, bg=LIGHT_BLUE, border=MED_BLUE, text_style=BOX_S):
    data = [[Paragraph(text, text_style)]]
    t = Table(data, colWidths=[17.5*cm])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), bg),
        ("BOX",        (0,0), (-1,-1), 1, border),
        ("TOPPADDING",    (0,0), (-1,-1), 6),
        ("BOTTOMPADDING", (0,0), (-1,-1), 6),
        ("LEFTPADDING",   (0,0), (-1,-1), 8),
    ]))
    return t

def warn_box(text):
    return info_box(text, bg=RED_LIGHT, border=RED, text_style=WARN_S)

def note_box(text):
    return info_box(text, bg=YELLOW_LIGHT, border=ORANGE, text_style=NOTE_S)

def make_table(headers, rows, col_widths, header_bg=DARK_BLUE, alt_bg=GREY_LIGHT):
    data = [[Paragraph(h, CELL_H) for h in headers]]
    for i, row in enumerate(rows):
        bg = WHITE if i % 2 == 0 else alt_bg
        data.append([Paragraph(str(c), CELL_B) for c in row])
    t = Table(data, colWidths=col_widths, repeatRows=1)
    style_cmds = [
        ("BACKGROUND",   (0,0), (-1,0), header_bg),
        ("FONTNAME",     (0,0), (-1,0), "Helvetica-Bold"),
        ("ALIGN",        (0,0), (-1,0), "CENTER"),
        ("VALIGN",       (0,0), (-1,-1), "MIDDLE"),
        ("ROWBACKGROUNDS",(0,1),(-1,-1), [WHITE, alt_bg]),
        ("GRID",         (0,0), (-1,-1), 0.4, GREY_MID),
        ("TOPPADDING",   (0,0), (-1,-1), 4),
        ("BOTTOMPADDING",(0,0), (-1,-1), 4),
        ("LEFTPADDING",  (0,0), (-1,-1), 5),
        ("RIGHTPADDING", (0,0), (-1,-1), 5),
    ]
    t.setStyle(TableStyle(style_cmds))
    return t

# ── Flowchart helpers (drawn as table-based boxes) ────────────────────────────
def flow_box(text, bg=MED_BLUE, tc=WHITE, w=17.5*cm):
    s = ParagraphStyle("fb", fontName="Helvetica-Bold", fontSize=8.5,
                       textColor=tc, leading=12, alignment=TA_CENTER)
    t = Table([[Paragraph(text, s)]], colWidths=[w])
    t.setStyle(TableStyle([
        ("BACKGROUND",(0,0),(-1,-1),bg),
        ("BOX",(0,0),(-1,-1),1,GREY_MID),
        ("TOPPADDING",(0,0),(-1,-1),5),
        ("BOTTOMPADDING",(0,0),(-1,-1),5),
        ("ROUNDEDCORNERS",[4,4,4,4]),
    ]))
    return t

def flow_arrow(): return Paragraph("▼", style("Normal", fontSize=10,
    textColor=GREY_HEADER, alignment=TA_CENTER))

def flow_diamond(text, w=17.5*cm):
    s = ParagraphStyle("fd", fontName="Helvetica-Bold", fontSize=8.5,
                       textColor=DARK_BLUE, leading=12, alignment=TA_CENTER)
    t = Table([[Paragraph("◆  " + text + "  ◆", s)]], colWidths=[w])
    t.setStyle(TableStyle([
        ("BACKGROUND",(0,0),(-1,-1),ORANGE_LIGHT),
        ("BOX",(0,0),(-1,-1),1.5,ORANGE),
        ("TOPPADDING",(0,0),(-1,-1),6),
        ("BOTTOMPADDING",(0,0),(-1,-1),6),
    ]))
    return t

def two_col_flow(left_items, right_items, label_left="YES / N(-)", label_right="NO / N(+)"):
    """Two-branch decision flowchart using a 2-col table."""
    def col(items, bg, tc):
        rows = []
        for itm in items:
            s = ParagraphStyle("fc", fontName="Helvetica", fontSize=7.5,
                               textColor=tc, leading=11, alignment=TA_CENTER)
            rows.append([Paragraph(itm, s)])
        return rows

    left_rows  = col(left_items,  GREEN_LIGHT, GREEN)
    right_rows = col(right_items, RED_LIGHT,   RED)
    max_rows = max(len(left_rows), len(right_rows))
    while len(left_rows)  < max_rows: left_rows.append( [Paragraph("", BODY_SM)])
    while len(right_rows) < max_rows: right_rows.append([Paragraph("", BODY_SM)])

    lh = ParagraphStyle("lh", fontName="Helvetica-Bold", fontSize=8,
                        textColor=WHITE, leading=12, alignment=TA_CENTER)
    header_row = [[Paragraph("✓ " + label_left, lh), Paragraph("✗ " + label_right, lh)]]
    data = header_row + [[l[0], r[0]] for l, r in zip(left_rows, right_rows)]
    t = Table(data, colWidths=[8.5*cm, 8.5*cm])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0),(0,0), GREEN),
        ("BACKGROUND", (1,0),(1,0), RED),
        ("BACKGROUND", (0,1),(0,-1), GREEN_LIGHT),
        ("BACKGROUND", (1,1),(1,-1), RED_LIGHT),
        ("GRID",       (0,0),(-1,-1), 0.4, GREY_MID),
        ("VALIGN",     (0,0),(-1,-1), "MIDDLE"),
        ("TOPPADDING", (0,0),(-1,-1), 4),
        ("BOTTOMPADDING",(0,0),(-1,-1),4),
        ("LEFTPADDING", (0,0),(-1,-1), 5),
    ]))
    return t

# ══════════════════════════════════════════════════════════════════════════════
#  BUILD PDF
# ══════════════════════════════════════════════════════════════════════════════
doc = SimpleDocTemplate(
    OUTPUT, pagesize=A4,
    leftMargin=1.8*cm, rightMargin=1.8*cm,
    topMargin=2*cm, bottomMargin=2*cm
)

story = []

# ─── COVER ────────────────────────────────────────────────────────────────────
cover_data = [[
    Paragraph("CERVICAL CANCER IN PREGNANCY", TITLE_S),
    Paragraph("(CCIP) — Comprehensive Management Guide", SUB_S),
    Paragraph("Stage-Wise · Trimester-Wise · Evidence-Based", SUB_S),
    Spacer(1, 6),
    Paragraph("ESGO/INCIP 2025 · ESGO/ESTRO/ESP 2023 · FIGO 2018 · NCCN 2024", FOOT_S),
    Paragraph("Berek & Novak's Gynecology · Creasy & Resnik's Maternal-Fetal Medicine", FOOT_S),
]]
cover_t = Table([[r] for r in cover_data[0]], colWidths=[17.5*cm])
cover_t.setStyle(TableStyle([
    ("BACKGROUND", (0,0),(-1,-1), DARK_BLUE),
    ("TOPPADDING",    (0,0),(-1,-1), 12),
    ("BOTTOMPADDING", (0,0),(-1,-1), 12),
    ("LEFTPADDING",   (0,0),(-1,-1), 14),
    ("ROUNDEDCORNERS",[6,6,6,6]),
]))
story.append(cover_t)
story.append(sp(10))

# ─── EPIDEMIOLOGY ─────────────────────────────────────────────────────────────
story.append(section_header("1. EPIDEMIOLOGY & KEY FACTS"))
story.append(sp(6))
epi_rows = [
    ["Incidence", "~1.2 per 10,000 pregnancies"],
    ["Rank", "Most common gynecologic malignancy in pregnancy (alongside breast cancer, melanoma, lymphoma)"],
    ["Diagnosis timing", "Usually at first-trimester cervical screening; often delayed due to bleeding attributed to obstetric causes"],
    ["Prognosis in pregnancy", "Slightly better OS (higher proportion of stage I); postpartum diagnosis carries worse prognosis"],
    ["Postpartum (within 6 mo)", "Associated with more advanced stage and significantly worse outcomes — treat immediately per non-pregnant guidelines"],
]
story.append(make_table(["Parameter", "Detail"], epi_rows,
                         [5.5*cm, 12*cm], header_bg=TEAL, alt_bg=TEAL_LIGHT))
story.append(sp(8))

# ─── STAGING ──────────────────────────────────────────────────────────────────
story.append(section_header("2. FIGO 2018 STAGING (Used Throughout)"))
story.append(sp(6))
staging_rows = [
    ["IA1", "Microscopic invasion ≤3 mm depth, ≤7 mm width"],
    ["IA2", "Microscopic invasion 3–5 mm depth, ≤7 mm width"],
    ["IB1", "Clinically visible ≤2 cm OR microscopic >IA2"],
    ["IB2", "Clinically visible, 2–4 cm"],
    ["IB3", "Clinically visible, >4 cm"],
    ["IIA", "Extension to upper 2/3 vagina; no parametrial involvement"],
    ["IIB", "Parametrial involvement"],
    ["IIIA/IIIB", "Lower vagina / pelvic wall / hydronephrosis"],
    ["IVA/IVB", "Bladder or rectum invasion / distant metastases"],
]
story.append(make_table(["Stage", "Description"], staging_rows,
                         [3*cm, 14.5*cm]))
story.append(sp(8))

# ─── DIAGNOSIS ────────────────────────────────────────────────────────────────
story.append(section_header("3. DIAGNOSIS & INVESTIGATIONS IN PREGNANCY"))
story.append(sp(6))
dx_rows = [
    ["Pap smear", "ALL trimesters", "Perform at FIRST prenatal visit"],
    ["Colposcopy", "ALL trimesters", "Safe; NO endocervical curettage"],
    ["Cervical biopsy", "ALL trimesters", "Safe; perform for grossly suspicious lesions"],
    ["Conization (diagnostic)", "AVOID in 1st trimester", "Abortion risk up to 33%; prefer 2nd trimester; only if cancer cannot be excluded by biopsy/colposcopy"],
    ["MRI (no gadolinium)", "ALL trimesters", "PREFERRED imaging — safe; use for local staging and tumor extent"],
    ["Chest X-ray + shielding", "ALL trimesters", "Acceptable; fetal dose <0.001 cGy"],
    ["CT abdomen/pelvis", "Use with caution", "Fetal dose ~1–2 cGy; use only when essential; avoid in 1st trimester"],
    ["PET scan", "AVOID", "Limited fetal safety data; use only if no alternative"],
    ["SLN biopsy (⁹⁹ᵐTc only)", "1st/2nd trimester", "Feasible; NO blue dye (Patent Blue V); ESGO/INCIP 2025 supports this"],
    ["Amniocentesis", "3rd trimester", "For fetal lung maturity before planned early delivery"],
]
story.append(make_table(
    ["Investigation", "When Safe", "Notes"],
    dx_rows, [4.5*cm, 3.5*cm, 9.5*cm], header_bg=MED_BLUE
))
story.append(sp(8))

# ─── MASTER MANAGEMENT TABLE ──────────────────────────────────────────────────
story.append(section_header("4. MASTER MANAGEMENT TABLE: STAGE × TRIMESTER"))
story.append(sp(6))
story.append(info_box(
    "KEY PRINCIPLE: Management must be individualized. Multidisciplinary team (gynecologic oncologist + perinatologist "
    "+ neonatologist + radiation oncologist + psychologist) is MANDATORY for every case. "
    "Lymph node status is the SINGLE most critical factor determining whether pregnancy can be preserved.",
    bg=LIGHT_BLUE, border=MED_BLUE
))
story.append(sp(6))

mgmt_rows = [
    # IA1 no LVSI
    ["IA1\n(No LVSI)",
     "1st (<14 wks)",
     "Observe; avoid conization; repeat colposcopy in 2nd trimester",
     "Cesarean preferred → postpartum Rx"],
    ["IA1\n(No LVSI)",
     "2nd (14–28 wks)",
     "Observe; conize only if cancer cannot be excluded",
     "Cesarean preferred → postpartum Rx"],
    ["IA1\n(No LVSI)",
     "3rd (>28 wks)",
     "Observe to fetal maturity",
     "Cesarean → simple hysterectomy 6 wks postpartum (or conization if fertility desired)"],
    # IA1 LVSI / IA2
    ["IA1 (LVSI+)\nor IA2",
     "1st",
     "SLN biopsy (⁹⁹ᵐTc); if N(−): observe/NACT from 14 wks;\nif N(+): terminate + immediate treatment",
     "C-section + modified radical hysterectomy + pelvic LND at/after delivery"],
    ["IA1 (LVSI+)\nor IA2",
     "2nd",
     "SLN biopsy; if N(−): NACT to delay to ≥32 wks;\nif N(+): immediate chemoradiation",
     "C-section 32–34 wks + radical hysterectomy + LND"],
    ["IA1 (LVSI+)\nor IA2",
     "3rd",
     "Deliver at 32–34 wks when lung maturity confirmed (amniocentesis)",
     "C-section + modified radical hysterectomy + pelvic LND"],
    # IB1-IB2
    ["IB1–IB2\n(≤4 cm)",
     "1st",
     "Option A: Gravid radical hysterectomy + pelvic LND (in situ fetus)\nOption B: SLN → if N(−), NACT from 14 wks → radical trachelectomy (experimental)\nIf N(+): terminate + definitive treatment",
     "Per nodal status; see below"],
    ["IB1–IB2\n(≤4 cm)",
     "2nd (<22 wks)",
     "Gravid radical hysterectomy OR NACT (carboplatin/paclitaxel) from ≥14 wks\nMonitor with MRI q6–8 wks + US q4 wks",
     "C-section ≥32 wks + radical hysterectomy + LND"],
    ["IB1–IB2\n(≤4 cm)",
     "2nd (22–28 wks)",
     "NACT preferred (carboplatin/paclitaxel weekly or q3wk)\nLast cycle ≥3 wks before delivery",
     "C-section 32–34 wks + radical hysterectomy"],
    ["IB1–IB2\n(≤4 cm)",
     "3rd (28–32 wks)",
     "NACT to buy time to ≥32 wks",
     "C-section + radical hysterectomy + LND at same sitting"],
    ["IB1–IB2\n(≤4 cm)",
     "3rd (>32–34 wks)",
     "Deliver promptly (fetal viability assured)",
     "C-section + radical hysterectomy at same sitting"],
    # IB3
    ["IB3\n(>4 cm)",
     "1st/early 2nd",
     "Terminate pregnancy → definitive chemoradiation OR neoadjuvant chemo + surgery",
     "Per non-pregnant IB3 guidelines postpartum"],
    ["IB3\n(>4 cm)",
     "Late 2nd/3rd",
     "NACT bridge; if N(+): terminate + immediate CRT",
     "C-section ≥32 wks → definitive CRT"],
    # IIA
    ["IIA",
     "1st / early 2nd (<22 wks)",
     "Immediate treatment; terminate pregnancy + chemoradiation or radical surgery",
     "Per non-pregnant IIA guidelines"],
    ["IIA",
     "Late 2nd/3rd (>22 wks)",
     "Individualize: NACT bridge if N(−) and patient refuses termination; target ≥32 wks",
     "C-section + definitive CRT postpartum"],
    # IIB-IIIB
    ["IIB–IIIB\n(Locally Advanced)",
     "1st",
     "IMMEDIATE chemoradiation (EBRT + weekly cisplatin 40 mg/m²)\nFetal loss will occur (spontaneous or therapeutic)",
     "N/A — no fetal preservation possible"],
    ["IIB–IIIB\n(Locally Advanced)",
     "2nd (<22 wks)",
     "Immediate treatment; therapeutic termination or wait for spontaneous fetal loss from CRT",
     "Definitive CRT + brachytherapy as non-pregnant"],
    ["IIB–IIIB\n(Locally Advanced)",
     "2nd (>22 wks)",
     "NACT only if patient refuses termination; extreme caution; multidisciplinary decision",
     "Early C-section ≥32 wks → postpartum CRT"],
    ["IIB–IIIB\n(Locally Advanced)",
     "3rd (>28 wks)",
     "Deliver by C-section as soon as viable (≥32 wks preferred)",
     "Begin definitive CRT immediately postpartum"],
    # IVA/IVB
    ["IVA/IVB\n(Metastatic)",
     "Any trimester",
     "Immediate systemic therapy; termination strongly advised; NO delay acceptable",
     "Systemic chemo ± pembrolizumab (post-delivery); RT for pelvic control"],
    ["IVA/IVB\n(Metastatic)",
     "3rd trimester",
     "Deliver by C-section immediately; start systemic therapy without delay",
     "Individualize per PS; palliative intent"],
]

story.append(make_table(
    ["Stage", "Trimester", "Management During Pregnancy", "Definitive Treatment"],
    mgmt_rows,
    [2.5*cm, 2.5*cm, 7*cm, 5.5*cm],
    header_bg=DARK_BLUE
))
story.append(sp(8))

# ─── FLOWCHART 1 ──────────────────────────────────────────────────────────────
story.append(PageBreak())
story.append(section_header("5. FLOWCHART 1 — Initial Assessment & Triage"))
story.append(sp(6))
story.append(flow_box("CERVICAL CANCER DIAGNOSED IN PREGNANCY", bg=DARK_BLUE))
story.append(sp(3)); story.append(flow_arrow()); story.append(sp(3))
story.append(flow_box("MULTIDISCIPLINARY TEAM ASSESSMENT\nGynecologic Oncologist · Perinatologist · Neonatologist · Radiation Oncologist · Psychologist", bg=MED_BLUE))
story.append(sp(3)); story.append(flow_arrow()); story.append(sp(3))

# Two parallel boxes
p1 = flow_box("STAGING\n• MRI pelvis (no gadolinium)\n• CXR + shielding\n• Colposcopy + biopsy\n• SLN biopsy (⁹⁹ᵐTc) if indicated\n• Chest CT if needed", bg=TEAL, w=8.5*cm)
p2 = flow_box("COUNSELING\n• Maternal prognosis\n• Fetal status + gestational age\n• Desire to continue pregnancy\n• Fertility wishes\n• Risks of treatment delay", bg=PURPLE, w=8.5*cm)
two_p = Table([[p1, p2]], colWidths=[8.75*cm, 8.75*cm])
two_p.setStyle(TableStyle([("VALIGN",(0,0),(-1,-1),"TOP"),("LEFTPADDING",(0,0),(-1,-1),2)]))
story.append(two_p)
story.append(sp(3)); story.append(flow_arrow()); story.append(sp(3))
story.append(flow_diamond("KEY DECISION: LYMPH NODE STATUS"))
story.append(sp(3))
story.append(two_col_flow(
    ["NODE NEGATIVE (N−)", "▼", "Pregnancy preservation options open",
     "→ Stage IA–IB2: consider NACT / delay to ≥32 wks",
     "→ Stage ≥IB3: individualize based on trimester"],
    ["NODE POSITIVE (N+)", "▼", "Pregnancy preservation NOT recommended",
     "→ <22 wks: terminate pregnancy",
     "→ >22 wks: early delivery then immediate treatment"],
    label_left="N(−) — Nodes Clear", label_right="N(+) — Nodal Disease"
))
story.append(sp(8))

# ─── FLOWCHART 2 ──────────────────────────────────────────────────────────────
story.append(section_header("6. FLOWCHART 2 — Management by Gestational Age"))
story.append(sp(6))
story.append(flow_box("GESTATIONAL AGE AT DIAGNOSIS", bg=DARK_BLUE))
story.append(sp(3)); story.append(flow_arrow()); story.append(sp(3))

trim_data = [
    [
        flow_box("1st TRIMESTER\n< 14 weeks", bg=RED, w=5.5*cm),
        flow_box("2nd TRIMESTER\n14 – 28 weeks", bg=ORANGE, w=5.5*cm),
        flow_box("3rd TRIMESTER\n> 28 weeks", bg=GREEN, w=5.5*cm),
    ],
    [
        Paragraph("▼", style("Normal",fontSize=14,textColor=RED,alignment=TA_CENTER)),
        Paragraph("▼", style("Normal",fontSize=14,textColor=ORANGE,alignment=TA_CENTER)),
        Paragraph("▼", style("Normal",fontSize=14,textColor=GREEN,alignment=TA_CENTER)),
    ],
    [
        flow_box("IMMEDIATE treatment required\nfor stages >IA1\nOR terminate pregnancy\nif patient consents\n\nSurgery or CRT without delay", bg=RED_LIGHT, tc=RED, w=5.5*cm),
        flow_box("NACT from ≥14 wks\nif N(−) and pregnancy desired\n\nLymph node assessment first\nMonitor MRI q6–8 wks\nLast chemo ≥3 wks before delivery", bg=ORANGE_LIGHT, tc=ORANGE, w=5.5*cm),
        flow_box("Fetal maturity assessment\n(amniocentesis 32–34 wks)\n\nTarget delivery ≥32 wks\nC-section + cancer surgery\nat same sitting if feasible", bg=GREEN_LIGHT, tc=GREEN, w=5.5*cm),
    ]
]
trim_t = Table(trim_data, colWidths=[5.83*cm, 5.83*cm, 5.84*cm])
trim_t.setStyle(TableStyle([
    ("VALIGN",(0,0),(-1,-1),"MIDDLE"),
    ("TOPPADDING",(0,0),(-1,-1),4),
    ("BOTTOMPADDING",(0,0),(-1,-1),4),
]))
story.append(trim_t)
story.append(sp(3)); story.append(flow_arrow()); story.append(sp(3))
story.append(flow_box("DELIVER BY CESAREAN SECTION ≥32 WEEKS\n(Cesarean is strongly preferred mode of delivery for ALL stages — vaginal delivery is most significant predictor of recurrence)", bg=DARK_BLUE))
story.append(sp(3)); story.append(flow_arrow()); story.append(sp(3))
story.append(flow_box("DEFINITIVE STAGE-APPROPRIATE TREATMENT POSTPARTUM\n(Radical hysterectomy + LND  OR  Concurrent chemoradiation  OR  Systemic therapy)\nManage identical to non-pregnant patient", bg=GREY_HEADER))
story.append(sp(8))

# ─── FLOWCHART 3 ──────────────────────────────────────────────────────────────
story.append(section_header("7. FLOWCHART 3 — Stage-Based Algorithm (Summary)"))
story.append(sp(6))

algo_rows = [
    ["Stage IA1 (No LVSI)", LIGHT_BLUE, MED_BLUE,
     "Follow to term (all trimesters)  →  Cesarean (preferred)  →  Postpartum Rx (simple hysterectomy or conization)"],
    ["Stage IA1 (LVSI+) / IA2", TEAL_LIGHT, TEAL,
     "SLN biopsy  →  N(−): delay to term or NACT  →  Cesarean + radical hysterectomy\n                     N(+): terminate + immediate treatment"],
    ["Stage IB1–IB2", LIGHT_BLUE, MED_BLUE,
     "1st trim: Gravid radical hysterectomy OR NACT from 14 wks\n2nd/3rd: NACT  →  Cesarean ≥32 wks  →  Radical hysterectomy + LND"],
    ["Stage IB3–IIA", ORANGE_LIGHT, ORANGE,
     "<22 wks: Terminate + immediate surgery/CRT\n>22 wks: NACT bridge  →  Cesarean ≥32 wks  →  Definitive CRT"],
    ["Stage IIB–IVA (Locally Advanced)", RED_LIGHT, RED,
     "<22 wks: Immediate CRT (terminate / spontaneous loss)\n>28 wks: Deliver early  →  Immediate postpartum CRT\nRegimen: Cisplatin 40 mg/m² weekly + EBRT + brachytherapy"],
    ["Stage IVB (Metastatic)", PURPLE_LIGHT, PURPLE,
     "Terminate pregnancy (any trimester) OR deliver immediately if viable\nSystemic chemotherapy ± pembrolizumab (post-delivery)"],
]
for stage, bg, border, text in algo_rows:
    row_data = [[
        Paragraph(stage, ParagraphStyle("sh", fontName="Helvetica-Bold", fontSize=8.5, textColor=border, leading=12)),
        Paragraph(text, ParagraphStyle("sb", fontName="Helvetica", fontSize=8, textColor=GREY_HEADER, leading=11))
    ]]
    t = Table(row_data, colWidths=[4*cm, 13.5*cm])
    t.setStyle(TableStyle([
        ("BACKGROUND",(0,0),(-1,-1),bg),
        ("BOX",(0,0),(-1,-1),1,border),
        ("TOPPADDING",(0,0),(-1,-1),5),
        ("BOTTOMPADDING",(0,0),(-1,-1),5),
        ("LEFTPADDING",(0,0),(-1,-1),6),
        ("VALIGN",(0,0),(-1,-1),"MIDDLE"),
    ]))
    story.append(t)
    story.append(sp(3))

story.append(sp(6))

# ─── NACT TABLE ───────────────────────────────────────────────────────────────
story.append(PageBreak())
story.append(section_header("8. NEOADJUVANT CHEMOTHERAPY (NACT) IN PREGNANCY"))
story.append(sp(6))
story.append(info_box(
    "ESGO/INCIP 2025: NACT is used to control disease progression and delay delivery until fetal viability (≥32 wks). "
    "Start NO earlier than 14 weeks gestation (organogenesis complete). Last cycle must be ≥3 weeks before planned delivery.",
    bg=LIGHT_BLUE, border=MED_BLUE
))
story.append(sp(5))
nact_rows = [
    ["Earliest start",        "≥14 weeks gestation (after organogenesis)"],
    ["Preferred regimen (ESGO/INCIP 2025)", "Paclitaxel/Carboplatin — weekly OR every-3-week cycles"],
    ["Alternative",           "Cisplatin-based regimens (cisplatin 50–70 mg/m² q3wk ± gemcitabine)"],
    ["Last cycle timing",     "≥3 weeks before planned delivery (bone marrow recovery)"],
    ["Disease monitoring",    "MRI (no gadolinium) q6–8 wks; transvaginal/transrectal US q4 wks"],
    ["Fetal monitoring",      "Standard obstetric protocol; biophysical profile; growth scans"],
    ["Target delivery age",   "≥32 weeks (≥34 weeks ideal)"],
    ["Mode of delivery",      "Cesarean section ALWAYS preferred"],
    ["Main fetal risk",       "Low birth weight; myelosuppression in neonate; avoid <14 wks (teratogenesis)"],
    ["Contraindications",     "Known hypersensitivity; severe hepatic dysfunction; 1st trimester (<14 wks)"],
]
story.append(make_table(["Parameter", "Detail"], nact_rows,
                         [6*cm, 11.5*cm], header_bg=TEAL, alt_bg=TEAL_LIGHT))
story.append(sp(8))

# ─── CHEMO SAFETY TABLE ───────────────────────────────────────────────────────
story.append(section_header("9. CHEMOTHERAPY SAFETY PROFILE IN PREGNANCY"))
story.append(sp(6))
chemo_rows = [
    ["Carboplatin",    "✓ Preferred platinum", "Best tolerated; ESGO/INCIP 2025 first choice"],
    ["Paclitaxel",    "✓ Acceptable ≥14 wks",  "Preferred taxane; limited but acceptable data"],
    ["Cisplatin",     "⚠ Moderate risk",        "Ototoxicity in neonate; usable ≥14 wks; avoid 1st trimester"],
    ["Vincristine",   "⚠ Limited data",         "Avoid 1st trimester; limited cervical ca use"],
    ["Bleomycin",     "⚠ Caution",              "Pulmonary toxicity; limited experience in pregnancy"],
    ["Bevacizumab",   "✗ CONTRAINDICATED",      "Anti-angiogenic; confirmed fetal harm"],
    ["Pembrolizumab", "✗ CONTRAINDICATED",      "Immunotherapy — risk of immune-mediated fetal rejection"],
    ["5-FU",          "✗ Avoid 1st trim",       "Teratogenic in 1st trimester; limited data thereafter"],
]
cs = make_table(
    ["Drug", "Safety", "Notes"],
    chemo_rows, [4*cm, 4*cm, 9.5*cm], header_bg=MED_BLUE
)
# colour the safety cells
for i, row in enumerate(chemo_rows):
    safety = row[1]
    if "✓" in safety: bg = GREEN_LIGHT
    elif "✗" in safety: bg = RED_LIGHT
    else: bg = ORANGE_LIGHT
    cs.setStyle(TableStyle([("BACKGROUND",(1,i+1),(1,i+1), bg)]))
story.append(cs)
story.append(sp(8))

# ─── RADIATION TABLE ──────────────────────────────────────────────────────────
story.append(section_header("10. RADIATION THERAPY IN PREGNANCY"))
story.append(sp(6))
rt_rows = [
    ["1st/2nd trimester — advanced stage", "External beam RT + weekly cisplatin 40 mg/m²; fetal loss anticipated (spontaneous or therapeutic)"],
    ["3rd trimester",                       "AVOID RT; deliver by C-section first; initiate CRT postpartum"],
    ["Brachytherapy",                        "Post-delivery ONLY — never in pregnancy"],
    ["Fetal dose threshold",                 "Deterministic effects >10 cGy; standard CRT doses far exceed this — pregnancy loss is expected"],
    ["Anatomic distortion",                  "Uterine enlargement alters optimal RT field planning; requires specialized dosimetry"],
    ["Concurrent cisplatin",                 "40 mg/m² weekly; gold-standard radiosensitizer; same as non-pregnant protocol"],
]
story.append(make_table(["Situation", "Recommendation"], rt_rows,
                         [6.5*cm, 11*cm], header_bg=RED, alt_bg=RED_LIGHT))
story.append(sp(8))

# ─── MODE OF DELIVERY ─────────────────────────────────────────────────────────
story.append(section_header("11. MODE OF DELIVERY — CRITICAL CONSIDERATIONS"))
story.append(sp(6))
story.append(warn_box(
    "⚠  VAGINAL DELIVERY IS THE MOST SIGNIFICANT INDEPENDENT PREDICTOR OF RECURRENCE  ⚠\n"
    "Multivariate analysis of 56 pregnant women with cervical cancer: recurrences after vaginal delivery\n"
    "predominantly involved DISTANT sites. Cesarean section is STRONGLY preferred for ALL stages."
))
story.append(sp(5))
del_rows = [
    ["Mode of delivery",      "Cesarean section STRONGLY preferred for ALL stages"],
    ["Optimal gestational age","≥32 weeks preferred; ≥34 weeks ideal"],
    ["Cesarean timing",        "At same operative sitting as definitive cancer surgery when feasible"],
    ["Vaginal delivery",       "Only if compelling reason; close inspection of episiotomy site required (metastases reported)"],
    ["Fetal lung maturity",    "Confirm by amniocentesis before planned early delivery (32–34 wks)"],
    ["Concomitant surgery",    "Radical hysterectomy + pelvic LND at C-section if nodes previously staged negative"],
    ["Uterotonic agents",      "Oxytocin preferred; ergometrine use is standard; no specific contraindication"],
]
story.append(make_table(["Consideration", "Recommendation"], del_rows,
                         [6*cm, 11.5*cm], header_bg=TEAL, alt_bg=TEAL_LIGHT))
story.append(sp(8))

# ─── FERTILITY SPARING ────────────────────────────────────────────────────────
story.append(section_header("12. FERTILITY-SPARING OPTIONS (ESGO/ESHRE/ESGE 2024)"))
story.append(sp(6))
fs_rows = [
    ["IA1 (No LVSI)", "Conization / LLETZ", "Negative margins; followed to term; cervical cerclage after conization if needed"],
    ["IA1 (LVSI+) / IA2", "Simple or modified radical trachelectomy", "Nodes negative; tumor ≤2 cm; squamous or adenocarcinoma"],
    ["IB1 (≤2 cm)", "Radical trachelectomy (vaginal or abdominal)", "Nodes negative; no LVSI; specialist center only"],
    ["IB2 (2–4 cm)", "NACT + radical trachelectomy", "EXPERIMENTAL; specialized centers only; limited data"],
    ["Any — N(+)", "NO fertility sparing possible", "Terminate + definitive treatment mandatory"],
    ["Any — LVSI+", "Upgrade management to next stage protocol", "LVSI is an adverse factor requiring lymph node assessment"],
]
story.append(make_table(
    ["Stage", "Procedure", "Conditions / Notes"],
    fs_rows, [2.5*cm, 5*cm, 10*cm], header_bg=PURPLE, alt_bg=PURPLE_LIGHT
))
story.append(sp(8))

# ─── MONITORING ───────────────────────────────────────────────────────────────
story.append(section_header("13. MONITORING DURING CONSERVATIVE MANAGEMENT"))
story.append(sp(6))
mon_rows = [
    ["Clinical exam + colposcopy",          "Every 4–8 weeks during pregnancy"],
    ["MRI pelvis (no gadolinium)",          "Every 6–8 weeks to assess disease progression / NACT response"],
    ["Transvaginal/transrectal ultrasound", "Every 4 weeks (ESGO/INCIP 2025: suitable for NACT response assessment)"],
    ["Fetal wellbeing",                     "Standard obstetric protocol; additional biophysical profiles if NACT administered"],
    ["Fetal growth scans",                  "Every 4 weeks (more frequently if NACT given)"],
    ["Amniocentesis",                       "At 32–34 weeks when planning early delivery to confirm lung maturity"],
    ["Tumor markers (SCC, CEA)",            "Baseline then every 4–6 weeks"],
    ["CBC (if on NACT)",                    "Before each cycle; confirm recovery before next cycle"],
]
story.append(make_table(["Assessment", "Frequency / Notes"], mon_rows,
                         [7*cm, 10.5*cm], header_bg=TEAL, alt_bg=TEAL_LIGHT))
story.append(sp(8))

# ─── POSTPARTUM MANAGEMENT ────────────────────────────────────────────────────
story.append(section_header("14. POSTPARTUM MANAGEMENT BY STAGE"))
story.append(sp(6))
pp_rows = [
    ["IA1 (No LVSI)", "Simple hysterectomy (6 wks postpartum) if no further fertility desired; or conization if fertility desired"],
    ["IA2",           "Modified radical hysterectomy + pelvic lymph node dissection"],
    ["IB1–IB2",       "Radical hysterectomy + pelvic LND ± adjuvant CRT (based on final pathology: Sedlis criteria)"],
    ["IB3–IIA",       "Radical hysterectomy OR definitive CRT per standard non-pregnant guidelines"],
    ["IIB–IVA",       "Concurrent chemoradiation: EBRT + intracavitary brachytherapy + weekly cisplatin 40 mg/m²"],
    ["IVB",           "Systemic chemotherapy ± pembrolizumab (if PD-L1 positive); bevacizumab addition if eligible"],
]
story.append(make_table(["Stage", "Postpartum Treatment"], pp_rows,
                         [2.5*cm, 15*cm], header_bg=GREY_HEADER))
story.append(sp(8))

# ─── SPECIAL SCENARIOS ────────────────────────────────────────────────────────
story.append(section_header("15. SPECIAL CLINICAL SCENARIOS"))
story.append(sp(6))

story.append(Paragraph("Patient Refuses Treatment / Termination", H2))
story.append(info_box(
    "• Document counseling thoroughly; multidisciplinary input mandatory.\n"
    "• NACT from ≥14 wks may bridge to fetal viability.\n"
    "• ESGO/INCIP 2025: 'Delay of therapy is acceptable in carefully selected patients with stage IA–IB2 disease if nodes are negative; "
    "individualize with shared decision-making.'\n"
    "• Maximum safe delay: up to 32 weeks for stage I–II without significant compromise in most published series.",
    bg=YELLOW_LIGHT, border=ORANGE
))
story.append(sp(5))

story.append(Paragraph("Postpartum Diagnosis (Within 6 Months of Delivery)", H2))
story.append(info_box(
    "• Associated with more advanced stage and significantly worse prognosis.\n"
    "• Treat immediately per standard non-pregnant guidelines without delay.\n"
    "• Consider rapid weaning from breastfeeding if systemic therapy required.",
    bg=RED_LIGHT, border=RED
))
story.append(sp(5))

story.append(Paragraph("Advanced Imaging Considerations", H2))
img_rows = [
    ["Abdomen CT (with contrast)", "~2 cGy"],
    ["Pelvis CT (with contrast)",  "~2 cGy"],
    ["Abdomen CT (without)",       "~1 cGy"],
    ["Barium meal (fluoroscopy)",  "~3.9 cGy"],
    ["IVP (fluoroscopy)",          "~0.73 cGy"],
    ["Chest X-ray",               "<0.001 cGy"],
    ["Threshold for deterministic effects", ">10 cGy"],
]
story.append(make_table(
    ["Examination", "Estimated Fetal Dose (1st Trimester)"],
    img_rows, [9*cm, 8.5*cm], header_bg=MED_BLUE
))
story.append(note_box("MRI (without gadolinium) is the imaging modality of choice for local staging in pregnancy. "
                      "Gadolinium crosses the placenta and is CLASS C — avoid unless absolutely essential. "
                      "Source: Creasy & Resnik's Maternal-Fetal Medicine, p. 1352"))
story.append(sp(8))

# ─── QUICK REFERENCE SUMMARY ──────────────────────────────────────────────────
story.append(PageBreak())
story.append(section_header("16. QUICK REFERENCE SUMMARY CARD"))
story.append(sp(6))

qr_headers = ["Stage", "1st Trimester (<14 wks)", "2nd Trimester (14–28 wks)", "3rd Trimester (>28 wks)"]
qr_rows = [
    ["IA1\n(No LVSI)",
     "Observe; colposcopy only",
     "Observe; conize only if essential",
     "Observe to term → C-section → postpartum Rx"],
    ["IA1 (LVSI+)\nIA2",
     "SLN → N(−): observe;\nN(+): terminate + Rx",
     "SLN → N(−): NACT + delay;\nN(+): immediate CRT",
     "Deliver 32–34 wks;\nC-section + radical hyst."],
    ["IB1–IB2",
     "Gravid radical hyst. OR\nNACT from 14 wks",
     "NACT from 14–16 wks;\ndeliver ≥32 wks",
     "NACT → deliver 32–34 wks\n→ radical hysterectomy"],
    ["IB3–IIA",
     "Terminate + surgery/CRT",
     "<22 wks: terminate;\n>22 wks: NACT bridge",
     "Deliver 32–34 wks;\npostpartum CRT"],
    ["IIB–IVA",
     "Terminate + immediate CRT",
     "<22 wks: terminate + CRT;\n>22 wks: NACT bridge if refuses",
     "Deliver early →\nimmediate postpartum CRT"],
    ["IVB",
     "Systemic chemo;\nterminate",
     "Systemic chemo;\ndiscuss pregnancy",
     "Deliver immediately;\nsystemic therapy"],
]
story.append(make_table(qr_headers, qr_rows,
                         [2.5*cm, 4.5*cm, 5.25*cm, 5.25*cm],
                         header_bg=DARK_BLUE))
story.append(sp(8))

# ─── REFERENCES ───────────────────────────────────────────────────────────────
story.append(section_header("17. KEY GUIDELINE REFERENCES"))
story.append(sp(6))
ref_rows = [
    ["1", "ESGO/INCIP 2025", "Amant F et al. ESGO/INCIP Guidelines for management of gynecological cancers during pregnancy. Int J Gynecol Cancer 2025. PMID 40707270"],
    ["2", "ESGO/ESTRO/ESP 2023", "Cibula D et al. ESGO/ESTRO/ESP Guidelines for management of patients with cervical cancer — update 2023. Int J Gynecol Cancer 2023;33:649–66"],
    ["3", "ESGO/ESHRE/ESGE 2024", "Morice P et al. Fertility-sparing treatment in cervical, ovarian cancer and borderline tumours. Lancet Oncol 2024. PMID 39216500"],
    ["4", "FIGO 2018 Staging",   "Bhatla N et al. Revised FIGO staging for carcinoma of the cervix uteri. Int J Gynaecol Obstet 2019;145:129–35"],
    ["5", "NCCN 2024",           "National Comprehensive Cancer Network Clinical Practice Guidelines in Oncology: Cervical Cancer v1.2024"],
    ["6", "Berek & Novak",       "Berek JS, Hacker NF. Berek & Novak's Gynecology, 16th ed. Cervical Cancer During Pregnancy, pp. 2270–2271"],
    ["7", "Creasy & Resnik",     "Creasy & Resnik's Maternal-Fetal Medicine, 8th ed. Cervical Carcinoma in Pregnancy, pp. 1352–1353"],
]
story.append(make_table(
    ["#", "Source", "Full Reference"],
    ref_rows, [0.8*cm, 4.5*cm, 12.2*cm], header_bg=GREY_HEADER
))

story.append(sp(10))
story.append(info_box(
    "DISCLAIMER: These guidelines are intended for educational purposes and clinical reference. "
    "Individual patient management must be decided by a qualified multidisciplinary team, taking into account "
    "the patient's clinical status, institutional resources, and patient preferences. "
    "All cases of CCIP should be centralized to high-volume specialized centers (ESGO/INCIP 2025).",
    bg=YELLOW_LIGHT, border=ORANGE, text_style=NOTE_S
))

# ── Build PDF ─────────────────────────────────────────────────────────────────
doc.build(story)
print("PDF generated:", OUTPUT)
Running Command

cd /tmp/workspace/ccip && python3 generate_ccip_pdf.py 2>&1

Running Command

ls -lh /tmp/workspace/ccip/CCIP_Management_Guide.pdf

Your PDF is ready for download:

CCIP Management Guide

PDF Document · PDF

What's inside (17 sections, ~31 KB):
  1. Epidemiology & Key Facts
  2. FIGO 2018 Staging Table
  3. Diagnosis & Investigations in Pregnancy (with safety by trimester)
  4. Master Management Table - every stage (IA1 to IVB) × every trimester
  5. Flowchart 1 - Initial Assessment & Triage (with lymph node decision branch)
  6. Flowchart 2 - Management by Gestational Age (1st / 2nd / 3rd trimester branches)
  7. Flowchart 3 - Stage-Based Algorithm Summary
  8. Neoadjuvant Chemotherapy (NACT) - full protocol table
  9. Chemotherapy Safety Profile (colour-coded: safe / caution / contraindicated)
  10. Radiation Therapy in Pregnancy
  11. Mode of Delivery - critical evidence + warning box
  12. Fertility-Sparing Options (ESGO/ESHRE/ESGE 2024)
  13. Monitoring During Conservative Management
  14. Postpartum Management by Stage
  15. Special Clinical Scenarios (patient refusal, postpartum diagnosis, radiation doses)
  16. Quick Reference Summary Card
  17. Key Guideline References (ESGO/INCIP 2025, ESGO/ESTRO/ESP 2023, NCCN 2024, FIGO 2018, Berek & Novak, Creasy & Resnik)
This is a shared conversation. Sign in to Orris to start your own chat.