attachment
attachment

I ll send you a picture in which there are important question for my prelims examination of 1 st year mbbs which is going to held in 10 days so give answer to these questions with a refrence to any standard book for physiology and in my exam we get good marks for good and neat presentation so please try to make in good presentation and pointwise answer don't make in long paragraphs also divide any questions in topics and subtopics and make it look like good to get me a good marks according to you and then make a pdf for all these answers add diagrams flowchart and table or whatever you want to add which can help me get a good marks

analyse_media
Reading File
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Reading File
Running Command

mkdir -p /home/daytona/workspace/physiology-exam && ls /home/daytona/workspace/p…

Give me the pdf

Writing File

~/physiology-exam/gen_pdf.py


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.platypus import ListItem, ListFlowable
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.graphics.shapes import Drawing, Rect, String, Line, Arrow, Polygon, Circle
from reportlab.graphics.charts.barcharts import VerticalBarChart
from reportlab.graphics import renderPDF
from reportlab.platypus import Flowable
import reportlab.lib.colors as rcolors

# ── Colours ──────────────────────────────────────────────────────────────────
DARK_BLUE   = colors.HexColor("#1a237e")
MID_BLUE    = colors.HexColor("#1565c0")
LIGHT_BLUE  = colors.HexColor("#e3f2fd")
ACCENT      = colors.HexColor("#0288d1")
GREEN       = colors.HexColor("#2e7d32")
LIGHT_GREEN = colors.HexColor("#e8f5e9")
ORANGE      = colors.HexColor("#e65100")
LIGHT_ORG   = colors.HexColor("#fff3e0")
PURPLE      = colors.HexColor("#6a1b9a")
LIGHT_PURP  = colors.HexColor("#f3e5f5")
RED         = colors.HexColor("#c62828")
LIGHT_RED   = colors.HexColor("#ffebee")
TEAL        = colors.HexColor("#00695c")
LIGHT_TEAL  = colors.HexColor("#e0f2f1")
GREY_BG     = colors.HexColor("#f5f5f5")
WHITE       = colors.white
BLACK       = colors.black

# ── Document setup ────────────────────────────────────────────────────────────
doc = SimpleDocTemplate(
    "/home/daytona/workspace/physiology-exam/Physiology_Prelims_Answers.pdf",
    pagesize=A4,
    rightMargin=1.8*cm, leftMargin=1.8*cm,
    topMargin=2*cm, bottomMargin=2*cm
)
W, H = A4

styles = getSampleStyleSheet()

def S(name, **kw):
    """Quick style factory"""
    base = styles.get(name, styles["Normal"])
    return ParagraphStyle(name+"_custom", parent=base, **kw)

cover_title   = S("Title",   fontSize=26, textColor=WHITE, alignment=TA_CENTER, spaceAfter=6, leading=32)
cover_sub     = S("Normal",  fontSize=14, textColor=LIGHT_BLUE, alignment=TA_CENTER, spaceAfter=4)
cover_note    = S("Normal",  fontSize=11, textColor=colors.HexColor("#bbdefb"), alignment=TA_CENTER)

ch_title      = S("Heading1", fontSize=18, textColor=WHITE, alignment=TA_CENTER,
                   spaceBefore=0, spaceAfter=0, leading=22,
                   fontName="Helvetica-Bold")
q_title       = S("Heading2", fontSize=13, textColor=DARK_BLUE,
                   spaceBefore=10, spaceAfter=4, leading=16,
                   fontName="Helvetica-Bold")
sub_head      = S("Heading3", fontSize=11, textColor=MID_BLUE,
                   spaceBefore=6, spaceAfter=3, leading=14,
                   fontName="Helvetica-Bold")
body          = S("Normal",   fontSize=10, textColor=BLACK,
                   spaceAfter=3, leading=14, alignment=TA_JUSTIFY)
bullet_style  = S("Normal",   fontSize=10, textColor=BLACK,
                   spaceAfter=2, leading=13, leftIndent=14,
                   bulletIndent=4)
ref_style     = S("Normal",   fontSize=9, textColor=PURPLE,
                   spaceAfter=2, leading=12, fontName="Helvetica-Oblique")
key_style     = S("Normal",   fontSize=10, textColor=RED,
                   spaceAfter=2, leading=13, fontName="Helvetica-Bold")
note_style    = S("Normal",   fontSize=9.5, textColor=colors.HexColor("#4e342e"),
                   spaceAfter=3, leading=13, leftIndent=8)

def ref(text):
    return Paragraph(f"📚 Reference: {text}", ref_style)

def bullet(items, color=MID_BLUE):
    return ListFlowable(
        [ListItem(Paragraph(i, bullet_style), bulletColor=color, bulletFontSize=9)
         for i in items],
        bulletType='bullet', leftIndent=18, bulletOffsetY=-2
    )

def numbered(items):
    return ListFlowable(
        [ListItem(Paragraph(i, bullet_style), bulletColor=GREEN)
         for i in items],
        bulletType='1', leftIndent=20
    )

def key_point(text):
    return Paragraph(f"★ {text}", key_style)

def note(text):
    return Paragraph(f"Note: {text}", note_style)


# ── Chapter header helper ─────────────────────────────────────────────────────
def chapter_header(title, color=DARK_BLUE):
    data = [[Paragraph(title, ch_title)]]
    t = Table(data, colWidths=[W - 3.6*cm])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), color),
        ("ROUNDEDCORNERS", [8]),
        ("TOPPADDING",    (0,0), (-1,-1), 10),
        ("BOTTOMPADDING", (0,0), (-1,-1), 10),
        ("LEFTPADDING",   (0,0), (-1,-1), 14),
        ("RIGHTPADDING",  (0,0), (-1,-1), 14),
    ]))
    return t

def section_box(title, bg=LIGHT_BLUE, tc=DARK_BLUE):
    p = ParagraphStyle("sb", fontSize=11.5, textColor=tc,
                       fontName="Helvetica-Bold", leading=14)
    data = [[Paragraph(title, p)]]
    t = Table(data, colWidths=[W - 3.6*cm])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), bg),
        ("LEFTPADDING",   (0,0), (-1,-1), 10),
        ("RIGHTPADDING",  (0,0), (-1,-1), 10),
        ("TOPPADDING",    (0,0), (-1,-1), 6),
        ("BOTTOMPADDING", (0,0), (-1,-1), 6),
        ("LINEBELOW", (0,0), (-1,-1), 1.5, tc),
    ]))
    return t

def divider(color=ACCENT):
    return HRFlowable(width="100%", thickness=1, color=color, spaceAfter=4, spaceBefore=4)

def tbl(headers, rows, col_widths=None, hdr_bg=MID_BLUE):
    data = [[Paragraph(str(h), S("Normal", fontSize=9.5, textColor=WHITE,
                                 fontName="Helvetica-Bold")) for h in headers]]
    for row in rows:
        data.append([Paragraph(str(c), S("Normal", fontSize=9, textColor=BLACK)) for c in row])
    cw = col_widths or [(W - 3.6*cm) / len(headers)] * len(headers)
    t = Table(data, colWidths=cw, repeatRows=1)
    style = [
        ("BACKGROUND", (0,0), (-1,0), hdr_bg),
        ("GRID",       (0,0), (-1,-1), 0.5, colors.grey),
        ("TOPPADDING",    (0,0), (-1,-1), 5),
        ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING",   (0,0), (-1,-1), 6),
        ("RIGHTPADDING",  (0,0), (-1,-1), 6),
        ("ROWBACKGROUNDS",(0,1), (-1,-1), [WHITE, GREY_BG]),
        ("VALIGN",     (0,0), (-1,-1), "TOP"),
    ]
    t.setStyle(TableStyle(style))
    return t


# ══════════════════════════════════════════════════════════════════════════════
# FLOWCHART helpers  (pure ReportLab Drawing)
# ══════════════════════════════════════════════════════════════════════════════
class FlowChart(Flowable):
    """Generic ASCII-style box-and-arrow vertical flowchart."""
    def __init__(self, steps, width=460, box_h=28, gap=18,
                 fill=LIGHT_BLUE, stroke=MID_BLUE, txt_color=DARK_BLUE):
        super().__init__()
        self.steps     = steps
        self.box_w     = width
        self.box_h     = box_h
        self.gap       = gap
        self.fill      = fill
        self.stroke    = stroke
        self.txt_color = txt_color
        n              = len(steps)
        self.width     = width
        self.height    = n * box_h + (n-1) * gap + 10

    def draw(self):
        c = self.canv
        y = self.height - 10
        for i, step in enumerate(self.steps):
            top = y
            bot = y - self.box_h
            c.setFillColor(self.fill)
            c.setStrokeColor(self.stroke)
            c.setLineWidth(1.2)
            c.roundRect(0, bot, self.box_w, self.box_h, 5, fill=1, stroke=1)
            c.setFillColor(self.txt_color)
            c.setFont("Helvetica-Bold", 9)
            c.drawCentredString(self.box_w/2, bot + self.box_h/2 - 4, step)
            # arrow
            if i < len(self.steps) - 1:
                ax = self.box_w / 2
                c.setStrokeColor(self.stroke)
                c.setFillColor(self.stroke)
                c.setLineWidth(1.5)
                c.line(ax, bot, ax, bot - self.gap + 6)
                # arrowhead
                c.setLineWidth(0)
                c.triangle(ax-4, bot-self.gap+8, ax+4, bot-self.gap+8,
                           ax, bot-self.gap+2, fill=1)
            y = bot - self.gap


def simple_flowchart(steps, width=460, fill=LIGHT_BLUE, stroke=MID_BLUE):
    return FlowChart(steps, width=width, fill=fill, stroke=stroke)


# ══════════════════════════════════════════════════════════════════════════════
# BUILD STORY
# ══════════════════════════════════════════════════════════════════════════════
story = []

# ─── COVER PAGE ───────────────────────────────────────────────────────────────
cover_data = [[Paragraph("PHYSIOLOGY\nPRELIMS EXAM", cover_title)]]
cover_tbl = Table(cover_data, colWidths=[W - 3.6*cm])
cover_tbl.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,-1), DARK_BLUE),
    ("TOPPADDING",    (0,0), (-1,-1), 30),
    ("BOTTOMPADDING", (0,0), (-1,-1), 30),
]))
story.append(Spacer(1, 3*cm))
story.append(cover_tbl)
story.append(Spacer(1, 0.5*cm))

sub_data = [[Paragraph("1st Year MBBS — Complete Answer Key", cover_sub)]]
sub_tbl = Table(sub_data, colWidths=[W - 3.6*cm])
sub_tbl.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,-1), MID_BLUE),
    ("TOPPADDING",    (0,0), (-1,-1), 12),
    ("BOTTOMPADDING", (0,0), (-1,-1), 12),
]))
story.append(sub_tbl)
story.append(Spacer(1, 0.5*cm))

