Explain me antianginal drugs with its mechanism of action and side effects with diagrams

Reading File
Finding Sources
Finding Sources
Searching Images

antianginal drugs mechanism of action diagram

Reading File
Finding Sources
Finding Sources
Searching Images

nitrate mechanism angina vasodilation smooth muscle

Reading File
Reading File
Searching Images

calcium channel blocker mechanism cardiac angina

Reading File
Searching Images

beta blocker mechanism of action heart rate angina

Generating Image

Antianginal drugs mechanism of action summary diagram showing four drug classes: 1) Organic Nitrates (nitroglycerin) - releases nitric oxide, activates guanylyl cyclase, increases cGMP, causes venodilation reducing preload and arterial dilation reducing afterload; 2) Beta-blockers (metoprolol, atenolol) - block beta-1 receptors, reduce heart rate and contractility, decrease myocardial oxygen demand; 3) Calcium Channel Blockers - divided into dihydropyridines (amlodipine, nifedipine) causing peripheral vasodilation, and non-dihydropyridines (verapamil, diltiazem) reducing heart rate and contractility; 4) Newer agents - Ranolazine blocks late sodium current, Ivabradine blocks If current in SA node. Central focus shows the oxygen supply-demand balance in the heart. Medical education style with clear labels and arrows.

Generating Image

Nitrate mechanism of action detailed biochemical pathway diagram: nitroglycerin enters smooth muscle cell, converted by ALDH2 enzyme and glutathione S-transferase, releases nitric oxide (NO), NO activates soluble guanylyl cyclase (sGC), converts GTP to cGMP, cGMP activates protein kinase G (PKG), PKG dephosphorylates myosin light chains, smooth muscle relaxation and vasodilation. Show venous dilation reducing preload and arterial dilation reducing afterload. Medical textbook illustration style with labeled pathways and arrows.

Generating Image

Comparison table diagram of antianginal drugs side effects: Organic Nitrates side effects (headache, flushing, hypotension, reflex tachycardia, tolerance with continuous use); Beta-blockers side effects (bradycardia, fatigue, bronchospasm, cold extremities, impotence, masking hypoglycemia); Calcium Channel Blockers - dihydropyridines side effects (peripheral edema, flushing, headache, reflex tachycardia) vs non-dihydropyridines (bradycardia, constipation, negative inotropy); Ranolazine side effects (QT prolongation, dizziness, constipation). Clean medical education infographic style with color-coded boxes per drug class.

Here is a comprehensive guide to antianginal drugs — their mechanisms of action and side effects.

Antianginal Drugs

Pathophysiology Overview

Angina pectoris results from an imbalance between myocardial oxygen demand and supply. Antianginal drugs work by either:
  • Reducing demand (↓ heart rate, contractility, wall tension)
  • Increasing supply (coronary/peripheral vasodilation)

Overall Mechanism Summary

Antianginal Drugs Overview

1. Organic Nitrates

Drugs: Nitroglycerin (GTN), Isosorbide dinitrate (ISDN), Isosorbide mononitrate (ISMN), Amyl nitrite

Mechanism of Action

Nitrate Mechanism
Nitroglycerin must be bioactivated enzymatically:
  1. ALDH2 (mitochondrial aldehyde dehydrogenase isoform 2) and glutathione S-transferase denitrate nitroglycerin → releases nitric oxide (NO)
  2. NO combines with the heme group of soluble guanylyl cyclase (sGC) → activates it
  3. sGC converts GTP → cGMP (cyclic GMP)
  4. cGMP activates protein kinase G (PKG)
  5. PKG dephosphorylates myosin light chains → smooth muscle relaxation → vasodilation
Net hemodynamic effects:
EffectResult
Venodilation (dominant)↓ Venous return → ↓ Preload → ↓ Wall tension → ↓ O₂ demand
Arterial dilation↓ Afterload → ↓ Cardiac work
Coronary redistributionImproves flow to ischemic subendocardium
Weak negative inotropyvia NO
Pharmacokinetics:
  • Oral bioavailability is low (<10–20%) due to extensive hepatic first-pass metabolism
  • Sublingual route preferred for rapid effect (onset 1–3 min, duration 15–30 min)
  • Isosorbide mononitrate has 100% bioavailability (oral)

Side Effects

Side EffectMechanism
Headache (most common)Cerebral vasodilation
FlushingCutaneous vasodilation
Hypotension / syncopeExcessive vasodilation
Reflex tachycardiaBaroreceptor response to hypotension
ToleranceDepletion of sulfhydryl groups needed for ALDH2; requires nitrate-free interval (8–12 h/day)
Severe hypotension with PDE-5 inhibitorsBoth increase cGMP — dangerous combination; wait ≥6 h between use
Methemoglobinemia (with large doses)Rare

