The following files are required for me to teach students appearing for the INI SS CET CVTS which is a single best answer multiple choice question examination. Generate 3 files from chapter 123. 1. 5 page High yield notes from the chapter for teaching with probable questions, and include teaching notes, flowcharts, landmark trials, guidelines, tables, memory aids, exam pearls and most probably INI SS Questions. Also include last minute revision tables. 2. 25 MCQs from the chapter in the INI CET SS standard format single best answer, can have a paragraph questions, vignettes, image based questions, photographs with attributes. Source can be the internet as well. Make sure that the PDF has all 25 questions. 3. Answer key with detailed explanation of the correct answer and explanation of the distractors. Do not copy paste the same explanations loop to all answers. Make sure that the explanation pdf has all 25 explanations. Answers can be either a,b,c or d. Explain every correct answer and give distractor analysis as well. Correct answer, explanation, why each distractor is incorrect, relevant guideline, and learning point. Create 3 pdfs with a direct download link. Make sure the questions are based on decision making, guidelines, landmark trials, operative judgement, hemodynamics, clinical scenarios and imaging interpretation. Please provide all 3 sets in downloadable PDF format only with link.

Reading File
Running Command

cd /home/daytona/workspace/attachments/5bba5b05-1fb6-44f3-af9f-7ff13d78df90/ && …

Running Command

mkdir -p /home/daytona/workspace/INI_SS_CVTS_Ch123 && echo "Directory created"

Writing File

~/INI_SS_CVTS_Ch123/generate_hyn.py

#!/usr/bin/env python3
"""Generate High Yield Notes PDF for Chapter 123: PA/IVS - INI SS CET CVTS"""

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

OUTPUT = "/home/daytona/workspace/INI_SS_CVTS_Ch123/Ch123_HighYield_Notes.pdf"

# --- Color palette ---
DARK_BLUE   = colors.HexColor("#0D2B6E")
MED_BLUE    = colors.HexColor("#1565C0")
LIGHT_BLUE  = colors.HexColor("#E3F0FF")
TEAL        = colors.HexColor("#00838F")
TEAL_LIGHT  = colors.HexColor("#E0F7FA")
RED         = colors.HexColor("#B71C1C")
RED_LIGHT   = colors.HexColor("#FFEBEE")
ORANGE      = colors.HexColor("#E65100")
ORANGE_LIGHT= colors.HexColor("#FFF3E0")
GREEN       = colors.HexColor("#1B5E20")
GREEN_LIGHT = colors.HexColor("#E8F5E9")
YELLOW      = colors.HexColor("#F9A825")
YELLOW_LIGHT= colors.HexColor("#FFFDE7")
PURPLE      = colors.HexColor("#4A148C")
PURPLE_LIGHT= colors.HexColor("#F3E5F5")
GREY_LIGHT  = colors.HexColor("#F5F5F5")
GREY        = colors.HexColor("#9E9E9E")
BLACK       = colors.black

doc = SimpleDocTemplate(OUTPUT, pagesize=A4,
                        leftMargin=1.5*cm, rightMargin=1.5*cm,
                        topMargin=1.5*cm, bottomMargin=1.5*cm)

styles = getSampleStyleSheet()

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

title_style   = S('Title', fontSize=18, textColor=DARK_BLUE, alignment=TA_CENTER,
                   spaceAfter=4, leading=22, fontName='Helvetica-Bold')
subtitle_style= S('Normal', fontSize=11, textColor=MED_BLUE, alignment=TA_CENTER,
                   spaceAfter=2, leading=14)
tag_style     = S('Normal', fontSize=9, textColor=colors.white, alignment=TA_CENTER,
                   spaceAfter=8, leading=12)
h1_style      = S('Heading1', fontSize=13, textColor=colors.white,
                   fontName='Helvetica-Bold', spaceAfter=0, spaceBefore=6, leading=16)
h2_style      = S('Heading2', fontSize=11, textColor=DARK_BLUE,
                   fontName='Helvetica-Bold', spaceAfter=3, spaceBefore=5, leading=14)
h3_style      = S('Heading3', fontSize=10, textColor=TEAL,
                   fontName='Helvetica-Bold', spaceAfter=2, spaceBefore=3, leading=13)
body_style    = S('Normal', fontSize=9, textColor=BLACK, spaceAfter=2,
                   leading=13, alignment=TA_JUSTIFY)
bullet_style  = S('Normal', fontSize=9, textColor=BLACK, spaceAfter=1,
                   leading=13, leftIndent=12, firstLineIndent=-8)
small_style   = S('Normal', fontSize=8, textColor=BLACK, spaceAfter=1,
                   leading=11, leftIndent=8)
red_bold      = S('Normal', fontSize=9, textColor=RED,
                   fontName='Helvetica-Bold', spaceAfter=1, leading=12)
pearl_style   = S('Normal', fontSize=9, textColor=PURPLE,
                   fontName='Helvetica-Bold', spaceAfter=1, leading=12,
                   leftIndent=10, firstLineIndent=-8)
warn_style    = S('Normal', fontSize=9, textColor=RED,
                   fontName='Helvetica-Bold', spaceAfter=1, leading=12,
                   leftIndent=10, firstLineIndent=-8)
note_style    = S('Normal', fontSize=8.5, textColor=GREEN,
                   fontName='Helvetica-Bold', spaceAfter=1, leading=12)
table_hdr     = S('Normal', fontSize=8.5, textColor=colors.white,
                   fontName='Helvetica-Bold', alignment=TA_CENTER, leading=11)
table_cell    = S('Normal', fontSize=8, textColor=BLACK,
                   alignment=TA_CENTER, leading=10)
table_cell_l  = S('Normal', fontSize=8, textColor=BLACK,
                   alignment=TA_LEFT, leading=10)

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

def colored_box(content_list, bg=LIGHT_BLUE, border=MED_BLUE):
    data = [[c] for c in content_list]
    t = Table([[item] for item in content_list], colWidths=[17*cm])
    t.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,-1), bg),
        ('BOX', (0,0), (-1,-1), 1, border),
        ('TOPPADDING',    (0,0),(-1,-1), 4),
        ('BOTTOMPADDING', (0,0),(-1,-1), 4),
        ('LEFTPADDING',   (0,0),(-1,-1), 8),
        ('RIGHTPADDING',  (0,0),(-1,-1), 8),
    ]))
    return t

def bullet(txt, color=BLACK, bold=False):
    fn = 'Helvetica-Bold' if bold else 'Helvetica'
    st = S('Normal', fontSize=9, textColor=color, spaceAfter=1,
            leading=12, leftIndent=14, firstLineIndent=-10, fontName=fn)
    return Paragraph(u'\u2022 ' + txt, st)

def sub_bullet(txt):
    st = S('Normal', fontSize=8.5, textColor=BLACK, spaceAfter=1,
            leading=12, leftIndent=22, firstLineIndent=-10)
    return Paragraph(u'\u2013 ' + txt, st)

def exam_pearl(txt):
    st = S('Normal', fontSize=9, textColor=PURPLE,
            fontName='Helvetica-Bold', spaceAfter=1, leading=12,
            leftIndent=14, firstLineIndent=-12)
    return Paragraph(u'\u2605 EXAM PEARL: ' + txt, st)

def warn(txt):
    st = S('Normal', fontSize=9, textColor=RED,
            fontName='Helvetica-Bold', spaceAfter=1, leading=12,
            leftIndent=14, firstLineIndent=-12)
    return Paragraph(u'\u26A0 WARNING: ' + txt, st)

def teaching_note(txt):
    st = S('Normal', fontSize=9, textColor=GREEN,
            fontName='Helvetica-Bold', spaceAfter=1, leading=12,
            leftIndent=14, firstLineIndent=-12)
    return Paragraph(u'\u270D TEACHING NOTE: ' + txt, st)

def memory_aid(txt):
    st = S('Normal', fontSize=9.5, textColor=ORANGE,
            fontName='Helvetica-Bold', spaceAfter=1, leading=13,
            leftIndent=14, firstLineIndent=-12)
    return Paragraph(u'\U0001F9E0 MEMORY AID: ' + txt, st)

story = []

# ============================================================
# PAGE 1: TITLE + INTRODUCTION + ANATOMY
# ============================================================
story.append(Spacer(1, 3*mm))

# Title Box
title_data = [
    [Paragraph("HIGH YIELD TEACHING NOTES", title_style)],
    [Paragraph("Chapter 123 | Pulmonary Atresia With Intact Ventricular Septum (PA/IVS)", subtitle_style)],
    [Paragraph("INI SS CET | Cardio-Vascular & Thoracic Surgery | LaPar & Bacha", tag_style)],
]
title_tbl = Table(title_data, colWidths=[17.5*cm])
title_tbl.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,-1), DARK_BLUE),
    ('TOPPADDING',    (0,0),(-1,-1), 6),
    ('BOTTOMPADDING', (0,0),(-1,-1), 6),
    ('LEFTPADDING',   (0,0),(-1,-1), 10),
    ('RIGHTPADDING',  (0,0),(-1,-1), 10),
    ('ROUNDEDCORNERS',[6,6,6,6]),
]))
story.append(title_tbl)
story.append(Spacer(1, 4*mm))

# --- SECTION 1: KEY FACTS ---
story.append(section_header("1. INTRODUCTION & EPIDEMIOLOGY"))
story.append(Spacer(1, 2*mm))
story.append(bullet("Prevalence: 4-8 per 100,000 live births; accounts for 1%-3% of all CHD", color=MED_BLUE, bold=True))
story.append(bullet("Complete RVOT obstruction + intact IVS = hallmark definition"))
story.append(bullet("Duct-dependent pulmonary circulation in neonates — PDA is often the ONLY source of pulmonary blood flow"))
story.append(bullet("First successful repair: Weinberg (1962) — transventricular valvotomy"))
story.append(bullet("Wide phenotypic heterogeneity driven by degree of TV/RV hypoplasia and coronary anatomy"))
story.append(Spacer(1, 2*mm))

