attachment
attachment

MBBS Proff and with proper diagrams and flow charts PDF

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

mkdir -p /tmp/workspace/mbbs-surgery-paper && ls /tmp/workspace/

Writing File

~/mbbs-surgery-paper/generate_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 inch, cm
from reportlab.platypus import (SimpleDocTemplate, Paragraph, Spacer, Table,
                                 TableStyle, PageBreak, HRFlowable, ListFlowable, ListItem)
from reportlab.platypus.flowables import Flowable
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.graphics.shapes import Drawing, Rect, String, Line, Polygon, Arrow, Circle, Group
from reportlab.graphics.charts.flowcharts import *
from reportlab.graphics import renderPDF
import reportlab.graphics.shapes as shapes

PAGE_W, PAGE_H = A4
MARGIN = 1.8 * cm

# ─── Color palette ───────────────────────────────────────────────────────────
C_DARK   = colors.HexColor('#1a2540')   # deep navy
C_MED    = colors.HexColor('#2e6da4')   # mid-blue
C_LIGHT  = colors.HexColor('#d6eaf8')   # pale blue
C_GREEN  = colors.HexColor('#1e8449')
C_LGREEN = colors.HexColor('#d5f5e3')
C_ORANGE = colors.HexColor('#d35400')
C_LORANGE= colors.HexColor('#fdebd0')
C_RED    = colors.HexColor('#c0392b')
C_LRED   = colors.HexColor('#fadbd8')
C_YELLOW = colors.HexColor('#f39c12')
C_LYELLOW= colors.HexColor('#fef9e7')
C_PURPLE = colors.HexColor('#7d3c98')
C_LPURPLE= colors.HexColor('#f4ecf7')
C_GRAY   = colors.HexColor('#808b96')
C_LGRAY  = colors.HexColor('#f2f3f4')
C_WHITE  = colors.white
C_BLACK  = colors.black

doc = SimpleDocTemplate(
    "/tmp/workspace/mbbs-surgery-paper/Surgery_Paper_I_Answers.pdf",
    pagesize=A4,
    rightMargin=MARGIN, leftMargin=MARGIN,
    topMargin=MARGIN, bottomMargin=MARGIN,
    title="3rd Prof Surgery Paper I – Model Answers",
    author="Orris AI – MBBS Study Aid"
)

styles = getSampleStyleSheet()

# Custom styles
def S(name, **kw):
    return ParagraphStyle(name, **kw)

sTitle    = S('sTitle',    fontSize=20, textColor=C_WHITE,     alignment=TA_CENTER, fontName='Helvetica-Bold', leading=26, spaceAfter=4)
sSubTitle = S('sSubTitle', fontSize=11, textColor=C_LIGHT,     alignment=TA_CENTER, fontName='Helvetica',      leading=15, spaceAfter=6)
sQ        = S('sQ',        fontSize=13, textColor=C_WHITE,     alignment=TA_LEFT,   fontName='Helvetica-Bold', leading=18, spaceAfter=2)
sSection  = S('sSection',  fontSize=11, textColor=C_WHITE,     alignment=TA_LEFT,   fontName='Helvetica-Bold', leading=16, spaceAfter=2)
sBody     = S('sBody',     fontSize=9.5,textColor=C_DARK,      alignment=TA_JUSTIFY,fontName='Helvetica',      leading=14, spaceAfter=4)
sBullet   = S('sBullet',   fontSize=9.5,textColor=C_DARK,      alignment=TA_LEFT,   fontName='Helvetica',      leading=13, spaceAfter=2, leftIndent=14, bulletIndent=4)
sEmphasis = S('sEmphasis', fontSize=9.5,textColor=C_DARK,      alignment=TA_LEFT,   fontName='Helvetica-Bold', leading=13, spaceAfter=2)
sSmall    = S('sSmall',    fontSize=8,  textColor=C_GRAY,      alignment=TA_CENTER, fontName='Helvetica',      leading=11)
sCenter   = S('sCenter',   fontSize=9.5,textColor=C_DARK,      alignment=TA_CENTER, fontName='Helvetica',      leading=13, spaceAfter=4)
sTableH   = S('sTableH',   fontSize=9,  textColor=C_WHITE,     alignment=TA_CENTER, fontName='Helvetica-Bold', leading=13)
sTableB   = S('sTableB',   fontSize=8.5,textColor=C_DARK,      alignment=TA_LEFT,   fontName='Helvetica',      leading=12)
sTableBC  = S('sTableBC',  fontSize=8.5,textColor=C_DARK,      alignment=TA_CENTER, fontName='Helvetica',      leading=12)
sNote     = S('sNote',     fontSize=8.5,textColor=C_ORANGE,    alignment=TA_LEFT,   fontName='Helvetica-BoldOblique', leading=12, spaceAfter=2)

AVAILABLE_WIDTH = PAGE_W - 2 * MARGIN

# ─── Helper: colored header band ────────────────────────────────────────────
def q_header(qnum, title, marks, color=C_DARK):
    data = [[Paragraph(f"Q{qnum}. {title}", sQ), Paragraph(f"({marks} marks)", sQ)]]
    t = Table(data, colWidths=[AVAILABLE_WIDTH*0.82, AVAILABLE_WIDTH*0.18])
    t.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,-1), color),
        ('PADDING', (0,0), (-1,-1), 7),
        ('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
        ('ALIGN', (1,0), (1,0), 'RIGHT'),
        ('ROUNDEDCORNERS', [4, 4, 4, 4]),
    ]))
    return t

def sub_header(text, color=C_MED):
    data = [[Paragraph(text, sSection)]]
    t = Table(data, colWidths=[AVAILABLE_WIDTH])
    t.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,-1), color),
        ('PADDING', (0,0), (-1,-1), 5),
        ('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
    ]))
    return t

def info_box(text, color=C_LIGHT, border=C_MED):
    data = [[Paragraph(text, sBody)]]
    t = Table(data, colWidths=[AVAILABLE_WIDTH])
    t.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,-1), color),
        ('BOX', (0,0), (-1,-1), 1, border),
        ('PADDING', (0,0), (-1,-1), 6),
        ('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
    ]))
    return t

def bullet(txt): return Paragraph(f"• {txt}", sBullet)
def body(txt):   return Paragraph(txt, sBody)
def bold(txt):   return Paragraph(txt, sEmphasis)
def note(txt):   return Paragraph(f"★ {txt}", sNote)
def sp(h=4):     return Spacer(1, h)
def hr():        return HRFlowable(width="100%", thickness=0.5, color=C_GRAY, spaceAfter=3)

# ─── FLOWCHART / DIAGRAM helpers ────────────────────────────────────────────
class BoxArrowChart(Flowable):
    """Vertical flowchart with boxes and arrows."""
    def __init__(self, steps, width=None, box_height=26, spacing=18, colors_list=None):
        super().__init__()
        self.steps = steps  # list of (text, bg_color, text_color)
        self.w = width or AVAILABLE_WIDTH
        self.box_h = box_height
        self.spacing = spacing
        n = len(steps)
        self.height = n * box_height + (n - 1) * spacing
        self.width = self.w

    def draw(self):
        c = self.canv
        bw = self.w * 0.72
        bx = (self.w - bw) / 2
        y = self.height

        for i, (text, bg, tc) in enumerate(self.steps):
            y -= self.box_h
            # rounded rect
            c.setFillColor(bg)
            c.setStrokeColor(colors.HexColor('#aaaaaa'))
            c.setLineWidth(0.5)
            c.roundRect(bx, y, bw, self.box_h, 5, fill=1, stroke=1)
            # text
            c.setFillColor(tc)
            c.setFont('Helvetica-Bold' if i == 0 else 'Helvetica', 8.5)
            c.drawCentredString(self.w / 2, y + self.box_h / 2 - 4, text)

            if i < len(self.steps) - 1:
                # arrow down
                mid_x = self.w / 2
                ay_top = y
                ay_bot = y - self.spacing
                c.setStrokeColor(C_MED)
                c.setLineWidth(1.2)
                c.line(mid_x, ay_top, mid_x, ay_bot + 6)
                # arrowhead
                c.setFillColor(C_MED)
                c.setStrokeColor(C_MED)
                c.polygon([mid_x-4, ay_bot+6, mid_x+4, ay_bot+6, mid_x, ay_bot], fill=1, stroke=0)
                y -= self.spacing

