make all emergency drugs

Asking for Preferences
Reading File
Reading File
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Finding Sources
Finding Sources
Finding Sources
Running Command

mkdir -p /tmp/workspace/emergency-drugs && ls /tmp/workspace/emergency-drugs/

Writing File

~/emergency-drugs/build_emergency_drugs.py

from docx import Document
from docx.shared import Pt, Inches, RGBColor, Cm
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.enum.table import WD_TABLE_ALIGNMENT, WD_ALIGN_VERTICAL
from docx.oxml.ns import qn
from docx.oxml import OxmlElement
import copy

doc = Document()

# ── Page margins ──────────────────────────────────────────────
for section in doc.sections:
    section.top_margin    = Cm(2.0)
    section.bottom_margin = Cm(2.0)
    section.left_margin   = Cm(2.2)
    section.right_margin  = Cm(2.2)

# ── Helper: set cell background colour ───────────────────────
def set_cell_bg(cell, hex_color):
    tc = cell._tc
    tcPr = tc.get_or_add_tcPr()
    shd = OxmlElement('w:shd')
    shd.set(qn('w:val'), 'clear')
    shd.set(qn('w:color'), 'auto')
    shd.set(qn('w:fill'), hex_color)
    tcPr.append(shd)

def set_cell_borders(cell, hex_color='AAAAAA', size='4'):
    tc = cell._tc
    tcPr = tc.get_or_add_tcPr()
    tcBorders = OxmlElement('w:tcBorders')
    for side in ['top','left','bottom','right']:
        border = OxmlElement(f'w:{side}')
        border.set(qn('w:val'), 'single')
        border.set(qn('w:sz'), size)
        border.set(qn('w:space'), '0')
        border.set(qn('w:color'), hex_color)
        tcBorders.append(border)
    tcPr.append(tcBorders)

# ── Global font default ───────────────────────────────────────
style = doc.styles['Normal']
style.font.name = 'Calibri'
style.font.size = Pt(10)

# ── Title page ────────────────────────────────────────────────
title_para = doc.add_paragraph()
title_para.alignment = WD_ALIGN_PARAGRAPH.CENTER
run = title_para.add_run('EMERGENCY DRUGS')
run.bold = True
run.font.size = Pt(26)
run.font.color.rgb = RGBColor(0xC0, 0x00, 0x00)
run.font.name = 'Calibri'

sub_para = doc.add_paragraph()
sub_para.alignment = WD_ALIGN_PARAGRAPH.CENTER
sub_run = sub_para.add_run('Quick-Reference Clinical Compendium')
sub_run.font.size = Pt(13)
sub_run.font.color.rgb = RGBColor(0x44, 0x44, 0x44)
sub_run.italic = True

doc.add_paragraph()  # spacer

note_para = doc.add_paragraph()
note_para.alignment = WD_ALIGN_PARAGRAPH.CENTER
note_run = note_para.add_run(
    'Sources: Miller\'s Anesthesia 10e | Tintinalli\'s Emergency Medicine | '
    'Barash Clinical Anesthesia 9e | Goodman & Gilman\'s Pharmacology | '
    'Washington Manual of Medical Therapeutics'
)
note_run.font.size = Pt(8)
note_run.font.color.rgb = RGBColor(0x88, 0x88, 0x88)
note_run.italic = True

doc.add_page_break()

# ══════════════════════════════════════════════════════════════
# HELPER: add a colour-banded section heading
# ══════════════════════════════════════════════════════════════
def section_heading(text, color_hex='1F3864'):
    p = doc.add_paragraph()
    p.paragraph_format.space_before = Pt(14)
    p.paragraph_format.space_after  = Pt(4)
    run = p.add_run(text.upper())
    run.bold = True
    run.font.size = Pt(13)
    run.font.name = 'Calibri'
    run.font.color.rgb = RGBColor(0xFF, 0xFF, 0xFF)
    # shade the paragraph background via direct XML
    pPr = p._p.get_or_add_pPr()
    shd = OxmlElement('w:shd')
    shd.set(qn('w:val'), 'clear')
    shd.set(qn('w:color'), 'auto')
    shd.set(qn('w:fill'), color_hex)
    pPr.append(shd)
    return p

def sub_heading(text):
    p = doc.add_paragraph()
    p.paragraph_format.space_before = Pt(8)
    p.paragraph_format.space_after  = Pt(2)
    run = p.add_run(text)
    run.bold = True
    run.font.size = Pt(11)
    run.font.color.rgb = RGBColor(0x1F, 0x38, 0x64)
    return p

def body(text):
    p = doc.add_paragraph(text)
    p.paragraph_format.space_before = Pt(1)
    p.paragraph_format.space_after  = Pt(1)
    p.runs[0].font.size = Pt(10) if p.runs else None
    return p

def bullet(text, level=0):
    p = doc.add_paragraph(text, style='List Bullet')
    p.paragraph_format.left_indent  = Inches(0.3 + level * 0.25)
    p.paragraph_format.space_before = Pt(1)
    p.paragraph_format.space_after  = Pt(1)
    return p

# ══════════════════════════════════════════════════════════════
# BIG TABLE helper
# ══════════════════════════════════════════════════════════════
HEADER_BG  = '1F3864'   # dark navy
ROW1_BG    = 'DEEAF1'   # light blue
ROW2_BG    = 'FFFFFF'   # white