# --- ANATOMY ---
story.append(section_header("2. ANATOMY — CRITICAL FEATURES", bg=MED_BLUE))
story.append(Spacer(1, 2*mm))

story.append(Paragraph("<b>A. Tricuspid Valve (TV) — THE KEY PREDICTOR</b>", h2_style))

tv_data = [
    [Paragraph("TV z-score", table_hdr),
     Paragraph("RV Morphology", table_hdr),
     Paragraph("RVOT Infundibulum", table_hdr),
     Paragraph("RVDCC Risk", table_hdr),
     Paragraph("Repair Goal", table_hdr)],
    [Paragraph(">−2", table_cell), Paragraph("Tripartite (normal)", table_cell),
     Paragraph("Present", table_cell), Paragraph("Rare", table_cell), Paragraph("Biventricular", table_cell)],
    [Paragraph("−2 to −4", table_cell), Paragraph("Bipartite", table_cell),
     Paragraph("Intermediate", table_cell), Paragraph("Possible", table_cell), Paragraph("1.5-ventricle", table_cell)],
    [Paragraph("<−4", table_cell), Paragraph("Unipartite", table_cell),
     Paragraph("Absent", table_cell), Paragraph("Common", table_cell), Paragraph("Single-ventricle", table_cell)],
]
tv_tbl = Table(tv_data, colWidths=[2.8*cm, 3.8*cm, 3.5*cm, 2.8*cm, 3.6*cm])
tv_tbl.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), DARK_BLUE),
    ('BACKGROUND', (0,1), (-1,1), GREEN_LIGHT),
    ('BACKGROUND', (0,2), (-1,2), ORANGE_LIGHT),
    ('BACKGROUND', (0,3), (-1,3), RED_LIGHT),
    ('BOX',   (0,0), (-1,-1), 1, DARK_BLUE),
    ('GRID',  (0,0), (-1,-1), 0.5, GREY),
    ('TOPPADDING',    (0,0),(-1,-1), 3),
    ('BOTTOMPADDING', (0,0),(-1,-1), 3),
    ('LEFTPADDING',   (0,0),(-1,-1), 4),
    ('RIGHTPADDING',  (0,0),(-1,-1), 4),
    ('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
]))
story.append(tv_tbl)
story.append(Spacer(1, 2*mm))

story.append(exam_pearl("TV z-score is the SINGLE MOST IMPORTANT predictor — memorize the cutoffs: ≥−2 = biventricular; −2 to −4 = 1.5V; <−4 = univentricular"))
story.append(Spacer(1, 2*mm))

story.append(Paragraph("<b>B. Right Ventricle Morphology</b>", h2_style))
story.append(bullet("Tripartite (60-80%): inlet + trabecular body + infundibular outlet — most favorable"))
story.append(bullet("Bipartite (15-30%): inlet + body only — apical trabecular overgrowth eliminates outlet"))
story.append(bullet("Unipartite (2-10%): severely hypoplastic — only inlet — worst prognosis"))
story.append(Spacer(1, 2*mm))

story.append(Paragraph("<b>C. Coronary Anatomy — MOST DANGEROUS ASPECT</b>", h2_style))
story.append(bullet("In 45-70%, coronary sinusoids persist (RV-to-coronary artery fistulae) due to hypertensive RV"))
story.append(bullet("RVDCC (Right Ventricle-Dependent Coronary Circulation): ~25% of cases"))
story.append(sub_bullet("Defined as: coronary blood flow partially or completely dependent on RETROGRADE flow from RV"))
story.append(sub_bullet("Mechanism: hypertensive RV drives blood retrogradely into coronary arteries"))
story.append(sub_bullet("Risk: coronary steal + ischemia + sudden death if RV is decompressed"))

coronary_data = [
    [Paragraph("Pattern", table_hdr), Paragraph("Description", table_hdr), Paragraph("Clinical Significance", table_hdr)],
    [Paragraph("A (Normal)", table_cell_l), Paragraph("No fistulae, normal coronary anatomy", table_cell_l), Paragraph("No RVDCC risk", table_cell_l)],
    [Paragraph("B (Fistulae, no stenosis)", table_cell_l), Paragraph("RV-RCA fistulae without stenosis", table_cell_l), Paragraph("Potential steal phenomenon", table_cell_l)],
    [Paragraph("C (Fistulae + stenosis)", table_cell_l), Paragraph("Proximal or distal coronary stenosis", table_cell_l), Paragraph("Steal OR ischemia risk", table_cell_l)],
    [Paragraph("D (RVDCC + ostial atresia)", table_cell_l), Paragraph("Coronary ostial atresia — RV is sole source", table_cell_l), Paragraph("Decompression = DEATH", table_cell_l)],
]
cor_tbl = Table(coronary_data, colWidths=[3.5*cm, 7*cm, 7*cm])
cor_tbl.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), TEAL),
    ('BACKGROUND', (0,1), (-1,1), GREY_LIGHT),
    ('BACKGROUND', (0,4), (-1,4), RED_LIGHT),
    ('BOX',  (0,0), (-1,-1), 1, TEAL),
    ('GRID', (0,0), (-1,-1), 0.5, GREY),
    ('TOPPADDING',    (0,0),(-1,-1), 3),
    ('BOTTOMPADDING', (0,0),(-1,-1), 3),
    ('LEFTPADDING',   (0,0),(-1,-1), 4),
    ('RIGHTPADDING',  (0,0),(-1,-1), 4),
]))
story.append(coronary_data[0][0])
story.append(Spacer(1, 1*mm))
story.append(cor_tbl)
story.append(Spacer(1, 2*mm))
warn("RVDCC with ostial atresia (Pattern D) = ABSOLUTE CONTRAINDICATION to RV decompression — decompressing the RV leads to coronary steal, ischemia and sudden death")
story.append(Spacer(1, 2*mm))

story.append(Paragraph("<b>D. Pulmonary Valve Morphology</b>", h2_style))
story.append(bullet("Membranous atresia (~75%): fused leaflets with thin membrane — most amenable to catheter perforation"))
story.append(bullet("Muscular atresia (~25%): complete obliteration of infundibulum — more severe, associated with RVDCC"))
story.append(Spacer(1, 2*mm))
story.append(memory_aid("TV Z-score = 'TREE': Tripartite (≥−2) = Root; Range (−2 to −4) = trunk; <−4 = bare stump (single ventricle)"))

story.append(PageBreak())

# ============================================================
# PAGE 2: PATHOPHYSIOLOGY + DIAGNOSIS + INITIAL MANAGEMENT
# ============================================================
story.append(section_header("3. PATHOPHYSIOLOGY — FLOWCHART"))
story.append(Spacer(1, 2*mm))

# Flowchart as table
flow_data = [
    ["PULMONARY VALVE ATRESIA + INTACT IVS"],
    ["↓"],
    ["No antegrade pulmonary blood flow through RVOT"],
    ["↓"],
    ["RV pressure rises (suprasystemic in some)"],
    ["↓                                          ↓"],
    ["Competent TV (no TR)                 Severe TR present"],
    ["↓                                          ↓"],
    ["Suprasystemic RV pressure          RV pressure normalizes"],
    ["Coronary sinusoids persist         No RVDCC"],
    ["↓"],
    ["RVDCC develops → coronary blood = retrograde deoxygenated blood"],
    ["↓"],
    ["Egress of RV blood via: (1) PFO/ASD right-to-left shunt + (2) coronary fistulae"],
    ["↓"],
    ["Pulmonary blood flow via PDA (duct-dependent circulation)"],
    ["↓"],
    ["Mixed blood in LA → systemic desaturation (cyanosis)"],
]
ft_tbl = Table([[Paragraph(r[0], S('Normal', fontSize=8.5, textColor=DARK_BLUE,
                fontName='Helvetica-Bold', alignment=TA_CENTER, leading=12))] for r in flow_data],
               colWidths=[17*cm])
ft_tbl.setStyle(TableStyle([
    ('BACKGROUND', (0,0),  (0,0),  DARK_BLUE),
    ('BACKGROUND', (0,13), (0,13), LIGHT_BLUE),
    ('BACKGROUND', (0,16), (0,16), RED_LIGHT),
    ('BOX',  (0,0), (-1,-1), 1, MED_BLUE),
    ('GRID', (0,0), (-1,-1), 0.3, GREY),
    ('TOPPADDING',    (0,0),(-1,-1), 2),
    ('BOTTOMPADDING', (0,0),(-1,-1), 2),
    ('LEFTPADDING',   (0,0),(-1,-1), 6),
]))
# Fix header text color
story.append(ft_tbl)
story.append(Spacer(1, 2*mm))
story.append(teaching_note("A competent TV with no TR → more severe RV hypertension → more likely RVDCC. Paradoxically the WORSE the TV, the SAFER the RVDCC profile."))
story.append(Spacer(1, 2*mm))

story.append(section_header("4. DIAGNOSIS & IMAGING", bg=TEAL))
story.append(Spacer(1, 2*mm))

