Anti epileptics medication it’s mechanism of action and side effects Exam oriented

Reading File
Finding Sources
Finding Sources
Reading File
Reading File
Finding Sources
Reading File
Reading File
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
I now have all the data needed for a thorough exam-oriented answer. Let me compile it:

Antiepileptic Drugs (AEDs) - Exam-Oriented Review

Classification by Mechanism of Action

AEDs are best remembered by grouping them according to their primary mechanism:
MechanismDrugs
Na+ channel blockersPhenytoin, Carbamazepine, Oxcarbazepine, Lamotrigine, Lacosamide, Valproate (partial)
Ca2+ channel blockersEthosuximide, Gabapentin, Pregabalin, Valproate (partial)
GABA enhancementPhenobarbital, Benzodiazepines, Valproate, Tiagabine, Vigabatrin
SV2A ligand (synaptic vesicle protein)Levetiracetam, Brivaracetam
Multiple/broad spectrumValproate, Topiramate, Zonisamide

Individual Drug Details

1. PHENYTOIN (Dilantin)

Mechanism: Blocks voltage-gated Na+ channels - binds to the inactive (inactivated) state of the channel and slows its rate of recovery, preventing high-frequency repetitive firing.
Key pharmacokinetics (exam high yield!):
  • Nonlinear (zero-order / saturable) pharmacokinetics - small dose increases cause disproportionately large rises in plasma concentration, risking toxicity
  • Highly protein-bound
  • Hepatic enzyme inducer (CYP2C, CYP3A) - accelerates metabolism of OCP, warfarin, steroids
Side effects:
  • Dose-related: Nystagmus, ataxia, diplopia, confusion
  • Chronic use: Gingival hyperplasia (gum overgrowth), hirsutism, coarsening of facial features, peripheral neuropathy, osteoporosis, folate deficiency, megaloblastic anemia
  • Teratogenic (fetal hydantoin syndrome)
  • Skin hypersensitivity (Stevens-Johnson syndrome)
Uses: Focal seizures, generalized tonic-clonic, status epilepticus (IV), trigeminal neuralgia
Exam tip: Fosphenytoin is the prodrug for IV/IM use. Phenytoin sodium must NEVER be given IM (causes tissue necrosis).
Gingival hyperplasia in a patient on phenytoin

2. CARBAMAZEPINE (Tegretol)

Mechanism: Blocks Na+ channels - inhibits generation of repetitive action potentials at the epileptic focus, prevents spread.
Key pharmacokinetics:
  • Autoinduction - induces its own CYP3A4 metabolism, so half-life decreases over time (from 25-65h initially down to 8-20h)
  • CYP1A2, CYP2C, CYP3A, UGT inducer - reduces levels of many co-medications
Side effects:
  • Diplopia, ataxia, nausea (dose-related)
  • Hyponatremia (SIADH-like effect - especially in elderly)
  • Aplastic anemia, agranulocytosis (rare but serious)
  • Stevens-Johnson syndrome / Toxic epidermal necrolysis (especially HLA-B*1502 in Asian patients)
  • Teratogenic
Uses: Focal seizures, tonic-clonic seizures, trigeminal neuralgia, bipolar disorder
Exam tip: Contraindicated in absence seizures - may worsen them!

3. VALPROATE / VALPROIC ACID (Depakote/Epilim)

Mechanism: Multiple - GABA potentiation + Na+ channel inhibition + T-type Ca2+ channel inhibition + NMDA inhibition. Considered the true broad-spectrum AED.
Key pharmacokinetics:
  • Hepatic enzyme inhibitor (opposite of phenytoin/carbamazepine) - raises levels of lamotrigine, phenobarbital
  • Highly protein-bound (90%)
Side effects:
  • Nausea, vomiting, tremor, weight gain, hair loss (alopecia)
  • Hepatotoxicity (most serious - especially in children under 2 on polytherapy)
  • Pancreatitis
  • Teratogenicity - neural tube defects (spina bifida), cognitive impairment in offspring; highest teratogenic risk among AEDs
  • Thrombocytopenia
Uses: Broadest spectrum - absence, myoclonic, tonic-clonic, focal seizures; migraine prophylaxis; bipolar disorder
Exam tip: Drug of choice for juvenile myoclonic epilepsy (JME) and absence seizures. Most teratogenic common AED.

4. ETHOSUXIMIDE (Zarontin)

Mechanism: Selectively blocks T-type (low-voltage) Ca2+ channels in thalamic neurons - suppresses the thalamo-cortical spike-wave discharge seen in absence seizures.
Side effects:
  • GI upset (nausea, vomiting), anorexia
  • Drowsiness, headache
  • Skin rashes (Stevens-Johnson rare)
  • Does NOT cause gingival hyperplasia or hirsutism
Uses: Absence seizures ONLY (no effect on other seizure types)
Exam tip: Drug of choice for pure absence seizures. If absence + generalized tonic-clonic coexist, use valproate.

5. PHENOBARBITAL (Luminal)

Mechanism: Enhances GABA-A receptor function by prolonging the duration (not frequency) of Cl- channel opening; also reduces glutamate excitation.
Side effects:
  • Sedation, cognitive slowing (major problem in children)
  • Tolerance, dependence, withdrawal seizures
  • Hepatic enzyme inducer
  • Teratogenic (cleft palate)
Uses: Tonic-clonic seizures, status epilepticus (IV), neonatal seizures

6. BENZODIAZEPINES (Diazepam, Lorazepam, Clonazepam, Clobazam)

Mechanism: Enhance GABA-A receptor function by increasing the frequency (not duration) of Cl- channel opening.
Side effects:
  • Sedation, respiratory depression
  • Tolerance and dependence
  • Anterograde amnesia
Uses:
  • Lorazepam/Diazepam: First-line for status epilepticus
  • Clonazepam: Absence seizures, myoclonic seizures (long-term)
  • Clobazam: Lennox-Gastaut syndrome, adjunct
Exam mnemonic - BZD vs Barbiturate GABA effect:
  • BZD = Frequency (F for both)
  • Barbiturate = Duration (D for both)

7. LAMOTRIGINE (Lamictal)

Mechanism: Na+ channel blocker; also reduces glutamate release.
Side effects:
  • Dizziness, headache, diplopia
  • Serious skin rash including Stevens-Johnson syndrome - especially if dose is escalated too rapidly, or combined with valproate
  • Valproate doubles lamotrigine levels (reduce lamotrigine dose when co-prescribing)
Uses: Focal seizures, generalized tonic-clonic, absence, bipolar depression

8. LEVETIRACETAM (Keppra)

