Post op hypotension and treatment guidelines

Reading File
Finding Sources
Finding Sources
Searching PubMed

"postoperative hypotension" AND treatment

Reading File
Reading File
Reading Article

PMID: 37778937

Reading Article

PMID: 38839472

Reading Article

PMID: 40886448

Finding Sources
Reading File
Searching the Web

postoperative hypotension management guidelines 2024 vasopressor treatment thresholds

I now have comprehensive data from multiple authoritative sources. Let me compile the full answer.

Post-Operative Hypotension: Causes, Assessment & Treatment Guidelines

Definition

Post-operative hypotension (POH) is most commonly defined as a mean arterial pressure (MAP) <65 mmHg, or a systolic blood pressure <90 mmHg (or >20-30% decrease from baseline), occurring in the post-anaesthesia care unit (PACU) or surgical wards. The POQI 2024 consensus statement emphasizes that POH is often unrecognised and may be more clinically significant than intraoperative hypotension because it tends to be prolonged and undertreated. POQI 2024 consensus

Why It Matters

A 2025 meta-analysis of 23 studies (262,435 patients) found POH is independently associated with:
OutcomeOdds Ratio (95% CI)
MortalityOR 2.51 (1.86-3.38)
Myocardial injuryOR 2.52 (1.71-3.69)
Acute kidney injuryOR 1.72 (1.25-2.36)
StrokeOR 1.82 (1.09-3.05)
  • Han et al., J Clin Anesth, 2025 [PMID: 40886448]
Clinically, hypotension causes end-organ dysfunction manifest as: urine output <0.5 mL/kg/h, decreased consciousness, myocardial ischaemia, and capillary refill >2 seconds. - Bailey & Love's Surgery, 28th ed.

Causes and Classification

Understanding the underlying mechanism is the most important step in treatment. The differential is best organised by haemodynamic mechanism:

1. Hypovolaemia (most common)

  • Surgical bleeding (occult or overt)
  • Third-space fluid losses
  • Inadequate intraoperative fluid replacement
  • Pre-operative fasting/bowel preparation
  • Key sign: narrow pulse pressure, tachycardia, elevated lactate

2. Vasodilation (distributive)

  • Neuraxial/epidural analgesia - sympathetic blockade is a major cause; epidural-related hypotension incidence ~5.6% (95% CI 3.0-10.2%) - Miller's Anesthesia, 10th ed.
  • Sepsis / systemic inflammatory response
  • Residual volatile anaesthetic effect
  • Alpha-blockade (e.g., phaeochromocytoma patients post-adrenalectomy): "infusion of large volumes of fluid or noradrenaline can be necessary to correct post-operative hypotension in the presence of unopposed alpha-blockade" - Bailey & Love's, 28th ed.
  • Anaphylaxis
  • Key sign: wide pulse pressure, low diastolic BP, warm peripheries

3. Cardiogenic / Pump Failure

  • Myocardial ischaemia/infarction
  • Arrhythmia (new AF, bradycardia)
  • Diastolic dysfunction (very common in middle-aged patients undergoing non-cardiac surgery, susceptible to exaggerated hypotension after hypovolaemia) - Bailey & Love's
  • Key sign: narrow pulse pressure, elevated JVP/PCWP, S3 gallop

4. Obstructive

  • Tension pneumothorax
  • Pulmonary embolism
  • Pericardial tamponade
  • Key sign: raised JVP, shock unresponsive to fluids

5. Neuroendocrine/Hormonal

  • Adrenocortical insufficiency (if both adrenal glands were manipulated, or if patient on chronic steroids) - Goldman-Cecil Medicine
  • Hypoglycaemia (can co-occur in immediate post-op period)

6. Drug/Neurogenic

  • Carotid endarterectomy: baroreceptor hypersensitivity/reactivation is a key mechanism; more common after regional anaesthesia. "Cardiac output is frequently normal or elevated and systemic vascular resistance is reduced" - Miller's Anesthesia, 10th ed.

Assessment Algorithm

Step 1: Identify the mechanism
  • Check blood loss, surgical drains
  • Assess volume responsiveness (passive leg raise, fluid challenge)
  • Review medications: antihypertensives, epidural infusion, vasodilators
  • Low diastolic BP → suggests vasodilation
  • Narrow pulse pressure + tachycardia → suggests hypovolaemia or low cardiac output
  • Unresponsive to fluids + raised JVP → obstructive or cardiogenic
Step 2: Targeted investigations
  • ECG (ischaemia, arrhythmia)
  • Troponin if myocardial injury suspected
  • ABG/lactate (tissue perfusion)
  • Bedside echo (LVEF, IVC collapsibility, pericardial effusion)
  • FBC (haemorrhage), cortisol (if adrenal insufficiency suspected)

Treatment Guidelines

General Principle

Treatment should always be aimed at the underlying cause. - Bailey & Love's Short Practice of Surgery, 28th ed.

Target MAP

  • Maintain MAP ≥60 mmHg in at-risk patients (the POQI 2024 consensus recommendation)
  • Increase the MAP target when venous or compartment pressures are elevated
  • Postoperative ICU patients may need MAP targets well above 65 mmHg

Step-by-Step Management

1. Fluid resuscitation
  • First-line for hypovolaemia - crystalloid (balanced solutions preferred) or colloid
  • Do NOT fluid-overload patients with diastolic dysfunction (risk of pulmonary oedema)
  • Guided by dynamic markers: pulse pressure variation, stroke volume variation
2. Vasopressors (when vasodilation is the mechanism or fluid challenge has failed)
AgentMechanismIndication
Norepinephrineα1 + β1First-line vasodilatory shock; most common vasopressor used post-op
Phenylephrineα1 onlyPure vasodilation; spinal hypotension; preserves CO in certain patients
Ephedrineα + β (indirect)Spinal/epidural hypotension; bradycardia component
VasopressinV1 receptorRefractory vasodilatory shock; add-on to norepinephrine
Epinephrineα + βAnaphylaxis; cardiogenic shock with vasodilation
A 2023 systematic review (Douglas et al., Br J Anaesth) found norepinephrine was the most common vasopressor used for POH, with a median 42% of patients receiving vasopressors post-operatively. Vasodilation was the most common underlying physiological disturbance. The review noted current evidence supporting vasopressor use is still limited in quality. [PMID: 37778937]
3. Inotropes
  • Cardiogenic shock: dobutamine (β1 agonist) or milrinone (PDE-3 inhibitor)
  • Treat underlying ischaemia / arrhythmia concurrently
4. Epidural-specific hypotension
  • Reduce local anaesthetic rate or concentration
  • Switch to opioid-only infusion (neuraxial opioids do not cause hypotension)
  • Treat underlying cause (hypovolaemia) - Miller's Anesthesia, 10th ed.
5. Carotid endarterectomy post-op hypotension
  • "Judicious use of fluids and vasopressors are recommended"
  • Most cases resolve within 12-24 hours - Miller's Anesthesia, 10th ed.
6. Adrenal insufficiency
  • Administer IV hydrocortisone 100 mg stat, then 50 mg every 6-8 hours
  • Replace if bilateral adrenal manipulation occurred or patient on long-term steroids
7. Delaying antihypertensives (prevention)
  • ACE inhibitors/ARBs continued pre-operatively are a major contributor to POH
  • A 2025 meta-analysis (Dou et al., Ann Med) confirmed that withholding ACEi/ARBs before surgery reduces intraoperative/postoperative hypotension [PMID: 41017370]
  • The APSF recommends delaying restarting chronic antihypertensives until clearly necessary post-op