note_data = [[Paragraph(
    "Sections Covered: General · Blood · Muscle · Digestive\n"
    "Reference: Guyton & Hall (14e) · Ganong (26e) · Costanzo (7e)",
    cover_note)]]
note_tbl = Table(note_data, colWidths=[W - 3.6*cm])
note_tbl.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,-1), ACCENT),
    ("TOPPADDING",    (0,0), (-1,-1), 10),
    ("BOTTOMPADDING", (0,0), (-1,-1), 10),
]))
story.append(note_tbl)
story.append(PageBreak())


# ══════════════════════════════════════════════════════════════════════════════
# SECTION 1 — GENERAL
# ══════════════════════════════════════════════════════════════════════════════
story.append(chapter_header("SECTION 1: GENERAL PHYSIOLOGY", DARK_BLUE))
story.append(Spacer(1, 0.3*cm))

# ─── Q1: Mitochondria ─────────────────────────────────────────────────────────
story.append(section_box("Q1. Mitochondria (Cell Organelle) [R]", LIGHT_BLUE, DARK_BLUE))
story.append(Spacer(1,0.15*cm))
story.append(Paragraph("A. Introduction", sub_head))
story.append(bullet([
    "Mitochondria = powerhouses of the cell",
    "Site of ATP synthesis via oxidative phosphorylation",
    "Contain their own DNA (mtDNA, 37 genes) — maternally inherited",
    "Self-replicating organelles",
]))
story.append(Paragraph("B. Structure", sub_head))
story.append(tbl(
    ["Component", "Description"],
    [
        ["Outer membrane", "Contains porins; regulates ion/metabolite flow"],
        ["Inner membrane", "Folded into cristae; contains oxidative enzymes & ETC"],
        ["Cristae", "Infoldings that increase surface area for reactions"],
        ["Matrix", "Contains dissolved enzymes, mtDNA, ribosomes"],
        ["Intermembrane space", "Between outer and inner membrane; proton reservoir"],
    ],
    col_widths=[6*cm, 10.5*cm]
))
story.append(Paragraph("C. Functions", sub_head))
story.append(numbered([
    "ATP synthesis (oxidative phosphorylation)",
    "Fatty acid beta-oxidation",
    "Kreb's cycle (TCA cycle) — in matrix",
    "Calcium homeostasis",
    "Apoptosis initiation (release of cytochrome c)",
    "Heat production (thermogenesis)",
    "Steroid hormone synthesis",
]))
story.append(ref("Guyton & Hall, 14e, Ch.2 — The Cell and Its Functions"))
story.append(divider())

# ─── Q2: Apoptosis ────────────────────────────────────────────────────────────
story.append(section_box("Q2. Apoptosis [S5]", LIGHT_GREEN, GREEN))
story.append(Spacer(1,0.15*cm))
story.append(Paragraph("A. Definition", sub_head))
story.append(body.clone("b2", parent=body))
story.append(Paragraph(
    "Apoptosis is programmed cell death — a genetically controlled, energy-dependent process "
    "of self-destruction that eliminates unwanted, damaged, or aged cells without inflammation.", body))
story.append(Paragraph("B. Pathways", sub_head))
story.append(tbl(
    ["Pathway", "Trigger", "Key Mediators"],
    [
        ["Intrinsic (Mitochondrial)", "DNA damage, oxidative stress, ischaemia",
         "Cytochrome c → Apoptosome → Caspase-9 → Caspase-3"],
        ["Extrinsic (Death Receptor)", "FasL, TNF-α binding to death receptors",
         "FADD → Caspase-8 → Caspase-3"],
    ],
    col_widths=[4.5*cm, 5.5*cm, 6.5*cm]
))
story.append(Paragraph("C. Morphological Features", sub_head))
story.append(bullet([
    "Cell shrinkage (pyknosis)",
    "Chromatin condensation",
    "Membrane blebbing",
    "Formation of apoptotic bodies",
    "Phagocytosis by macrophages — NO inflammation",
]))
story.append(Paragraph("D. Physiological Roles", sub_head))
story.append(bullet([
    "Embryogenesis (digit separation, neural tube formation)",
    "Hormone-induced involution (endometrium)",
    "Immune system regulation (deletion of auto-reactive T-cells)",
    "Elimination of DNA-damaged cells — prevents cancer",
]))
story.append(key_point("KEY: Apoptosis ≠ Necrosis — No inflammation, No cell lysis in apoptosis"))
story.append(tbl(
    ["Feature", "Apoptosis", "Necrosis"],
    [
        ["Trigger", "Physiological/mild injury", "Severe, irreversible injury"],
        ["Cell size", "Shrinks", "Swells"],
        ["DNA", "Ladder pattern (internucleosomal)", "Random fragmentation"],
        ["Membrane", "Intact → apoptotic bodies", "Ruptures"],
        ["Inflammation", "None", "Present"],
        ["Energy", "ATP-dependent", "ATP-independent"],
    ],
    col_widths=[4*cm, 5.5*cm, 7*cm]
))
story.append(ref("Guyton & Hall, 14e, Ch.3; Ganong 26e, Ch.1"))
story.append(divider())

# ─── Q3: Gap Junction ─────────────────────────────────────────────────────────
story.append(section_box("Q3. Gap Junctions [S2]", LIGHT_PURP, PURPLE))
story.append(Spacer(1,0.15*cm))
story.append(bullet([
    "Gap junctions are intercellular channels formed by connexin proteins",
    "Two hemi-channels (connexons) from adjacent cells align to form a complete channel",
    "Pore diameter: ~1.5 nm — allows ions and small molecules (<1000 Da) to pass",
    "Allows direct electrical and chemical communication between cells",
]))
story.append(Paragraph("Functions:", sub_head))
story.append(bullet([
    "Electrical coupling — cardiac muscle & smooth muscle (functional syncytium)",
    "Metabolic coupling — sharing of nutrients and signalling molecules",
    "Coordinated contraction in cardiac and uterine muscle",
    "Embryonic development — pattern formation",
]))
story.append(ref("Guyton & Hall, 14e, Ch.2; Ganong 26e, Ch.2"))
story.append(divider())

# ─── Q4: Active & Passive Transport + Osmosis ─────────────────────────────────
story.append(section_box("Q4. Active & Passive Transport and Osmosis [S10]", LIGHT_TEAL, TEAL))
story.append(Spacer(1,0.15*cm))
story.append(tbl(
    ["Feature", "Passive Transport", "Active Transport"],
    [
        ["Energy required", "No", "Yes (ATP)"],
        ["Direction", "Down concentration gradient", "Against concentration gradient"],
        ["Carrier", "Not always needed", "Always needs carrier"],
        ["Types", "Diffusion, Facilitated diffusion, Osmosis", "Primary, Secondary (co-transport)"],
        ["Examples", "O₂, CO₂, glucose (via GLUT)", "Na⁺-K⁺ ATPase, Ca²⁺ pump"],
    ],
    col_widths=[4.5*cm, 5.5*cm, 6.5*cm]
))
story.append(Paragraph("A. Diffusion", sub_head))
story.append(bullet([
    "Movement of molecules from high → low concentration",
    "Rate governed by Fick's Law: J = -DA(dC/dx)",
    "Simple diffusion: lipid-soluble substances (O₂, CO₂, steroids)",
    "Facilitated diffusion: uses protein channels or carriers (glucose, amino acids)",
]))
story.append(Paragraph("B. Osmosis", sub_head))
story.append(bullet([
    "Movement of water across a semipermeable membrane from low → high solute concentration",
    "Osmotic pressure (π) = CRT (van't Hoff equation)",
    "Plasma osmolality: 285–295 mOsm/kg",
    "Isosmotic: same osmolarity | Hyperosmotic: higher osmolarity | Hyposmotic: lower",
]))
story.append(Paragraph("C. Primary Active Transport", sub_head))
story.append(bullet([
    "Na⁺-K⁺ ATPase: pumps 3 Na⁺ OUT, 2 K⁺ IN per ATP — maintains RMP",
    "H⁺-K⁺ ATPase: in parietal cells of stomach",
    "Ca²⁺ ATPase: in SR and plasma membrane",
]))
story.append(Paragraph("D. Secondary Active Transport", sub_head))
story.append(bullet([
    "Co-transport (symport): Na⁺-glucose cotransporter (SGLT) in intestine and kidney",
    "Counter-transport (antiport): Na⁺-H⁺ exchanger",
]))
story.append(ref("Costanzo Physiology, 7e, Ch.1; Guyton & Hall, 14e, Ch.4"))
story.append(divider())

# ─── Q5: Pinocytosis & Phagocytosis ──────────────────────────────────────────
story.append(section_box("Q5. Pinocytosis and Phagocytosis [S2]", LIGHT_ORG, ORANGE))
story.append(Spacer(1,0.15*cm))
story.append(tbl(
    ["Feature", "Pinocytosis", "Phagocytosis"],
    [
        ["Meaning", '"Cell drinking"', '"Cell eating"'],
        ["Material ingested", "Fluid + dissolved solutes", "Large solid particles (>0.5 μm)"],
        ["Cells involved", "Most cells", "Macrophages, neutrophils, monocytes"],
        ["Vesicle", "Pinosome (small)", "Phagosome (large)"],
        ["Examples", "Absorption of nutrients", "Bacteria, dead cells, debris"],
    ],
    col_widths=[4*cm, 5.5*cm, 7*cm]
))
story.append(ref("Guyton & Hall, 14e, Ch.2"))
story.append(divider())

# ─── Q6: MOA of Homeostatic System ───────────────────────────────────────────
story.append(section_box("Q6. Mechanism of Action of Homeostatic System [S10]", LIGHT_BLUE, DARK_BLUE))
story.append(Spacer(1,0.15*cm))
story.append(Paragraph(
    "Homeostasis is the maintenance of a stable internal environment despite external changes. "
    "It operates through feedback control systems.", body))
story.append(Paragraph("Components of a Control System:", sub_head))
story.append(simple_flowchart([
    "STIMULUS → Disturbs set point",
    "SENSOR / RECEPTOR detects change",
    "AFFERENT PATHWAY sends signal",
    "CONTROL CENTRE (Integrator) compares to set point",
    "EFFERENT PATHWAY sends corrective signal",
    "EFFECTOR makes correction",
    "RESPONSE → Restores set point (Feedback)",
], fill=LIGHT_BLUE, stroke=MID_BLUE))
story.append(Spacer(1,0.2*cm))
story.append(tbl(
    ["Feature", "Negative Feedback", "Positive Feedback"],
    [
        ["Direction", "Reverses the initial change", "Amplifies the initial change"],
        ["Common?", "Most common", "Uncommon"],
        ["Purpose", "Restores homeostasis", "Drives process to completion"],
        ["Examples", "Body temperature, blood glucose, blood pressure",
         "Oxytocin in labour, blood clotting, action potential depolarization"],
    ],
    col_widths=[4*cm, 5.5*cm, 7*cm]
))
story.append(key_point("Feed-forward control: Anticipatory responses before disruption occurs (e.g., insulin release before meal is complete)"))
story.append(ref("Guyton & Hall, 14e, Ch.1; Ganong 26e, Ch.1"))
story.append(PageBreak())