Mechanism: Binds synaptic vesicle protein SV2A - modulates neurotransmitter release. Exact mechanism still debated.
Side effects:
  • Behavioral/psychiatric - irritability, anxiety, depression, aggression ("Keppra rage")
  • Dizziness, somnolence
  • Renally excreted (no hepatic interactions)
Uses: Focal, generalized tonic-clonic, myoclonic seizures. Widely used as it has minimal drug interactions.

9. GABAPENTIN & PREGABALIN

Mechanism: Bind to α2δ subunit of voltage-gated Ca2+ channels - reduce excitatory neurotransmitter release. Despite the name, do NOT directly act on GABA receptors.
Side effects:
  • Sedation, dizziness, ataxia, weight gain, peripheral edema
  • Pregabalin: euphoria (abuse potential, schedule V in US)
Uses:
  • Gabapentin: Adjunct for focal seizures, neuropathic pain, postherpetic neuralgia
  • Pregabalin: Focal seizures, diabetic neuropathy, fibromyalgia, anxiety

10. TOPIRAMATE (Topamax)

Mechanism: Multiple - Na+ channel blocking + GABA-A enhancement + AMPA/kainate receptor antagonism (anti-glutamate) + carbonic anhydrase inhibition.
Side effects:
  • Cognitive slowing, word-finding difficulty ("Dopamax")
  • Renal stones (carbonic anhydrase inhibition)
  • Metabolic acidosis
  • Anorexia, weight loss (used off-label for obesity)
  • Teratogenic (cleft lip/palate)
Uses: Focal + generalized seizures, Lennox-Gastaut, migraine prophylaxis, weight loss (off-label)

11. SODIUM VALPROATE vs OTHERS - Drug Interactions (High-Yield Table)

DrugEnzyme EffectKey Interaction
PhenytoinCYP inducerReduces OCP, warfarin, steroids
CarbamazepineCYP inducerReduces OCP, warfarin; autoinduces itself
PhenobarbitalCYP inducerSedation additive with CNS depressants
ValproateCYP inhibitorRaises lamotrigine, phenobarbital levels
LevetiracetamMinimalFewest interactions

Quick Seizure-to-Drug Matching (Exam Essentials)

Seizure TypeDrug of ChoiceAlternatives
Absence (petit mal)EthosuximideValproate, Lamotrigine
Tonic-clonic (grand mal)ValproatePhenytoin, Carbamazepine
Focal (partial)CarbamazepinePhenytoin, Lamotrigine, Levetiracetam
MyoclonicValproateLevetiracetam, Clonazepam
Status epilepticusLorazepam/Diazepam (1st)Phenytoin/Fosphenytoin (2nd), Phenobarbital (3rd)
Juvenile myoclonic epilepsyValproateLevetiracetam
Lennox-GastautValproate, TopiramateClobazam, Rufinamide, Cannabidiol
Trigeminal neuralgiaCarbamazepineOxcarbazepine

High-Yield Mnemonics & Exam Tips

Phenytoin unique side effects (mnemonic "HAGG"):
Hirsutism, Ataxia/nystagmus, Gingival hyperplasia, Gingloid (folate deficiency / megaloblastic anemia)
Valproate = "PANTHER":
Pancreatitis, Alopecia, Neural tube defects, Tremor, Hepatotoxicity, Enzyme inhibitor, Remors (weight gain)
Carbamazepine "HAS" special toxicity:
Hyponatremia, Aplastic anemia, Stevens-Johnson
"BZD increases Frequency; Barbiturate increases Duration" - of Cl- channel opening at GABA-A receptor
Drugs contraindicated in absence seizures: Carbamazepine, Phenytoin, Tiagabine, Vigabatrin (all can worsen absence)

Sources:
  • Katzung's Basic and Clinical Pharmacology, 16th Edition, Summary Table: Antiseizure Medications
  • Lippincott Illustrated Reviews: Pharmacology, Ch. 19 - Antiepileptic Drugs
  • Adams and Victor's Principles of Neurology, 12th Edition, Table 15-5/15-6
  • Barash Clinical Anesthesia, 9th Edition, Table 24-8

Create a summary PDF with drug comparison tables for quick revision

Reading File
Running Command

ls /home/daytona/workspace/ 2>/dev/null || echo "workspace empty"

Writing File

~/aed_summary/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 mm, cm
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, KeepTogether, PageBreak
)
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus import BaseDocTemplate, Frame, PageTemplate

# ── Color palette ──────────────────────────────────────────────────
DARK_BLUE    = colors.HexColor("#1A237E")
MID_BLUE     = colors.HexColor("#1565C0")
LIGHT_BLUE   = colors.HexColor("#BBDEFB")
ACCENT_TEAL  = colors.HexColor("#00838F")
LIGHT_TEAL   = colors.HexColor("#E0F7FA")
ORANGE       = colors.HexColor("#E65100")
LIGHT_ORANGE = colors.HexColor("#FFF3E0")
GREEN        = colors.HexColor("#1B5E20")
LIGHT_GREEN  = colors.HexColor("#E8F5E9")
RED          = colors.HexColor("#B71C1C")
LIGHT_RED    = colors.HexColor("#FFEBEE")
YELLOW_BG    = colors.HexColor("#FFFDE7")
GRAY_DARK    = colors.HexColor("#37474F")
GRAY_LIGHT   = colors.HexColor("#ECEFF1")
WHITE        = colors.white

OUTPUT = "/home/daytona/workspace/aed_summary/Antiepileptic_Drugs_Summary.pdf"

# ── Document setup ─────────────────────────────────────────────────
doc = SimpleDocTemplate(
    OUTPUT,
    pagesize=A4,
    leftMargin=15*mm, rightMargin=15*mm,
    topMargin=18*mm, bottomMargin=18*mm,
)

W = A4[0] - 30*mm   # usable width

# ── Styles ─────────────────────────────────────────────────────────
base = getSampleStyleSheet()

def S(name, **kw):
    s = ParagraphStyle(name, **kw)
    return s