diag_data = [
    [Paragraph("<b>Modality</b>", table_hdr), Paragraph("<b>Key Findings in PA/IVS</b>", table_hdr), Paragraph("<b>INI SS Points</b>", table_hdr)],
    [Paragraph("ECG", table_cell_l),
     Paragraph("QRS axis 0-120°; DECREASED anterior RV forces", table_cell_l),
     Paragraph("Opposite to RVH pattern — ask 'why?': RV is hypoplastic", table_cell_l)],
    [Paragraph("CXR", table_cell_l),
     Paragraph("Variable cardiac size; REDUCED pulmonary vascularity. If severe TR → massive cardiomegaly (Ebstein-like)", table_cell_l),
     Paragraph("Reduced PBF = pale lung fields", table_cell_l)],
    [Paragraph("Echocardiography (TTE)", table_cell_l),
     Paragraph("PRIMARY diagnostic tool. Assesses: TV size/z-score, RV morphology, infundibulum, PV morphology, PDA, ASD/PFO", table_cell_l),
     Paragraph("FIRST modality of choice", table_cell_l)],
    [Paragraph("Cardiac Cath", table_cell_l),
     Paragraph("RV ventriculography, coronary angiography (MUST to define RVDCC), hemodynamics. Also therapeutic: RF perforation, BAS", table_cell_l),
     Paragraph("DEFINITIVE for coronary anatomy", table_cell_l)],
    [Paragraph("CT / MRI", table_cell_l),
     Paragraph("Expanding role: PA anatomy, RV volume/function, post-op assessment. MRI shows RV growth after repair", table_cell_l),
     Paragraph("Follow-up recruitment assessment", table_cell_l)],
]
diag_tbl = Table(diag_data, colWidths=[3*cm, 8.5*cm, 6*cm])
diag_tbl.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), TEAL),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [GREY_LIGHT, colors.white]),
    ('BOX',  (0,0), (-1,-1), 1, TEAL),
    ('GRID', (0,0), (-1,-1), 0.5, GREY),
    ('TOPPADDING',    (0,0),(-1,-1), 3),
    ('BOTTOMPADDING', (0,0),(-1,-1), 3),
    ('LEFTPADDING',   (0,0),(-1,-1), 4),
    ('RIGHTPADDING',  (0,0),(-1,-1), 4),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
]))
story.append(diag_tbl)
story.append(Spacer(1, 2*mm))
story.append(exam_pearl("TTE is the PRIMARY tool; Cardiac cath is DEFINITIVE for coronary anatomy and RVDCC classification"))
story.append(Spacer(1, 2*mm))

story.append(section_header("5. INITIAL MANAGEMENT & STABILIZATION", bg=ORANGE))
story.append(Spacer(1, 2*mm))
story.append(bullet("Prostaglandin E1 (PGE1) infusion: IMMEDIATE on diagnosis — maintains PDA patency", bold=True, color=RED))
story.append(bullet("Ensure unrestricted atrial-level right-to-left shunt (PFO/ASD) — allows RV decompression"))
story.append(bullet("Cardiac catheterization: coronary angiography + RV ventriculography + consider Balloon Atrial Septostomy (BAS)"))
story.append(bullet("Respiratory support + inotropes if needed for metabolic stabilization"))
story.append(bullet("Assess for RVDCC BEFORE any decompression procedure"))
story.append(Spacer(1, 2*mm))
story.append(memory_aid("PEACH: PGE1 + Echo + Angiography (coronary) + Catheter-based BAS if needed + Hemodynamic stabilization"))

story.append(PageBreak())

# ============================================================
# PAGE 3: SURGICAL MANAGEMENT
# ============================================================
story.append(section_header("6. SURGICAL MANAGEMENT — DECISION ALGORITHM", bg=DARK_BLUE))
story.append(Spacer(1, 2*mm))

story.append(Paragraph("<b>Goals:</b> Biventricular repair is always the PREFERRED goal. Proceed to lesser options only when anatomy mandates.", h3_style))
story.append(Spacer(1, 2*mm))

# Decision flowchart
story.append(Paragraph("<b>NEONATAL DECISION ALGORITHM (INI SS HIGH YIELD)</b>", 
    S('Normal', fontSize=10, textColor=DARK_BLUE, fontName='Helvetica-Bold', alignment=TA_CENTER)))
story.append(Spacer(1, 1*mm))

algo_data = [
    [Paragraph("<b>PA/IVS Diagnosed</b>", S('Normal', fontSize=9, textColor=colors.white, fontName='Helvetica-Bold', alignment=TA_CENTER))],
    [Paragraph("↓  Assess TV z-score + RV morphology + Coronary anatomy", S('Normal', fontSize=8.5, textColor=DARK_BLUE, alignment=TA_CENTER))],
    [Paragraph("↙                    ↓                       ↘", S('Normal', fontSize=9, textColor=DARK_BLUE, alignment=TA_CENTER, fontName='Helvetica-Bold'))],
]
algo_tbl = Table(algo_data, colWidths=[17.5*cm])
algo_tbl.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (0,0), MED_BLUE),
    ('BOX', (0,0), (-1,-1), 1, MED_BLUE),
    ('TOPPADDING',    (0,0),(-1,-1), 3),
    ('BOTTOMPADDING', (0,0),(-1,-1), 3),
    ('LEFTPADDING',   (0,0),(-1,-1), 6),
]))
story.append(algo_tbl)
story.append(Spacer(1, 1*mm))

three_col = [
    [Paragraph("<b>MILD RV HYPOPLASIA</b>\nTV z ≥ −2\nTripartite RV\nNo RVDCC", 
                S('Normal', fontSize=8.5, textColor=GREEN, fontName='Helvetica-Bold', alignment=TA_CENTER, leading=13)),
     Paragraph("<b>MODERATE RV HYPOPLASIA</b>\nTV z −2 to −4\nBipartite RV\nPossible RVDCC",
                S('Normal', fontSize=8.5, textColor=ORANGE, fontName='Helvetica-Bold', alignment=TA_CENTER, leading=13)),
     Paragraph("<b>SEVERE RV HYPOPLASIA</b>\nTV z < −4\nUnipartite RV\nRVDCC likely",
                S('Normal', fontSize=8.5, textColor=RED, fontName='Helvetica-Bold', alignment=TA_CENTER, leading=13))],
    [Paragraph("↓\nRV Decompression\n+ systemic-PA shunt\n(mBT or central)\nor PDA stent",
                S('Normal', fontSize=8, textColor=GREEN, alignment=TA_CENTER, leading=12)),
     Paragraph("↓\nRV Decompression\n+ systemic-PA shunt\nRe-evaluate at\n6-12 months cath",
                S('Normal', fontSize=8, textColor=ORANGE, alignment=TA_CENTER, leading=12)),
     Paragraph("↓\nSystemic-PA shunt\nOR PDA stent\n(NO RV decompression\nif RVDCC present)",
                S('Normal', fontSize=8, textColor=RED, alignment=TA_CENTER, leading=12))],
    [Paragraph("↓\nBiventricular Repair\n(ASD closure + shunt closure\nwhen RV recruited)",
                S('Normal', fontSize=8, textColor=GREEN, fontName='Helvetica-Bold', alignment=TA_CENTER, leading=12)),
     Paragraph("↓\nIF adequate: Biventricular\nIF inadequate: 1.5-ventricle\n(Glenn + RVOT reconstruction)",
                S('Normal', fontSize=8, textColor=ORANGE, fontName='Helvetica-Bold', alignment=TA_CENTER, leading=12)),
     Paragraph("↓\nStaged Single-ventricle\n(BDG @ 3-6 months\n→ Fontan completion)",
                S('Normal', fontSize=8, textColor=RED, fontName='Helvetica-Bold', alignment=TA_CENTER, leading=12))],
]
col_tbl = Table(three_col, colWidths=[5.8*cm, 5.8*cm, 5.9*cm])
col_tbl.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (0,2), GREEN_LIGHT),
    ('BACKGROUND', (1,0), (1,2), ORANGE_LIGHT),
    ('BACKGROUND', (2,0), (2,2), RED_LIGHT),
    ('BOX',  (0,0), (-1,-1), 1.5, DARK_BLUE),
    ('INNERGRID', (0,0), (-1,-1), 0.5, GREY),
    ('TOPPADDING',    (0,0),(-1,-1), 5),
    ('BOTTOMPADDING', (0,0),(-1,-1), 5),
    ('LEFTPADDING',   (0,0),(-1,-1), 4),
    ('RIGHTPADDING',  (0,0),(-1,-1), 4),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
]))
story.append(col_tbl)
story.append(Spacer(1, 2*mm))

story.append(section_header("7. SURGICAL OPTIONS — DETAILED", bg=MED_BLUE))
story.append(Spacer(1, 2*mm))

story.append(Paragraph("<b>A. Neonatal Palliation (Stage 1)</b>", h2_style))
story.append(bullet("Pulmonary blood flow source:"))
story.append(sub_bullet("Modified Blalock-Taussig shunt (mBTS): innominate artery to R pulmonary artery, 3-3.5mm PTFE graft"))
story.append(sub_bullet("Central systemic-PA shunt: aorta to MPA"))
story.append(sub_bullet("PDA stenting (transcatheter): growing popularity as alternative to surgical shunt"))
story.append(bullet("RV Decompression (if feasible and no RVDCC):"))
story.append(sub_bullet("Membranous atresia: transcatheter RF wire perforation + balloon valvuloplasty (preferred), OR surgical valvotomy/valvectomy"))
story.append(sub_bullet("Muscular atresia: surgical infundibulectomy + transannular patch RVOT reconstruction"))
story.append(sub_bullet("PDA ligation after shunt placement"))
story.append(Spacer(1, 1*mm))
story.append(exam_pearl("Post-RV decompression: if RV dysfunction persists, a systemic-PA shunt is STILL needed to augment pulmonary flow while RV recovers"))
story.append(Spacer(1, 1*mm))

story.append(Paragraph("<b>B. Follow-up Catheterization at 6-12 months</b>", h2_style))
story.append(bullet("Temporarily occlude systemic-PA shunt → check saturations"))
story.append(bullet("Temporarily occlude ASD → check RA pressure"))
story.append(bullet("Criteria for biventricular repair: RA pressure <15 mmHg with adequate cardiac output with ASD occluded"))
story.append(bullet("If criteria met: ASD closure (percutaneous) + shunt closure (same cath session)"))
story.append(Spacer(1, 2*mm))

story.append(Paragraph("<b>C. 1.5-Ventricle (Hybrid) Repair</b>", h2_style))
story.append(bullet("For patients with moderate RV hypoplasia unable to support full biventricular circulation"))
story.append(bullet("Components: (1) Superior Cavopulmonary Connection (Bidirectional Glenn) + (2) RVOT reconstruction with transannular patch + RV overhaul + (3) ASD closure (complete or fenestrated 4mm)"))
story.append(bullet("IVC returns to RV normally → augmented by Glenn for SVC blood"))
story.append(bullet("If RA pressure >15 mmHg → fenestrate ASD at 4mm → close percutaneously later"))
story.append(Spacer(1, 2*mm))