# ══════════════════════════════════════════════════════════════════════════════
# SECTION 2 — BLOOD
# ══════════════════════════════════════════════════════════════════════════════
story.append(chapter_header("SECTION 2: BLOOD", MID_BLUE))
story.append(Spacer(1, 0.3*cm))

# ─── Q7: Functions of Blood & Plasma Proteins ────────────────────────────────
story.append(section_box("Q7. Functions of Blood and Plasma Proteins [S5]", LIGHT_BLUE, DARK_BLUE))
story.append(Paragraph("A. Functions of Blood", sub_head))
story.append(numbered([
    "Transport: O₂, CO₂, nutrients, hormones, waste",
    "Regulation: temperature, pH, fluid balance",
    "Protection: WBCs, antibodies, clotting factors",
    "Homeostasis: acid-base balance, osmotic balance",
]))
story.append(Paragraph("B. Plasma Proteins", sub_head))
story.append(tbl(
    ["Protein", "% of Total", "Functions"],
    [
        ["Albumin", "54–60%", "Oncotic pressure, carrier protein, drug binding, buffer"],
        ["Globulin (α, β, γ)", "35–38%", "α: transport (ceruloplasmin, haptoglobin); β: iron transport (transferrin); γ: immunoglobulins (antibodies)"],
        ["Fibrinogen", "4–7%", "Coagulation — converted to fibrin by thrombin"],
        ["Prothrombin", "<1%", "Clotting (Factor II precursor)"],
    ],
    col_widths=[3.5*cm, 2.5*cm, 10.5*cm]
))
story.append(key_point("Normal plasma protein = 6–8 g/dL; Albumin = 3.5–5 g/dL"))
story.append(ref("Guyton & Hall, 14e, Ch.32"))
story.append(divider())

# ─── Q8: Biconcave Shape ─────────────────────────────────────────────────────
story.append(section_box("Q8. Advantages of Biconcave Shape of RBC [SQ]", LIGHT_GREEN, GREEN))
story.append(numbered([
    "Increased Surface-to-Volume ratio → maximises gas exchange",
    "Flexibility — can squeeze through capillaries (3 μm diameter) despite 8 μm size",
    "Shorter diffusion distance to haemoglobin",
    "No nucleus or mitochondria → more room for Hb → carries 280 million Hb molecules",
    "Uniform distribution of Hb across the cell",
    "MCV (mean cell volume) remains constant — reflects deformability",
]))
story.append(ref("Guyton & Hall, 14e, Ch.32"))
story.append(divider())

# ─── Q9: Fate of Hb ─────────────────────────────────────────────────────────
story.append(section_box("Q9. Fate of Haemoglobin [S5]", LIGHT_ORG, ORANGE))
story.append(simple_flowchart([
    "RBC lifespan = 120 days → Destroyed in spleen/liver by macrophages (RES)",
    "Hb released → split into Haem + Globin",
    "Globin → hydrolysed to amino acids → reutilised",
    "Haem → Fe³⁺ released + Protoporphyrin ring",
    "Fe³⁺ → stored as Ferritin/Haemosiderin OR transported by Transferrin to bone marrow",
    "Protoporphyrin → Biliverdin (green) → Bilirubin (yellow, unconjugated)",
    "Bilirubin → bound to albumin → liver → conjugated (glucuronide) → bile",
    "In gut → Urobilinogen → Stercobilin (faeces) + Urobilin (urine)",
], fill=LIGHT_ORG, stroke=ORANGE))
story.append(key_point("Normal serum bilirubin = 0.2–1.2 mg/dL; Jaundice appears >2 mg/dL"))
story.append(ref("Guyton & Hall, 14e, Ch.32"))
story.append(divider())

# ─── Q10: Erythropoiesis ─────────────────────────────────────────────────────
story.append(section_box("Q10. Stages and Factors of Erythropoiesis [S10]", LIGHT_TEAL, TEAL))
story.append(Paragraph("A. Stages of Erythropoiesis", sub_head))
story.append(simple_flowchart([
    "Pluripotent Stem Cell (Haemocytoblast)",
    "Committed Erythroid Progenitor (BFU-E → CFU-E)",
    "Proerythroblast (Pronormoblast) — basophilic; starts Hb synthesis",
    "Early Normoblast (Basophilic erythroblast) — active Hb synthesis",
    "Intermediate Normoblast (Polychromatic erythroblast)",
    "Late Normoblast (Orthochromatic) — nucleus ejected",
    "Reticulocyte — enters bloodstream; loses ribosomes in 1–2 days",
    "Mature Erythrocyte (RBC) — 7.2 μm biconcave disc",
], fill=LIGHT_TEAL, stroke=TEAL))
story.append(Paragraph("B. Factors Required for Erythropoiesis", sub_head))
story.append(tbl(
    ["Factor", "Role"],
    [
        ["Erythropoietin (EPO)", "Primary stimulus; produced by peritubular cells of kidney in response to hypoxia"],
        ["Iron (Fe²⁺)", "Essential for haem synthesis (Hb structure)"],
        ["Vitamin B12 (Cobalamin)", "DNA synthesis; requires intrinsic factor for absorption"],
        ["Folic Acid", "DNA synthesis (thymidine synthesis)"],
        ["Vitamin C", "Fe³⁺ → Fe²⁺ (enhances absorption)"],
        ["Vitamin B6 (Pyridoxine)", "Porphyrin/haem synthesis"],
        ["Copper", "Iron mobilisation (ceruloplasmin)"],
        ["Cobalt", "Stimulates EPO release"],
        ["Protein (Amino acids)", "Globin chain synthesis"],
    ],
    col_widths=[5*cm, 11.5*cm]
))
story.append(ref("Guyton & Hall, 14e, Ch.33; Ganong 26e, Ch.26"))
story.append(divider())

# ─── Q11: Anaemia Classification ─────────────────────────────────────────────
story.append(section_box("Q11. Classification of Anaemia [S3]", LIGHT_RED, RED))
story.append(tbl(
    ["Classification", "Types", "Examples"],
    [
        ["By MCV (Morphological)",
         "Microcytic (MCV<80)\nNormocytic (MCV 80–100)\nMacrocytic (MCV>100)",
         "IDA, Thalassaemia\nHaemolytic, aplastic, acute blood loss\nVit B12/Folate deficiency"],
        ["By Reticulocyte Count",
         "Hyperproliferative (retics ↑)\nHypoproliferative (retics ↓)",
         "Haemolysis, blood loss\nBone marrow failure, nutritional"],
        ["By Aetiology",
         "Decreased production\nIncreased destruction\nBlood loss",
         "Aplastic, nutritional\nHaemolytic\nAcute/chronic"],
    ],
    col_widths=[4*cm, 5.5*cm, 7*cm]
))
story.append(ref("Guyton & Hall, 14e, Ch.33"))
story.append(divider())

# ─── Q12: Iron-Def / Megaloblastic / Haemorrhagic Anaemia ────────────────────
story.append(section_box("Q12. Iron Deficiency, Megaloblastic, and Haemorrhagic Anaemia [S10]", LIGHT_RED, RED))
story.append(tbl(
    ["Feature", "Iron Deficiency Anaemia", "Megaloblastic Anaemia", "Haemorrhagic Anaemia"],
    [
        ["Cause", "Low iron intake, chronic blood loss, malabsorption",
         "Vit B12 deficiency (pernicious) or Folate deficiency",
         "Acute/chronic blood loss"],
        ["MCV", "Low (microcytic)", "High (macrocytic)", "Normal initially"],
        ["Hb", "Low", "Low", "Low"],
        ["RBC morphology", "Hypochromic, microcytic, pencil cells",
         "Macro-ovalocytes, hypersegmented neutrophils",
         "Normocytic normochromic"],
        ["Serum iron", "↓", "Normal", "↓ (chronic)"],
        ["Ferritin", "↓", "Normal", "↓ (chronic)"],
        ["TIBC", "↑", "Normal", "↑ (chronic)"],
        ["Special findings", "Koilonychia, angular stomatitis, glossitis",
         "Subacute combined degeneration of spinal cord (B12)",
         "↑ reticulocytes (compensation)"],
        ["Treatment", "Oral ferrous sulphate", "Vit B12 IM / Folic acid",
         "Stop bleeding, iron, transfusion if severe"],
    ],
    col_widths=[3.5*cm, 4.5*cm, 5*cm, 4.5*cm]
))
story.append(ref("Guyton & Hall, 14e, Ch.33"))
story.append(divider())

# ─── Q13: Cell-Mediated & Humoral Immunity ────────────────────────────────────
story.append(section_box("Q13. Cell-Mediated and Humoral Immunity [S10]", LIGHT_BLUE, DARK_BLUE))
story.append(tbl(
    ["Feature", "Humoral Immunity", "Cell-Mediated Immunity"],
    [
        ["Cells involved", "B lymphocytes → Plasma cells", "T lymphocytes (CD4⁺ helper, CD8⁺ cytotoxic)"],
        ["Mediator", "Antibodies (IgG, IgM, IgA, IgE, IgD)", "Lymphokines, cytokines (IL-2, IFN-γ)"],
        ["Target", "Extracellular pathogens, toxins", "Intracellular pathogens, virus-infected cells, tumour cells, transplants"],
        ["Memory", "Long-lived plasma cells + memory B cells", "Memory T cells"],
        ["Passive transfer", "By serum (IgG)", "By T lymphocytes"],
    ],
    col_widths=[4*cm, 5.5*cm, 7*cm]
))
story.append(Paragraph("Classes of Immunoglobulins:", sub_head))
story.append(tbl(
    ["Ig Class", "Location / Role"],
    [
        ["IgG", "Most abundant; crosses placenta; secondary response"],
        ["IgM", "Largest; first in primary response; pentamer"],
        ["IgA", "Secretory (saliva, tears, breast milk); dimer"],
        ["IgE", "Allergy / anaphylaxis; parasites"],
        ["IgD", "B-cell surface receptor; minor role"],
    ],
    col_widths=[3*cm, 13.5*cm]
))
story.append(ref("Guyton & Hall, 14e, Ch.35; Ganong 26e, Ch.3"))
story.append(divider())