class HorizontalFlowchart(Flowable):
    """Horizontal flowchart."""
    def __init__(self, steps, width=None, box_height=32):
        super().__init__()
        self.steps = steps  # list of (text, bg_color, text_color)
        self.w = width or AVAILABLE_WIDTH
        n = len(steps)
        self.box_w = (self.w - (n - 1) * 12) / n
        self.box_h = box_height
        self.height = box_height + 20
        self.width = self.w

    def draw(self):
        c = self.canv
        n = len(self.steps)
        box_w = (self.w - (n - 1) * 12) / n
        y0 = 10

        for i, (text, bg, tc) in enumerate(self.steps):
            x = i * (box_w + 12)
            c.setFillColor(bg)
            c.setStrokeColor(colors.HexColor('#aaaaaa'))
            c.setLineWidth(0.5)
            c.roundRect(x, y0, box_w, self.box_h, 4, fill=1, stroke=1)
            c.setFillColor(tc)
            c.setFont('Helvetica-Bold' if i == 0 else 'Helvetica', 7.5)
            # word wrap manually
            words = text.split()
            line1 = ' '.join(words[:len(words)//2 + (len(words)%2)])
            line2 = ' '.join(words[len(words)//2 + (len(words)%2):])
            if line2:
                c.drawCentredString(x + box_w/2, y0 + self.box_h/2 + 3, line1)
                c.drawCentredString(x + box_w/2, y0 + self.box_h/2 - 7, line2)
            else:
                c.drawCentredString(x + box_w/2, y0 + self.box_h/2 - 4, text)

            if i < n - 1:
                ax = x + box_w
                ay = y0 + self.box_h/2
                c.setStrokeColor(C_MED)
                c.setLineWidth(1.2)
                c.line(ax, ay, ax + 8, ay)
                c.setFillColor(C_MED)
                c.polygon([ax+8, ay+3, ax+8, ay-3, ax+12, ay], fill=1, stroke=0)

class ClassificationDiagram(Flowable):
    """Tree diagram for classification."""
    def __init__(self, root, branches, width=None, height=160):
        super().__init__()
        self.root = root
        self.branches = branches  # list of (branch_label, [leaf1, leaf2, ...], color)
        self.w = width or AVAILABLE_WIDTH
        self.height = height
        self.width = self.w

    def draw(self):
        c = self.canv
        n_branches = len(self.branches)
        branch_w = self.w / n_branches
        root_h = 26
        root_y = self.height - root_h - 5
        root_x = self.w * 0.25
        root_bw = self.w * 0.50

        # root box
        c.setFillColor(C_DARK)
        c.setStrokeColor(C_DARK)
        c.roundRect(root_x, root_y, root_bw, root_h, 5, fill=1, stroke=0)
        c.setFillColor(C_WHITE)
        c.setFont('Helvetica-Bold', 9)
        c.drawCentredString(self.w/2, root_y + root_h/2 - 4, self.root)

        for i, (label, leaves, col) in enumerate(self.branches):
            bx = i * branch_w + branch_w * 0.1
            bw = branch_w * 0.80
            branch_y = root_y - 50

            # line root -> branch
            c.setStrokeColor(C_GRAY)
            c.setLineWidth(0.8)
            c.line(self.w/2, root_y, bx + bw/2, branch_y + 22)

            # branch box
            c.setFillColor(col)
            c.roundRect(bx, branch_y, bw, 22, 4, fill=1, stroke=0)
            c.setFillColor(C_WHITE)
            c.setFont('Helvetica-Bold', 7.5)
            c.drawCentredString(bx + bw/2, branch_y + 7, label)

            # leaves
            leaf_y = branch_y - 12
            for leaf in leaves:
                leaf_y -= 16
                c.setFillColor(colors.HexColor('#eaf4fb'))
                c.setStrokeColor(col)
                c.setLineWidth(0.5)
                c.roundRect(bx, leaf_y, bw, 14, 3, fill=1, stroke=1)
                c.setFillColor(C_DARK)
                c.setFont('Helvetica', 7)
                c.drawCentredString(bx + bw/2, leaf_y + 3, leaf)
                c.setStrokeColor(C_GRAY)
                c.line(bx + bw/2, branch_y, bx + bw/2, leaf_y + 14)


class PathwayDiagram(Flowable):
    """Two-column pathway (cause -> effect)."""
    def __init__(self, rows, width=None, col_labels=("Mechanism","Effect")):
        super().__init__()
        self.rows = rows  # list of (left, right, color)
        self.w = width or AVAILABLE_WIDTH
        self.col_labels = col_labels
        self.height = len(rows) * 22 + 30
        self.width = self.w

    def draw(self):
        c = self.canv
        col_w = self.w / 2 - 6
        y = self.height - 22
        # header
        for ci, lbl in enumerate(self.col_labels):
            cx = ci * (col_w + 12)
            c.setFillColor(C_DARK)
            c.roundRect(cx, y, col_w, 20, 3, fill=1, stroke=0)
            c.setFillColor(C_WHITE)
            c.setFont('Helvetica-Bold', 8.5)
            c.drawCentredString(cx + col_w/2, y + 6, lbl)
        y -= 4
        for left, right, col in self.rows:
            y -= 22
            for ci, txt in enumerate([left, right]):
                cx = ci * (col_w + 12)
                c.setFillColor(col)
                c.setStrokeColor(colors.HexColor('#cccccc'))
                c.roundRect(cx, y, col_w, 18, 3, fill=1, stroke=1)
                c.setFillColor(C_DARK)
                c.setFont('Helvetica', 7.5)
                c.drawCentredString(cx + col_w/2, y + 4, txt)
            # arrow between cols
            c.setStrokeColor(C_MED)
            c.setLineWidth(1)
            c.line(col_w, y+9, col_w+12, y+9)
            c.setFillColor(C_MED)
            c.polygon([col_w+9, y+12, col_w+9, y+6, col_w+12, y+9], fill=1, stroke=0)

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

# ─── COVER PAGE ─────────────────────────────────────────────
cover_data = [[Paragraph(
    "3rd Prof Part II (Final MBBS)<br/>Surgery Paper I – Model Answers",
    sTitle)]]
cover = Table(cover_data, colWidths=[AVAILABLE_WIDTH])
cover.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,-1), C_DARK),
    ('PADDING', (0,0), (-1,-1), 18),
    ('ROUNDEDCORNERS', [6, 6, 6, 6]),
]))
story += [cover, sp(6)]

meta_data = [[
    Paragraph("Teerthanker Mahaveer Medical College &amp; Research Centre, Moradabad", sSubTitle),
    Paragraph("Dept. of General Surgery | 8th Semester | Batch 2020", sSubTitle),
    Paragraph("Date: 04-04-2024 | Max Marks: 100", sSubTitle),
]]
meta = Table(meta_data, colWidths=[AVAILABLE_WIDTH])
meta.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,-1), C_MED),
    ('PADDING', (0,0), (-1,-1), 8),
    ('ROUNDEDCORNERS', [4,4,4,4]),
]))
story += [meta, sp(6)]
story.append(info_box("📌  This document contains detailed model answers for all 7 questions with diagrams, flowcharts, and tables as required for the Final MBBS examination.", C_LYELLOW, C_YELLOW))
story.append(PageBreak())

# ══════════════════════════════════════════════════════════════
# Q1 – WOUND HEALING
# ══════════════════════════════════════════════════════════════
story.append(q_header(1, "Wound Healing – Phases, Classification & Factors", "3+3+4"))
story.append(sp(6))

# Part A – Phases
story.append(sub_header("A. Phases of Wound Healing (3 marks)"))
story.append(sp(4))
story.append(body("Wound healing proceeds through four overlapping phases: Haemostasis → Inflammation → Proliferation → Remodelling."))
story.append(sp(6))

# Horizontal phases flowchart
phases_fc = HorizontalFlowchart([
    ("HAEMOSTASIS\n0–few hrs", C_RED, C_WHITE),
    ("INFLAMMATION\n1–4 days", C_ORANGE, C_WHITE),
    ("PROLIFERATION\n4–21 days", C_MED, C_WHITE),
    ("REMODELLING\n21 days–2 yrs", C_GREEN, C_WHITE),
], width=AVAILABLE_WIDTH, box_height=38)
story += [phases_fc, sp(4)]

phases_table = [
    [Paragraph("Phase", sTableH), Paragraph("Duration", sTableH), Paragraph("Key Cells", sTableH), Paragraph("Events", sTableH)],
    [Paragraph("Haemostasis", sTableB), Paragraph("Mins–hours", sTableBC), Paragraph("Platelets, clotting factors", sTableB), Paragraph("Vasoconstriction, platelet plug, fibrin clot (scaffold)", sTableB)],
    [Paragraph("Inflammation", sTableB), Paragraph("1–4 days", sTableBC), Paragraph("Neutrophils (1-3d), Macrophages (2-4d)", sTableB), Paragraph("Phagocytosis of debris/bacteria; release of cytokines (IL-1, TNF, PDGF) attracting fibroblasts", sTableB)],
    [Paragraph("Proliferation", sTableB), Paragraph("4–21 days", sTableBC), Paragraph("Fibroblasts, Endothelium, Epithelium", sTableB), Paragraph("Collagen synthesis (Type III→I), angiogenesis, granulation tissue, epithelialisation, wound contraction (myofibroblasts)", sTableB)],
    [Paragraph("Remodelling", sTableB), Paragraph("21 d – 2 yrs", sTableBC), Paragraph("Fibroblasts, MMPs", sTableB), Paragraph("Type III → Type I collagen, cross-linking; max tensile strength ~80% of original; scar maturation", sTableB)],
]
pt = Table(phases_table, colWidths=[AVAILABLE_WIDTH*x for x in [0.18, 0.14, 0.26, 0.42]])
pt.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), C_DARK),
    ('BACKGROUND', (0,1), (-1,1), C_LRED),
    ('BACKGROUND', (0,2), (-1,2), C_LORANGE),
    ('BACKGROUND', (0,3), (-1,3), C_LIGHT),
    ('BACKGROUND', (0,4), (-1,4), C_LGREEN),
    ('BOX', (0,0), (-1,-1), 0.5, C_GRAY),
    ('INNERGRID', (0,0), (-1,-1), 0.3, C_GRAY),
    ('PADDING', (0,0), (-1,-1), 5),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
]))
story += [pt, sp(8)]