title_style  = S("Title2",  fontName="Helvetica-Bold",  fontSize=20, textColor=WHITE,       alignment=TA_CENTER, spaceAfter=2)
sub_style    = S("Sub",     fontName="Helvetica",        fontSize=10, textColor=LIGHT_BLUE,  alignment=TA_CENTER, spaceAfter=4)
h1_style     = S("H1",      fontName="Helvetica-Bold",  fontSize=13, textColor=WHITE,        spaceBefore=6, spaceAfter=3)
h2_style     = S("H2",      fontName="Helvetica-Bold",  fontSize=11, textColor=DARK_BLUE,    spaceBefore=8, spaceAfter=3)
body_style   = S("Body2",   fontName="Helvetica",        fontSize=8.5, textColor=GRAY_DARK,  leading=12, spaceAfter=2)
mnem_style   = S("Mnem",    fontName="Helvetica-BoldOblique", fontSize=8.5, textColor=ORANGE, leading=12, spaceAfter=2)
note_style   = S("Note",    fontName="Helvetica-Oblique", fontSize=8, textColor=ACCENT_TEAL, leading=11, spaceAfter=2)
th_style     = S("TH",      fontName="Helvetica-Bold",  fontSize=8,  textColor=WHITE,        alignment=TA_CENTER, leading=10)
td_style     = S("TD",      fontName="Helvetica",        fontSize=7.5, textColor=GRAY_DARK,  alignment=TA_CENTER, leading=10)
td_l_style   = S("TDL",     fontName="Helvetica",        fontSize=7.5, textColor=GRAY_DARK,  alignment=TA_LEFT,   leading=10)
bold_td      = S("BTD",     fontName="Helvetica-Bold",  fontSize=7.5, textColor=DARK_BLUE,   alignment=TA_LEFT,   leading=10)
warn_style   = S("Warn",    fontName="Helvetica-Bold",  fontSize=8,   textColor=RED,         alignment=TA_LEFT,   leading=11)

def P(text, style=body_style): return Paragraph(text, style)
def TH(t): return Paragraph(t, th_style)
def TD(t): return Paragraph(t, td_style)
def TDL(t): return Paragraph(t, td_l_style)
def BTD(t): return Paragraph(t, bold_td)

story = []

# ════════════════════════════════════════════════════════════════════
# COVER BANNER
# ════════════════════════════════════════════════════════════════════
banner_data = [[P("ANTIEPILEPTIC DRUGS", title_style)],
               [P("Mechanism of Action · Side Effects · Drug Comparison Tables", sub_style)],
               [P("Exam-Oriented Quick Revision Guide", sub_style)]]
banner_tbl = Table(banner_data, colWidths=[W])
banner_tbl.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,-1), DARK_BLUE),
    ("TOPPADDING",  (0,0), (-1,-1), 10),
    ("BOTTOMPADDING",(0,0),(-1,-1), 8),
    ("LEFTPADDING", (0,0), (-1,-1), 10),
    ("ALIGN",       (0,0), (-1,-1), "CENTER"),
    ("VALIGN",      (0,0), (-1,-1), "MIDDLE"),
    ("ROUNDEDCORNERS", [6]),
]))
story.append(banner_tbl)
story.append(Spacer(1, 6*mm))

# ════════════════════════════════════════════════════════════════════
# SECTION HEADER HELPER
# ════════════════════════════════════════════════════════════════════
def section_header(text, color=MID_BLUE):
    t = Table([[P(text, h1_style)]], colWidths=[W])
    t.setStyle(TableStyle([
        ("BACKGROUND",   (0,0),(-1,-1), color),
        ("TOPPADDING",   (0,0),(-1,-1), 5),
        ("BOTTOMPADDING",(0,0),(-1,-1), 5),
        ("LEFTPADDING",  (0,0),(-1,-1), 8),
        ("ROUNDEDCORNERS",[4]),
    ]))
    return t

def info_box(text, bg=LIGHT_TEAL, tc=ACCENT_TEAL):
    st = S("IB", fontName="Helvetica-BoldOblique", fontSize=8.5, textColor=tc, leading=12, spaceAfter=0)
    t = Table([[P(text, st)]], colWidths=[W])
    t.setStyle(TableStyle([
        ("BACKGROUND",   (0,0),(-1,-1), bg),
        ("TOPPADDING",   (0,0),(-1,-1), 5),
        ("BOTTOMPADDING",(0,0),(-1,-1), 5),
        ("LEFTPADDING",  (0,0),(-1,-1), 8),
        ("ROUNDEDCORNERS",[4]),
    ]))
    return t

# ════════════════════════════════════════════════════════════════════
# 1. CLASSIFICATION BY MECHANISM
# ════════════════════════════════════════════════════════════════════
story.append(section_header("1.  Classification by Mechanism of Action"))
story.append(Spacer(1, 3*mm))

mech_data = [
    [TH("Mechanism"), TH("Primary Site"), TH("Drugs")],
    [TD("Na⁺ Channel Blockers"),
     TDL("Inactive state of VG-Na⁺ channel\n→ ↓ high-freq firing"),
     TDL("Phenytoin, Carbamazepine, Oxcarbazepine,\nLamotrigine, Lacosamide, Eslicarbazepine")],
    [TD("Ca²⁺ Channel Blockers\n(T-type)"),
     TDL("Thalamic T-type Ca²⁺ channels\n→ ↓ spike-wave discharge"),
     TDL("Ethosuximide, Valproate (partial)")],
    [TD("Ca²⁺ Channel Blockers\n(α₂δ subunit)"),
     TDL("VG-Ca²⁺ α₂δ subunit\n→ ↓ excitatory NT release"),
     TDL("Gabapentin, Pregabalin")],
    [TD("GABA Enhancement"),
     TDL("GABA-A receptor Cl⁻ channel\n(↑ duration = barbiturates;\n↑ frequency = BZDs)"),
     TDL("Phenobarbital, Primidone,\nBenzodiazepines, Vigabatrin, Tiagabine")],
    [TD("SV2A Ligand"),
     TDL("Synaptic vesicle protein SV2A\n→ modulates NT release"),
     TDL("Levetiracetam, Brivaracetam")],
    [TD("Multiple / Broad"),
     TDL("Na⁺ channels + T-Ca²⁺ +\nGABA + NMDA antagonism"),
     TDL("Valproate, Topiramate, Zonisamide,\nFelbamate")],
]

mech_tbl = Table(mech_data, colWidths=[W*0.22, W*0.33, W*0.45])
mech_tbl.setStyle(TableStyle([
    ("BACKGROUND",   (0,0), (-1,0),  MID_BLUE),
    ("TEXTCOLOR",    (0,0), (-1,0),  WHITE),
    ("BACKGROUND",   (0,1), (-1,1),  LIGHT_BLUE),
    ("BACKGROUND",   (0,2), (-1,2),  GRAY_LIGHT),
    ("BACKGROUND",   (0,3), (-1,3),  LIGHT_BLUE),
    ("BACKGROUND",   (0,4), (-1,4),  GRAY_LIGHT),
    ("BACKGROUND",   (0,5), (-1,5),  LIGHT_BLUE),
    ("BACKGROUND",   (0,6), (-1,6),  GRAY_LIGHT),
    ("GRID",         (0,0), (-1,-1), 0.4, colors.white),
    ("TOPPADDING",   (0,0), (-1,-1), 4),
    ("BOTTOMPADDING",(0,0), (-1,-1), 4),
    ("LEFTPADDING",  (0,0), (-1,-1), 5),
    ("RIGHTPADDING", (0,0), (-1,-1), 5),
    ("VALIGN",       (0,0), (-1,-1), "TOP"),
    ("ALIGN",        (0,0), (0,-1),  "CENTER"),
    ("ALIGN",        (0,0), (-1,0),  "CENTER"),
]))
story.append(mech_tbl)
story.append(Spacer(1, 4*mm))
story.append(info_box("⚡ Key Distinction: Barbiturates ↑ DURATION of Cl⁻ opening | Benzodiazepines ↑ FREQUENCY of Cl⁻ opening"))
story.append(Spacer(1, 5*mm))