def drug_table(headers, rows, col_widths_cm=None):
    """headers: list of strings; rows: list of lists."""
    n_cols = len(headers)
    tbl = doc.add_table(rows=1, cols=n_cols)
    tbl.style = 'Table Grid'
    tbl.alignment = WD_TABLE_ALIGNMENT.CENTER

    # Set column widths
    if col_widths_cm:
        for i, cell in enumerate(tbl.columns[i].cells[0] for i in range(n_cols)):
            pass  # done per-cell below

    # Header row
    hdr_cells = tbl.rows[0].cells
    for i, h in enumerate(headers):
        cell = hdr_cells[i]
        set_cell_bg(cell, HEADER_BG)
        p = cell.paragraphs[0]
        p.alignment = WD_ALIGN_PARAGRAPH.CENTER
        run = p.add_run(h)
        run.bold = True
        run.font.size = Pt(9)
        run.font.color.rgb = RGBColor(0xFF, 0xFF, 0xFF)
        run.font.name = 'Calibri'
        if col_widths_cm:
            cell.width = Cm(col_widths_cm[i])

    # Data rows
    for ri, row_data in enumerate(rows):
        row = tbl.add_row()
        bg = ROW1_BG if ri % 2 == 0 else ROW2_BG
        for ci, val in enumerate(row_data):
            cell = row.cells[ci]
            set_cell_bg(cell, bg)
            set_cell_borders(cell)
            p = cell.paragraphs[0]
            if ci == 0:
                run = p.add_run(str(val))
                run.bold = True
                run.font.size = Pt(9)
                run.font.color.rgb = RGBColor(0x1F, 0x38, 0x64)
            else:
                run = p.add_run(str(val))
                run.font.size = Pt(9)
            run.font.name = 'Calibri'
            if col_widths_cm:
                cell.width = Cm(col_widths_cm[ci])

    doc.add_paragraph()  # spacer after table
    return tbl


# ══════════════════════════════════════════════════════════════
# SECTION 1 – CARDIAC ARREST / ACLS
# ══════════════════════════════════════════════════════════════
section_heading('1. Cardiac Arrest — ACLS Drugs', '7B0C02')

body('Per 2020 AHA Guidelines for CPR & ECC. Standard approach: CPR + defibrillation for shockable rhythms, then vasopressors and antiarrhythmics.')

drug_table(
    ['Drug', 'Indication', 'Dose & Route', 'Mechanism / Notes'],
    [
        ['Epinephrine (Adrenaline)',
         'VF, pulseless VT, PEA, Asystole',
         '1 mg IV/IO every 3-5 min\n(High-dose NOT routine)',
         'α-agonist: ↑ coronary & cerebral perfusion pressure during CPR.\nEarly use recommended for non-shockable rhythms (PEA/asystole).\nException: beta-blocker/Ca-channel blocker OD may need higher doses.'],
        ['Amiodarone',
         'Shock-refractory VF / pulseless VT',
         '1st dose: 300 mg IV/IO bolus\n2nd dose: 150 mg IV/IO',
         'Class III antiarrhythmic. Facilitates restoration of perfusing rhythm.\nNone proven to increase long-term survival.\nPreferred over lidocaine; both are acceptable alternatives.'],
        ['Lidocaine',
         'VF / pulseless VT (alternative to amiodarone)',
         '1st dose: 1-1.5 mg/kg IV/IO\n2nd dose: 0.5-0.75 mg/kg IV/IO',
         'Class Ib antiarrhythmic.\nAlternative when amiodarone unavailable.\nDo NOT use routinely together with amiodarone.'],
        ['Atropine',
         'Symptomatic bradycardia (NOT asystole/PEA)',
         '0.5 mg IV every 3-5 min\nMax total: 3 mg',
         'Muscarinic antagonist. Increases SA node firing rate.\nRemoved from asystole/PEA algorithm (no benefit shown).'],
        ['Magnesium Sulfate',
         'Torsades de Pointes (TdP)',
         '1-2 g IV over 5-20 min\n(Maintenance infusion if needed)',
         'NOT recommended for routine VF/VT.\nDrug of choice specifically for TdP / hypomagnesaemia-related VF.'],
        ['Sodium Bicarbonate',
         'Severe acidosis, hyperkalemia, TCA OD',
         '1 mEq/kg IV bolus initially\nGuided by ABG thereafter',
         'NOT recommended routinely in cardiac arrest.\nUse for TCA overdose, severe metabolic acidosis (pH <7.1), hyperkalemia.'],
        ['Calcium Chloride',
         'Hyperkalemia, hypocalcemia, Ca-channel blocker OD',
         '1 g IV (CaCl2 10%)\nor 3 g calcium gluconate IV',
         'Stabilises cardiac membrane potential.\nCaCl2 provides 3x more elemental Ca vs gluconate.\nCautious use with digoxin toxicity.'],
        ['Adenosine',
         'Stable narrow-complex SVT',
         '6 mg rapid IV push (antecubital)\n12 mg if no response (×2)\nCentral line: halve doses',
         'Transiently blocks AV node. Very short half-life (~10 sec).\nMust be given as RAPID IV push followed by 20 mL saline flush.\nWarning: monitor for bronchospasm in asthma.'],
        ['Vasopressin',
         'Removed from 2015 ACLS algorithm',
         'Historical: 40 units IV ×1\n(No longer recommended)',
         'Non-adrenergic vasoconstrictor. No benefit vs epinephrine alone in multiple trials. Not in current AHA 2020 adult arrest algorithm.'],
    ],
    [4.5, 4.0, 4.5, 7.5]
)

# ══════════════════════════════════════════════════════════════
# SECTION 2 – ACUTE CORONARY SYNDROME (STEMI)
# ══════════════════════════════════════════════════════════════
section_heading('2. Acute Coronary Syndrome / STEMI', '1F3864')