# Part B – Classification of Surgical Wounds
story.append(sub_header("B. Classification of Surgical Wounds – CDC/NRC Classification (3 marks)"))
story.append(sp(4))
wound_class = [
    [Paragraph("Class", sTableH), Paragraph("Type", sTableH), Paragraph("Description", sTableH), Paragraph("Infection Risk", sTableH)],
    [Paragraph("I", sTableBC), Paragraph("Clean", sTableB), Paragraph("Non-inflamed, elective, no GI/GU/respiratory tract opened. Primary closure. E.g., hernia repair, thyroidectomy", sTableB), Paragraph("<2%", sTableBC)],
    [Paragraph("II", sTableBC), Paragraph("Clean-Contaminated", sTableB), Paragraph("Respiratory, GI, GU, biliary tracts opened under controlled conditions with minor spillage. E.g., cholecystectomy", sTableB), Paragraph("2–10%", sTableBC)],
    [Paragraph("III", sTableBC), Paragraph("Contaminated", sTableB), Paragraph("Open fresh accidental wounds, major breaks in sterile technique, gross spillage from GI tract, acute non-purulent inflammation", sTableB), Paragraph("10–20%", sTableBC)],
    [Paragraph("IV", sTableBC), Paragraph("Dirty-Infected", sTableB), Paragraph("Old traumatic wounds with devitalized tissue, existing infection or perforated viscera encountered. Organisms present before surgery", sTableB), Paragraph(">25%", sTableBC)],
]
wt = Table(wound_class, colWidths=[AVAILABLE_WIDTH*x for x in [0.07, 0.20, 0.55, 0.18]])
wt.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), C_DARK),
    ('BACKGROUND', (0,1), (-1,1), C_LGREEN),
    ('BACKGROUND', (0,2), (-1,2), C_LYELLOW),
    ('BACKGROUND', (0,3), (-1,3), C_LORANGE),
    ('BACKGROUND', (0,4), (-1,4), C_LRED),
    ('BOX', (0,0), (-1,-1), 0.5, C_GRAY),
    ('INNERGRID', (0,0), (-1,-1), 0.3, C_GRAY),
    ('PADDING', (0,0), (-1,-1), 5),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
]))
story += [wt, sp(8)]

# Part C – Factors affecting wound healing
story.append(sub_header("C. Factors Affecting Wound Healing (4 marks)"))
story.append(sp(4))

factors_data = [
    [Paragraph("LOCAL FACTORS", sTableH), Paragraph("SYSTEMIC FACTORS", sTableH)],
    [
        Paragraph("• <b>Blood supply:</b> Ischaemia delays healing (arteriosclerosis, pressure sores)<br/>"
                  "• <b>Infection:</b> Bacteria prolong inflammation, destroy granulation tissue<br/>"
                  "• <b>Foreign bodies:</b> Sutures, dead tissue, haematoma act as nidus<br/>"
                  "• <b>Wound size & depth:</b> Larger wounds heal slowly<br/>"
                  "• <b>Radiation:</b> Damages vascularity and fibroblast function<br/>"
                  "• <b>Oedema:</b> Impairs oxygen/nutrient delivery<br/>"
                  "• <b>Denervation:</b> Neurogenic trophic factors are lost", sTableB),
        Paragraph("• <b>Age:</b> Elderly – reduced collagen synthesis, poorer immune response<br/>"
                  "• <b>Nutrition:</b> Protein, Vit C (collagen hydroxylation), Vit A, Zinc deficiency impair healing<br/>"
                  "• <b>Diabetes mellitus:</b> Angiopathy + neuropathy + impaired leucocyte function<br/>"
                  "• <b>Steroids:</b> Inhibit macrophages and collagen synthesis<br/>"
                  "• <b>Cytotoxics/Immunosuppressants:</b> Impair cell proliferation<br/>"
                  "• <b>Anaemia/Hypoxia:</b> Reduced O2 → impaired collagen synthesis<br/>"
                  "• <b>Jaundice/Uraemia:</b> Impair fibroblast function<br/>"
                  "• <b>Smoking:</b> CO causes carboxyhaemoglobinaemia, nicotine causes vasoconstriction", sTableB),
    ]
]
ft = Table(factors_data, colWidths=[AVAILABLE_WIDTH*0.5, AVAILABLE_WIDTH*0.5])
ft.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), C_DARK),
    ('BACKGROUND', (0,1), (0,1), C_LIGHT),
    ('BACKGROUND', (1,1), (1,1), C_LGREEN),
    ('BOX', (0,0), (-1,-1), 0.5, C_GRAY),
    ('INNERGRID', (0,0), (-1,-1), 0.3, C_GRAY),
    ('PADDING', (0,0), (-1,-1), 6),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
]))
story += [ft, PageBreak()]

# ══════════════════════════════════════════════════════════════
# Q2 – BLOOD TRANSFUSION
# ══════════════════════════════════════════════════════════════
story.append(q_header(2, "Blood Transfusion – Donor Criteria, Massive BT & Complications", "2.5+2.5+5", C_GREEN))
story.append(sp(6))

story.append(sub_header("A. Donor Criteria for Blood Transfusion (2.5 marks)", C_GREEN))
story.append(sp(4))
donor = [
    [Paragraph("Parameter", sTableH), Paragraph("Criteria", sTableH)],
    [Paragraph("Age", sTableB), Paragraph("18–65 years (voluntary donation)", sTableB)],
    [Paragraph("Weight", sTableB), Paragraph(">50 kg", sTableB)],
    [Paragraph("Haemoglobin", sTableB), Paragraph("Males ≥13.5 g/dL; Females ≥12.5 g/dL", sTableB)],
    [Paragraph("Blood Pressure", sTableB), Paragraph("Systolic 100–180 mmHg; Diastolic 60–100 mmHg", sTableB)],
    [Paragraph("Pulse", sTableB), Paragraph("60–100 bpm, regular", sTableB)],
    [Paragraph("Temperature", sTableB), Paragraph("Afebrile (<37.5°C)", sTableB)],
    [Paragraph("Donation interval", sTableB), Paragraph("≥3 months from last donation (max 3× per year)", sTableB)],
    [Paragraph("Exclusions", sTableB), Paragraph("HIV, HBsAg+, HCV, malaria, syphilis, jaundice within 12 months, recent surgery, pregnancy, hypertension, diabetes on insulin, malignancy", sTableB)],
]
dt = Table(donor, colWidths=[AVAILABLE_WIDTH*0.28, AVAILABLE_WIDTH*0.72])
dt.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), C_GREEN),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [C_LGREEN, C_WHITE]),
    ('BOX', (0,0), (-1,-1), 0.5, C_GRAY),
    ('INNERGRID', (0,0), (-1,-1), 0.3, C_GRAY),
    ('PADDING', (0,0), (-1,-1), 5),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
]))
story += [dt, sp(8)]

story.append(sub_header("B. Massive Blood Transfusion (2.5 marks)", C_GREEN))
story.append(sp(4))
story.append(info_box("<b>Definition:</b> Transfusion of ≥10 units of packed RBCs within 24 hours (equivalent to one blood volume in an adult), OR replacement of 50% of total blood volume within 3 hours, OR blood loss >150 mL/min.", C_LGREEN, C_GREEN))
story.append(sp(4))
story.append(bold("Indications: Major trauma, ruptured aortic aneurysm, obstetric haemorrhage, massive GI bleed."))
story.append(sp(4))
story.append(body("<b>Damage Control Resuscitation (1:1:1 protocol):</b> Balanced ratio of RBC : FFP : Platelets in 1:1:1 ratio approximating whole blood. Early use of Tranexamic Acid (antifibrinolytic). Monitor with thromboelastometry (TEG/ROTEM)."))
story.append(sp(8))

story.append(sub_header("C. Complications of Blood Transfusion (5 marks)", C_GREEN))
story.append(sp(4))

comp_data = [
    [Paragraph("IMMUNOLOGICAL", sTableH), Paragraph("NON-IMMUNOLOGICAL", sTableH), Paragraph("MASSIVE TRANSFUSION", sTableH)],
    [
        Paragraph("• <b>Acute haemolytic reaction</b> (ABO incompatibility) – fever, rigors, loin pain, haemoglobinuria, renal failure<br/>"
                  "• <b>Delayed haemolytic reaction</b> (3–10 days) – mild jaundice, anaemia<br/>"
                  "• <b>Febrile non-haemolytic</b> – anti-leukocyte antibodies<br/>"
                  "• <b>Allergic/Anaphylactic</b> – IgA deficiency<br/>"
                  "• <b>TRALI</b> (Transfusion-Related Acute Lung Injury) – within 6 hrs, bilateral infiltrates<br/>"
                  "• <b>TA-GvHD</b> – immunocompromised patients<br/>"
                  "• <b>Post-transfusion purpura</b>", sTableB),
        Paragraph("• <b>Infection</b>: Bacterial (faulty storage), Hepatitis B/C, HIV, CMV, Malaria, Syphilis, vCJD<br/>"
                  "• <b>Circulatory overload (TACO)</b> – cardiac failure, pulmonary oedema<br/>"
                  "• <b>Air embolism</b><br/>"
                  "• <b>Thrombophlebitis</b><br/>"
                  "• <b>Iron overload</b> (repeated transfusions – thalassaemia)", sTableB),
        Paragraph("• <b>Coagulopathy</b> – dilutional, DIC<br/>"
                  "• <b>Hypocalcaemia</b> – citrate toxicity → tetany, arrhythmias<br/>"
                  "• <b>Hyperkalaemia</b> – stored blood releases K+<br/>"
                  "• <b>Hypothermia</b> – cold stored blood<br/>"
                  "• <b>Metabolic alkalosis</b> (citrate→bicarbonate)<br/>"
                  "• <b>2,3-DPG depletion</b> – left shift of Hb–O2 curve", sTableB),
    ]
]
ct = Table(comp_data, colWidths=[AVAILABLE_WIDTH/3]*3)
ct.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), C_GREEN),
    ('BACKGROUND', (0,1), (0,1), C_LIGHT),
    ('BACKGROUND', (1,1), (1,1), C_LYELLOW),
    ('BACKGROUND', (2,1), (2,1), C_LRED),
    ('BOX', (0,0), (-1,-1), 0.5, C_GRAY),
    ('INNERGRID', (0,0), (-1,-1), 0.3, C_GRAY),
    ('PADDING', (0,0), (-1,-1), 5),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
]))
story += [ct, PageBreak()]