# ════════════════════════════════════════════════════════════════════
# 2. MAIN DRUG COMPARISON TABLE
# ════════════════════════════════════════════════════════════════════
story.append(section_header("2.  Main Drug Comparison Table"))
story.append(Spacer(1, 3*mm))

drug_data = [
    [TH("Drug"), TH("Mechanism"), TH("Uses"), TH("Major Side Effects"), TH("Unique / Exam Tips")],

    [BTD("Phenytoin\n(Dilantin)"),
     TDL("VG-Na⁺ channel\nblocker (inactive\nstate)"),
     TDL("Focal, tonic-clonic,\nstatus epilepticus,\ntrigeminal neuralgia"),
     TDL("Nystagmus, ataxia, diplopia,\nGingival hyperplasia,\nHirsutism, Peripheral neuropathy,\nOsteoporosis, Folate def."),
     TDL("Nonlinear (zero-order) PK\nCYP enzyme inducer\nTeratogenic (fetal hydantoin)\nNEVER give IM")],

    [BTD("Carbamazepine\n(Tegretol)"),
     TDL("VG-Na⁺ channel\nblocker"),
     TDL("Focal, tonic-clonic,\ntrigeminal neuralgia,\nbipolar disorder"),
     TDL("Diplopia, ataxia, nausea,\nHyponatremia (SIADH),\nAplastic anemia,\nStevens-Johnson (HLA-B*1502)"),
     TDL("Autoinduces own metabolism\nCYP inducer\nContraindicated in ABSENCE\nTeratogenic")],

    [BTD("Valproate\n(Depakote)"),
     TDL("Broad: Na⁺, T-Ca²⁺,\nGABA ↑, NMDA ↓"),
     TDL("ALL seizure types,\nmigraine, bipolar,\nJME (drug of choice)"),
     TDL("Nausea, tremor, weight gain,\nAlopecia, Hepatotoxicity,\nPancreatitis, Thrombocytopenia"),
     TDL("CYP INHIBITOR (↑ lamotrigine)\nMOST teratogenic (neural tube\ndefects, spina bifida)\nDOC for JME + absence + GTC")],

    [BTD("Ethosuximide\n(Zarontin)"),
     TDL("T-type Ca²⁺ channel\nblocker (thalamic)"),
     TDL("ABSENCE SEIZURES\nONLY"),
     TDL("GI upset, anorexia,\nDrowsiness, headache\nSkin rash (rare SJS)"),
     TDL("NO effect on other seizure\ntypes. If absence + GTC\ncoexist → use Valproate")],

    [BTD("Phenobarbital\n(Luminal)"),
     TDL("GABA-A ↑ duration\nof Cl⁻ opening;\n↓ glutamate"),
     TDL("Tonic-clonic,\nstatus epilepticus (IV),\nneonatal seizures"),
     TDL("Sedation, cognitive slowing,\nTolerance & dependence,\nWithdrawal seizures"),
     TDL("CYP inducer\nTeratogenic (cleft palate)\nLong t½ (40-120h)")],

    [BTD("Lamotrigine\n(Lamictal)"),
     TDL("Na⁺ channel blocker;\n↓ glutamate release"),
     TDL("Focal, GTC, absence,\nmyoclonic, bipolar\ndepression"),
     TDL("Dizziness, diplopia,\nSerious rash / SJS\n(esp. with valproate)"),
     TDL("Valproate DOUBLES lamotrigine\nlevels (reduce dose!)\nTitrate dose SLOWLY to\navoid SJS rash")],

    [BTD("Levetiracetam\n(Keppra)"),
     TDL("SV2A synaptic\nvesicle protein\nbinding"),
     TDL("Focal, GTC,\nmyoclonic seizures"),
     TDL("'Keppra Rage': irritability,\naggression, depression,\nanxiety, dizziness"),
     TDL("Minimal drug interactions\nRenal excretion\nNo hepatic metabolism\nMost widely used new AED")],

    [BTD("Gabapentin &\nPregabalin"),
     TDL("α₂δ subunit of\nVG-Ca²⁺ channels\n→ ↓ NT release"),
     TDL("Adjunct focal Sz;\nneuropathic pain,\nfibromyalgia"),
     TDL("Sedation, dizziness, ataxia,\nWeight gain, peripheral edema\nPregabalin: euphoria/abuse"),
     TDL("Despite 'GABA' in name, do\nNOT act on GABA receptors!\nPregabalin: Schedule V\nDose adjust in renal failure")],

    [BTD("Topiramate\n(Topamax)"),
     TDL("Multiple: Na⁺ block,\nGABA ↑, AMPA/\nkainate antagonist,\nCA inhibitor"),
     TDL("Focal + generalized,\nLennox-Gastaut,\nmigraine prophylaxis"),
     TDL("Cognitive slowing ('Dopamax'),\nWord-finding difficulty,\nRenal stones (CA inhibition),\nMetabolic acidosis, Anorexia"),
     TDL("Weight LOSS (off-label obesity)\nContraceptive failure\nTeratogenic (cleft lip/palate)")],

    [BTD("Benzodiazepines\n(Diazepam,\nLorazepam,\nClonazepam)"),
     TDL("GABA-A ↑ frequency\nof Cl⁻ opening"),
     TDL("Status epilepticus\n(lorazepam = 1st line)\nAbsence, myoclonic\n(clonazepam)"),
     TDL("Sedation, respiratory depression,\nTolerance & dependence,\nAnterograde amnesia"),
     TDL("Tolerance limits long-term use\nDiazepam: rectal/intranasal\nfor prolonged seizures\nClobazam: Lennox-Gastaut")],
]