drug_table(
    ['Drug / Class', 'Dose', 'Notes'],
    [
        ['Aspirin (Antiplatelet)', '162-325 mg PO (chew)', 'First-line for all ACS; inhibits TXA2-mediated platelet aggregation.'],
        ['Clopidogrel (P2Y12)', '600 mg PO loading, then 75 mg daily\n(No loading in >75y receiving fibrinolytic)', 'Thienopyridine; irreversible P2Y12 inhibition.'],
        ['Ticagrelor (P2Y12)', '180 mg loading, then 90 mg twice daily', 'Reversible P2Y12 inhibitor. Preferred over clopidogrel in NSTEMI/STEMI.'],
        ['Prasugrel (P2Y12)', '60 mg loading, then 10 mg daily\n(Post-PCI, once anatomy defined)', 'Avoid if prior stroke/TIA, age >75, or weight <60 kg.'],
        ['UFH (Unfractionated Heparin)', '60 units/kg bolus (max 4,000 U)\nthen 12 units/kg/h (max 1,000 U/h)\nTarget aPTT 1.5-2.5x control', 'Antithrombotic; used during PCI and fibrinolysis.'],
        ['Enoxaparin (LMWH)', '30 mg IV bolus + 1 mg/kg SC q12h', 'Reduce dose in renal impairment. Simpler monitoring than UFH.'],
        ['Alteplase (Fibrinolytic)', '<67 kg: 15 mg IV bolus, then 50 mg/30 min, then 35 mg/60 min\n≥67 kg: 15 mg bolus, 0.75 mg/kg/30 min, 0.5 mg/kg/60 min', 'tPA. Use within 12h of symptom onset if PCI unavailable.'],
        ['Tenecteplase (Fibrinolytic)', '30-50 mg IV bolus (weight-based)', '<60 kg=30 mg; 60-70 kg=35 mg; 70-80 kg=40 mg; 80-90 kg=45 mg; ≥90 kg=50 mg.'],
        ['Nitroglycerin', 'SL: 0.4 mg q5 min x3\nIV: Start 10 mcg/min, titrate\n(10% MAP ↓ if normotensive; 30% if hypertensive)', 'Venodilator; reduces preload and ischemic pain. CONTRAINDICATED with PDE5 inhibitors.'],
        ['Morphine', '2-5 mg IV q5-15 min PRN pain', 'Use cautiously — may mask symptoms; some data suggest worse outcomes in ACS.'],
        ['Metoprolol (Beta-blocker)', 'Oral if stable; IV if needed\n(Withhold if cardiogenic shock/bradycardia/heart block)', 'Reduces myocardial O2 demand. CONTRAINDICATED in decompensated HF, severe bradycardia.'],
    ],
    [4.5, 5.0, 7.0]
)

# ══════════════════════════════════════════════════════════════
# SECTION 3 – ANAPHYLAXIS
# ══════════════════════════════════════════════════════════════
section_heading('3. Anaphylaxis', 'C45911')

drug_table(
    ['Drug', 'Dose & Route', 'Priority', 'Notes'],
    [
        ['Epinephrine (Adrenaline)',
         'Adults: 0.3-0.5 mg IM (anterolateral thigh)\nChildren: 0.01 mg/kg IM (max 0.5 mg)\nSelf-injector: EpiPen 0.3 mg / EpiPen Jr 0.15 mg\nSevere/refractory: 0.1-0.2 mg IV slow push',
         '1st LINE',
         'ALWAYS first drug. IM thigh > SC/deltoid. Repeat every 5-15 min if needed.\nβ-agonist: reverses bronchospasm.\nα-agonist: reverses vasodilation & hypotension.'],
        ['Normal Saline (IV Fluids)',
         '1-2 L rapid IV bolus (adults)\n20 mL/kg bolus (children)',
         '1st LINE',
         'Given immediately for hypotension. May need several litres for refractory shock.'],
        ['Diphenhydramine (H1-blocker)',
         '25-50 mg IV/IM/PO',
         '2nd LINE',
         'Treats urticaria/pruritus — does NOT reverse respiratory/cardiovascular effects.\nNever give as sole treatment; always after epinephrine.'],
        ['Ranitidine / Famotidine (H2-blocker)',
         'Ranitidine 50 mg IV or Famotidine 20 mg IV',
         '2nd LINE',
         'Additive benefit with H1 blocker for cutaneous symptoms. NOT a substitute for epinephrine.'],
        ['Hydrocortisone / Methylprednisolone',
         'Hydrocortisone 200 mg IV or\nMethylprednisolone 1-2 mg/kg IV',
         '2nd LINE',
         'Prevents biphasic reaction (onset 4-8h). NOT for acute management — too slow.\nMonitor for observation period of 4-8h after anaphylaxis.'],
        ['Salbutamol / Albuterol (Nebulised)',
         '2.5-5 mg nebulised; repeat as needed',
         'Adjunct',
         'For bronchospasm refractory to epinephrine.\nDoes NOT replace epinephrine.'],
        ['Glucagon',
         '1-5 mg IV over 5 min, then 5-15 mcg/min infusion',
         'Adjunct',
         'For patients on beta-blockers (who may not respond to epinephrine).\nBypass β-receptor to increase cAMP and cardiac output.'],
    ],
    [3.5, 5.0, 2.0, 6.0]
)

# ══════════════════════════════════════════════════════════════
# SECTION 4 – SEIZURES / STATUS EPILEPTICUS
# ══════════════════════════════════════════════════════════════
section_heading('4. Seizures & Status Epilepticus', '1F3864')

