~/drug-reference/build_pdf.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm, mm
from reportlab.platypus import (
SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
HRFlowable, PageBreak, KeepTogether
)
from reportlab.lib.enums import TA_CENTER, TA_LEFT
from reportlab.platypus import BaseDocTemplate, Frame, PageTemplate
OUTPUT = "/home/daytona/workspace/drug-reference/Drug_Classes_Quick_Reference.pdf"
# ─── Colour palette ───────────────────────────────────────────────────────────
NAVY = colors.HexColor("#1B3A5C")
TEAL = colors.HexColor("#1A7A8A")
LBLUE = colors.HexColor("#D6EAF8")
MINT = colors.HexColor("#D1F2EB")
LEMON = colors.HexColor("#FEF9E7")
LAVEN = colors.HexColor("#EBE6F5")
SALMON = colors.HexColor("#FDECEA")
PEACH = colors.HexColor("#FEF3E7")
WHITE = colors.white
LGRAY = colors.HexColor("#F2F3F4")
DGRAY = colors.HexColor("#5D6D7E")
BLACK = colors.black
# ─── System colour map ────────────────────────────────────────────────────────
SYS_COLORS = {
"Cardiovascular": (colors.HexColor("#154360"), colors.HexColor("#D6EAF8")),
"Nervous System": (colors.HexColor("#1B5E20"), colors.HexColor("#D5F5E3")),
"Antimicrobials": (colors.HexColor("#6E2F0A"), colors.HexColor("#FDEBD0")),
"Endocrine": (colors.HexColor("#4A235A"), colors.HexColor("#F5EEF8")),
"Respiratory": (colors.HexColor("#1A5276"), colors.HexColor("#D6EAF8")),
"Anticancer": (colors.HexColor("#7B241C"), colors.HexColor("#FDEDEC")),
"GI": (colors.HexColor("#0E6655"), colors.HexColor("#D0ECE7")),
"Anticoag/Platelet": (colors.HexColor("#784212"), colors.HexColor("#FDEBD0")),
"Immunosuppressants":(colors.HexColor("#283747"), colors.HexColor("#D6DBDF")),
}
# ─── Styles ───────────────────────────────────────────────────────────────────
styles = getSampleStyleSheet()
def make_style(name, parent="Normal", **kwargs):
return ParagraphStyle(name, parent=styles[parent], **kwargs)
cover_title = make_style("CoverTitle", fontSize=32, textColor=WHITE,
alignment=TA_CENTER, fontName="Helvetica-Bold", leading=38)
cover_sub = make_style("CoverSub", fontSize=14, textColor=colors.HexColor("#A9CCE3"),
alignment=TA_CENTER, fontName="Helvetica", leading=20)
cover_date = make_style("CoverDate", fontSize=10, textColor=colors.HexColor("#85C1E9"),
alignment=TA_CENTER, fontName="Helvetica")
sys_heading = make_style("SysHeading", fontSize=13, textColor=WHITE,
fontName="Helvetica-Bold", leading=16, spaceAfter=0, spaceBefore=0)
cls_name = make_style("ClsName", fontSize=9, textColor=NAVY,
fontName="Helvetica-Bold", leading=12)
moa_text = make_style("MoaText", fontSize=8, textColor=colors.HexColor("#2C3E50"),
fontName="Helvetica", leading=11)
eg_text = make_style("EgText", fontSize=7.5,textColor=DGRAY,
fontName="Helvetica-Oblique", leading=10)
note_text = make_style("NoteText", fontSize=7, textColor=colors.HexColor("#7F8C8D"),
fontName="Helvetica", leading=9)
toc_style = make_style("TocStyle", fontSize=10, textColor=NAVY,
fontName="Helvetica", leading=16)
toc_heading = make_style("TocHeading", fontSize=14, textColor=NAVY,
fontName="Helvetica-Bold", leading=20, spaceAfter=6)
footer_sty = make_style("Footer", fontSize=7, textColor=DGRAY,
fontName="Helvetica", alignment=TA_CENTER)
# ─── Drug data ────────────────────────────────────────────────────────────────
DRUG_DATA = {
"Cardiovascular": [
("ACE Inhibitors",
"Inhibit angiotensin-converting enzyme → ↓ angiotensin II → vasodilation + ↓ aldosterone",
"Lisinopril, Enalapril, Ramipril, Perindopril"),
("ARBs (Angiotensin Receptor Blockers)",
"Block AT1 receptor → vasodilation (angiotensin II still formed but cannot act)",
"Losartan, Valsartan, Irbesartan, Candesartan"),
("Beta-Blockers (β-blockers)",
"Competitive antagonism at β1 (± β2) adrenoceptors → ↓ HR, ↓ CO, ↓ renin release",
"Metoprolol, Atenolol, Bisoprolol, Carvedilol, Propranolol"),
("Calcium Channel Blockers (CCBs)",
"Block L-type voltage-gated Ca²⁺ channels → vasodilation (dihydropyridines) / ↓ nodal conduction (non-DHP)",
"Amlodipine, Nifedipine (DHP); Verapamil, Diltiazem (non-DHP)"),
("Thiazide Diuretics",
"Inhibit Na⁺/Cl⁻ cotransporter (NCC) in distal convoluted tubule → ↑ NaCl excretion",
"Hydrochlorothiazide, Chlorthalidone, Indapamide"),
("Loop Diuretics",
"Inhibit Na⁺/K⁺/2Cl⁻ cotransporter (NKCC2) in thick ascending loop of Henle",
"Furosemide, Bumetanide, Torsemide"),
("Aldosterone Antagonists",
"Block mineralocorticoid receptor → ↓ Na⁺ reabsorption, K⁺-sparing",
"Spironolactone, Eplerenone, Finerenone"),
("Statins (HMG-CoA Reductase Inhibitors)",
"Inhibit HMG-CoA reductase → ↓ cholesterol synthesis → upregulate hepatic LDL receptors",
"Atorvastatin, Rosuvastatin, Simvastatin, Pravastatin"),
("PCSK9 Inhibitors",
"Monoclonal antibodies blocking PCSK9 → prevent LDL receptor degradation → ↓↓ LDL",
"Evolocumab, Alirocumab"),
("Antiarrhythmics – Class I (Na⁺ blockers)",
"Ia: ↓ conduction + prolong APD (quinidine). Ib: shorten APD (lidocaine). Ic: ↓↓ conduction (flecainide)",
"Ia: Quinidine, Procainamide; Ib: Lidocaine, Mexiletine; Ic: Flecainide, Propafenone"),
("Antiarrhythmics – Class III (K⁺ blockers)",
"Block K⁺ channels → prolong repolarisation and QT interval",
"Amiodarone, Sotalol, Dofetilide, Ibutilide"),
("Digoxin",
"Inhibits Na⁺/K⁺-ATPase → ↑ intracellular Ca²⁺ → ↑ contractility; vagal tone ↑ → ↓ AV conduction",
"Digoxin"),
("Nitrates",
"Metabolised to NO → activate guanylyl cyclase → ↑ cGMP → vascular smooth muscle relaxation",
"GTN (nitroglycerin), Isosorbide mononitrate/dinitrate"),
("SGLT2 Inhibitors (cardiac/renal)",
"Block SGLT2 in proximal tubule → glucosuria; reduce preload/afterload, cardioprotective",
"Empagliflozin, Dapagliflozin, Canagliflozin"),
],
"Nervous System": [
("Opioid Analgesics",
"Agonists at μ (mu), κ (kappa), δ (delta) opioid receptors (Gi-coupled) → ↓ cAMP, ↓ Ca²⁺ influx, ↑ K⁺ efflux → analgesia",
"Morphine, Fentanyl, Oxycodone, Codeine, Tramadol, Buprenorphine"),
("NSAIDs",
"Non-selective inhibition of COX-1 and COX-2 → ↓ prostaglandin synthesis → analgesia, antipyresis, anti-inflammation",
"Ibuprofen, Naproxen, Diclofenac, Ketorolac"),
("Selective COX-2 Inhibitors",
"Selectively inhibit inducible COX-2 → ↓ prostaglandins with fewer GI effects (COX-1 spared)",
"Celecoxib, Etoricoxib"),
("SSRIs (Antidepressants)",
"Selectively inhibit serotonin reuptake transporter (SERT) → ↑ synaptic serotonin",
"Fluoxetine, Sertraline, Escitalopram, Paroxetine, Citalopram"),
("SNRIs (Antidepressants)",
"Inhibit both SERT and norepinephrine transporter (NET) → ↑ synaptic 5-HT and NE",
"Venlafaxine, Duloxetine, Desvenlafaxine"),
("TCAs (Tricyclic Antidepressants)",
"Inhibit NET and SERT; also block H1, muscarinic M1, α1 receptors → multiple side effects",
"Amitriptyline, Imipramine, Nortriptyline, Clomipramine"),
("MAO Inhibitors",
"Irreversibly inhibit monoamine oxidase A/B → ↑ NE, 5-HT, dopamine at synapse",
"Phenelzine, Tranylcypromine; Moclobemide (reversible MAO-A)"),
("Typical Antipsychotics",
"Primarily D2 dopamine receptor antagonists → block mesolimbic pathway (antipsychotic) + nigrostriatal (EPS)",
"Haloperidol, Chlorpromazine, Fluphenazine, Trifluoperazine"),
("Atypical Antipsychotics",
"D2 antagonism + 5-HT2A antagonism (and other receptors) → antipsychotic with lower EPS risk",
"Olanzapine, Quetiapine, Risperidone, Aripiprazole, Clozapine"),
("Benzodiazepines",
"Positive allosteric modulators of GABAA receptors → ↑ frequency of Cl⁻ channel opening → CNS depression",
"Diazepam, Lorazepam, Clonazepam, Alprazolam, Midazolam"),
("Antiepileptics – Na⁺ Channel Blockers",
"Stabilise inactivated state of voltage-gated Na⁺ channels → prevent repetitive firing",
"Phenytoin, Carbamazepine, Lamotrigine, Oxcarbazepine, Valproate"),
("Antiepileptics – SV2A Modulators",
"Bind synaptic vesicle glycoprotein 2A → modulate neurotransmitter release",
"Levetiracetam, Brivaracetam"),
("Levodopa / Dopamine Agonists",
"Levodopa: precursor converted to dopamine in CNS. DA agonists: directly stimulate D2/D3 receptors",
"Levodopa + Carbidopa; Pramipexole, Ropinirole, Rotigotine"),
("Acetylcholinesterase Inhibitors",
"Inhibit AChE → ↑ acetylcholine at cholinergic synapses (central and peripheral)",
"Donepezil, Rivastigmine, Galantamine (dementia); Neostigmine (NMJ)"),
],
"Antimicrobials": [
("Beta-Lactams (Penicillins / Cephalosporins / Carbapenems)",
"Inhibit transpeptidases (PBPs) → prevent peptidoglycan cross-linking → cell wall synthesis failure → bactericidal",
"Amoxicillin, Flucloxacillin; Cefazolin, Ceftriaxone; Meropenem, Ertapenem"),
("Glycopeptides",
"Bind D-Ala-D-Ala terminus of peptidoglycan precursors → block transglycosylation and transpeptidation",
"Vancomycin, Teicoplanin"),
("Aminoglycosides",
"Irreversibly bind 30S ribosomal subunit (16S rRNA) → misreading of mRNA → premature termination → bactericidal",
"Gentamicin, Amikacin, Tobramycin, Streptomycin"),
("Tetracyclines",
"Reversibly bind 30S ribosome → block aminoacyl-tRNA entry at A site → bacteriostatic",
"Doxycycline, Minocycline, Tetracycline, Tigecycline"),
("Macrolides",
"Bind 50S ribosome (23S rRNA) at peptidyl transferase site → block translocation → bacteriostatic",
"Azithromycin, Clarithromycin, Erythromycin"),
("Fluoroquinolones",
"Inhibit DNA gyrase (topoisomerase II) and topoisomerase IV → prevent DNA replication and repair → bactericidal",
"Ciprofloxacin, Levofloxacin, Moxifloxacin, Norfloxacin"),
("Sulfonamides + Trimethoprim",
"Sulfonamides: inhibit dihydropteroate synthase. TMP: inhibits DHFR. Both block folate synthesis at sequential steps",
"Sulfamethoxazole-Trimethoprim (Co-trimoxazole / TMP-SMX)"),
("Metronidazole",
"Reduced to cytotoxic nitroso free-radical intermediates inside anaerobic/microaerophilic organisms → DNA strand breaks",
"Metronidazole, Tinidazole"),
("Oxazolidinones",
"Bind 50S+30S junction → prevent 70S initiation complex formation → inhibit protein synthesis",
"Linezolid, Tedizolid"),
("NRTIs (Antiretrovirals)",
"Nucleoside/nucleotide analogues incorporated into viral DNA → chain termination (lack 3'-OH group)",
"Zidovudine (AZT), Tenofovir (TDF/TAF), Emtricitabine, Lamivudine, Abacavir"),
("NNRTIs (Antiretrovirals)",
"Bind allosteric pocket on HIV reverse transcriptase (non-competitive) → conformational change → enzyme inactivation",
"Efavirenz, Nevirapine, Rilpivirine, Doravirine"),
("HIV Protease Inhibitors",
"Block HIV aspartyl protease → prevent polyprotein cleavage → immature, non-infectious virions",
"Ritonavir, Darunavir, Lopinavir, Atazanavir"),
("HIV Integrase Inhibitors",
"Block HIV integrase strand transfer → prevent integration of viral DNA into host genome",
"Raltegravir, Dolutegravir, Bictegravir, Cabotegravir"),
("Antifungals – Azoles",
"Inhibit fungal CYP51 (lanosterol 14α-demethylase) → ↓ ergosterol synthesis → membrane disruption",
"Fluconazole, Itraconazole, Voriconazole, Posaconazole"),
("Antifungals – Polyenes",
"Bind directly to ergosterol in fungal membrane → pore formation → ion leakage → fungicidal",
"Amphotericin B, Nystatin"),
("Antifungals – Echinocandins",
"Inhibit β-1,3-glucan synthase → disrupt fungal cell wall synthesis → fungicidal for Candida",
"Caspofungin, Micafungin, Anidulafungin"),
("Neuraminidase Inhibitors (Influenza)",
"Block influenza neuraminidase → prevent cleavage of sialic acid → inhibit viral release from cells",
"Oseltamivir (Tamiflu), Zanamivir, Baloxavir (different MOA: cap-dependent endonuclease inhibitor)"),
],
"Endocrine": [
("Insulin",
"Binds insulin receptor (receptor tyrosine kinase) → GLUT4 translocation → glucose uptake; anabolic effects on fat, protein",
"Rapid: Lispro, Aspart, Glulisine; Short: Regular; Inter: NPH; Long: Glargine, Detemir, Degludec"),
("Metformin (Biguanide)",
"Activates AMPK; inhibits mitochondrial Complex I → ↓ hepatic gluconeogenesis; does not cause hypoglycaemia",
"Metformin"),
("Sulfonylureas",
"Block ATP-sensitive K⁺ channels (KATP) on β-cells → membrane depolarisation → Ca²⁺ influx → insulin secretion",
"Glibenclamide, Glipizide, Gliclazide, Glimepiride"),
("GLP-1 Receptor Agonists",
"Bind GLP-1R (Gs-coupled) → ↑ glucose-dependent insulin secretion, ↓ glucagon, slow gastric emptying, ↓ appetite",
"Semaglutide, Liraglutide, Dulaglutide, Exenatide, Tirzepatide (dual GLP-1/GIP)"),
("DPP-4 Inhibitors (Gliptins)",
"Block dipeptidyl peptidase-4 enzyme → prevent degradation of endogenous GLP-1 and GIP → modest incretin enhancement",
"Sitagliptin, Saxagliptin, Linagliptin, Alogliptin"),
("SGLT2 Inhibitors (metabolic)",
"Block Na⁺-glucose cotransporter 2 in proximal tubule → glucosuria → ↓ plasma glucose; weight loss, BP reduction",
"Empagliflozin, Dapagliflozin, Canagliflozin, Ertugliflozin"),
("Thiazolidinediones (TZDs)",
"Activate PPARγ nuclear receptor → regulate adipokine and glucose transporter gene expression → ↑ insulin sensitivity",
"Pioglitazone, Rosiglitazone"),
("Levothyroxine",
"Replaces/supplements T4 → converted peripherally to T3 → binds nuclear thyroid hormone receptors → regulate metabolism",
"Levothyroxine (T4); Liothyronine (T3)"),
("Thionamides (Antithyroid)",
"Inhibit thyroid peroxidase → block T3/T4 synthesis. PTU also blocks T4→T3 peripheral conversion",
"Methimazole, Carbimazole, Propylthiouracil (PTU)"),
("Glucocorticoids",
"Bind intracellular GR → translocate to nucleus → suppress NF-κB, AP-1 → broad anti-inflammatory and immunosuppressive",
"Prednisolone, Dexamethasone, Hydrocortisone, Methylprednisolone, Budesonide"),
],
"Respiratory": [
("Short-Acting β2-Agonists (SABA)",
"Activate β2-adrenoceptors → Gs → ↑ cAMP → PKA activation → smooth muscle relaxation → bronchodilation (rapid onset)",
"Albuterol (Salbutamol), Terbutaline, Levalbuterol"),
("Long-Acting β2-Agonists (LABA)",
"Same mechanism as SABA; lipophilic tail anchors in membrane → prolonged receptor engagement (12–24 h duration)",
"Salmeterol, Formoterol, Indacaterol, Vilanterol"),
("Short-Acting Muscarinic Antagonists (SAMA)",
"Block M3 muscarinic receptors on bronchial smooth muscle → prevent ACh-induced bronchoconstriction",
"Ipratropium bromide"),
("Long-Acting Muscarinic Antagonists (LAMA)",
"Same mechanism as SAMA; selectively dissociate from M3 slowly (kinetically selective) → 24 h bronchodilation",
"Tiotropium, Umeclidinium, Glycopyrronium, Aclidinium"),
("Inhaled Corticosteroids (ICS)",
"Bind GR → suppress inflammatory gene transcription → ↓ cytokines, ↓ eosinophil infiltration → reduce airway inflammation",
"Budesonide, Fluticasone, Beclomethasone, Ciclesonide, Mometasone"),
("Leukotriene Receptor Antagonists (LTRA)",
"Block CysLT1 receptors → prevent leukotriene-mediated bronchoconstriction, mucus secretion, eosinophil recruitment",
"Montelukast, Zafirlukast"),
("PDE4 Inhibitors",
"Inhibit phosphodiesterase-4 → ↑ cAMP in inflammatory cells → anti-inflammatory; used in COPD",
"Roflumilast"),
("Anti-IgE Biologic",
"Binds free IgE → prevents IgE binding to mast cell FcεRI receptors → inhibit mast cell degranulation",
"Omalizumab"),
("Anti-IL-5 / IL-4/13 Biologics",
"IL-5 blockade: ↓ eosinophil survival/recruitment. IL-4/13 blockade: ↓ Th2 inflammation, ↓ IgE, ↓ mucus",
"Mepolizumab, Benralizumab (anti-IL-5); Dupilumab (anti-IL-4Rα/IL-13)"),
],
"Anticancer": [
("Alkylating Agents",
"Form covalent bonds with DNA → intra/inter-strand cross-links → prevent replication and transcription → apoptosis",
"Cyclophosphamide, Ifosfamide, Cisplatin, Carboplatin, Oxaliplatin, Dacarbazine"),
("Antimetabolites – Folate Antagonists",
"Inhibit dihydrofolate reductase (DHFR) → ↓ THF → impair thymidylate and purine synthesis",
"Methotrexate, Pemetrexed"),
("Antimetabolites – Pyrimidine Analogues",
"5-FU: inhibit thymidylate synthase + incorporated into RNA. Cytarabine: incorporated into DNA → chain termination",
"5-Fluorouracil (5-FU), Capecitabine (prodrug of 5-FU), Cytarabine, Gemcitabine"),
("Topoisomerase Inhibitors",
"Topo I inhibitors (camptothecins): stabilise Topo I-DNA complex → single-strand breaks. Topo II inhibitors: stabilise cleavable complex → double-strand breaks",
"Irinotecan, Topotecan (Topo I); Doxorubicin, Etoposide, Epirubicin (Topo II)"),
("Vinca Alkaloids",
"Bind β-tubulin → inhibit tubulin polymerisation → prevent spindle formation → metaphase arrest → apoptosis",
"Vincristine, Vinblastine, Vinorelbine"),
("Taxanes",
"Bind and stabilise polymerised microtubules → prevent depolymerisation → disrupt spindle dynamics → cell death",
"Paclitaxel, Docetaxel, Nab-paclitaxel, Cabazitaxel"),
("Tyrosine Kinase Inhibitors (TKIs)",
"Competitively inhibit ATP binding site of tyrosine kinases → block downstream proliferation/survival signalling",
"Imatinib (BCR-ABL), Erlotinib/Gefitinib (EGFR), Trastuzumab+Lapatinib (HER2), Ibrutinib (BTK)"),
("VEGF Pathway Inhibitors",
"Bevacizumab: anti-VEGF antibody → prevents VEGF binding to receptor → inhibit tumour angiogenesis",
"Bevacizumab, Ramucirumab; Sunitinib, Sorafenib (multi-target TKIs incl. VEGFR)"),
("Immune Checkpoint Inhibitors",
"Block PD-1/PD-L1 or CTLA-4 co-inhibitory pathways → restore T-cell anti-tumour immune response",
"Pembrolizumab, Nivolumab (anti-PD-1); Atezolizumab (anti-PD-L1); Ipilimumab (anti-CTLA-4)"),
("Hormone Therapy",
"SERMs/aromatase inhibitors: block estrogen signalling in ER+ breast cancer. Anti-androgens: block AR in prostate cancer",
"Tamoxifen (SERM), Letrozole/Anastrozole (aromatase inhibitors); Enzalutamide, Abiraterone (prostate)"),
],
"GI": [
("Proton Pump Inhibitors (PPIs)",
"Irreversibly inhibit H⁺/K⁺-ATPase (proton pump) on gastric parietal cells → profound ↓ acid secretion",
"Omeprazole, Pantoprazole, Lansoprazole, Esomeprazole, Rabeprazole"),
("H2 Receptor Antagonists",
"Competitively block H2 receptors on parietal cells → reduce histamine-stimulated acid secretion",
"Ranitidine, Famotidine, Cimetidine"),
("5-HT3 Antagonists (Antiemetics)",
"Block 5-HT3 receptors on vagal afferents and in chemoreceptor trigger zone → suppress nausea/vomiting",
"Ondansetron, Granisetron, Palonosetron"),
("NK1 Receptor Antagonists (Antiemetics)",
"Block substance P at NK1 receptors in nucleus tractus solitarius → prevent chemotherapy-induced delayed emesis",
"Aprepitant, Fosaprepitant, Netupitant"),
("Prokinetics",
"Metoclopramide/Domperidone: D2 antagonism → ↑ GI motility + antiemetic. Metoclopramide also 5-HT4 agonist",
"Metoclopramide, Domperidone, Prucalopride (5-HT4 agonist)"),
("Laxatives",
"Osmotic: draw water into lumen (lactulose, macrogol). Stimulant: activate myenteric plexus (senna, bisacodyl). Bulk: increase stool bulk (psyllium)",
"Lactulose, Macrogol; Senna, Bisacodyl; Psyllium, Methylcellulose"),
("Antidiarrhoeals",
"Loperamide: agonist at enteric μ-opioid receptors → ↓ peristalsis, ↑ anal sphincter tone, ↓ secretion (does not cross BBB)",
"Loperamide; Codeine phosphate; Bismuth subsalicylate"),
("IBD Biologics",
"Anti-TNF: block TNF-α-mediated inflammation. Anti-integrins: block gut-homing lymphocyte trafficking",
"Infliximab, Adalimumab (anti-TNF); Vedolizumab (anti-α4β7 integrin); Ustekinumab (anti-IL-12/23)"),
],
"Anticoag/Platelet": [
("Unfractionated Heparin (UFH)",
"Activates antithrombin III → accelerates inhibition of thrombin (IIa), Factor Xa and others; effect monitored by aPTT",
"Unfractionated Heparin (IV/SC)"),
("Low Molecular Weight Heparins (LMWH)",
"Activate antithrombin III with preference for Factor Xa inhibition over thrombin; more predictable PK, no routine monitoring",
"Enoxaparin, Dalteparin, Tinzaparin"),
("Vitamin K Antagonists",
"Inhibit VKORC1 (Vitamin K epoxide reductase) → deplete Factors II, VII, IX, X + Protein C/S; effect monitored by INR/PT",
"Warfarin, Acenocoumarol, Phenprocoumon"),
("Direct Thrombin Inhibitors (DTIs)",
"Directly inhibit thrombin (Factor IIa) independent of antithrombin; dabigatran is oral, bivalirudin is parenteral",
"Dabigatran (oral DOAC); Bivalirudin, Argatroban (parenteral)"),
("Direct Factor Xa Inhibitors",
"Directly inhibit Factor Xa at active site → block prothrombinase complex; predictable PK, no routine monitoring",
"Rivaroxaban, Apixaban, Edoxaban, Betrixaban"),
("Aspirin (Antiplatelet)",
"Irreversibly acetylates serine residue on COX-1 → prevents TXA2 synthesis → ↓ platelet aggregation for platelet lifespan",
"Aspirin 75–100 mg (antiplatelet dose)"),
("P2Y12 Receptor Antagonists",
"Block ADP-activated P2Y12 purinergic receptor on platelets → prevent Gi-mediated ↓ cAMP → ↓ platelet activation",
"Clopidogrel, Prasugrel (irreversible); Ticagrelor, Cangrelor (reversible)"),
("GP IIb/IIIa Inhibitors",
"Block fibrinogen/vWF binding site on glycoprotein IIb/IIIa (αIIbβ3 integrin) → prevent platelet cross-linking/aggregation",
"Abciximab (mAb), Eptifibatide, Tirofiban (small molecules)"),
],
"Immunosuppressants": [
("Calcineurin Inhibitors",
"Inhibit calcineurin phosphatase → prevent NFAT dephosphorylation → block IL-2 gene transcription → ↓ T-cell activation",
"Cyclosporine (CsA), Tacrolimus (FK506)"),
("mTOR Inhibitors",
"Inhibit mTOR kinase (FKBP12 complex) → block IL-2 receptor signalling → prevent T- and B-cell proliferation",
"Sirolimus (Rapamycin), Everolimus"),
("Antimetabolites (Immunosuppressant)",
"Azathioprine: prodrug → 6-MP → inhibit de novo purine synthesis → ↓ lymphocyte proliferation. MMF: inhibit IMPDH",
"Azathioprine, Mycophenolate mofetil (MMF)"),
("Anti-TNF Biologics",
"Block TNF-α (soluble or membrane-bound) → ↓ downstream NF-κB activation → reduce systemic inflammation",
"Infliximab, Adalimumab, Etanercept, Certolizumab, Golimumab"),
("JAK Inhibitors",
"Inhibit Janus kinases (JAK1, JAK2, JAK3, TYK2) → block cytokine receptor signalling (JAK-STAT pathway)",
"Tofacitinib (JAK1/3), Baricitinib (JAK1/2), Upadacitinib (JAK1), Ruxolitinib (JAK1/2)"),
("IL-6 Receptor Antagonists",
"Block IL-6 receptor → prevent IL-6-mediated pro-inflammatory signalling (STAT3 activation)",
"Tocilizumab, Sarilumab"),
("Anti-CD20 (B-cell depletion)",
"Bind CD20 on B-cell surface → antibody-dependent cellular cytotoxicity (ADCC), CDC, and apoptosis → B-cell depletion",
"Rituximab, Obinutuzumab, Ocrelizumab"),
],
}
# ─── Page decorators ──────────────────────────────────────────────────────────
def cover_bg(canvas, doc):
canvas.saveState()
# Dark gradient background simulation
canvas.setFillColor(NAVY)
canvas.rect(0, 0, A4[0], A4[1], fill=1, stroke=0)
# Decorative accent stripe
canvas.setFillColor(TEAL)
canvas.rect(0, A4[1]*0.38, A4[0], 4, fill=1, stroke=0)
canvas.setFillColor(colors.HexColor("#2E86C1"))
canvas.rect(0, A4[1]*0.38-6, A4[0], 3, fill=1, stroke=0)
canvas.restoreState()
def inner_page(canvas, doc):
canvas.saveState()
# Subtle top bar
canvas.setFillColor(NAVY)
canvas.rect(0, A4[1]-18*mm, A4[0], 18*mm, fill=1, stroke=0)
# Footer
canvas.setFillColor(LGRAY)
canvas.rect(0, 0, A4[0], 12*mm, fill=1, stroke=0)
canvas.setFont("Helvetica", 7)
canvas.setFillColor(DGRAY)
canvas.drawCentredString(A4[0]/2, 4*mm,
f"Drug Classes Quick Reference | Page {doc.page} | For educational use only")
# Header text
canvas.setFillColor(WHITE)
canvas.setFont("Helvetica-Bold", 9)
canvas.drawString(1.5*cm, A4[1]-12*mm, "DRUG CLASSES QUICK REFERENCE")
canvas.setFont("Helvetica", 9)
canvas.drawRightString(A4[0]-1.5*cm, A4[1]-12*mm, "Pharmacology by Body System")
canvas.restoreState()
# ─── Build flowables ──────────────────────────────────────────────────────────
def build_system_table(system, entries, hdr_color, bg_color):
"""Return a KeepTogether block for one drug system section."""
flowables = []
# Section header bar
hdr_data = [[Paragraph(f" {system.upper()}", sys_heading)]]
hdr_tbl = Table(hdr_data, colWidths=[17.5*cm])
hdr_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), hdr_color),
("TOPPADDING", (0,0), (-1,-1), 6),
("BOTTOMPADDING", (0,0), (-1,-1), 6),
("LEFTPADDING", (0,0), (-1,-1), 8),
("ROUNDEDCORNERS", [4]),
]))
flowables.append(hdr_tbl)
flowables.append(Spacer(1, 3))
# Build table rows
rows = []
rows.append([
Paragraph("<b>Drug Class</b>", make_style("TH", fontSize=8, textColor=WHITE, fontName="Helvetica-Bold")),
Paragraph("<b>Mechanism of Action</b>", make_style("TH2", fontSize=8, textColor=WHITE, fontName="Helvetica-Bold")),
Paragraph("<b>Key Examples</b>", make_style("TH3", fontSize=8, textColor=WHITE, fontName="Helvetica-Bold")),
])
for cls, moa, examples in entries:
rows.append([
Paragraph(cls, cls_name),
Paragraph(moa, moa_text),
Paragraph(examples, eg_text),
])
col_w = [4.2*cm, 8.8*cm, 4.5*cm]
tbl = Table(rows, colWidths=col_w, repeatRows=1)
row_bg = []
for i in range(1, len(rows)):
c = bg_color if i % 2 == 1 else WHITE
row_bg.append(("BACKGROUND", (0, i), (-1, i), c))
tbl.setStyle(TableStyle([
# Header row
("BACKGROUND", (0,0), (-1,0), hdr_color),
("TEXTCOLOR", (0,0), (-1,0), WHITE),
("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,0), 8),
("TOPPADDING", (0,0), (-1,0), 5),
("BOTTOMPADDING", (0,0), (-1,0), 5),
# Body
("FONTSIZE", (0,1), (-1,-1), 8),
("TOPPADDING", (0,1), (-1,-1), 4),
("BOTTOMPADDING", (0,1), (-1,-1), 4),
("LEFTPADDING", (0,0), (-1,-1), 5),
("RIGHTPADDING", (0,0), (-1,-1), 5),
("VALIGN", (0,0), (-1,-1), "TOP"),
# Borders
("GRID", (0,0), (-1,-1), 0.3, colors.HexColor("#BDC3C7")),
("LINEBELOW", (0,0), (-1,0), 1, hdr_color),
*row_bg,
]))
flowables.append(tbl)
flowables.append(Spacer(1, 8))
return flowables
# ─── Main ─────────────────────────────────────────────────────────────────────
def main():
doc = SimpleDocTemplate(
OUTPUT,
pagesize=A4,
leftMargin=1.5*cm,
rightMargin=1.5*cm,
topMargin=2.2*cm,
bottomMargin=1.8*cm,
)
story = []
# ── COVER PAGE ─────────────────────────────────────────────────────────────
story.append(Spacer(1, 5*cm))
story.append(Paragraph("DRUG CLASSES", cover_title))
story.append(Spacer(1, 0.4*cm))
story.append(Paragraph("Quick Reference Guide", cover_sub))
story.append(Spacer(1, 0.3*cm))
story.append(Paragraph("Mechanisms of Action · Key Examples · Body System Organisation",
cover_sub))
story.append(Spacer(1, 2*cm))
# Decorative divider on cover
cover_div_data = [[""]]
cover_div = Table(cover_div_data, colWidths=[12*cm])
cover_div.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), TEAL),
("TOPPADDING", (0,0), (-1,-1), 2),
("BOTTOMPADDING", (0,0), (-1,-1), 2),
]))
story.append(cover_div)
story.append(Spacer(1, 2*cm))
story.append(Paragraph("Based on Goodman & Gilman's, Katzung's, and Lippincott's Pharmacology",
cover_date))
story.append(Spacer(1, 0.3*cm))
story.append(Paragraph("For educational use only | 2026", cover_date))
story.append(PageBreak())
# ── TABLE OF CONTENTS ──────────────────────────────────────────────────────
story.append(Spacer(1, 0.5*cm))
story.append(Paragraph("Contents", toc_heading))
story.append(HRFlowable(width="100%", thickness=2, color=TEAL, spaceAfter=10))
systems_list = list(DRUG_DATA.keys())
for i, sys_name in enumerate(systems_list, 1):
n_drugs = len(DRUG_DATA[sys_name])
story.append(Paragraph(
f"<b>{i}.</b> {sys_name} <font color='#7F8C8D' size='9'>({n_drugs} drug classes)</font>",
toc_style))
story.append(Spacer(1, 1*cm))
story.append(Paragraph(
"<font color='#7F8C8D'>Each section covers: Drug Class Name · Mechanism of Action · Prototypical Examples</font>",
note_text))
story.append(PageBreak())
# ── DRUG SECTIONS ──────────────────────────────────────────────────────────
for sys_name, entries in DRUG_DATA.items():
hdr_color, bg_color = SYS_COLORS[sys_name]
section_flowables = build_system_table(sys_name, entries, hdr_color, bg_color)
story.extend(section_flowables)
# ── LEGEND PAGE ────────────────────────────────────────────────────────────
story.append(PageBreak())
story.append(Spacer(1, 0.5*cm))
story.append(Paragraph("Abbreviations & Legend", toc_heading))
story.append(HRFlowable(width="100%", thickness=2, color=TEAL, spaceAfter=10))
abbrevs = [
["↑ / ↓", "Increase / Decrease"],
["MOA", "Mechanism of Action"],
["GPCR", "G-protein coupled receptor"],
["cAMP", "Cyclic adenosine monophosphate"],
["cGMP", "Cyclic guanosine monophosphate"],
["PKA / PKC", "Protein kinase A / C"],
["NF-κB", "Nuclear factor kappa B"],
["STAT", "Signal transducer and activator of transcription"],
["PBP", "Penicillin-binding protein"],
["DHFR", "Dihydrofolate reductase"],
["SERT / NET / DAT", "Serotonin / Norepinephrine / Dopamine transporter"],
["DOAC", "Direct oral anticoagulant"],
["APD", "Action potential duration"],
["EPS", "Extrapyramidal symptoms"],
["AUC", "Area under the curve"],
["PK", "Pharmacokinetics"],
["aPTT / INR / PT", "Activated partial thromboplastin time / International normalised ratio / Prothrombin time"],
["BBB", "Blood-brain barrier"],
["VEGF", "Vascular endothelial growth factor"],
["TNF-α", "Tumour necrosis factor alpha"],
]
abbrev_rows = [[Paragraph("<b>Term</b>", cls_name), Paragraph("<b>Meaning</b>", cls_name)]]
for term, meaning in abbrevs:
abbrev_rows.append([Paragraph(term, moa_text), Paragraph(meaning, moa_text)])
abbrev_tbl = Table(abbrev_rows, colWidths=[5*cm, 12*cm])
abbrev_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), NAVY),
("TEXTCOLOR", (0,0), (-1,0), WHITE),
("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
("GRID", (0,0), (-1,-1), 0.3, colors.HexColor("#BDC3C7")),
("ROWBACKGROUNDS",(0,1), (-1,-1), [LGRAY, WHITE]),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING", (0,0), (-1,-1), 4),
("LEFTPADDING", (0,0), (-1,-1), 6),
]))
story.append(abbrev_tbl)
# ── BUILD ──────────────────────────────────────────────────────────────────
def page_template(canvas, doc):
if doc.page == 1:
cover_bg(canvas, doc)
else:
inner_page(canvas, doc)
doc.build(story, onFirstPage=page_template, onLaterPages=page_template)
print(f"PDF saved: {OUTPUT}")
if __name__ == "__main__":
main()