Monitoring

  • Continuous arterial pressure monitoring is preferred over intermittent NIBP in high-risk patients - it reduces both the severity and duration of hypotension (POQI 2024)
  • POH on the surgical ward is frequently unmonitored and untreated - this is a patient safety priority
  • Surveillance for myocardial (troponin) and cerebral (neurological exam) ischaemia should accompany every episode of significant POH

Key Takeaways

  1. POH is common, often underrecognised on the ward, and carries a 2.5x increased mortality risk
  2. Always identify the mechanism first - fluid, vasopressor, or inotrope therapy each targets a different physiology
  3. MAP ≥60 mmHg is the standard minimum target; higher may be needed in critically ill post-op patients
  4. Norepinephrine is the most widely used first-line vasopressor for vasodilatory POH
  5. Epidural analgesia, blood loss, and residual anaesthetic/antihypertensive effects are the most common causes
  6. Adrenal insufficiency must not be missed after adrenal surgery or in steroid-dependent patients

Sources:

Create notes on how to treat post op hypertension in step wise approach with Pharmacology explained

Finding Sources
Finding Sources
Searching PubMed

"postoperative hypertension" AND management

Searching the Web

postoperative hypertension stepwise treatment guidelines antihypertensive drugs 2024

Reading File
Reading File
Reading File
Finding Sources
Reading File
Finding Sources
Finding Sources
Reading File
Reading File
I now have all the data needed for a comprehensive, well-structured set of notes. Let me compile them.

Post-Operative Hypertension: Stepwise Treatment Notes with Pharmacology


1. Definition and When to Treat

Post-operative hypertension (POH-T) is defined as a sustained elevation in blood pressure occurring after surgery, most commonly within the first 30 minutes of PACU admission.
Threshold for treatment (individualize to the patient):
  • BP elevation >20-30% above the patient's own baseline, OR
  • Any elevation associated with:
    • Myocardial ischaemia
    • Heart failure / pulmonary oedema
    • Active surgical bleeding
    • Intracranial hypertension
    • Suture line disruption risk
"Mild hypertension generally does not require treatment, but a reversible cause should be sought." - Morgan & Mikhail's Clinical Anesthesiology, 7th ed.
The endpoint of treatment should always target the patient's own normal (pre-operative) blood pressure, not a generic number.

2. Pathophysiology

Arterial vasoconstriction (raised systemic vascular resistance) is the dominant mechanism in most post-op hypertension, particularly after cardiac surgery.

3. Common Causes (Box - Identify Before Treating)

CategorySpecific Cause
PainIncisional pain, endotracheal tube irritation
PhysiologicalHypoxaemia, hypercapnia, metabolic acidosis
BladderBladder distension (very common - check first)
NeurologicalEmergence agitation/excitement, raised ICP
Drug reboundBeta-blocker withdrawal, clonidine withdrawal
VolumeFluid overload / hypervolaemia
EndocrineNeuroendocrine stress response (catecholamine surge)
Surgical-specificCarotid endarterectomy (baroreceptor denervation), intracranial procedures
OccultPhaeochromocytoma (unresected residual tumour)
Source: Miller's Anesthesia 10th ed., Morgan & Mikhail's 7th ed. - Box 76.6

4. Hazards of Untreated Post-Op Hypertension

  • Increased myocardial oxygen demand (increased afterload)
  • Myocardial infarction / ischaemia
  • Cardiac arrhythmias
  • Cerebrovascular accident / intracranial haemorrhage
  • Increased surgical site bleeding
  • Suture line disruption (especially after vascular anastomoses)

5. Stepwise Management Algorithm


STEP 1 - Treat Reversible Causes First (Non-Pharmacological)

Before reaching for any drug, address these systematically:
  1. Pain - adequate analgesia (IV opioid, paracetamol, NSAIDs as appropriate)
  2. Bladder distension - catheterise or check catheter patency
  3. Hypoxaemia - supplemental oxygen, airway manoeuvre, treat bronchospasm
  4. Hypercapnia / acidosis - optimise ventilation, check airway
  5. Shivering / emergence agitation - warming, low-dose IV opioid, dexmedetomidine
  6. Anxiety - reassurance, anxiolytics if needed
  7. Fluid overload - restrict IV fluids, consider diuretic
If BP normalises after addressing the above, no antihypertensive drug is needed.

STEP 2 - Mild to Moderate Elevation (20-30% above baseline, no end-organ signs)

First-line IV agents (titratable, short-acting preferred):

A. Labetalol (First choice in most patients)

  • Class: Combined α1 + non-selective β-blocker
  • Mechanism: Blocks α1-adrenoceptors → reduces SVR; blocks β1 → reduces HR and cardiac output. The α:β blockade ratio is approximately 1:7 (IV)
  • Dose: 0.3-1.0 mg/kg slow IV bolus (max 80 mg/bolus); repeat after 10 min PRN. Infusion: 0.4-1.0 mg/kg/h up to 3 mg/kg/h. Maximum total dose 300 mg
  • Onset: 5-10 min | Duration: 3-6 hours
  • Advantages: Lowers BP without reflex tachycardia; safe in most post-op contexts
  • Avoid in: Acute heart failure, severe bronchospasm/asthma, COPD, bradycardia, AV block

B. Nicardipine (Excellent choice, especially post cardiac/vascular surgery)

  • Class: Dihydropyridine calcium channel blocker (CCB)
  • Mechanism: Blocks L-type voltage-gated Ca²+ channels in vascular smooth muscle → arterial vasodilation and reduced SVR. Minimal effect on cardiac conduction.
  • Dose: Start at 5 mg/h IV infusion; titrate by 2.5 mg/h every 5-15 min; max 15 mg/h
  • Onset: 5-15 min | Duration: 4-6 hours (after infusion stops, ~30 min)
  • Advantages: Pure arterial vasodilator; no negative inotropy; good for coronary vasospasm; preferred in post-cardiac surgery
  • Avoid in: Heart failure with severe LV dysfunction (relative), co-administration with other negative inotropes

C. Enalaprilat (IV ACE inhibitor)

  • Class: ACE inhibitor (active form of enalapril)
  • Mechanism: Inhibits ACE → blocks conversion of angiotensin I to angiotensin II → reduces vasoconstriction and aldosterone release → reduces preload and afterload
  • Dose: 0.625-1.25 mg IV over 5 min every 6 hours
  • Onset: 15-30 min | Duration: 6-12 hours
  • Advantages: Useful in renin-mediated hypertension (post-renal artery surgery, renal hypertension)
  • Avoid in: Renal artery stenosis, hyperkalaemia, acute kidney injury, after cardiac bypass (angiotensin system is maximally activated)

STEP 3 - Marked Hypertension With Limited Cardiac Reserve or End-Organ Signs

Requires direct intra-arterial pressure monitoring and IV infusion of titratable agents:

A. Sodium Nitroprusside (SNP) - The Benchmark Agent

  • Class: Direct nitrovasodilator
  • Mechanism: Spontaneously releases nitric oxide (NO) → activates guanylyl cyclase → raises cGMP → smooth muscle relaxation → both arterial AND venous vasodilation (reduces preload + afterload simultaneously)
  • Dose: Start 0.3 mcg/kg/min; titrate up to 10 mcg/kg/min. Wrap bottle in foil (light-sensitive)
  • Onset: Seconds (30-60 sec) | Duration: 1-2 min (extremely titratable)
  • Advantages: Most rapid-acting and titratable agent; ideal for hypertensive crisis
  • Critical adverse effects:
    • Cyanide toxicity: SNP is metabolised to cyanide in red blood cells; toxicity manifests as lactic acidosis, tachyphylaxis, altered mental status. Risk increases with doses >2 mcg/kg/min for >48 hours or in renal failure
    • Thiocyanate accumulation: In renal failure (slower clearance)
    • Reflex tachycardia: Due to baroreceptor activation
    • Coronary steal: Theoretical risk (dilates collateral vessels)
  • Monitor: Arterial line mandatory; consider plasma thiocyanate levels if prolonged use
  • Use with caution: Renal failure; prefer alternative if available

B. Nitroglycerin (Glyceryl Trinitrate)

  • Class: Organic nitrate / nitrovasodilator
  • Mechanism: Converted to NO by mitochondrial aldehyde dehydrogenase (mtALDH2) → venodilation > arterial dilation at low doses; arterial dilation at high doses. Preferentially reduces preload (venous capacitance), reduces myocardial wall tension
  • Dose: 5-10 mcg/min IV; titrate up to 200 mcg/min
  • Onset: 1-2 min | Duration: 3-5 min after stopping
  • Advantages: First choice in coronary artery bypass surgery patients and ischaemia (coronary vasodilator); reduces myocardial O2 demand
  • Limitations: Primarily a venodilator - does not reliably lower BP through arterial dilation at standard doses; tolerance develops rapidly (within 24 hours)
  • Avoid: Phosphodiesterase-5 inhibitor use (sildenafil), severe hypotension

C. Clevidipine (Newer preferred agent)

  • Class: Ultra-short-acting dihydropyridine CCB (3rd generation)
  • Mechanism: Highly selective L-type Ca²+ channel blocker in arterial smooth muscle → pure arteriolar vasodilation; rapidly hydrolysed by plasma esterases
  • Dose: Start 1-2 mg/h IV; double every 90 seconds to desired effect; usual range 4-6 mg/h; max 32 mg/h
  • Onset: 2-4 min | Duration: 5-15 min (rapidly metabolised, independent of renal/hepatic function)
  • Advantages: Predictable titration; no drug accumulation in organ failure; safe lipid emulsion vehicle; does not cause reflex tachycardia significantly; superior to SNP in avoiding rebound hypertension
  • Note: Contraindicated in soy/egg allergy (lipid emulsion base); caution in severe aortic stenosis

D. Esmolol

  • Class: Ultra-short-acting cardioselective β1-blocker
  • Mechanism: Competitive antagonism of β1-adrenoceptors → reduces heart rate and contractility → reduces cardiac output and BP. Half-life ~9 min (hydrolysed by red blood cell esterases)
  • Dose: Loading: 250-500 mcg/kg IV over 1 min; Maintenance: 50-300 mcg/kg/min infusion
  • Onset: 1-2 min | Duration: 10-30 min
  • Advantages: Ideal when hypertension is rate-related (tachycardia + hypertension); excellent for aortic dissection (reduces dP/dt); perioperative utility
  • Avoid: Severe LV dysfunction, asthma, bradycardia, AV block

STEP 4 - Specific Clinical Situations

SituationFirst ChoiceSecond ChoiceAvoid
Coronary artery surgeryNitroglycerin, nicardipine, clevidipineEsmolol, labetalol, SNP-
Heart failure / pulmonary oedemaClevidipine, nitroglycerin, fenoldopamSNP + loop diureticHydralazine, diazoxide, beta-blockers
Aortic dissectionLabetalol OR esmolol + SNP/fenoldopam-Vasodilator monotherapy (reflex tachycardia)
Carotid endarterectomyShort-acting IV agents (labetalol, nicardipine)-Delay - most resolve in 12-24h
Neurological surgery (raised ICP)Esmolol, labetalolNicardipineSNP (increases ICP via cerebral vasodilation)
Catecholamine excess (phaeochromocytoma)Phentolamine (α-blocker)LabetalolBeta-blocker alone (precipitates hypertensive crisis)
Renal failureClevidipine, nicardipine, labetalolFenoldopam (increases renal blood flow)SNP (thiocyanate accumulation)
Post-eclampsiaHydralazine, labetalol, nicardipine-ACE inhibitors, ARBs (teratogenic)
Source: Comprehensive Clinical Nephrology 7th ed. - Table 36.2; Miller's Anesthesia 10th ed.

STEP 5 - Resume/Restart Chronic Antihypertensives

Once the patient is tolerating oral intake and haemodynamically stable:
  • Restart most antihypertensives to prevent rebound hypertension (especially beta-blockers and clonidine - abrupt withdrawal causes dangerous rebound)
  • ACE inhibitors/ARBs: Consider delaying restart until adequate volume status confirmed (to avoid hypotension) - supported by 2025 meta-analysis [PMID: 41017370]
  • 2024 AHA/ACC perioperative guidelines: Continue non-dihydropyridine CCBs in patients with arrhythmia or angina; continue beta-blockers throughout

6. Drugs to Avoid in Post-Op Hypertension

DrugReason to Avoid
Sublingual nifedipineUncontrolled BP drop, reflex tachycardia → myocardial ischaemia/infarction
IV hydralazineUnpredictable response, reflex tachycardia, prolonged duration, difficult to titrate
DiazoxideExcessive and prolonged hypotension
Beta-blocker monotherapy in phaeochromocytomaUnopposed alpha stimulation → hypertensive crisis
SNP in raised ICPCerebral vasodilation worsens ICP
ACE inhibitors in bilateral renal artery stenosisAcute renal failure

7. Quick Pharmacology Summary Table

DrugClassMechanismOnsetDurationKey UseKey Avoid
Labetalolα1+β blocker↓ SVR + ↓ HR/CO5-10 min3-6 hMost post-op HTNHF, asthma, bradycardia
NicardipineDihydropyridine CCB↓ Ca²+ in vascular SM → ↓ SVR5-15 min4-6 hCardiac/vascular surgery-
ClevidipineDihydropyridine CCB (ultra-short)↓ Ca²+ arterial SM → plasma esterase hydrolysis2-4 min5-15 minCritical care hypertension, organ failureSoy/egg allergy
Esmololβ1 blocker↓ HR + contractility via β1 blockade1-2 min10-30 minRate-driven HTN, aortic dissectionHF, asthma, bradycardia
SNPNitrovasodilatorNO release → ↑cGMP → arterial + venous vasodilationSeconds1-2 minHypertensive crisisRenal failure, raised ICP
NitroglycerinOrganic nitrateNO → venodilation > arterial dilation1-2 min3-5 minCAB surgery, ischaemiaTolerance after 24h
EnalaprilatACE inhibitor (IV)↓ Ang II → ↓ SVR + preload15-30 min6-12 hRenin-mediated HTNRenal artery stenosis, AKI
FenoldopamDopamine D1 agonistD1 receptor → arterial vasodilation + natriuresis5-10 min30-60 minRenal failure patientsReflex tachycardia at high dose
Phentolamineα-blockerBlocks α1+α2 → ↓ SVR1-2 min10-30 minPhaeochromocytoma, catecholamine surgeTachycardia
Urapidilα1-blocker + 5-HT1A agonist↓ SVR + central sympatholysis3-5 min4-6 hPerioperative HTN-