drug_table(
    ['Drug', 'Dose & Route', 'Timing', 'Notes'],
    [
        ['Lorazepam (Ativan)',
         '0.1 mg/kg IV (max 4 mg/dose)\nRepeat once after 5 min if needed',
         '0-5 min (1st line IV)',
         'Benzodiazepine. First choice if IV access available. Longer duration than diazepam.'],
        ['Midazolam (Buccal/IM)',
         '10 mg IM (>40 kg) / 5 mg (13-40 kg)\nBuccal: 10 mg',
         '0-5 min (1st line no IV)',
         'Preferred when no IV access. IM midazolam as effective as IV lorazepam for prehospital SE.'],
        ['Diazepam (Rectal/IV)',
         'IV: 0.15 mg/kg (max 10 mg)\nRectal: 0.5 mg/kg',
         '0-5 min (alternative)',
         'Rectal route useful in paediatrics/prehospital. Shorter duration than lorazepam; more rebound.'],
        ['Phenytoin / Fosphenytoin',
         'Phenytoin: 20 mg/kg IV at ≤50 mg/min\nFosphenytoin: 20 mg PE/kg at ≤150 mg PE/min',
         '5-30 min (2nd line)',
         'Fosphenytoin preferred (less phlebitis, faster admin).\nMonitor for hypotension and arrhythmia during loading.'],
        ['Valproate (Sodium Valproate)',
         '40 mg/kg IV over 10 min (max 3000 mg)',
         '5-30 min (2nd line alt.)',
         'Safe alternative to phenytoin. Avoid in liver disease/pregnancy (mitochondrial effects).'],
        ['Levetiracetam',
         '60 mg/kg IV over 10 min (max 4500 mg)',
         '5-30 min (2nd line alt.)',
         'Minimal drug interactions. Well-tolerated. Increasingly preferred over phenytoin.'],
        ['Phenobarbital',
         '20 mg/kg IV at ≤60 mg/min',
         '30-60 min (3rd line)',
         'Particularly useful in neonatal seizures. Causes significant sedation and respiratory depression.'],
        ['Propofol',
         '1-2 mg/kg IV induction\nThen 2-10 mg/kg/h infusion',
         'Refractory SE (ICU)',
         'For refractory SE requiring anaesthetic depth. Requires intubation/ventilatory support.\nPropofol infusion syndrome risk with prolonged high doses.'],
        ['Midazolam Infusion',
         '0.2 mg/kg IV bolus then 0.05-2 mg/kg/h',
         'Refractory SE (ICU)',
         'Preferred for refractory SE in many protocols. Titrate to EEG burst suppression.'],
    ],
    [3.5, 5.0, 3.0, 5.0]
)

# ══════════════════════════════════════════════════════════════
# SECTION 5 – HYPERTENSIVE EMERGENCY
# ══════════════════════════════════════════════════════════════
section_heading('5. Hypertensive Emergency', '1F3864')

body('Target: Reduce MAP by no more than 25% in the first hour, then to 160/100-110 over next 2-6h. Exceptions: aortic dissection (SBP <120 rapidly), ischaemic stroke (permissive hypertension).')

drug_table(
    ['Drug', 'Dose', 'Use Case', 'Notes'],
    [
        ['Labetalol', '20 mg IV over 2 min; then 40-80 mg q10 min (max 300 mg)\nOR infusion 0.5-2 mg/min', 'Most hypertensive emergencies, aortic dissection, hypertension in pregnancy (not 1st trim)', 'Alpha+beta blocker. Avoid in acute HF, bronchospasm, cocaine-induced HTN.'],
        ['Nicardipine', '5 mg/h IV infusion; titrate up to 15 mg/h', 'Hypertensive encephalopathy, perioperative HTN, stroke', 'Dihydropyridine Ca-channel blocker. Smooth, titratable. Safe in renal/hepatic disease.'],
        ['Nitroprusside', '0.3-0.5 mcg/kg/min IV; max 10 mcg/kg/min', 'Hypertensive emergency with HF (acute pulmonary oedema)', 'Arterio-venous dilator. Risk of cyanide toxicity at high doses/prolonged use. Avoid in renal failure.'],
        ['Nitroglycerin IV', '5-200 mcg/min IV infusion', 'ACS with hypertension, pulmonary oedema', 'Predominantly venodilator; less potent for BP than nitroprusside. Tolerance develops after 24h.'],
        ['Esmolol', '500 mcg/kg IV bolus over 1 min\nthen 50-200 mcg/kg/min infusion', 'Perioperative hypertension, aortic dissection', 'Ultra-short-acting selective β1-blocker. Half-life ~9 min. Rapidly titratable.'],
        ['Hydralazine', '10-20 mg IV (repeat q4-6h PRN)', 'Hypertension in pregnancy / eclampsia', 'Direct arteriolar vasodilator. Unpredictable duration; reflex tachycardia. IV onset 10-20 min.'],
        ['Phentolamine', '5-15 mg IV bolus; repeat PRN', 'Phaeochromocytoma crisis, cocaine/MAOI-induced HTN', 'Non-selective alpha blocker. Drug of choice for catecholamine excess.'],
        ['Magnesium Sulfate', '4-6 g IV over 15-20 min\nthen 1-2 g/h infusion', 'Eclampsia seizure prevention/treatment', 'Reduces neuromuscular excitability. Target Mg 4-7 mEq/L. Monitor for toxicity (loss of patellar reflex, respiratory depression).'],
    ],
    [3.5, 5.0, 3.5, 5.0]
)

# ══════════════════════════════════════════════════════════════
# SECTION 6 – REVERSAL AGENTS
# ══════════════════════════════════════════════════════════════
section_heading('6. Reversal Agents & Antidotes', 'C45911')