2. Beta-Adrenoceptor Blockers (β-Blockers)

Drugs: Metoprolol, Atenolol (cardioselective β₁); Propranolol (non-selective β₁/β₂)

Mechanism of Action

By blocking β₁-adrenoceptors on the heart:
  • ↓ Heart rate (negative chronotropy)
  • ↓ Contractility (negative inotropy)
  • ↓ AV conduction velocity
→ All three reduce myocardial oxygen demand, especially during exertion (the main trigger for effort angina)
Hemodynamic effects:
  • ↓ Heart rate × ↓ Systolic pressure = reduced rate-pressure product (key determinant of O₂ demand)
  • Prolonged diastolic filling time → improved coronary perfusion
  • Not vasodilators; do not benefit vasospastic/Prinzmetal angina (may worsen it by allowing unopposed α-vasoconstriction)

Side Effects

Side EffectNotes
Bradycardia / heart blockEspecially non-selective agents
Bronchospasmβ₂ blockade — contraindicated in asthma
Fatigue, lethargyCNS effects
Cold extremities↓ peripheral perfusion
ImpotencePeripheral vascular effect
Masking of hypoglycemiaBlocks tachycardia warning sign in diabetics
Rebound anginaOn abrupt withdrawal — must taper
Negative inotropyWorsens decompensated heart failure

3. Calcium Channel Blockers (CCBs)

Drugs:
  • Dihydropyridines (DHPs): Amlodipine, Nifedipine, Felodipine
  • Non-dihydropyridines (Non-DHPs): Verapamil (phenylalkylamine), Diltiazem (benzothiazepine)

Mechanism of Action

Block voltage-gated L-type calcium channels (Ca²⁺ channels):
Drug ClassPrimary TargetEffect
DihydropyridinesVascular smooth muscle >> heartPeripheral arterial vasodilation → ↓ afterload
VerapamilHeart > vessels↓ HR, ↓ contractility, ↓ AV conduction; less vasodilation
DiltiazemHeart and vessels equallyIntermediate effects
How it helps angina:
  • DHPs: ↓ afterload → ↓ O₂ demand; first-line for vasospastic (Prinzmetal) angina
  • Non-DHPs: ↓ HR + contractility → ↓ O₂ demand (similar to β-blockers)
  • All: coronary vasodilation → ↑ O₂ supply

Side Effects

Dihydropyridines:
Side EffectCause
Peripheral edemaVasodilation causing precapillary dilation > postcapillary
Flushing, headacheVasodilation
Reflex tachycardiaWith short-acting nifedipine (less with amlodipine)
Gingival hyperplasia(especially nifedipine)
Non-dihydropyridines (Verapamil/Diltiazem):
Side EffectCause
Bradycardia / AV blockDirect cardiac effect
Constipation(especially verapamil — smooth muscle relaxation in GI)
Negative inotropyMay worsen systolic heart failure
Contraindicated with β-blockersRisk of complete heart block

Side Effects Comparison

Side Effects Summary

4. Newer / Second-Line Antianginal Agents

Ranolazine

  • Mechanism: Inhibits the late sodium current (late I_Na) → ↓ intracellular Na⁺ → ↓ Na⁺/Ca²⁺ exchanger activity → ↓ intracellular Ca²⁺ → reduces diastolic tension and cardiac work
  • Does not affect heart rate or blood pressure significantly
  • Side effects: QT prolongation (though no torsades reported), dizziness, constipation, nausea; may inhibit metabolism of digoxin and simvastatin

Ivabradine

  • Mechanism: Selectively blocks the hyperpolarization-activated I_f ("funny") current in the SA node → ↓ heart rate only
  • No negative inotropic or vasodilator effects
  • Similar efficacy to CCBs and β-blockers for angina
  • Side effects: Visual disturbances (phosphenes — flickering lights), bradycardia

Nicorandil

  • Mechanism: Dual — K⁺ channel activator (hyperpolarizes smooth muscle) + nitrate-like NO donor → vasodilation of coronary and peripheral vessels
  • Side effects: Headache (like nitrates), hypotension, oral/GI ulceration

Trimetazidine (metabolic agent)

  • Mechanism: Partially inhibits fatty acid oxidation (inhibits LC-3KAT enzyme) → myocardium shifts to glucose oxidation which consumes less oxygen per ATP → metabolic efficiency in ischemia
  • Not approved in the USA; available in Europe and Asia
  • Side effects: Parkinsonism-like symptoms, GI effects

Summary Table