story.append(Paragraph("<b>D. Staged Single-Ventricle Palliation (Fontan Pathway)</b>", h2_style))
story.append(bullet("Reserved for: severe RV hypoplasia + RVDCC"))
story.append(bullet("Stage 2 (3-6 months): Bidirectional Glenn (BDG) — superior cavopulmonary connection"))
story.append(bullet("Stage 3 (2-4 years): Fontan completion — total cavopulmonary connection (TCPC)"))
story.append(Spacer(1, 2*mm))

story.append(section_header("8. CPB TECHNIQUE IN RVDCC — CRITICAL", bg=RED))
story.append(Spacer(1, 2*mm))
story.append(bullet("Standard cannulation is DANGEROUS in RVDCC", bold=True, color=RED))
story.append(bullet("Technique: BICAVAL venous cannulation (snared) + RIGHT ATRIAL arterial cannulation"))
story.append(bullet("Maintain RV preload and perfusion during CPB"))
story.append(bullet("Repairs performed with RV FILLED and BEATING to prevent coronary ischemia"))
story.append(bullet("Goal: maintain oxygenated blood delivery to RVDCC-dependent coronary territory"))
story.append(Spacer(1, 2*mm))
story.append(warn("In RVDCC: NEVER allow the RV to be empty/decompressed on bypass — bicaval snaring + RA arterial cannulation maintains RV filling"))

story.append(PageBreak())

# ============================================================
# PAGE 4: OUTCOMES + LANDMARK TRIALS + PROBABLE QUESTIONS
# ============================================================
story.append(section_header("9. SURGICAL OUTCOMES & LANDMARK DATA", bg=TEAL))
story.append(Spacer(1, 2*mm))

outcomes_data = [
    [Paragraph("<b>Study / Data</b>", table_hdr), Paragraph("<b>Key Finding</b>", table_hdr), Paragraph("<b>INI SS Relevance</b>", table_hdr)],
    [Paragraph("Hanley et al. (1993)\nJ Thorac Cardiovasc Surg\n[multiinstitutional]", table_cell_l),
     Paragraph("Landmark multicenter series; established importance of TV/RV morphology and coronary anatomy in predicting outcomes", table_cell_l),
     Paragraph("THE landmark outcomes paper for PA/IVS — frequently referenced", table_cell_l)],
    [Paragraph("Schneider et al. (2014)", table_cell_l),
     Paragraph("87% survival at 10 years in 60 patients", table_cell_l),
     Paragraph("Quote this survival figure", table_cell_l)],
    [Paragraph("Zheng et al. (2016)\nSingle-center, n=33", table_cell_l),
     Paragraph("Single-stage: 97/94/88% at 1/5/15 years\nStaged: 90/88/69% at 1/5/15 years", table_cell_l),
     Paragraph("Single-stage > staged survival", table_cell_l)],
    [Paragraph("Cheung et al. (2014)\nAnn Thorac Surg", table_cell_l),
     Paragraph("50% mortality in RVDCC; 100% mortality for RVDCC with ostial atresia on single-ventricle pathway", table_cell_l),
     Paragraph("RVDCC + ostial atresia = worst prognosis", table_cell_l)],
    [Paragraph("Elias et al. (long-term\nsingle-ventricle data)", table_cell_l),
     Paragraph("Fontan outcomes: 85% survival at 10yr WITHOUT RVDCC vs significantly worse WITH RVDCC", table_cell_l),
     Paragraph("RVDCC adversely impacts even Fontan outcomes", table_cell_l)],
    [Paragraph("Mayo Clinic Adult PA/IVS\nJohn & Warnes (2012)", table_cell_l),
     Paragraph("ALL 20 adult survivors required reintervention; 80% atrial arrhythmias; 15% ventricular arrhythmias", table_cell_l),
     Paragraph("Long-term morbidity = arrhythmias", table_cell_l)],
    [Paragraph("Congenital Heart\nSurgeons Society (2013)", table_cell_l),
     Paragraph("Long-term functional health; exercise capacity reduced in all repair types", table_cell_l),
     Paragraph("QoL data for PA/IVS", table_cell_l)],
]
out_tbl = Table(outcomes_data, colWidths=[4.5*cm, 8*cm, 5*cm])
out_tbl.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), TEAL),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [GREY_LIGHT, colors.white]),
    ('BOX',  (0,0), (-1,-1), 1, TEAL),
    ('GRID', (0,0), (-1,-1), 0.5, GREY),
    ('TOPPADDING',    (0,0),(-1,-1), 3),
    ('BOTTOMPADDING', (0,0),(-1,-1), 3),
    ('LEFTPADDING',   (0,0),(-1,-1), 4),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
]))
story.append(out_tbl)
story.append(Spacer(1, 2*mm))

# Predictors
story.append(Paragraph("<b>Predictors of Biventricular Repair Success (Evidence-Based)</b>", h2_style))
pred_data = [
    [Paragraph("<b>Favorable Factor</b>", table_hdr), Paragraph("<b>Unfavorable Factor</b>", table_hdr)],
    [Paragraph("TV z-score ≥ −2", table_cell_l), Paragraph("TV z-score < −4", table_cell_l)],
    [Paragraph("Tripartite (normal) RV", table_cell_l), Paragraph("Unipartite RV", table_cell_l)],
    [Paragraph("Absence of RVDCC", table_cell_l), Paragraph("RVDCC present (especially with ostial atresia)", table_cell_l)],
    [Paragraph("Significant tricuspid regurgitation (TR)", table_cell_l), Paragraph("Competent TV (paradoxically promotes RVDCC)", table_cell_l)],
    [Paragraph("Membranous pulmonary atresia", table_cell_l), Paragraph("Muscular pulmonary atresia + no infundibulum", table_cell_l)],
]
pred_tbl = Table(pred_data, colWidths=[8.5*cm, 9*cm])
pred_tbl.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (0,0), GREEN),
    ('BACKGROUND', (1,0), (1,0), RED),
    ('ROWBACKGROUNDS', (0,1), (0,-1), [GREEN_LIGHT, colors.white]),
    ('ROWBACKGROUNDS', (1,1), (1,-1), [RED_LIGHT, colors.white]),
    ('BOX',  (0,0), (-1,-1), 1, DARK_BLUE),
    ('GRID', (0,0), (-1,-1), 0.5, GREY),
    ('TOPPADDING',    (0,0),(-1,-1), 3),
    ('BOTTOMPADDING', (0,0),(-1,-1), 3),
    ('LEFTPADDING',   (0,0),(-1,-1), 6),
]))
story.append(pred_tbl)
story.append(Spacer(1, 2*mm))

story.append(section_header("10. LONG-TERM MORBIDITY", bg=PURPLE))
story.append(Spacer(1, 2*mm))
story.append(bullet("ALL adult survivors require reinterventions (Mayo Clinic data)"))
story.append(bullet("Most common reinterventions: Pulmonary valve replacement (n=6), TV replacement (n=5), MV replacement (n=2)"))
story.append(bullet("Atrial arrhythmias: 80% of all patients — highest in single-ventricle Fontan"))
story.append(bullet("Ventricular arrhythmias: 15%"))
story.append(bullet("RVDCC with ostial atresia undergoing Fontan: 100% mortality (Cheung 2014)"))
story.append(Spacer(1, 2*mm))
story.append(exam_pearl("RVDCC + ostial atresia = prohibitive surgical risk regardless of pathway — worst prognosis in entire PA/IVS spectrum"))

story.append(PageBreak())

# ============================================================
# PAGE 5: PROBABLE INI SS QUESTIONS + MEMORY AIDS + LAST MINUTE REVISION
# ============================================================
story.append(section_header("11. PROBABLE INI SS CET QUESTIONS", bg=DARK_BLUE))
story.append(Spacer(1, 2*mm))

pq_data = [
    [Paragraph("<b>#</b>", table_hdr), Paragraph("<b>Probable Question Stem</b>", table_hdr), Paragraph("<b>Key Answer Point</b>", table_hdr)],
    [Paragraph("1", table_cell), Paragraph("Neonate with cyanosis + reduced pulmonary vascularity + ECG showing LEFT axis deviation and decreased RV forces — diagnosis?", table_cell_l),
     Paragraph("PA/IVS — NOT RVH because RV is hypoplastic", table_cell_l)],
    [Paragraph("2", table_cell), Paragraph("TV z-score of −5, no identifiable RVOT outlet, RVDCC on angiography — best surgical option?", table_cell_l),
     Paragraph("Staged single-ventricle palliation (BDG → Fontan)", table_cell_l)],
    [Paragraph("3", table_cell), Paragraph("PA/IVS patient on CPB for Glenn procedure — how do you cannulate to prevent coronary ischemia in RVDCC?", table_cell_l),
     Paragraph("Bicaval venous + RA arterial cannulation; keep RV filled and beating", table_cell_l)],
    [Paragraph("4", table_cell), Paragraph("Neonate with PA/IVS undergoing cardiac cath — angiography shows coronary arteries filling from RV injection with NO filling from aortic root — significance?", table_cell_l),
     Paragraph("Pattern D RVDCC with ostial atresia — do NOT decompress RV", table_cell_l)],
    [Paragraph("5", table_cell), Paragraph("TV z-score −1.5, tripartite RV, membranous atresia, no RVDCC — catheter-based option?", table_cell_l),
     Paragraph("RF wire perforation + balloon pulmonary valvuloplasty — ideal candidate", table_cell_l)],
    [Paragraph("6", table_cell), Paragraph("At 6-12 month follow-up cath post-RV decompression in PA/IVS — criteria to proceed with biventricular repair?", table_cell_l),
     Paragraph("RA pressure <15 mmHg with adequate cardiac output when ASD is occluded", table_cell_l)],
    [Paragraph("7", table_cell), Paragraph("PA/IVS patient — TV z-score −3, bipartite RV, marginal antegrade flow post-neonatal decompression — best next repair?", table_cell_l),
     Paragraph("1.5-ventricle repair (BDG + RVOT reconstruction + ASD closure)", table_cell_l)],
    [Paragraph("8", table_cell), Paragraph("PA/IVS adult survivor: most common late complication requiring reintervention?", table_cell_l),
     Paragraph("Arrhythmias (80% atrial) + valve replacements (PV most common)", table_cell_l)],
    [Paragraph("9", table_cell), Paragraph("Which pulmonary valve morphology in PA/IVS is MOST amenable to transcatheter perforation?", table_cell_l),
     Paragraph("Membranous atresia (~75% of cases)", table_cell_l)],
    [Paragraph("10", table_cell), Paragraph("RVDCC pathophysiology — why does decompressing the RV cause myocardial ischemia?", table_cell_l),
     Paragraph("Coronary flow is retrograde from hypertensive RV; decompression = loss of retrograde perfusion pressure = coronary steal", table_cell_l)],
]
pq_tbl = Table(pq_data, colWidths=[0.8*cm, 9.7*cm, 7*cm])
pq_tbl.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), DARK_BLUE),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [YELLOW_LIGHT, colors.white]),
    ('BOX',  (0,0), (-1,-1), 1, DARK_BLUE),
    ('GRID', (0,0), (-1,-1), 0.5, GREY),
    ('TOPPADDING',    (0,0),(-1,-1), 3),
    ('BOTTOMPADDING', (0,0),(-1,-1), 3),
    ('LEFTPADDING',   (0,0),(-1,-1), 4),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
]))
story.append(pq_tbl)
story.append(Spacer(1, 3*mm))