# ══════════════════════════════════════════════════════════════
# Q3 – SSI
# ══════════════════════════════════════════════════════════════
story.append(q_header(3, "Surgical Site Infection (SSI)", "1+1+3+3+2", C_ORANGE))
story.append(sp(6))

story.append(sub_header("A. What is SSI? (1 mark)", C_ORANGE))
story.append(sp(4))
story.append(info_box("<b>SSI (Surgical Site Infection)</b> is defined by the CDC as infection occurring within <b>30 days</b> after the operative procedure (or within <b>90 days</b> if an implant is placed) AND involves skin, subcutaneous tissue, fascia, muscle, or organ/space manipulated during surgery.", C_LORANGE, C_ORANGE))
story.append(sp(6))

story.append(sub_header("B. Organisms Causing SSI (1 mark)", C_ORANGE))
story.append(sp(4))
story.append(body("<b>Most common:</b> Staphylococcus aureus (incl. MRSA) – ~30%. Others: Coagulase-negative Staphylococci, Enterococcus spp., E. coli, Pseudomonas aeruginosa, Klebsiella spp. (GNBs important in abdominal surgery), Candida spp. (immunocompromised)."))
story.append(sp(6))

story.append(sub_header("C. Classification of SSI – CDC/NHSN (3 marks)", C_ORANGE))
story.append(sp(4))

ssi_fc = ClassificationDiagram(
    root="SURGICAL SITE INFECTION (SSI)",
    branches=[
        ("Superficial\nIncisional", ["Skin only", "Subcut tissue", "Within 30 days"], C_ORANGE),
        ("Deep\nIncisional", ["Fascia", "Muscle layers", "Within 30/90 days"], C_RED),
        ("Organ /\nSpace", ["Any organ opened", "Cavity entered", "E.g., abscess"], C_PURPLE),
    ],
    width=AVAILABLE_WIDTH,
    height=160
)
story += [ssi_fc, sp(4)]

ssi_class = [
    [Paragraph("Type", sTableH), Paragraph("Structures Involved", sTableH), Paragraph("Criteria", sTableH)],
    [Paragraph("Superficial Incisional", sTableB), Paragraph("Skin & subcutaneous tissue only", sTableB), Paragraph("Purulent drainage, organisms from superficial incision, or surgeon deliberately opens wound. Dx within 30 days.", sTableB)],
    [Paragraph("Deep Incisional", sTableB), Paragraph("Deep soft tissue – fascia & muscle layers", sTableB), Paragraph("Purulent drainage from depth, spontaneous dehiscence/surgeon opens incision when patient has fever >38°C, tenderness, or localised pain. Within 30/90 days.", sTableB)],
    [Paragraph("Organ/Space", sTableB), Paragraph("Any organ or space opened during surgery (e.g., peritoneal cavity, pleura, bladder)", sTableB), Paragraph("Purulent drainage via drain, organisms from culture of organ/space, abscess found on reoperation or imaging.", sTableB)],
]
ssi_t = Table(ssi_class, colWidths=[AVAILABLE_WIDTH*x for x in [0.25, 0.30, 0.45]])
ssi_t.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), C_ORANGE),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [C_LORANGE, C_LRED, C_LPURPLE]),
    ('BOX', (0,0), (-1,-1), 0.5, C_GRAY),
    ('INNERGRID', (0,0), (-1,-1), 0.3, C_GRAY),
    ('PADDING', (0,0), (-1,-1), 5),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
]))
story += [ssi_t, sp(8)]

story.append(sub_header("D. Prevention of SSI (3 marks)", C_ORANGE))
story.append(sp(4))

prev_data = [
    [Paragraph("PREOPERATIVE", sTableH), Paragraph("INTRAOPERATIVE", sTableH), Paragraph("POSTOPERATIVE", sTableH)],
    [
        Paragraph("• Treat remote infections before elective surgery<br/>"
                  "• Antiseptic shower night before<br/>"
                  "• Nasal decolonisation (MRSA – mupirocin)<br/>"
                  "• Clip (not shave) hair; do it immediately pre-op<br/>"
                  "• Preoperative antibiotic prophylaxis (within 60 min of incision)<br/>"
                  "• Optimise: glucose, nutrition, smoking cessation, immunosuppressant dose", sTableB),
        Paragraph("• Maintain normothermia (forced-air warming)<br/>"
                  "• Maintain normoglycaemia (<200 mg/dL)<br/>"
                  "• Adequate skin prep (chlorhexidine-alcohol > povidone-iodine)<br/>"
                  "• Minimize contamination; avoid dead space<br/>"
                  "• Use appropriate suture material<br/>"
                  "• Limit re-dosing of antibiotics (>2× half-life)<br/>"
                  "• Maintain tissue perfusion and oxygenation", sTableB),
        Paragraph("• Wound care – sterile dressings for 24–48 hrs<br/>"
                  "• No antibiotic beyond 24 hrs prophylaxis<br/>"
                  "• Surveillance and early recognition<br/>"
                  "• Hyperglycaemia control in ICU<br/>"
                  "• Avoid unnecessary drain use", sTableB),
    ]
]
prev_t = Table(prev_data, colWidths=[AVAILABLE_WIDTH/3]*3)
prev_t.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), C_ORANGE),
    ('BACKGROUND', (0,1), (0,1), C_LYELLOW),
    ('BACKGROUND', (1,1), (1,1), C_LIGHT),
    ('BACKGROUND', (2,1), (2,1), C_LGREEN),
    ('BOX', (0,0), (-1,-1), 0.5, C_GRAY),
    ('INNERGRID', (0,0), (-1,-1), 0.3, C_GRAY),
    ('PADDING', (0,0), (-1,-1), 5),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
]))
story += [prev_t, sp(8)]

story.append(sub_header("E. Management of SSI (2 marks)", C_ORANGE))
story.append(sp(4))
mgmt_fc = BoxArrowChart([
    ("Suspect SSI: Fever, wound pain, erythema, discharge", C_ORANGE, C_WHITE),
    ("Open & drain wound (superficial) / Formal incision & drainage", C_RED, C_WHITE),
    ("Wound swab for C/S – debride necrotic tissue", C_MED, C_WHITE),
    ("Start empirical antibiotics; modify per sensitivity", C_GREEN, C_WHITE),
    ("Wound care: regular dressing / VAC therapy for deep SSI", C_PURPLE, C_WHITE),
    ("Re-suture when clean (delayed primary closure)", C_DARK, C_WHITE),
], width=AVAILABLE_WIDTH, box_height=24, spacing=14)
story += [mgmt_fc, PageBreak()]

# ══════════════════════════════════════════════════════════════
# Q4 – SHOCK
# ══════════════════════════════════════════════════════════════
story.append(q_header(4, "Shock – Types, Pathophysiology & Management of Septic Shock", "1+2+3+4", C_RED))
story.append(sp(6))

story.append(sub_header("A. Definition of Shock (1 mark)", C_RED))
story.append(sp(4))
story.append(info_box("<b>Shock</b> is a life-threatening, generalised form of acute circulatory failure associated with inadequate oxygen utilisation by the cells, resulting in cellular dysfunction and, if untreated, multi-organ failure and death.", C_LRED, C_RED))
story.append(sp(6))

story.append(sub_header("B. Types of Shock (2 marks)", C_RED))
story.append(sp(4))

shock_types = [
    [Paragraph("Type", sTableH), Paragraph("Mechanism", sTableH), Paragraph("Examples", sTableH), Paragraph("CO", sTableH), Paragraph("SVR", sTableH)],
    [Paragraph("Hypovolaemic", sTableB), Paragraph("↓ Circulating volume → ↓ preload", sTableB), Paragraph("Haemorrhage, burns, vomiting/diarrhoea", sTableB), Paragraph("↓", sTableBC), Paragraph("↑", sTableBC)],
    [Paragraph("Cardiogenic", sTableB), Paragraph("Pump failure → ↓ CO despite adequate volume", sTableB), Paragraph("MI, cardiac tamponade, tension pneumothorax", sTableB), Paragraph("↓↓", sTableBC), Paragraph("↑↑", sTableBC)],
    [Paragraph("Distributive", sTableB), Paragraph("Peripheral vasodilation → maldistribution of flow", sTableB), Paragraph("Septic, anaphylactic, neurogenic, toxic shock", sTableB), Paragraph("↑", sTableBC), Paragraph("↓↓", sTableBC)],
    [Paragraph("Obstructive", sTableB), Paragraph("Mechanical obstruction of blood flow", sTableB), Paragraph("Massive PE, cardiac tamponade, tension pneumothorax", sTableB), Paragraph("↓", sTableBC), Paragraph("↑", sTableBC)],
]
st2 = Table(shock_types, colWidths=[AVAILABLE_WIDTH*x for x in [0.18, 0.30, 0.33, 0.09, 0.10]])
st2.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), C_RED),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [C_LRED, C_LORANGE, C_LIGHT, C_LPURPLE]),
    ('BOX', (0,0), (-1,-1), 0.5, C_GRAY),
    ('INNERGRID', (0,0), (-1,-1), 0.3, C_GRAY),
    ('PADDING', (0,0), (-1,-1), 5),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
]))
story += [st2, sp(8)]