Drug ClassKey MechanismReducesAngina TypeKey Side Effect
Organic NitratesNO → cGMP → vasodilationPreload (primarily)Effort + VasospasticHeadache, tolerance
β-Blockers↓ HR, contractilityO₂ demandEffort onlyBronchospasm, bradycardia
DHP CCBsBlock L-Ca²⁺ in vesselsAfterloadEffort + VasospasticEdema, flushing
Non-DHP CCBsBlock L-Ca²⁺ in heartHR + contractilityEffort + VasospasticAV block, constipation
RanolazineBlock late I_NaDiastolic tensionEffort (add-on)QT prolongation
IvabradineBlock I_f in SA nodeHR onlyEffort (add-on)Visual phosphenes
NicorandilK⁺ activation + NOPre/afterloadEffort + VasospasticHeadache, ulcers

Key Clinical Point: β-blockers and short-acting dihydropyridine CCBs should not be combined (risk of severe bradycardia). However, β-blockers + long-acting DHPs (amlodipine) is a safe and effective combination. Never combine nitrates + PDE-5 inhibitors (sildenafil, tadalafil) due to severe hypotension risk.
Source: Katzung's Basic and Clinical Pharmacology, 16th Edition, Chapter 12: Vasodilators & the Treatment of Angina Pectoris

Can you generate flashcards for it

Asking for Preferences
Reading File
Running Command

ls -la /home/daytona/workspace/ 2>/dev/null || mkdir -p /home/daytona/workspace && echo "workspace ready"

Running Command

mkdir -p /home/daytona/workspace/antianginal-flashcards && echo "dir created"

Writing File

~/antianginal-flashcards/generate_flashcards.py

from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import cm
from reportlab.pdfgen import canvas
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.platypus import Paragraph
from reportlab.lib.enums import TA_CENTER, TA_LEFT
import textwrap

OUTPUT = "/home/daytona/workspace/antianginal-flashcards/Antianginal_Drugs_Flashcards.pdf"

