Write a 50 marks answer for Postgraduate Anaesthesia exam on the topic of Management of Tachydysrrhythmia including Cardioversion and Defibrillation and its anaesthetic considerations (Shoe with the flowchart ) and convert it to pdf
mkdir -p /home/daytona/workspace/tachydysrhythmia && ls /home/daytona/workspace/
~/tachydysrhythmia/generate_pdf.py
#!/usr/bin/env python3
"""Generate a comprehensive PG Anaesthesia exam answer PDF on Tachydysrhythmia Management."""
from reportlab.lib.pagesizes import A4
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm, mm
from reportlab.lib import colors
from reportlab.platypus import (
SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
HRFlowable, KeepTogether
)
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus.flowables import Flowable
import io
# ── Document setup ──────────────────────────────────────────────────────────
OUTPUT = "/home/daytona/workspace/tachydysrhythmia/Tachydysrhythmia_Management_PG_Anaesthesia.pdf"
doc = SimpleDocTemplate(
OUTPUT,
pagesize=A4,
leftMargin=2*cm, rightMargin=2*cm,
topMargin=2*cm, bottomMargin=2*cm,
title="Management of Tachydysrhythmia – PG Anaesthesia Exam Answer",
)
W, H = A4
content_width = W - 4*cm # usable width
# ── Styles ───────────────────────────────────────────────────────────────────
styles = getSampleStyleSheet()
def make_style(name, parent='Normal', **kw):
s = ParagraphStyle(name, parent=styles[parent], **kw)
styles.add(s)
return s
title_style = make_style('ExamTitle', fontSize=16, textColor=colors.HexColor('#1a237e'),
leading=20, spaceAfter=4, alignment=TA_CENTER, fontName='Helvetica-Bold')
subtitle_style = make_style('ExamSubtitle', fontSize=11, textColor=colors.HexColor('#37474f'),
leading=14, spaceAfter=2, alignment=TA_CENTER)
marks_style = make_style('Marks', fontSize=11, textColor=colors.HexColor('#b71c1c'),
leading=14, alignment=TA_CENTER, spaceAfter=8)
h1_style = make_style('H1', fontSize=13, textColor=colors.HexColor('#1565c0'),
leading=16, spaceBefore=10, spaceAfter=4, fontName='Helvetica-Bold')
h2_style = make_style('H2', fontSize=11, textColor=colors.HexColor('#1976d2'),
leading=14, spaceBefore=8, spaceAfter=3, fontName='Helvetica-Bold')
h3_style = make_style('H3', fontSize=10, textColor=colors.HexColor('#0288d1'),
leading=13, spaceBefore=5, spaceAfter=2, fontName='Helvetica-Bold')
body_style = make_style('Body', fontSize=9.5, leading=14, spaceAfter=3, alignment=TA_JUSTIFY)
bullet_style = make_style('Bullet', fontSize=9.5, leading=13, leftIndent=14, spaceAfter=2,
bulletIndent=4, alignment=TA_LEFT)
table_hdr = make_style('TblHdr', fontSize=9, textColor=colors.white, fontName='Helvetica-Bold',
leading=12, alignment=TA_CENTER)
table_cell = make_style('TblCell', fontSize=8.5, leading=11, alignment=TA_LEFT)
table_cell_c = make_style('TblCellC', fontSize=8.5, leading=11, alignment=TA_CENTER)
small_style = make_style('Small', fontSize=8, leading=11, textColor=colors.HexColor('#546e7a'),
alignment=TA_CENTER, spaceAfter=4)
box_style = make_style('BoxText', fontSize=9.5, leading=13, alignment=TA_CENTER,
textColor=colors.HexColor('#1a237e'))
ref_style = make_style('Ref', fontSize=8, leading=11, textColor=colors.HexColor('#455a64'),
leftIndent=10, spaceAfter=1)
# ── Helper: horizontal rule ───────────────────────────────────────────────────
def hr(color='#1565c0', thickness=1, spaceBefore=2, spaceAfter=4):
return HRFlowable(width="100%", thickness=thickness,
color=colors.HexColor(color),
spaceBefore=spaceBefore, spaceAfter=spaceAfter)
# ── Flowchart rendered as a ReportLab table ───────────────────────────────────
def build_flowchart():
"""Build the ACLS Tachycardia with Pulse flowchart as a styled table."""
BLUE = colors.HexColor('#1565c0')
LBLUE = colors.HexColor('#e3f2fd')
RED = colors.HexColor('#b71c1c')
LRED = colors.HexColor('#ffebee')
GREEN = colors.HexColor('#1b5e20')
LGRN = colors.HexColor('#e8f5e9')
AMBER = colors.HexColor('#e65100')
LAMB = colors.HexColor('#fff3e0')
GREY = colors.HexColor('#37474f')
LGREY = colors.HexColor('#eceff1')
PURP = colors.HexColor('#4a148c')
LPURP = colors.HexColor('#f3e5f5')
TEAL = colors.HexColor('#004d40')
LTEAL = colors.HexColor('#e0f2f1')
fc_style = ParagraphStyle('FC', fontSize=8.5, leading=12, alignment=TA_CENTER)
fc_bold = ParagraphStyle('FCB', fontSize=8.5, leading=12, alignment=TA_CENTER,
fontName='Helvetica-Bold')
fc_small = ParagraphStyle('FCS', fontSize=7.5, leading=11, alignment=TA_CENTER)
def cell(txt, bold=False, color=colors.black, bg=colors.white, small=False):
s = fc_bold if bold else (fc_small if small else fc_style)
return (Paragraph(f'<font color="{color.hexval() if hasattr(color,"hexval") else "#000000"}">{txt}</font>', s), bg)
arrow = Paragraph('<b>▼</b>', ParagraphStyle('Arr', fontSize=11, alignment=TA_CENTER))
rows = []
def add_box(text, bold=False, bg=LBLUE, fg=BLUE, colspan=1):
rows.append([Paragraph(f'<font color="{fg.hexval() if hasattr(fg,"hexval") else "#1565c0"}">{"<b>" if bold else ""}{text}{"</b>" if bold else ""}</font>',
fc_bold if bold else fc_style)])
# We'll build as a single-column table of alternating box+arrow rows
box_data = []
def add(txt, bg, fg=colors.HexColor('#000000'), bold=False):
s = fc_bold if bold else fc_style
col = fg.hexval() if hasattr(fg, 'hexval') else '#000000'
box_data.append(([Paragraph(f'<font color="{col}">{"<b>" if bold else ""}{txt}{"</b>" if bold else ""}</font>', s)], bg))
def add_arrow():
box_data.append(([arrow], colors.white))
add("PATIENT WITH TACHYCARDIA (HR > 100 bpm)", BLUE, colors.white, bold=True)
add_arrow()
add("Assess & monitor: O₂ sat, IV access, 12-lead ECG, vital signs", LGREY)
add_arrow()
add("UNSTABLE? (Hypotension | AMS | Ischaemic chest pain | Acute HF | Shock)", LRED, RED, bold=True)
add_arrow()
# Branch: Unstable vs Stable
branch_data = [
[
Paragraph('<b><font color="#b71c1c">YES – UNSTABLE</font></b>', fc_bold),
Paragraph('<b><font color="#1b5e20">NO – STABLE</font></b>', fc_bold)
]
]
branch_table = Table(branch_data, colWidths=[content_width*0.45, content_width*0.45])
branch_table.setStyle(TableStyle([
('BOX', (0,0), (0,0), 1.5, RED),
('BOX', (1,0), (1,0), 1.5, GREEN),
('BACKGROUND', (0,0), (0,0), LRED),
('BACKGROUND', (1,0), (1,0), LGRN),
('ALIGN', (0,0), (-1,-1), 'CENTER'),
('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
('TOPPADDING', (0,0), (-1,-1), 6),
('BOTTOMPADDING', (0,0), (-1,-1), 6),
('COLPADDING', (0,0), (-1,-1), 4),
('LEFTPADDING', (0,0), (-1,-1), 4),
('RIGHTPADDING', (0,0), (-1,-1), 4),
]))
# Left branch (Unstable)
unstable = [
Paragraph('<b><font color="#b71c1c">IMMEDIATE SYNCHRONISED CARDIOVERSION</font></b>', fc_bold),
Paragraph('• Sedate/anaesthetise (Propofol / Midazolam + Fentanyl)\n• Airway + resuscitation equipment ready\n• Synchronise mode ON (except polymorphic VT/VF)', fc_small),
Paragraph('<b>Energy (Biphasic):</b>\nAF: 120–200 J | Flutter/SVT: 50–100 J\nMonomorphic VT: 100 J | Polymorphic VT → DEFIBRILLATE', fc_small),
]
# Right branch (Stable)
stable = [
Paragraph('<b><font color="#1b5e20">CHARACTERISE THE RHYTHM</font></b>', fc_bold),
Paragraph('QRS narrow (<0.12 s) or wide (≥0.12 s)?', fc_small),
]
branch2_data = [
[
Table([[p] for p in unstable],
colWidths=[content_width*0.45],
style=TableStyle([
('BOX', (0,0), (-1,-1), 1, RED),
('BACKGROUND', (0,0), (-1,-1), LRED),
('ALIGN', (0,0), (-1,-1), 'CENTER'),
('TOPPADDING', (0,0), (-1,-1), 4),
('BOTTOMPADDING', (0,0), (-1,-1), 4),
('LEFTPADDING', (0,0), (-1,-1), 4),
('RIGHTPADDING', (0,0), (-1,-1), 4),
])),
Table([[p] for p in stable],
colWidths=[content_width*0.45],
style=TableStyle([
('BOX', (0,0), (-1,-1), 1, GREEN),
('BACKGROUND', (0,0), (-1,-1), LGRN),
('ALIGN', (0,0), (-1,-1), 'CENTER'),
('TOPPADDING', (0,0), (-1,-1), 4),
('BOTTOMPADDING', (0,0), (-1,-1), 4),
('LEFTPADDING', (0,0), (-1,-1), 4),
('RIGHTPADDING', (0,0), (-1,-1), 4),
])),
]
]
branch2_table = Table(branch2_data, colWidths=[content_width*0.47, content_width*0.47],
hAlign='CENTER')
branch2_table.setStyle(TableStyle([
('ALIGN', (0,0), (-1,-1), 'CENTER'),
('VALIGN', (0,0), (-1,-1), 'TOP'),
('COLPADDING', (0,0), (-1,-1), 3),
]))
# Stable pathway detail table
stable_detail = [
[Paragraph('<b>NARROW QRS</b>', ParagraphStyle('NQ', fontSize=8, alignment=TA_CENTER, fontName='Helvetica-Bold')),
Paragraph('<b>WIDE QRS</b>', ParagraphStyle('WQ', fontSize=8, alignment=TA_CENTER, fontName='Helvetica-Bold'))],
[Paragraph('Regular:\n• Vagal maneuvers\n• Adenosine 6mg IV\n (repeat 12mg x2)\n• AV nodal blockers\n (Verapamil/Diltiazem/BB)\nIrregular (AF/Flutter):\n• Rate control: Diltiazem,\n Metoprolol, Digoxin\n• Rhythm control:\n Amiodarone, Flecainide\n• Anticoagulation',
ParagraphStyle('NQD', fontSize=7.5, leading=11, alignment=TA_LEFT)),
Paragraph('Regular (monomorphic VT):\n• If stable: Amiodarone\n 150mg IV over 10 min\n• Procainamide / Sotalol\n• If deteriorates → Sync\n cardioversion\nIrregular (polymorphic VT/\nTorsades de Pointes):\n• Mg sulphate 2g IV\n• Correct electrolytes\n• If pulseless → CPR +\n DEFIBRILLATION',
ParagraphStyle('WQD', fontSize=7.5, leading=11, alignment=TA_LEFT))],
]
stable_detail_tbl = Table(stable_detail,
colWidths=[content_width*0.44, content_width*0.44],
hAlign='CENTER')
stable_detail_tbl.setStyle(TableStyle([
('BOX', (0,0), (-1,-1), 1, GREY),
('INNERGRID', (0,0), (-1,-1), 0.5, GREY),
('BACKGROUND', (0,0), (-1,0), LBLUE),
('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'),
('ALIGN', (0,0), (-1,0), 'CENTER'),
('TOPPADDING', (0,0), (-1,-1), 4),
('BOTTOMPADDING', (0,0), (-1,-1), 4),
('LEFTPADDING', (0,0), (-1,-1), 4),
('RIGHTPADDING', (0,0), (-1,-1), 4),
]))
# VF / Pulseless VT sub-flow
vf_data = [
[Paragraph('<b><font color="white">VF / PULSELESS VT – DEFIBRILLATION PATHWAY</font></b>',
ParagraphStyle('VFH', fontSize=9, alignment=TA_CENTER, fontName='Helvetica-Bold',
textColor=colors.white))],
[Paragraph('CPR 2 min → Defibrillate 200 J (biphasic) → CPR 2 min → Reassess\n'
'Epinephrine 1mg IV q3–5 min | Amiodarone 300mg IV (1st) / 150mg (2nd)\n'
'Consider reversible causes: 4Hs & 4Ts\n'
'Consider double sequential defibrillation if refractory',
ParagraphStyle('VFD', fontSize=8, leading=12, alignment=TA_CENTER))],
]
vf_table = Table(vf_data, colWidths=[content_width*0.9], hAlign='CENTER')
vf_table.setStyle(TableStyle([
('BACKGROUND', (0,0), (0,0), RED),
('BACKGROUND', (0,1), (0,1), LRED),
('BOX', (0,0), (-1,-1), 1.5, RED),
('TOPPADDING', (0,0), (-1,-1), 5),
('BOTTOMPADDING', (0,0), (-1,-1), 5),
('LEFTPADDING', (0,0), (-1,-1), 6),
('RIGHTPADDING', (0,0), (-1,-1), 6),
]))
elements = []
# Build the box_data rows into a table
for row_content, bg in box_data:
t = Table([[row_content[0]]], colWidths=[content_width * 0.88], hAlign='CENTER')
bg_color = bg
if bg == colors.white: # arrow
t.setStyle(TableStyle([('ALIGN', (0,0), (-1,-1), 'CENTER'),
('TOPPADDING', (0,0), (-1,-1), 1),
('BOTTOMPADDING', (0,0), (-1,-1), 1)]))
else:
t.setStyle(TableStyle([
('BOX', (0,0), (-1,-1), 1.2, BLUE),
('BACKGROUND', (0,0), (-1,-1), bg_color),
('ALIGN', (0,0), (-1,-1), 'CENTER'),
('TOPPADDING', (0,0), (-1,-1), 5),
('BOTTOMPADDING', (0,0), (-1,-1), 5),
('LEFTPADDING', (0,0), (-1,-1), 6),
('RIGHTPADDING', (0,0), (-1,-1), 6),
]))
elements.append(t)
elements.append(Spacer(1, 2*mm))
elements.append(branch_table)
elements.append(Spacer(1, 2*mm))
elements.append(branch2_table)
elements.append(Spacer(1, 4*mm))
elements.append(Paragraph('<b>STABLE – Detailed Management</b>',
ParagraphStyle('SDH', fontSize=9, alignment=TA_CENTER,
fontName='Helvetica-Bold',
textColor=colors.HexColor('#1565c0'))))
elements.append(Spacer(1, 1*mm))
elements.append(stable_detail_tbl)
elements.append(Spacer(1, 4*mm))
elements.append(vf_table)
return elements
# ── Drug table helper ─────────────────────────────────────────────────────────
def drug_table(headers, rows, col_widths=None):
data = [[Paragraph(h, table_hdr) for h in headers]]
for r in rows:
data.append([Paragraph(str(c), table_cell) for c in r])
if col_widths is None:
col_widths = [content_width / len(headers)] * len(headers)
t = Table(data, colWidths=col_widths, repeatRows=1)
t.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,0), colors.HexColor('#1565c0')),
('TEXTCOLOR', (0,0), (-1,0), colors.white),
('INNERGRID', (0,0), (-1,-1), 0.4, colors.HexColor('#b0bec5')),
('BOX', (0,0), (-1,-1), 1, colors.HexColor('#1565c0')),
('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.HexColor('#e3f2fd'), colors.white]),
('TOPPADDING', (0,0), (-1,-1), 4),
('BOTTOMPADDING',(0,0), (-1,-1), 4),
('LEFTPADDING', (0,0), (-1,-1), 4),
('RIGHTPADDING',(0,0), (-1,-1), 4),
('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'),
]))
return t
# ── Build document elements ───────────────────────────────────────────────────
story = []
# ── Cover / Title block ───────────────────────────────────────────────────────
story.append(Spacer(1, 0.3*cm))
story.append(Paragraph("POSTGRADUATE ANAESTHESIA EXAMINATION", subtitle_style))
story.append(Spacer(1, 2*mm))
story.append(hr('#1565c0', 2))
story.append(Paragraph("Management of Tachydysrhythmia", title_style))
story.append(Paragraph("Including Cardioversion, Defibrillation & Anaesthetic Considerations", subtitle_style))
story.append(hr('#1565c0', 2))
story.append(Paragraph("[Total Marks: 50]", marks_style))
story.append(Spacer(1, 0.3*cm))
# ── 1. Introduction ───────────────────────────────────────────────────────────
story.append(Paragraph("1. INTRODUCTION & DEFINITION", h1_style))
story.append(hr('#bbdefb', 0.5))
story.append(Paragraph(
"Tachydysrhythmia is defined as any cardiac rhythm disturbance with a ventricular rate exceeding "
"100 beats/min. Clinically significant haemodynamic compromise is more likely when heart rate "
"exceeds 150 bpm. From an anaesthetic perspective, tachydysrhythmias may present pre-operatively, "
"intra-operatively, or post-operatively and their management demands rapid, systematic assessment "
"guided by Advanced Cardiac Life Support (ACLS) algorithms. The underlying principle is: "
"<b>haemodynamically UNSTABLE → immediate electrical therapy; STABLE → pharmacological "
"therapy guided by rhythm characterisation.</b>", body_style))
story.append(Spacer(1, 2*mm))
# ── 2. Classification ─────────────────────────────────────────────────────────
story.append(Paragraph("2. CLASSIFICATION OF TACHYDYSRHYTHMIAS", h1_style))
story.append(hr('#bbdefb', 0.5))
classif_rows = [
["Narrow QRS (<0.12 s) – Regular",
"Sinus tachycardia, AVNRT, AVRT (orthodromic), Atrial tachycardia, Junctional tachycardia"],
["Narrow QRS (<0.12 s) – Irregular",
"Atrial fibrillation (AF), Atrial flutter with variable block, Multifocal atrial tachycardia (MAT)"],
["Wide QRS (≥0.12 s) – Regular",
"Ventricular tachycardia (VT) – monomorphic, SVT with aberrancy, Pre-excitation (WPW), Paced rhythm"],
["Wide QRS (≥0.12 s) – Irregular",
"Polymorphic VT / Torsades de Pointes, AF with aberrancy, AF with WPW, Ventricular fibrillation (VF)"],
]
story.append(drug_table(["Category", "Arrhythmia Types"], classif_rows,
col_widths=[content_width*0.32, content_width*0.68]))
story.append(Spacer(1, 3*mm))
# ── 3. Pathophysiology ────────────────────────────────────────────────────────
story.append(Paragraph("3. PATHOPHYSIOLOGY", h1_style))
story.append(hr('#bbdefb', 0.5))
story.append(Paragraph("Three main electrophysiological mechanisms underlie tachydysrhythmias:", body_style))
for b in [
"<b>Reentry:</b> Most common mechanism. A unidirectional block and a zone of slow conduction create a circuit (e.g., AVNRT, atrial flutter, monomorphic VT in ischaemic cardiomyopathy).",
"<b>Enhanced automaticity:</b> Abnormal spontaneous depolarisation of ectopic foci (e.g., ectopic atrial tachycardia, accelerated junctional rhythm).",
"<b>Triggered activity:</b> Early or delayed after-depolarisations. Early after-depolarisations cause Torsades de Pointes; delayed after-depolarisations cause digitalis-toxic arrhythmias.",
]:
story.append(Paragraph(f"• {b}", bullet_style))
story.append(Spacer(1, 3*mm))
# ── 4. ACLS-Based Management Algorithm (Flowchart) ───────────────────────────
story.append(Paragraph("4. MANAGEMENT ALGORITHM – TACHYCARDIA WITH PULSE (2020 ACLS)", h1_style))
story.append(hr('#bbdefb', 0.5))
story.append(Paragraph(
"The following flowchart is based on the 2020 AHA/ACLS Tachycardia with Pulse Algorithm "
"(Miller's Anaesthesia 10e, Ch. 82; Braunwald's Heart Disease, Ch. 67 & 69).",
small_style))
story.append(Spacer(1, 2*mm))
story.extend(build_flowchart())
story.append(Spacer(1, 3*mm))
# ── 5. Cardioversion ──────────────────────────────────────────────────────────
story.append(Paragraph("5. CARDIOVERSION", h1_style))
story.append(hr('#bbdefb', 0.5))
story.append(Paragraph("5.1 Definition & Principle", h2_style))
story.append(Paragraph(
"Cardioversion is the delivery of a <b>synchronised</b> DC shock timed to the R wave of the ECG. "
"Synchronisation prevents shock delivery during the vulnerable T-wave period (relative refractory "
"period), which could precipitate VF. It terminates tachyarrhythmias by depolarising the reentrant "
"circuit simultaneously, allowing the sinoatrial node to reassert dominance.",
body_style))
story.append(Paragraph("5.2 Indications", h2_style))
for b in [
"Haemodynamically unstable SVT / AF / Atrial flutter / Monomorphic VT with pulse",
"Stable monomorphic VT refractory to pharmacotherapy",
"Elective cardioversion for AF (rhythm control strategy)",
"Rate-related cardiovascular compromise (AMS, hypotension, ischaemia, acute HF)",
]:
story.append(Paragraph(f"• {b}", bullet_style))
story.append(Paragraph("5.3 Contraindications / Precautions", h2_style))
for b in [
"Digitalis toxicity (risk of refractory VF) – use low energy, correct toxicity first",
"Hypokalaemia – correct before cardioversion",
"LA thrombus on TOE – postpone cardioversion (minimum 3 weeks therapeutic anticoagulation)",
"Pacemaker / ICD – position pads ≥8 cm from device; interrogate device post-procedure",
]:
story.append(Paragraph(f"• {b}", bullet_style))
story.append(Paragraph("5.4 Procedure", h2_style))
for b in [
"<b>Electrode position:</b> Antero-posterior (preferred) or antero-lateral. Adhesive gel pads preferred. If initial position fails, try right parasternal / lateral configuration.",
"<b>Synchronisation:</b> Ensure R-wave sensing is adequate on monitor BEFORE pressing 'Sync'.",
"<b>Energy (Biphasic):</b> AF 120–200 J (start high); Atrial flutter/SVT 50–100 J; Monomorphic VT 100 J; Polymorphic VT – treat as VF (unsynchronised).",
"<b>Escalation:</b> If initial shock fails, increase energy stepwise to maximum (360 J biphasic). Apply manual pressure to electrode to reduce transthoracic impedance.",
"<b>Ibutilide pre-treatment:</b> IV ibutilide facilitates cardioversion when shocks alone fail (Fuster and Hurst's The Heart, 15e).",
]:
story.append(Paragraph(f"• {b}", bullet_style))
story.append(Spacer(1, 3*mm))
# Energy table
story.append(Paragraph("5.5 Recommended Energy Levels", h2_style))
energy_rows = [
["Atrial Fibrillation", "120–200 J", "360 J", "Biphasic preferred; start high"],
["Atrial Flutter / SVT", "50–100 J", "200–360 J", "Escalate in steps"],
["Monomorphic VT (pulse+)", "100 J", "200–360 J", "Sync mode ON"],
["Polymorphic VT / VF", "200 J", "360 J", "DEFIBRILLATION – Sync OFF"],
["Paediatric", "0.5–1 J/kg (1st)", "2 J/kg", "Max 10 J/kg"],
]
story.append(drug_table(
["Rhythm", "Initial Energy (Biphasic)", "Escalation", "Notes"],
energy_rows,
col_widths=[content_width*0.22, content_width*0.22, content_width*0.2, content_width*0.36]
))
story.append(Spacer(1, 3*mm))
# ── 6. Defibrillation ────────────────────────────────────────────────────────
story.append(Paragraph("6. DEFIBRILLATION", h1_style))
story.append(hr('#bbdefb', 0.5))
story.append(Paragraph("6.1 Definition & Principle", h2_style))
story.append(Paragraph(
"Defibrillation is the delivery of an <b>unsynchronised</b> high-energy DC shock to terminate "
"ventricular fibrillation (VF) or pulseless ventricular tachycardia (pVT). The shock "
"depolarises a critical mass of myocardium, interrupting multiple fibrillatory wavefronts and "
"allowing the sinoatrial node to resume pacemaker activity. Biphasic waveforms have supplanted "
"monophasic waveforms due to lower defibrillation thresholds and less post-shock myocardial "
"dysfunction (Braunwald's Heart Disease, Ch. 69).",
body_style))
story.append(Paragraph("6.2 Indications", h2_style))
for b in [
"Ventricular fibrillation (VF)",
"Pulseless ventricular tachycardia (pVT)",
"Polymorphic VT with haemodynamic collapse",
]:
story.append(Paragraph(f"• {b}", bullet_style))
story.append(Paragraph("6.3 Procedure (In-Hospital Cardiac Arrest)", h2_style))
for i, b in enumerate([
"<b>Confirm VF/pVT</b> on monitor (check lead connections, pulse check max 10 sec).",
"<b>Charge defibrillator</b> to 200 J (biphasic) while CPR continues.",
"<b>Clear + deliver shock</b> – confirm 'all clear', deliver shock.",
"<b>Resume CPR immediately</b> (2 min, 5 cycles 30:2 or continuous with airway).",
"<b>Reassess rhythm</b> – if VF persists, repeat shock at same or higher energy.",
"<b>Epinephrine 1 mg IV</b> every 3–5 min (after 2nd shock).",
"<b>Amiodarone 300 mg IV</b> after 3rd shock; repeat 150 mg x1 if needed.",
"<b>Vasopressin 40 IU IV</b> – alternative to epinephrine.",
"Treat reversible causes: <b>4 H's</b> (Hypoxia, Hypo/Hyperkalemia, Hypothermia, Hypovolaemia) & <b>4 T's</b> (Tension pneumothorax, Tamponade, Toxins, Thrombosis).",
"Consider <b>double sequential defibrillation</b> for refractory VF (two defibrillators, slightly staggered shocks – emerging evidence).",
], start=1):
story.append(Paragraph(f"{i}. {b}", bullet_style))
story.append(Spacer(1, 3*mm))
# ── 7. Pharmacological Management ────────────────────────────────────────────
story.append(Paragraph("7. PHARMACOLOGICAL MANAGEMENT OF TACHYDYSRHYTHMIAS", h1_style))
story.append(hr('#bbdefb', 0.5))
drug_rows = [
["Adenosine", "6 mg rapid IV bolus (repeat 12 mg x2)", "Narrow complex regular SVT (1st line)", "Bronchospasm, transient AV block, chest pain; SHORT t½ (10 sec)"],
["Amiodarone", "150 mg IV over 10 min, then 1 mg/min x6h", "VT (stable), AF rate/rhythm control, refractory VF", "Hypotension, phlebitis; avoid in QT prolongation, thyroid disease"],
["Adenosine", "0.1–0.2 mg/kg IV (paeds)", "Paediatric SVT", "Same as above"],
["Procainamide", "20–50 mg/min IV (max 17 mg/kg)", "Monomorphic VT (haemodynamically stable), AF in WPW", "Hypotension, QRS widening; avoid in renal failure (NAPA accumulation)"],
["Sotalol", "1–1.5 mg/kg IV over 5 min", "Monomorphic VT, AF/Flutter", "QT prolongation, torsades risk; caution in HF"],
["Lidocaine", "1–1.5 mg/kg IV bolus", "Monomorphic VT (2nd line after amiodarone)", "CNS toxicity; less effective than amiodarone"],
["Verapamil", "2.5–5 mg IV over 2 min", "Stable narrow QRS SVT (after adenosine failure), Fascicular VT", "NEVER in WPW with AF, HF, wide QRS tachycardia"],
["Metoprolol", "5 mg IV q5 min (max 15 mg)", "Sinus tachycardia, AF/flutter rate control, AVNRT", "Bronchospasm, bradycardia, hypotension"],
["Diltiazem", "0.25 mg/kg IV over 2 min", "AF/Flutter rate control, AVNRT", "Hypotension, negative inotropy; avoid in accessory pathway"],
["Digoxin", "0.5 mg IV (loading)", "AF rate control in HFrEF", "Narrow TI; toxicity → bidirectional VT, AV block"],
["Magnesium sulphate", "2 g IV over 10 min", "Torsades de Pointes, digoxin toxicity VT, hypoMg VT", "Hypotension, respiratory depression at toxic levels"],
["Ibutilide", "1 mg IV over 10 min", "Facilitate cardioversion of AF/Flutter", "QT prolongation, Torsades (2–4%); monitor 4h post-dose"],
["Flecainide", "2 mg/kg IV (max 150 mg)", "AF cardioversion (pill-in-pocket), AVNRT", "CONTRAINDICATED in structural heart disease (proarrhythmic)"],
]
story.append(drug_table(
["Drug", "Dose", "Indications", "Key Considerations"],
drug_rows,
col_widths=[content_width*0.14, content_width*0.22, content_width*0.3, content_width*0.34]
))
story.append(Spacer(1, 3*mm))
# ── 8. Anaesthetic Considerations ───────────────────────────────────────────
story.append(Paragraph("8. ANAESTHETIC CONSIDERATIONS FOR CARDIOVERSION & DEFIBRILLATION", h1_style))
story.append(hr('#bbdefb', 0.5))
story.append(Paragraph("8.1 Pre-procedure Assessment", h2_style))
for b in [
"<b>Cardiac evaluation:</b> ECG, echocardiography (LV/RV function, valvular disease, LA thrombus), TOE if AF >48 h or CHA₂DS₂-VASc ≥2 (men) / ≥3 (women).",
"<b>Anticoagulation status:</b> INR ≥2.0 for ≥3 weeks before elective cardioversion; continue 4 weeks post-procedure.",
"<b>Electrolyte check:</b> K⁺ (target 4.0–5.0 mEq/L), Mg²⁺, Ca²⁺ corrected before cardioversion.",
"<b>Medications:</b> Digoxin level (withhold if toxic); antiarrhythmic pre-loading may be considered for high-risk AF patients.",
"<b>Fasting:</b> Standard ASA fasting guidelines (6 h solids, 2 h clear fluids) for elective procedure. In emergencies, treat as full stomach – RSI if needed.",
"<b>Implanted devices:</b> ICD – disable anti-tachycardia therapy before cardioversion; reactivate post-procedure. Place pads ≥8 cm from device pulse generator.",
"<b>Respiratory:</b> Supplemental O₂, ensure patent airway; have BVM + intubation equipment ready.",
]:
story.append(Paragraph(f"• {b}", bullet_style))
story.append(Paragraph("8.2 Sedation / Anaesthesia for Elective Cardioversion", h2_style))
story.append(Paragraph(
"Adequate sedation is mandatory before cardioversion in conscious patients "
"(Fuster and Hurst's The Heart, 15e). The goal is rapid-onset, short-acting "
"sedation / general anaesthesia preserving airway reflexes:",
body_style))
sedation_rows = [
["Propofol", "0.5–1.5 mg/kg IV titrated", "Rapid onset (30 s), short duration, antiemetic; risk of apnoea/hypotension – have vasopressors ready; PREFERRED agent"],
["Midazolam", "1–2.5 mg IV ± Fentanyl 1 µg/kg", "Anxiolysis + analgesia; longer duration; reversal with flumazenil; suitable if haemodynamically compromised"],
["Etomidate", "0.1–0.3 mg/kg IV", "Haemodynamic stability (ideal for poor LV function); myoclonus; adrenal suppression with repeated use"],
["Ketamine", "1–2 mg/kg IV", "Maintains airway reflexes, haemodynamic stability; increases HR/BP (avoid in ischaemic VT); useful in hypotensive patients"],
["Remifentanil", "0.5–1 µg/kg IV (slow)", "Opioid supplement for analgesia; ultra-short; risk of apnoea – have ventilation ready"],
["Dexmedetomidine", "0.5–1 µg/kg over 10 min", "Sedation without respiratory depression; adjunct; slower onset; haemodynamic effects"],
]
story.append(drug_table(
["Agent", "Dose", "Comments"],
sedation_rows,
col_widths=[content_width*0.15, content_width*0.28, content_width*0.57]
))
story.append(Spacer(1, 3*mm))
story.append(Paragraph("8.3 Intra-procedure Monitoring", h2_style))
for b in [
"Continuous 5-lead ECG (ensure R-wave synchronisation confirmed before shock)",
"Non-invasive BP every 1–3 minutes; arterial line for haemodynamically unstable patients",
"Pulse oximetry (SpO₂) – supplemental O₂ via face mask/nasal cannula",
"IV access – large bore peripheral cannula (min 18G); defibrillator pads applied and charged",
"Capnography if intubated or deep sedation protocol used",
]:
story.append(Paragraph(f"• {b}", bullet_style))
story.append(Paragraph("8.4 Intra-operative Tachydysrhythmias – Special Considerations", h2_style))
for b in [
"<b>Sinus tachycardia (most common):</b> Treat the cause – light anaesthesia, pain, hypovolaemia, hypoxia, hypercapnia, hyperthermia, thyrotoxicosis, malignant hyperthermia.",
"<b>AF (new onset intraoperative):</b> Identify and treat precipitants; rate control with metoprolol or diltiazem IV; cardioversion if haemodynamically compromised.",
"<b>SVT:</b> Vagal manoeuvres (carotid sinus massage while under GA is NOT recommended due to stroke risk); adenosine IV first-line.",
"<b>VT:</b> If haemodynamically stable – amiodarone; treat electrolytes and ischaemia; if unstable – synchronised cardioversion.",
"<b>Pacemaker / ICD interaction:</b> Diathermy (electrocautery) can inhibit pacemakers or trigger ICD shocks. Use bipolar diathermy; place neutral electrode away from cardiac devices; magnet placement inhibits ICD therapy (use only if no cardiologist available).",
"<b>Volatile anaesthetics:</b> Halothane (now historical) sensitises myocardium to catecholamines (adrenaline use limit: 1–2 µg/kg); isoflurane, sevoflurane, desflurane generally safe but can prolong QTc.",
"<b>Drug interactions:</b> Amiodarone + volatile agents → hypotension; suxamethonium → hyperkalaemia in susceptible patients may provoke VF.",
]:
story.append(Paragraph(f"• {b}", bullet_style))
story.append(Paragraph("8.5 Post-procedure Care", h2_style))
for b in [
"Oxygen supplementation until fully awake (SpO₂ >95%)",
"Continuous cardiac monitoring for minimum 1–4 hours post-cardioversion (ibutilide: 4 h)",
"12-lead ECG to confirm sinus rhythm and detect ischaemia",
"Anticoagulation: Continue for minimum 4 weeks post-cardioversion (atrial stunning)",
"Assess for skin burns at electrode sites (treat with topical hydrocortisone)",
"ICD/pacemaker re-interrogation post-procedure",
"Watch for hypotension, respiratory depression, aspiration if sedation used",
"Discharge: Meet modified Aldrete score ≥9; escort required; driving restrictions post-sedation",
]:
story.append(Paragraph(f"• {b}", bullet_style))
story.append(Spacer(1, 3*mm))
# ── 9. Special Situations ────────────────────────────────────────────────────
story.append(Paragraph("9. SPECIAL ANAESTHETIC SCENARIOS", h1_style))
story.append(hr('#bbdefb', 0.5))
story.append(Paragraph("9.1 WPW Syndrome (Pre-excitation) with AF", h2_style))
story.append(Paragraph(
"In WPW + AF with rapid ventricular response via accessory pathway (delta waves, wide irregular QRS): "
"AV nodal blockers (adenosine, verapamil, diltiazem, digoxin, amiodarone IV) are <b>CONTRAINDICATED</b> "
"as they can paradoxically accelerate conduction via accessory pathway, precipitating VF. "
"<b>Treatment: DC cardioversion (first-line); procainamide IV (haemodynamically stable).</b>",
body_style))
story.append(Paragraph("9.2 Torsades de Pointes", h2_style))
for b in [
"Caused by QT prolongation (congenital LQTS, drugs, hypokalaemia, hypomagnesaemia)",
"Treatment: IV Magnesium sulphate 2 g over 1–2 min (first-line)",
"Correct K⁺ (target >4.5 mEq/L), Mg²⁺ (target >2 mEq/L)",
"Discontinue QT-prolonging drugs",
"If sustained/haemodynamically unstable: defibrillation",
"Overdrive pacing (100–120 bpm) or isoproterenol infusion to shorten QT",
]:
story.append(Paragraph(f"• {b}", bullet_style))
story.append(Paragraph("9.3 Pregnancy", h2_style))
story.append(Paragraph(
"Cardioversion and defibrillation are safe in pregnancy when indicated. "
"Left lateral tilt (15–30°) to avoid aortocaval compression. "
"Foetal heart rate monitoring recommended; foetal tachycardia or DC conversion of "
"the foetus has not been reported with standard energy levels. "
"Propofol / etomidate may be used for sedation; avoid benzodiazepines (Category D).",
body_style))
story.append(Paragraph("9.4 Paediatric Cardioversion / Defibrillation", h2_style))
for b in [
"Synchronised cardioversion: 0.5–1 J/kg; escalate to 2 J/kg if no response",
"Defibrillation (VF/pVT): 2 J/kg initial; subsequent 4 J/kg (max 10 J/kg or adult dose)",
"Ketamine preferred for sedation in paediatrics",
"Paediatric pads for <10 kg; adult pads for >10 kg",
]:
story.append(Paragraph(f"• {b}", bullet_style))
story.append(Spacer(1, 3*mm))
# ── 10. Complications ────────────────────────────────────────────────────────
story.append(Paragraph("10. COMPLICATIONS OF CARDIOVERSION / DEFIBRILLATION", h1_style))
story.append(hr('#bbdefb', 0.5))
comp_rows = [
["Thromboembolism", "Atrial thrombus dislodgement; incidence 0–7% without anticoagulation; prevented by 3-week pre-cardioversion anticoagulation"],
["Arrhythmias", "Bradycardia, AV block, sinus arrest (seconds to minutes); ventricular arrhythmias (if unsynchronised or digitalis toxicity)"],
["Myocardial injury", "Transient ST changes, CK-MB rise; rare with biphasic waveforms and appropriate energy"],
["Skin burns", "At electrode sites; use gel pads, avoid direct skin contact with metal"],
["Pulmonary oedema", "Flash pulmonary oedema post-cardioversion due to LV dysfunction / atrial stunning"],
["Device malfunction", "ICD inappropriate shocks or sensing failure; always interrogate post-procedure"],
["Sedation complications", "Apnoea, aspiration, hypotension, laryngospasm; have resuscitation equipment ready"],
]
story.append(drug_table(
["Complication", "Description / Prevention"],
comp_rows,
col_widths=[content_width*0.22, content_width*0.78]
))
story.append(Spacer(1, 3*mm))
# ── 11. Anaesthetic drugs and arrhythmia interaction ─────────────────────────
story.append(Paragraph("11. EFFECTS OF ANAESTHETIC AGENTS ON CARDIAC CONDUCTION", h1_style))
story.append(hr('#bbdefb', 0.5))
drug_arrhythmia_rows = [
["Propofol", "Mild QT shortening; bradycardia at induction; PRIS can cause VF", "Overall safe; useful for sedation"],
["Thiopentone", "Rarely tachycardia at induction", "Largely withdrawn; historical"],
["Ketamine", "↑ HR and BP (sympathomimetic); may worsen ischaemia-induced VT", "Useful in haemodynamic compromise; avoid in catecholamine depletion"],
["Etomidate", "Minimal cardiac effects; safest induction agent for poor LV", "Myoclonus; adrenal suppression"],
["Suxamethonium", "Bradycardia (especially paediatrics); ↑K⁺ in burns/denervation → VF", "Premedicate with atropine in children"],
["Neostigmine", "Bradyarrhythmia, AV block (if given without glycopyrrolate/atropine)", "Always pair with anticholinergic"],
["Halothane", "Sensitises myocardium to catecholamines → VT/VF; QT prolongation", "Avoid adrenaline >1–2 µg/kg"],
["Sevoflurane", "QT prolongation (dose-related); LQTS patients at higher risk", "Safe in standard doses"],
["Desflurane", "Tachycardia with rapid concentration increase; sympathetic surge", "Gradual increases; avoid in ischaemia"],
["Dexmedetomidine", "Bradycardia, AV block at high doses; antiarrhythmic properties", "Useful supplement; monitor HR closely"],
]
story.append(drug_table(
["Agent", "Effect on Rhythm", "Clinical Pearl"],
drug_arrhythmia_rows,
col_widths=[content_width*0.18, content_width*0.44, content_width*0.38]
))
story.append(Spacer(1, 3*mm))
# ── 12. Key Points Summary ───────────────────────────────────────────────────
story.append(Paragraph("12. SUMMARY OF KEY POINTS", h1_style))
story.append(hr('#bbdefb', 0.5))
summary_pts = [
"Tachydysrhythmia = HR >100 bpm; haemodynamically significant when HR >150 bpm.",
"Primary question: Is the patient STABLE or UNSTABLE? – drives the entire management strategy.",
"UNSTABLE → immediate synchronised cardioversion (anaesthesia/sedation mandatory).",
"STABLE → identify narrow vs. wide QRS → regular vs. irregular → tailor pharmacotherapy.",
"Defibrillation (unsynchronised) is reserved for VF and pulseless VT.",
"Synchronisation mode MUST be switched ON for cardioversion and confirmed before shock delivery.",
"Biphasic waveforms require lower energy than monophasic: preferred for both cardioversion and defibrillation.",
"Propofol is the preferred sedation agent for elective cardioversion; etomidate for poor LV function.",
"Anticoagulate for ≥3 weeks before and ≥4 weeks after elective cardioversion for AF of >48 h duration.",
"WPW + AF: AV nodal blockers are CONTRAINDICATED; use cardioversion or procainamide.",
"Torsades de Pointes: magnesium sulphate 2 g IV is first-line pharmacotherapy.",
"Always interrogate ICD/pacemaker before and after cardioversion/defibrillation.",
"Treat reversible causes (4 Hs and 4 Ts) concurrently with resuscitation.",
"Anaesthetic management of intraoperative tachycardia: address light anaesthesia, hypoxia, hypovolaemia first.",
]
for pt in summary_pts:
story.append(Paragraph(f"• {pt}", bullet_style))
story.append(Spacer(1, 4*mm))
# ── References ───────────────────────────────────────────────────────────────
story.append(Paragraph("REFERENCES", h1_style))
story.append(hr('#bbdefb', 0.5))
refs = [
"Miller RD et al. Miller's Anaesthesia, 10th Edition. Elsevier, 2023. Chapter 82: Cardiac Rhythm Management.",
"Libby P, Bonow RO et al. Braunwald's Heart Disease, 12th Edition. Elsevier, 2022. Chapters 67, 69.",
"Fuster V et al. Fuster and Hurst's The Heart, 15th Edition. McGraw-Hill, 2022. Chapter 36.",
"Link MS, Berkow LC et al. 2020 AHA Guidelines for CPR and Emergency Cardiovascular Care. Circulation. 2020;142(16 Suppl 2):S366–S468.",
"Panchal AR et al. Part 3: Adult Basic and Advanced Life Support: 2020 AHA Guidelines Update. Circulation. 2020;142(16 Suppl 2):S366–S468.",
"Goldman L, Schafer AI. Goldman-Cecil Medicine, 27th Edition. Elsevier, 2024. Chapter 62.",
"Pfenninger JL, Fowler GC. Pfenninger and Fowler's Procedures for Primary Care, 3rd Edition. Elsevier, 2011.",
"Roberts JR, Hedges JR. Roberts and Hedges' Clinical Procedures in Emergency Medicine, 7th Edition. Elsevier, 2018.",
]
for r in refs:
story.append(Paragraph(f"• {r}", ref_style))
story.append(Spacer(1, 4*mm))
story.append(hr('#1565c0', 1))
story.append(Paragraph("End of Answer – Total Marks: 50", small_style))
# ── Build ─────────────────────────────────────────────────────────────────────
doc.build(story)
print(f"PDF generated: {OUTPUT}")
cd /home/daytona/workspace/tachydysrhythmia && python3 generate_pdf.py 2>&1
~/tachydysrhythmia/generate_pdf.py
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/tachydysrhythmia/generate_pdf.py'
cd /home/daytona/workspace/tachydysrhythmia && python3 generate_pdf.py 2>&1
ls -lh /home/daytona/workspace/tachydysrhythmia/
Tachydysrhythmia Management PG Anaesthesia
PDF Document · PDF
| Section | Topic | Marks |
|---|---|---|
| 1 | Introduction & Definition | 2 |
| 2 | Classification (narrow/wide, regular/irregular) | 4 |
| 3 | Pathophysiology (reentry, automaticity, triggered activity) | 3 |
| 4 | ACLS Algorithm Flowchart (2020 AHA) | 6 |
| 5 | Cardioversion – definition, indications, contraindications, procedure, energy levels table | 8 |
| 6 | Defibrillation – definition, indications, step-by-step procedure (4Hs & 4Ts, epinephrine, amiodarone) | 6 |
| 7 | Pharmacological management table (13 drugs with doses, indications, cautions) | 6 |
| 8 | Anaesthetic considerations – pre-assessment, sedation agents table, monitoring, intraoperative, post-procedure | 8 |
| 9 | Special scenarios – WPW+AF, Torsades de Pointes, Pregnancy, Paediatrics | 4 |
| 10 | Complications of cardioversion/defibrillation | 2 |
| 11 | Anaesthetic agents and cardiac rhythm interactions | 3 |
| 12 | Summary key points (14 bullet points) | 3 |
| Refs | 8 authoritative references | 1 |