story.append(sub_header("C. Pathophysiology of Septic Shock (3 marks)", C_RED))
story.append(sp(4))

patho_fc = BoxArrowChart([
    ("Infective focus: Gram-negative LPS / Gram-positive peptidoglycan", C_DARK, C_WHITE),
    ("Pattern Recognition Receptors (TLR4) on Macrophages/Monocytes activated", C_MED, C_WHITE),
    ("Release of pro-inflammatory cytokines: TNF-α, IL-1, IL-6, IL-8", C_ORANGE, C_WHITE),
    ("↑ NO production (iNOS) → profound vasodilation → ↓ SVR (warm shock)", C_RED, C_WHITE),
    ("↑ Vascular permeability → fluid extravasation → hypovolaemia", C_RED, C_WHITE),
    ("Endothelial injury → DIC → microvascular thrombosis → organ ischaemia", C_PURPLE, C_WHITE),
    ("Mitochondrial dysfunction → cytopathic hypoxia → MODS", C_DARK, C_WHITE),
], width=AVAILABLE_WIDTH, box_height=24, spacing=12)
story += [patho_fc, sp(8)]

story.append(sub_header("D. Management of Septic Shock – Surviving Sepsis Campaign Bundle (4 marks)", C_RED))
story.append(sp(4))

story.append(note("Hour-1 Bundle (Surviving Sepsis Campaign 2021): Must complete within 1 hour of recognition"))
story.append(sp(4))

mgmt_septic = BoxArrowChart([
    ("RECOGNITION: Sepsis-3 Criteria – Suspected infection + SOFA score ≥2 + Septic shock: MAP <65 + Lactate >2 despite fluids", C_RED, C_WHITE),
    ("1. Blood cultures (≥2 sets) BEFORE antibiotics | Measure serum lactate", C_MED, C_WHITE),
    ("2. IV antibiotics within 1 hour (broad spectrum – Piperacillin-Tazobactam / Meropenem ± Vancomycin)", C_ORANGE, C_WHITE),
    ("3. 30 mL/kg IV crystalloid (0.9% NaCl or Ringer's Lactate) within 3 hours", C_GREEN, C_WHITE),
    ("4. Vasopressors if MAP <65 after fluids: NOREPINEPHRINE 1st choice (target MAP ≥65)", C_RED, C_WHITE),
    ("5. Hydrocortisone 200 mg/day IV if refractory to vasopressors", C_PURPLE, C_WHITE),
    ("6. Source Control: Drain abscess, remove infected device within 6–12 hours", C_DARK, C_WHITE),
    ("ICU CARE: Ventilatory support, glycaemic control <180 mg/dL, DVT prophylaxis, early enteral nutrition", C_MED, C_WHITE),
], width=AVAILABLE_WIDTH, box_height=24, spacing=12)
story += [mgmt_septic, PageBreak()]

# ══════════════════════════════════════════════════════════════
# Q5 – BURNS (Medicolegal + Management)
# ══════════════════════════════════════════════════════════════
story.append(q_header(5, "25% Burns in Young Woman – Medicolegal & Management", "2+2+6", C_PURPLE))
story.append(sp(6))
story.append(info_box("Clinical scenario: 25-year-old woman, 25% burns, conscious, claims self-infliction with kerosene oil, requests no case be filed against husband.", C_LPURPLE, C_PURPLE))
story.append(sp(4))

story.append(sub_header("a. Will You Inform the Police? (2 marks)", C_PURPLE))
story.append(sp(4))
story.append(info_box("<b>YES – Mandatory Reporting is legally obligatory in India.</b><br/><br/>"
    "Under the <b>BNSS (Bharatiya Nagarik Suraksha Sanhita) 2023 / CrPC Section 39</b>, every person (especially a medical professional) who acquires knowledge of an offence is obliged to inform the nearest magistrate or police officer.<br/><br/>"
    "Under <b>MCI/NMC Code of Ethics</b>, a doctor must inform the police of injuries that may involve criminal assault, even if the patient requests confidentiality.<br/><br/>"
    "<b>Reasons:</b><br/>"
    "• The history is inconsistent – self-inflicted burns with kerosene in a newlywed woman is a classic pattern of dowry violence (bride burning).<br/>"
    "• The patient may be under duress or coercion.<br/>"
    "• Consent of the victim does NOT override legal reporting obligation in a potential cognisable offence.<br/>"
    "• Failure to report is itself an offence under law.", C_LPURPLE, C_PURPLE))
story.append(sp(6))

story.append(sub_header("b. If Police Cannot Come on Time – Treat or Wait? (2 marks)", C_PURPLE))
story.append(sp(4))
story.append(info_box("<b>START TREATMENT IMMEDIATELY – Do NOT delay treatment.</b><br/><br/>"
    "• The patient is a medical emergency. A 25% burn is life-threatening and every minute's delay worsens prognosis.<br/>"
    "• <b>Right to Emergency Care</b> supersedes medicolegal formalities.<br/>"
    "• Document everything thoroughly in writing (time, condition, history as narrated by patient).<br/>"
    "• Inform police in writing (via MLC – Medico-Legal Case form) but commence treatment simultaneously.<br/>"
    "• Record wounds with diagrams/photographs for forensic documentation.", C_LPURPLE, C_PURPLE))
story.append(sp(6))

story.append(sub_header("c. Management of 25% Burns (6 marks)", C_PURPLE))
story.append(sp(4))

story.append(bold("STEP 1 – INITIAL ASSESSMENT (ATLS Primary Survey)"))
story.append(sp(2))
story.append(body("Airway (singed nasal hairs, hoarse voice, facial burns → intubate early), Breathing (exclude inhalation injury, CO poisoning), Circulation (IV access, fluid resuscitation), Disability, Exposure (estimate burn area, depth, strip clothing)."))
story.append(sp(4))

story.append(bold("STEP 2 – ESTIMATE BURN AREA (Rule of Nines)"))
story.append(sp(4))

rule9_data = [
    [Paragraph("Region", sTableH), Paragraph("Adult %", sTableH)],
    [Paragraph("Head & Neck", sTableBC), Paragraph("9%", sTableBC)],
    [Paragraph("Each Upper Limb", sTableBC), Paragraph("9% (×2=18%)", sTableBC)],
    [Paragraph("Anterior Trunk", sTableBC), Paragraph("18%", sTableBC)],
    [Paragraph("Posterior Trunk", sTableBC), Paragraph("18%", sTableBC)],
    [Paragraph("Each Lower Limb", sTableBC), Paragraph("18% (×2=36%)", sTableBC)],
    [Paragraph("Perineum", sTableBC), Paragraph("1%", sTableBC)],
    [Paragraph("TOTAL", sTableBC), Paragraph("100%", sTableBC)],
]
r9t = Table(rule9_data, colWidths=[AVAILABLE_WIDTH*0.5, AVAILABLE_WIDTH*0.5])
r9t.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), C_PURPLE),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [C_LPURPLE, C_WHITE]),
    ('BACKGROUND', (0,-1), (-1,-1), C_DARK),
    ('TEXTCOLOR', (0,-1), (-1,-1), C_WHITE),
    ('FONTNAME', (0,-1), (-1,-1), 'Helvetica-Bold'),
    ('BOX', (0,0), (-1,-1), 0.5, C_GRAY),
    ('INNERGRID', (0,0), (-1,-1), 0.3, C_GRAY),
    ('PADDING', (0,0), (-1,-1), 5),
    ('ALIGN', (0,0), (-1,-1), 'CENTER'),
]))
story += [r9t, sp(6)]

story.append(bold("STEP 3 – DEPTH CLASSIFICATION"))
story.append(sp(4))
depth_data = [
    [Paragraph("Degree", sTableH), Paragraph("Depth", sTableH), Paragraph("Features", sTableH), Paragraph("Healing", sTableH)],
    [Paragraph("1st (Superficial)", sTableBC), Paragraph("Epidermis only", sTableB), Paragraph("Erythema, pain, no blisters, dry. E.g., sunburn", sTableB), Paragraph("7–10 days, no scar", sTableBC)],
    [Paragraph("2nd Superficial\n(Partial thickness)", sTableBC), Paragraph("Papillary dermis", sTableB), Paragraph("Blisters, moist, painful, blanches on pressure", sTableB), Paragraph("14–21 days, minimal scar", sTableBC)],
    [Paragraph("2nd Deep\n(Partial thickness)", sTableBC), Paragraph("Reticular dermis", sTableB), Paragraph("Fixed staining, less pain, does not blanch", sTableB), Paragraph(">21 days, scarring likely, may need grafting", sTableBC)],
    [Paragraph("3rd (Full thickness)", sTableBC), Paragraph("Full dermis + subcut", sTableB), Paragraph("Leathery/waxy white or charred, painless, dry, no blisters", sTableB), Paragraph("No spontaneous healing → needs grafting", sTableBC)],
]
dd = Table(depth_data, colWidths=[AVAILABLE_WIDTH*x for x in [0.18, 0.17, 0.40, 0.25]])
dd.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), C_PURPLE),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [C_LYELLOW, C_LORANGE, C_LRED, C_LGRAY]),
    ('BOX', (0,0), (-1,-1), 0.5, C_GRAY),
    ('INNERGRID', (0,0), (-1,-1), 0.3, C_GRAY),
    ('PADDING', (0,0), (-1,-1), 5),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
]))
story += [dd, sp(6)]