drug_table(
    ['Agent', 'Reverses', 'Dose', 'Notes'],
    [
        ['Naloxone (Narcan)',
         'Opioid toxicity (all mu-agonists)',
         '0.4-2 mg IV/IM/IN every 2-3 min\n(Low dose 0.04 mg in opioid-tolerant patients)',
         'Competitive opioid receptor antagonist. Short half-life (30-90 min) — re-dosing or infusion needed for long-acting opioids.\nAvoid precipitating acute withdrawal in dependent patients.'],
        ['Flumazenil (Annexate)',
         'Benzodiazepine toxicity',
         '0.2 mg IV over 30 sec; repeat 0.2 mg q60 sec\nMax 1 mg (or 3 mg in ICU setting)',
         'Competitive GABA-A receptor antagonist. Short half-life — resedation common.\nCONTRAINDICATED in benzodiazepine-dependent patients (risk of seizures) and in TCA co-ingestion.'],
        ['Sugammadex',
         'Rocuronium / Vecuronium (NMB)',
         'Routine reversal: 2 mg/kg\nDeep block: 4 mg/kg\nEmergency (can\'t intubate/ventilate): 16 mg/kg',
         'Encapsulates aminosteroid NMB agents. Rapid and complete reversal. Does not require anticholinesterase. Preferred over neostigmine for deep or immediate reversal.'],
        ['Neostigmine + Glycopyrrolate',
         'Non-depolarising NMB (residual block only)',
         'Neostigmine 0.04-0.07 mg/kg IV\n+ Glycopyrrolate 0.01 mg/kg IV',
         'Acetylcholinesterase inhibitor. Glycopyrrolate prevents muscarinic side-effects (bradycardia, bronchospasm). Not for deep block.'],
        ['Atropine',
         'Organophosphate / Nerve agent poisoning; Bradycardia',
         'Organophosphate: 2-4 mg IV q5-10 min until secretions dry\nBradycardia: 0.5 mg IV q3-5 min (max 3 mg)',
         'Muscarinic antagonist. In OP poisoning: titrate to dry secretions (not HR). Pralidoxime (2-PAM) given concurrently for OP to reactivate AChE.'],
        ['Protamine Sulfate',
         'Heparin (UFH > LMWH)',
         '1 mg per 100 units UFH (last 2-4h)\n(LMWH: 1 mg per 1 mg enoxaparin — 60-80% reversal only)',
         'Reversal occurs within 5 min. Risk of hypotension, bradycardia, anaphylaxis. Have epinephrine ready.'],
        ['Vitamin K (Phytomenadione)',
         'Warfarin / Vitamin K antagonists',
         'Non-urgent: 1-2.5 mg PO\nUrgent: 5-10 mg slow IV (anaphylaxis risk)\nImmediate: combine with FFP or 4F-PCC',
         'Onset slow (6-12h IV; 24h PO). Give with PCC/FFP for urgent reversal.'],
        ['Idarucizumab (Praxbind)',
         'Dabigatran',
         '5 g IV (2×2.5 g within 15 min)',
         'Monoclonal antibody fragment. Rapid, complete reversal of dabigatran. Used for life-threatening bleeding or urgent surgery.'],
        ['Andexanet Alfa (Ondexxya)',
         'Factor Xa inhibitors (rivaroxaban, apixaban, edoxaban)',
         'Rivaroxaban/Apixaban high-dose: 800 mg IV bolus then 960 mg over 2h\nLow-dose: 400 mg bolus then 480 mg over 2h',
         'Decoy Xa protein. Expensive; limited availability. 4F-PCC (50 units/kg) is a practical alternative.'],
        ['Dantrolene',
         'Malignant Hyperthermia',
         '2.5 mg/kg IV bolus; repeat every 5 min up to 10 mg/kg\nthen 1 mg/kg q6h × 24-48h',
         'Prevents Ca2+ release from sarcoplasmic reticulum. Stop all triggering agents (volatile anaesthetics, succinylcholine). Treat hyperkalemia, acidosis concurrently.\nMinimum 12 vials (each 20 mg) must be available wherever triggering agents are used.'],
        ['Lipid Emulsion (Intralipid 20%)',
         'Local anaesthetic systemic toxicity (LAST)',
         'Bolus: 1.5 mL/kg over 1 min\nthen 0.25 mL/kg/min for 30-60 min\n(Repeat bolus ×1-2 if cardiac arrest)',
         '"Lipid sink" — sequesters lipophilic LA from myocardium. Use for bupivacaine/levobupivacaine/ropivacaine toxicity. Continue CPR during administration.'],
        ['N-Acetylcysteine (NAC)',
         'Paracetamol (Acetaminophen) OD',
         'IV: 150 mg/kg over 60 min, then 50 mg/kg/4h, then 100 mg/kg/16h\nOral: 140 mg/kg loading, then 70 mg/kg q4h × 17 doses',
         'Replenishes glutathione; prevents NAPQI-induced hepatotoxicity.\nMost effective within 8-10h of ingestion. Can still benefit up to 24h+. Assess via Rumack-Matthew nomogram.'],
    ],
    [3.5, 4.0, 4.5, 5.5]
)

# ══════════════════════════════════════════════════════════════
# SECTION 7 – VASOPRESSORS & INOTROPES
# ══════════════════════════════════════════════════════════════
section_heading('7. Vasopressors & Inotropes', '1F3864')