8. Monitoring During Treatment

  • Intra-arterial line: Mandatory for SNP, clevidipine infusions, marked hypertension with limited cardiac reserve
  • ECG: Continuous monitoring for ischaemia and arrhythmia
  • Urine output: End-organ perfusion marker (target >0.5 mL/kg/h)
  • Troponin: If myocardial injury suspected
  • SNP-specific: Plasma thiocyanate/cyanide if prolonged use >48h or renal failure

Sources:

Generate a clinical decision tree PDF for POH drug selection by presentation

Reading File
Running Command

mkdir -p /home/daytona/workspace/poh-decision-tree && ls /home/daytona/workspace…

Writing File

~/poh-decision-tree/generate_pdf.py

"""
Post-Operative Hypertension (POH) Clinical Decision Tree PDF
Uses ReportLab to draw a detailed flowchart on A3 landscape pages.
"""

from reportlab.lib.pagesizes import A3, landscape
from reportlab.lib.units import mm
from reportlab.lib import colors
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 os

OUTPUT_PATH = "/home/daytona/workspace/poh-decision-tree/POH_Drug_Selection_Decision_Tree.pdf"

# ── Colour palette ─────────────────────────────────────────────────────────────
C_NAVY       = colors.HexColor("#1B2A4A")
C_TEAL       = colors.HexColor("#1F7A8C")
C_ORANGE     = colors.HexColor("#E87040")
C_RED        = colors.HexColor("#C0392B")
C_GREEN      = colors.HexColor("#27AE60")
C_YELLOW     = colors.HexColor("#F39C12")
C_PURPLE     = colors.HexColor("#7D3C98")
C_BLUE_LT    = colors.HexColor("#D6EAF8")
C_TEAL_LT    = colors.HexColor("#D1F2EB")
C_ORANGE_LT  = colors.HexColor("#FAE5D3")
C_RED_LT     = colors.HexColor("#FADBD8")
C_GREEN_LT   = colors.HexColor("#D5F5E3")
C_YELLOW_LT  = colors.HexColor("#FEF9E7")
C_PURPLE_LT  = colors.HexColor("#E8DAEF")
C_GREY_LT    = colors.HexColor("#F2F3F4")
C_WHITE      = colors.white
C_BLACK      = colors.HexColor("#1A1A1A")
C_BORDER     = colors.HexColor("#BFC9CA")

PAGE_W, PAGE_H = landscape(A3)   # 420 × 297 mm


# ── Helper: wrapped text in a box ─────────────────────────────────────────────
def draw_box(c, x, y, w, h,
             lines,                      # list of (text, fontname, fontsize, color)
             bg=C_WHITE, border=C_BORDER,
             radius=4, border_width=1.2,
             shadow=False):
    """Draw a rounded rectangle with multiple text lines centred inside."""
    if shadow:
        c.setFillColor(colors.HexColor("#CCCCCC"))
        c.roundRect(x+2, y-2, w, h, radius, fill=1, stroke=0)
    c.setFillColor(bg)
    c.setStrokeColor(border)
    c.setLineWidth(border_width)
    c.roundRect(x, y, w, h, radius, fill=1, stroke=1)

    total_text_h = sum(fs + 2 for _, _, fs, _ in lines)
    gap = (h - total_text_h) / 2
    cur_y = y + h - gap

    for text, font, fs, col in lines:
        cur_y -= fs
        c.setFillColor(col)
        c.setFont(font, fs)
        c.drawCentredString(x + w / 2, cur_y, text)
        cur_y -= 2


def draw_diamond(c, cx, cy, hw, hh,
                 lines, bg=C_YELLOW_LT, border=C_YELLOW,
                 border_width=1.5):
    """Draw a diamond decision shape."""
    path = c.beginPath()
    path.moveTo(cx, cy + hh)
    path.lineTo(cx + hw, cy)
    path.lineTo(cx, cy - hh)
    path.lineTo(cx - hw, cy)
    path.close()
    c.setFillColor(bg)
    c.setStrokeColor(border)
    c.setLineWidth(border_width)
    c.drawPath(path, fill=1, stroke=1)

    total_text_h = sum(fs + 2 for _, _, fs, _ in lines)
    cur_y = cy + total_text_h / 2

    for text, font, fs, col in lines:
        c.setFillColor(col)
        c.setFont(font, fs)
        c.drawCentredString(cx, cur_y, text)
        cur_y -= (fs + 3)


def arrow(c, x1, y1, x2, y2, label="", col=C_NAVY, lw=1.2):
    """Draw an arrow with an optional label."""
    c.setStrokeColor(col)
    c.setLineWidth(lw)
    c.line(x1, y1, x2, y2)
    # Arrowhead
    import math
    angle = math.atan2(y2 - y1, x2 - x1)
    ah = 6
    for da in (0.4, -0.4):
        ex = x2 - ah * math.cos(angle - da)
        ey = y2 - ah * math.sin(angle - da)
        c.line(x2, y2, ex, ey)
    if label:
        mx, my = (x1 + x2) / 2, (y1 + y2) / 2
        c.setFont("Helvetica-Bold", 7)
        c.setFillColor(col)
        c.drawCentredString(mx, my + 3, label)


def h_arrow(c, x1, y, x2, label="", col=C_NAVY):
    arrow(c, x1, y, x2, y, label, col)


def v_arrow(c, x, y1, y2, label="", col=C_NAVY):
    arrow(c, x, y1, x, y2, label, col)