# Flashcard data: (question, answer, category, color)
CARDS = [
    # ── OVERVIEW ──────────────────────────────────────────────────────────────
    (
        "What is the fundamental mechanism of angina pectoris?",
        "Imbalance between myocardial O₂ DEMAND and O₂ SUPPLY.\n\n"
        "• Effort angina: demand exceeds supply during exertion\n"
        "• Vasospastic (Prinzmetal): supply decreases due to coronary spasm\n"
        "• Unstable angina: platelet clots + increased coronary resistance at rest",
        "Overview", "#2C3E50"
    ),
    (
        "Name the 4 main classes of antianginal drugs.",
        "1. Organic Nitrates (nitroglycerin, ISDN, ISMN)\n"
        "2. Beta-blockers (metoprolol, atenolol, propranolol)\n"
        "3. Calcium Channel Blockers (amlodipine, verapamil, diltiazem)\n"
        "4. Newer agents (ranolazine, ivabradine, nicorandil, trimetazidine)",
        "Overview", "#2C3E50"
    ),

    # ── ORGANIC NITRATES ──────────────────────────────────────────────────────
    (
        "What is the mechanism of action of organic nitrates?",
        "Nitrates → (ALDH2 / glutathione-S-transferase) → Nitric Oxide (NO)\n\n"
        "NO activates soluble guanylyl cyclase (sGC)\n"
        "sGC: GTP → cGMP\n"
        "cGMP activates Protein Kinase G (PKG)\n"
        "PKG dephosphorylates myosin light chains → smooth muscle relaxation → VASODILATION",
        "Organic Nitrates", "#1A5276"
    ),
    (
        "What are the primary hemodynamic effects of nitrates in angina?",
        "DOMINANT EFFECT — Venodilation:\n"
        "↓ venous return → ↓ preload → ↓ ventricular wall tension → ↓ O₂ demand\n\n"
        "SECONDARY — Arterial dilation:\n"
        "↓ afterload → ↓ cardiac work → ↓ O₂ demand\n\n"
        "Also: coronary redistribution to ischemic subendocardium\n"
        "Weak negative inotropy via NO",
        "Organic Nitrates", "#1A5276"
    ),
    (
        "Why is the sublingual route preferred for nitroglycerin?",
        "Oral bioavailability is LOW (<10–20%) due to extensive hepatic first-pass metabolism.\n\n"
        "Sublingual route BYPASSES first-pass effect:\n"
        "• Onset: 1–3 minutes\n"
        "• Duration: 15–30 minutes\n\n"
        "Isosorbide mononitrate (ISMN) has 100% oral bioavailability (no first-pass effect).",
        "Organic Nitrates", "#1A5276"
    ),
    (
        "What enzyme is key in activating nitroglycerin inside cells?",
        "Mitochondrial ALDH2 (Aldehyde Dehydrogenase Isoform 2)\n\n"
        "Also: glutathione S-transferase\n\n"
        "These enzymes denitrate nitroglycerin → release of nitric oxide (NO)\n\n"
        "Depletion of ALDH2 sulfhydryl groups is the primary mechanism of NITRATE TOLERANCE.",
        "Organic Nitrates", "#1A5276"
    ),
    (
        "List the side effects of organic nitrates.",
        "• Headache (most common) — cerebral vasodilation\n"
        "• Flushing — cutaneous vasodilation\n"
        "• Orthostatic hypotension / syncope\n"
        "• Reflex tachycardia — baroreceptor response\n"
        "• Tolerance — with continuous use; requires 8–12 h nitrate-free interval\n"
        "• Severe hypotension if combined with PDE-5 inhibitors (sildenafil, tadalafil)\n"
        "• Methemoglobinemia (rare, with large doses)",
        "Organic Nitrates", "#1A5276"
    ),
    (
        "Why are nitrates contraindicated with PDE-5 inhibitors (sildenafil)?",
        "Both increase cGMP levels:\n"
        "• Nitrates: stimulate cGMP production (via NO → sGC)\n"
        "• PDE-5 inhibitors: block cGMP BREAKDOWN\n\n"
        "Combined effect = massive ↑ cGMP → severe, potentially fatal HYPOTENSION\n\n"
        "Clinical rule: Wait ≥6 hours between a nitrate and a PDE-5 inhibitor.",
        "Organic Nitrates", "#1A5276"
    ),
    (
        "How does nitrate tolerance develop and how is it prevented?",
        "MECHANISM:\n"
        "Continuous nitrate exposure depletes sulfhydryl groups (-SH)\n"
        "→ ALDH2 cannot activate nitroglycerin → no NO release\n\n"
        "PREVENTION:\n"
        "• Provide a nitrate-free interval of 8–12 hours daily\n"
        "  (usually overnight when angina risk is lowest)\n"
        "• Use eccentric dosing (e.g. ISMN: 8 AM and 3 PM, not equal intervals)",
        "Organic Nitrates", "#1A5276"
    ),

    # ── BETA-BLOCKERS ─────────────────────────────────────────────────────────
    (
        "What is the mechanism of beta-blockers in angina?",
        "Block β₁-adrenoceptors on the heart:\n\n"
        "↓ Heart rate (negative chronotropy)\n"
        "↓ Contractility (negative inotropy)\n"
        "↓ AV conduction velocity\n\n"
        "→ ↓ Myocardial O₂ DEMAND (key: reduces rate-pressure product)\n"
        "→ Prolongs diastolic filling time → better coronary perfusion\n\n"
        "NOT vasodilators — ineffective (may worsen) vasospastic angina.",
        "Beta-Blockers", "#117A65"
    ),
    (
        "Name cardioselective vs. non-selective beta-blockers used in angina.",
        "CARDIOSELECTIVE (β₁ selective):\n"
        "• Metoprolol, Atenolol, Bisoprolol\n"
        "• Preferred in patients with asthma/COPD\n\n"
        "NON-SELECTIVE (β₁ + β₂):\n"
        "• Propranolol, Nadolol\n"
        "• Block both cardiac and bronchial/vascular β receptors\n\n"
        "Note: Cardioselectivity is RELATIVE, not absolute at high doses.",
        "Beta-Blockers", "#117A65"
    ),
    (
        "List the side effects of beta-blockers.",
        "• Bradycardia / AV block\n"
        "• Bronchospasm — β₂ blockade (CONTRAINDICATED in asthma)\n"
        "• Fatigue, lethargy (CNS effects)\n"
        "• Cold extremities / worsened peripheral vascular disease\n"
        "• Erectile dysfunction\n"
        "• Masks hypoglycemia (blunts tachycardia warning) in diabetics\n"
        "• Rebound angina on ABRUPT WITHDRAWAL — must taper\n"
        "• Worsens decompensated heart failure (acute setting)\n"
        "• Can worsen Prinzmetal (vasospastic) angina",
        "Beta-Blockers", "#117A65"
    ),
    (
        "In which type of angina are beta-blockers CONTRAINDICATED?",
        "VASOSPASTIC (Prinzmetal) angina\n\n"
        "Reason: β-blockade removes sympathetic vasodilation\n"
        "→ Unopposed α-adrenergic vasoconstriction\n"
        "→ Coronary spasm WORSENED\n\n"
        "First-line for vasospastic angina: Calcium Channel Blockers (especially dihydropyridines)\n"
        "Also nitrates are effective.",
        "Beta-Blockers", "#117A65"
    ),

    # ── CALCIUM CHANNEL BLOCKERS ──────────────────────────────────────────────
    (
        "What is the general mechanism of calcium channel blockers in angina?",
        "Block voltage-gated L-type (slow) Ca²⁺ channels:\n\n"
        "In vascular smooth muscle:\n"
        "↓ Ca²⁺ influx → vasodilation → ↓ afterload → ↓ O₂ demand\n\n"
        "In cardiac muscle (non-DHPs):\n"
        "↓ Ca²⁺ influx → ↓ HR, ↓ contractility, ↓ AV conduction → ↓ O₂ demand\n\n"
        "Also dilate coronary arteries → ↑ O₂ supply\n"
        "DRUG OF CHOICE for vasospastic (Prinzmetal) angina.",
        "Calcium Channel Blockers", "#7D3C98"
    ),
    (
        "How do dihydropyridine CCBs differ from non-dihydropyridines?",
        "DIHYDROPYRIDINES (amlodipine, nifedipine, felodipine):\n"
        "• Act mainly on VASCULAR smooth muscle\n"
        "• Potent peripheral vasodilation → ↓ afterload\n"
        "• Can cause reflex tachycardia (especially short-acting nifedipine)\n"
        "• Little/no direct cardiac effect\n\n"
        "NON-DIHYDROPYRIDINES:\n"
        "• Verapamil: Acts mainly on HEART (like β-blocker effect)\n"
        "• Diltiazem: Intermediate — both heart and vessels\n"
        "• Both slow HR and reduce contractility\n"
        "• CONTRAINDICATED with β-blockers (risk of complete AV block)",
        "Calcium Channel Blockers", "#7D3C98"
    ),
    (
        "List the side effects of dihydropyridine CCBs (e.g., amlodipine, nifedipine).",
        "• Peripheral edema (ankle edema) — most common\n"
        "  (precapillary dilation > postcapillary)\n"
        "• Flushing, headache — vasodilation\n"
        "• Reflex tachycardia (more with short-acting nifedipine)\n"
        "• Gingival hyperplasia (especially nifedipine)\n"
        "• Dizziness, palpitations\n\n"
        "NOTE: Amlodipine (long-acting) has much less reflex tachycardia than nifedipine.",
        "Calcium Channel Blockers", "#7D3C98"
    ),
    (
        "List the side effects of non-dihydropyridine CCBs (verapamil, diltiazem).",
        "VERAPAMIL:\n"
        "• Bradycardia / AV block (most potent cardiac effect)\n"
        "• Constipation (very common — smooth muscle relaxation in GI)\n"
        "• Negative inotropy — may precipitate heart failure\n"
        "• Hypotension\n\n"
        "DILTIAZEM:\n"
        "• Bradycardia, AV block (less than verapamil)\n"
        "• Flushing, edema (less than DHPs)\n\n"
        "BOTH: Contraindicated with β-blockers (risk of complete heart block)",
        "Calcium Channel Blockers", "#7D3C98"
    ),

    # ── RANOLAZINE ────────────────────────────────────────────────────────────
    (
        "What is the mechanism of action of ranolazine?",
        "Inhibits the LATE sodium current (late I_Na)\n\n"
        "↓ Na⁺ entry → ↓ Na⁺/Ca²⁺ exchanger activity → ↓ intracellular Ca²⁺\n"
        "→ ↓ Diastolic tension and cardiac work → ↓ O₂ demand\n\n"
        "Key features:\n"
        "• Does NOT affect heart rate or blood pressure\n"
        "• Used as ADD-ON therapy when standard drugs are insufficient\n"
        "• Prolongs QT interval (but not associated with torsades de pointes)\n"
        "• May inhibit metabolism of digoxin and simvastatin",
        "Newer Agents", "#C0392B"
    ),
    (
        "What are the side effects and drug interactions of ranolazine?",
        "Side effects:\n"
        "• QT prolongation (monitor ECG)\n"
        "• Dizziness, headache\n"
        "• Constipation, nausea\n\n"
        "Drug interactions:\n"
        "• Inhibits metabolism of DIGOXIN → ↑ digoxin levels\n"
        "• Inhibits metabolism of SIMVASTATIN → ↑ simvastatin levels\n\n"
        "Unique: Shortens QT in LQT3 syndrome (despite prolonging in CAD patients)\n"
        "Approved in USA for chronic stable angina.",
        "Newer Agents", "#C0392B"
    ),

    # ── IVABRADINE ────────────────────────────────────────────────────────────
    (
        "What is the mechanism of ivabradine?",
        "Selectively blocks the hyperpolarization-activated I_f (\"funny\") current\n"
        "in the SINOATRIAL (SA) node\n\n"
        "→ ↓ Slope of pacemaker depolarization\n"
        "→ ↓ Heart rate ONLY (pure rate reduction)\n\n"
        "NO effect on:\n"
        "• Blood pressure\n"
        "• Contractility\n"
        "• AV conduction\n"
        "• Peripheral vasodilation\n\n"
        "Similar efficacy to CCBs and β-blockers for angina prophylaxis.",
        "Newer Agents", "#C0392B"
    ),
    (
        "What are the side effects of ivabradine?",
        "• PHOSPHENES (visual disturbances) — flickering/enhanced brightness\n"
        "  in the visual field; due to If channels in retinal cells\n"
        "• Bradycardia (dose-dependent)\n"
        "• Headache\n\n"
        "Important: Does NOT cause bronchospasm (unlike β-blockers)\n"
        "Can be used in asthma patients who need rate control\n\n"
        "Contraindicated in: sick sinus syndrome, severe bradycardia, AF",
        "Newer Agents", "#C0392B"
    ),

    # ── NICORANDIL ────────────────────────────────────────────────────────────
    (
        "What is the mechanism of nicorandil?",
        "DUAL mechanism:\n\n"
        "1. K⁺ channel activator (ATP-sensitive K⁺ channels)\n"
        "   → Membrane hyperpolarization → vascular smooth muscle relaxation\n"
        "   → Arterial and venous vasodilation\n\n"
        "2. Nitrate-like NO donor component\n"
        "   → Additional vasodilation (similar to organic nitrates)\n\n"
        "Result: ↓ Preload + ↓ Afterload + coronary vasodilation\n"
        "Effective in both effort and vasospastic angina.",
        "Newer Agents", "#C0392B"
    ),
    (
        "What are the side effects of nicorandil?",
        "• Headache (common — nitrate component)\n"
        "• Flushing\n"
        "• Hypotension\n"
        "• ORAL and GASTROINTESTINAL ULCERATION (distinctive side effect)\n"
        "  — may also cause perianal and skin ulcers\n"
        "• Tolerance (less than pure nitrates)\n\n"
        "Not approved in USA; used in Europe and Asia.",
        "Newer Agents", "#C0392B"
    ),

    # ── TRIMETAZIDINE ─────────────────────────────────────────────────────────
    (
        "What is the mechanism of trimetazidine?",
        "Metabolic (pFOX) inhibitor:\n\n"
        "Partially inhibits fatty acid oxidation by blocking\n"
        "LC-3KAT (long-chain 3-ketoacyl thiolase)\n\n"
        "→ Myocardium shifts from fatty acid oxidation to GLUCOSE oxidation\n"
        "→ Glucose oxidation uses LESS O₂ per ATP generated\n"
        "→ Improved metabolic efficiency in ischemic tissue\n\n"
        "No effect on heart rate, blood pressure, or vasodilation.\n"
        "NOT approved in the USA; available in Europe and Asia.",
        "Newer Agents", "#C0392B"
    ),

    # ── COMPARATIVE / HIGH-YIELD ──────────────────────────────────────────────
    (
        "Which drug is first-line for VASOSPASTIC (Prinzmetal) angina?",
        "CALCIUM CHANNEL BLOCKERS (especially dihydropyridines like nifedipine)\n\n"
        "• Directly relax coronary artery smooth muscle → relieve/prevent spasm\n\n"
        "Also effective: Organic nitrates (sublingual GTN for acute relief)\n\n"
        "AVOID: Beta-blockers\n"
        "→ Remove sympathetic vasodilation → unopposed α-constriction → worsen spasm",
        "Clinical Comparison", "#784212"
    ),
    (
        "Which antianginal drugs reduce heart rate?",
        "Heart rate REDUCING agents:\n"
        "• Beta-blockers (↓ HR via β₁ blockade)\n"
        "• Non-DHP CCBs — Verapamil and Diltiazem (↓ SA node automaticity)\n"
        "• Ivabradine (selective I_f blocker in SA node)\n\n"
        "Heart rate INCREASING (reflex tachycardia):\n"
        "• Short-acting DHP CCBs (e.g., immediate-release nifedipine)\n"
        "• Organic nitrates (via baroreceptor reflex)",
        "Clinical Comparison", "#784212"
    ),
    (
        "Which combination of antianginal drugs is DANGEROUS and why?",
        "DANGEROUS COMBINATIONS:\n\n"
        "1. Nitrates + PDE-5 inhibitors (sildenafil, tadalafil)\n"
        "   → Both ↑ cGMP → severe hypotension / MI\n"
        "   → Wait ≥6 hours between use\n\n"
        "2. Beta-blockers + Non-DHP CCBs (verapamil/diltiazem)\n"
        "   → Additive negative chronotropy/inotropy\n"
        "   → Risk of complete AV block and severe bradycardia\n\n"
        "SAFE combination:\n"
        "Beta-blocker + Amlodipine (long-acting DHP CCB) — complementary effects",
        "Clinical Comparison", "#784212"
    ),
    (
        "Which antianginal drugs reduce PRELOAD vs AFTERLOAD?",
        "PRELOAD reduction (venodilation):\n"
        "• Organic nitrates (primary effect)\n"
        "• Nicorandil (partial)\n\n"
        "AFTERLOAD reduction (arterial dilation):\n"
        "• Dihydropyridine CCBs (primary effect)\n"
        "• Organic nitrates (secondary effect)\n"
        "• Nicorandil (partial)\n\n"
        "BOTH preload AND afterload:\n"
        "• Nicorandil, high-dose nitrates\n\n"
        "NEITHER (pure O₂ demand reduction via HR/contractility):\n"
        "• Beta-blockers, Non-DHP CCBs, Ivabradine, Ranolazine",
        "Clinical Comparison", "#784212"
    ),
    (
        "What is the clinical significance of the rate-pressure product in angina?",
        "Rate-Pressure Product (RPP) = Heart Rate × Systolic Blood Pressure\n\n"
        "• Best correlate of MYOCARDIAL O₂ DEMAND\n"
        "• Angina threshold = point where RPP triggers ischemia\n\n"
        "Drugs that reduce RPP:\n"
        "• Beta-blockers (↓ HR and BP)\n"
        "• Non-DHP CCBs (↓ HR and BP)\n"
        "• Nitrates (↓ BP, may reflexly ↑ HR)\n\n"
        "Goal of therapy: Keep RPP below the ischemic threshold",
        "Clinical Comparison", "#784212"
    ),
    (
        "Summarize all antianginal drugs in a quick comparison.",
        "Drug Class     | Mechanism        | Reduces     | Angina Type\n"
        "Nitrates       | NO→cGMP→vasodil  | Preload↓    | Effort+Vasospastic\n"
        "β-Blockers     | β₁ blockade       | HR+contract | Effort ONLY\n"
        "DHP CCBs       | L-Ca²⁺ (vessel)  | Afterload↓  | Effort+Vasospastic\n"
        "Non-DHP CCBs   | L-Ca²⁺ (heart)   | HR+contract | Effort+Vasospastic\n"
        "Ranolazine     | Late I_Na block   | Diastol.ten | Effort (add-on)\n"
        "Ivabradine     | I_f block (SA)    | HR only     | Effort (add-on)\n"
        "Nicorandil     | K⁺ channel+NO     | Pre+Afterld | Effort+Vasospastic\n"
        "Trimetazidine  | Fatty acid oxid↓  | O₂/ATP req  | Effort (add-on)",
        "Clinical Comparison", "#784212"
    ),
]