drug_table(
    ['Drug', 'Dose Range', 'Primary Effect', 'Use Case', 'Notes'],
    [
        ['Norepinephrine\n(Noradrenaline)',
         '0.01-3 mcg/kg/min IV',
         'α1++ / β1+\n(predominantly vasoconstriction)',
         'Septic shock (1st line per SSC)',
         'MAP target ≥65 mmHg. First-line vasopressor in septic shock. Monitor for ischaemia of extremities.'],
        ['Epinephrine\n(Adrenaline)',
         '0.01-1 mcg/kg/min IV',
         'α1++ / β1++ / β2++',
         'Anaphylaxis, cardiogenic shock, post-cardiac surgery',
         'Low dose: β-predominant (↑CO). High dose: α-predominant (↑SVR). Causes hyperglycaemia and lactic acidosis.'],
        ['Dopamine',
         '2-20 mcg/kg/min IV',
         'Dose-dependent:\n<5: D1 (renal)\n5-10: β1\n>10: α1',
         '2nd line vasopressor; cardiogenic shock with bradycardia',
         '"Renal dose dopamine" for renal protection: NOT supported by evidence. Higher rates of arrhythmia vs norepinephrine.'],
        ['Vasopressin',
         '0.03-0.04 units/min IV (fixed dose)',
         'V1 receptor\n(vasoconstriction)',
         'Catecholamine-sparing in septic shock; post-cardiac surgery vasodilation',
         'Add-on to norepinephrine; allows norepinephrine dose reduction. VASST trial: benefit in less severe septic shock.'],
        ['Phenylephrine',
         '0.5-5 mcg/kg/min IV\n(or 50-200 mcg IV bolus)',
         'α1 only\n(pure vasoconstriction)',
         'Anaesthetic-induced hypotension; SVT with hypotension',
         'No direct cardiac effect. Can cause reflex bradycardia. Avoids tachycardia. Avoid in cardiogenic shock (↑afterload).'],
        ['Dobutamine',
         '2-20 mcg/kg/min IV',
         'β1++ / β2+\n(inotrope/vasodilator)',
         'Cardiogenic shock (with adequate MAP)',
         'Positive inotrope. Reduces afterload. Combine with norepinephrine if hypotensive. Tachycardia limits use.'],
        ['Milrinone',
         '0.375-0.75 mcg/kg/min IV\n(Loading: 50 mcg/kg optional)',
         'PDE3 inhibitor\n(inodilator)',
         'Cardiogenic shock, post-cardiac surgery low output, pulmonary hypertension',
         'Increases cAMP; positive inotropy + vasodilation. Does not require β-receptor. Caution in renal failure (renally cleared).'],
        ['Levosimendan',
         '0.05-0.2 mcg/kg/min IV ×24h\n(Loading: 6-12 mcg/kg optional)',
         'Ca2+ sensitiser + K-ATP channel opener\n(inodilator)',
         'Acute decompensated HF, cardiogenic shock',
         'Does not ↑ myocardial O2 demand. Sustained effect up to 1 week. Used in Europe/Asia; limited US approval.'],
    ],
    [3.0, 3.0, 3.0, 3.0, 5.5]
)

# ══════════════════════════════════════════════════════════════
# SECTION 8 – AIRWAY / RAPID SEQUENCE INTUBATION
# ══════════════════════════════════════════════════════════════
section_heading('8. Rapid Sequence Intubation (RSI) Drugs', 'C45911')

drug_table(
    ['Drug', 'Dose', 'Class', 'Notes'],
    [
        ['Succinylcholine\n(Suxamethonium)',
         '1.5 mg/kg IV (adults)\n2 mg/kg IV (children <10 kg)',
         'Depolarising NMB (1st choice RSI)',
         'Fastest onset (~60 sec), shortest duration (~10 min). CONTRAINDICATED: hyperkalemia, burn/crush >48h, upper motor neuron lesions, malignant hyperthermia history, myopathies. Check pseudo-cholinesterase deficiency risk.'],
        ['Rocuronium',
         'RSI: 1.2 mg/kg IV\nRoutine: 0.6 mg/kg IV',
         'Non-depolarising NMB (2nd choice RSI)',
         'Preferred when succinylcholine is contraindicated. RSI dose provides intubating conditions in 60-90 sec.\nReversal: Sugammadex 16 mg/kg for emergency. Longer duration than suxamethonium.'],
        ['Propofol',
         '1-2 mg/kg IV (titrate to effect)\n(Reduced in elderly/haemodynamically unstable: 0.5 mg/kg)',
         'IV Induction agent',
         'Rapid onset (<30 sec), pleasant induction. Causes hypotension (↓SVR, ↓CO). Have vasopressor ready. Also treats laryngospasm/bronchospasm (small doses 0.5 mg/kg).'],
        ['Ketamine',
         '1-2 mg/kg IV (or 4-6 mg/kg IM)',
         'Dissociative anaesthetic',
         'Preferred induction for haemodynamically unstable patients (catecholamine release). Maintains airway reflexes (partial). Bronchodilator. Use with benzodiazepine to reduce emergence phenomena. Avoid in severe hypertension/raised ICP.'],
        ['Etomidate',
         '0.3 mg/kg IV',
         'IV Induction agent',
         'Best haemodynamic stability. Preferred for trauma/haemodynamic instability where ketamine is contraindicated. Single dose adrenal suppression (avoid repeat dosing or infusion). Myoclonus common.'],
        ['Thiopental (Thiopentone)',
         '3-5 mg/kg IV\n(Reduced in elderly: 1-2 mg/kg)',
         'IV Induction agent (barbiturate)',
         'Historically first-line; now largely superseded by propofol. Still used where propofol unavailable. Reduces ICP — useful in neurosurgical emergencies.'],
        ['Fentanyl',
         '1-3 mcg/kg IV (pre-induction)\n"LOADS": 3 mcg/kg to blunt laryngoscopy',
         'Opioid (pre-treatment)',
         'Blunts sympathetic response to laryngoscopy (important in raised ICP, severe HTN). Onset 3-5 min. Causes chest wall rigidity at high doses.'],
        ['Midazolam',
         '0.01-0.05 mg/kg IV (sedation)\n0.1-0.15 mg/kg IV (induction)',
         'Benzodiazepine (sedation/co-induction)',
         'Reduces induction dose requirements. Anxiolytic. Used for procedural sedation (0.02-0.04 mg/kg). Longer recovery than propofol. Reversed by flumazenil.'],
        ['Lidocaine (pre-RSI)',
         '1.5 mg/kg IV 3 min before laryngoscopy',
         'Local anaesthetic (adjunct)',
         'Attenuates rise in ICP, laryngospasm reflex, and bronchospasm during intubation. Controversial evidence but widely used in neurological emergencies.'],
    ],
    [3.5, 3.5, 3.0, 7.0]
)