# ─── Q14: Platelets ──────────────────────────────────────────────────────────
story.append(section_box("Q14. Functions of Platelets [S3]", LIGHT_GREEN, GREEN))
story.append(bullet([
    "Normal count: 1.5–4 × 10⁵/μL; Lifespan: 8–10 days",
    "Formed from megakaryocytes in bone marrow",
]))
story.append(tbl(
    ["Function", "Details"],
    [
        ["Vascular repair", "Adhere to damaged endothelium via vWF → temporary platelet plug"],
        ["Vasoconstriction", "Release thromboxane A₂ (TXA₂) → powerful vasoconstrictor"],
        ["Coagulation support", "Provide phospholipid surface (PF3) for coagulation cascade"],
        ["Clot retraction", "Contain actin & myosin → thrombostenin → clot retraction"],
        ["Wound healing", "Release PDGF → stimulates fibroblast proliferation"],
        ["Fibrinolysis", "Release plasminogen activator"],
    ],
    col_widths=[4.5*cm, 12*cm]
))
story.append(ref("Guyton & Hall, 14e, Ch.37"))
story.append(divider())

# ─── Q15: Haemostasis Chart ──────────────────────────────────────────────────
story.append(section_box("Q15. Haemostasis — Chart [S3]", LIGHT_TEAL, TEAL))
story.append(simple_flowchart([
    "VESSEL INJURY",
    "1. VASCULAR SPASM — immediate reflex vasoconstriction",
    "2. PRIMARY HAEMOSTASIS — Platelet adhesion (vWF), activation, aggregation → Platelet plug",
    "3. SECONDARY HAEMOSTASIS — Coagulation cascade → Fibrin clot",
    "4. FIBRINOLYSIS — Plasmin dissolves clot; vessel repairs",
], fill=LIGHT_TEAL, stroke=TEAL))
story.append(ref("Guyton & Hall, 14e, Ch.37"))
story.append(divider())

# ─── Q16: Blood Coagulation (Stages) ─────────────────────────────────────────
story.append(section_box("Q16. Stages of Blood Coagulation [S5]", LIGHT_BLUE, DARK_BLUE))
story.append(tbl(
    ["Pathway", "Factors Involved", "Activated by"],
    [
        ["Extrinsic Pathway", "Tissue Factor (III) + Factor VIIa",
         "Vessel wall damage → Tissue Factor released"],
        ["Intrinsic Pathway",
         "XII → XI → IX → VIII (tenase complex)",
         "Contact of blood with collagen / foreign surface"],
        ["Common Pathway",
         "X → Xa + Va (prothrombinase) → Prothrombin (II) → Thrombin (IIa) → Fibrinogen → Fibrin → Factor XIIIa stabilises fibrin",
         "Both pathways converge at Factor X"],
    ],
    col_widths=[4*cm, 6*cm, 6.5*cm]
))
story.append(key_point("Mnemonic — Intrinsic: 12, 11, 9, 8 (1-2-9-8) | Extrinsic: 7 | Common: 10, 5, 2, 1"))
story.append(tbl(
    ["Lab Test", "Tests"],
    [
        ["PT (Prothrombin Time)", "Extrinsic + Common pathway (Normal: 11–13 sec)"],
        ["aPTT", "Intrinsic + Common pathway (Normal: 25–35 sec)"],
        ["Bleeding Time", "Primary haemostasis / platelet function (Normal: 2–7 min)"],
        ["Clotting Time", "Overall coagulation (Normal: 5–10 min)"],
    ],
    col_widths=[5.5*cm, 11*cm]
))
story.append(ref("Guyton & Hall, 14e, Ch.37; Ganong 26e, Ch.31"))
story.append(divider())

# ─── Q17: Anticoagulation + Fibrinolysis ─────────────────────────────────────
story.append(section_box("Q17. Anticoagulation Mechanism, Fibrinolysis, and Anticoagulants [S5]", LIGHT_PURP, PURPLE))
story.append(Paragraph("A. Natural Anticoagulants", sub_head))
story.append(tbl(
    ["Anticoagulant", "Mechanism"],
    [
        ["Antithrombin III (ATIII)", "Inactivates thrombin, Xa, IXa, XIa; enhanced 1000× by heparin"],
        ["Protein C + Protein S", "Vitamin K-dependent; inactivates Factors Va and VIIIa"],
        ["Tissue Factor Pathway Inhibitor (TFPI)", "Inhibits Tissue Factor-VIIa complex"],
        ["Prostacyclin (PGI₂)", "Released by intact endothelium; inhibits platelet aggregation"],
        ["Thrombomodulin", "Endothelial receptor; thrombin-thrombomodulin complex activates Protein C"],
    ],
    col_widths=[5*cm, 11.5*cm]
))
story.append(Paragraph("B. Fibrinolysis", sub_head))
story.append(simple_flowchart([
    "Thrombin + vessel injury → Endothelium releases t-PA (tissue Plasminogen Activator)",
    "t-PA converts Plasminogen → Plasmin",
    "Plasmin degrades Fibrin clot → Fibrin Degradation Products (FDPs, D-dimer)",
    "Clot dissolved; vessel recanalised",
], fill=LIGHT_PURP, stroke=PURPLE))
story.append(Paragraph("C. Clinical Anticoagulants", sub_head))
story.append(tbl(
    ["Drug", "Mechanism"],
    [
        ["Heparin", "Activates ATIII; immediate effect; IV/SC; monitored by aPTT"],
        ["Warfarin", "Inhibits Vitamin K-dependent factors (II, VII, IX, X); monitored by PT/INR"],
        ["Aspirin", "Irreversibly inhibits COX → ↓ TXA₂ → anti-platelet"],
        ["tPA, Streptokinase", "Fibrinolytic agents — convert plasminogen to plasmin"],
    ],
    col_widths=[4*cm, 12.5*cm]
))
story.append(ref("Guyton & Hall, 14e, Ch.37"))
story.append(divider())

# ─── Q18: Bleeding Disorders ─────────────────────────────────────────────────
story.append(section_box("Q18. Bleeding Disorders [S3]", LIGHT_RED, RED))
story.append(tbl(
    ["Disorder", "Defect", "Lab Findings", "Features"],
    [
        ["Haemophilia A", "Factor VIII deficiency (X-linked recessive)",
         "↑ aPTT; PT normal", "Haemarthrosis, deep muscle bleeds; males affected"],
        ["Haemophilia B", "Factor IX deficiency (Christmas disease; X-linked)",
         "↑ aPTT; PT normal", "Same as Haem A; treat with Factor IX concentrate"],
        ["Von Willebrand disease", "vWF deficiency/dysfunction (AD)",
         "↑ BT; aPTT may ↑", "Mucosal bleeding, epistaxis, menorrhagia"],
        ["ITP", "Autoimmune platelet destruction (anti-GPIIb/IIIa)",
         "↓ Platelet count; BT ↑", "Petechiae, purpura; treat with steroids"],
        ["DIC", "Widespread activation of coagulation → clotting + bleeding",
         "↑ PT, ↑ aPTT, ↓ platelets, ↑ D-dimer", "Triggered by sepsis, obstetric emergencies"],
    ],
    col_widths=[3.5*cm, 4.5*cm, 3.5*cm, 5*cm]
))
story.append(ref("Guyton & Hall, 14e, Ch.37"))
story.append(divider())

# ─── Q19: ABO / Rh Incompatibility ──────────────────────────────────────────
story.append(section_box("Q19. Blood Grouping, Cross-Matching and Transfusion Reaction [S5]", LIGHT_BLUE, DARK_BLUE))
story.append(Paragraph("A. ABO Blood Groups", sub_head))
story.append(tbl(
    ["Blood Group", "Antigens on RBC", "Antibodies in Plasma", "Can Donate to", "Can Receive from"],
    [
        ["A", "A", "Anti-B", "A, AB", "A, O"],
        ["B", "B", "Anti-A", "B, AB", "B, O"],
        ["AB (Universal Recipient)", "A and B", "None", "AB only", "A, B, AB, O"],
        ["O (Universal Donor)", "None", "Anti-A and Anti-B", "A, B, AB, O", "O only"],
    ],
    col_widths=[3.5*cm, 3*cm, 3.5*cm, 3*cm, 3.5*cm]
))
story.append(Paragraph("B. Rh System", sub_head))
story.append(bullet([
    "Rh antigen (D antigen) — present in Rh+, absent in Rh-",
    "Rh- individual has NO anti-D naturally; sensitisation required",
    "First incompatible transfusion → sensitisation; Second → haemolytic transfusion reaction",
]))
story.append(Paragraph("C. Transfusion Reactions (ABO Incompatibility)", sub_head))
story.append(bullet([
    "Agglutination: donor RBCs clump → plugs small vessels",
    "Haemolysis: complement activation → intravascular haemolysis → haemoglobinaemia, haemoglobinuria",
    "Symptoms: fever, chills, back pain, haematuria, shock, renal failure",
    "Cross-matching: Donor RBCs + Recipient serum — must be NEGATIVE for safe transfusion",
]))
story.append(ref("Guyton & Hall, 14e, Ch.36"))
story.append(divider())

# ─── Q20: Erythroblastosis Foetalis ──────────────────────────────────────────
story.append(section_box("Q20. Erythroblastosis Foetalis [S5]", LIGHT_ORG, ORANGE))
story.append(simple_flowchart([
    "Rh⁻ mother × Rh⁺ father → Rh⁺ fetus",
    "During delivery: fetal Rh⁺ RBCs enter maternal circulation → sensitisation",
    "Mother produces IgG anti-D antibodies",
    "2nd Rh⁺ pregnancy: IgG anti-D crosses placenta (FcRn receptor) → attacks fetal RBCs",
    "Haemolysis → Anaemia → Compensatory extramedullary erythropoiesis (liver, spleen)",
    "Release of nucleated RBCs (Erythroblasts) into fetal blood",
    "Severe: Hydrops fetalis (oedema, ascites) → stillbirth",
    "High bilirubin after birth → Kernicterus (brain damage)",
], fill=LIGHT_ORG, stroke=ORANGE))
story.append(Paragraph("Prevention:", sub_head))
story.append(bullet([
    "Anti-D immunoglobulin (RhoGAM) given to Rh⁻ mother at 28 weeks and within 72h of delivery",
    "Prevents sensitisation by neutralising Rh⁺ fetal cells before immune response",
]))
story.append(Paragraph("Treatment:", sub_head))
story.append(bullet([
    "Intrauterine blood transfusion (for severe anaemia in fetus)",
    "Phototherapy after birth for jaundice",
    "Exchange transfusion for severe hyperbilirubinaemia",
]))
story.append(ref("Guyton & Hall, 14e, Ch.36"))
story.append(divider())

# ─── Q21: Hazards of Blood Transfusion ────────────────────────────────────────
story.append(section_box("Q21. Hazards of Blood Transfusion [S3]", LIGHT_RED, RED))
story.append(tbl(
    ["Type", "Examples"],
    [
        ["Immunological", "Haemolytic reactions (ABO/Rh), Febrile non-haemolytic, Urticaria, Anaphylaxis, TRALI, Transfusion-associated GvHD"],
        ["Infectious", "HIV, HCV, HBV, CMV, syphilis, malaria, variant CJD"],
        ["Metabolic", "Hypocalcaemia (citrate toxicity), Hyperkalaemia (stored blood), Acidosis, Hypothermia"],
        ["Volume overload", "TACO (Transfusion-Associated Circulatory Overload) → pulmonary oedema"],
        ["Massive transfusion", "Dilutional coagulopathy, thrombocytopaenia"],
    ],
    col_widths=[4.5*cm, 12*cm]
))
story.append(ref("Guyton & Hall, 14e, Ch.36"))
story.append(PageBreak())