# LAST MINUTE REVISION TABLE
story.append(section_header("12. LAST MINUTE REVISION — HIGH YIELD SUMMARY TABLE", bg=RED))
story.append(Spacer(1, 2*mm))

lmr_data = [
    [Paragraph("<b>Topic</b>", table_hdr), Paragraph("<b>Key Fact / Number to Memorize</b>", table_hdr)],
    [Paragraph("Prevalence", table_cell_l), Paragraph("4-8/100,000 live births; 1-3% of all CHD", table_cell_l)],
    [Paragraph("First repair", table_cell_l), Paragraph("Weinberg 1962 — transventricular valvotomy", table_cell_l)],
    [Paragraph("Hallmark anatomy", table_cell_l), Paragraph("Complete RVOTO + IVS intact — no RV-LV communication", table_cell_l)],
    [Paragraph("TV z-score cutoffs", table_cell_l), Paragraph("≥−2: biV; −2 to −4: 1.5V; <−4: single-V", table_cell_l)],
    [Paragraph("RV morphology types", table_cell_l), Paragraph("Tripartite 60-80%; Bipartite 15-30%; Unipartite 2-10%", table_cell_l)],
    [Paragraph("RVDCC incidence", table_cell_l), Paragraph("~25% of PA/IVS cases", table_cell_l)],
    [Paragraph("Coronary sinusoids", table_cell_l), Paragraph("45-70% of PA/IVS have RV-coronary fistulae", table_cell_l)],
    [Paragraph("PV morphology", table_cell_l), Paragraph("Membranous ~75%; Muscular ~25%", table_cell_l)],
    [Paragraph("First-line drug neonatal", table_cell_l), Paragraph("PGE1 infusion — IMMEDIATELY on diagnosis", table_cell_l)],
    [Paragraph("Primary diagnostic tool", table_cell_l), Paragraph("TTE (echocardiography) — primary; Cath for coronary anatomy", table_cell_l)],
    [Paragraph("mBT shunt size", table_cell_l), Paragraph("3 or 3.5mm PTFE — innominate artery to RPA", table_cell_l)],
    [Paragraph("1.5V repair components", table_cell_l), Paragraph("BDG + RVOT patch + RV overhaul + ASD closure (fenestrated if RA>15)", table_cell_l)],
    [Paragraph("BV repair criteria (cath)", table_cell_l), Paragraph("RA pressure <15 mmHg + adequate CO with ASD occluded", table_cell_l)],
    [Paragraph("Stage 2 SV timing", table_cell_l), Paragraph("BDG at 3-6 months; Fontan at 2-4 years", table_cell_l)],
    [Paragraph("CPB in RVDCC", table_cell_l), Paragraph("Bicaval venous + RA arterial cannulation; RV filled + beating", table_cell_l)],
    [Paragraph("10-year survival", table_cell_l), Paragraph("~87-90% overall (Schneider 2014; Hanley 1993)", table_cell_l)],
    [Paragraph("RVDCC + ostial atresia", table_cell_l), Paragraph("100% mortality on single-V palliation (Cheung 2014)", table_cell_l)],
    [Paragraph("Long-term arrhythmia", table_cell_l), Paragraph("Atrial 80%; Ventricular 15% (John & Warnes 2012)", table_cell_l)],
    [Paragraph("TR paradox", table_cell_l), Paragraph("Severe TR = LOWER RV pressure = LESS RVDCC (counterintuitive!)", table_cell_l)],
    [Paragraph("Ebstein-like CXR", table_cell_l), Paragraph("Seen when severe TR → massive RA/RV enlargement", table_cell_l)],
]
lmr_tbl = Table(lmr_data, colWidths=[5*cm, 12.5*cm])
lmr_tbl.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), RED),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [RED_LIGHT, colors.white]),
    ('BOX',  (0,0), (-1,-1), 1, RED),
    ('GRID', (0,0), (-1,-1), 0.5, GREY),
    ('TOPPADDING',    (0,0),(-1,-1), 2),
    ('BOTTOMPADDING', (0,0),(-1,-1), 2),
    ('LEFTPADDING',   (0,0),(-1,-1), 5),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
]))
story.append(lmr_tbl)
story.append(Spacer(1, 3*mm))

# Memory Aids
story.append(section_header("13. MEMORY AIDS & MNEMONICS", bg=ORANGE))
story.append(Spacer(1, 2*mm))
story.append(memory_aid("RV TRIP = TV z-score + Right ventricle morphology + Infundibulum + Perforation type (membranous vs muscular) — the 4 anatomy pillars"))
story.append(memory_aid("'FISH' for coronary patterns: Fistulae + Isolation (ostial atresia) = RVDCC Severity Hierarchy"))
story.append(memory_aid("1.5 Ventricle = 'Half Glenn' pathway: BDG handles SVC, RV handles IVC"))
story.append(memory_aid("Fontan physiology paradox: RVDCC + ostial atresia → 100% mortality even in Fontan = no safe exit"))
story.append(memory_aid("CPB in RVDCC = 'Keep RV Happy': Bicaval snare + RA cannula + Beating heart"))
story.append(Spacer(1, 2*mm))

# Footer
footer_data = [[Paragraph(
    "INI SS CET CVTS | Chapter 123: PA/IVS | High Yield Notes | LaPar & Bacha | "
    "For Educational Use Only",
    S('Normal', fontSize=7.5, textColor=GREY, alignment=TA_CENTER))]]
f_tbl = Table(footer_data, colWidths=[17.5*cm])
f_tbl.setStyle(TableStyle([
    ('TOPPADDING', (0,0),(-1,-1), 3),
    ('BOTTOMPADDING', (0,0),(-1,-1), 3),
    ('LINEABOVE', (0,0), (-1,0), 0.5, GREY),
]))
story.append(f_tbl)

doc.build(story)
print(f"SUCCESS: {OUTPUT}")
Writing File

~/INI_SS_CVTS_Ch123/generate_mcq.py

#!/usr/bin/env python3
"""Generate 25 MCQs PDF for Chapter 123: PA/IVS - INI SS CET CVTS Standard"""

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

OUTPUT = "/home/daytona/workspace/INI_SS_CVTS_Ch123/Ch123_MCQ_25Questions.pdf"

DARK_BLUE   = colors.HexColor("#0D2B6E")
MED_BLUE    = colors.HexColor("#1565C0")
LIGHT_BLUE  = colors.HexColor("#E3F0FF")
TEAL        = colors.HexColor("#00838F")
RED         = colors.HexColor("#B71C1C")
RED_LIGHT   = colors.HexColor("#FFEBEE")
ORANGE      = colors.HexColor("#E65100")
ORANGE_LIGHT= colors.HexColor("#FFF3E0")
GREEN       = colors.HexColor("#1B5E20")
GREEN_LIGHT = colors.HexColor("#E8F5E9")
YELLOW_LIGHT= colors.HexColor("#FFFDE7")
PURPLE      = colors.HexColor("#4A148C")
GREY_LIGHT  = colors.HexColor("#F5F5F5")
GREY        = colors.HexColor("#9E9E9E")
BLACK       = colors.black

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

styles = getSampleStyleSheet()

def S(name, **kw):
    base = styles[name] if name in styles else styles['Normal']
    return ParagraphStyle(name+'_q_'+str(hash(str(kw))), parent=base, **kw)

title_s   = S('Title', fontSize=17, textColor=colors.white, alignment=TA_CENTER,
               spaceAfter=2, leading=21, fontName='Helvetica-Bold')
subtitle_s= S('Normal', fontSize=10, textColor=colors.white, alignment=TA_CENTER,
               spaceAfter=2, leading=13)
qnum_s    = S('Normal', fontSize=10, textColor=colors.white, fontName='Helvetica-Bold',
               alignment=TA_CENTER, leading=13)
q_s       = S('Normal', fontSize=10, textColor=DARK_BLUE, fontName='Helvetica-Bold',
               spaceAfter=4, leading=14, alignment=TA_JUSTIFY)
vignette_s= S('Normal', fontSize=9.5, textColor=BLACK, spaceAfter=3,
               leading=13, alignment=TA_JUSTIFY,
               leftIndent=8, borderPad=4)
opt_s     = S('Normal', fontSize=10, textColor=BLACK, spaceAfter=3,
               leading=13, leftIndent=12)
tag_s     = S('Normal', fontSize=7.5, textColor=TEAL, fontName='Helvetica-Bold',
               spaceAfter=2, leading=10)
img_note_s= S('Normal', fontSize=8.5, textColor=PURPLE, fontName='Helvetica-Bold',
               spaceAfter=2, leading=11, alignment=TA_CENTER)
body_s    = S('Normal', fontSize=9, textColor=BLACK, spaceAfter=2, leading=12)