# ══════════════════════════════════════════════════════════════
# SECTION 9 – METABOLIC / OTHER EMERGENCIES
# ══════════════════════════════════════════════════════════════
section_heading('9. Metabolic & Other Emergencies', '1F3864')

drug_table(
    ['Drug', 'Indication', 'Dose', 'Notes'],
    [
        ['50% Dextrose (D50W)', 'Hypoglycaemia (<3 mmol/L with symptoms)', '25-50 mL (12.5-25 g) IV; repeat PRN', 'Rapid onset. Check BGL after 10-15 min. Follow with oral carbohydrates/dextrose infusion to prevent relapse.'],
        ['Glucagon', 'Hypoglycaemia (no IV access)', '1 mg IM/SC', 'Onset 8-10 min. Stimulates hepatic glycogenolysis. Ineffective if glycogen-depleted (starvation, alcohol-related). Also used in beta-blocker overdose (1-5 mg IV).'],
        ['Insulin (Regular)', 'Hyperglycaemia, DKA, HHS, Hyperkalemia', 'DKA: 0.1 units/kg/h IV infusion\nHyperkalemia: 10 units IV + 50 mL D50W\nHHS: 0.05 units/kg/h IV', 'For hyperkalemia: drives K+ intracellularly. Always give with dextrose to avoid hypoglycaemia.'],
        ['Calcium (IV)', 'Hyperkalemia, Hypocalcemia, Ca-channel blocker OD', 'CaCl2 10%: 1 g (10 mL) IV over 10 min\nCalcium gluconate 10%: 10-30 mL IV over 10 min', 'Stabilises cardiac membrane potential. CaCl2 provides more elemental Ca2+ (3x) but is more irritating to veins (prefer central line).'],
        ['Sodium Bicarbonate', 'Severe metabolic acidosis (pH <7.1), Hyperkalemia, TCA OD', '1-2 mEq/kg IV bolus, guided by ABG', 'For TCA: alkalinises serum; reduces Na-channel blockade. For hyperkalemia: temporary transcellular shift. Do not over-alkalinise: left-shifts O2-Hb curve.'],
        ['Potassium Chloride (IV)', 'Severe hypokalaemia (<2.5 mEq/L, with ECG changes)', 'Peripheral: ≤10 mEq/h (max 20 mEq/h central)\nConcentration: ≤40 mEq/L peripheral', 'NEVER IV bolus undiluted — causes cardiac arrest. Replace with continuous ECG monitoring. Oral route always preferred if possible.'],
        ['Thiamine (Vitamin B1)', 'Suspected Wernicke\'s encephalopathy, alcohol-related emergency', '100-500 mg IV (give BEFORE dextrose)', 'Prevents precipitation of acute Wernicke\'s. Classic triad: confusion, ataxia, ophthalmoplegia. Give empirically in any malnourished/alcohol-use patient requiring glucose.'],
        ['Activated Charcoal', 'Oral drug/poison ingestion (within 1-2h)', '50 g PO / via NG tube (adults)\n1 g/kg (children)', 'Most effective within 1h of ingestion. CONTRAINDICATED in: unconscious patient without protected airway, caustic ingestion, hydrocarbon ingestion, intestinal obstruction.'],
        ['Sodium Nitrite + Sodium Thiosulfate', 'Cyanide poisoning', 'Na Nitrite: 300 mg (10 mL of 3%) IV over 5-10 min\nNa Thiosulfate: 12.5 g (50 mL of 25%) IV over 10 min', 'Nitrite induces methaemoglobinaemia (cyanide binds preferentially to metHb). Thiosulfate converts cyanothiosulfate to thiocyanate. Hydroxocobalamin (5 g IV) is preferred modern alternative.'],
        ['Hydroxocobalamin (Cyanokit)', 'Cyanide poisoning', '5 g IV over 15 min (repeat ×1-2 for severe poisoning)', 'Binds cyanide directly to form cyanocobalamin. Preferred over nitrite/thiosulfate (no methaemoglobinaemia). Turns skin/urine red-brown.'],
    ],
    [3.5, 3.5, 4.0, 6.5]
)

# ══════════════════════════════════════════════════════════════
# SECTION 10 – RAPID REFERENCE: KEY DOSES AT A GLANCE
# ══════════════════════════════════════════════════════════════
doc.add_page_break()
section_heading('10. Rapid Reference — Key Doses At A Glance', '1F3864')