# ══════════════════════════════════════════════════════════════════════════════
# SECTION 3 — MUSCLE
# ══════════════════════════════════════════════════════════════════════════════
story.append(chapter_header("SECTION 3: MUSCLE PHYSIOLOGY", GREEN))
story.append(Spacer(1, 0.3*cm))

# ─── Q22: Sarcomere ──────────────────────────────────────────────────────────
story.append(section_box("Q22. Sarcomere [S10]", LIGHT_GREEN, GREEN))
story.append(Paragraph("A. Definition", sub_head))
story.append(Paragraph(
    "The sarcomere is the basic contractile unit of skeletal muscle, extending from one Z-disc to the next. "
    "Length at rest: ~2.0–2.2 μm.", body))
story.append(Paragraph("B. Bands and Lines", sub_head))
story.append(tbl(
    ["Structure", "Description", "Contains"],
    [
        ["Z-disc (Z-line)", "Boundary of sarcomere", "Alpha-actinin; anchors thin filaments"],
        ["I-band", "Light band; bisected by Z-disc", "Thin (actin) filaments only"],
        ["A-band", "Dark band; remains constant in length", "Thick (myosin) + overlapping thin filaments"],
        ["H-zone", "Central pale zone of A-band", "Thick (myosin) filaments only"],
        ["M-line", "Centre of H-zone", "Myomesin, titin; anchors thick filaments"],
        ["Titin", "Elastic protein from M-line to Z-disc", "Prevents over-stretching"],
    ],
    col_widths=[3.5*cm, 5*cm, 8*cm]
))
story.append(Paragraph("C. Changes During Contraction (Sliding Filament Theory)", sub_head))
story.append(bullet([
    "I-band shortens (thin filaments slide in)",
    "H-zone shortens or disappears",
    "A-band length remains CONSTANT",
    "Z-discs come closer together",
    "Sarcomere length decreases",
]))
story.append(key_point("Mnemonic: A-band is Always constant; I-band and H-zone shorten"))
story.append(ref("Guyton & Hall, 14e, Ch.6; Ganong 26e, Ch.5"))
story.append(divider())

# ─── Q23: Contractile Proteins ───────────────────────────────────────────────
story.append(section_box("Q23. Contractile Proteins [S3]", LIGHT_TEAL, TEAL))
story.append(tbl(
    ["Protein", "Type", "Location", "Function"],
    [
        ["Myosin", "Thick filament", "A-band", "Motor protein; ATPase activity; forms cross-bridges with actin"],
        ["Actin", "Thin filament", "I-band + A-band overlap", "Binds myosin; has binding sites covered by tropomyosin"],
        ["Tropomyosin", "Regulatory", "Thin filament groove", "Blocks myosin binding sites on actin at rest"],
        ["Troponin T", "Regulatory", "Thin filament", "Binds tropomyosin"],
        ["Troponin I", "Regulatory", "Thin filament", "Inhibits actin-myosin interaction"],
        ["Troponin C", "Regulatory (Ca²⁺ sensor)", "Thin filament", "Binds Ca²⁺ → conformational change → exposes binding sites"],
        ["Titin", "Structural/elastic", "M-line to Z-disc", "Elasticity; prevents over-stretch"],
        ["Nebulin", "Structural", "Along thin filament", "Template for thin filament length"],
    ],
    col_widths=[3*cm, 3*cm, 3.5*cm, 7*cm]
))
story.append(ref("Guyton & Hall, 14e, Ch.6"))
story.append(divider())

# ─── Q24: Sarco-Tubular System ────────────────────────────────────────────────
story.append(section_box("Q24. Sarco-Tubular System [S10]", LIGHT_BLUE, DARK_BLUE))
story.append(tbl(
    ["Component", "Description", "Function"],
    [
        ["T-Tubules (Transverse tubules)",
         "Deep invaginations of sarcolemma at A-I junction (2 per sarcomere in skeletal)",
         "Conduct action potential rapidly deep into muscle fibre"],
        ["Sarcoplasmic Reticulum (SR)",
         "Specialised smooth ER surrounding myofibrils; terminal cisternae at ends",
         "Stores and releases Ca²⁺; SERCA pump resequestrates Ca²⁺"],
        ["Triad",
         "One T-tubule flanked by two terminal cisternae of SR",
         "Excitation-contraction coupling site"],
    ],
    col_widths=[4*cm, 5.5*cm, 7*cm]
))
story.append(Paragraph("Mechanism of Ca²⁺ Release:", sub_head))
story.append(simple_flowchart([
    "Action Potential along sarcolemma → enters T-tubule",
    "Activates DHPR (dihydropyridine receptor) — voltage sensor in T-tubule membrane",
    "DHPR activates RyR1 (ryanodine receptor) on SR membrane",
    "Ca²⁺ floods from SR into cytoplasm",
    "Ca²⁺ binds Troponin C → exposes actin binding sites → cross-bridge cycling",
    "Relaxation: SERCA pump resequestrates Ca²⁺ into SR; troponin-tropomyosin complex re-covers actin",
], fill=LIGHT_BLUE, stroke=MID_BLUE))
story.append(ref("Guyton & Hall, 14e, Ch.7; Ganong 26e, Ch.5"))
story.append(divider())

# ─── Q25: Molecular Basis of Contraction ────────────────────────────────────
story.append(section_box("Q25. Molecular Basis of Contraction (Cross-Bridge Cycle) [S5]", LIGHT_GREEN, GREEN))
story.append(simple_flowchart([
    "STEP 1: AP → Ca²⁺ release from SR → Ca²⁺ binds Troponin C",
    "STEP 2: Conformational change → Tropomyosin moves → Actin binding sites EXPOSED",
    "STEP 3: Myosin head (ADP+Pi attached) binds actin → Cross-bridge formed",
    "STEP 4: POWER STROKE — ADP+Pi released → myosin head tilts (45°→ 90°) → actin slides toward M-line",
    "STEP 5: ATP binds myosin head → Cross-bridge DETACHES from actin",
    "STEP 6: ATP hydrolysed (ATPase) → ADP+Pi → Myosin head re-cocked (90°) → ready for next cycle",
    "RELAXATION: Ca²⁺ re-pumped to SR by SERCA; Tropomyosin covers actin binding sites again",
], fill=LIGHT_GREEN, stroke=GREEN))
story.append(key_point("Rigor Mortis: No ATP → Cross-bridges cannot detach → muscles remain rigid"))
story.append(ref("Guyton & Hall, 14e, Ch.6; Ganong 26e, Ch.5"))
story.append(divider())

# ─── Q26: NM Junction ────────────────────────────────────────────────────────
story.append(section_box("Q26. Neuromuscular Junction (NMJ) [S10]", LIGHT_TEAL, TEAL))
story.append(Paragraph("A. Structure", sub_head))
story.append(bullet([
    "Synapse between motor neuron and skeletal muscle fibre",
    "Pre-synaptic terminal: contains ACh vesicles, mitochondria, active zones",
    "Synaptic cleft: ~50 nm; contains acetylcholinesterase",
    "Post-synaptic membrane (motor end plate): junctional folds, nicotinic ACh receptors (nAChR)",
]))
story.append(Paragraph("B. Sequence of Events at NMJ", sub_head))
story.append(simple_flowchart([
    "AP reaches motor nerve terminal",
    "Depolarisation → Ca²⁺ influx via VGCC (voltage-gated Ca²⁺ channels)",
    "Ca²⁺ triggers ACh vesicle exocytosis into synaptic cleft",
    "ACh binds nicotinic receptors (α-subunits) on motor end plate",
    "Na⁺ influx → End Plate Potential (EPP) generated",
    "EPP triggers AP in sarcolemma → T-tubule → Ca²⁺ release → contraction",
    "AChE in cleft breaks down ACh → Choline reuptake + Acetate",
]))
story.append(Paragraph("C. Pharmacology:", sub_head))
story.append(tbl(
    ["Drug", "Action", "Effect"],
    [
        ["Neostigmine, Physostigmine", "AChE inhibitor", "↑ ACh at NMJ → prolonged depolarisation"],
        ["Succinylcholine", "Depolarising blocker (NM agonist)", "Persistent depolarisation → flaccid paralysis"],
        ["Curare (d-tubocurarine)", "Non-depolarising blocker (competitive)", "Blocks nAChR → flaccid paralysis"],
        ["Botulinum toxin", "Inhibits ACh vesicle fusion", "Flaccid paralysis"],
    ],
    col_widths=[4.5*cm, 4.5*cm, 7.5*cm]
))
story.append(ref("Guyton & Hall, 14e, Ch.7; Ganong 26e, Ch.6"))
story.append(divider())

# ─── Q27: Muscle Tone ────────────────────────────────────────────────────────
story.append(section_box("Q27. Muscle Tone [S5]", LIGHT_PURP, PURPLE))
story.append(bullet([
    "Muscle tone = state of slight, continuous partial contraction of muscle at rest",
    "Due to asynchronous firing of motor units",
    "Maintained by stretch reflex via muscle spindles (Ia afferents) → α-motor neurons",
    "CNS control: cerebellum and basal ganglia regulate tone",
]))
story.append(tbl(
    ["Condition", "Tone", "Cause", "Features"],
    [
        ["Hypotonia", "Decreased", "LMN lesion, cerebellum disease", "Flaccid muscles, hyporeflexia"],
        ["Hypertonia", "Increased", "UMN lesion", "Spasticity (UMNL) or Rigidity (basal ganglia)"],
        ["Spasticity", "↑ (velocity-dependent)", "UMN lesion (stroke, spinal cord)", "Clasp-knife rigidity"],
        ["Rigidity", "↑ (throughout ROM)", "Parkinson's disease", "Cogwheel / lead-pipe rigidity"],
    ],
    col_widths=[3*cm, 2.5*cm, 4.5*cm, 6.5*cm]
))
story.append(ref("Guyton & Hall, 14e, Ch.55"))
story.append(divider())