# ══════════════════════════════════════════════════════════════════════════════
# PAGE 1  –  MASTER DECISION TREE
# ══════════════════════════════════════════════════════════════════════════════
def page1(c):
    W, H = PAGE_W, PAGE_H
    c.setPageSize(landscape(A3))

    # ── Background ────────────────────────────────────────────────────────────
    c.setFillColor(colors.HexColor("#F7F9FC"))
    c.rect(0, 0, W, H, fill=1, stroke=0)

    # ── Header bar ────────────────────────────────────────────────────────────
    c.setFillColor(C_NAVY)
    c.rect(0, H - 22*mm, W, 22*mm, fill=1, stroke=0)
    c.setFillColor(C_WHITE)
    c.setFont("Helvetica-Bold", 16)
    c.drawCentredString(W/2, H - 13*mm, "POST-OPERATIVE HYPERTENSION (POH-T) — CLINICAL DRUG SELECTION DECISION TREE")
    c.setFont("Helvetica", 9)
    c.drawCentredString(W/2, H - 19*mm,
        "Sources: Morgan & Mikhail 7e • Miller's Anesthesia 10e • Comprehensive Clinical Nephrology 7e • AHA/ACC 2024 Perioperative Guidelines")

    # ── Footer ────────────────────────────────────────────────────────────────
    c.setFillColor(C_NAVY)
    c.rect(0, 0, W, 8*mm, fill=1, stroke=0)
    c.setFillColor(C_WHITE)
    c.setFont("Helvetica-Oblique", 7)
    c.drawCentredString(W/2, 2.5*mm,
        "For clinical use only. Individualise all decisions to the patient. MAP target ≥60 mmHg (POQI 2024). Page 1 of 2")

    # ── Column guide lines (subtle) ───────────────────────────────────────────
    # Nothing — keep clean

    # ═══ TIER 0 : START ═══
    bw, bh = 90*mm, 16*mm
    bx = W/2 - bw/2
    by = H - 22*mm - 5*mm - bh
    draw_box(c, bx, by, bw, bh,
             [("PATIENT DEVELOPS POST-OP HYPERTENSION", "Helvetica-Bold", 10, C_WHITE),
              ("SBP >20–30% above patient's own baseline  OR  SBP ≥180 mmHg", "Helvetica", 7.5, C_WHITE)],
             bg=C_NAVY, border=C_NAVY, radius=5, shadow=True)
    top_cx = W/2
    top_cy = by  # bottom of start box

    # ═══ TIER 1 : Diamond — Reversible Cause? ═══
    d1_cx = W/2
    d1_cy = by - 22*mm
    d1_hw, d1_hh = 72*mm, 11*mm
    draw_diamond(c, d1_cx, d1_cy, d1_hw, d1_hh,
                 [("STEP 1:  Identify & Treat Reversible Causes First", "Helvetica-Bold", 8.5, C_BLACK),
                  ("Pain? Bladder distension? Hypoxaemia? Hypercapnia? Agitation? Fluid overload?", "Helvetica", 7, C_BLACK)],
                 bg=C_YELLOW_LT, border=C_YELLOW)
    v_arrow(c, top_cx, top_cy, d1_cx, d1_cy + d1_hh + 0.5*mm)

    # YES branch — BP resolved
    yes_bx = W/2 + d1_hw + 6*mm
    yes_by = d1_cy - 7*mm
    yes_bw, yes_bh = 55*mm, 14*mm
    draw_box(c, yes_bx, yes_by, yes_bw, yes_bh,
             [("BP RESOLVES", "Helvetica-Bold", 9, C_GREEN),
              ("No drug needed", "Helvetica", 7.5, C_BLACK),
              ("Continue monitoring", "Helvetica", 7.5, C_BLACK)],
             bg=C_GREEN_LT, border=C_GREEN, radius=5)
    h_arrow(c, d1_cx + d1_hw, d1_cy, yes_bx, label="YES", col=C_GREEN)

    # NO branch — continues down
    v_arrow(c, d1_cx, d1_cy - d1_hh - 0.5*mm, d1_cx, d1_cy - d1_hh - 12*mm, label="NO", col=C_RED)

    # ═══ TIER 2 : Severity Diamond ═══
    d2_cy = d1_cy - d1_hh - 18*mm
    d2_hw, d2_hh = 60*mm, 11*mm
    draw_diamond(c, d1_cx, d2_cy, d2_hw, d2_hh,
                 [("STEP 2:  Assess Severity & End-Organ Signs", "Helvetica-Bold", 8.5, C_BLACK),
                  ("Ischaemia? Heart failure? Bleeding? Neuro signs? ICU?", "Helvetica", 7, C_BLACK)],
                 bg=C_YELLOW_LT, border=C_ORANGE)

    # ── MILD-MODERATE branch (LEFT) ───────────────────────────────────────────
    mild_cx = W/2 - 110*mm
    mild_cy = d2_cy - 0*mm

    # Arrow from diamond left
    arrow(c, d1_cx - d2_hw, d2_cy, mild_cx + 55*mm, d2_cy,
          label="MILD–MODERATE", col=C_TEAL)

    # MILD BOX
    draw_box(c, mild_cx - 27*mm, d2_cy - 8*mm, 54*mm, 14*mm,
             [("MILD–MODERATE HTN", "Helvetica-Bold", 9, C_WHITE),
              ("20–30% above baseline", "Helvetica", 7.5, C_WHITE),
              ("No end-organ signs", "Helvetica", 7.5, C_WHITE)],
             bg=C_TEAL, border=C_TEAL, radius=5, shadow=True)

    # STEP 3 drugs — mild
    mild_drugs_y = d2_cy - 24*mm
    drug_w, drug_h = 54*mm, 42*mm

    draw_box(c, mild_cx - 27*mm, mild_drugs_y - drug_h, drug_w, drug_h,
             [("STEP 3A — FIRST-LINE IV DRUGS", "Helvetica-Bold", 8, C_WHITE),
              ("", "Helvetica", 2, C_WHITE),
              ("① LABETALOL  (α₁+β blocker)", "Helvetica-Bold", 8, C_YELLOW_LT),
              ("0.3–1 mg/kg IV bolus (max 80 mg)", "Helvetica", 7, C_WHITE),
              ("Onset 5–10 min | Duration 3–6 h", "Helvetica", 7, C_WHITE),
              ("Avoid: HF, asthma, bradycardia", "Helvetica-Oblique", 6.5, colors.HexColor("#FADADD")),
              ("", "Helvetica", 2, C_WHITE),
              ("② NICARDIPINE  (DHP-CCB)", "Helvetica-Bold", 8, C_YELLOW_LT),
              ("5 mg/h IV → titrate to 15 mg/h", "Helvetica", 7, C_WHITE),
              ("Onset 5–15 min | Duration 4–6 h", "Helvetica", 7, C_WHITE),
              ("Preferred post cardiac/vascular surgery", "Helvetica-Oblique", 6.5, colors.HexColor("#D5F5E3")),
              ("", "Helvetica", 2, C_WHITE),
              ("③ ENALAPRILAT  (IV ACE-i)", "Helvetica-Bold", 8, C_YELLOW_LT),
              ("0.625–1.25 mg IV q6h", "Helvetica", 7, C_WHITE),
              ("Onset 15–30 min | Duration 6–12 h", "Helvetica", 7, C_WHITE),
              ("Avoid: RAS inhibitors post-bypass, AKI", "Helvetica-Oblique", 6.5, colors.HexColor("#FADADD"))],
             bg=C_TEAL, border=C_TEAL, radius=5, shadow=True)

    # ── SEVERE branch (RIGHT) ─────────────────────────────────────────────────
    sev_cx = W/2 + 110*mm

    arrow(c, d1_cx + d2_hw, d2_cy, sev_cx - 27*mm, d2_cy,
          label="SEVERE / END-ORGAN SIGNS", col=C_RED)

    draw_box(c, sev_cx - 27*mm, d2_cy - 8*mm, 54*mm, 14*mm,
             [("SEVERE HTN / END-ORGAN SIGNS", "Helvetica-Bold", 9, C_WHITE),
              ("Ischaemia, HF, ICH, bleeding", "Helvetica", 7.5, C_WHITE),
              ("→ Arterial line mandatory", "Helvetica-Bold", 7.5, colors.HexColor("#FFD700"))],
             bg=C_RED, border=C_RED, radius=5, shadow=True)

    sev_drugs_y = d2_cy - 24*mm

    draw_box(c, sev_cx - 27*mm, sev_drugs_y - drug_h, drug_w, drug_h,
             [("STEP 3B — IV INFUSION AGENTS", "Helvetica-Bold", 8, C_WHITE),
              ("", "Helvetica", 2, C_WHITE),
              ("① CLEVIDIPINE  (ultra-short DHP-CCB)", "Helvetica-Bold", 8, C_YELLOW_LT),
              ("Start 1–2 mg/h → double q90 sec", "Helvetica", 7, C_WHITE),
              ("Onset 2–4 min | Duration 5–15 min", "Helvetica", 7, C_WHITE),
              ("Plasma esterase metabolism — organ-safe", "Helvetica-Oblique", 6.5, colors.HexColor("#D5F5E3")),
              ("", "Helvetica", 2, C_WHITE),
              ("② SODIUM NITROPRUSSIDE  (SNP)", "Helvetica-Bold", 8, C_YELLOW_LT),
              ("0.3–10 mcg/kg/min IV (titrate)", "Helvetica", 7, C_WHITE),
              ("Onset seconds | Duration 1–2 min", "Helvetica", 7, C_WHITE),
              ("⚠ Cyanide toxicity if >2 mcg/kg/min >48h", "Helvetica-Oblique", 6.5, colors.HexColor("#FADADD")),
              ("", "Helvetica", 2, C_WHITE),
              ("③ ESMOLOL  (β₁-blocker, ultra-short)", "Helvetica-Bold", 8, C_YELLOW_LT),
              ("500 mcg/kg bolus → 50–300 mcg/kg/min", "Helvetica", 7, C_WHITE),
              ("Onset 1–2 min | Duration 10–30 min", "Helvetica", 7, C_WHITE),
              ("Rate-related HTN, aortic dissection", "Helvetica-Oblique", 6.5, colors.HexColor("#D5F5E3"))],
             bg=C_RED, border=C_RED, radius=5, shadow=True)

    # ── CENTRE: STEP 4 — Situation-specific ──────────────────────────────────
    spec_y = d2_cy - 24*mm - drug_h - 10*mm
    spec_w = 120*mm
    spec_x = W/2 - spec_w/2
    spec_h = 28*mm

    # Connector from both branches
    v_arrow(c, mild_cx, d2_cy - 24*mm - drug_h,
            W/2, spec_y + spec_h, col=C_NAVY)
    v_arrow(c, sev_cx, d2_cy - 24*mm - drug_h,
            W/2, spec_y + spec_h, col=C_NAVY)

    draw_box(c, spec_x, spec_y, spec_w, spec_h,
             [("STEP 4 — SITUATION-SPECIFIC DRUG SELECTION", "Helvetica-Bold", 9, C_WHITE),
              ("(See Page 2 for full situation-by-situation chart)", "Helvetica", 7.5, colors.HexColor("#D6EAF8")),
              ("Coronary surgery → NTG / Nicardipine", "Helvetica", 7.5, C_WHITE),
              ("Aortic dissection → Labetalol + SNP (↓dP/dt)", "Helvetica", 7.5, C_WHITE),
              ("Raised ICP → Esmolol / Labetalol  (AVOID SNP)", "Helvetica", 7.5, C_WHITE),
              ("Phaeochromocytoma → Phentolamine (AVOID β-blocker alone)", "Helvetica", 7.5, C_WHITE)],
             bg=C_NAVY, border=C_TEAL, radius=6, shadow=True)

    # ── STEP 5 ────────────────────────────────────────────────────────────────
    step5_y = spec_y - 14*mm
    step5_w = 110*mm
    step5_x = W/2 - step5_w/2

    v_arrow(c, W/2, spec_y, W/2, step5_y + 12*mm, col=C_NAVY)

    draw_box(c, step5_x, step5_y, step5_w, 12*mm,
             [("STEP 5 — RESUME ORAL ANTIHYPERTENSIVES when tolerating orally", "Helvetica-Bold", 8, C_NAVY),
              ("Restart β-blockers & clonidine FIRST to prevent rebound | Delay ACE-i/ARB until volume adequate", "Helvetica", 7, C_BLACK)],
             bg=C_BLUE_LT, border=C_NAVY, radius=4)

    # ── Legend boxes ─────────────────────────────────────────────────────────
    leg_x = 8*mm
    leg_y = 12*mm
    lw, lh = 30*mm, 7*mm
    items = [
        (C_TEAL_LT, C_TEAL, "Mild–Moderate"),
        (C_RED_LT,  C_RED,  "Severe / End-Organ"),
        (C_GREEN_LT,C_GREEN,"Resolved / No Rx"),
        (C_YELLOW_LT,C_YELLOW,"Decision Point"),
        (C_NAVY,    C_NAVY, "Navigation"),
    ]
    c.setFont("Helvetica-Bold", 7.5)
    c.setFillColor(C_NAVY)
    c.drawString(leg_x, leg_y + len(items)*lh + 2*mm, "LEGEND")
    for i, (bg, bdr, txt) in enumerate(items):
        bx2 = leg_x
        by2 = leg_y + i * (lh + 1.5*mm)
        c.setFillColor(bg)
        c.setStrokeColor(bdr)
        c.setLineWidth(1)
        c.roundRect(bx2, by2, lw, lh, 2, fill=1, stroke=1)
        c.setFillColor(C_BLACK if bg != C_NAVY else C_WHITE)
        c.setFont("Helvetica", 7)
        c.drawCentredString(bx2 + lw/2, by2 + 2*mm, txt)

    # ── Arrows: mild & severe down to situation-specific ─────────────────────
    # Already drawn above as connector lines