story.append(bold("STEP 4 – FLUID RESUSCITATION (Parkland Formula)"))
story.append(sp(2))
story.append(info_box("<b>Parkland Formula:</b>  Total fluid in 24 h = 4 mL × weight(kg) × %TBSA burn<br/>"
    "For this patient (assume 55 kg): 4 × 55 × 25 = <b>5500 mL Ringer's Lactate</b><br/>"
    "• Give <b>½ in first 8 hours</b> (from time of injury, not arrival)<br/>"
    "• Give <b>½ in next 16 hours</b><br/>"
    "• Monitor urine output: Target 0.5–1 mL/kg/hr<br/>"
    "• Children: Muir–Barclay formula preferred", C_LPURPLE, C_PURPLE))
story.append(sp(4))

story.append(bold("OTHER MANAGEMENT:"))
story.append(sp(2))
for item in [
    "IV morphine analgesia; anti-tetanus prophylaxis",
    "Catheterize – strict I/O monitoring",
    "NPO if inhalation injury – NG tube for enteral feeding",
    "Cool the burn with cool (not cold) running water for 20 minutes within 3 hours of injury (remove kerosene contamination first)",
    "Do NOT apply toothpaste, butter, or traditional remedies",
    "Antiseptic dressings: Silver sulfadiazine (SSD) 1% cream or Mafenide acetate",
    "Escharotomy if circumferential deep burn → compartment syndrome",
    "Surgical: Split-thickness skin grafting (STSG) for deep partial/full thickness burns once patient stabilised",
    "Psychological support; social worker involvement given medicolegal background",
    "ICU admission for large burns / inhalation injury",
]:
    story.append(bullet(item))
story.append(PageBreak())

# ══════════════════════════════════════════════════════════════
# Q6 – SHORT NOTES
# ══════════════════════════════════════════════════════════════
story.append(q_header(6, "Short Notes (4 × 5 = 20 marks)", "20", C_MED))
story.append(sp(6))

# 6a – Refeeding Syndrome
story.append(sub_header("a. Refeeding Syndrome", C_MED))
story.append(sp(4))
story.append(info_box("<b>Definition:</b> Potentially life-threatening electrolyte and fluid shifts occurring when nutrition (particularly carbohydrates) is reintroduced to severely malnourished patients after a period of starvation.", C_LIGHT, C_MED))
story.append(sp(4))

rf_flow = BoxArrowChart([
    ("Starvation → Depletion of intracellular electrolytes (PO4, Mg, K) but normal serum levels", C_MED, C_WHITE),
    ("Refeeding → Carbohydrate intake → ↑ Insulin → Cellular uptake of glucose, PO4, Mg, K", C_ORANGE, C_WHITE),
    ("Hypophosphataemia (<0.5 mmol/L) = HALLMARK – causes ATP/2,3-DPG depletion", C_RED, C_WHITE),
    ("Respiratory failure, Cardiac arrhythmias, Neurological (seizures, Wernicke's), Rhabdomyolysis", C_DARK, C_WHITE),
], width=AVAILABLE_WIDTH, box_height=24, spacing=12)
story += [rf_flow, sp(4)]

rf_table = [
    [Paragraph("Risk Factors", sTableH), Paragraph("Key Electrolyte Changes", sTableH), Paragraph("Prevention/Management", sTableH)],
    [
        Paragraph("• BMI <16, >10% weight loss in 2 months<br/>"
                  "• Chronic alcoholism, anorexia nervosa<br/>"
                  "• Prolonged fasting (>5 days)<br/>"
                  "• Malabsorption, post-bariatric surgery", sTableB),
        Paragraph("• <b>Hypophosphataemia</b> (hallmark)<br/>"
                  "• Hypokalaemia<br/>"
                  "• Hypomagnesaemia<br/>"
                  "• Sodium/water retention<br/>"
                  "• Thiamine deficiency", sTableB),
        Paragraph("• NICE guidelines: Start at 10 kcal/kg/day, increase over 4–7 days<br/>"
                  "• Give IV thiamine (Pabrinex) BEFORE feeding<br/>"
                  "• Supplement PO4, K, Mg before and during refeeding<br/>"
                  "• Restrict sodium; monitor fluid balance<br/>"
                  "• Monitor ECG, electrolytes daily", sTableB),
    ]
]
rft = Table(rf_table, colWidths=[AVAILABLE_WIDTH/3]*3)
rft.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), C_MED),
    ('BACKGROUND', (0,1), (0,1), C_LRED),
    ('BACKGROUND', (1,1), (1,1), C_LORANGE),
    ('BACKGROUND', (2,1), (2,1), C_LGREEN),
    ('BOX', (0,0), (-1,-1), 0.5, C_GRAY),
    ('INNERGRID', (0,0), (-1,-1), 0.3, C_GRAY),
    ('PADDING', (0,0), (-1,-1), 5),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
]))
story += [rft, sp(8)]

# 6b – TPN
story.append(sub_header("b. Total Parenteral Nutrition (TPN)", C_MED))
story.append(sp(4))
story.append(info_box("<b>TPN:</b> Intravenous provision of complete nutritional requirements (carbohydrates, proteins, lipids, vitamins, trace elements) via a central venous catheter when the enteral route is unavailable or inadequate.", C_LIGHT, C_MED))
story.append(sp(4))

tpn_data = [
    [Paragraph("Component", sTableH), Paragraph("Source", sTableH), Paragraph("Requirements (70 kg)", sTableH)],
    [Paragraph("Carbohydrate", sTableBC), Paragraph("Dextrose (20–50%)", sTableB), Paragraph("50–60% of non-protein calories; 3–5 g/kg/day", sTableB)],
    [Paragraph("Protein", sTableBC), Paragraph("Crystalline amino acids", sTableB), Paragraph("1–1.5 g/kg/day (higher in catabolic states 1.5–2 g/kg/day)", sTableB)],
    [Paragraph("Lipids", sTableBC), Paragraph("Soybean/olive oil emulsion", sTableB), Paragraph("30–40% of non-protein calories; 1–1.5 g/kg/day", sTableB)],
    [Paragraph("Electrolytes", sTableBC), Paragraph("Na, K, Ca, Mg, Phosphate, Chloride, Acetate", sTableB), Paragraph("As per daily requirements and serum levels", sTableB)],
    [Paragraph("Vitamins", sTableBC), Paragraph("MVI (multiple vitamin infusion)", sTableB), Paragraph("Daily multi-vitamin, Vit K weekly", sTableB)],
    [Paragraph("Trace elements", sTableBC), Paragraph("Zinc, Copper, Selenium, Manganese, Chromium", sTableB), Paragraph("Daily infusion; zinc higher in GI losses", sTableB)],
]
tpnt = Table(tpn_data, colWidths=[AVAILABLE_WIDTH*x for x in [0.18, 0.30, 0.52]])
tpnt.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), C_MED),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [C_LIGHT, C_WHITE]),
    ('BOX', (0,0), (-1,-1), 0.5, C_GRAY),
    ('INNERGRID', (0,0), (-1,-1), 0.3, C_GRAY),
    ('PADDING', (0,0), (-1,-1), 5),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
]))
story += [tpnt, sp(4)]

story.append(bold("Indications for TPN:"))
for ind in ["Short bowel syndrome (SBS), high-output fistulas", "Ileus, intestinal obstruction, Crohn's disease with failure", "Severe pancreatitis when enteral feeding not tolerated", "Post-operative major GI surgery when gut not functional >5–7 days", "Bone marrow transplantation / intensive chemotherapy"]:
    story.append(bullet(ind))
story.append(sp(4))
story.append(bold("Complications of TPN:"))
story.append(body("<b>Catheter-related:</b> Pneumothorax, arterial injury, air embolism (at insertion); CLABSI (central line-associated bloodstream infection), thrombosis (long-term)."))
story.append(body("<b>Metabolic:</b> Hyperglycaemia (most common), refeeding syndrome, hypoglycaemia (abrupt cessation), hepatic steatosis/cholestasis (IFALD), electrolyte abnormalities."))
story.append(sp(8))

# 6c – Abdominal Compartment Syndrome
story.append(sub_header("c. Abdominal Compartment Syndrome (ACS)", C_MED))
story.append(sp(4))
story.append(info_box("<b>Definition (WSACS):</b> Sustained intra-abdominal pressure (IAP) >20 mmHg with new organ dysfunction/failure. Normal IAP = 0–5 mmHg. Intra-abdominal hypertension (IAH) = IAP ≥12 mmHg.", C_LIGHT, C_MED))
story.append(sp(4))