drug_tbl = Table(drug_data, colWidths=[W*0.12, W*0.16, W*0.17, W*0.28, W*0.27])
drug_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0),  (-1,0),   DARK_BLUE),
    ("TEXTCOLOR",     (0,0),  (-1,0),   WHITE),
    # alternating rows
    ("BACKGROUND",    (0,1),  (-1,1),   LIGHT_BLUE),
    ("BACKGROUND",    (0,2),  (-1,2),   GRAY_LIGHT),
    ("BACKGROUND",    (0,3),  (-1,3),   LIGHT_BLUE),
    ("BACKGROUND",    (0,4),  (-1,4),   GRAY_LIGHT),
    ("BACKGROUND",    (0,5),  (-1,5),   LIGHT_BLUE),
    ("BACKGROUND",    (0,6),  (-1,6),   GRAY_LIGHT),
    ("BACKGROUND",    (0,7),  (-1,7),   LIGHT_BLUE),
    ("BACKGROUND",    (0,8),  (-1,8),   GRAY_LIGHT),
    ("BACKGROUND",    (0,9),  (-1,9),   LIGHT_BLUE),
    ("BACKGROUND",    (0,10), (-1,10),  GRAY_LIGHT),
    ("GRID",          (0,0),  (-1,-1),  0.4, colors.white),
    ("TOPPADDING",    (0,0),  (-1,-1),  4),
    ("BOTTOMPADDING", (0,0),  (-1,-1),  4),
    ("LEFTPADDING",   (0,0),  (-1,-1),  5),
    ("RIGHTPADDING",  (0,0),  (-1,-1),  5),
    ("VALIGN",        (0,0),  (-1,-1),  "TOP"),
    ("ALIGN",         (0,0),  (-1,0),   "CENTER"),
]))
story.append(drug_tbl)
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════
# 3. SEIZURE TYPE → DRUG OF CHOICE
# ════════════════════════════════════════════════════════════════════
story.append(section_header("3.  Seizure Type → Drug of Choice", color=ACCENT_TEAL))
story.append(Spacer(1, 3*mm))

sz_data = [
    [TH("Seizure Type"), TH("1st Choice (DOC)"), TH("Alternatives"), TH("Avoid")],
    [TD("Absence (Petit Mal)"),         TD("Ethosuximide"),             TD("Valproate, Lamotrigine"),              TD("Carbamazepine, Phenytoin,\nTiagabine, Vigabatrin")],
    [TD("Tonic-Clonic (Grand Mal)"),    TD("Valproate"),                TD("Phenytoin, Carbamazepine,\nLamotrigine, Levetiracetam"),  TD("—")],
    [TD("Focal (Partial)"),             TD("Carbamazepine"),            TD("Phenytoin, Lamotrigine,\nLevetiracetam, Oxcarbazepine"), TD("—")],
    [TD("Myoclonic"),                   TD("Valproate"),                TD("Levetiracetam, Clonazepam,\nTopiramate"),                TD("Carbamazepine, Phenytoin,\nGabapentin")],
    [TD("Juvenile Myoclonic\nEpilepsy (JME)"), TD("Valproate"),        TD("Levetiracetam, Topiramate,\nLamotrigine"),               TD("Carbamazepine")],
    [TD("Status Epilepticus"),          TD("Lorazepam IV (1st)\nor Diazepam IV"), TD("Phenytoin/Fosphenytoin (2nd)\nPhenobarbital IV (3rd)\nMidazolam, Propofol, Pentobarbital"), TD("—")],
    [TD("Lennox-Gastaut\nSyndrome"),    TD("Valproate"),                TD("Topiramate, Clobazam,\nRufinamide, Cannabidiol"),        TD("Carbamazepine\n(worsens atonic Sz)")],
    [TD("Trigeminal Neuralgia"),        TD("Carbamazepine"),            TD("Oxcarbazepine, Phenytoin,\nLamotrigine"),                TD("—")],
    [TD("Absence + GTC\n(coexisting)"), TD("Valproate"),               TD("Lamotrigine"),                         TD("Ethosuximide alone")],
    [TD("Neonatal Seizures"),           TD("Phenobarbital"),            TD("Phenytoin, Levetiracetam"),            TD("—")],
    [TD("Bipolar Disorder"),            TD("Valproate / Lithium"),      TD("Carbamazepine, Lamotrigine\n(bipolar depression)"),      TD("—")],
    [TD("Migraine Prophylaxis"),        TD("Valproate / Topiramate"),   TD("—"),                                   TD("—")],
]
sz_tbl = Table(sz_data, colWidths=[W*0.22, W*0.22, W*0.31, W*0.25])
sz_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0),  (-1,0),  ACCENT_TEAL),
    ("TEXTCOLOR",     (0,0),  (-1,0),  WHITE),
    *[("BACKGROUND",  (0,i),  (-1,i),  LIGHT_TEAL if i%2==1 else GRAY_LIGHT) for i in range(1, len(sz_data))],
    ("GRID",          (0,0),  (-1,-1), 0.4, colors.white),
    ("TOPPADDING",    (0,0),  (-1,-1), 4),
    ("BOTTOMPADDING", (0,0),  (-1,-1), 4),
    ("LEFTPADDING",   (0,0),  (-1,-1), 5),
    ("RIGHTPADDING",  (0,0),  (-1,-1), 5),
    ("VALIGN",        (0,0),  (-1,-1), "TOP"),
    ("ALIGN",         (0,0),  (-1,0),  "CENTER"),
]))
story.append(sz_tbl)
story.append(Spacer(1, 5*mm))

# ════════════════════════════════════════════════════════════════════
# 4. SIDE EFFECT COMPARISON TABLE
# ════════════════════════════════════════════════════════════════════
story.append(section_header("4.  Distinctive Side Effects — Quick Comparison", color=colors.HexColor("#4A148C")))
story.append(Spacer(1, 3*mm))

PURPLE_DARK  = colors.HexColor("#4A148C")
PURPLE_LIGHT = colors.HexColor("#EDE7F6")
PURPLE_MID   = colors.HexColor("#D1C4E9")