# ══════════════════════════════════════════════════════════════════════════════
# PAGE 2  –  SITUATION-SPECIFIC CHART + PHARMACOLOGY REFERENCE
# ══════════════════════════════════════════════════════════════════════════════
def page2(c):
    W, H = PAGE_W, PAGE_H
    c.setPageSize(landscape(A3))

    # Background
    c.setFillColor(colors.HexColor("#F7F9FC"))
    c.rect(0, 0, W, H, fill=1, stroke=0)

    # Header
    c.setFillColor(C_NAVY)
    c.rect(0, H - 22*mm, W, 22*mm, fill=1, stroke=0)
    c.setFillColor(C_WHITE)
    c.setFont("Helvetica-Bold", 15)
    c.drawCentredString(W/2, H - 13*mm,
        "POH-T — SITUATION-SPECIFIC DRUG SELECTION & PHARMACOLOGY REFERENCE")
    c.setFont("Helvetica", 8.5)
    c.drawCentredString(W/2, H - 19*mm,
        "Sources: Comprehensive Clinical Nephrology 7e (Table 36.2, 38.1) • Miller's Anesthesia 10e • Morgan & Mikhail 7e")

    # Footer
    c.setFillColor(C_NAVY)
    c.rect(0, 0, W, 8*mm, fill=1, stroke=0)
    c.setFillColor(C_WHITE)
    c.setFont("Helvetica-Oblique", 7)
    c.drawCentredString(W/2, 2.5*mm,
        "Individualise all treatment decisions. MAP target ≥60 mmHg (POQI 2024 Consensus, Br J Anaesth).  Page 2 of 2")

    # ─── SECTION A: Situation-Specific Table ────────────────────────────────
    tbl_y = H - 22*mm - 5*mm
    tbl_x = 8*mm
    tbl_w = W - 16*mm
    col_widths = [52*mm, 60*mm, 55*mm, 45*mm, 50*mm]  # 5 cols
    row_h = 10*mm

    headers = ["CLINICAL SITUATION", "FIRST-CHOICE DRUG(S)", "SECOND CHOICE / ADD-ON", "DRUGS TO AVOID", "BP REDUCTION AIM"]
    rows = [
        ["Coronary artery / CABG surgery",
         "Nitroglycerin (GTN)\nNicardipine\nClevidipine",
         "Labetalol\nEsmolol (if no HF)\nSNP",
         "Diazoxide\nHydralazine",
         "Improve coronary perfusion\nAvoid ischaemia"],
        ["Heart failure /\nPulmonary oedema",
         "Clevidipine\nNitroglycerin\nFenoldopam",
         "SNP + loop diuretic\nEnalaprilat",
         "Diazoxide\nHydralazine\nβ-blockers",
         "↓ Afterload\nReduce pulmonary oedema"],
        ["Aortic dissection",
         "Labetalol\n— OR —\nEsmolol + SNP/Fenoldopam",
         "Nicardipine\nClevidipine",
         "Vasodilator monotherapy\n(reflex tachycardia ↑ dP/dt)",
         "HR <60 bpm\nSBP 100–120 mmHg\nMinimise dP/dt"],
        ["Raised ICP /\nNeurosurgery",
         "Esmolol\nLabetalol",
         "Nicardipine",
         "SNP\n(cerebral vasodilation → ↑ICP)",
         "Lower MAP gradually\nPreserve CPP"],
        ["Post-carotid endarterectomy",
         "Short-acting IV agents:\nLabetalol, Nicardipine",
         "Esmolol",
         "—",
         "Near pre-op values\nMost resolve in 12–24 h"],
        ["Phaeochromocytoma\n(catecholamine excess)",
         "Phentolamine\n(α-blocker)\nNicardipine",
         "Labetalol (combined α+β)",
         "β-blocker ALONE\n(→ hypertensive crisis)",
         "Control catecholamine surge\nAvoid reflex tachycardia"],
        ["Renal failure",
         "Clevidipine\nNicardipine\nLabetalol",
         "Fenoldopam\n(↑ renal blood flow + natriuresis)",
         "SNP\n(thiocyanate accumulates)",
         "Preserve renal perfusion"],
        ["Post-eclampsia /\nObstetric",
         "Hydralazine (IV)\nLabetalol\nNicardipine",
         "Magnesium sulfate\n(seizure prophylaxis)",
         "ACE inhibitors\nARBs (teratogenic)",
         "SBP <160 / DBP <110 mmHg"],
    ]

    # Draw header row
    cur_x = tbl_x
    c.setFillColor(C_NAVY)
    for i, h_txt in enumerate(headers):
        c.rect(cur_x, tbl_y - row_h, col_widths[i], row_h, fill=1, stroke=0)
        c.setFillColor(C_WHITE)
        c.setFont("Helvetica-Bold", 7.5)
        c.drawCentredString(cur_x + col_widths[i]/2, tbl_y - row_h + 3.5*mm, h_txt)
        c.setFillColor(C_NAVY)
        cur_x += col_widths[i]

    # Table rows
    row_colors = [C_BLUE_LT, C_WHITE]
    situation_colors = [C_TEAL, C_RED, C_PURPLE, C_ORANGE,
                        C_TEAL, C_RED, C_GREEN, C_NAVY]
    situation_lt = [C_TEAL_LT, C_RED_LT, C_PURPLE_LT, C_ORANGE_LT,
                    C_TEAL_LT, C_RED_LT, C_GREEN_LT, C_BLUE_LT]

    cur_row_y = tbl_y - row_h
    for ri, row in enumerate(rows):
        rh = row_h * 2 if '\n' in row[0] else row_h * 1.7
        cur_row_y -= rh
        cur_x = tbl_x
        for ci, cell in enumerate(row):
            bg = situation_lt[ri] if ci == 0 else row_colors[ri % 2]
            c.setFillColor(bg)
            c.setStrokeColor(C_BORDER)
            c.setLineWidth(0.5)
            c.rect(cur_x, cur_row_y, col_widths[ci], rh, fill=1, stroke=1)
            # Text
            lines = cell.split('\n')
            font = "Helvetica-Bold" if ci == 0 else "Helvetica"
            fs = 7.5 if ci == 0 else 7
            total_h = len(lines) * (fs + 2.5)
            ty = cur_row_y + rh/2 + total_h/2 - fs
            for line in lines:
                c.setFillColor(situation_colors[ri] if ci == 0 else C_BLACK)
                c.setFont(font, fs)
                c.drawCentredString(cur_x + col_widths[ci]/2, ty, line)
                ty -= (fs + 2.5)
            cur_x += col_widths[ci]

    # ─── SECTION B: Pharmacology Quick Reference Boxes ──────────────────────
    pharm_y = cur_row_y - 8*mm
    c.setFont("Helvetica-Bold", 10)
    c.setFillColor(C_NAVY)
    c.drawString(tbl_x, pharm_y, "PHARMACOLOGY QUICK REFERENCE")
    c.setLineWidth(1.5)
    c.setStrokeColor(C_TEAL)
    c.line(tbl_x, pharm_y - 1.5*mm, tbl_x + 100*mm, pharm_y - 1.5*mm)

    drugs_data = [
        {
            "name": "LABETALOL", "class": "α₁ + β blocker",
            "mech": "Blocks α₁ (↓SVR) and β₁ (↓HR, ↓CO). α:β ratio 1:7 IV.",
            "dose": "0.3–1 mg/kg IV bolus q10 min\nor 0.4–1 mg/kg/h infusion",
            "onset": "5–10 min", "dur": "3–6 h",
            "avoid": "HF, asthma, bradycardia, AV block",
            "bg": C_TEAL_LT, "bdr": C_TEAL
        },
        {
            "name": "NICARDIPINE", "class": "DHP Calcium Channel Blocker",
            "mech": "Blocks L-type Ca²⁺ in vascular SM → arterial vasodilation. Minimal cardiac effect.",
            "dose": "5 mg/h IV → titrate 2.5 mg/h\nevery 5–15 min; max 15 mg/h",
            "onset": "5–15 min", "dur": "4–6 h",
            "avoid": "Severe LV dysfunction (relative)",
            "bg": C_BLUE_LT, "bdr": C_TEAL
        },
        {
            "name": "CLEVIDIPINE", "class": "Ultra-short DHP-CCB (3rd gen)",
            "mech": "Highly selective arterial L-type Ca²⁺ blocker. Hydrolysed by plasma esterases → organ-independent metabolism.",
            "dose": "1–2 mg/h IV; double q90 sec\nUsual 4–6 mg/h; max 32 mg/h",
            "onset": "2–4 min", "dur": "5–15 min",
            "avoid": "Soy/egg allergy (lipid vehicle), severe AS",
            "bg": C_BLUE_LT, "bdr": C_NAVY
        },
        {
            "name": "ESMOLOL", "class": "Ultra-short β₁ blocker",
            "mech": "β₁-adrenoceptor antagonism → ↓ HR and contractility. t½ ~9 min (RBC esterases).",
            "dose": "500 mcg/kg bolus over 1 min\nthen 50–300 mcg/kg/min infusion",
            "onset": "1–2 min", "dur": "10–30 min",
            "avoid": "HF, asthma, COPD, AV block, bradycardia",
            "bg": C_ORANGE_LT, "bdr": C_ORANGE
        },
        {
            "name": "SODIUM NITROPRUSSIDE", "class": "Nitrovasodilator",
            "mech": "Releases NO → ↑ cGMP → arterial + venous vasodilation. Most titratable agent available.",
            "dose": "0.3 mcg/kg/min → titrate\nto max 10 mcg/kg/min. Cover from light.",
            "onset": "Seconds", "dur": "1–2 min",
            "avoid": "Renal failure (thiocyanate), raised ICP\n⚠ Cyanide toxicity >2 mcg/kg/min >48h",
            "bg": C_RED_LT, "bdr": C_RED
        },
        {
            "name": "NITROGLYCERIN", "class": "Organic nitrate",
            "mech": "mtALDH2 converts to NO → venodilation >> arterial dilation. Reduces preload & wall tension. Coronary vasodilator.",
            "dose": "5–10 mcg/min IV; titrate\nto 200 mcg/min",
            "onset": "1–2 min", "dur": "3–5 min",
            "avoid": "PDE-5 inhibitors; tolerance within 24h",
            "bg": C_RED_LT, "bdr": C_ORANGE
        },
        {
            "name": "FENOLDOPAM", "class": "Dopamine D₁ agonist",
            "mech": "D₁ receptor stimulation → arterial vasodilation + ↑ renal blood flow (natriuresis, diuresis). No adrenergic activity.",
            "dose": "0.1–1.6 mcg/kg/min IV infusion\n(start low, titrate)",
            "onset": "5–10 min", "dur": "30–60 min",
            "avoid": "High doses → reflex tachycardia\nGlaucoma (↑ IOP)",
            "bg": C_GREEN_LT, "bdr": C_GREEN
        },
        {
            "name": "PHENTOLAMINE", "class": "Non-selective α blocker",
            "mech": "Competitive α₁ + α₂ blockade → ↓ SVR. α₂ blockade → reflex noradrenaline release → tachycardia.",
            "dose": "5–15 mg IV bolus\nRepeat q10 min as needed",
            "onset": "1–2 min", "dur": "10–30 min",
            "avoid": "Use without β-blocker (if rate control needed,\nadd β-blocker AFTER α-blockade established)",
            "bg": C_PURPLE_LT, "bdr": C_PURPLE
        },
    ]

    # Draw drug boxes in 2 rows of 4
    box_w = (tbl_w - 7*mm) / 4
    box_h = 32*mm
    box_gap = 2.5*mm
    pharm_box_y = pharm_y - 4*mm - box_h

    for idx, d in enumerate(drugs_data):
        col = idx % 4
        row = idx // 4
        bx = tbl_x + col * (box_w + box_gap)
        by = pharm_box_y - row * (box_h + box_gap)

        # Box background
        c.setFillColor(d["bg"])
        c.setStrokeColor(d["bdr"])
        c.setLineWidth(1.5)
        c.roundRect(bx, by, box_w, box_h, 4, fill=1, stroke=1)

        # Header strip
        c.setFillColor(d["bdr"])
        c.roundRect(bx, by + box_h - 8*mm, box_w, 8*mm, 4, fill=1, stroke=0)
        # Cover bottom corners of header
        c.rect(bx, by + box_h - 8*mm, box_w, 4*mm, fill=1, stroke=0)

        c.setFillColor(C_WHITE)
        c.setFont("Helvetica-Bold", 8)
        c.drawCentredString(bx + box_w/2, by + box_h - 5*mm, d["name"])
        c.setFont("Helvetica-Oblique", 6.5)
        c.drawCentredString(bx + box_w/2, by + box_h - 8*mm + 1.5*mm, d["class"])

        # Content
        content_y = by + box_h - 10*mm
        text_items = [
            ("Mechanism: " + d["mech"], "Helvetica", 6.2, C_BLACK),
            ("Dose: " + d["dose"], "Helvetica-Bold", 6.5, C_BLACK),
            ("Onset: " + d["onset"] + "   Duration: " + d["dur"], "Helvetica", 6.2, C_BLACK),
            ("⚠ Avoid: " + d["avoid"], "Helvetica-Oblique", 6, C_RED),
        ]
        for text, font, fs, col2 in text_items:
            # Wrap manually if needed
            lines = text.split('\n')
            for line in lines:
                content_y -= (fs + 1.5)
                c.setFillColor(col2)
                c.setFont(font, fs)
                # Truncate if too wide
                while c.stringWidth(line, font, fs) > box_w - 3*mm and len(line) > 10:
                    line = line[:-4] + "…"
                c.drawString(bx + 2*mm, content_y, line)

    # ─── DRUGS TO AVOID PANEL ─────────────────────────────────────────────────
    avoid_y = pharm_box_y - 2 * (box_h + box_gap) - 3*mm
    avoid_w = tbl_w
    avoid_h = 12*mm

    c.setFillColor(C_RED_LT)
    c.setStrokeColor(C_RED)
    c.setLineWidth(1.5)
    c.roundRect(tbl_x, avoid_y, avoid_w, avoid_h, 4, fill=1, stroke=1)

    c.setFillColor(C_RED)
    c.setFont("Helvetica-Bold", 8.5)
    c.drawString(tbl_x + 3*mm, avoid_y + 8*mm, "⛔  DRUGS TO AVOID IN POST-OP HYPERTENSION:")
    c.setFillColor(C_BLACK)
    c.setFont("Helvetica", 7.5)
    avoid_text = ("Sublingual Nifedipine  (uncontrolled BP drop, reflex tachycardia → MI risk)   |   "
                  "IV Hydralazine  (unpredictable, prolonged, reflex tachycardia)   |   "
                  "Diazoxide  (excessive / prolonged hypotension)   |   "
                  "SNP in raised ICP  (cerebral vasodilation ↑ ICP)   |   "
                  "β-blocker alone in phaeochromocytoma  (unopposed α → hypertensive crisis)   |   "
                  "ACE-i / ARBs in bilateral RAS or AKI")
    c.drawString(tbl_x + 3*mm, avoid_y + 2.5*mm, avoid_text)