acs_fc = BoxArrowChart([
    ("Precipitating Cause: Massive fluid resuscitation (burns/trauma), Ileus, Ascites, Abdominal packing", C_DARK, C_WHITE),
    ("↑ Intra-abdominal Pressure (IAP >20 mmHg)", C_RED, C_WHITE),
    ("Compression of IVC → ↓ Venous return → ↓ CO | Compression of diaphragm → ↑ Airway pressures, ↓ FRC", C_ORANGE, C_WHITE),
    ("Renal vein compression → Oliguria/ARF | Mesenteric ischaemia → Gut mucosal barrier failure", C_RED, C_WHITE),
    ("Treatment: Decompressive Laparotomy + Temporary Abdominal Closure (TAC/Bogota bag)", C_GREEN, C_WHITE),
], width=AVAILABLE_WIDTH, box_height=24, spacing=12)
story += [acs_fc, sp(4)]

story.append(body("<b>Measurement:</b> Bladder pressure (indirect IAP measurement) via urinary catheter – instil 25 mL NS, measure with manometer. Measured at end-expiration, supine position."))
story.append(sp(8))

# 6d – Buerger's Disease
story.append(sub_header("d. Buerger's Disease (Thromboangiitis Obliterans)", C_MED))
story.append(sp(4))
story.append(body("<b>Definition:</b> Segmental, occlusive, inflammatory thrombotic disease of small and medium arteries and veins of the extremities, occurring exclusively in smokers."))
story.append(sp(4))

buerger_data = [
    [Paragraph("Feature", sTableH), Paragraph("Details", sTableH)],
    [Paragraph("Epidemiology", sTableB), Paragraph("Young males (20–45 yrs); strong association with heavy tobacco use; prevalent in Asia, Middle East", sTableB)],
    [Paragraph("Pathology", sTableB), Paragraph("Highly cellular, inflammatory thrombus with intact vessel wall (no atherosclerosis); all three layers inflamed; microabscesses with giant cells", sTableB)],
    [Paragraph("Clinical Features", sTableB), Paragraph("Claudication of feet/arch; rest pain; Raynaud's phenomenon; superficial thrombophlebitis (migratory); digital ulcers/gangrene; positive Allen's test", sTableB)],
    [Paragraph("Diagnosis", sTableB), Paragraph("Angiography: corkscrew collaterals ('tree root' appearance), segmental occlusions; Duplex ultrasound; Biopsy of thrombosed vein", sTableB)],
    [Paragraph("Shionoya Criteria", sTableB), Paragraph("(1) Smoking history; (2) Onset <50 yrs; (3) Infrapopliteal/infrabrachial involvement; (4) Superficial phlebitis; (5) Absent atherosclerosis risk factors", sTableB)],
    [Paragraph("Treatment", sTableB), Paragraph("1st: COMPLETE CESSATION OF SMOKING (only definitive treatment)<br/>Vasodilators: Iloprost IV (prostacyclin analogue) – best for rest pain/ulcers<br/>Calcium channel blockers (Nifedipine) for Raynaud's<br/>Sympathectomy for vasospasm relief<br/>Amputation as last resort for gangrene", sTableB)],
]
bdt = Table(buerger_data, colWidths=[AVAILABLE_WIDTH*0.22, AVAILABLE_WIDTH*0.78])
bdt.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), C_MED),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [C_LIGHT, C_WHITE]),
    ('BOX', (0,0), (-1,-1), 0.5, C_GRAY),
    ('INNERGRID', (0,0), (-1,-1), 0.3, C_GRAY),
    ('PADDING', (0,0), (-1,-1), 5),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
]))
story += [bdt, sp(8)]

# 6e – Phylloides Tumour
story.append(sub_header("e. Phyllodes Tumour (Cystosarcoma Phyllodes)", C_MED))
story.append(sp(4))
story.append(info_box("<b>Definition:</b> A fibroepithelial tumour of the breast arising from periductal stroma, characterised by a leaf-like (phyllodes = leaf) pattern on histology. Represents <1% of all breast tumours.", C_LIGHT, C_MED))
story.append(sp(4))

phyll_data = [
    [Paragraph("Feature", sTableH), Paragraph("Benign (60–70%)", sTableH), Paragraph("Borderline (15%)", sTableH), Paragraph("Malignant (15–20%)", sTableH)],
    [Paragraph("Stromal cellularity", sTableB), Paragraph("Mild", sTableBC), Paragraph("Moderate", sTableBC), Paragraph("Marked", sTableBC)],
    [Paragraph("Mitotic rate", sTableB), Paragraph("<5/10HPF", sTableBC), Paragraph("5–9/10HPF", sTableBC), Paragraph("≥10/10HPF", sTableBC)],
    [Paragraph("Margins", sTableB), Paragraph("Well-defined", sTableBC), Paragraph("Infiltrating", sTableBC), Paragraph("Infiltrating", sTableBC)],
    [Paragraph("Metastasis", sTableB), Paragraph("None", sTableBC), Paragraph("Rare", sTableBC), Paragraph("Haematogenous (lungs, bone)", sTableBC)],
    [Paragraph("Treatment", sTableB), Paragraph("Wide local excision (≥1 cm margin)", sTableBC), Paragraph("Wide local excision", sTableBC), Paragraph("Simple mastectomy (no routine axillary dissection)", sTableBC)],
]
phyt = Table(phyll_data, colWidths=[AVAILABLE_WIDTH*x for x in [0.22, 0.22, 0.22, 0.34]])
phyt.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), C_MED),
    ('BACKGROUND', (0,1), (0,-1), C_LGRAY),
    ('BACKGROUND', (1,1), (1,-1), C_LGREEN),
    ('BACKGROUND', (2,1), (2,-1), C_LYELLOW),
    ('BACKGROUND', (3,1), (3,-1), C_LRED),
    ('BOX', (0,0), (-1,-1), 0.5, C_GRAY),
    ('INNERGRID', (0,0), (-1,-1), 0.3, C_GRAY),
    ('PADDING', (0,0), (-1,-1), 5),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
]))
story += [phyt, sp(4)]
story.append(body("<b>Clinical Features:</b> Middle-aged women (35–55 yrs). Rapidly enlarging breast lump, skin stretched but not fixed, prominent surface veins. FNA unreliable – core needle biopsy preferred. Recurrence after simple excision is common (20–25%)."))
story.append(PageBreak())

# ══════════════════════════════════════════════════════════════
# Q7 – THYROID CARCINOMA
# ══════════════════════════════════════════════════════════════
story.append(q_header(7, "Thyroid Carcinoma – Classification, Papillary Ca Features & Management", "2+1+2+5", colors.HexColor('#117a65')))
story.append(sp(6))

story.append(sub_header("A. Classification of Thyroid Carcinoma (2 marks)", colors.HexColor('#117a65')))
story.append(sp(4))

tc_class = ClassificationDiagram(
    root="THYROID CARCINOMA",
    branches=[
        ("Differentiated\n(90%)", ["Papillary (80%)", "Follicular (10%)"], colors.HexColor('#2e86c1')),
        ("Poorly Diff.", ["Anaplastic\n(5%)", "Undiff."], colors.HexColor('#c0392b')),
        ("Parafollicular", ["Medullary\n(2.5%)", "Sporadic/MEN2"], colors.HexColor('#8e44ad')),
        ("Other", ["Lymphoma\n(2.5%)", "Secondary/Mets"], colors.HexColor('#117a65')),
    ],
    width=AVAILABLE_WIDTH,
    height=180
)
story += [tc_class, sp(4)]

tc_table = [
    [Paragraph("Type", sTableH), Paragraph("Origin", sTableH), Paragraph("Incidence", sTableH), Paragraph("Spread", sTableH), Paragraph("Prognosis", sTableH)],
    [Paragraph("Papillary", sTableB), Paragraph("Follicular cells", sTableB), Paragraph("80%", sTableBC), Paragraph("Lymphatic (neck nodes)", sTableB), Paragraph("Excellent (20-yr survival >90%)", sTableB)],
    [Paragraph("Follicular", sTableB), Paragraph("Follicular cells", sTableB), Paragraph("10%", sTableBC), Paragraph("Haematogenous (lung, bone)", sTableB), Paragraph("Good if intrathyroidal", sTableB)],
    [Paragraph("Medullary", sTableB), Paragraph("Parafollicular C cells (calcitonin)", sTableB), Paragraph("2.5%", sTableBC), Paragraph("Both lymph + haematogenous", sTableB), Paragraph("Intermediate", sTableB)],
    [Paragraph("Anaplastic", sTableB), Paragraph("Follicular cells (de-diff.)", sTableB), Paragraph("5%", sTableBC), Paragraph("Direct invasion + early mets", sTableB), Paragraph("Very poor (<6 months)", sTableB)],
]
tct = Table(tc_table, colWidths=[AVAILABLE_WIDTH*x for x in [0.16, 0.22, 0.13, 0.26, 0.23]])
tct.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), colors.HexColor('#117a65')),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [C_LIGHT, C_LGREEN, C_LPURPLE, C_LRED]),
    ('BOX', (0,0), (-1,-1), 0.5, C_GRAY),
    ('INNERGRID', (0,0), (-1,-1), 0.3, C_GRAY),
    ('PADDING', (0,0), (-1,-1), 5),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
]))
story += [tct, sp(8)]

story.append(sub_header("B. Clinical Features of Papillary Thyroid Carcinoma (1 mark)", colors.HexColor('#117a65')))
story.append(sp(4))
for feat in [
    "Most common thyroid malignancy; Peak 30–50 yrs; F:M = 3:1",
    "Presents as a painless, firm, solitary thyroid nodule – or as a 'cold nodule' on scan",
    "50% have regional lymph node metastasis at presentation (but prognosis still excellent)",
    "Distant metastasis rare (lung, bone)",
    "Dysphagia, hoarseness (RLN involvement) in advanced cases",
    "Multifocal in up to 80% of cases",
    "Associated with radiation exposure (neck radiation in childhood); MEN2A rarely"
]:
    story.append(bullet(feat))