se_data = [
    [TH("Side Effect / Toxicity"), TH("Drug(s) Responsible")],
    [TDL("Gingival Hyperplasia (gum overgrowth)"),    TDL("Phenytoin")],
    [TDL("Hirsutism + Coarsening of facial features"),TDL("Phenytoin")],
    [TDL("Nonlinear (zero-order) pharmacokinetics"),  TDL("Phenytoin")],
    [TDL("Hyponatremia / SIADH-like"),                TDL("Carbamazepine, Oxcarbazepine")],
    [TDL("Aplastic anemia / Agranulocytosis"),         TDL("Carbamazepine, Felbamate")],
    [TDL("Stevens-Johnson Syndrome (SJS)"),            TDL("Carbamazepine (HLA-B*1502), Lamotrigine,\nPhenytoin, Phenobarbital")],
    [TDL("Autoinduction of own metabolism"),           TDL("Carbamazepine")],
    [TDL("Hepatotoxicity (esp. children <2 on\npolytherapy)"),TDL("Valproate (most serious!)")],
    [TDL("Pancreatitis"),                              TDL("Valproate")],
    [TDL("Alopecia (hair loss)"),                      TDL("Valproate")],
    [TDL("Weight GAIN"),                               TDL("Valproate, Gabapentin, Pregabalin")],
    [TDL("Weight LOSS"),                               TDL("Topiramate, Felbamate, Zonisamide")],
    [TDL("Neural tube defects (teratogenicity)"),       TDL("Valproate (highest risk!), Carbamazepine")],
    [TDL("Cognitive slowing / 'Dopamax' effect"),       TDL("Topiramate")],
    [TDL("Renal stones (nephrolithiasis)"),             TDL("Topiramate, Zonisamide, Acetazolamide")],
    [TDL("Behavioral disturbance ('Keppra rage')"),     TDL("Levetiracetam")],
    [TDL("Tolerance & Dependence"),                     TDL("Benzodiazepines, Barbiturates")],
    [TDL("Sedation / Cognitive slowing in children"),   TDL("Phenobarbital (major limitation)")],
    [TDL("Peripheral edema + euphoria/abuse potential"),TDL("Pregabalin")],
    [TDL("Rash — severely worsened by Valproate"),      TDL("Lamotrigine (dose escalate slowly!)")],
    [TDL("Osteoporosis / Osteomalacia"),                TDL("Phenytoin, Phenobarbital, Carbamazepine\n(enzyme inducers → ↓ Vit D)")],
    [TDL("Folic acid deficiency / Megaloblastic anemia"),TDL("Phenytoin, Phenobarbital")],
    [TDL("Tissue necrosis if given IM"),                TDL("Phenytoin (use Fosphenytoin instead!)")],
]
se_tbl = Table(se_data, colWidths=[W*0.52, W*0.48])
se_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0),  (-1,0),  PURPLE_DARK),
    ("TEXTCOLOR",     (0,0),  (-1,0),  WHITE),
    *[("BACKGROUND",  (0,i),  (-1,i),  PURPLE_LIGHT if i%2==1 else GRAY_LIGHT) for i in range(1, len(se_data))],
    ("GRID",          (0,0),  (-1,-1), 0.4, colors.white),
    ("TOPPADDING",    (0,0),  (-1,-1), 4),
    ("BOTTOMPADDING", (0,0),  (-1,-1), 4),
    ("LEFTPADDING",   (0,0),  (-1,-1), 6),
    ("RIGHTPADDING",  (0,0),  (-1,-1), 6),
    ("VALIGN",        (0,0),  (-1,-1), "TOP"),
    ("ALIGN",         (0,0),  (-1,0),  "CENTER"),
]))
story.append(se_tbl)
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════
# 5. ENZYME INTERACTIONS TABLE
# ════════════════════════════════════════════════════════════════════
story.append(section_header("5.  Drug Interactions — Enzyme Inducers vs Inhibitors", color=ORANGE))
story.append(Spacer(1, 3*mm))

int_data = [
    [TH("Drug"), TH("Enzyme Effect"), TH("Drugs Affected (levels ↓ unless noted)"), TH("Exam Tip")],
    [BTD("Phenytoin"),       TD("CYP INDUCER\n(2C9, 2C19, 3A4)"), TDL("OCP, warfarin, steroids,\ncyclosporine, digoxin,\ncarbamazepine"), TDL("Can lower its OWN level\n+ raises phenobarb level")],
    [BTD("Carbamazepine"),   TD("CYP INDUCER\n(1A2, 2C, 3A4, UGT)"),TDL("OCP, warfarin, valproate,\nlamotrigine, phenytoin,\nclonazepam"), TDL("AUTOINDUCES itself\n→ t½ falls over weeks")],
    [BTD("Phenobarbital"),   TD("CYP INDUCER\n(broad)"),           TDL("OCP, steroids, warfarin,\nmost AEDs"),                          TDL("Valproate INHIBITS\nphenobarb metabolism\n→ ↑ sedation")],
    [BTD("Valproate"),       TD("CYP INHIBITOR\n(2C9, UGT)"),      TDL("Lamotrigine LEVEL ↑ 2×\nPhenobarb level ↑\nEthosuximide level ↑"),TDL("Most important interaction:\n↑ lamotrigine → SJS risk!")],
    [BTD("Levetiracetam"),   TD("MINIMAL interactions"),           TDL("Virtually none"),                                               TDL("Safest for polypharmacy\nPolycystic epilepsy patients")],
    [BTD("Gabapentin /\nPregabalin"), TD("NONE"),                  TDL("No CYP interactions"),                                          TDL("Renally excreted,\nadjust in renal failure")],
    [BTD("Lamotrigine"),     TD("NONE (substrate only)"),          TDL("—"),                                                            TDL("Its OWN level:\n↑ by valproate (inhibit)\n↓ by CBZ, PHT, PHB (induce)")],
]
int_tbl = Table(int_data, colWidths=[W*0.14, W*0.18, W*0.37, W*0.31])
int_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0),  (-1,0),  ORANGE),
    ("TEXTCOLOR",     (0,0),  (-1,0),  WHITE),
    *[("BACKGROUND",  (0,i),  (-1,i),  LIGHT_ORANGE if i%2==1 else GRAY_LIGHT) for i in range(1, len(int_data))],
    ("GRID",          (0,0),  (-1,-1), 0.4, colors.white),
    ("TOPPADDING",    (0,0),  (-1,-1), 4),
    ("BOTTOMPADDING", (0,0),  (-1,-1), 4),
    ("LEFTPADDING",   (0,0),  (-1,-1), 5),
    ("RIGHTPADDING",  (0,0),  (-1,-1), 5),
    ("VALIGN",        (0,0),  (-1,-1), "TOP"),
    ("ALIGN",         (0,0),  (-1,0),  "CENTER"),
]))
story.append(int_tbl)
story.append(Spacer(1, 5*mm))

# ════════════════════════════════════════════════════════════════════
# 6. TERATOGENICITY TABLE
# ════════════════════════════════════════════════════════════════════
story.append(section_header("6.  Teratogenicity — AEDs in Pregnancy", color=RED))
story.append(Spacer(1, 3*mm))