# ══════════════════════════════════════════════════════════════════════════════
# MAIN
# ══════════════════════════════════════════════════════════════════════════════
def main():
    os.makedirs(os.path.dirname(OUTPUT_PATH), exist_ok=True)
    c = canvas.Canvas(OUTPUT_PATH, pagesize=landscape(A3))
    c.setTitle("POH-T Clinical Drug Selection Decision Tree")
    c.setAuthor("Orris Clinical AI")
    c.setSubject("Post-Operative Hypertension Management")

    page1(c)
    c.showPage()
    page2(c)
    c.showPage()
    c.save()
    print(f"PDF saved to: {OUTPUT_PATH}")


if __name__ == "__main__":
    main()
Running Command

cd /home/daytona/workspace/poh-decision-tree && python generate_pdf.py

Editing File

~/poh-decision-tree/generate_pdf.py

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/poh-decision-tree/generate_pdf.py'
Running Command

cd /home/daytona/workspace/poh-decision-tree && python generate_pdf.py

Editing File

~/poh-decision-tree/generate_pdf.py

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/poh-decision-tree/generate_pdf.py'
Running Command

cd /home/daytona/workspace/poh-decision-tree && python generate_pdf.py 2>&1

Searching Content

"def v_arrow" in ~/poh-decision-tree

Reading File
Reading File
Reading File
Running Command

grep -n "v_arrow" /home/daytona/workspace/poh-decision-tree/generate_pdf.py

Editing File

~/poh-decision-tree/generate_pdf.py

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/poh-decision-tree/generate_pdf.py'
Editing File

~/poh-decision-tree/generate_pdf.py

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/poh-decision-tree/generate_pdf.py'
Running Command

cd /home/daytona/workspace/poh-decision-tree && python generate_pdf.py 2>&1 && l…

Model call limits exceeded: run limit (20/20)
This is a shared conversation. Sign in to Orris to start your own chat.