# ─────────────────────────────────────────────────────────────────────────────
# PAGE LAYOUT: 2 cards per A4 page (front + back on same page)
# Each card: ~13 cm tall, full A4 width
# Front = question (left half), Back = answer (right half)
# ─────────────────────────────────────────────────────────────────────────────

PAGE_W, PAGE_H = A4  # 595 x 842 pt
MARGIN = 1 * cm
CARD_W = (PAGE_W - 2 * MARGIN) / 2 - 0.3 * cm
CARD_H = (PAGE_H - 2 * MARGIN) / 2 - 0.3 * cm
GUTTER = 0.6 * cm


def draw_card(c, x, y, w, h, header, body, bg_color, is_question=True):
    """Draw a single flashcard at position (x,y) with given dimensions."""
    # Background
    c.setFillColor(colors.HexColor(bg_color))
    c.roundRect(x, y, w, h, radius=8, fill=1, stroke=0)

    # Header bar
    header_h = 0.85 * cm
    c.setFillColor(colors.HexColor("#FFFFFF") if is_question else colors.HexColor("#F0F0F0"))
    c.setStrokeColor(colors.HexColor("#FFFFFF"))
    c.roundRect(x, y + h - header_h, w, header_h, radius=4, fill=1, stroke=0)

    # Label (Q / A)
    label = "Q" if is_question else "A"
    c.setFont("Helvetica-Bold", 10)
    c.setFillColor(colors.HexColor(bg_color))
    c.drawString(x + 0.3 * cm, y + h - header_h + 0.22 * cm, label)

    # Header text (category)
    c.setFont("Helvetica-Bold", 8)
    c.setFillColor(colors.HexColor(bg_color))
    c.drawString(x + 0.7 * cm, y + h - header_h + 0.22 * cm, header)

    # Body text
    text_x = x + 0.4 * cm
    text_y = y + h - header_h - 0.35 * cm
    text_w = w - 0.8 * cm
    text_h_available = h - header_h - 0.5 * cm

    c.setFillColor(colors.white)
    # Word-wrap manually using reportlab text object
    text_obj = c.beginText(text_x, text_y)
    text_obj.setFont("Helvetica", 8.5)
    text_obj.setFillColor(colors.white)
    text_obj.setLeading(12)

    lines = body.split('\n')
    chars_per_line = int(text_w / (8.5 * 0.52))  # approx char width
    for line in lines:
        if line.strip() == '':
            text_obj.textLine('')
            continue
        # Wrap long lines
        wrapped = textwrap.wrap(line, width=chars_per_line) if len(line) > chars_per_line else [line]
        for wl in wrapped:
            text_obj.textLine(wl)

    c.drawText(text_obj)