tera_data = [
    [TH("Drug"), TH("Risk"), TH("Main Defect(s)"), TH("Notes")],
    [BTD("Valproate"),      TD("HIGHEST ⚠⚠⚠"),  TDL("Neural tube defects (spina bifida),\ncognitive impairment in child,\nAutism spectrum disorder"), TDL("Use supplemental folic acid;\nconsider alternatives if possible")],
    [BTD("Carbamazepine"),  TD("HIGH ⚠⚠"),       TDL("Neural tube defects (lower risk than\nvalproate), facial anomalies"),  TDL("HLA-B*1502 screening before use\nin Asian patients")],
    [BTD("Phenytoin"),      TD("HIGH ⚠⚠"),       TDL("Fetal hydantoin syndrome:\nhypertelorism, digital hypoplasia,\ncleft lip/palate"),             TDL("CYP inducer → ↓ folic acid\nUse folic acid supplementation")],
    [BTD("Phenobarbital"),  TD("MODERATE ⚠"),    TDL("Cleft lip/palate, cardiac defects"),   TDL("Neonatal withdrawal + bleeding\nGive vit K to mother + neonate")],
    [BTD("Topiramate"),     TD("MODERATE ⚠"),    TDL("Cleft lip/palate, low birth weight"),  TDL("FDA Category D")],
    [BTD("Lamotrigine"),    TD("LOW-MODERATE"),  TDL("Cleft palate (dose-dependent risk)"),   TDL("Relatively safer option;\nmonitor levels in pregnancy")],
    [BTD("Levetiracetam"),  TD("LOW"),           TDL("Limited data; no major teratogen\nidentified so far"),                TDL("Often preferred in pregnancy\nwhen AED needed")],
]
tera_tbl = Table(tera_data, colWidths=[W*0.14, W*0.14, W*0.38, W*0.34])
tera_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0),  (-1,0),  RED),
    ("TEXTCOLOR",     (0,0),  (-1,0),  WHITE),
    *[("BACKGROUND",  (0,i),  (-1,i),  LIGHT_RED if i%2==1 else GRAY_LIGHT) for i in range(1, len(tera_data))],
    ("GRID",          (0,0),  (-1,-1), 0.4, colors.white),
    ("TOPPADDING",    (0,0),  (-1,-1), 4),
    ("BOTTOMPADDING", (0,0),  (-1,-1), 4),
    ("LEFTPADDING",   (0,0),  (-1,-1), 5),
    ("RIGHTPADDING",  (0,0),  (-1,-1), 5),
    ("VALIGN",        (0,0),  (-1,-1), "TOP"),
    ("ALIGN",         (0,0),  (-1,0),  "CENTER"),
    ("ALIGN",         (0,1),  (0,-1),  "CENTER"),
]))
story.append(tera_tbl)
story.append(Spacer(1, 5*mm))

# ════════════════════════════════════════════════════════════════════
# 7. PHARMACOKINETICS TABLE
# ════════════════════════════════════════════════════════════════════
story.append(section_header("7.  Key Pharmacokinetics at a Glance", color=GREEN))
story.append(Spacer(1, 3*mm))

pk_data = [
    [TH("Drug"), TH("t½ (hours)"), TH("Therapeutic Level (µg/mL)"), TH("Protein Binding"), TH("Metabolism / Excretion"), TH("Special PK Notes")],
    [BTD("Phenytoin"),      TD("12–36"),  TD("10–20"),   TD("~90%"),  TDL("CYP2C9, 2C19\nLiver"),          TDL("NONLINEAR kinetics\n(zero-order at high doses)")],
    [BTD("Carbamazepine"),  TD("8–20\n(adult, after\nautoinduction)"), TD("4–12"), TD("75%"),TDL("CYP3A4 → active\nepoxide metabolite"),TDL("Autoinduction ↓ t½\nover first weeks")],
    [BTD("Valproate"),      TD("5–16"),   TD("50–100"),  TD("~90%"),  TDL("Liver (mitochondrial\n+ glucuronidation)"), TDL("Inhibits own + other\ndrug metabolism")],
    [BTD("Ethosuximide"),   TD("30–60"),  TD("40–100"),  TD("Minimal"),TDL("CYP3A4, liver"),               TDL("DOC for pure absence;\nlong t½ → once daily OK")],
    [BTD("Phenobarbital"),  TD("40–120"), TD("15–40"),   TD("~50%"),  TDL("CYP2C9, glucuronide,\nliver"),   TDL("Very long t½\n→ once daily dosing")],
    [BTD("Lamotrigine"),    TD("8–35\n(varies with\nco-meds)"),TD("2–7"), TD("55%"),  TDL("Glucuronidation (UGT);\nno active metabolites"), TDL("t½ ↑ with valproate;\nt½ ↓ with CBZ, PHT")],
    [BTD("Levetiracetam"),  TD("6–11"),   TD("12–46"),   TD("<10%"),  TDL("Minimal; 66% excreted\nunchanged in urine"),TDL("Dose reduce in CKD;\nno hepatic interactions")],
    [BTD("Gabapentin"),     TD("5–9"),    TD("Variable"), TD("<5%"),   TDL("Not metabolized;\nexcreted unchanged in urine"), TDL("Dose reduce in CKD;\nzero CYP interactions")],
    [BTD("Pregabalin"),     TD("6–7"),    TD("Variable"), TD("<5%"),   TDL("Not metabolized;\nexcreted unchanged in urine"), TDL("Dose reduce in CKD;\nschedule V (abuse risk)")],
    [BTD("Topiramate"),     TD("21"),     TD("Variable"), TD("~15%"),  TDL("~50% excreted\nunchanged in urine"),           TDL("Mild renal excretion;\nsome hepatic")],
]
pk_tbl = Table(pk_data, colWidths=[W*0.13, W*0.10, W*0.16, W*0.12, W*0.24, W*0.25])
pk_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0),  (-1,0),  GREEN),
    ("TEXTCOLOR",     (0,0),  (-1,0),  WHITE),
    *[("BACKGROUND",  (0,i),  (-1,i),  LIGHT_GREEN if i%2==1 else GRAY_LIGHT) for i in range(1, len(pk_data))],
    ("GRID",          (0,0),  (-1,-1), 0.4, colors.white),
    ("TOPPADDING",    (0,0),  (-1,-1), 3),
    ("BOTTOMPADDING", (0,0),  (-1,-1), 3),
    ("LEFTPADDING",   (0,0),  (-1,-1), 4),
    ("RIGHTPADDING",  (0,0),  (-1,-1), 4),
    ("VALIGN",        (0,0),  (-1,-1), "TOP"),
    ("ALIGN",         (0,0),  (-1,0),  "CENTER"),
    ("ALIGN",         (0,1),  (1,-1),  "CENTER"),
    ("ALIGN",         (0,2),  (2,-1),  "CENTER"),
    ("ALIGN",         (0,3),  (3,-1),  "CENTER"),
]))
story.append(pk_tbl)
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════
# 8. HIGH-YIELD MNEMONICS & EXAM TIPS
# ════════════════════════════════════════════════════════════════════
story.append(section_header("8.  High-Yield Mnemonics & Exam Tips", color=colors.HexColor("#4A148C")))
story.append(Spacer(1, 3*mm))