story.append(sp(6))

story.append(sub_header("C. Histopathology of Papillary Thyroid Carcinoma (2 marks)", colors.HexColor('#117a65')))
story.append(sp(4))
story.append(info_box("<b>Macroscopy:</b> Usually unencapsulated, infiltrative, firm, whitish-grey cut surface. May be cystic.<br/><br/>"
    "<b>Microscopy (Key Features):</b><br/>"
    "• <b>'Orphan Annie eye' nuclei</b> – large, clear, ground-glass nuclei with central clearing (pathognomonic)<br/>"
    "• <b>Nuclear grooves and pseudo-inclusions</b> (intranuclear cytoplasmic inclusions)<br/>"
    "• <b>Psammoma bodies</b> – calcified, laminated concentric bodies (pathognomonic of papillary Ca) in ~40–50%<br/>"
    "• Papillary architecture with fibrovascular cores lined by tumour cells<br/>"
    "• Variants: Follicular variant (most common variant), tall cell variant (aggressive), diffuse sclerosing variant<br/>"
    "• <b>BRAF V600E mutation</b> in ~60% (most common molecular alteration)", C_LGREEN, colors.HexColor('#117a65')))
story.append(sp(6))

story.append(sub_header("D. Management of Papillary Thyroid Carcinoma (5 marks)", colors.HexColor('#117a65')))
story.append(sp(4))

ptc_flow = BoxArrowChart([
    ("DIAGNOSIS: FNA cytology (Bethesda VI – malignant) + Neck USS + Laryngoscopy (vocal cords)", colors.HexColor('#117a65'), C_WHITE),
    ("STAGING: CT neck/chest (mets), TFTs, Serum Thyroglobulin (baseline), Serum calcium", C_MED, C_WHITE),
    ("SURGERY: Total Thyroidectomy (standard for PTC >4cm, bilateral, ETE, nodal disease)\nHemithyroidectomy may suffice for unifocal PTC <1cm (microcarcinoma)", C_ORANGE, C_WHITE),
    ("LYMPH NODES: Central neck dissection (Level VI) if clinically node-positive\nModified radical neck dissection (Levels II–V) for lateral neck disease", C_RED, C_WHITE),
    ("RADIOIODINE (RAI – I-131): Remnant ablation after TT for intermediate/high-risk disease\nKills residual thyroid tissue; treats micro-metastases", C_PURPLE, C_WHITE),
    ("TSH SUPPRESSION: Thyroxine (Levothyroxine) to suppress TSH <0.1 mU/L (high-risk)\nor 0.1–0.5 mU/L (low-risk) – reduces stimulation of any residual tumour cells", C_GREEN, C_WHITE),
    ("FOLLOW-UP: Serum Thyroglobulin + anti-Tg Ab every 6–12 months; Neck USS; RAI WBS (whole-body scan)", C_DARK, C_WHITE),
], width=AVAILABLE_WIDTH, box_height=28, spacing=14)
story += [ptc_flow, sp(4)]

story.append(bold("Risk Stratification (ATA Guidelines):"))
risk_data = [
    [Paragraph("Risk", sTableH), Paragraph("Criteria", sTableH), Paragraph("TSH Target", sTableH)],
    [Paragraph("Low Risk", sTableB), Paragraph("Intrathyroidal, no mets, no vascular invasion, R0 resection, classic histology, no RAI uptake outside thyroid bed", sTableB), Paragraph("0.5–2 mU/L", sTableBC)],
    [Paragraph("Intermediate Risk", sTableB), Paragraph("Minor ETE, microscopic LN mets, vascular invasion, RAI uptake outside thyroid bed on WBS", sTableB), Paragraph("0.1–0.5 mU/L", sTableBC)],
    [Paragraph("High Risk", sTableB), Paragraph("Macroscopic ETE, incomplete resection, distant mets, post-surgical serum Tg suggesting distant mets", sTableB), Paragraph("<0.1 mU/L", sTableBC)],
]
rdt = Table(risk_data, colWidths=[AVAILABLE_WIDTH*x for x in [0.18, 0.62, 0.20]])
rdt.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), colors.HexColor('#117a65')),
    ('BACKGROUND', (0,1), (-1,1), C_LGREEN),
    ('BACKGROUND', (0,2), (-1,2), C_LYELLOW),
    ('BACKGROUND', (0,3), (-1,3), C_LRED),
    ('BOX', (0,0), (-1,-1), 0.5, C_GRAY),
    ('INNERGRID', (0,0), (-1,-1), 0.3, C_GRAY),
    ('PADDING', (0,0), (-1,-1), 5),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
]))
story += [rdt, sp(8)]

# ─── FOOTER / Disclaimer ─────────────────────────────────────
story.append(hr())
story.append(Paragraph("Prepared by <b>Orris AI</b> for Final MBBS Surgery – General Surgery Paper I | Teerthanker Mahaveer Medical College, Moradabad | Batch 2020 | Model answers based on Bailey &amp; Love, Sabiston, Harrison's, Surviving Sepsis Campaign guidelines. For educational use only.", sSmall))

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

cd /tmp/workspace/mbbs-surgery-paper && python generate_pdf.py 2>&1

Editing File

~/mbbs-surgery-paper/generate_pdf.py

Successfully replaced 1 instance(s) of the string in '/tmp/workspace/mbbs-surgery-paper/generate_pdf.py'
Running Command

cd /tmp/workspace/mbbs-surgery-paper && python generate_pdf.py 2>&1

Reading File
Editing File

~/mbbs-surgery-paper/generate_pdf.py

Successfully replaced 1 instance(s) of the string in '/tmp/workspace/mbbs-surgery-paper/generate_pdf.py'
Reading File
Editing File

~/mbbs-surgery-paper/generate_pdf.py

Successfully replaced 1 instance(s) of the string in '/tmp/workspace/mbbs-surgery-paper/generate_pdf.py'
Running Command

cd /tmp/workspace/mbbs-surgery-paper && python generate_pdf.py 2>&1

Running Command

ls -lh /tmp/workspace/mbbs-surgery-paper/Surgery_Paper_I_Answers.pdf

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

Surgery Paper I Answers

PDF Document · PDF


What's Inside the PDF

The document covers all 7 questions from your 3rd Prof Part II (Final MBBS) General Surgery Paper I with full model answers, colour-coded tables, flowcharts, and classification diagrams:

Q1 – Wound Healing (3+3+4)

  • Horizontal 4-phase timeline (Haemostasis → Inflammation → Proliferation → Remodelling) with durations and key cells
  • NRC/CDC 4-class wound classification table (clean to dirty-infected, with infection risks)
  • Two-column table separating local vs systemic factors affecting healing

Q2 – Blood Transfusion (2.5+2.5+5)

  • Donor eligibility criteria table (age, weight, Hb, BP, exclusions)
  • Massive transfusion definition + Damage Control Resuscitation (1:1:1 protocol)
  • Three-column complications table (Immunological / Non-immunological / Massive transfusion)

Q3 – SSI (1+1+3+3+2)

  • CDC definition, causative organisms
  • Tree diagram for CDC/NHSN classification (Superficial / Deep Incisional / Organ-Space)
  • Three-column prevention table (Pre-op / Intra-op / Post-op)
  • Management flowchart (6 steps from suspicion to delayed primary closure)

Q4 – Shock (1+2+3+4)

  • Definition, 4-type classification table with CO/SVR changes
  • Septic shock pathophysiology flowchart (LPS → TLR4 → Cytokines → NO → MODS)
  • Surviving Sepsis Campaign Hour-1 Bundle flowchart (antibiotics, fluids, vasopressors, source control)

Q5 – Burns Medicolegal & Management (2+2+6)

  • Medicolegal answer: mandatory police reporting under BNSS/NMC code
  • Treat immediately - do NOT delay
  • Rule of Nines table, burn depth classification table
  • Parkland formula calculated for the patient (5,500 mL RL)
  • Full management including wound care, escharotomy, STSG

Q6 – Short Notes (4 × 5 marks)

  • Refeeding Syndrome with pathophysiology flowchart (starvation → refeeding → hypophosphataemia)
  • TPN - components, indications, complications (catheter + metabolic)
  • Abdominal Compartment Syndrome with IAP measurement and decompressive laparotomy
  • Buerger's Disease - Shionoya criteria, corkscrew collaterals, Iloprost, smoking cessation
  • Phyllodes Tumour - benign/borderline/malignant grading table with mitotic rate and margins

Q7 – Thyroid Carcinoma (2+1+2+5)

  • Tree classification diagram (Papillary 80%, Follicular 10%, Medullary, Anaplastic, Lymphoma)
  • Incidence/spread/prognosis comparison table
  • Histopathology: Orphan Annie eye nuclei, psammoma bodies, BRAF V600E
  • Management flowchart (FNA → Total thyroidectomy → RAI → TSH suppression → Follow-up)
  • ATA risk stratification table (Low/Intermediate/High) with TSH targets

Sources: Bailey & Love's Surgery 28e, Sabiston Textbook of Surgery, Harrison's 22e, Surviving Sepsis Campaign 2021, ATA Thyroid Guidelines
This is a shared conversation. Sign in to Orris to start your own chat.