# ─── Q28: Refractory Period ──────────────────────────────────────────────────
story.append(section_box("Q28. Refractory Period [S3]", LIGHT_BLUE, DARK_BLUE))
story.append(tbl(
    ["Type", "Duration", "Mechanism", "Response to Stimulus"],
    [
        ["Absolute Refractory Period (ARP)",
         "~1–2 ms (nerve); ~250 ms (cardiac)",
         "Na⁺ channels inactivated (h-gate closed); no AP possible",
         "No response to any stimulus"],
        ["Relative Refractory Period (RRP)",
         "Several ms after ARP",
         "Na⁺ channels partially recovered; membrane hyperpolarised (K⁺ efflux)",
         "Only supra-threshold stimulus can generate AP"],
        ["Supernormal Period",
         "After RRP",
         "Membrane slightly depolarised (close to threshold)",
         "Easier to fire"],
    ],
    col_widths=[3.5*cm, 3*cm, 5*cm, 5*cm]
))
story.append(key_point("ARP prevents tetanic contraction in cardiac muscle — essential for pumping"))
story.append(ref("Guyton & Hall, 14e, Ch.5; Ganong 26e, Ch.4"))
story.append(divider())

# ─── Q29: AP Curve ────────────────────────────────────────────────────────────
story.append(section_box("Q29. Action Potential Curve [S3]", LIGHT_GREEN, GREEN))
story.append(tbl(
    ["Phase", "Change", "Ion responsible"],
    [
        ["Resting Membrane Potential", "–70 mV (nerve), –90 mV (muscle)", "K⁺ dominates; Na⁺-K⁺ ATPase maintains gradient"],
        ["Threshold", "–55 mV", "Sufficient Na⁺ channels open"],
        ["Depolarisation (Phase 0)", "–70 → +30 mV (overshoot)", "Na⁺ influx (VG Na⁺ channels open)"],
        ["Repolarisation", "+30 → –70 mV", "K⁺ efflux (VG K⁺ channels open); Na⁺ channels inactivate"],
        ["After-hyperpolarisation", "<–70 mV briefly", "K⁺ channels slow to close"],
        ["Restoration", "Return to RMP", "Na⁺-K⁺ ATPase restores gradients"],
    ],
    col_widths=[4*cm, 4*cm, 8.5*cm]
))
story.append(key_point("All-or-None Law: AP is either fully generated or not; amplitude does not vary with stimulus intensity"))
story.append(ref("Guyton & Hall, 14e, Ch.5; Costanzo 7e, Ch.1"))
story.append(divider())

# ─── Q30: Heat, Rigor & Mortis ────────────────────────────────────────────────
story.append(section_box("Q30. Heat, Rigor Mortis and Contracture [S3]", LIGHT_ORG, ORANGE))
story.append(Paragraph("Heat in Muscle Contraction:", sub_head))
story.append(bullet([
    "Initial Heat: produced during contraction (activation heat + heat of shortening)",
    "Recovery Heat: produced after contraction during aerobic resynthesis of ATP",
    "Total Energy = Initial heat + Recovery heat + Mechanical work",
]))
story.append(Paragraph("Rigor Mortis:", sub_head))
story.append(bullet([
    "Definition: post-mortem stiffening of muscles",
    "Cause: ATP depletion → cross-bridges cannot detach → permanent rigor complex",
    "Onset: 2–6 hours after death; complete by 12 hours",
    "Passes off: 24–48 hours when autolytic enzymes destroy cross-bridges",
    "Heat Rigor: Hb and proteins denature at high temperatures → irreversible contracture",
]))
story.append(ref("Ganong 26e, Ch.5"))
story.append(divider())

# ─── Q31: Myasthenia Gravis ──────────────────────────────────────────────────
story.append(section_box("Q31. Myasthenia Gravis [S10]", LIGHT_RED, RED))
story.append(Paragraph("A. Definition:", sub_head))
story.append(Paragraph(
    "Autoimmune disorder where antibodies against post-synaptic nicotinic ACh receptors (nAChR) "
    "at NMJ cause progressive fatigable muscle weakness.", body))
story.append(Paragraph("B. Pathophysiology:", sub_head))
story.append(simple_flowchart([
    "Anti-nAChR IgG antibodies produced (Thymus — role in antigen presentation)",
    "Antibodies bind nAChR on motor end plate",
    "Complement activation → destruction of junctional folds",
    "Reduced functional nAChRs → smaller EPP",
    "EPP may fall below threshold → no AP → No contraction",
    "Repeated stimulation → progressive EPP decline → FATIGABLE WEAKNESS",
], fill=LIGHT_RED, stroke=RED))
story.append(Paragraph("C. Clinical Features:", sub_head))
story.append(bullet([
    "Fatigable ptosis (drooping of eyelid worsens with use)",
    "Diplopia, dysarthria, dysphagia",
    "Proximal limb weakness, worse at end of day",
    "Myasthenic crisis: respiratory failure (life-threatening)",
]))
story.append(Paragraph("D. Investigations:", sub_head))
story.append(bullet([
    "Anti-AChR antibodies (positive in 85%)",
    "Edrophonium (Tensilon) test: short-acting AChE inhibitor → temporary improvement",
    "Decremental response on repetitive nerve stimulation (EMG)",
    "CT chest: Thymoma (15%)",
]))
story.append(Paragraph("E. Treatment:", sub_head))
story.append(bullet([
    "Pyridostigmine (AChE inhibitor) — first line",
    "Steroids / Immunosuppressants (azathioprine)",
    "Thymectomy (especially if thymoma present)",
    "Plasmapheresis / IVIG for crisis",
]))
story.append(ref("Guyton & Hall, 14e, Ch.7; Ganong 26e, Ch.6"))
story.append(PageBreak())


# ══════════════════════════════════════════════════════════════════════════════
# SECTION 4 — DIGESTIVE SYSTEM
# ══════════════════════════════════════════════════════════════════════════════
story.append(chapter_header("SECTION 4: DIGESTIVE SYSTEM", TEAL))
story.append(Spacer(1, 0.3*cm))

# ─── Q32: Nerve Supply to GIT ────────────────────────────────────────────────
story.append(section_box("Q32. Nerve Supply to GIT [S5]", LIGHT_TEAL, TEAL))
story.append(tbl(
    ["Division", "Nerves", "Function"],
    [
        ["Extrinsic Parasympathetic",
         "Vagus nerve (CN X) — to oesophagus to transverse colon\nPelvic nerves (S2,3,4) — to descending colon to rectum",
         "↑ GI motility and secretion; ↓ sphincter tone"],
        ["Extrinsic Sympathetic",
         "Greater splanchnic (T5-9) → celiac plexus\nLesser splanchnic (T10-11) → superior mesenteric\nLeast splanchnic (T12) → inferior mesenteric",
         "↓ GI motility and secretion; ↑ sphincter tone; vasoconstriction"],
        ["Enteric Nervous System (Intrinsic)",
         "Auerbach's (myenteric) plexus — between circular and longitudinal muscle\nMeissner's (submucosal) plexus — in submucosa",
         "Controls all GI motility and secretion independently; 'Second Brain'"],
    ],
    col_widths=[3.5*cm, 5.5*cm, 7.5*cm]
))
story.append(ref("Guyton & Hall, 14e, Ch.63; Ganong 26e, Ch.26"))
story.append(divider())

# ─── Q33: Saliva ─────────────────────────────────────────────────────────────
story.append(section_box("Q33. Composition and Functions of Saliva [S3]", LIGHT_GREEN, GREEN))
story.append(Paragraph("A. Composition (daily volume: 1–1.5 L/day; pH 6.0–7.4)", sub_head))
story.append(tbl(
    ["Component", "Source / Notes"],
    [
        ["Salivary amylase (Ptyalin)", "Parotid gland; begins starch digestion (α-1,4 bonds)"],
        ["Lingual lipase", "Serous glands of tongue; fat digestion starts in mouth"],
        ["Mucin (Mucus)", "Sublingual + submandibular; lubrication"],
        ["IgA (secretory)", "Antibacterial; passive immunity"],
        ["Lysozyme", "Antimicrobial enzyme; cleaves bacterial cell wall"],
        ["Lactoferrin", "Binds iron; bacteriostatic"],
        ["Bicarbonate (HCO₃⁻)", "Neutralises acid; protects teeth"],
        ["Kallikrein", "Produces bradykinin → vasodilation"],
        ["Water", "~99%"],
    ],
    col_widths=[5*cm, 11.5*cm]
))
story.append(Paragraph("B. Functions of Saliva:", sub_head))
story.append(numbered([
    "Digestion: amylase begins starch hydrolysis",
    "Lubrication: mucin facilitates swallowing",
    "Antibacterial: IgA, lysozyme, lactoferrin",
    "Solvent: dissolves food chemicals for taste",
    "pH regulation: HCO₃⁻ neutralises acid",
    "Oral hygiene: washes food particles",
    "Speech: moistens mouth",
]))
story.append(ref("Guyton & Hall, 14e, Ch.64; Ganong 26e, Ch.26"))
story.append(divider())

# ─── Q34: Gastric Juice ─────────────────────────────────────────────────────
story.append(section_box("Q34. Composition and Functions of Gastric Juice [S3]", LIGHT_BLUE, DARK_BLUE))
story.append(tbl(
    ["Component", "Cell of origin", "Function"],
    [
        ["HCl", "Parietal (Oxyntic) cells", "Kills bacteria; converts pepsinogen → pepsin; denatures proteins; provides acid environment"],
        ["Pepsinogen", "Chief (Peptic) cells", "Activated by HCl → Pepsin; begins protein digestion"],
        ["Intrinsic Factor (IF)", "Parietal cells", "Essential for Vit B12 absorption in terminal ileum"],
        ["Mucus", "Mucous neck cells + surface mucus cells", "Protects gastric mucosa from acid; bicarbonate barrier"],
        ["Gastric lipase", "Chief cells", "Begins fat digestion (limited)"],
        ["Gastrin", "G cells (antrum)", "Stimulates HCl secretion and gastric motility"],
    ],
    col_widths=[3.5*cm, 4.5*cm, 8.5*cm]
))
story.append(key_point("H⁺-K⁺-ATPase (proton pump) in parietal cells is the final step in HCl secretion; inhibited by PPIs"))
story.append(ref("Guyton & Hall, 14e, Ch.65"))
story.append(divider())

# ─── Q35: Secretion of Gastric Juice (Guyton) + Phases ─────────────────────
story.append(section_box("Q35. Secretion of Gastric Juice — Guyton & Phases of Gastric Secretion [S5]", LIGHT_ORG, ORANGE))
story.append(Paragraph("Phases of Gastric Secretion:", sub_head))
story.append(tbl(
    ["Phase", "Stimulus", "Mechanism", "% of Total Secretion"],
    [
        ["Cephalic Phase",
         "Sight, smell, taste, thought of food",
         "Via Vagus nerve (CN X) → ACh → stimulates parietal and chief cells",
         "~30%"],
        ["Gastric Phase",
         "Food in stomach; distension; amino acids, peptides",
         "Gastrin released from G cells (antrum); Vagal reflex; Histamine (ECL cells via H₂ receptors)",
         "~60%"],
        ["Intestinal Phase",
         "Chyme enters duodenum",
         "Initial: intestinal gastrin stimulates; Late: secretin, CCK, GIP inhibit",
         "~10%"],
    ],
    col_widths=[3*cm, 4.5*cm, 6.5*cm, 2.5*cm]
))
story.append(Paragraph("Stimulants of HCl secretion:", sub_head))
story.append(bullet([
    "Gastrin (via CCK-B receptors on parietal cells)",
    "Histamine (via H₂ receptors on parietal cells — most potent stimulus)",
    "ACh (via M₃ receptors on parietal cells)",
]))
story.append(Paragraph("Inhibitors of HCl secretion:", sub_head))
story.append(bullet([
    "Secretin — released when duodenal pH < 2",
    "CCK (cholecystokinin) — from duodenum",
    "GIP (gastric inhibitory peptide) — fat in duodenum",
    "Somatostatin — from D cells",
]))
story.append(ref("Guyton & Hall, 14e, Ch.65"))
story.append(divider())

