Hey, analyse this pdf one by one topics given, i want you to prepare a summarise yet effective flowchart each of topic which explains the pathophysiology only and make a effective pdf so that i can revise for my exam, but before making a pdf , ask me is it ok? For any random topic? Take validation from me then only make full pdf of 90 topics
cd /home/daytona/workspace/attachments/90d82789-a1a4-4355-b670-6a5404df8a3b && python3 -c " from pypdf import PdfReader reader = PdfReader('DNB Pathophysiology Questions 90.pdf') print(f'Pages: {len(reader.pages)}') for i, page in enumerate(reader.pages): print(f'--- PAGE {i+1} ---') print(page.extract_text()) print() "
ARDS PATHOPHYSIOLOGY
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
TRIGGER
(Pneumonia / Sepsis / Aspiration / Trauma)
↓
ALVEOLAR EPITHELIAL & ENDOTHELIAL INJURY
(Type I & II pneumocyte damage + capillary leak)
↓
NEUTROPHIL ACTIVATION + CYTOKINE STORM
(IL-1, IL-6, TNF-α, ROS release)
↓
DIFFUSE ALVEOLAR DAMAGE (DAD)
(Protein-rich exudate fills alveoli)
↓
HYALINE MEMBRANE FORMATION
(↓Surfactant → alveolar collapse)
↓
↓ Compliance + ↓ P/F Ratio + Bilateral Opacities
↓
BERLIN CRITERIA: Mild P/F 200-300 | Moderate 100-200 | Severe <100
↓
CLINICAL: Refractory hypoxaemia, ↑Work of breathing
↓
ANAESTHETIC IMPLICATION
Lung-protective ventilation (TV 6ml/kg IBW, PEEP, Pplat <30cmH₂O)
Prone positioning (>12h/day for severe)
One more type
mkdir -p /home/daytona/workspace/dnb-pathophysiology && ls /home/daytona/workspace/dnb-pathophysiology/
~/dnb-pathophysiology/sample_test.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm
from reportlab.pdfgen import canvas
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, HRFlowable
from reportlab.lib.enums import TA_CENTER, TA_LEFT
W, H = A4
def make_sample():
path = "/home/daytona/workspace/dnb-pathophysiology/SAMPLE_Topic15_MH.pdf"
c = canvas.Canvas(path, pagesize=A4)
# ── palette ──────────────────────────────────────────────────────────────
BG = colors.HexColor("#0D1B2A") # dark navy background
HEADER_BG = colors.HexColor("#1B3A5C") # slightly lighter header
ACCENT = colors.HexColor("#F4A261") # warm orange arrows / highlights
BOX_BG = colors.HexColor("#132233") # box background
BOX_BORDER= colors.HexColor("#2E6DA4") # box border
TEXT_MAIN = colors.HexColor("#E8F4FD") # near-white text
TEXT_DIM = colors.HexColor("#A8C7E0") # secondary text
STAR_COL = colors.HexColor("#F4A261") # star colour
PEARL_BG = colors.HexColor("#1A3C1A") # dark green for anaesthetic pearl
PEARL_BOR = colors.HexColor("#4CAF50") # green border
# ── full-page dark background ─────────────────────────────────────────────
c.setFillColor(BG)
c.rect(0, 0, W, H, fill=1, stroke=0)
# ── top header bar ────────────────────────────────────────────────────────
c.setFillColor(HEADER_BG)
c.rect(0, H - 28*mm, W, 28*mm, fill=1, stroke=0)
# accent line under header
c.setFillColor(ACCENT)
c.rect(0, H - 29*mm, W, 1.5, fill=1, stroke=0)
# header text
c.setFillColor(ACCENT)
c.setFont("Helvetica-Bold", 9)
c.drawString(12*mm, H - 10*mm, "DNB ANAESTHESIOLOGY — PATHOPHYSIOLOGY FLOWCHARTS | 2021-2025")
c.setFillColor(TEXT_MAIN)
c.setFont("Helvetica-Bold", 17)
c.drawString(12*mm, H - 21*mm, "Topic 15 — Malignant Hyperthermia (MH)")
# frequency stars
c.setFillColor(STAR_COL)
c.setFont("Helvetica-Bold", 11)
c.drawRightString(W - 12*mm, H - 21*mm, "★★★ High Priority")
# ── helper: draw a flowchart box ──────────────────────────────────────────
def draw_box(x, y, w, h, title, lines, title_color=ACCENT, bg=BOX_BG, border=BOX_BORDER):
# shadow
c.setFillColor(colors.HexColor("#000000"))
c.setFillAlpha(0.25)
c.rect(x+1.5, y-1.5, w, h, fill=1, stroke=0)
c.setFillAlpha(1.0)
# box
c.setFillColor(bg)
c.setStrokeColor(border)
c.setLineWidth(1.2)
c.roundRect(x, y, w, h, 4, fill=1, stroke=1)
# title
c.setFillColor(title_color)
c.setFont("Helvetica-Bold", 9)
c.drawString(x + 5, y + h - 13, title)
# content lines
c.setFillColor(TEXT_MAIN)
c.setFont("Helvetica", 8)
for i, line in enumerate(lines):
c.drawString(x + 5, y + h - 24 - i*11, line)
def draw_arrow(x, y_top, length=18):
"""Draw a vertical downward arrow centred at x."""
c.setStrokeColor(ACCENT)
c.setFillColor(ACCENT)
c.setLineWidth(1.8)
c.line(x, y_top, x, y_top - length + 6)
# arrowhead (triangle)
p = c.beginPath()
p.moveTo(x, y_top - length)
p.lineTo(x - 4, y_top - length + 8)
p.lineTo(x + 4, y_top - length + 8)
p.close()
c.drawPath(p, fill=1, stroke=0)
cx = W / 2 # horizontal centre
bw = 155*mm # box width
bx = cx - bw/2
# ── flowchart boxes ───────────────────────────────────────────────────────
# 1. TRIGGER
y1 = H - 60*mm
bh1 = 22*mm
draw_box(bx, y1, bw, bh1,
"① TRIGGER — Genetic Susceptibility",
["RYR1 gene mutation (Ryanodine Receptor 1 on chromosome 19q)",
"Autosomal dominant | Incidence ~1:10,000–15,000 anaesthetics"])
draw_arrow(cx, y1, 18)
# 2. INITIATING AGENT
y2 = y1 - 18*mm - 22*mm
bh2 = 22*mm
draw_box(bx, y2, bw, bh2,
"② INITIATING AGENT (Triggers)",
["Volatile anaesthetics (halothane > sevoflurane > isoflurane > desflurane)",
"Succinylcholine (depolarising NMB) | Stress / heat (rare)"])
draw_arrow(cx, y2, 18)
# 3. PATHOLOGICAL MECHANISM
y3 = y2 - 18*mm - 28*mm
bh3 = 28*mm
draw_box(bx, y3, bw, bh3,
"③ CORE MECHANISM — Uncontrolled Ca²⁺ Release",
["Trigger → RYR1 channel opens uncontrollably in SR",
"Massive Ca²⁺ floods sarcoplasm → sustained muscle contraction",
"ATP consumed at extreme rate → hypermetabolism",
"Anaerobic glycolysis → lactic acidosis + heat generation"])
draw_arrow(cx, y3, 18)
# 4. CLINICAL CASCADE
y4 = y3 - 18*mm - 32*mm
bh4 = 32*mm
draw_box(bx, y4, bw, bh4,
"④ CLINICAL CASCADE (in order of appearance)",
["EARLIEST: ↑ETCO2 (↑↑ CO2 production) + Masseter spasm (sux)",
"↑ HR, ↑ BP, muscle rigidity (generalised)",
"Hyperthermia (rises ~1°C / 5 min — LATE sign)",
"Metabolic acidosis | Hyperkalaemia (cell membrane breakdown)",
"Rhabdomyolysis → myoglobinuria → AKI"])
draw_arrow(cx, y4, 18)
# 5. TREATMENT
y5 = y4 - 18*mm - 36*mm
bh5 = 36*mm
draw_box(bx, y5, bw, bh5,
"⑤ TREATMENT — MHAUS Protocol",
["STOP all volatile agents + succinylcholine immediately",
"Hyperventilate 100% O₂ at 2-3× MV (↓ ETCO2)",
"DANTROLENE 2.5 mg/kg IV bolus → repeat q5 min (max 10 mg/kg)",
" MOA: blocks RYR1 → ↓ Ca²⁺ release from SR",
"Cool patient (ice packs / cold IV fluids) → target 38.5°C",
"Treat hyperkalaemia (calcium / insulin-glucose / bicarb)",
"Monitor: ETCO2, temperature, ABG, CK, urine output"],
title_color=PEARL_BOR, bg=PEARL_BG, border=PEARL_BOR)
# ── bottom memory hook ────────────────────────────────────────────────────
yb = y5 - 12*mm
c.setFillColor(colors.HexColor("#2C1810"))
c.setStrokeColor(ACCENT)
c.setLineWidth(1)
c.roundRect(bx, yb - 12*mm, bw, 14*mm, 4, fill=1, stroke=1)
c.setFillColor(ACCENT)
c.setFont("Helvetica-Bold", 9)
c.drawString(bx + 5, yb - 5, "⚡ MEMORY HOOK: ETCO₂ UP first → Dantrolene is the ONLY cure → Stop triggers IMMEDIATELY")
# ── footer ────────────────────────────────────────────────────────────────
c.setFillColor(HEADER_BG)
c.rect(0, 0, W, 12*mm, fill=1, stroke=0)
c.setFillColor(ACCENT)
c.rect(0, 12*mm, W, 0.8, fill=1, stroke=0)
c.setFillColor(TEXT_DIM)
c.setFont("Helvetica", 7.5)
c.drawString(12*mm, 4.5*mm, "DNB Anaesthesiology Pathophysiology Flowcharts | Sample — Topic 15 of 90")
c.drawRightString(W - 12*mm, 4.5*mm, "For Exam Revision Only")
c.save()
print("Saved:", path)
make_sample()
cd /home/daytona/workspace/dnb-pathophysiology && python3 sample_test.py
SAMPLE Topic15 MH
PDF Document · PDF
No, i dont like that plus wanr
~/dnb-pathophysiology/sample_v2.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm
from reportlab.pdfgen import canvas
W, H = A4
def draw_page(c, topic_num, topic_title, freq_label, steps, pearl, memory):
"""
steps = list of (step_label, [bullet, bullet, ...])
pearl = string (anaesthetic implication)
memory = string (memory hook)
"""
# ── colours ───────────────────────────────────────────────────────────────
C_HEADER = colors.HexColor("#1A56DB") # blue header
C_STEP_BG = colors.HexColor("#EFF6FF") # very light blue box
C_STEP_BOR = colors.HexColor("#93C5FD") # soft blue border
C_ARROW = colors.HexColor("#1A56DB")
C_PEARL_BG = colors.HexColor("#F0FDF4") # mint green
C_PEARL_BOR= colors.HexColor("#4ADE80")
C_MEM_BG = colors.HexColor("#FFFBEB") # warm yellow
C_MEM_BOR = colors.HexColor("#FCD34D")
C_TEXT = colors.HexColor("#1E293B") # near-black
C_SUB = colors.HexColor("#475569") # grey subtitle
# ── white background ──────────────────────────────────────────────────────
c.setFillColor(colors.white)
c.rect(0, 0, W, H, fill=1, stroke=0)
# ── header strip ─────────────────────────────────────────────────────────
c.setFillColor(C_HEADER)
c.rect(0, H - 22*mm, W, 22*mm, fill=1, stroke=0)
c.setFillColor(colors.white)
c.setFont("Helvetica-Bold", 16)
c.drawString(12*mm, H - 13*mm, f"Topic {topic_num} — {topic_title}")
c.setFont("Helvetica", 9)
c.drawRightString(W - 12*mm, H - 10*mm, freq_label)
c.setFont("Helvetica", 8)
c.drawRightString(W - 12*mm, H - 17*mm, "DNB Anaesthesiology | Pathophysiology Flowchart")
# ── helper: arrow ─────────────────────────────────────────────────────────
def arrow(x, y_top, length=14):
c.setStrokeColor(C_ARROW)
c.setFillColor(C_ARROW)
c.setLineWidth(2)
c.line(x, y_top, x, y_top - length + 5)
p = c.beginPath()
p.moveTo(x, y_top - length)
p.lineTo(x - 5, y_top - length + 9)
p.lineTo(x + 5, y_top - length + 9)
p.close()
c.drawPath(p, fill=1, stroke=0)
# ── helper: step box ──────────────────────────────────────────────────────
def step_box(y, label, bullets, bg=C_STEP_BG, bor=C_STEP_BOR):
bw = W - 28*mm
bx = 14*mm
pad = 4*mm
line_h = 6.5*mm
bh = 9*mm + len(bullets) * line_h + pad
c.setFillColor(bg)
c.setStrokeColor(bor)
c.setLineWidth(1.2)
c.roundRect(bx, y - bh, bw, bh, 5, fill=1, stroke=1)
# label pill
c.setFillColor(C_HEADER)
pill_w = c.stringWidth(label, "Helvetica-Bold", 8.5) + 8
c.roundRect(bx + 5*mm, y - 7.5*mm, pill_w, 5.5*mm, 3, fill=1, stroke=0)
c.setFillColor(colors.white)
c.setFont("Helvetica-Bold", 8.5)
c.drawString(bx + 5*mm + 4, y - 4.5*mm, label)
# bullets
c.setFillColor(C_TEXT)
c.setFont("Helvetica", 10)
for i, b in enumerate(bullets):
bullet_y = y - 10*mm - i * line_h
c.setFillColor(C_ARROW)
c.circle(bx + 6*mm, bullet_y + 2, 1.8, fill=1, stroke=0)
c.setFillColor(C_TEXT)
c.drawString(bx + 9*mm, bullet_y, b)
return bh # return height used
# ── lay out flowchart steps ───────────────────────────────────────────────
cx = W / 2
cur_y = H - 26*mm # start just below header
for i, (label, bullets) in enumerate(steps):
cur_y -= 6*mm # top margin before box
bh = step_box(cur_y, label, bullets)
cur_y -= bh
if i < len(steps) - 1:
arrow(cx, cur_y, 14)
cur_y -= 2*mm
# ── anaesthetic pearl ─────────────────────────────────────────────────────
cur_y -= 5*mm
bw = W - 28*mm
bx = 14*mm
pearl_h = 16*mm
c.setFillColor(C_PEARL_BG)
c.setStrokeColor(C_PEARL_BOR)
c.setLineWidth(1.5)
c.roundRect(bx, cur_y - pearl_h, bw, pearl_h, 5, fill=1, stroke=1)
c.setFillColor(colors.HexColor("#15803D"))
c.setFont("Helvetica-Bold", 9)
c.drawString(bx + 5*mm, cur_y - 6*mm, "Anaesthetic Implication")
c.setFillColor(C_TEXT)
c.setFont("Helvetica", 10)
c.drawString(bx + 5*mm, cur_y - 12.5*mm, pearl)
cur_y -= pearl_h
# ── memory hook ──────────────────────────────────────────────────────────
cur_y -= 4*mm
mem_h = 13*mm
c.setFillColor(C_MEM_BG)
c.setStrokeColor(C_MEM_BOR)
c.setLineWidth(1.2)
c.roundRect(bx, cur_y - mem_h, bw, mem_h, 5, fill=1, stroke=1)
c.setFillColor(colors.HexColor("#92400E"))
c.setFont("Helvetica-Bold", 9)
c.drawString(bx + 5*mm, cur_y - 6*mm, "Memory Hook")
c.setFillColor(C_TEXT)
c.setFont("Helvetica-Oblique", 9.5)
c.drawString(bx + 5*mm, cur_y - 11.5*mm, memory)
# ── footer ────────────────────────────────────────────────────────────────
c.setStrokeColor(colors.HexColor("#CBD5E1"))
c.setLineWidth(0.5)
c.line(12*mm, 10*mm, W - 12*mm, 10*mm)
c.setFillColor(C_SUB)
c.setFont("Helvetica", 7.5)
c.drawString(12*mm, 6*mm, f"Topic {topic_num} of 90 | DNB Anaesthesiology Pathophysiology Flowcharts")
c.drawRightString(W - 12*mm, 6*mm, "For Exam Revision Only")
# ── SAMPLE: Topic 15 — Malignant Hyperthermia ────────────────────────────────
path = "/home/daytona/workspace/dnb-pathophysiology/SAMPLE_v2_Topic15_MH.pdf"
c = canvas.Canvas(path, pagesize=A4)
draw_page(
c,
topic_num=15,
topic_title="Malignant Hyperthermia",
freq_label="★★★ High Priority | Asked Dec22, Dec25, Oct23",
steps=[
("TRIGGER — Genetic Basis",
["RYR1 gene mutation (chromosome 19q13) — Autosomal Dominant",
"Incidence: ~1 : 10,000–15,000 anaesthetics"]),
("INITIATING AGENTS",
["All volatile anaesthetics (halothane > sevo > iso > des)",
"Succinylcholine (depolarising NMB)"]),
("CORE DEFECT — Uncontrolled Ca²⁺ Release",
["Trigger opens RYR1 channel → massive SR Ca²⁺ release",
"Sustained muscle contraction → extreme ATP consumption",
"Anaerobic glycolysis → lactic acid + ↑↑ heat"]),
("CLINICAL CASCADE (in sequence)",
["① ↑↑ EtCO₂ (EARLIEST sign) + masseter spasm",
"② Tachycardia, hypertension, generalised rigidity",
"③ Hyperthermia (rises ~1°C/5 min — LATE)",
"④ Metabolic acidosis, hyperkalaemia",
"⑤ Rhabdomyolysis → myoglobinuria → AKI"]),
("TREATMENT — MHAUS Protocol",
["STOP trigger agent + succinylcholine | Call for help",
"Hyperventilate 100% O₂ at 2–3× minute volume",
"DANTROLENE 2.5 mg/kg IV q5 min (max 10 mg/kg)",
"Active cooling → target 38.5°C",
"Treat K⁺ & acidosis | Urine output > 1 ml/kg/h"]),
],
pearl="Avoid all volatiles & succinylcholine. Use TIVA (propofol + remi). Have dantrolene stocked.",
memory="EtCO₂ FIRST → Dantrolene is the ONLY cure → STOP trigger → Cool"
)
c.save()
print("Saved:", path)
cd /home/daytona/workspace/dnb-pathophysiology && python3 sample_v2.py
SAMPLE v2 Topic15 MH
PDF Document · PDF
No
Including anesthesia implication in simple format plus please check number , support numbers
~/dnb-pathophysiology/sample_v3.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm
from reportlab.pdfgen import canvas
W, H = A4
def wrap_text(text, max_chars=70):
"""Simple word-wrap into lines of max_chars."""
words = text.split()
lines = []
cur = ""
for w in words:
if len(cur) + len(w) + 1 <= max_chars:
cur = (cur + " " + w).strip()
else:
if cur:
lines.append(cur)
cur = w
if cur:
lines.append(cur)
return lines
def draw_flowchart_page(c, topic_num, topic_title, freq, flow_steps, anaesthetic_points):
"""
flow_steps: list of strings (each is one step in the flow)
anaesthetic_points: list of strings
"""
FONT_MONO = "Courier"
FONT_BOLD = "Helvetica-Bold"
FONT_REG = "Helvetica"
C_TITLE = colors.HexColor("#374151") # dark grey title
C_FREQ = colors.HexColor("#6B7280") # lighter grey freq
C_BOX_BG = colors.HexColor("#F1F5F9") # very light grey box (like reference)
C_ANESTH_BG= colors.HexColor("#F0FDF4") # very light green
C_TEXT = colors.HexColor("#111827") # near black
C_ARROW = colors.HexColor("#374151") # dark grey arrow
C_BORDER = colors.HexColor("#CBD5E1") # subtle border
C_GREEN = colors.HexColor("#15803D")
# White page
c.setFillColor(colors.white)
c.rect(0, 0, W, H, fill=1, stroke=0)
margin_l = 14*mm
margin_r = W - 14*mm
box_w = W - 28*mm
cur_y = H - 14*mm
# ── Topic title ───────────────────────────────────────────────────────────
c.setFillColor(C_TITLE)
c.setFont(FONT_BOLD, 15)
c.drawString(margin_l, cur_y, f"Topic {topic_num}. {topic_title.upper()} — PATHOPHYSIOLOGY FLOWCHART")
cur_y -= 5*mm
# Frequency line
c.setFillColor(C_FREQ)
c.setFont(FONT_REG, 9)
c.drawString(margin_l, cur_y, freq)
cur_y -= 4*mm
# thin rule
c.setStrokeColor(C_BORDER)
c.setLineWidth(0.7)
c.line(margin_l, cur_y, margin_r, cur_y)
cur_y -= 5*mm
# ── Build full text block for flowchart box ───────────────────────────────
# Each step may need wrapping; between steps insert a ↓ line
FONT_SIZE = 11
LINE_H = 6.5*mm
ARROW_H = 6*mm
PAD_V = 5*mm
PAD_H = 8*mm
# Pre-compute all display lines
display_lines = [] # list of (text, is_arrow)
for i, step in enumerate(flow_steps):
wrapped = wrap_text(step, max_chars=68)
for ln in wrapped:
display_lines.append((ln, False))
if i < len(flow_steps) - 1:
display_lines.append(("↓", True))
total_flow_h = PAD_V + len(display_lines) * LINE_H + PAD_V
# Draw box
box_y = cur_y - total_flow_h
c.setFillColor(C_BOX_BG)
c.setStrokeColor(C_BORDER)
c.setLineWidth(0.8)
c.roundRect(margin_l, box_y, box_w, total_flow_h, 4, fill=1, stroke=1)
# Draw lines inside box
text_x = margin_l + PAD_H
text_y = cur_y - PAD_V - LINE_H * 0.15
for (line, is_arrow) in display_lines:
if is_arrow:
c.setFillColor(C_ARROW)
c.setFont(FONT_MONO, FONT_SIZE + 1)
c.drawString(text_x + 30, text_y, line)
else:
c.setFillColor(C_TEXT)
c.setFont(FONT_MONO, FONT_SIZE)
c.drawString(text_x, text_y, line)
text_y -= LINE_H
cur_y = box_y - 6*mm
# ── Anaesthetic Implication box ───────────────────────────────────────────
c.setFillColor(C_GREEN)
c.setFont(FONT_BOLD, 10)
c.drawString(margin_l, cur_y, "ANAESTHETIC IMPLICATIONS")
cur_y -= 4*mm
# pre-compute lines
anesth_lines = []
for pt in anaesthetic_points:
wrapped = wrap_text("• " + pt, max_chars=68)
anesth_lines.extend(wrapped)
anesth_h = PAD_V + len(anesth_lines) * LINE_H + PAD_V
abox_y = cur_y - anesth_h
c.setFillColor(C_ANESTH_BG)
c.setStrokeColor(colors.HexColor("#86EFAC"))
c.setLineWidth(0.8)
c.roundRect(margin_l, abox_y, box_w, anesth_h, 4, fill=1, stroke=1)
ty = cur_y - PAD_V - LINE_H * 0.15
for ln in anesth_lines:
c.setFillColor(C_TEXT)
c.setFont(FONT_MONO, FONT_SIZE)
c.drawString(text_x, ty, ln)
ty -= LINE_H
cur_y = abox_y - 5*mm
# ── Footer ────────────────────────────────────────────────────────────────
c.setStrokeColor(C_BORDER)
c.setLineWidth(0.5)
c.line(margin_l, 10*mm, margin_r, 10*mm)
c.setFillColor(C_FREQ)
c.setFont(FONT_REG, 7.5)
c.drawString(margin_l, 6.5*mm, f"Topic {topic_num} of 90 | DNB Anaesthesiology Pathophysiology Flowcharts | Exam Revision")
c.drawRightString(margin_r, 6.5*mm, "2021–2025 Question Bank")
# ── SAMPLE: Topic 15 — Malignant Hyperthermia ────────────────────────────────
path = "/home/daytona/workspace/dnb-pathophysiology/SAMPLE_v3_Topic15_MH.pdf"
c = canvas.Canvas(path, pagesize=A4)
draw_flowchart_page(
c,
topic_num = 15,
topic_title = "Malignant Hyperthermia",
freq = "★★★ High Priority | Asked: Dec 2022, Dec 2025, Oct 2023",
flow_steps = [
"RYR1 gene mutation (chromosome 19q13) — Autosomal Dominant",
"Exposure to volatile anaesthetic (halothane > sevo > iso > des) OR succinylcholine",
"RYR1 channel opens uncontrollably → massive Ca²⁺ release from sarcoplasmic reticulum",
"Sustained muscle contraction → extreme ATP consumption → hypermetabolism",
"Anaerobic glycolysis → lactic acidosis + massive heat generation",
"↑↑ EtCO₂ (EARLIEST sign) + masseter spasm",
"Tachycardia, hypertension, generalised muscle rigidity",
"Hyperthermia (rises ~1°C per 5 min — LATE sign)",
"Hyperkalaemia + metabolic acidosis",
"Rhabdomyolysis → myoglobinuria → AKI + cardiac arrhythmias",
],
anaesthetic_points = [
"STOP volatile agent + succinylcholine immediately. Call for help.",
"Hyperventilate with 100% O₂ at 2-3× minute volume.",
"DANTROLENE 2.5 mg/kg IV bolus, repeat q5 min up to 10 mg/kg (blocks RYR1).",
"Active cooling: ice packs, cold IV fluids — target temperature 38.5°C.",
"Treat hyperkalaemia (calcium gluconate, insulin-glucose, bicarb).",
"Use TIVA (propofol + remifentanil) — avoid all volatiles in susceptible patients.",
"Have dantrolene stocked (36 vials minimum). Screen family (MHAUS protocol).",
]
)
c.save()
print("Saved:", path)
cd /home/daytona/workspace/dnb-pathophysiology && python3 sample_v3.py
SAMPLE v3 Topic15 MH
PDF Document · PDF
Better plus i want to focus on the Etco2 that 2 is not there its shown blank boxes
~/dnb-pathophysiology/sample_v4.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm
from reportlab.pdfgen import canvas
W, H = A4
def wrap_text(text, max_chars=70):
words = text.split()
lines = []
cur = ""
for w in words:
if len(cur) + len(w) + 1 <= max_chars:
cur = (cur + " " + w).strip()
else:
if cur:
lines.append(cur)
cur = w
if cur:
lines.append(cur)
return lines
def draw_flowchart_page(c, topic_num, topic_title, freq, flow_steps, anaesthetic_points):
FONT_MONO = "Courier"
FONT_BOLD = "Helvetica-Bold"
FONT_REG = "Helvetica"
C_TITLE = colors.HexColor("#1E293B")
C_FREQ = colors.HexColor("#64748B")
C_BOX_BG = colors.HexColor("#F1F5F9")
C_ANESTH_BG= colors.HexColor("#F0FDF4")
C_TEXT = colors.HexColor("#0F172A")
C_ARROW = colors.HexColor("#334155")
C_BORDER = colors.HexColor("#CBD5E1")
C_GREEN_TXT= colors.HexColor("#166534")
C_GREEN_BOR= colors.HexColor("#86EFAC")
C_ACCENT = colors.HexColor("#1D4ED8") # blue for topic title accent line
c.setFillColor(colors.white)
c.rect(0, 0, W, H, fill=1, stroke=0)
margin_l = 16*mm
margin_r = W - 16*mm
box_w = W - 32*mm
FONT_SIZE = 11
LINE_H = 7*mm
PAD_V = 5*mm
PAD_H = 7*mm
cur_y = H - 12*mm
# Blue accent bar left of title
c.setFillColor(C_ACCENT)
c.rect(margin_l, cur_y - 11*mm, 3, 13*mm, fill=1, stroke=0)
# Topic title
c.setFillColor(C_TITLE)
c.setFont(FONT_BOLD, 14)
c.drawString(margin_l + 6, cur_y, f"Topic {topic_num}. {topic_title.upper()}")
cur_y -= 6*mm
# Subtitle: Pathophysiology Flowchart
c.setFillColor(C_ACCENT)
c.setFont(FONT_BOLD, 9)
c.drawString(margin_l + 6, cur_y, "PATHOPHYSIOLOGY FLOWCHART")
cur_y -= 5*mm
# Frequency
c.setFillColor(C_FREQ)
c.setFont(FONT_REG, 8.5)
c.drawString(margin_l + 6, cur_y, freq)
cur_y -= 4*mm
# Divider
c.setStrokeColor(C_BORDER)
c.setLineWidth(0.8)
c.line(margin_l, cur_y, margin_r, cur_y)
cur_y -= 6*mm
# ── Build display lines ───────────────────────────────────────────────────
display_lines = []
for i, step in enumerate(flow_steps):
wrapped = wrap_text(step, max_chars=66)
for ln in wrapped:
display_lines.append((ln, False))
if i < len(flow_steps) - 1:
display_lines.append((" |", True)) # arrow line
total_flow_h = PAD_V + len(display_lines) * LINE_H + PAD_V
# Draw grey box
box_y = cur_y - total_flow_h
c.setFillColor(C_BOX_BG)
c.setStrokeColor(C_BORDER)
c.setLineWidth(0.8)
c.roundRect(margin_l, box_y, box_w, total_flow_h, 5, fill=1, stroke=1)
# Draw text inside box
text_x = margin_l + PAD_H
text_y = cur_y - PAD_V - LINE_H * 0.3
for (line, is_arrow) in display_lines:
if is_arrow:
# Draw a proper downward arrow using lines + triangle
ax = margin_l + PAD_H + 18
c.setStrokeColor(C_ARROW)
c.setFillColor(C_ARROW)
c.setLineWidth(1.5)
c.line(ax, text_y + 3*mm, ax, text_y - 0.5*mm)
# arrowhead
p = c.beginPath()
p.moveTo(ax, text_y - 1.5*mm)
p.lineTo(ax - 4, text_y + 1.5*mm)
p.lineTo(ax + 4, text_y + 1.5*mm)
p.close()
c.drawPath(p, fill=1, stroke=0)
else:
c.setFillColor(C_TEXT)
c.setFont(FONT_MONO, FONT_SIZE)
c.drawString(text_x, text_y, line)
text_y -= LINE_H
cur_y = box_y - 7*mm
# ── Anaesthetic Implications ──────────────────────────────────────────────
c.setFillColor(C_GREEN_TXT)
c.setFont(FONT_BOLD, 10)
c.drawString(margin_l, cur_y, "ANAESTHETIC IMPLICATIONS")
cur_y -= 5*mm
anesth_lines = []
for pt in anaesthetic_points:
wrapped = wrap_text("* " + pt, max_chars=66)
anesth_lines.extend(wrapped)
anesth_h = PAD_V + len(anesth_lines) * LINE_H + PAD_V
abox_y = cur_y - anesth_h
c.setFillColor(C_ANESTH_BG)
c.setStrokeColor(C_GREEN_BOR)
c.setLineWidth(0.8)
c.roundRect(margin_l, abox_y, box_w, anesth_h, 5, fill=1, stroke=1)
ty = cur_y - PAD_V - LINE_H * 0.3
for ln in anesth_lines:
c.setFillColor(C_TEXT)
c.setFont(FONT_MONO, FONT_SIZE)
c.drawString(text_x, ty, ln)
ty -= LINE_H
cur_y = abox_y
# ── Footer ────────────────────────────────────────────────────────────────
c.setStrokeColor(C_BORDER)
c.setLineWidth(0.5)
c.line(margin_l, 11*mm, margin_r, 11*mm)
c.setFillColor(C_FREQ)
c.setFont(FONT_REG, 7.5)
c.drawString(margin_l, 7*mm,
f"Topic {topic_num} of 90 | DNB Anaesthesiology Pathophysiology Flowcharts")
c.drawRightString(margin_r, 7*mm, "2021-2025 Question Bank")
# ── SAMPLE: Topic 15 — Malignant Hyperthermia ────────────────────────────────
path = "/home/daytona/workspace/dnb-pathophysiology/SAMPLE_v4_Topic15_MH.pdf"
c = canvas.Canvas(path, pagesize=A4)
draw_flowchart_page(
c,
topic_num = 15,
topic_title = "Malignant Hyperthermia",
freq = "High Priority (3x) | Asked: Dec 2022, Dec 2025, Oct 2023",
flow_steps = [
"RYR1 gene mutation (chromosome 19q13) -- Autosomal Dominant",
"Exposure to volatile anaesthetic (halothane > sevo > iso > des) OR succinylcholine",
"RYR1 channel opens uncontrollably --> massive Ca2+ release from sarcoplasmic reticulum",
"Sustained muscle contraction --> extreme ATP consumption --> hypermetabolism",
"Anaerobic glycolysis --> lactic acidosis + massive heat generation",
"EtCO2 rises sharply (EARLIEST sign) + masseter spasm after sux",
"Tachycardia + hypertension + generalised muscle rigidity",
"Hyperthermia (rises ~1 deg C per 5 min -- LATE sign)",
"Hyperkalaemia + severe metabolic acidosis",
"Rhabdomyolysis --> myoglobinuria --> AKI + cardiac arrhythmias --> death if untreated",
],
anaesthetic_points = [
"STOP volatile agent + succinylcholine immediately. Activate MH protocol.",
"Hyperventilate with 100% O2 at 2-3x minute volume to wash out CO2.",
"DANTROLENE 2.5 mg/kg IV bolus, repeat every 5 min (max 10 mg/kg). MOA: blocks RYR1.",
"Active cooling: ice packs, cold IV saline -- target temp 38.5 deg C.",
"Treat hyperkalaemia: calcium gluconate + insulin-glucose + sodium bicarbonate.",
"Use TIVA (propofol + remifentanil) in susceptible patients -- avoid ALL volatiles.",
"Stock minimum 36 vials dantrolene. Screen family members (MHAUS protocol).",
]
)
c.save()
print("Saved:", path)
cd /home/daytona/workspace/dnb-pathophysiology && python3 sample_v4.py
SAMPLE v4 Topic15 MH
PDF Document · PDF
--> instead of →, deg C instead of °C, -- instead of em dashI think i like the ARDS format which u showed first time
~/dnb-pathophysiology/sample_v5.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm
from reportlab.pdfgen import canvas
W, H = A4
def wrap_text(text, max_chars=65):
words = text.split()
lines, cur = [], ""
for w in words:
if len(cur) + len(w) + 1 <= max_chars:
cur = (cur + " " + w).strip()
else:
if cur: lines.append(cur)
cur = w
if cur: lines.append(cur)
return lines
def draw_page(c, topic_num, topic_title, freq, flow_steps, anaesthetic_points):
# ── colours (matching reference image palette) ────────────────────────────
C_BG = colors.white
C_BOX = colors.HexColor("#EAECF0") # same grey as reference
C_ABOX = colors.HexColor("#F0FDF4") # light green
C_TITLE = colors.HexColor("#374151") # dark grey title
C_FREQ = colors.HexColor("#6B7280")
C_TEXT = colors.HexColor("#111827")
C_ARROW = colors.HexColor("#374151")
C_BORDER = colors.HexColor("#D1D5DB")
C_ABORDER = colors.HexColor("#A7F3D0")
C_ATITLE = colors.HexColor("#065F46")
FONT = "Courier"
FONT_BOLD = "Helvetica-Bold"
FONT_REG = "Helvetica"
FS = 11.5 # main font size
LH = 7.2*mm # line height
PAD = 6*mm # vertical padding inside box
PADH = 8*mm # horizontal padding inside box
ML = 16*mm # left margin
MR = W - 16*mm
# White background
c.setFillColor(C_BG)
c.rect(0, 0, W, H, fill=1, stroke=0)
cur_y = H - 14*mm
# ── Title ─────────────────────────────────────────────────────────────────
c.setFillColor(C_TITLE)
c.setFont(FONT_BOLD, 14)
title_str = f"Topic {topic_num}. {topic_title.upper()} -- PATHOPHYSIOLOGY FLOWCHART"
c.drawString(ML, cur_y, title_str)
cur_y -= 6*mm
# Frequency
c.setFillColor(C_FREQ)
c.setFont(FONT_REG, 8.5)
c.drawString(ML, cur_y, freq)
cur_y -= 5*mm
# Thin rule
c.setStrokeColor(C_BORDER)
c.setLineWidth(0.7)
c.line(ML, cur_y, MR, cur_y)
cur_y -= 7*mm
BOX_W = MR - ML
# ── Build flow lines ──────────────────────────────────────────────────────
flow_lines = [] # list of (text, is_arrow)
for i, step in enumerate(flow_steps):
for ln in wrap_text(step, 63):
flow_lines.append((ln, False))
if i < len(flow_steps) - 1:
flow_lines.append(("DOWN_ARROW", True))
flow_h = PAD + len(flow_lines) * LH + PAD
# Grey box
c.setFillColor(C_BOX)
c.setStrokeColor(C_BORDER)
c.setLineWidth(0.7)
c.roundRect(ML, cur_y - flow_h, BOX_W, flow_h, 4, fill=1, stroke=1)
ty = cur_y - PAD - LH * 0.25
cx = ML + BOX_W / 2
for (line, is_arrow) in flow_lines:
if is_arrow:
# Draw centred down arrow: vertical bar + arrowhead
ax = cx
top = ty + LH * 0.65
bot = ty - LH * 0.05
c.setStrokeColor(C_ARROW)
c.setFillColor(C_ARROW)
c.setLineWidth(1.4)
c.line(ax, top, ax, bot + 3)
# arrowhead triangle
p = c.beginPath()
p.moveTo(ax, bot)
p.lineTo(ax - 5, bot + 9)
p.lineTo(ax + 5, bot + 9)
p.close()
c.drawPath(p, fill=1, stroke=0)
else:
c.setFillColor(C_TEXT)
c.setFont(FONT, FS)
c.drawString(ML + PADH, ty, line)
ty -= LH
cur_y = cur_y - flow_h - 8*mm
# ── Anaesthetic Implications section ─────────────────────────────────────
c.setFillColor(C_ATITLE)
c.setFont(FONT_BOLD, 10.5)
c.drawString(ML, cur_y, "ANAESTHETIC IMPLICATIONS")
cur_y -= 5*mm
alines = []
for pt in anaesthetic_points:
for ln in wrap_text("- " + pt, 63):
alines.append(ln)
abox_h = PAD + len(alines) * LH + PAD
c.setFillColor(C_ABOX)
c.setStrokeColor(C_ABORDER)
c.setLineWidth(0.7)
c.roundRect(ML, cur_y - abox_h, BOX_W, abox_h, 4, fill=1, stroke=1)
ty = cur_y - PAD - LH * 0.25
for ln in alines:
c.setFillColor(C_TEXT)
c.setFont(FONT, FS)
c.drawString(ML + PADH, ty, ln)
ty -= LH
# ── Footer ────────────────────────────────────────────────────────────────
c.setStrokeColor(C_BORDER)
c.setLineWidth(0.5)
c.line(ML, 11*mm, MR, 11*mm)
c.setFillColor(C_FREQ)
c.setFont(FONT_REG, 7.5)
c.drawString(ML, 7*mm, f"Topic {topic_num} of 90 | DNB Anaesthesiology Pathophysiology | 2021-2025")
c.drawRightString(MR, 7*mm, "Exam Revision")
# ── SAMPLE: Topic 15 — Malignant Hyperthermia ────────────────────────────────
path = "/home/daytona/workspace/dnb-pathophysiology/SAMPLE_v5_Topic15_MH.pdf"
c = canvas.Canvas(path, pagesize=A4)
draw_page(
c,
topic_num = 15,
topic_title= "Malignant Hyperthermia",
freq = "High Priority (3x asked) | Dec 2022, Dec 2025, Oct 2023",
flow_steps = [
"RYR1 gene mutation (chr 19q13) -- Autosomal Dominant",
"Exposure to volatile agent (halothane > sevo > iso > des) OR succinylcholine",
"RYR1 channel opens uncontrollably",
"Massive Ca2+ release from sarcoplasmic reticulum into sarcoplasm",
"Sustained skeletal muscle contraction -- extreme ATP consumption",
"Anaerobic glycolysis -- lactic acidosis + massive heat generation",
"EtCO2 rises sharply (EARLIEST sign) + masseter spasm after sux",
"Tachycardia + hypertension + generalised muscle rigidity",
"Hyperthermia (rises ~1 deg C per 5 min -- LATE sign)",
"Hyperkalaemia + severe metabolic acidosis",
"Rhabdomyolysis --> myoglobinuria --> AKI + cardiac arrhythmias --> death if untreated",
],
anaesthetic_points = [
"STOP volatile agent + succinylcholine immediately. Call for help.",
"Hyperventilate 100% O2 at 2-3x minute volume to blow off CO2.",
"DANTROLENE 2.5 mg/kg IV bolus q5 min, max 10 mg/kg (blocks RYR1 channel).",
"Active cooling: ice packs + cold IV saline -- target 38.5 deg C.",
"Treat hyperkalaemia: calcium gluconate + insulin-glucose + NaHCO3.",
"Use TIVA (propofol + remifentanil) in susceptible patients -- avoid all volatiles.",
"Stock min 36 vials dantrolene. Screen family members (MHAUS protocol).",
]
)
c.save()
print("Saved:", path)
cd /home/daytona/workspace/dnb-pathophysiology && python3 sample_v5.py
SAMPLE v5 Topic15 MH
PDF Document · PDF
No,this one ARDS PATHOPHYSIOLOGY ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ TRIGGER (Pneumonia / Sepsis / Aspiration / Trauma) ↓ ALVEOLAR EPITHELIAL & ENDOTHELIAL INJURY (Type I & II pneumocyte damage + capillary leak) ↓ NEUTROPHIL ACTIVATION + CYTOKINE STORM (IL-1, IL-6, TNF-α, ROS release) ↓ DIFFUSE ALVEOLAR DAMAGE (DAD) (Protein-rich exudate fills alveoli) ↓ HYALINE MEMBRANE FORMATION (↓Surfactant → alveolar collapse) ↓ ↓ Compliance + ↓ P/F Ratio + Bilateral Opacities ↓ BERLIN CRITERIA: Mild P/F 200-300 | Moderate 100-200 | Severe <100 ↓ CLINICAL: Refractory hypoxaemia, ↑Work of breathing ↓ ANAESTHETIC IMPLICATION Lung-protective ventilation (TV 6ml/kg IBW, PEEP, Pplat <30cmH₂O) Prone positioning (>12h/day for severe)
~/dnb-pathophysiology/sample_v6.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm
from reportlab.pdfgen import canvas
W, H = A4
def wrap(text, max_chars=62):
words = text.split()
lines, cur = [], ""
for w in words:
if len(cur) + len(w) + 1 <= max_chars:
cur = (cur + " " + w).strip()
else:
if cur: lines.append(cur)
cur = w
if cur: lines.append(cur)
return lines
def draw_page(c, topic_num, topic_title, freq, steps, anaesthetic_lines):
"""
steps: list of (BOLD_TITLE, subtitle_or_None)
e.g. ("TRIGGER", "(Pneumonia / Sepsis / Aspiration / Trauma)")
subtitle can be None for steps with no sub-line
anaesthetic_lines: list of plain strings shown at bottom (no bold title needed,
the section header is drawn automatically)
"""
# ── Fonts & colours ───────────────────────────────────────────────────────
F_TITLE = "Helvetica-Bold"
F_STEP = "Helvetica-Bold" # BOLD step titles
F_SUB = "Helvetica" # subtitle / bracket text
F_MONO = "Courier" # body / implication text
C_TITLE = colors.HexColor("#1F2937")
C_RULE = colors.HexColor("#9CA3AF")
C_BOX = colors.HexColor("#F3F4F6") # very light grey -- matches reference
C_BORDER = colors.HexColor("#D1D5DB")
C_TEXT = colors.HexColor("#111827")
C_SUB = colors.HexColor("#374151")
C_ARROW = colors.HexColor("#374151")
C_ATITLE = colors.HexColor("#065F46") # dark green for ANAESTHETIC IMPLICATION header
C_FREQ = colors.HexColor("#6B7280")
FS_STEP = 11.5 # bold step title size
FS_SUB = 10.5 # subtitle size
FS_IMP = 10.5 # implication text size
LH_STEP = 6.8*mm
LH_SUB = 6.2*mm
LH_ARR = 8*mm # height reserved for arrow row
PAD_V = 5*mm
PAD_H = 10*mm
ML = 15*mm
MR = W - 15*mm
BOX_W = MR - ML
# White page
c.setFillColor(colors.white)
c.rect(0, 0, W, H, fill=1, stroke=0)
cur_y = H - 13*mm
# ── Topic heading ─────────────────────────────────────────────────────────
c.setFillColor(C_TITLE)
c.setFont(F_TITLE, 13.5)
c.drawString(ML, cur_y, f"Topic {topic_num}. {topic_title.upper()} PATHOPHYSIOLOGY FLOWCHART")
cur_y -= 5.5*mm
# Frequency
c.setFillColor(C_FREQ)
c.setFont(F_SUB, 8.5)
c.drawString(ML, cur_y, freq)
cur_y -= 5*mm
# ── Pre-calculate all rows inside the single big box ──────────────────────
# Each step produces: step-title row + optional sub rows + arrow row
# Last step: no arrow row; instead separator + ANAESTHETIC IMPLICATION header + implication rows
rows = [] # each item: ("step", text) | ("sub", text) | ("arrow",) | ("sep",) | ("atitle",) | ("aimp", text)
for i, (title, subtitle) in enumerate(steps):
rows.append(("step", title))
if subtitle:
for ln in wrap(subtitle, 60):
rows.append(("sub", ln))
if i < len(steps) - 1:
rows.append(("arrow",))
# Separator before anaesthetic implication
rows.append(("sep",))
rows.append(("atitle", "ANAESTHETIC IMPLICATION"))
for pt in anaesthetic_lines:
for ln in wrap(pt, 60):
rows.append(("aimp", ln))
# Measure total box height
def row_height(r):
if r[0] == "step": return LH_STEP
if r[0] == "sub": return LH_SUB
if r[0] == "arrow": return LH_ARR
if r[0] == "sep": return 5*mm
if r[0] == "atitle": return LH_STEP + 2*mm
if r[0] == "aimp": return LH_SUB
return LH_SUB
total_h = PAD_V + sum(row_height(r) for r in rows) + PAD_V
box_y = cur_y - total_h
# Draw single box
c.setFillColor(C_BOX)
c.setStrokeColor(C_BORDER)
c.setLineWidth(0.8)
c.roundRect(ML, box_y, BOX_W, total_h, 4, fill=1, stroke=1)
# Horizontal rule just below topic title inside box (like reference ━━━━)
rule_y = cur_y - PAD_V * 0.3
c.setStrokeColor(C_RULE)
c.setLineWidth(1.2)
c.line(ML + 4, rule_y, MR - 4, rule_y)
# Draw rows
cx = ML + BOX_W / 2
tx = ML + PAD_H
ty = cur_y - PAD_V
for r in rows:
kind = r[0]
if kind == "step":
c.setFillColor(C_TEXT)
c.setFont(F_STEP, FS_STEP)
c.drawString(tx, ty, r[1])
ty -= LH_STEP
elif kind == "sub":
c.setFillColor(C_SUB)
c.setFont(F_SUB, FS_SUB)
c.drawString(tx, ty, r[1])
ty -= LH_SUB
elif kind == "arrow":
# centred down arrow
mid = ty - LH_ARR * 0.25
top = ty - 1*mm
bot = ty - LH_ARR + 3*mm
c.setStrokeColor(C_ARROW)
c.setFillColor(C_ARROW)
c.setLineWidth(1.5)
c.line(cx, top, cx, bot + 4)
p = c.beginPath()
p.moveTo(cx, bot)
p.lineTo(cx - 5, bot + 9)
p.lineTo(cx + 5, bot + 9)
p.close()
c.drawPath(p, fill=1, stroke=0)
ty -= LH_ARR
elif kind == "sep":
# horizontal divider before implication
c.setStrokeColor(C_RULE)
c.setLineWidth(0.7)
c.line(ML + 4, ty, MR - 4, ty)
ty -= 5*mm
elif kind == "atitle":
c.setFillColor(C_ATITLE)
c.setFont(F_STEP, FS_STEP)
c.drawString(tx, ty, r[1])
ty -= LH_STEP + 2*mm
elif kind == "aimp":
c.setFillColor(C_TEXT)
c.setFont(F_SUB, FS_IMP)
c.drawString(tx, ty, r[1])
ty -= LH_SUB
# ── Footer ────────────────────────────────────────────────────────────────
c.setStrokeColor(C_BORDER)
c.setLineWidth(0.5)
c.line(ML, 11*mm, MR, 11*mm)
c.setFillColor(C_FREQ)
c.setFont(F_SUB, 7.5)
c.drawString(ML, 7*mm, f"Topic {topic_num} of 90 | DNB Anaesthesiology Pathophysiology | 2021-2025")
c.drawRightString(MR, 7*mm, "Exam Revision")
# ── SAMPLE: Topic 15 -- Malignant Hyperthermia ───────────────────────────────
path = "/home/daytona/workspace/dnb-pathophysiology/SAMPLE_v6_Topic15_MH.pdf"
c = canvas.Canvas(path, pagesize=A4)
draw_page(
c,
topic_num = 15,
topic_title = "Malignant Hyperthermia",
freq = "High Priority (3x asked) | Dec 2022, Dec 2025, Oct 2023",
steps = [
("TRIGGER -- Genetic Susceptibility",
"(RYR1 gene mutation, chr 19q13 -- Autosomal Dominant)"),
("INITIATING AGENT",
"(Volatile: halothane > sevo > iso > des OR Succinylcholine)"),
("RYR1 CHANNEL OPENS UNCONTROLLABLY",
"(Massive Ca2+ floods sarcoplasm from sarcoplasmic reticulum)"),
("SUSTAINED MUSCLE CONTRACTION",
"(Extreme ATP consumption --> hypermetabolism)"),
("ANAEROBIC GLYCOLYSIS",
"(Lactic acidosis + massive heat generation)"),
("EtCO2 RISES SHARPLY <-- EARLIEST SIGN",
"(+ Masseter spasm after succinylcholine)"),
("TACHYCARDIA + HYPERTENSION + RIGIDITY",
None),
("HYPERTHERMIA <-- LATE SIGN",
"(Rises ~1 deg C per 5 min)"),
("HYPERKALAEMIA + SEVERE METABOLIC ACIDOSIS",
None),
("RHABDOMYOLYSIS",
"(Myoglobinuria --> AKI + cardiac arrhythmias --> death if untreated)"),
],
anaesthetic_lines = [
"STOP volatile agent + succinylcholine immediately. Call for help.",
"Hyperventilate 100% O2 at 2-3x MV to blow off CO2.",
"DANTROLENE 2.5 mg/kg IV q5 min (max 10 mg/kg) -- blocks RYR1.",
"Active cooling: ice packs + cold IV saline -- target 38.5 deg C.",
"Treat K+: calcium gluconate + insulin-glucose + NaHCO3.",
"TIVA (propofol + remifentanil) in susceptible patients -- NO volatiles.",
"Stock min 36 vials dantrolene. Family screening via MHAUS protocol.",
]
)
c.save()
print("Saved:", path)
cd /home/daytona/workspace/dnb-pathophysiology && python3 sample_v6.py
SAMPLE v6 Topic15 MH
PDF Document · PDF
No not liking, this, get the same which i uploaded
~/dnb-pathophysiology/sample_v7.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm
from reportlab.pdfgen import canvas
W, H = A4
def wrap(text, max_chars=58):
words = text.split()
lines, cur = [], ""
for w in words:
if len(cur) + len(w) + 1 <= max_chars:
cur = (cur + " " + w).strip()
else:
if cur: lines.append(cur)
cur = w
if cur: lines.append(cur)
return lines
def draw_page(c, topic_num, topic_title, freq, flow_steps, anaesthetic_lines):
"""
flow_steps: list of plain strings (one per step, like the reference image)
anaesthetic_lines: list of plain strings
"""
# ── exact colours from reference image ───────────────────────────────────
C_TITLE = colors.HexColor("#4B5563") # grey title text (outside box)
C_BOX = colors.HexColor("#E8ECF0") # light grey box fill - same as reference
C_TEXT = colors.HexColor("#1C1C1E") # near-black body text
C_ARROW = colors.HexColor("#374151") # arrow colour
C_FREQ = colors.HexColor("#9CA3AF") # small freq text
C_ATITLE = colors.HexColor("#374151") # anaesthetic section title
C_ABOX = colors.HexColor("#E8ECF0") # same grey for anaesthetic box
FONT = "Courier" # monospace - exactly like reference
FONT_HB = "Helvetica-Bold" # for outside title only
FS = 12 # font size - matches reference
LH = 7.5*mm # line height
ARR_H = 7*mm # height of arrow row
PAD_V = 7*mm # vertical padding inside box
PAD_H = 7*mm # horizontal padding inside box
ARR_X = 45 # x position of arrow from left edge of box (indented like reference)
ML = 14*mm
MR = W - 14*mm
BW = MR - ML # box width
# White page
c.setFillColor(colors.white)
c.rect(0, 0, W, H, fill=1, stroke=0)
cur_y = H - 14*mm
# ── Title OUTSIDE box (grey bold, like reference) ─────────────────────────
c.setFillColor(C_TITLE)
c.setFont(FONT_HB, 13)
c.drawString(ML, cur_y, f"{topic_title.upper()} PATHOPHYSIOLOGY FLOWCHART")
cur_y -= 5.5*mm
# Frequency line
c.setFillColor(C_FREQ)
c.setFont("Helvetica", 8.5)
c.drawString(ML, cur_y, freq)
cur_y -= 7*mm
# ── Build all display rows ────────────────────────────────────────────────
rows = [] # ("text", str) | ("arrow",)
for i, step in enumerate(flow_steps):
for ln in wrap(step, 56):
rows.append(("text", ln))
if i < len(flow_steps) - 1:
rows.append(("arrow",))
# measure flow box height
flow_h = PAD_V + sum(LH if r[0]=="text" else ARR_H for r in rows) + PAD_V
# Draw flow box (no stroke/border - just fill, like reference)
c.setFillColor(C_BOX)
c.roundRect(ML, cur_y - flow_h, BW, flow_h, 6, fill=1, stroke=0)
# Draw rows
tx = ML + PAD_H
ty = cur_y - PAD_V
for (kind, *rest) in rows:
if kind == "text":
ty -= LH
c.setFillColor(C_TEXT)
c.setFont(FONT, FS)
c.drawString(tx, ty + 2, rest[0])
else: # arrow
# small ↓ indented ~like reference (about 8 chars in)
ty -= ARR_H
c.setFillColor(C_ARROW)
c.setFont(FONT, FS + 1)
c.drawString(tx + ARR_X, ty + 3, "v") # plain v as arrow - clean
# Actually draw a proper small down arrow
ax = tx + ARR_X + 4
top_a = ty + ARR_H * 0.55
bot_a = ty + 1
c.setStrokeColor(C_ARROW)
c.setLineWidth(1.3)
c.line(ax, top_a, ax, bot_a + 3)
p = c.beginPath()
p.moveTo(ax, bot_a)
p.lineTo(ax - 4, bot_a + 7)
p.lineTo(ax + 4, bot_a + 7)
p.close()
c.drawPath(p, fill=1, stroke=0)
cur_y -= flow_h + 8*mm
# ── Anaesthetic Implications ──────────────────────────────────────────────
# Title outside box
c.setFillColor(C_ATITLE)
c.setFont(FONT_HB, 11)
c.drawString(ML, cur_y, "ANAESTHETIC IMPLICATIONS")
cur_y -= 6*mm
# Build rows
a_rows = []
for pt in anaesthetic_lines:
for ln in wrap(pt, 56):
a_rows.append(ln)
abox_h = PAD_V + len(a_rows) * LH + PAD_V
c.setFillColor(C_ABOX)
c.roundRect(ML, cur_y - abox_h, BW, abox_h, 6, fill=1, stroke=0)
ty = cur_y - PAD_V
for ln in a_rows:
ty -= LH
c.setFillColor(C_TEXT)
c.setFont(FONT, FS)
c.drawString(tx, ty + 2, ln)
# ── Footer ────────────────────────────────────────────────────────────────
c.setFillColor(C_FREQ)
c.setFont("Helvetica", 7.5)
c.drawString(ML, 8*mm, f"Topic {topic_num} of 90 | DNB Anaesthesiology Pathophysiology | 2021-2025")
c.drawRightString(MR, 8*mm, "Exam Revision")
# ── SAMPLE: Topic 15 -- Malignant Hyperthermia ───────────────────────────────
path = "/home/daytona/workspace/dnb-pathophysiology/SAMPLE_v7_Topic15_MH.pdf"
c = canvas.Canvas(path, pagesize=A4)
draw_page(
c,
topic_num = 15,
topic_title = "Malignant Hyperthermia",
freq = "High Priority (3x) | Dec 2022, Dec 2025, Oct 2023",
flow_steps = [
"RYR1 gene mutation (chr 19q13) -- Autosomal Dominant",
"Volatile agent (halothane > sevo > iso > des) OR succinylcholine",
"RYR1 channel opens uncontrollably",
"Massive Ca2+ floods sarcoplasm from sarcoplasmic reticulum",
"Sustained muscle contraction + extreme ATP consumption",
"Anaerobic glycolysis --> lactic acidosis + heat generation",
"EtCO2 rises sharply (EARLIEST sign) + masseter spasm",
"Tachycardia + hypertension + generalised muscle rigidity",
"Hyperthermia (~1 deg C per 5 min) -- LATE sign",
"Hyperkalaemia + severe metabolic acidosis",
"Rhabdomyolysis --> myoglobinuria --> AKI + arrhythmias",
],
anaesthetic_lines = [
"STOP trigger agent + sux immediately. Call for help.",
"Hyperventilate 100% O2 at 2-3x minute volume.",
"DANTROLENE 2.5 mg/kg IV q5 min, max 10 mg/kg (blocks RYR1).",
"Active cooling: ice packs + cold IV saline, target 38.5 deg C.",
"Treat K+: calcium gluconate + insulin-glucose + NaHCO3.",
"Use TIVA (propofol + remifentanil) -- avoid all volatiles.",
"Stock min 36 vials dantrolene. Screen family (MHAUS).",
]
)
c.save()
print("Saved:", path)
cd /home/daytona/workspace/dnb-pathophysiology && python3 sample_v7.py
SAMPLE v7 Topic15 MH
PDF Document · PDF
Make Anesthesia implication in light blue color theme plus i dont want one pathophysiology in 2 paper , use a new page for a new topic and make pdf categories wise so 10 pdf will form
~/dnb-pathophysiology/engine.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm
from reportlab.pdfgen import canvas
W, H = A4
def wrap(text, max_chars=56):
words = text.split()
lines, cur = [], ""
for w in words:
if len(cur) + len(w) + 1 <= max_chars:
cur = (cur + " " + w).strip()
else:
if cur: lines.append(cur)
cur = w
if cur: lines.append(cur)
return lines
def draw_page(c, topic_num, topic_title, freq, flow_steps, anaesthetic_lines):
C_TITLE = colors.HexColor("#4B5563")
C_BOX = colors.HexColor("#E8ECF0") # grey flow box
C_ABOX = colors.HexColor("#DBEAFE") # light blue anaesthetic box
C_ATITLE = colors.HexColor("#1E40AF") # blue title for anaesthetic section
C_TEXT = colors.HexColor("#1C1C1E")
C_ARROW = colors.HexColor("#374151")
C_FREQ = colors.HexColor("#9CA3AF")
FONT = "Courier"
FONT_HB = "Helvetica-Bold"
FONT_H = "Helvetica"
FS = 11.5
LH = 7.2*mm
ARR_H = 6.8*mm
PAD_V = 7*mm
PAD_H = 7*mm
ARR_INDENT = 42 # px from left inner edge -- matches reference
ML = 14*mm
MR = W - 14*mm
BW = MR - ML
c.setFillColor(colors.white)
c.rect(0, 0, W, H, fill=1, stroke=0)
cur_y = H - 14*mm
# Title outside box
c.setFillColor(C_TITLE)
c.setFont(FONT_HB, 13)
c.drawString(ML, cur_y, f"{topic_title.upper()} PATHOPHYSIOLOGY FLOWCHART")
cur_y -= 5.5*mm
# Topic number + freq
c.setFillColor(C_FREQ)
c.setFont(FONT_H, 8.5)
c.drawString(ML, cur_y, f"Topic {topic_num} of 90 | {freq}")
cur_y -= 7*mm
# Build flow rows
rows = []
for i, step in enumerate(flow_steps):
for ln in wrap(step, 56):
rows.append(("text", ln))
if i < len(flow_steps) - 1:
rows.append(("arrow",))
flow_h = PAD_V + sum(LH if r[0]=="text" else ARR_H for r in rows) + PAD_V
c.setFillColor(C_BOX)
c.roundRect(ML, cur_y - flow_h, BW, flow_h, 6, fill=1, stroke=0)
tx = ML + PAD_H
ty = cur_y - PAD_V
for (kind, *rest) in rows:
if kind == "text":
ty -= LH
c.setFillColor(C_TEXT)
c.setFont(FONT, FS)
c.drawString(tx, ty + 2, rest[0])
else:
ty -= ARR_H
ax = tx + ARR_INDENT
top_a = ty + ARR_H * 0.72
bot_a = ty + 1.5
c.setStrokeColor(C_ARROW)
c.setFillColor(C_ARROW)
c.setLineWidth(1.3)
c.line(ax, top_a, ax, bot_a + 4)
p = c.beginPath()
p.moveTo(ax, bot_a)
p.lineTo(ax - 4, bot_a + 8)
p.lineTo(ax + 4, bot_a + 8)
p.close()
c.drawPath(p, fill=1, stroke=0)
cur_y -= flow_h + 8*mm
# Anaesthetic Implications title (outside box, blue)
c.setFillColor(C_ATITLE)
c.setFont(FONT_HB, 11)
c.drawString(ML, cur_y, "ANAESTHETIC IMPLICATIONS")
cur_y -= 6*mm
# Build anaesthetic rows
a_rows = []
for pt in anaesthetic_lines:
for ln in wrap(pt, 56):
a_rows.append(ln)
abox_h = PAD_V + len(a_rows) * LH + PAD_V
c.setFillColor(C_ABOX)
c.roundRect(ML, cur_y - abox_h, BW, abox_h, 6, fill=1, stroke=0)
ty = cur_y - PAD_V
for ln in a_rows:
ty -= LH
c.setFillColor(C_TEXT)
c.setFont(FONT, FS)
c.drawString(tx, ty + 2, ln)
# Footer
c.setFillColor(C_FREQ)
c.setFont(FONT_H, 7.5)
c.drawString(ML, 8*mm, "DNB Anaesthesiology Pathophysiology Flowcharts | 2021-2025 Question Bank")
c.drawRightString(MR, 8*mm, "Exam Revision Only")