def header_box(text, sub):
    data = [[Paragraph(text, title_s)],
            [Paragraph(sub, subtitle_s)]]
    t = Table(data, colWidths=[16.5*cm])
    t.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,-1), DARK_BLUE),
        ('TOPPADDING',    (0,0),(-1,-1), 6),
        ('BOTTOMPADDING', (0,0),(-1,-1), 6),
        ('LEFTPADDING',   (0,0),(-1,-1), 10),
    ]))
    return t

def q_header(num, qtype, domain):
    data = [[
        Paragraph(f"Q.{num}", qnum_s),
        Paragraph(f"Type: {qtype}", S('Normal', fontSize=8, textColor=colors.white, alignment=TA_CENTER, leading=11)),
        Paragraph(f"Domain: {domain}", S('Normal', fontSize=8, textColor=colors.white, alignment=TA_CENTER, leading=11)),
    ]]
    t = Table(data, colWidths=[1.5*cm, 7.5*cm, 7.5*cm])
    t.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (0,0), DARK_BLUE),
        ('BACKGROUND', (1,0), (1,0), MED_BLUE),
        ('BACKGROUND', (2,0), (2,0), TEAL),
        ('TOPPADDING',    (0,0),(-1,-1), 3),
        ('BOTTOMPADDING', (0,0),(-1,-1), 3),
        ('LEFTPADDING',   (0,0),(-1,-1), 5),
    ]))
    return t

def vignette_box(text):
    data = [[Paragraph(text, vignette_s)]]
    t = Table(data, colWidths=[16.5*cm])
    t.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,-1), LIGHT_BLUE),
        ('BOX', (0,0), (-1,-1), 1, MED_BLUE),
        ('TOPPADDING',    (0,0),(-1,-1), 5),
        ('BOTTOMPADDING', (0,0),(-1,-1), 5),
        ('LEFTPADDING',   (0,0),(-1,-1), 8),
        ('RIGHTPADDING',  (0,0),(-1,-1), 8),
    ]))
    return t

def image_note(text):
    data = [[Paragraph(f"[IMAGE DESCRIPTION]: {text}", img_note_s)]]
    t = Table(data, colWidths=[16.5*cm])
    t.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,-1), colors.HexColor("#F3E5F5")),
        ('BOX', (0,0), (-1,-1), 1, PURPLE),
        ('TOPPADDING',    (0,0),(-1,-1), 4),
        ('BOTTOMPADDING', (0,0),(-1,-1), 4),
        ('LEFTPADDING',   (0,0),(-1,-1), 8),
    ]))
    return t

def options(a, b, c, d):
    items = []
    for ltr, txt in [('A', a), ('B', b), ('C', c), ('D', d)]:
        items.append(Paragraph(f"<b>({ltr})</b>  {txt}", opt_s))
    return items

def spacer(): return Spacer(1, 3*mm)

story = []

# Title
story.append(header_box(
    "25 MCQs — Pulmonary Atresia With Intact Ventricular Septum (PA/IVS)",
    "INI SS CET | CVTS | Chapter 123 | Single Best Answer | Standard Format"))
story.append(Spacer(1, 2*mm))
story.append(Paragraph(
    "Instructions: Each question has ONE best answer. Questions are based on decision making, "
    "guidelines, landmark trials, operative judgement, hemodynamics, clinical scenarios, and imaging interpretation. "
    "Time: ~37 minutes (1.5 min/question). Negative marking: −1/3.",
    S('Normal', fontSize=9, textColor=DARK_BLUE, alignment=TA_JUSTIFY,
      leading=13, spaceAfter=4, fontName='Helvetica-Bold')))
story.append(HRFlowable(width="100%", thickness=1, color=DARK_BLUE))
story.append(Spacer(1, 3*mm))

# ==============================================================
# QUESTIONS
# ==============================================================

# Q1
story.append(KeepTogether([
    q_header(1, "Clinical Scenario", "Pathophysiology / Hemodynamics"),
    spacer(),
    Paragraph("A 2-day-old male neonate is brought to the emergency department with progressive central cyanosis and respiratory distress. On examination, SpO2 is 62% on room air, improving partially to 74% on supplemental oxygen. Auscultation reveals a single S2 with a continuous murmur. CXR shows mildly reduced pulmonary vascular markings. ECG demonstrates QRS axis of +60° with markedly decreased anterior chest lead forces (V1-V4). Echocardiography reveals complete atresia of the pulmonary valve with no communication between the RVOT and the pulmonary artery, with an intact interventricular septum.", q_s),
    spacer(),
    Paragraph("Which statement BEST describes the primary mechanism maintaining pulmonary blood flow in this neonate?", q_s),
    spacer(),
    *options(
        "Left-to-right shunting via a ventricular septal defect driving pulmonary flow",
        "Retrograde flow from the aorta through a patent ductus arteriosus",
        "Antegrade pulmonary flow through the partially patent RVOT",
        "Pulmonary blood flow via aortopulmonary collateral vessels (MAPCAs)"
    ),
    spacer(),
]))

# Q2
story.append(KeepTogether([
    q_header(2, "Anatomical / Decision Making", "Anatomy — TV z-score & Repair Planning"),
    spacer(),
    Paragraph("A newborn with confirmed PA/IVS undergoes detailed echocardiographic assessment. The tricuspid valve annulus z-score is calculated as −5.2. The right ventricle shows a single identifiable component (inlet only) with complete obliteration of the trabecular body and infundibular outlet.", q_s),
    spacer(),
    Paragraph("Which of the following BEST describes the RV morphology AND the most appropriate long-term surgical pathway for this patient?", q_s),
    spacer(),
    *options(
        "Tripartite RV — proceed directly to biventricular repair after neonatal palliation",
        "Bipartite RV — consider 1.5-ventricle repair after assessing RV recruitment at 6-12 months",
        "Unipartite RV — plan for staged single-ventricle (Fontan) palliation",
        "Bipartite RV — proceed to Fontan completion without interim palliation"
    ),
    spacer(),
]))

# Q3
story.append(KeepTogether([
    q_header(3, "Operative Judgement / Safety", "RVDCC — Contraindication to Decompression"),
    spacer(),
    Paragraph("A 4-day-old neonate with PA/IVS is on PGE1 infusion. Pre-operative cardiac catheterization and angiography is performed. Right ventriculography demonstrates a severely hypoplastic RV cavity. Selective coronary angiography from the aortic root reveals NO antegrade coronary filling. A right ventricular injection, however, opacifies the right coronary artery, left anterior descending artery, and circumflex artery in their entirety in a retrograde fashion.", q_s),
    spacer(),
    Paragraph("What is the MOST important implication of this coronary anatomy for surgical planning?", q_s),
    spacer(),
    *options(
        "RV decompression should be performed urgently to allow biventricular recovery",
        "RV decompression is safe provided a systemic-PA shunt is placed concomitantly",
        "RV decompression is absolutely contraindicated; systemic-PA shunt is the safe initial palliation",
        "Coronary artery bypass grafting should be performed prior to any cardiac repair"
    ),
    spacer(),
]))

# Q4
story.append(KeepTogether([
    q_header(4, "Imaging Interpretation", "Echocardiographic Assessment"),
    spacer(),
    image_note("Transthoracic echocardiogram — Apical 4-chamber view: Small, hypertrophied right ventricle with no identifiable outflow tract. Moderately dysplastic tricuspid valve with color Doppler showing grade 2 tricuspid regurgitation. Normal left ventricular size and function. Patent foramen ovale with bidirectional shunting predominantly right-to-left. No ventricular septal defect."),
    spacer(),
    Paragraph("Based on this echocardiographic description, which of the following pathophysiological mechanisms is MOST responsible for systemic oxygenation in this patient?", q_s),
    spacer(),
    *options(
        "Left-to-right shunting through the VSD ensuring mixing at ventricular level",
        "Right-to-left shunting at atrial level via the PFO combined with pulmonary blood flow via PDA",
        "Antegrade pulmonary arterial flow through partially obstructed RVOT",
        "Pulmonary venous admixture with systemic venous blood in the left atrium"
    ),
    spacer(),
]))

story.append(PageBreak())

# Q5
story.append(KeepTogether([
    q_header(5, "Management / Guidelines", "Initial Stabilization — PGE1"),
    spacer(),
    Paragraph("A term neonate born at 39 weeks gestation is noted to have SpO2 of 68% at 6 hours of life. Echocardiography confirms PA/IVS with ductal-dependent pulmonary circulation. The PDA measures 3mm and is narrowing.", q_s),
    spacer(),
    Paragraph("Which of the following is the MOST urgent pharmacological intervention?", q_s),
    spacer(),
    *options(
        "Intravenous indomethacin to prevent further ductal closure",
        "Prostaglandin E1 infusion to maintain PDA patency",
        "IV milrinone to improve right ventricular function and pulmonary blood flow",
        "Inhaled nitric oxide to reduce pulmonary vascular resistance"
    ),
    spacer(),
]))

# Q6
story.append(KeepTogether([
    q_header(6, "Landmark Trial / Evidence", "Cheung 2014 — RVDCC Outcomes"),
    spacer(),
    Paragraph("A surgical team is counselling the parents of a neonate diagnosed with PA/IVS and right ventricle-dependent coronary circulation (RVDCC) with angiographic demonstration of coronary ostial atresia. They are discussing the prognosis with single-ventricle palliation.", q_s),
    spacer(),
    Paragraph("Based on the landmark study by Cheung and colleagues (Ann Thorac Surg, 2014), what is the reported mortality rate for PA/IVS patients with RVDCC and coronary ostial atresia undergoing single-ventricle palliation?", q_s),
    spacer(),
    *options(
        "Approximately 25%",
        "Approximately 50% overall mortality for RVDCC; up to 100% for those with ostial atresia",
        "Approximately 15%, comparable to PA/IVS without RVDCC",
        "Approximately 75%, but outcomes improve significantly with early Fontan"
    ),
    spacer(),
]))