drug_table(
    ['Situation', 'Drug of Choice', 'Quick Dose'],
    [
        ['Cardiac arrest (any rhythm)', 'Epinephrine', '1 mg IV/IO q3-5 min'],
        ['VF / pulseless VT (refractory)', 'Amiodarone', '300 mg IV/IO bolus'],
        ['Torsades de Pointes', 'Magnesium Sulfate', '2 g IV over 5-20 min'],
        ['Symptomatic bradycardia', 'Atropine', '0.5 mg IV (max 3 mg)'],
        ['SVT (stable)', 'Adenosine', '6 mg rapid IV; 12 mg ×2 if needed'],
        ['Anaphylaxis', 'Epinephrine IM', '0.3 mg IM (anterolateral thigh)'],
        ['Seizure (1st line IV)', 'Lorazepam', '0.1 mg/kg IV (max 4 mg)'],
        ['Seizure (no IV access)', 'Midazolam IM', '10 mg IM'],
        ['Opioid overdose', 'Naloxone', '0.4-2 mg IV/IM/IN'],
        ['Benzodiazepine overdose', 'Flumazenil', '0.2 mg IV q60s to max 1 mg'],
        ['Rocuronium reversal (emergency)', 'Sugammadex', '16 mg/kg IV'],
        ['Malignant hyperthermia', 'Dantrolene', '2.5 mg/kg IV bolus (repeat to 10 mg/kg)'],
        ['Local anaesthetic toxicity', 'Intralipid 20%', '1.5 mL/kg IV bolus; then 0.25 mL/kg/min'],
        ['Paracetamol overdose', 'N-Acetylcysteine', '150 mg/kg IV over 1h (then infusions)'],
        ['Septic shock (vasopressor)', 'Norepinephrine', '0.01-3 mcg/kg/min IV (MAP ≥65)'],
        ['Hypertensive emergency', 'Labetalol / Nicardipine', '20 mg IV; or 5 mg/h infusion (nicardipine)'],
        ['Eclampsia', 'Magnesium Sulfate', '4-6 g IV over 15 min, then 1-2 g/h'],
        ['Cyanide poisoning', 'Hydroxocobalamin', '5 g IV over 15 min'],
        ['Hypoglycaemia (no IV)', 'Glucagon', '1 mg IM/SC'],
        ['Hyperkalemia (cardiac)', 'Calcium Chloride', '1 g (10 mL 10%) IV over 10 min'],
    ],
    [6.0, 5.0, 6.5]
)

# ── Footer note ───────────────────────────────────────────────
doc.add_paragraph()
footer_p = doc.add_paragraph()
footer_p.alignment = WD_ALIGN_PARAGRAPH.CENTER
fr = footer_p.add_run(
    'DISCLAIMER: This document is a clinical quick-reference compiled from authoritative medical textbooks. '
    'Always verify doses against current local guidelines, product information, and patient-specific factors. '
    'Not a substitute for clinical judgement.'
)
fr.italic = True
fr.font.size = Pt(8)
fr.font.color.rgb = RGBColor(0x88, 0x88, 0x88)

# ── Save ──────────────────────────────────────────────────────
out_path = '/tmp/workspace/emergency-drugs/Emergency_Drugs_Reference.docx'
doc.save(out_path)
print(f'Saved: {out_path}')
Running Command

cd /tmp/workspace/emergency-drugs && python build_emergency_drugs.py 2>&1

Running Command

python3 -c " from docx import Document doc = Document('/tmp/workspace/emergency-drugs/Emergency_Drugs_Reference.docx') headings = [p.text for p in doc.paragraphs if p.style.name.startswith('Heading') or p.text.strip().startswith('1.') or p.text.strip().startswith('2.') or p.text.strip().startswith('3.') or p.text.strip().startswith('4.') or p.text.strip().startswith('5.') or p.text.strip().startswith('6.') or p.text.strip().startswith('7.') or p.text.strip().startswith('8.') or p.text.strip().startswith('9.') or p.text.strip().startswith('10.')] for h in headings[:15]: print(h[:80]) print('---') print('Total paragraphs:', len(doc.paragraphs)) print('Total tables:', len(doc.tables)) import os; print('File size:', os.path.getsize('/tmp/workspace/emergency-drugs/Emergency_Drugs_Reference.docx'), 'bytes') "

Your emergency drugs reference document is ready:

Emergency Drugs Reference

Word Document · DOCX


Here is what's inside - 10 color-coded sections, 10 drug tables, 80+ drugs with doses, mechanisms, and clinical notes:
#SectionKey Drugs
1Cardiac Arrest / ACLSEpinephrine, Amiodarone, Lidocaine, Atropine, Magnesium, Adenosine, Bicarbonate, Calcium
2STEMI / ACSAspirin, Clopidogrel, Ticagrelor, Prasugrel, UFH, Enoxaparin, Alteplase, Tenecteplase, Nitroglycerin, Morphine
3AnaphylaxisEpinephrine (IM), IV Fluids, Diphenhydramine, H2 blockers, Hydrocortisone, Salbutamol, Glucagon
4Seizures / Status EpilepticusLorazepam, Midazolam, Diazepam, Phenytoin, Valproate, Levetiracetam, Phenobarbital, Propofol
5Hypertensive EmergencyLabetalol, Nicardipine, Nitroprusside, Nitroglycerin, Esmolol, Hydralazine, Phentolamine, Magnesium
6Reversal Agents & AntidotesNaloxone, Flumazenil, Sugammadex, Dantrolene, Intralipid, NAC, Protamine, Idarucizumab, Andexanet
7Vasopressors & InotropesNorepinephrine, Epinephrine, Dopamine, Vasopressin, Phenylephrine, Dobutamine, Milrinone, Levosimendan
8RSI DrugsSuccinylcholine, Rocuronium, Propofol, Ketamine, Etomidate, Thiopental, Fentanyl, Midazolam, Lidocaine
9Metabolic EmergenciesDextrose 50%, Glucagon, Insulin, KCl, Thiamine, Activated Charcoal, Hydroxocobalamin, NAC
10Rapid Reference TableTop 20 emergency situations with drug + dose at a glance
Sources: Miller's Anesthesia 10e, Tintinalli's Emergency Medicine, Barash Clinical Anesthesia 9e, Goodman & Gilman's Pharmacology, Washington Manual of Medical Therapeutics.
This is a shared conversation. Sign in to Orris to start your own chat.