mnemonic_data = [
    [TH("Drug / Topic"), TH("Mnemonic / Key Point")],
    [BTD("Phenytoin\nSide Effects"),
     TDL('"HAGG-SNOD"\nH = Hirsutism\nA = Ataxia / nystagmus\nG = Gingival hyperplasia\nG = Gait disturbance (ataxia)\nS = Stevens-Johnson\nN = Neuropathy (peripheral)\nO = Osteoporosis\nD = Diplopia / Drug interactions (CYP inducer)')],
    [BTD("Valproate\nSide Effects"),
     TDL('"PANTHER"\nP = Pancreatitis\nA = Alopecia\nN = Neural tube defects (teratogen #1)\nT = Tremor, Thrombocytopenia\nH = Hepatotoxicity\nE = Enzyme Inhibitor\nR = Rampant weight gain')],
    [BTD("Carbamazepine\nSide Effects"),
     TDL('"HAS" + SJS\nH = Hyponatremia\nA = Aplastic anemia\nS = Stevens-Johnson (check HLA-B*1502 in Asians!)\nAlso: autoinduces, teratogenic, worsens ABSENCE')],
    [BTD("GABA-A receptor:\nBZD vs Barbiturate"),
     TDL('BZD = B-F: increases FREQUENCY of Cl⁻ channel opening\nBarbiturate = B-D: increases DURATION of Cl⁻ channel opening\n(Remember: "BZD = F-requency; Barbiturate = D-uration")')],
    [BTD("AEDs that WORSEN\nAbsence Seizures"),
     TDL('"Can These Villains Go?" → CBZ, Tiagabine, Vigabatrin, GABApentin (and Phenytoin)\nAll Na⁺ channel blockers except Valproate + Lamotrigine can worsen absence')],
    [BTD("Enzyme INDUCERS\n(forget your OCP!)"),
     TDL('"PPCRBR" (Pile Pheno, Carba, Rifampin, Barb, Rifabutin)\nPhenytoin, Phenobarbital, Carbamazepine, Primidone = classic enzyme inducers\n→ Reduce OCP efficacy! Warn women of childbearing age')],
    [BTD("Status Epilepticus\nManagement Steps"),
     TDL('Step 1 (0–5 min): ABCs, IV access, glucose\nStep 2 (5–20 min): Lorazepam IV 0.1 mg/kg OR Diazepam IV\nStep 3 (20–40 min): Fosphenytoin IV OR Valproate IV OR Levetiracetam IV\nStep 4 (>40 min): Intubation + Midazolam / Propofol / Phenobarbital\nStep 5 (refractory): Pentobarbital coma, Ketamine, Isoflurane')],
    [BTD("Ethosuximide\nvs Valproate for Absence"),
     TDL('Pure absence only → Ethosuximide (T-Ca²⁺ channel only)\nAbsence + Tonic-clonic → Valproate (broad spectrum)\nIf valproate fails absence → add/switch to Lamotrigine')],
    [BTD("Phenytoin\nspecial facts"),
     TDL('• Fosphenytoin = prodrug → preferred for IV/IM use\n• Phenytoin SODIUM: NEVER IM → causes tissue necrosis\n• Nonlinear PK: small dose change → huge plasma level change\n• Zero-order kinetics at therapeutic doses')],
    [BTD("Levetiracetam\n'Keppra Rage'"),
     TDL('Behavioral effects: irritability, depression, psychosis\nAdd B6 (pyridoxine) supplementation may help\nMinimal drug interactions → useful in polypharmacy\nRenal dosing required in CKD')],
]

mn_tbl = Table(mnemonic_data, colWidths=[W*0.20, W*0.80])
mn_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0),  (-1,0),  colors.HexColor("#4A148C")),
    ("TEXTCOLOR",     (0,0),  (-1,0),  WHITE),
    *[("BACKGROUND",  (0,i),  (-1,i),  YELLOW_BG if i%2==1 else GRAY_LIGHT) for i in range(1, len(mnemonic_data))],
    ("GRID",          (0,0),  (-1,-1), 0.4, colors.white),
    ("TOPPADDING",    (0,0),  (-1,-1), 5),
    ("BOTTOMPADDING", (0,0),  (-1,-1), 5),
    ("LEFTPADDING",   (0,0),  (-1,-1), 6),
    ("RIGHTPADDING",  (0,0),  (-1,-1), 6),
    ("VALIGN",        (0,0),  (-1,-1), "TOP"),
    ("ALIGN",         (0,0),  (-1,0),  "CENTER"),
]))
story.append(mn_tbl)
story.append(Spacer(1, 5*mm))

# ════════════════════════════════════════════════════════════════════
# FOOTER
# ════════════════════════════════════════════════════════════════════
footer_data = [[P("Sources: Katzung's Basic & Clinical Pharmacology 16e | Lippincott Illustrated Reviews: Pharmacology | Adams & Victor's Principles of Neurology 12e | Barash Clinical Anesthesia 9e", note_style)]]
footer_tbl = Table(footer_data, colWidths=[W])
footer_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,-1), LIGHT_TEAL),
    ("TOPPADDING",    (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING",   (0,0), (-1,-1), 8),
    ("ROUNDEDCORNERS",[4]),
]))
story.append(footer_tbl)

# ── Build PDF ──────────────────────────────────────────────────────
doc.build(story)
print(f"PDF created: {OUTPUT}")
Running Command

cd /home/daytona/workspace/aed_summary && python generate_pdf.py 2>&1

Running Command

ls -lh /home/daytona/workspace/aed_summary/Antiepileptic_Drugs_Summary.pdf

Your PDF is ready for download:

Antiepileptic Drugs Summary

PDF Document · PDF


Here's what's packed into the PDF (4 pages, color-coded by section):
SectionContent
1. Classification by MechanismAll drugs grouped by Na⁺ blockers, Ca²⁺ blockers, GABA enhancers, SV2A ligands, broad-spectrum
2. Main Drug Comparison Table10 drugs - mechanism, uses, side effects, unique exam tips side by side
3. Seizure → Drug of Choice13 seizure types mapped to DOC + alternatives + drugs to avoid
4. Distinctive Side Effects23 side effects mapped to responsible drugs (gingival hyperplasia, SJS, hepatotoxicity, etc.)
5. Enzyme InteractionsInducers vs inhibitors, OCP interactions, valproate-lamotrigine interaction
6. Teratogenicity TableRisk ranking Valproate > CBZ > Phenytoin > Phenobarbital > Lamotrigine > Levetiracetam
7. Pharmacokineticst½, therapeutic levels, protein binding, metabolism for all major AEDs
8. Mnemonics & Exam TipsHAGG-SNOD (phenytoin), PANTHER (valproate), HAS (carbamazepine), Status epilepticus steps, and more
This is a shared conversation. Sign in to Orris to start your own chat.