# Q7
story.append(KeepTogether([
    q_header(7, "Operative Technique", "CPB Cannulation in RVDCC"),
    spacer(),
    Paragraph("A 5-month-old infant with PA/IVS and RVDCC (without ostial atresia) is taken to the operating room for a bidirectional Glenn (BDG) procedure. The surgical team is planning cardiopulmonary bypass cannulation strategy.", q_s),
    spacer(),
    Paragraph("Which cannulation strategy is MOST appropriate to prevent intraoperative myocardial ischemia in this patient?", q_s),
    spacer(),
    *options(
        "Standard aortic arterial cannulation and single right atrial venous cannulation — standard approach",
        "Bicaval venous cannulation with snares and right atrial arterial cannulation; maintain RV filled and beating",
        "Left ventricular venting with aortic cross-clamp and cardioplegic arrest to protect the coronary circulation",
        "Femoral arterial and femoral venous cannulation to decompress the heart completely"
    ),
    spacer(),
]))

# Q8
story.append(KeepTogether([
    q_header(8, "Clinical Scenario / Decision Making", "Follow-up Catheterization Criteria"),
    spacer(),
    Paragraph("An 8-month-old infant with PA/IVS underwent neonatal palliation including RV decompression (transannular patch) and modified Blalock-Taussig shunt. Follow-up cardiac catheterization is performed. With the systemic-PA shunt occluded, SpO2 is 93%. When the ASD is temporarily occluded with a balloon catheter, the right atrial pressure measures 12 mmHg with acceptable cardiac output.", q_s),
    spacer(),
    Paragraph("What is the MOST appropriate next step in management?", q_s),
    spacer(),
    *options(
        "Proceed to staged Fontan palliation — ASD occlusion test suggests RV cannot support biventricular circulation",
        "Perform a bidirectional Glenn procedure to supplement pulmonary blood flow",
        "Proceed with ASD closure (percutaneous) and BT shunt closure — criteria for biventricular repair are met",
        "Continue conservative management with repeat catheterization at 18 months"
    ),
    spacer(),
]))

story.append(PageBreak())

# Q9
story.append(KeepTogether([
    q_header(9, "Anatomy / Surgical Planning", "1.5-Ventricle Repair Indications"),
    spacer(),
    Paragraph("A 14-month-old child with PA/IVS, TV z-score of −3.1, and bipartite RV underwent neonatal palliation with RV decompression + mBT shunt. At 12-month follow-up catheterization, transient ASD occlusion results in an RA pressure of 19 mmHg with falling cardiac output, despite adequate antegrade RVOT flow.", q_s),
    spacer(),
    Paragraph("Which of the following is the MOST appropriate definitive repair strategy for this patient?", q_s),
    spacer(),
    *options(
        "Complete biventricular repair with ASD and shunt closure — RA pressure is acceptable",
        "1.5-ventricle repair: bidirectional Glenn + RVOT reconstruction + fenestrated ASD closure",
        "Staged Fontan palliation — the RV has failed to recruit adequately for biventricular function",
        "Pulmonary valve replacement alone — the obstruction is the limiting factor"
    ),
    spacer(),
]))

# Q10
story.append(KeepTogether([
    q_header(10, "Pathophysiology", "Tricuspid Regurgitation Paradox"),
    spacer(),
    Paragraph("Two neonates with PA/IVS are compared. Neonate A has severe tricuspid regurgitation (TR), while Neonate B has a competent tricuspid valve with no TR. Both have similarly hypoplastic RVs.", q_s),
    spacer(),
    Paragraph("Regarding the risk of right ventricle-dependent coronary circulation (RVDCC), which statement is MOST accurate?", q_s),
    spacer(),
    *options(
        "Both neonates have equal RVDCC risk regardless of TV competence",
        "Neonate A (severe TR) has HIGHER RVDCC risk due to greater volume load on the RV",
        "Neonate B (competent TV) has HIGHER RVDCC risk because RV hypertension is more severe",
        "Neonate A (severe TR) has higher risk because TR causes RV dilation and coronary stretching"
    ),
    spacer(),
]))

# Q11
story.append(KeepTogether([
    q_header(11, "Surgical Options", "Pulmonary Blood Flow Sources"),
    spacer(),
    Paragraph("A neonate with PA/IVS, TV z-score of −4.8, unipartite RV, and RVDCC without ostial atresia requires initial palliation. The interventional cardiology team proposes a transcatheter alternative to surgical palliation.", q_s),
    spacer(),
    Paragraph("Which transcatheter option is currently the MOST widely accepted alternative to a surgical systemic-PA shunt for initial palliation in PA/IVS?", q_s),
    spacer(),
    *options(
        "Transcatheter pulmonary valve implantation (TPVI)",
        "Balloon atrial septostomy (BAS) as the primary palliation",
        "Transcatheter PDA stenting",
        "Radiofrequency wire perforation of the atretic pulmonary valve"
    ),
    spacer(),
]))

story.append(PageBreak())

# Q12
story.append(KeepTogether([
    q_header(12, "Anatomy / ECG Interpretation", "ECG Pattern in PA/IVS"),
    spacer(),
    Paragraph("A 3-day-old neonate with cyanosis undergoes an ECG. The tracing shows QRS axis of +80° and markedly REDUCED R-wave amplitude in leads V1-V4 with dominant S waves. This pattern is unexpected by the resident who anticipated right ventricular hypertrophy findings.", q_s),
    spacer(),
    Paragraph("Which diagnosis BEST explains this ECG pattern, and what is the anatomical explanation?", q_s),
    spacer(),
    *options(
        "Transposition of great arteries — systemic ventricle is the right ventricle causing RVH",
        "PA/IVS — the RV is hypoplastic, resulting in decreased anterior RV electrical forces rather than RVH",
        "Tetralogy of Fallot — infundibular obstruction reduces RV mass",
        "Ebstein anomaly — tricuspid valve displacement reduces effective RV mass"
    ),
    spacer(),
]))

# Q13
story.append(KeepTogether([
    q_header(13, "Clinical Vignette / Long-term Outcomes", "Adult PA/IVS — Late Complications"),
    spacer(),
    Paragraph("A 32-year-old woman with history of PA/IVS repaired in infancy (biventricular repair with transannular patch and BT shunt closure) presents to the adult congenital heart disease clinic. She reports palpitations and intermittent dyspnea on exertion. Holter monitor reveals paroxysmal atrial flutter. She has a history of one pulmonary valve replacement at age 22.", q_s),
    spacer(),
    Paragraph("Based on published long-term data (John & Warnes, Int J Cardiol 2012), which of the following statements about adult survivors of PA/IVS is MOST accurate?", q_s),
    spacer(),
    *options(
        "The majority of adult survivors remain arrhythmia-free without need for reintervention",
        "Atrial arrhythmias occur in 80% and ALL adult survivors require some form of reintervention",
        "Ventricular arrhythmias predominate (>60%), making ICD implantation nearly universal",
        "Single-ventricle Fontan patients have better long-term arrhythmia profiles than biventricular repairs"
    ),
    spacer(),
]))

# Q14
story.append(KeepTogether([
    q_header(14, "Anatomy", "Pulmonary Valve Morphology Types"),
    spacer(),
    Paragraph("A neonate with PA/IVS is evaluated for suitability of transcatheter-based pulmonary valve perforation. Echocardiography shows a hyperechoic, domed structure at the pulmonary annulus with identifiable (albeit fused) leaflet tissue. The infundibulum and RVOT are well-preserved.", q_s),
    spacer(),
    Paragraph("This echocardiographic appearance corresponds to which morphological type of pulmonary atresia, and what proportion of PA/IVS cases does it represent?", q_s),
    spacer(),
    *options(
        "Muscular atresia — present in approximately 75% of PA/IVS cases",
        "Membranous atresia — present in approximately 75% of PA/IVS cases",
        "Membranous atresia — present in approximately 25% of PA/IVS cases",
        "Muscular atresia — present in approximately 25% of PA/IVS cases"
    ),
    spacer(),
]))

story.append(PageBreak())

# Q15
story.append(KeepTogether([
    q_header(15, "Landmark Trial / Outcomes", "Hanley et al. 1993 — Predictors"),
    spacer(),
    Paragraph("A paediatric cardiac surgical team is reviewing predictors of successful biventricular repair in PA/IVS based on published multiinstitutional data including the landmark series by Hanley et al. (J Thorac Cardiovasc Surg, 1993) and subsequent literature.", q_s),
    spacer(),
    Paragraph("Which of the following combination of factors is MOST predictive of achieving biventricular repair?", q_s),
    spacer(),
    *options(
        "TV z-score −5, unipartite RV, absence of RVDCC, membranous atresia",
        "TV z-score ≥ −2, tripartite RV, absence of RVDCC, significant tricuspid regurgitation",
        "TV z-score −3, bipartite RV, RVDCC present, membranous atresia",
        "TV z-score −2, unipartite RV, severe RVDCC, muscular atresia"
    ),
    spacer(),
]))

# Q16
story.append(KeepTogether([
    q_header(16, "Imaging / Intervention", "Role of Cardiac MRI in Follow-up"),
    spacer(),
    Paragraph("A 10-year-old child with history of membranous PA/IVS treated as a neonate with transcatheter wire perforation and balloon pulmonary valvuloplasty (without surgical intervention) undergoes cardiac MRI for routine surveillance. The scan demonstrates a well-developed tripartite right ventricle with normal dimensions and a mildly dilated main pulmonary artery.", q_s),
    spacer(),
    Paragraph("What does this MRI finding MOST importantly demonstrate in the context of PA/IVS management?", q_s),
    spacer(),
    *options(
        "Failure of intervention — a well-developed RV is unexpected after catheter-based treatment alone",
        "Successful RV recruitment and growth following early transcatheter decompression, supporting biventricular outcome",
        "Development of RVDCC over time due to pulmonary regurgitation from the prior valvuloplasty",
        "Indication for urgent pulmonary valve replacement due to RV dilation"
    ),
    spacer(),
]))