def generate_pdf(output_path, cards):
    c = canvas.Canvas(output_path, pagesize=A4)
    c.setTitle("Antianginal Drugs – Flashcards")
    c.setAuthor("Orris Medical AI")
    c.setSubject("Pharmacology – Antianginal Drugs")

    # Title page
    c.setFillColor(colors.HexColor("#2C3E50"))
    c.rect(0, 0, PAGE_W, PAGE_H, fill=1, stroke=0)

    c.setFillColor(colors.white)
    c.setFont("Helvetica-Bold", 28)
    c.drawCentredString(PAGE_W / 2, PAGE_H / 2 + 3 * cm, "ANTIANGINAL DRUGS")
    c.setFont("Helvetica-Bold", 18)
    c.drawCentredString(PAGE_W / 2, PAGE_H / 2 + 1.5 * cm, "Pharmacology Flashcards")
    c.setFont("Helvetica", 12)
    c.drawCentredString(PAGE_W / 2, PAGE_H / 2 + 0.3 * cm, "Mechanism of Action · Side Effects · Clinical Pearls")

    # Color legend
    categories = [
        ("Overview", "#2C3E50"),
        ("Organic Nitrates", "#1A5276"),
        ("Beta-Blockers", "#117A65"),
        ("Calcium Channel Blockers", "#7D3C98"),
        ("Newer Agents", "#C0392B"),
        ("Clinical Comparison", "#784212"),
    ]
    legend_y = PAGE_H / 2 - 2 * cm
    c.setFont("Helvetica-Bold", 10)
    c.drawCentredString(PAGE_W / 2, legend_y, "Card Categories:")
    legend_y -= 0.6 * cm
    for cat, col in categories:
        c.setFillColor(colors.HexColor(col))
        c.roundRect(PAGE_W / 2 - 7 * cm, legend_y - 0.15 * cm, 3 * cm, 0.45 * cm, radius=3, fill=1, stroke=0)
        c.setFillColor(colors.white)
        c.setFont("Helvetica-Bold", 9)
        c.drawCentredString(PAGE_W / 2 - 5.5 * cm, legend_y, cat)
        legend_y -= 0.65 * cm

    c.setFont("Helvetica", 9)
    c.setFillColor(colors.HexColor("#BDC3C7"))
    c.drawCentredString(PAGE_W / 2, 2 * cm, f"Total: {len(cards)} flashcards  •  Source: Katzung's Basic & Clinical Pharmacology, 16th Ed.")
    c.showPage()

    # Flashcard pages — 2 cards per page (Q on left, A on right)
    card_positions = [
        # row 0 (top)
        (MARGIN, MARGIN + CARD_H + GUTTER),
        # row 1 (bottom)
        (MARGIN, MARGIN),
    ]

    cards_per_page = 2
    for page_start in range(0, len(cards), cards_per_page):
        page_cards = cards[page_start: page_start + cards_per_page]

        for i, (question, answer, category, color) in enumerate(page_cards):
            cx, cy = card_positions[i]
            # Question (left half)
            draw_card(c, cx, cy, CARD_W, CARD_H,
                      f"#{page_start + i + 1}  {category}", question, color, is_question=True)
            # Answer (right half)
            draw_card(c, cx + CARD_W + GUTTER, cy, CARD_W, CARD_H,
                      f"#{page_start + i + 1}  ANSWER", answer, color, is_question=False)

        # Cut lines
        c.setStrokeColor(colors.HexColor("#CCCCCC"))
        c.setLineWidth(0.3)
        c.setDash(4, 4)
        # Horizontal cut line
        mid_y = MARGIN + CARD_H + GUTTER / 2
        c.line(0.3 * cm, mid_y, PAGE_W - 0.3 * cm, mid_y)
        # Vertical cut line
        mid_x = MARGIN + CARD_W + GUTTER / 2
        c.line(mid_x, 0.3 * cm, mid_x, PAGE_H - 0.3 * cm)
        c.setDash()

        c.showPage()

    c.save()
    print(f"PDF saved: {output_path}  ({len(cards)} cards)")


generate_pdf(OUTPUT, CARDS)
Running Command

cd /home/daytona/workspace/antianginal-flashcards && python generate_flashcards.py 2>&1

Running Command

ls -lh /home/daytona/workspace/antianginal-flashcards/

Your credits are exhausted. Your daily credits reset tomorrow, or you can purchase a top-up for more.
This is a shared conversation. Sign in to Orris to start your own chat.