# ─── Q36: Pancreatic Juice ──────────────────────────────────────────────────
story.append(section_box("Q36. Composition, Functions and Regulation of Pancreatic Juice [S3]", LIGHT_TEAL, TEAL))
story.append(Paragraph("A. Composition (Volume: 1.5–2 L/day; pH 8–8.3)", sub_head))
story.append(tbl(
    ["Enzyme", "Precursor", "Function"],
    [
        ["Trypsin", "Trypsinogen → activated by Enterokinase",
         "Cleaves peptide bonds at Arg/Lys; activates other zymogens"],
        ["Chymotrypsin", "Chymotrypsinogen → activated by Trypsin",
         "Cleaves at aromatic/bulky amino acids"],
        ["Elastase", "Proelastase", "Cleaves elastin"],
        ["Carboxypeptidase A & B", "Procarboxypeptidase", "Exopeptidases — cleave from C-terminal"],
        ["Pancreatic amylase", "—", "Digests starch → maltose + dextrins"],
        ["Pancreatic lipase", "—", "Digests triglycerides → monoglycerides + fatty acids"],
        ["Colipase", "—", "Cofactor for lipase; anchors lipase to lipid droplets"],
        ["Phospholipase A₂", "—", "Digests phospholipids"],
        ["Ribonuclease/DNase", "—", "Digests RNA/DNA"],
        ["Bicarbonate (HCO₃⁻)", "— (from ductal cells)", "Neutralises acid chyme; pH 8.3; essential for enzyme activity"],
    ],
    col_widths=[3.5*cm, 3.5*cm, 9.5*cm]
))
story.append(Paragraph("B. Regulation:", sub_head))
story.append(tbl(
    ["Stimulus", "Hormone", "Effect on Pancreas"],
    [
        ["Acid chyme in duodenum (pH<4.5)", "Secretin (S-cells)", "↑↑ HCO₃⁻ secretion (water + bicarbonate)"],
        ["Fats + Proteins in duodenum", "CCK (I-cells)", "↑↑ Enzyme secretion"],
        ["Vagal stimulation (cephalic phase)", "ACh", "↑ Enzyme secretion (minor)"],
        ["Somatostatin", "D-cells", "↓ Pancreatic secretion"],
    ],
    col_widths=[4.5*cm, 3*cm, 9*cm]
))
story.append(ref("Guyton & Hall, 14e, Ch.66; Ganong 26e, Ch.26"))
story.append(divider())

# ─── Q37: Bile and Bile Salts ────────────────────────────────────────────────
story.append(section_box("Q37. Functions of Bile and Bile Salts [S5]", LIGHT_BLUE, DARK_BLUE))
story.append(Paragraph("A. Composition of Bile (produced 700–1000 mL/day):", sub_head))
story.append(tbl(
    ["Component", "Notes"],
    [
        ["Bile salts", "Chenodeoxycholic + Cholic acid conjugated with glycine/taurine; 50%"],
        ["Phospholipids (Lecithin)", "Solubilises cholesterol in bile"],
        ["Cholesterol", "End product of cholesterol metabolism"],
        ["Bilirubin glucuronide", "Main bile pigment; gives bile yellow-green colour"],
        ["Electrolytes", "Na⁺, Cl⁻, HCO₃⁻"],
        ["Water", "~95%"],
    ],
    col_widths=[4.5*cm, 12*cm]
))
story.append(Paragraph("B. Functions of Bile Salts:", sub_head))
story.append(numbered([
    "Emulsification of fats: reduce large fat globules to small droplets → ↑ surface area for lipase",
    "Micelle formation: solubilise lipid digestion products (fatty acids, monoglycerides) for absorption",
    "Activation of pancreatic lipase",
    "Enterohepatic circulation: 94% reabsorbed in terminal ileum → portal vein → liver",
    "Cholesterol excretion: primary route for cholesterol elimination",
]))
story.append(Paragraph("C. Functions of Bile itself:", sub_head))
story.append(bullet([
    "Excretion of bilirubin, cholesterol, drug metabolites",
    "Neutralises acid chyme (with HCO₃⁻)",
    "Fat-soluble vitamin (A, D, E, K) absorption",
]))
story.append(ref("Guyton & Hall, 14e, Ch.66"))
story.append(divider())

# ─── Q38: Jaundice ──────────────────────────────────────────────────────────
story.append(section_box("Q38. Jaundice [S5]", LIGHT_ORG, ORANGE))
story.append(Paragraph(
    "Jaundice (Icterus) = yellowish discolouration of skin, sclera, and mucous membranes due to "
    "raised serum bilirubin (>2 mg/dL).", body))
story.append(tbl(
    ["Feature", "Pre-hepatic (Haemolytic)", "Hepatic (Hepatocellular)", "Post-hepatic (Obstructive)"],
    [
        ["Cause", "Excess RBC destruction", "Liver cell damage", "Bile duct obstruction"],
        ["Examples", "Haemolytic anaemia, malaria, G6PD deficiency",
         "Viral hepatitis, cirrhosis, drugs",
         "Gallstone, Ca pancreas, cholangiocarcinoma"],
        ["Bilirubin type", "↑ Unconjugated", "↑ Both", "↑ Conjugated"],
        ["Urine bilirubin", "Absent", "Present", "Present (dark urine)"],
        ["Urine urobilinogen", "↑↑ (↑ haem breakdown)", "↑ or Normal", "Absent or ↓"],
        ["Stool colour", "Dark (↑ stercobilin)", "Normal or pale", "Pale/clay-coloured"],
        ["Liver enzymes", "Normal", "↑ ALT, AST", "↑ ALP, GGT"],
        ["Pruritus", "Absent", "Variable", "Present (↑ bile salts in skin)"],
    ],
    col_widths=[3*cm, 4*cm, 4.5*cm, 5*cm]
))
story.append(ref("Guyton & Hall, 14e, Ch.71"))
story.append(divider())

# ─── Q39: Deglutition ────────────────────────────────────────────────────────
story.append(section_box("Q39. Deglutition (Swallowing) [S10]", LIGHT_GREEN, GREEN))
story.append(Paragraph("Deglutition = process of swallowing; has 3 phases:", sub_head))
story.append(tbl(
    ["Phase", "Voluntary/Reflex", "Events"],
    [
        ["Oral/Buccal Phase",
         "VOLUNTARY",
         "Tongue pushes bolus backward to pharynx; lips closed; soft palate pressed against teeth"],
        ["Pharyngeal Phase",
         "REFLEX (mediated by swallowing centre in medulla)",
         "Soft palate closes nasopharynx; larynx elevates; epiglottis closes laryngeal inlet; UES opens; peristaltic wave carries bolus to oesophagus; breathing briefly stops"],
        ["Oesophageal Phase",
         "REFLEX (enteric + vagal)",
         "Primary peristalsis carries bolus; LES relaxes; gravity assists upright; if bolus remains → secondary peristalsis (distension-induced)"],
    ],
    col_widths=[3.5*cm, 3.5*cm, 9.5*cm]
))
story.append(key_point("Dysphagia to solids first → mechanical obstruction; Dysphagia to liquids first → neuromuscular disorder"))
story.append(ref("Guyton & Hall, 14e, Ch.64; Ganong 26e, Ch.26"))
story.append(divider())

# ─── Q40: Movements of Stomach ──────────────────────────────────────────────
story.append(section_box("Q40. Movements of the Stomach [S3]", LIGHT_TEAL, TEAL))
story.append(tbl(
    ["Movement", "Location", "Function"],
    [
        ["Receptive Relaxation",
         "Fundus",
         "Vagally-mediated relaxation of fundus when food enters → accommodation; ↑ volume without ↑ pressure"],
        ["Tonic Contractions",
         "Body",
         "Slow sustained contractions → mix food and propel toward antrum"],
        ["Peristaltic Waves",
         "Body → Antrum",
         "3 waves/min; propulsive force; mix chyme with gastric juice; driven by pacemaker cells in corpus"],
        ["Retropulsion",
         "Antrum + Pylorus",
         "Pylorus closes before complete emptying → chyme bounces back → trituration (mechanical grinding)"],
        ["Systolic Contractions (Pyloric pump)",
         "Antrum",
         "Strong peristaltic contractions every 20s squirt small amounts (1–7 mL) into duodenum"],
    ],
    col_widths=[4*cm, 3*cm, 9.5*cm]
))
story.append(ref("Guyton & Hall, 14e, Ch.64"))
story.append(divider())

# ─── Q41: Emptying of Stomach ────────────────────────────────────────────────
story.append(section_box("Q41. Gastric Emptying [S5]", LIGHT_BLUE, DARK_BLUE))
story.append(Paragraph("A. Factors that PROMOTE gastric emptying:", sub_head))
story.append(bullet([
    "Distension of stomach (→ antral pump activated)",
    "Gastrin hormone",
    "Motilin hormone",
    "Liquid / semi-liquid contents",
]))
story.append(Paragraph("B. Factors that INHIBIT gastric emptying (Enterogastric Reflex):", sub_head))
story.append(bullet([
    "Fats in duodenum → CCK → powerful inhibition",
    "Acid in duodenum (pH<3.5) → Secretin → inhibition",
    "Hyperosmotic solutions in duodenum → osmoreceptors → inhibition",
    "Protein/fats → GIP → inhibition",
    "Pain, stress (via SNS)",
]))
story.append(Paragraph("C. Half-emptying times:", sub_head))
story.append(bullet([
    "Water: ~10–20 min",
    "Mixed meal: ~3–4 hours",
    "Fats: longest (4–5 hours)",
]))
story.append(ref("Guyton & Hall, 14e, Ch.64"))
story.append(divider())