# Q17
story.append(KeepTogether([
    q_header(17, "Surgical Decision / Operative Judgement", "Transannular Patch Indication"),
    spacer(),
    Paragraph("A neonate with PA/IVS (membranous atresia, TV z-score −1.8, tripartite RV, no RVDCC) is taken for surgical palliation using cardiopulmonary bypass. After valvotomy and excision of the atretic pulmonary valve tissue and resection of obstructing infundibular muscle bundles, the surgeon notes that the pulmonary annulus appears restrictive.", q_s),
    spacer(),
    Paragraph("Which of the following describes the MOST appropriate surgical reconstruction of the RVOT in this patient?", q_s),
    spacer(),
    *options(
        "Simple closure of the pulmonary arteriotomy without patch — to preserve valve function",
        "Pericardial transannular patch augmentation of the RVOT — to relieve annular restriction and promote RV growth",
        "Pulmonary homograft conduit insertion — gold standard for RVOT reconstruction in neonates",
        "Right ventricle to pulmonary artery conduit (Rastelli-type) — indicated for all PA/IVS repairs"
    ),
    spacer(),
]))

story.append(PageBreak())

# Q18
story.append(KeepTogether([
    q_header(18, "Clinical Scenario / Hemodynamics", "Post-palliation Management"),
    spacer(),
    Paragraph("Following RV decompression with transannular patch and placement of a 3.5mm mBT shunt in a neonate with PA/IVS, the patient is monitored in the ICU. The arterial saturation is 78%, but right ventricular function appears severely impaired on post-operative echocardiography. The ductus arteriosus was ligated intraoperatively.", q_s),
    spacer(),
    Paragraph("The presence of which finding in this post-operative scenario is MOST likely responsible for allowing the patient to maintain adequate systemic output despite severe early RV dysfunction?", q_s),
    spacer(),
    *options(
        "The mBT shunt provides pulmonary blood flow independent of RV function",
        "The intact IVS allows LV to compensate for RV dysfunction",
        "Right-to-left shunting through a residual PFO/small ASD decompresses the RV and maintains systemic output",
        "Systemic hypoxia triggers Bezold-Jarisch reflex improving cardiac output"
    ),
    spacer(),
]))

# Q19
story.append(KeepTogether([
    q_header(19, "Guidelines / Management", "Balloon Atrial Septostomy Indication"),
    spacer(),
    Paragraph("A 1-day-old neonate with PA/IVS has a closing PDA despite PGE1 infusion. Echocardiography shows a restrictive PFO with a mean gradient of 8 mmHg across it and severe systemic venous hypertension. SpO2 is 52% despite maximum PGE1. Cardiac catheterization is being planned.", q_s),
    spacer(),
    Paragraph("In addition to managing the PDA, which catheter-based procedure is MOST urgently indicated at this catheterization to improve hemodynamics?", q_s),
    spacer(),
    *options(
        "Transcatheter pulmonary valve implantation to restore antegrade flow",
        "Balloon atrial septostomy (BAS) to create an unrestricted atrial-level right-to-left shunt",
        "Coronary angioplasty to open the right coronary artery",
        "Balloon dilation of the PDA to increase its diameter"
    ),
    spacer(),
]))

# Q20
story.append(KeepTogether([
    q_header(20, "Anatomy / Classification", "TV z-score and RV Classification"),
    spacer(),
    Paragraph("During an echocardiographic conference, a case of PA/IVS is being discussed. The tricuspid valve annulus z-score is reported as −3.5.", q_s),
    spacer(),
    Paragraph("According to the anatomical classification in the chapter by LaPar and Bacha, which of the following BEST describes the expected right ventricular anatomy and associated features at this TV z-score?", q_s),
    spacer(),
    *options(
        "Tripartite RV with a well-formed infundibular outlet; RVDCC is rare",
        "Bipartite RV with loss of infundibular outlet; RVDCC is possible",
        "Unipartite RV with absent inlet; RVDCC is common",
        "Tripartite RV but with Ebstein-like TV displacement in 80% of cases"
    ),
    spacer(),
]))

story.append(PageBreak())

# Q21
story.append(KeepTogether([
    q_header(21, "Operative Judgement / Landmark Trial", "Zheng 2016 — Single-stage vs Staged"),
    spacer(),
    Paragraph("Parents of a neonate with PA/IVS (TV z-score −1.2, tripartite RV, membranous atresia, no RVDCC) ask the surgical team about survival expectations. The team references the 2016 single-center study by Zheng et al. examining single-stage versus staged repairs.", q_s),
    spacer(),
    Paragraph("Based on Zheng et al. (2016), what were the 15-year survival rates for SINGLE-STAGE versus STAGED repair approaches?", q_s),
    spacer(),
    *options(
        "Single-stage: 69%; Staged: 88% — staged repair has better long-term outcomes",
        "Single-stage: 88%; Staged: 69% — single-stage repair has superior long-term survival",
        "Single-stage: 94%; Staged: 94% — no difference between approaches at 15 years",
        "Single-stage: 75%; Staged: 70% — both approaches show similar intermediate-term outcomes"
    ),
    spacer(),
]))

# Q22
story.append(KeepTogether([
    q_header(22, "Hemodynamics / Critical Care", "Post-Fontan in RVDCC"),
    spacer(),
    Paragraph("A 4-year-old child with PA/IVS, severe RV hypoplasia, and RVDCC (without ostial atresia) is being considered for Fontan completion after a successful bidirectional Glenn at 5 months of age. Pre-Fontan evaluation demonstrates acceptable hemodynamics with low pulmonary artery pressures.", q_s),
    spacer(),
    Paragraph("Which of the following MOST accurately reflects the impact of RVDCC on Fontan outcomes in PA/IVS patients?", q_s),
    spacer(),
    *options(
        "RVDCC has no significant impact on Fontan outcomes once cavopulmonary circulation is established",
        "RVDCC significantly increases Fontan mortality, with 100% mortality specifically in ostial atresia subgroup (Cheung 2014) and reduced survival in other RVDCC subsets",
        "RVDCC actually improves Fontan hemodynamics by providing supplemental coronary augmentation",
        "RVDCC is eliminated by the Fontan procedure as RV pressures normalize"
    ),
    spacer(),
]))

# Q23
story.append(KeepTogether([
    q_header(23, "Imaging / Decision Making", "CXR in PA/IVS"),
    spacer(),
    image_note("Chest radiograph of a 5-day-old neonate with cyanosis: The cardiac silhouette is markedly enlarged occupying >75% of the transverse diameter of the chest. The lung fields show diminished pulmonary vascular markings bilaterally. The cardiac apex appears elevated and rotated suggesting right atrial and right ventricular enlargement."),
    spacer(),
    Paragraph("This CXR appearance in a neonate with PA/IVS is MOST likely associated with which anatomical finding?", q_s),
    spacer(),
    *options(
        "Severe tricuspid regurgitation causing massive right atrial and right ventricular enlargement, similar to Ebstein anomaly",
        "Large unrestrictive ASD causing left-to-right shunting with pulmonary plethora",
        "Severe left heart obstruction causing pulmonary venous hypertension",
        "Bilateral pleural effusions secondary to cardiac failure"
    ),
    spacer(),
]))

story.append(PageBreak())

# Q24
story.append(KeepTogether([
    q_header(24, "Clinical Vignette / Complex Decision", "Choosing the Right Intervention"),
    spacer(),
    vignette_box(
        "CLINICAL VIGNETTE: A 3-day-old term neonate (3.4 kg) is referred with PA/IVS. PGE1 infusion is running. "
        "SpO2 is 78%. Echo shows: TV z-score = −2.8 | Bipartite RV (inlet + body, no infundibular outlet) | "
        "Membranous pulmonary atresia | Small PFO with right-to-left shunting | Normal PA size | "
        "Moderate TR (grade 2). Cardiac catheterization: RV pressure = 95/12 mmHg (systemic = 92/60 mmHg). "
        "Coronary angiography: RV-to-RCA fistulae visible with distal RCA stenosis (Pattern C). "
        "Aortic root injection fills LCA normally; RCA fills both anterograde AND retrograde from RV injection."),
    spacer(),
    Paragraph("What is the MOST appropriate initial palliation strategy for this neonate?", q_s),
    spacer(),
    *options(
        "Surgical RV decompression with transannular patch + mBT shunt (2-stage neonatal palliation) — acceptable as Pattern C RVDCC does not represent complete RV-dependence",
        "Catheter-based RF perforation of the membranous atresia alone — safest given the coronary anatomy",
        "Direct Fontan pathway — no benefit to RV recruitment given bipartite morphology",
        "Transcatheter PDA stenting alone without any attempt at RV decompression — coronary anatomy precludes it entirely"
    ),
    spacer(),
]))

# Q25
story.append(KeepTogether([
    q_header(25, "Comprehensive / High-Order", "Most Important Prognostic Determinant"),
    spacer(),
    Paragraph("A multidisciplinary conference is reviewing five neonates newly diagnosed with PA/IVS. The team discusses the single MOST important anatomical determinant that should guide the entire surgical strategy, predict likelihood of biventricular repair, and predict survival outcomes based on the available evidence from multiple published series.", q_s),
    spacer(),
    Paragraph("Which of the following is considered the MOST important anatomical predictor of surgical pathway and outcomes in PA/IVS?", q_s),
    spacer(),
    *options(
        "Size and morphology of the main pulmonary artery trunk",
        "The presence or absence of right ventricle-dependent coronary circulation (RVDCC) in combination with the tricuspid valve z-score",
        "The type of pulmonary atresia (membranous vs muscular) as a standalone factor",
        "The degree of left ventricular hypertrophy as a compensatory mechanism"
    ),
    spacer(),
    HRFlowable(width="100%", thickness=1, color=DARK_BLUE),
    Paragraph("— End of Question Paper —", S('Normal', fontSize=9, textColor=DARK_BLUE,
                alignment=TA_CENTER, fontName='Helvetica-Bold', spaceAfter=2)),
    Paragraph("INI SS CET CVTS | Chapter 123 PA/IVS | 25 Questions | For Educational Use Only",
              S('Normal', fontSize=8, textColor=GREY, alignment=TA_CENTER, spaceAfter=2)),
]))

doc.build(story)
print(f"SUCCESS: {OUTPUT}")
This is a shared conversation. Sign in to Orris to start your own chat.