# ─── Q42: Vomiting ──────────────────────────────────────────────────────────
story.append(section_box("Q42. Vomiting [S5]", LIGHT_RED, RED))
story.append(Paragraph("A. Definition & Control Centre:", sub_head))
story.append(bullet([
    "Vomiting = forceful expulsion of gastric/intestinal contents through mouth",
    "Controlled by Vomiting Centre in reticular formation of medulla",
    "Chemoreceptor Trigger Zone (CTZ): area postrema, floor of 4th ventricle — lacks blood-brain barrier; responds to drugs, toxins",
]))
story.append(Paragraph("B. Causes (Act on CTZ or Vomiting Centre):", sub_head))
story.append(bullet([
    "GI irritation (gastroenteritis, peptic ulcer, obstruction)",
    "Motion sickness (vestibular-cerebellar pathway)",
    "Drugs: opioids, chemotherapy, digoxin, levodopa (act on CTZ via D₂/5-HT₃ receptors)",
    "Pregnancy (hCG stimulates CTZ)",
    "Raised ICP (stimulates VC directly)",
    "Uraemia, DKA (metabolic triggers via CTZ)",
]))
story.append(Paragraph("C. Act of Vomiting — Sequence:", sub_head))
story.append(simple_flowchart([
    "Deep inspiration → Glottis closes (prevents aspiration)",
    "Soft palate elevates → closes nasopharynx",
    "Diaphragm + Abdominal muscles contract forcefully → ↑ intra-abdominal pressure",
    "LES relaxes + Cardia of stomach opens",
    "Reverse peristalsis from small intestine → stomach → oesophagus",
    "Stomach contents expelled through mouth",
], fill=LIGHT_RED, stroke=RED))
story.append(Paragraph("D. Complications of Vomiting:", sub_head))
story.append(bullet([
    "Metabolic alkalosis (loss of H⁺ and Cl⁻)",
    "Hypokalaemia",
    "Dehydration",
    "Mallory-Weiss tear (mucosal tear at gastro-oesophageal junction)",
    "Aspiration pneumonia",
]))
story.append(ref("Guyton & Hall, 14e, Ch.64; Ganong 26e, Ch.26"))
story.append(divider())

# ─── Q43: Movements of Small Intestine ──────────────────────────────────────
story.append(section_box("Q43. Movements of Small Intestine [S10]", LIGHT_TEAL, TEAL))
story.append(tbl(
    ["Movement", "Type", "Description", "Function"],
    [
        ["Segmentation",
         "Non-propulsive (mixing)",
         "Circular muscle contracts in segments; 12/min duodenum, 8/min ileum; controlled by Auerbach's plexus + slow waves",
         "Mixes chyme with digestive juices; maximises contact with mucosa for absorption"],
        ["Peristalsis",
         "Propulsive",
         "Coordinated circular + longitudinal contractions; 'law of intestine'; moves aboral",
         "Propels chyme from duodenum → ileum"],
        ["Pendular movements",
         "Propulsive (partial)",
         "To and fro motion; common in small intestine",
         "Mixing"],
        ["Migrating Motor Complex (MMC)",
         "Interdigestive",
         "Powerful peristaltic waves every 90 min during fasting; from stomach → terminal ileum",
         "Housekeeping; clears debris and bacteria between meals"],
        ["Villous movements",
         "Local",
         "Rhythmic shortening/lengthening of intestinal villi",
         "Empties lacteals and venous capillaries; aids absorption"],
    ],
    col_widths=[3.5*cm, 3*cm, 5.5*cm, 4.5*cm]
))
story.append(ref("Guyton & Hall, 14e, Ch.64; Ganong 26e, Ch.26"))
story.append(divider())

# ─── Q44: Defecation ────────────────────────────────────────────────────────
story.append(section_box("Q44. Defecation [S5]", LIGHT_PURP, PURPLE))
story.append(simple_flowchart([
    "Colonic mass movements propel faeces into rectum",
    "Distension of rectum → Rectal pressure >25 mmHg → stretch receptors activated",
    "Signals via pelvic nerves to sacral spinal cord (S2,3,4) and cerebral cortex",
    "DEFECATION REFLEX (Intrinsic): Relaxation of internal anal sphincter (IAS); contraction of rectal walls",
    "CONSCIOUS CONTROL: If appropriate → External anal sphincter (EAS) relaxed (voluntary)",
    "VALSALVA MANOEUVRE: Deep breath → glottis closed → diaphragm + abd muscles contract → ↑ intra-abdominal pressure",
    "Puborectalis relaxes → anorectal angle straightens",
    "Faeces expelled",
], fill=LIGHT_PURP, stroke=PURPLE))
story.append(tbl(
    ["Sphincter", "Innervation", "Control"],
    [
        ["Internal Anal Sphincter (IAS)", "Autonomic (involuntary smooth muscle)", "Normally closed; relaxed by rectal distension (rectoanal inhibitory reflex)"],
        ["External Anal Sphincter (EAS)", "Pudendal nerve (S2,3,4) — somatic/voluntary", "Voluntarily contracted to defer defecation or relaxed to permit it"],
    ],
    col_widths=[4.5*cm, 4.5*cm, 7.5*cm]
))
story.append(ref("Guyton & Hall, 14e, Ch.64"))
story.append(divider())

# ─── Q45: Function of Liver ──────────────────────────────────────────────────
story.append(section_box("Q45. Functions of the Liver [S2]", LIGHT_GREEN, GREEN))
story.append(tbl(
    ["Category", "Functions"],
    [
        ["Metabolic",
         "Carbohydrate metabolism (glycogenesis, glycogenolysis, gluconeogenesis)\n"
         "Fat metabolism (β-oxidation, ketogenesis, lipogenesis, VLDL synthesis)\n"
         "Protein metabolism (transamination, deamination, urea synthesis)"],
        ["Secretory", "Bile production (700 mL/day); bile salts synthesis"],
        ["Synthetic",
         "Plasma proteins (albumin, globulins, fibrinogen, clotting factors I, II, V, VII, IX, X)\n"
         "Hormone synthesis (IGF-1, angiotensinogen, thrombopoietin)"],
        ["Detoxification",
         "Drug and toxin metabolism (Phase I: CYP450 oxidation; Phase II: conjugation)\n"
         "Alcohol metabolism (alcohol dehydrogenase)\n"
         "Ammonia → Urea (urea cycle)"],
        ["Storage",
         "Glycogen (2-day supply)\nFat-soluble vitamins (A, D, E, K) and B12\nIron (ferritin, haemosiderin)\nCopper"],
        ["Excretory", "Bilirubin, cholesterol, drug metabolites → bile"],
        ["Immune",
         "Kupffer cells (hepatic macrophages) — phagocytose bacteria from portal blood"],
        ["Endocrine",
         "Converts T4 → T3 (active thyroid hormone)\n25-hydroxylation of Vit D3\nDegradation of hormones (insulin, glucagon, steroids)"],
        ["Haematopoiesis",
         "Foetal haematopoiesis (6–7 weeks); produces EPO"],
    ],
    col_widths=[4*cm, 12.5*cm]
))
story.append(ref("Guyton & Hall, 14e, Ch.71"))

# ─── Final page ───────────────────────────────────────────────────────────────
story.append(PageBreak())
end_data = [[Paragraph("END OF ANSWER KEY", ParagraphStyle(
    "end", fontSize=20, textColor=WHITE, alignment=TA_CENTER,
    fontName="Helvetica-Bold"))]]
end_tbl = Table(end_data, colWidths=[W - 3.6*cm])
end_tbl.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,-1), DARK_BLUE),
    ("TOPPADDING",    (0,0), (-1,-1), 20),
    ("BOTTOMPADDING", (0,0), (-1,-1), 20),
]))
story.append(Spacer(1, 5*cm))
story.append(end_tbl)
story.append(Spacer(1, 0.5*cm))
story.append(Paragraph(
    "References: Guyton & Hall Textbook of Medical Physiology (14e) · "
    "Ganong's Review of Medical Physiology (26e) · Costanzo Physiology (7e)",
    S("Normal", fontSize=10, textColor=MID_BLUE, alignment=TA_CENTER)))
story.append(Spacer(1,0.3*cm))
story.append(Paragraph(
    "Best of luck for your Prelims Examination! 🎓",
    S("Normal", fontSize=12, textColor=GREEN, alignment=TA_CENTER,
      fontName="Helvetica-Bold")))

# ══════════════════════════════════════════════════════════════════════════════
# BUILD
# ══════════════════════════════════════════════════════════════════════════════
doc.build(story)
print("PDF generated successfully!")
Running Command

cd /home/daytona/workspace/physiology-exam && python gen_pdf.py 2>&1

Editing File

~/physiology-exam/gen_pdf.py

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/physiology-exam/gen_pdf.py'
Running Command

cd /home/daytona/workspace/physiology-exam && python gen_pdf.py 2>&1

Searching Content

"body.clone" in ~/physiology-exam

Editing File

~/physiology-exam/gen_pdf.py

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/physiology-exam/gen_pdf.py'
Running Command

cd /home/daytona/workspace/physiology-exam && python gen_pdf.py 2>&1

Editing File

~/physiology-exam/gen_pdf.py

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/physiology-exam/gen_pdf.py'
Running Command

cd /home/daytona/workspace/physiology-exam && python gen_pdf.py 2>&1

Running Command

ls -lh /home/daytona/workspace/physiology-exam/Physiology_Prelims_Answers.pdf

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

Physiology Prelims Answers

PDF Document · PDF


Here's what's inside the PDF:
Structure & Features:
  • Color-coded chapter headers for each section (General, Blood, Muscle, Digestive)
  • Every question in a labeled section box with its marks value
  • Flowcharts with arrows for processes like: Haemostasis, Blood Coagulation, Erythropoiesis, Cross-bridge cycle, Defecation, Vomiting, NMJ events, Gastric secretion phases
  • Tables for comparison questions (Apoptosis vs Necrosis, ABO groups, Anaemia types, Jaundice types, etc.)
  • Bullet points for concise exam-friendly answers
  • Numbered lists for ordered processes
  • "★ KEY POINT" highlights for examiner-favourite facts
  • Reference cited after each answer (Guyton & Hall 14e, Ganong 26e, Costanzo 7e)
45 Questions covered across all 4 sections:
SectionTopics Covered
GeneralMitochondria, Apoptosis, Gap Junction, Transport & Osmosis, Pinocytosis, Homeostasis
BloodPlasma proteins, Biconcave RBC, Fate of Hb, Erythropoiesis, Anaemia, Immunity, Platelets, Haemostasis, Coagulation, Anticoagulation, Bleeding disorders, ABO/Rh, Erythroblastosis foetalis, Transfusion hazards
MuscleSarcomere, Contractile proteins, Sarco-tubular system, Contraction mechanism, NMJ, Muscle tone, Refractory period, AP curve, Rigor mortis, Myasthenia gravis
DigestiveGIT nerve supply, Saliva, Gastric juice, Gastric secretion phases, Pancreatic juice, Bile & bile salts, Jaundice, Deglutition, Stomach movements, Gastric emptying, Vomiting, Small intestine movements, Defecation, Liver functions
All the best for your prelims! 🎓
This is a shared conversation. Sign in to Orris to start your own chat.