Make a list of emergency situations that is for preparation for NCLEX and NORCET AIIMS exam, what we do 1st and second or procedure or treatment based on medical and nursing terminologies all about

Reading File
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
I now have rich source material. Let me compile the comprehensive emergency situations guide from my medical knowledge supplemented by the textbook content.

🚨 Emergency Situations — NCLEX & NORCET AIIMS Preparation Guide

Priority Management Using Medical & Nursing Terminology

🔑 UNIVERSAL PRIORITY FRAMEWORK

For ALL emergencies, always apply ABC → D → E first:
  1. A — Airway (establish/maintain patency)
  2. B — Breathing (assess rate, depth, SpO₂)
  3. C — Circulation (HR, BP, skin perfusion, IV access)
  4. D — Disability (GCS, pupils, neurological status)
  5. E — Exposure (full body examination, vital signs)
Then apply SBAR for communication: Situation → Background → Assessment → Recommendation

1. 🫀 CARDIAC ARREST (Cardiopulmonary Arrest)

StepActionTerminology
1stConfirm unresponsiveness; call for help / activate code blueCode Blue activation
2ndCheck carotid pulse (≤10 sec); if absent → start CPRCardiac arrest protocol
3rdBegin chest compressions: 30:2 ratio, 100–120/min, depth 5–6 cm, hard & fastHigh-quality CPR
4thAttach defibrillator; analyze rhythm — shockable (VF/pulseless VT) → shock 200J biphasicDefibrillation
5thResume CPR immediately post-shock (2 min cycle); establish IV/IO accessPost-resuscitation
6thEpinephrine 1 mg IV/IO every 3–5 min; amiodarone 300 mg IV for VF/VTVasopressor/antiarrhythmic
7thIdentify and treat reversible causes (4H 4T)H's & T's
8thPost-ROSC: 12-lead ECG, targeted temperature management (TTM) 32–36°CReturn of Spontaneous Circulation
4H's: Hypoxia, Hypovolemia, Hypo/Hyperkalemia, Hypothermia 4T's: Tension pneumothorax, Tamponade (cardiac), Toxins, Thrombosis (PE/MI)
Nursing Priority: Do NOT delay first compression for IV/airway. Minimize interruptions (<10 sec).

2. 😮‍💨 RESPIRATORY DISTRESS / ARREST

StepAction
1stPosition: sit upright (high Fowler's/orthopneic position); O₂ via face mask at 10–15 L/min
2ndAssess SpO₂, RR, breath sounds (auscultation); apply pulse oximetry
3rdIf apneic → jaw thrust/chin lift; bag-valve-mask (BVM) ventilation
4thPrepare for endotracheal intubation (ETT); RSI (Rapid Sequence Intubation) if needed
5thConfirm ETT placement: ETCO₂ capnography, bilateral breath sounds, CXR
6thMechanical ventilation: set FiO₂, PEEP, tidal volume (6–8 mL/kg IBW)
Bronchospasm (Asthma Attack):
  • 1st: Salbutamol (albuterol) 2.5–5 mg nebulization + ipratropium
  • 2nd: IV/oral corticosteroids (prednisolone/methylprednisolone)
  • 3rd: IV magnesium sulfate 2g over 20 min (severe case)
  • Monitor: PEFR, SpO₂, accessory muscle use

3. 🩸 SHOCK — Types & Management

A. Hypovolemic Shock (Hemorrhagic/Fluid Loss)

StepAction
1stControl active bleeding (direct pressure, tourniquet)
2ndTwo large-bore IVs (16–18G); rapid IV fluid bolus: Lactated Ringer's / NS 1–2L
3rdBlood typing & cross-matching; transfuse PRBCs if Hgb <7 g/dL or ongoing hemorrhage
4thBalanced transfusion: pRBCs : FFP : Platelets = 1:1:1 ratio
5thMonitor: urine output (target >0.5 mL/kg/hr), BP, HR, lactate, base deficit
6thTreat underlying cause (surgery, endoscopy)
Grading: Class I (<15% blood loss) → Class IV (>40% blood loss, life-threatening)
Key Lab: Serum lactate >4 mmol/L or base deficit < −4 mEq/L = shock marker

B. Septic Shock (Distributive)

StepAction
1stObtain blood cultures × 2 (before antibiotics); lactate level
2ndBroad-spectrum IV antibiotics within 1 hour (e.g., piperacillin-tazobactam + vancomycin)
3rdIV fluid resuscitation: crystalloid 30 mL/kg within 3 hours
4thVasopressor if MAP <65 mmHg despite fluids: Norepinephrine (1st line)
5thHydrocortisone 200 mg/day IV if vasopressor-refractory
6thSource control: drain abscess, remove infected catheter
Surviving Sepsis Bundle (1-hour bundle): Measure lactate → blood cultures → antibiotics → IV fluids → vasopressors for MAP <65 mmHg

C. Anaphylactic Shock

StepAction
1stEpinephrine (Adrenaline) 0.3–0.5 mg IM (anterolateral thigh) — FIRST LINE
2ndPosition: supine with legs elevated (Trendelenburg)
3rdO₂ high flow; IV access; fluid resuscitation NS bolus
4thRepeat epinephrine every 5–15 min if needed
5thDiphenhydramine (antihistamine H1) IV/IM; ranitidine (H2 blocker)
6thIV corticosteroids: methylprednisolone 125 mg IV
7thNebulized salbutamol for bronchospasm; monitor for biphasic reaction (4–12 hrs)
Nursing Key: Epinephrine MUST be given first — not antihistamine!

D. Cardiogenic Shock

StepAction
1stO₂, monitor, IV access; 12-lead ECG for MI
2ndDobutamine (inotrope) IV; dopamine if severe hypotension
3rdCautious IV fluids (avoid fluid overload)
4thUrgent PCI (percutaneous coronary intervention) if AMI-related
5thIABP (Intra-Aortic Balloon Pump) / mechanical circulatory support

4. 🧠 STROKE (CVA — Cerebrovascular Accident)

Time is Brain — "FAST": Face drooping, Arm weakness, Speech difficulty, Time to call
StepAction
1stActivate stroke team; note exact time of symptom onset
2ndABC stabilization; O₂ if SpO₂ <94%; IV access; NPO
3rdSTAT non-contrast CT brain (rule out hemorrhagic stroke)
4thBlood glucose check (hypoglycemia mimics stroke)
5thIschemic stroke within 4.5 hours: IV tPA (alteplase) 0.9 mg/kg (max 90 mg)
6thLarge vessel occlusion within 24 hours: mechanical thrombectomy
7thBP management: in ischemic stroke, allow permissive hypertension <220/120 mmHg (pre-tPA); keep <180/105 mmHg post-tPA
8thAspirin 325 mg (after hemorrhage excluded); statin therapy
Nursing: Position HOB at 30°; monitor for dysphagia (swallow screen before oral intake); neuro checks q1h
Hemorrhagic Stroke:
  • Reverse anticoagulation if on warfarin (Vitamin K + FFP or PCC)
  • Neurosurgical consult
  • BP target: systolic <140 mmHg with IV labetalol/nicardipine

5. 💉 MYOCARDIAL INFARCTION (STEMI/NSTEMI)

MONA (Classic Nursing Mnemonic — now modified):
StepDrug/ActionNote
1st12-lead ECG within 10 min of arrivalST elevation ≥1mm in ≥2 contiguous leads = STEMI
2ndAspirin 325 mg (chewed) + P2Y12 inhibitor (clopidogrel/ticagrelor)Dual antiplatelet
3rdNitroglycerin SL 0.4 mg q5min × 3 (if BP >90 systolic, no RV infarct)Vasodilator
4thMorphine 2–4 mg IV (only if pain refractory, no longer 1st-line)Opioid analgesia
5thO₂ only if SpO₂ <90%Avoid hyperoxia
6thIV heparin (unfractionated) or enoxaparinAnticoagulation
7thPrimary PCI within 90 min (door-to-balloon) — preferred reperfusionCatheterization lab
8thIf PCI unavailable: IV fibrinolysis (streptokinase/tPA) within 30 minThrombolysis
Nursing Priority: Continuous cardiac monitoring; defibrillator ready; restrict activity; NPO for procedure

6. 🫁 PULMONARY EMBOLISM (PE)

StepAction
1stO₂ high flow; IV access; monitor SpO₂, BP, HR
2nd12-lead ECG (classic: S1Q3T3); D-dimer; ABG
3rdCT pulmonary angiography (CTPA) — gold standard imaging
4thAnticoagulation: IV unfractionated heparin bolus 80 U/kg, then 18 U/kg/hr
5thMassive PE (hemodynamic instability): thrombolysis with tPA 100 mg IV over 2 hrs
6thSurgical embolectomy if thrombolysis contraindicated
Wells Score used to assess pre-test probability

7. 🔋 DIABETIC EMERGENCIES

A. Diabetic Ketoacidosis (DKA)

StepAction
1stIV NS 1L/hr for first 1–2 hours (aggressive fluid resuscitation)
2ndIV regular insulin: 0.1 U/kg/hr (after K⁺ ≥3.5 mEq/L confirmed)
3rdPotassium replacement: 20–40 mEq/hr if K⁺ <5.5 mEq/L
4thMonitor glucose hourly; switch to D5 when glucose <200 mg/dL
5thMonitor ABG (pH, bicarbonate), urine output, electrolytes q2–4h
DKA criteria: Glucose >250 mg/dL + pH <7.3 + bicarbonate <18 mEq/L + ketonemia/ketonuria

B. Hypoglycemia (BGL <70 mg/dL)

StepAction
1stConscious patient: Rule of 15 — 15g fast-acting carbs, recheck in 15 min
2ndUnconscious/unable to swallow: Dextrose 25–50g (50% dextrose) IV bolus
3rdIf no IV access: Glucagon 1 mg IM/SC
4thIdentify and treat underlying cause; monitor BGL q15–30 min

8. ⚡ STATUS EPILEPTICUS

StepAction
1stProtect from injury; lateral position; time the seizure
2ndO₂ via face mask; suction if secretions (do NOT insert objects in mouth)
3rdIV access; blood glucose, electrolytes, drug levels
4thBenzodiazepine (0–5 min): Lorazepam 0.1 mg/kg IV (or diazepam 0.2 mg/kg IV/rectal)
5th2nd line (5–20 min): Levetiracetam 60 mg/kg IV OR phenytoin/fosphenytoin 20 mg/kg IV
6thRefractory (>30 min): Propofol/midazolam/barbiturate infusion; ICU admission + EEG monitoring
7thCheck: Thiamine 100 mg IV before glucose (in alcoholic patients — prevents Wernicke's)
Nursing: Seizure precautions: padded side rails, O₂ at bedside, suction ready, NPO

9. 🧊 INCREASED INTRACRANIAL PRESSURE (ICP)

StepAction
1stHOB elevated 30° (neutral head position — avoid jugular compression)
2ndO₂ to maintain SpO₂ >95%; avoid hypercarbia (PaCO₂ 35–40 mmHg)
3rdMannitol 0.25–1 g/kg IV (osmotic diuretic — 1st line)
4th3% hypertonic saline (alternative to mannitol)
5thHyperventilation (PCO₂ 30–35 mmHg) — temporary bridge only
6thNeurosurgical consultation; ICP monitoring; decompressive craniectomy if refractory
Cushing's Triad (late sign of herniation): Hypertension + Bradycardia + Irregular respirations

10. 🔥 BURNS

StepAction
1stStop the burning process; remove clothing/jewelry
2ndAirway assessment — inhalation injury: hoarseness, singed nasal hairs, stridor → early intubation
3rdCalculate TBSA (Rule of Nines); calculate fluid requirements
4thParkland Formula: 4 mL × weight (kg) × %TBSA (Lactated Ringer's) — ½ in first 8 hrs, ½ in next 16 hrs
5thTetanus prophylaxis; wound care; pain management (IV morphine)
6thTransfer to burn unit for burns >10% TBSA, face, hands, genitalia, circumferential burns
Rule of Nines: Head 9%, each arm 9%, chest 9%, abdomen 9%, each thigh 9%, each leg 9%, perineum 1%

11. 🤰 OBSTETRIC EMERGENCIES

A. Eclampsia

StepAction
1stProtect airway; left lateral decubitus (uterine displacement)
2ndMagnesium sulfate 4–6 g IV loading dose, then 1–2 g/hr maintenance
3rdAntihypertensive: hydralazine 5–10 mg IV or labetalol 20 mg IV (target BP <160/110)
4thFetal monitoring; plan for delivery
5thMonitor Mg toxicity: check reflexes (lost first), urine output, respiratory rate (keep calcium gluconate at bedside as antidote)

B. Postpartum Hemorrhage (PPH)

StepAction
1stBimanual uterine massage; assess for cause (4T's: Tone, Tissue, Trauma, Thrombin)
2ndOxytocin 20–40 units in 1L NS IV — 1st line uterotonic
3rdMisoprostol 800–1000 mcg rectal/sublingual
4thTranexamic acid 1g IV within 3 hours of delivery
5thBlood transfusion, surgical intervention (B-Lynch suture, hysterectomy)

12. ☠️ POISONING / OVERDOSE

Poison1st ActionAntidote
Opioid overdoseAirway supportNaloxone (Narcan) 0.4–2 mg IV/IM/IN
OrganophosphateAtropine IVAtropine + Pralidoxime (2-PAM)
Acetaminophen (paracetamol)Activated charcoal (if <1hr)N-Acetylcysteine (NAC) IV/oral
BenzodiazepineSupportiveFlumazenil 0.2 mg IV
WarfarinINR, CBCVitamin K IV + FFP/PCC
CyanideO₂ 100%Hydroxocobalamin (Cyanokit)
CO poisoningRemove from exposure100% O₂ (hyperbaric if severe)
Iron overdoseSupportiveDeferoxamine
Digoxin toxicityCardiac monitoringDigoxin-specific Fab fragments
Beta-blocker overdoseIV fluids, atropineGlucagon IV
TCA overdoseABCSodium bicarbonate IV
Universal approach: ABCDE → activated charcoal (if <1hr, alert, no caustic) → specific antidote → supportive care

13. 🌡️ HEAT STROKE / HYPOTHERMIA

Heat Stroke (core temp >40°C + CNS dysfunction)

StepAction
1stRemove from heat; ABC
2ndRapid cooling — target 39°C within 30 min: ice water immersion OR evaporative cooling + fans
3rdIV cold NS; do NOT give antipyretics (not effective in heat stroke)
4thMonitor rhabdomyolysis (CK, urine myoglobin), renal function

Hypothermia (core temp <35°C)

StepAction
1stRemove wet clothing; prevent further heat loss
2ndGentle warming: passive rewarming (mild) → active external (moderate) → active internal/ECMO (severe <30°C)
3rdWarm IV fluids (39–42°C); warmed humidified O₂
4thMonitor for J-waves (Osborn waves) on ECG; VF risk
Mantra"Not dead until warm and dead" — continue resuscitation until core temp >32°C

14. 🩺 HYPERTENSIVE EMERGENCY

(BP >180/120 mmHg with end-organ damage)
StepAction
1stIV access; continuous BP monitoring (arterial line preferred)
2ndTarget: reduce MAP by ≤25% in first hour (NOT to normal — risk of ischemia)
3rdIV antihypertensives: Nicardipine, Labetalol, Clevidipine, or Nitroprusside
4thAortic dissection → Esmolol + nitroprusside; target SBP <120 mmHg urgently
5thEclampsia → Magnesium sulfate + labetalol/hydralazine
End-organ damage: Hypertensive encephalopathy, stroke, AMI, acute heart failure, renal failure, aortic dissection, retinopathy

15. 🫀 ACUTE PULMONARY EDEMA (Cardiogenic)

StepAction
1stSit upright (high Fowler's 90°); O₂ via NRB mask or BiPAP/CPAP
2ndIV furosemide 40–80 mg (diuretic — 1st line)
3rdIV nitroglycerin infusion (vasodilation — reduces preload)
4thMorphine 2–4 mg IV (reduce anxiety/preload — use cautiously)
5thIdentify cause: STEMI → PCI; HTN → antihypertensives; arrhythmia → cardioversion
LMNOP Mnemonic: Lasix, Morphine, Nitrates, O₂, Position

16. 🌊 DROWNING / NEAR-DROWNING

StepAction
1stSafely remove from water; do NOT delay CPR for water drainage
2ndBegin CPR (5 rescue breaths first if no breathing, then 30:2)
3rdRemove wet clothes; prevent hypothermia (warm blankets)
4thO₂ high flow; prepare for intubation (lung injury)
5thMonitor for secondary drowning (up to 24 hrs); admit for observation

17. ⚡ SPINAL CORD INJURY

StepAction
1stImmobilize spine immediately (cervical collar, log-roll technique)
2ndAirway: jaw thrust ONLY (no head-tilt in cervical injury)
3rdNeurogenic shock (vasodilation + bradycardia): IV fluids + vasopressors + atropine
4thMRI spine; neurosurgical consultation
5thHigh-dose methylprednisolone (controversial; used within 8 hrs)
6thFoley catheter (urinary retention); pressure ulcer prevention

18. 🩹 TRAUMA (Polytrauma — Primary Survey)

Using ATLS Protocol:
SurveyAssessmentPriority Actions
A — AirwayObstruction, stridor, consciousnessJaw thrust, suction, intubation
B — BreathingTension pneumothorax, open chest woundNeedle decompression (2nd ICS MCL), chest seal
C — CirculationHemorrhage, BP, HRPressure, IV fluids, blood products
D — DisabilityGCS, pupils, spinalC-spine immobilization
E — ExposureWounds, fracturesLog roll, prevent hypothermia
Tension Pneumothorax: Absent breath sounds + tracheal deviation + hypotension → immediate needle decompression (2nd intercostal space, midclavicular line) — do NOT wait for X-ray

🏥 NURSING-SPECIFIC PRIORITY RULES (NCLEX/NORCET)

RulePrinciple
Maslow's HierarchyPhysiological needs first (airway > breathing > circulation)
ABC PriorityAirway always first unless DO NOT RESUSCITATE order
SafetySeizure precautions, fall precautions, infection control
Assessments FirstAssess before intervening (exception: cardiac arrest — act immediately)
DelegationRN: Assessment, teaching, unstable patients; LPN/LVN: stable, routine care; UAP: bathing, vitals (stable)
When in doubt, prioritize:Acute over chronic; unstable over stable; life-threatening over comfort

📊 QUICK REFERENCE: KEY ANTIDOTES

Drug/ToxinAntidote
HeparinProtamine sulfate
Warfarin/CoumadinVitamin K + FFP/PCC
OpioidsNaloxone (Narcan)
BenzodiazepinesFlumazenil
AcetaminophenN-Acetylcysteine
DigoxinDigoxin-specific Fab
OrganophosphatesAtropine + Pralidoxime
Beta-blockersGlucagon
Calcium channel blockersCalcium gluconate + glucagon
IronDeferoxamine
CyanideHydroxocobalamin
CO100% O₂ / Hyperbaric O₂
TCA overdoseSodium bicarbonate
Methanol/Ethylene glycolFomepizole (4-MP)
Magnesium toxicityCalcium gluconate

📝 EXAM-FOCUSED MNEMONICS

MnemonicMeaning
FASTFace, Arm, Speech, Time (stroke)
MONAMorphine, O₂, Nitroglycerin, Aspirin (MI — modified)
4H 4TReversible causes of cardiac arrest
LMNOPLasix, Morphine, Nitrates, O₂, Position (pulmonary edema)
RICERest, Ice, Compression, Elevation (musculoskeletal)
ABCDEAirway, Breathing, Circulation, Disability, Exposure
SBARSituation, Background, Assessment, Recommendation
Rule of NinesBurns TBSA estimation
Parkland Formula4 × kg × %TBSA = fluid for burns
SAMPLESigns/Symptoms, Allergies, Medications, Past history, Last oral intake, Events (history taking)

🔺 TOP HIGH-YIELD NCLEX/NORCET POINTS

  1. Epinephrine is ALWAYS 1st in anaphylaxis — not antihistamine
  2. tPA contraindicated in hemorrhagic stroke; give only after CT rules out bleed
  3. No aspirin in children <18 (Reye's syndrome risk)
  4. Succinylcholine used for RSI but contraindicated in burn patients >24–48 hrs (hyperkalemia risk)
  5. Position in shock: supine with legs elevated (except cardiogenic/pulmonary edema — sit up)
  6. Potassium must be ≥3.5 before starting insulin in DKA
  7. Thiamine BEFORE glucose in alcoholic patients (prevent Wernicke's encephalopathy)
  8. Never do LP before CT if ICP suspected (herniation risk)
  9. CPR ratio: 30:2 adults; 30:2 one-rescuer child; 15:2 two-rescuer child
  10. Magnesium antidote = Calcium gluconate (keep at bedside during mag infusion)
  11. Urine output target in shock: >0.5 mL/kg/hr; in burns: 0.5–1.0 mL/kg/hr
  12. Primary PCI within 90 minutes (door-to-balloon) for STEMI
  13. Oxygen NOT given in suspected COPD if SpO₂ >88–92% (hypercapnic drive)
  14. Trendelenburg is NOT recommended in most shock (evidence-based update)
  15. Jaw thrust (not head-tilt-chin-lift) in suspected cervical spine injury

Sources: ROSEN's Emergency Medicine (9780323757898), Sabiston Textbook of Surgery, Goldman-Cecil Medicine, Miller's Anesthesia — Medical Library; current ACLS/ATLS/Sepsis Surviving guidelines

Create a quick-reference PDF cheat sheet with these 18 emergencies

Reading File
Running Command

ls -la /home/daytona/workspace/ 2>/dev/null || echo "workspace not found"

Running Command

mkdir -p /home/daytona/workspace/emergency-cheatsheet && python3 -c "from report…

Writing File

~/emergency-cheatsheet/build_pdf.py

#!/usr/bin/env python3
"""
Emergency Quick-Reference Cheat Sheet PDF
NCLEX & NORCET AIIMS Exam Preparation
"""

from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import mm, cm
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, KeepTogether, PageBreak
)
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus import BaseDocTemplate, Frame, PageTemplate

OUTPUT = "/home/daytona/workspace/emergency-cheatsheet/Emergency_CheatSheet_NCLEX_NORCET.pdf"

# ─── Colour Palette ────────────────────────────────────────────────────────────
C_RED       = colors.HexColor("#C0392B")
C_DARK_RED  = colors.HexColor("#922B21")
C_ORANGE    = colors.HexColor("#E67E22")
C_BLUE      = colors.HexColor("#1A5276")
C_TEAL      = colors.HexColor("#117A65")
C_PURPLE    = colors.HexColor("#6C3483")
C_DARK_GRAY = colors.HexColor("#2C3E50")
C_MID_GRAY  = colors.HexColor("#5D6D7E")
C_LIGHT_BG  = colors.HexColor("#EBF5FB")
C_HEADER_BG = colors.HexColor("#1A5276")
C_ROW1      = colors.HexColor("#D6EAF8")
C_ROW2      = colors.HexColor("#EBF5FB")
C_GREEN     = colors.HexColor("#1E8449")
C_YELLOW_BG = colors.HexColor("#FEF9E7")
C_RED_BG    = colors.HexColor("#FDEDEC")
C_WHITE     = colors.white
C_BLACK     = colors.black
C_AMBER     = colors.HexColor("#F39C12")

# ─── Styles ────────────────────────────────────────────────────────────────────
styles = getSampleStyleSheet()

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

COVER_TITLE = S("CoverTitle",
    fontName="Helvetica-Bold", fontSize=26, textColor=C_WHITE,
    alignment=TA_CENTER, spaceAfter=6, leading=32)

COVER_SUB = S("CoverSub",
    fontName="Helvetica", fontSize=13, textColor=colors.HexColor("#AED6F1"),
    alignment=TA_CENTER, spaceAfter=4, leading=18)

COVER_NOTE = S("CoverNote",
    fontName="Helvetica-Oblique", fontSize=10, textColor=colors.HexColor("#D6EAF8"),
    alignment=TA_CENTER, spaceAfter=2)

SEC_HEADING = S("SecHeading",
    fontName="Helvetica-Bold", fontSize=11, textColor=C_WHITE,
    alignment=TA_LEFT, spaceBefore=4, spaceAfter=2, leading=14,
    leftIndent=4)

BODY = S("Body",
    fontName="Helvetica", fontSize=8.5, textColor=C_DARK_GRAY,
    spaceAfter=2, leading=12, alignment=TA_LEFT)

BODY_BOLD = S("BodyBold",
    fontName="Helvetica-Bold", fontSize=8.5, textColor=C_DARK_GRAY,
    spaceAfter=2, leading=12)

SMALL = S("Small",
    fontName="Helvetica", fontSize=7.5, textColor=C_MID_GRAY,
    spaceAfter=1, leading=10)

NOTE_STYLE = S("Note",
    fontName="Helvetica-Oblique", fontSize=8, textColor=C_TEAL,
    spaceAfter=3, leading=11, leftIndent=6)

MNEM_STYLE = S("Mnem",
    fontName="Helvetica-Bold", fontSize=8.5, textColor=C_PURPLE,
    spaceAfter=2, leading=12, leftIndent=6)

FOOTER_STYLE = S("Footer",
    fontName="Helvetica", fontSize=7, textColor=C_MID_GRAY,
    alignment=TA_CENTER)

TABLE_HEADER = S("TblHdr",
    fontName="Helvetica-Bold", fontSize=8, textColor=C_WHITE,
    alignment=TA_CENTER, leading=10)

TABLE_CELL = S("TblCell",
    fontName="Helvetica", fontSize=8, textColor=C_DARK_GRAY,
    leading=10, alignment=TA_LEFT)

TABLE_CELL_BOLD = S("TblCellBold",
    fontName="Helvetica-Bold", fontSize=8, textColor=C_DARK_RED,
    leading=10, alignment=TA_LEFT)

PAGE_W, PAGE_H = A4
MARGIN = 1.4 * cm
USABLE_W = PAGE_W - 2 * MARGIN

# ─── Helpers ──────────────────────────────────────────────────────────────────
def section_header(title, color=C_HEADER_BG, icon=""):
    """Coloured banner heading."""
    t = Table([[Paragraph(f"{icon}  {title}", SEC_HEADING)]],
              colWidths=[USABLE_W])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), color),
        ("TOPPADDING",    (0,0), (-1,-1), 5),
        ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING",   (0,0), (-1,-1), 8),
        ("ROUNDEDCORNERS", [4, 4, 4, 4]),
    ]))
    return t

def steps_table(rows, col_widths=None):
    """Step → Action two-column table."""
    if col_widths is None:
        col_widths = [2.2*cm, USABLE_W - 2.2*cm]
    data = []
    for i, (step, action, *rest) in enumerate(rows):
        bg = C_ROW1 if i % 2 == 0 else C_ROW2
        note_txt = rest[0] if rest else ""
        cell_action = Paragraph(f"<b>{action}</b>" + (f"<br/><font color='#117A65' size='7.5'><i>{note_txt}</i></font>" if note_txt else ""), TABLE_CELL)
        data.append([Paragraph(f"<b>{step}</b>", TABLE_CELL_BOLD), cell_action])
    t = Table(data, colWidths=col_widths)
    t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (0,-1), colors.HexColor("#FDFEFE")),
        ("ROWBACKGROUNDS",(0,0), (-1,-1), [C_ROW1, C_ROW2]),
        ("GRID",          (0,0), (-1,-1), 0.3, colors.HexColor("#BFC9CA")),
        ("TOPPADDING",    (0,0), (-1,-1), 4),
        ("BOTTOMPADDING", (0,0), (-1,-1), 4),
        ("LEFTPADDING",   (0,0), (-1,-1), 5),
        ("VALIGN",        (0,0), (-1,-1), "TOP"),
    ]))
    return t

def antidote_table(rows):
    hdr = [Paragraph("Drug / Toxin", TABLE_HEADER), Paragraph("Antidote", TABLE_HEADER)]
    data = [hdr]
    for toxin, antidote in rows:
        data.append([Paragraph(toxin, TABLE_CELL), Paragraph(f"<b>{antidote}</b>", TABLE_CELL_BOLD)])
    col_w = [USABLE_W/2, USABLE_W/2]
    t = Table(data, colWidths=col_w)
    t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,0), C_RED),
        ("ROWBACKGROUNDS",(0,1), (-1,-1), [C_ROW2, C_RED_BG]),
        ("GRID",          (0,0), (-1,-1), 0.3, colors.HexColor("#BFC9CA")),
        ("TOPPADDING",    (0,0), (-1,-1), 4),
        ("BOTTOMPADDING", (0,0), (-1,-1), 4),
        ("LEFTPADDING",   (0,0), (-1,-1), 6),
        ("VALIGN",        (0,0), (-1,-1), "TOP"),
    ]))
    return t

def mnemonic_table(rows, bg_color=C_YELLOW_BG):
    data = []
    for m, meaning in rows:
        data.append([Paragraph(f"<b>{m}</b>", MNEM_STYLE), Paragraph(meaning, BODY)])
    t = Table(data, colWidths=[3.5*cm, USABLE_W - 3.5*cm])
    t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,-1), bg_color),
        ("GRID",          (0,0), (-1,-1), 0.3, colors.HexColor("#D4E6F1")),
        ("TOPPADDING",    (0,0), (-1,-1), 4),
        ("BOTTOMPADDING", (0,0), (-1,-1), 4),
        ("LEFTPADDING",   (0,0), (-1,-1), 6),
        ("VALIGN",        (0,0), (-1,-1), "TOP"),
    ]))
    return t

def highlight_box(text, bg=C_RED_BG, text_color=C_DARK_RED):
    p = Paragraph(text, ParagraphStyle("hb", fontName="Helvetica-Bold", fontSize=8.5,
        textColor=text_color, leading=12, alignment=TA_LEFT))
    t = Table([[p]], colWidths=[USABLE_W])
    t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,-1), bg),
        ("TOPPADDING",    (0,0), (-1,-1), 6),
        ("BOTTOMPADDING", (0,0), (-1,-1), 6),
        ("LEFTPADDING",   (0,0), (-1,-1), 10),
        ("BOX",           (0,0), (-1,-1), 1, text_color),
    ]))
    return t

def sp(h=4):
    return Spacer(1, h)

def hr():
    return HRFlowable(width="100%", thickness=0.5, color=colors.HexColor("#AED6F1"), spaceAfter=4)

# ─── Page callback ────────────────────────────────────────────────────────────
def on_page(canvas, doc):
    canvas.saveState()
    # Footer
    canvas.setFont("Helvetica", 7)
    canvas.setFillColor(C_MID_GRAY)
    canvas.drawCentredString(PAGE_W/2, 1.1*cm,
        f"NCLEX & NORCET AIIMS Emergency Quick-Reference  •  Page {doc.page}")
    canvas.drawString(MARGIN, 1.1*cm, "For educational use only")
    canvas.drawRightString(PAGE_W - MARGIN, 1.1*cm, "Orris Medical Assistant 2026")
    # Top rule
    canvas.setStrokeColor(C_HEADER_BG)
    canvas.setLineWidth(2)
    canvas.line(MARGIN, PAGE_H - 1.2*cm, PAGE_W - MARGIN, PAGE_H - 1.2*cm)
    canvas.restoreState()

def on_first_page(canvas, doc):
    # Full-bleed cover gradient simulation via rectangles
    canvas.saveState()
    canvas.setFillColor(C_HEADER_BG)
    canvas.rect(0, 0, PAGE_W, PAGE_H, fill=1, stroke=0)
    canvas.setFillColor(colors.HexColor("#0D2B45"))
    canvas.rect(0, 0, PAGE_W, PAGE_H * 0.35, fill=1, stroke=0)
    canvas.restoreState()

# ─── Content builder ──────────────────────────────────────────────────────────
def build():
    doc = BaseDocTemplate(
        OUTPUT,
        pagesize=A4,
        leftMargin=MARGIN, rightMargin=MARGIN,
        topMargin=2.0*cm, bottomMargin=1.8*cm,
        title="Emergency Quick-Reference — NCLEX & NORCET AIIMS",
        author="Orris Medical Assistant",
        subject="Emergency Nursing & Medical Management"
    )

    frame = Frame(MARGIN, 1.8*cm, USABLE_W, PAGE_H - 3.8*cm, id="main")
    cover_frame = Frame(MARGIN, 1.8*cm, USABLE_W, PAGE_H - 3.8*cm, id="cover")

    doc.addPageTemplates([
        PageTemplate(id="cover", frames=[cover_frame], onPage=on_first_page),
        PageTemplate(id="body",  frames=[frame],       onPage=on_page),
    ])

    story = []

    # ── COVER ──────────────────────────────────────────────────────────────────
    story.append(Spacer(1, 3.5*cm))
    story.append(Paragraph("🚨 EMERGENCY QUICK-REFERENCE", COVER_TITLE))
    story.append(Paragraph("CHEAT SHEET", COVER_TITLE))
    story.append(Spacer(1, 0.5*cm))
    story.append(Paragraph("NCLEX  •  NORCET AIIMS  •  Nursing &amp; Medical Exams", COVER_SUB))
    story.append(Spacer(1, 0.4*cm))
    story.append(Paragraph("18 Critical Emergencies — First &amp; Second Priority Actions", COVER_SUB))
    story.append(Spacer(1, 1.0*cm))

    # Cover summary boxes
    cover_items = [
        ["01 Cardiac Arrest", "02 Respiratory Distress", "03 Shock (All Types)"],
        ["04 Stroke / CVA", "05 Myocardial Infarction", "06 Pulmonary Embolism"],
        ["07 Diabetic Emergencies", "08 Status Epilepticus", "09 Raised ICP"],
        ["10 Burns", "11 Obstetric Emergencies", "12 Poisoning / Overdose"],
        ["13 Heat Stroke / Hypothermia", "14 Hypertensive Emergency", "15 Acute Pulmonary Edema"],
        ["16 Drowning", "17 Spinal Cord Injury", "18 Polytrauma (ATLS)"],
    ]
    cover_cell_style = ParagraphStyle("cs", fontName="Helvetica-Bold", fontSize=8.5,
        textColor=C_DARK_GRAY, alignment=TA_CENTER, leading=11)
    cover_data = []
    for row in cover_items:
        cover_data.append([Paragraph(c, cover_cell_style) for c in row])
    ct = Table(cover_data, colWidths=[USABLE_W/3]*3)
    ct.setStyle(TableStyle([
        ("ROWBACKGROUNDS", (0,0), (-1,-1), [colors.HexColor("#EBF5FB"), colors.HexColor("#D6EAF8")]),
        ("GRID",           (0,0), (-1,-1), 0.5, colors.HexColor("#85C1E9")),
        ("TOPPADDING",     (0,0), (-1,-1), 6),
        ("BOTTOMPADDING",  (0,0), (-1,-1), 6),
        ("LEFTPADDING",    (0,0), (-1,-1), 4),
        ("VALIGN",         (0,0), (-1,-1), "MIDDLE"),
    ]))
    story.append(ct)
    story.append(Spacer(1, 0.8*cm))
    story.append(Paragraph("+ Antidotes Reference  •  Key Mnemonics  •  High-Yield Exam Points", COVER_NOTE))
    story.append(Spacer(1, 0.3*cm))
    story.append(Paragraph("Based on: ROSEN's Emergency Medicine • Goldman-Cecil Medicine • ACLS/ATLS Guidelines", COVER_NOTE))

    story.append(PageBreak())

    # ── Switch to body template ────────────────────────────────────────────────
    from reportlab.platypus import NextPageTemplate
    story.append(NextPageTemplate("body"))

    # ── PAGE 2: Universal Framework + Emergency 1 & 2 ─────────────────────────
    story.append(section_header("UNIVERSAL PRIORITY FRAMEWORK — Always Apply First", C_DARK_GRAY, "🔑"))
    story.append(sp(4))
    abc_data = [
        [Paragraph("<b>A — Airway</b>", TABLE_CELL_BOLD), Paragraph("Establish/maintain patency; jaw thrust or chin-lift; suction; intubate if needed", TABLE_CELL)],
        [Paragraph("<b>B — Breathing</b>", TABLE_CELL_BOLD), Paragraph("Assess RR, depth, SpO₂; O₂ therapy; bag-valve-mask if apneic", TABLE_CELL)],
        [Paragraph("<b>C — Circulation</b>", TABLE_CELL_BOLD), Paragraph("HR, BP, skin perfusion; 2 large-bore IVs; IV fluids; stop bleeding", TABLE_CELL)],
        [Paragraph("<b>D — Disability</b>", TABLE_CELL_BOLD), Paragraph("GCS, pupils (PERRLA), glucose check, neurological status", TABLE_CELL)],
        [Paragraph("<b>E — Exposure</b>", TABLE_CELL_BOLD), Paragraph("Full body exam; vital signs; prevent hypothermia", TABLE_CELL)],
    ]
    abct = Table(abc_data, colWidths=[3.2*cm, USABLE_W - 3.2*cm])
    abct.setStyle(TableStyle([
        ("ROWBACKGROUNDS", (0,0), (-1,-1), [colors.HexColor("#EAFAF1"), colors.HexColor("#F9FBE7")]),
        ("GRID",           (0,0), (-1,-1), 0.3, colors.HexColor("#A9DFBF")),
        ("TOPPADDING",     (0,0), (-1,-1), 4), ("BOTTOMPADDING", (0,0), (-1,-1), 4),
        ("LEFTPADDING",    (0,0), (-1,-1), 6), ("VALIGN", (0,0), (-1,-1), "TOP"),
    ]))
    story.append(abct)
    story.append(sp(6))
    story.append(highlight_box(
        "NURSING PRIORITY RULE: Physiological needs ALWAYS first (Maslow). "
        "Acute > Chronic | Unstable > Stable | Life-threatening > Comfort",
        bg=colors.HexColor("#EAFAF1"), text_color=C_TEAL))
    story.append(sp(8))

    # ── Emergency 1: Cardiac Arrest ───────────────────────────────────────────
    story.append(section_header("1. CARDIAC ARREST (Cardiopulmonary Arrest)", C_RED, "🫀"))
    story.append(sp(3))
    story.append(steps_table([
        ("1st", "Confirm unresponsiveness; shout for help; ACTIVATE CODE BLUE", ""),
        ("2nd", "Check carotid pulse ≤10 sec → absent → START CPR immediately", ""),
        ("3rd", "Chest compressions: 30:2, rate 100–120/min, depth 5–6 cm, hard & fast — MINIMIZE INTERRUPTIONS (<10 sec)", ""),
        ("4th", "Attach defibrillator; analyze rhythm → VF/pulseless VT (shockable) → SHOCK 200J biphasic", ""),
        ("5th", "Resume CPR 2 min immediately post-shock; establish IV/IO access", ""),
        ("6th", "Epinephrine 1 mg IV/IO every 3–5 min; Amiodarone 300 mg IV (VF/VT)", "Vasopressor + antiarrhythmic"),
        ("7th", "Identify & treat reversible causes: 4H's + 4T's (see below)", ""),
        ("8th", "Post-ROSC: 12-lead ECG; Targeted Temperature Management 32–36°C; ICU", ""),
    ]))
    story.append(sp(4))
    story.append(highlight_box(
        "4H's: Hypoxia | Hypovolemia | Hypo/Hyperkalemia | Hypothermia       "
        "4T's: Tension pneumothorax | Tamponade | Toxins | Thrombosis (PE/MI)",
        bg=colors.HexColor("#FDEDEC"), text_color=C_DARK_RED))
    story.append(sp(4))
    story.append(Paragraph(
        "<b>CPR Ratios:</b> Adults 30:2 | Child (1-rescuer) 30:2 | Child (2-rescuer) 15:2 | Infant 15:2",
        NOTE_STYLE))
    story.append(sp(8))

    # ── Emergency 2: Respiratory Distress ─────────────────────────────────────
    story.append(section_header("2. RESPIRATORY DISTRESS / ARREST", C_BLUE, "😮‍💨"))
    story.append(sp(3))
    story.append(steps_table([
        ("1st", "POSITION: High Fowler's / orthopneic (sit upright); O₂ via face mask 10–15 L/min", ""),
        ("2nd", "Assess: SpO₂, RR, breath sounds (auscultation), ABG, peak flow", ""),
        ("3rd", "If apneic: jaw-thrust/chin-lift; BVM (bag-valve-mask) ventilation", ""),
        ("4th", "Prepare RSI (Rapid Sequence Intubation) → Endotracheal intubation (ETT)", ""),
        ("5th", "Confirm ETT: ETCO₂ capnography + bilateral breath sounds + CXR", ""),
        ("6th", "Mechanical ventilation: FiO₂, PEEP, tidal volume 6–8 mL/kg IBW", ""),
    ]))
    story.append(sp(4))
    asthma_data = [
        [Paragraph("<b>Asthma Attack Steps</b>", TABLE_HEADER)],
        [Paragraph("1st: Salbutamol (Albuterol) 2.5–5 mg nebulization + Ipratropium bromide", TABLE_CELL)],
        [Paragraph("2nd: IV/oral Corticosteroids (Prednisolone / Methylprednisolone)", TABLE_CELL)],
        [Paragraph("3rd: IV Magnesium sulfate 2g over 20 min (severe/refractory)", TABLE_CELL)],
        [Paragraph("Monitor: PEFR, SpO₂, use of accessory muscles, RR, LOC", TABLE_CELL)],
    ]
    at = Table(asthma_data, colWidths=[USABLE_W])
    at.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,0), C_BLUE),
        ("BACKGROUND",    (0,1), (-1,-1), colors.HexColor("#EBF5FB")),
        ("GRID",          (0,0), (-1,-1), 0.3, colors.HexColor("#AED6F1")),
        ("TOPPADDING",    (0,0), (-1,-1), 4), ("BOTTOMPADDING", (0,0), (-1,-1), 4),
        ("LEFTPADDING",   (0,0), (-1,-1), 8), ("VALIGN", (0,0), (-1,-1), "TOP"),
    ]))
    story.append(at)

    story.append(PageBreak())

    # ── Emergency 3: SHOCK ────────────────────────────────────────────────────
    story.append(section_header("3. SHOCK — All Types & Management", C_ORANGE, "🩸"))
    story.append(sp(3))

    shock_types = [
        ("Hypovolemic\n(Hemorrhagic)", "1st: Control bleeding (direct pressure/tourniquet)\n2nd: 2 large-bore IVs; NS/LR 1–2L rapid bolus\n3rd: Type & cross-match; pRBCs if Hgb <7 g/dL\n4th: Balanced transfusion pRBCs:FFP:Platelets = 1:1:1\n5th: Monitor UO >0.5 mL/kg/hr, lactate, base deficit"),
        ("Septic\n(Distributive)", "1st: Blood cultures ×2 BEFORE antibiotics; lactate level\n2nd: Broad-spectrum IV antibiotics WITHIN 1 HOUR\n3rd: Crystalloid 30 mL/kg IV within 3 hours\n4th: Norepinephrine (1st-line vasopressor) if MAP <65 mmHg\n5th: Hydrocortisone 200 mg/day if vasopressor-refractory"),
        ("Anaphylactic\n(Distributive)", "1st: EPINEPHRINE 0.3–0.5 mg IM (anterolateral thigh) — FIRST LINE!\n2nd: Supine + legs elevated; O₂; IV access; NS bolus\n3rd: Repeat epinephrine q5–15 min if needed\n4th: Diphenhydramine IV + Ranitidine (H2 blocker)\n5th: Methylprednisolone 125 mg IV; monitor biphasic (4–12 hrs)"),
        ("Cardiogenic", "1st: O₂, monitor, IV access; 12-lead ECG for AMI\n2nd: Dobutamine (inotrope); Dopamine if severe hypotension\n3rd: CAUTIOUS fluids (avoid overload); Furosemide if pulm. edema\n4th: Urgent PCI if AMI-related (door-to-balloon ≤90 min)\n5th: IABP / mechanical circulatory support"),
    ]
    shock_data = [[Paragraph("<b>Type</b>", TABLE_HEADER), Paragraph("<b>Priority Steps</b>", TABLE_HEADER)]]
    bgs = [colors.HexColor("#FDEBD0"), colors.HexColor("#FFF9C4"),
           colors.HexColor("#FDEDEC"), colors.HexColor("#EBF5FB")]
    for i, (stype, ssteps) in enumerate(shock_types):
        shock_data.append([
            Paragraph(f"<b>{stype}</b>", ParagraphStyle("st", fontName="Helvetica-Bold", fontSize=8,
                textColor=C_DARK_RED, leading=11, alignment=TA_CENTER)),
            Paragraph(ssteps.replace("\n", "<br/>"), TABLE_CELL)
        ])
    st = Table(shock_data, colWidths=[2.8*cm, USABLE_W - 2.8*cm])
    st.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,0), C_ORANGE),
        ("ROWBACKGROUNDS",(0,1), (-1,-1), [colors.HexColor("#FFF3E0"), colors.HexColor("#FFF9C4"),
                                            colors.HexColor("#FDEDEC"), colors.HexColor("#EBF5FB")]),
        ("GRID",          (0,0), (-1,-1), 0.3, colors.HexColor("#F0B27A")),
        ("TOPPADDING",    (0,0), (-1,-1), 5), ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING",   (0,0), (-1,-1), 6), ("VALIGN", (0,0), (-1,-1), "TOP"),
    ]))
    story.append(st)
    story.append(sp(4))
    story.append(highlight_box(
        "KEY LAB: Lactate >4 mmol/L OR Base Deficit < −4 mEq/L = SHOCK  |  "
        "UO <0.5 mL/kg/hr = severe renal hypoperfusion  |  "
        "EPINEPHRINE = 1st in anaphylaxis (NOT antihistamine!)",
        bg=colors.HexColor("#FEF9E7"), text_color=C_AMBER))
    story.append(sp(8))

    # ── Emergency 4: Stroke ───────────────────────────────────────────────────
    story.append(section_header("4. STROKE / CVA (Cerebrovascular Accident)", C_PURPLE, "🧠"))
    story.append(sp(3))
    story.append(highlight_box(
        'FAST: Face drooping | Arm weakness | Speech difficulty | Time to call  —  "Time is Brain!"',
        bg=colors.HexColor("#F5EEF8"), text_color=C_PURPLE))
    story.append(sp(4))
    story.append(steps_table([
        ("1st", "Activate stroke team; NOTE exact time of symptom onset", ""),
        ("2nd", "ABC stabilization; O₂ if SpO₂ <94%; IV access; NPO (nil per os)", ""),
        ("3rd", "STAT non-contrast CT brain — rule out hemorrhagic stroke FIRST", ""),
        ("4th", "Blood glucose check (hypoglycemia mimics stroke — correct BGL first)", ""),
        ("5th", "Ischemic stroke ≤4.5 hrs: IV tPA (Alteplase) 0.9 mg/kg (max 90 mg)", "10% as bolus, rest over 60 min"),
        ("6th", "Large vessel occlusion ≤24 hrs: Mechanical Thrombectomy", ""),
        ("7th", "BP: allow ≤220/120 pre-tPA; keep <180/105 mmHg post-tPA", ""),
        ("8th", "Aspirin 325 mg (after hemorrhage excluded); Statin therapy", ""),
    ]))
    story.append(sp(3))
    story.append(Paragraph(
        "<b>Nursing:</b> HOB 30° | Swallow screen before oral intake | Neuro checks q1h | "
        "Hemorrhagic stroke: reverse anticoagulation; target SBP <140 mmHg",
        NOTE_STYLE))

    story.append(PageBreak())

    # ── Emergency 5: MI ────────────────────────────────────────────────────────
    story.append(section_header("5. MYOCARDIAL INFARCTION — STEMI / NSTEMI", C_RED, "💉"))
    story.append(sp(3))
    story.append(steps_table([
        ("1st", "12-lead ECG within 10 min of arrival — ST elevation ≥1mm in ≥2 contiguous leads = STEMI", ""),
        ("2nd", "Aspirin 325 mg (chewed) + P2Y12 inhibitor (Clopidogrel / Ticagrelor) — Dual antiplatelet therapy", ""),
        ("3rd", "Nitroglycerin SL 0.4 mg q5 min ×3 (if SBP >90, NO RV infarct)", "Vasodilator — reduces preload"),
        ("4th", "O₂ ONLY if SpO₂ <90% (avoid hyperoxia); Morphine 2–4 mg IV if refractory pain", ""),
        ("5th", "IV Heparin (unfractionated) or Enoxaparin — Anticoagulation", ""),
        ("6th", "PRIMARY PCI within 90 min (door-to-balloon) — PREFERRED reperfusion", ""),
        ("7th", "If PCI unavailable: IV Fibrinolysis (Streptokinase / tPA) within 30 min", "Contraindicated if hemorrhagic stroke, recent surgery"),
    ]))
    story.append(sp(4))
    story.append(highlight_box(
        "MONA Mnemonic: Morphine | O₂ (if SpO₂ <90%) | Nitroglycerin | Aspirin  —  "
        "Continuous cardiac monitoring + defibrillator ready + restrict activity + NPO for procedure",
        bg=colors.HexColor("#FDEDEC"), text_color=C_DARK_RED))
    story.append(sp(8))

    # ── Emergency 6: PE ────────────────────────────────────────────────────────
    story.append(section_header("6. PULMONARY EMBOLISM (PE)", C_BLUE, "🫁"))
    story.append(sp(3))
    story.append(steps_table([
        ("1st", "O₂ high flow; IV access; continuous monitoring of SpO₂, BP, HR", ""),
        ("2nd", "12-lead ECG (classic: S1Q3T3); D-dimer; ABG; Wells Score pre-test probability", ""),
        ("3rd", "CT Pulmonary Angiography (CTPA) — GOLD STANDARD imaging", ""),
        ("4th", "Anticoagulation: IV Unfractionated Heparin 80 U/kg bolus → 18 U/kg/hr infusion", ""),
        ("5th", "MASSIVE PE (hemodynamic instability): Thrombolysis tPA 100 mg IV over 2 hrs", ""),
        ("6th", "Surgical embolectomy if thrombolysis contraindicated", ""),
    ]))
    story.append(sp(8))

    # ── Emergency 7: Diabetic ─────────────────────────────────────────────────
    story.append(section_header("7. DIABETIC EMERGENCIES", C_TEAL, "🔋"))
    story.append(sp(3))

    dka_hypo_data = [
        [Paragraph("<b>DKA (Diabetic Ketoacidosis)</b>", TABLE_HEADER),
         Paragraph("<b>Hypoglycemia (BGL &lt;70 mg/dL)</b>", TABLE_HEADER)],
        [Paragraph("Criteria: BGL >250 mg/dL + pH <7.3 + HCO₃ <18 + ketonemia", SMALL),
         Paragraph("Rule of 15: 15g fast carbs → recheck in 15 min (conscious)", SMALL)],
        [Paragraph("1st: IV NS 1L/hr for 1–2 hrs (fluid resuscitation)", TABLE_CELL),
         Paragraph("1st: 15g fast-acting carbs PO if conscious", TABLE_CELL)],
        [Paragraph("2nd: IV Regular Insulin 0.1 U/kg/hr (ONLY if K⁺ ≥3.5 mEq/L)", TABLE_CELL),
         Paragraph("2nd: If unconscious/no IV: Glucagon 1 mg IM/SC", TABLE_CELL)],
        [Paragraph("3rd: K⁺ replacement 20–40 mEq/hr if K⁺ <5.5 mEq/L", TABLE_CELL),
         Paragraph("3rd: If IV access: Dextrose 25–50g (50% dextrose) IV bolus", TABLE_CELL)],
        [Paragraph("4th: Switch to D5 when BGL <200 mg/dL", TABLE_CELL),
         Paragraph("4th: Identify cause; monitor BGL q15–30 min", TABLE_CELL)],
        [Paragraph("5th: Monitor ABG, electrolytes, UO q2–4h", TABLE_CELL),
         Paragraph("⚠ Potassium must be ≥3.5 before insulin in DKA!", TABLE_CELL_BOLD)],
    ]
    dka_t = Table(dka_hypo_data, colWidths=[USABLE_W/2, USABLE_W/2])
    dka_t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (0,0), C_TEAL),
        ("BACKGROUND",    (1,0), (1,0), C_GREEN),
        ("ROWBACKGROUNDS",(0,1), (-1,-1), [colors.HexColor("#E8F8F5"), colors.HexColor("#EAFAF1")]),
        ("GRID",          (0,0), (-1,-1), 0.3, colors.HexColor("#A2D9CE")),
        ("TOPPADDING",    (0,0), (-1,-1), 4), ("BOTTOMPADDING", (0,0), (-1,-1), 4),
        ("LEFTPADDING",   (0,0), (-1,-1), 6), ("VALIGN", (0,0), (-1,-1), "TOP"),
    ]))
    story.append(dka_t)

    story.append(PageBreak())

    # ── Emergency 8: Status Epilepticus ───────────────────────────────────────
    story.append(section_header("8. STATUS EPILEPTICUS (Seizure >5 min or recurrent without recovery)", C_PURPLE, "⚡"))
    story.append(sp(3))
    story.append(steps_table([
        ("1st", "Protect from injury; lateral position (recovery); TIME the seizure; do NOT restrain or insert objects in mouth", ""),
        ("2nd", "O₂ via face mask; suction secretions; IV access; BGL, electrolytes, drug levels", ""),
        ("3rd", "Thiamine 100 mg IV BEFORE glucose in alcoholic patients (prevents Wernicke's encephalopathy)", ""),
        ("4th (0–5 min)", "Benzodiazepine: Lorazepam 0.1 mg/kg IV  OR  Diazepam 0.2 mg/kg IV/rectal  OR  Midazolam IM", "1st-line anticonvulsant"),
        ("5th (5–20 min)", "2nd-line: Levetiracetam 60 mg/kg IV  OR  Phenytoin/Fosphenytoin 20 mg/kg IV", ""),
        ("6th (>30 min)", "Refractory: Propofol / Midazolam / Phenobarbital infusion → ICU + continuous EEG monitoring", ""),
    ]))
    story.append(sp(3))
    story.append(Paragraph(
        "<b>Nursing seizure precautions:</b> Padded side rails | O₂ at bedside | Suction ready | NPO during seizure | Privacy",
        NOTE_STYLE))
    story.append(sp(8))

    # ── Emergency 9: Raised ICP ───────────────────────────────────────────────
    story.append(section_header("9. INCREASED INTRACRANIAL PRESSURE (Raised ICP)", C_DARK_GRAY, "🧊"))
    story.append(sp(3))
    story.append(steps_table([
        ("1st", "HOB 30° elevation (neutral head position — avoid jugular compression)", ""),
        ("2nd", "O₂ to maintain SpO₂ >95%; target PaCO₂ 35–40 mmHg (avoid hypercarbia)", ""),
        ("3rd", "Mannitol 0.25–1 g/kg IV (osmotic diuretic — 1st line); monitor serum osmolality <320 mOsm/kg", ""),
        ("4th", "3% Hypertonic Saline (alternative to mannitol; preferred if hypotensive)", ""),
        ("5th", "Controlled hyperventilation (PCO₂ 30–35 mmHg) — TEMPORARY bridge only", ""),
        ("6th", "Neurosurgical consult; ICP monitoring; Decompressive craniectomy if refractory", ""),
    ]))
    story.append(sp(4))
    story.append(highlight_box(
        "CUSHING'S TRIAD (late sign of herniation): Hypertension + Bradycardia + Irregular Respirations  |  "
        "⚠ NEVER do LP before CT if raised ICP suspected (herniation risk!)",
        bg=colors.HexColor("#F4ECF7"), text_color=C_PURPLE))
    story.append(sp(8))

    # ── Emergency 10: Burns ───────────────────────────────────────────────────
    story.append(section_header("10. BURNS", C_ORANGE, "🔥"))
    story.append(sp(3))
    story.append(steps_table([
        ("1st", "STOP burning process; remove clothing & jewelry (not stuck to skin)", ""),
        ("2nd", "Airway assessment for INHALATION INJURY: hoarseness, singed nasal hairs, stridor, carbonaceous sputum → EARLY intubation", ""),
        ("3rd", "Calculate TBSA (Total Body Surface Area) — Rule of Nines", ""),
        ("4th", "PARKLAND FORMULA: 4 mL × weight(kg) × %TBSA = Lactated Ringer's (½ in first 8 hrs, ½ in next 16 hrs)", ""),
        ("5th", "Target UO: 0.5–1.0 mL/kg/hr adults; 1 mL/kg/hr children", ""),
        ("6th", "Tetanus prophylaxis; pain management (IV Morphine); wound care", ""),
        ("7th", "Transfer to burn unit: >10% TBSA, face/hands/genitalia, circumferential, chemical/electrical burns", ""),
    ]))
    story.append(sp(3))
    story.append(highlight_box(
        "RULE OF NINES: Head 9% | Each Arm 9% | Chest 9% | Abdomen 9% | Each Thigh 9% | Each Lower Leg 9% | Perineum 1%",
        bg=colors.HexColor("#FEF9E7"), text_color=C_ORANGE))

    story.append(PageBreak())

    # ── Emergency 11: Obstetric ───────────────────────────────────────────────
    story.append(section_header("11. OBSTETRIC EMERGENCIES", C_PURPLE, "🤰"))
    story.append(sp(3))

    obs_data = [
        [Paragraph("<b>Eclampsia</b>", TABLE_HEADER),
         Paragraph("<b>Postpartum Hemorrhage (PPH)</b>", TABLE_HEADER)],
        [Paragraph("1st: Protect airway; LEFT LATERAL decubitus (uterine displacement)", TABLE_CELL),
         Paragraph("1st: Bimanual uterine massage; assess 4T's cause", TABLE_CELL)],
        [Paragraph("2nd: Magnesium Sulfate 4–6g IV loading → 1–2g/hr maintenance", TABLE_CELL_BOLD),
         Paragraph("2nd: Oxytocin 20–40 units in 1L NS IV — 1st-line uterotonic", TABLE_CELL_BOLD)],
        [Paragraph("3rd: Antihypertensive: Hydralazine 5–10 mg IV OR Labetalol 20 mg IV (target BP <160/110)", TABLE_CELL),
         Paragraph("3rd: Misoprostol 800–1000 mcg rectal/sublingual", TABLE_CELL)],
        [Paragraph("4th: Fetal monitoring; plan for delivery", TABLE_CELL),
         Paragraph("4th: Tranexamic acid 1g IV within 3 hrs of delivery", TABLE_CELL)],
        [Paragraph("5th: ANTIDOTE FOR Mg TOXICITY = Calcium Gluconate (keep at bedside!)", TABLE_CELL_BOLD),
         Paragraph("5th: Blood transfusion; surgical (B-Lynch suture / hysterectomy)", TABLE_CELL)],
    ]
    obs_t = Table(obs_data, colWidths=[USABLE_W/2, USABLE_W/2])
    obs_t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (0,0), C_PURPLE),
        ("BACKGROUND",    (1,0), (1,0), colors.HexColor("#922B21")),
        ("ROWBACKGROUNDS",(0,1), (-1,-1), [colors.HexColor("#F5EEF8"), colors.HexColor("#FDEDEC")]),
        ("GRID",          (0,0), (-1,-1), 0.3, colors.HexColor("#D7BDE2")),
        ("TOPPADDING",    (0,0), (-1,-1), 4), ("BOTTOMPADDING", (0,0), (-1,-1), 4),
        ("LEFTPADDING",   (0,0), (-1,-1), 6), ("VALIGN", (0,0), (-1,-1), "TOP"),
    ]))
    story.append(obs_t)
    story.append(sp(4))
    story.append(highlight_box(
        "PPH — 4T's Causes: Tone (atony, most common) | Tissue (retained placenta) | Trauma (laceration) | Thrombin (coagulopathy)",
        bg=colors.HexColor("#FDEDEC"), text_color=C_DARK_RED))
    story.append(sp(8))

    # ── Emergency 12: Poisoning ───────────────────────────────────────────────
    story.append(section_header("12. POISONING / OVERDOSE", C_DARK_GRAY, "☠️"))
    story.append(sp(3))
    story.append(Paragraph("<b>Universal Approach:</b> ABCDE → Activated charcoal (if <1 hr, alert, non-caustic) → Specific antidote → Supportive care", BODY_BOLD))
    story.append(sp(4))
    story.append(antidote_table([
        ("Opioids (Morphine, Heroin, Fentanyl)", "Naloxone (Narcan) 0.4–2 mg IV/IM/IN"),
        ("Organophosphates (Nerve agents, Pesticides)", "Atropine IV (repeat until dry) + Pralidoxime (2-PAM)"),
        ("Acetaminophen / Paracetamol", "N-Acetylcysteine (NAC) IV/oral — start within 8–10 hrs"),
        ("Benzodiazepines", "Flumazenil 0.2 mg IV (use cautiously — seizure risk)"),
        ("Warfarin / Coumadin", "Vitamin K IV + FFP or Prothrombin Complex Concentrate (PCC)"),
        ("Heparin", "Protamine Sulfate"),
        ("Digoxin toxicity", "Digoxin-specific Fab fragments (Digibind)"),
        ("Beta-blocker overdose", "Glucagon IV + high-dose insulin therapy"),
        ("Calcium channel blocker", "Calcium Gluconate IV + Glucagon"),
        ("Tricyclic Antidepressant (TCA)", "Sodium Bicarbonate IV (QRS narrowing)"),
        ("Carbon Monoxide (CO)", "100% O₂ (NRB mask); Hyperbaric O₂ if severe"),
        ("Cyanide poisoning", "Hydroxocobalamin (Cyanokit) IV"),
        ("Iron overdose", "Deferoxamine IV/IM"),
        ("Methanol / Ethylene glycol", "Fomepizole (4-MP) IV; dialysis if severe"),
        ("Magnesium toxicity", "Calcium Gluconate 1g IV (ANTIDOTE)"),
    ]))

    story.append(PageBreak())

    # ── Emergency 13: Heat Stroke / Hypothermia ───────────────────────────────
    story.append(section_header("13. HEAT STROKE & HYPOTHERMIA", C_RED, "🌡️"))
    story.append(sp(3))
    temp_data = [
        [Paragraph("<b>Heat Stroke (Core temp >40°C + CNS dysfunction)</b>", TABLE_HEADER),
         Paragraph("<b>Hypothermia (Core temp &lt;35°C)</b>", TABLE_HEADER)],
        [Paragraph("1st: Remove from heat; ABC stabilization", TABLE_CELL),
         Paragraph("1st: Remove wet clothing; prevent further heat loss", TABLE_CELL)],
        [Paragraph("2nd: RAPID COOLING — target 39°C within 30 min: ice water immersion OR evaporative cooling + fans", TABLE_CELL_BOLD),
         Paragraph("2nd: Passive (mild) → Active external (moderate) → Active internal/ECMO (severe <30°C)", TABLE_CELL)],
        [Paragraph("3rd: IV cold NS; DO NOT give antipyretics (not effective)", TABLE_CELL),
         Paragraph("3rd: Warm IV fluids 39–42°C; warmed humidified O₂", TABLE_CELL)],
        [Paragraph("4th: Monitor: rhabdomyolysis (CK, urine myoglobin), renal function, electrolytes", TABLE_CELL),
         Paragraph("4th: ECG monitoring — Osborn (J) waves; VF risk; DO NOT pronounce dead until warm >32°C", TABLE_CELL_BOLD)],
    ]
    temp_t = Table(temp_data, colWidths=[USABLE_W/2, USABLE_W/2])
    temp_t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (0,0), C_RED),
        ("BACKGROUND",    (1,0), (1,0), C_BLUE),
        ("ROWBACKGROUNDS",(0,1), (-1,-1), [colors.HexColor("#FFF3E0"), colors.HexColor("#EBF5FB")]),
        ("GRID",          (0,0), (-1,-1), 0.3, colors.HexColor("#BFC9CA")),
        ("TOPPADDING",    (0,0), (-1,-1), 4), ("BOTTOMPADDING", (0,0), (-1,-1), 4),
        ("LEFTPADDING",   (0,0), (-1,-1), 6), ("VALIGN", (0,0), (-1,-1), "TOP"),
    ]))
    story.append(temp_t)
    story.append(sp(4))
    story.append(highlight_box(
        '"Not dead until WARM and dead" — continue CPR/resuscitation until core temp >32°C in hypothermia',
        bg=colors.HexColor("#EBF5FB"), text_color=C_BLUE))
    story.append(sp(8))

    # ── Emergency 14: Hypertensive Emergency ─────────────────────────────────
    story.append(section_header("14. HYPERTENSIVE EMERGENCY (BP >180/120 + End-Organ Damage)", C_RED, "🩺"))
    story.append(sp(3))
    story.append(steps_table([
        ("1st", "IV access; continuous BP monitoring (arterial line preferred); ECG; labs (Cr, UA, troponin, CXR)", ""),
        ("2nd", "Target: Reduce MAP by ≤25% in FIRST HOUR — NOT to normal (risk of ischemic injury)", ""),
        ("3rd", "IV antihypertensives: Nicardipine / Labetalol / Clevidipine / Nitroprusside infusion", ""),
        ("4th (Aortic Dissection)", "Esmolol + Nitroprusside; target SBP <120 mmHg URGENTLY", ""),
        ("5th (Eclampsia)", "Magnesium Sulfate + Labetalol / Hydralazine", ""),
        ("6th (Hypertensive Encephalopathy)", "Reduce BP 30–40%; IV Labetalol or Nicardipine", "Fully reversible with prompt treatment"),
    ]))
    story.append(sp(4))
    story.append(highlight_box(
        "End-organ damage targets: Heart (ACS/HF) | Brain (Stroke/Encephalopathy) | Kidney (AKI) | Aorta (Dissection) | Eyes (Retinopathy) | Eclampsia",
        bg=colors.HexColor("#FDEDEC"), text_color=C_DARK_RED))
    story.append(sp(8))

    # ── Emergency 15: Acute Pulmonary Edema ───────────────────────────────────
    story.append(section_header("15. ACUTE PULMONARY EDEMA (Cardiogenic)", C_BLUE, "🫀"))
    story.append(sp(3))
    story.append(steps_table([
        ("1st", "POSITION: High Fowler's (90°) / sit upright; legs dangling; O₂ via NRB mask OR BiPAP/CPAP", ""),
        ("2nd", "IV Furosemide 40–80 mg — DIURETIC (1st line); monitor UO", ""),
        ("3rd", "IV Nitroglycerin infusion — vasodilator (reduces preload); monitor BP closely", ""),
        ("4th", "Morphine 2–4 mg IV (reduces anxiety/preload — use cautiously; monitor RR)", ""),
        ("5th", "Identify & treat cause: STEMI → PCI | HTN → antihypertensives | Arrhythmia → cardioversion", ""),
    ]))
    story.append(sp(4))
    story.append(highlight_box(
        "LMNOP Mnemonic: Lasix (Furosemide) | Morphine | Nitrates | O₂ | Position (upright)",
        bg=colors.HexColor("#EBF5FB"), text_color=C_BLUE))

    story.append(PageBreak())

    # ── Emergency 16: Drowning ────────────────────────────────────────────────
    story.append(section_header("16. DROWNING / NEAR-DROWNING", C_BLUE, "🌊"))
    story.append(sp(3))
    story.append(steps_table([
        ("1st", "Safely remove from water; ensure rescuer safety", ""),
        ("2nd", "Do NOT delay CPR for water drainage — begin immediately if unresponsive/apneic", ""),
        ("3rd", "5 RESCUE BREATHS first (if apneic), then standard CPR 30:2", "Different from standard adult CPR"),
        ("4th", "Remove wet clothes; warm blankets; prevent hypothermia", ""),
        ("5th", "O₂ high flow; prepare for ETT intubation (pulmonary injury/edema likely)", ""),
        ("6th", "Monitor for secondary drowning up to 24 hrs — admit for observation even if asymptomatic", ""),
    ]))
    story.append(sp(8))

    # ── Emergency 17: Spinal Cord Injury ─────────────────────────────────────
    story.append(section_header("17. SPINAL CORD INJURY", C_DARK_GRAY, "⚡"))
    story.append(sp(3))
    story.append(steps_table([
        ("1st", "IMMOBILIZE SPINE immediately — cervical collar + log-roll technique (maintain neutral alignment)", ""),
        ("2nd", "Airway: JAW THRUST ONLY (no head-tilt-chin-lift in cervical spine injury)", ""),
        ("3rd", "Neurogenic shock (vasodilation + bradycardia): IV fluids + Norepinephrine + Atropine", ""),
        ("4th", "MRI spine STAT; Neurosurgical consultation for decompression", ""),
        ("5th", "Foley catheter (urinary retention); Bowel management; Pressure ulcer prevention", ""),
        ("6th", "DVT prophylaxis (LMWH); respiratory support; skin care; psychological support", ""),
    ]))
    story.append(sp(4))
    story.append(highlight_box(
        "Neurogenic shock ≠ Spinal shock: Neurogenic = hemodynamic (hypotension + bradycardia). "
        "Spinal shock = flaccid paralysis below injury level (temporary).",
        bg=colors.HexColor("#F2F3F4"), text_color=C_DARK_GRAY))
    story.append(sp(8))

    # ── Emergency 18: Polytrauma ──────────────────────────────────────────────
    story.append(section_header("18. POLYTRAUMA — ATLS Primary Survey", C_DARK_RED, "🩹"))
    story.append(sp(3))
    atls_data = [
        [Paragraph("<b>Survey</b>", TABLE_HEADER),
         Paragraph("<b>Assessment</b>", TABLE_HEADER),
         Paragraph("<b>Priority Actions</b>", TABLE_HEADER)],
        [Paragraph("A — Airway\n+ C-spine", TABLE_CELL_BOLD),
         Paragraph("Obstruction, stridor, LOC", TABLE_CELL),
         Paragraph("Jaw thrust; suction; oropharyngeal airway; intubate", TABLE_CELL)],
        [Paragraph("B — Breathing", TABLE_CELL_BOLD),
         Paragraph("Tension pneumothorax, open chest, flail chest", TABLE_CELL),
         Paragraph("Needle decompression (2nd ICS MCL); chest seal; O₂", TABLE_CELL)],
        [Paragraph("C — Circulation", TABLE_CELL_BOLD),
         Paragraph("Active hemorrhage, BP, HR, skin perfusion", TABLE_CELL),
         Paragraph("Direct pressure; tourniquet; 2 large-bore IVs; blood products 1:1:1", TABLE_CELL)],
        [Paragraph("D — Disability", TABLE_CELL_BOLD),
         Paragraph("GCS, pupils, motor/sensory", TABLE_CELL),
         Paragraph("GCS calculation; C-spine precautions; glucose check", TABLE_CELL)],
        [Paragraph("E — Exposure", TABLE_CELL_BOLD),
         Paragraph("Hidden wounds, fractures, temperature", TABLE_CELL),
         Paragraph("Log roll; full-body exam; warm blankets (hypothermia prevention)", TABLE_CELL)],
    ]
    atls_t = Table(atls_data, colWidths=[2.5*cm, 4.5*cm, USABLE_W - 7.0*cm])
    atls_t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,0), C_DARK_RED),
        ("ROWBACKGROUNDS",(0,1), (-1,-1), [C_ROW1, C_ROW2]),
        ("GRID",          (0,0), (-1,-1), 0.3, colors.HexColor("#BFC9CA")),
        ("TOPPADDING",    (0,0), (-1,-1), 5), ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING",   (0,0), (-1,-1), 6), ("VALIGN", (0,0), (-1,-1), "TOP"),
    ]))
    story.append(atls_t)
    story.append(sp(4))
    story.append(highlight_box(
        "TENSION PNEUMOTHORAX: Absent breath sounds + tracheal deviation + hypotension + JVD → "
        "IMMEDIATE needle decompression (2nd intercostal space, midclavicular line) — DO NOT wait for X-ray!",
        bg=colors.HexColor("#FDEDEC"), text_color=C_DARK_RED))

    story.append(PageBreak())

    # ── KEY MNEMONICS PAGE ─────────────────────────────────────────────────────
    story.append(section_header("KEY MNEMONICS FOR NCLEX & NORCET AIIMS", C_TEAL, "📝"))
    story.append(sp(5))
    story.append(mnemonic_table([
        ("ABCDE",      "Airway | Breathing | Circulation | Disability | Exposure — Universal primary survey"),
        ("FAST",       "Face drooping | Arm weakness | Speech difficulty | Time → Stroke recognition"),
        ("MONA",       "Morphine | O₂ (if SpO₂ <90%) | Nitroglycerin | Aspirin — Myocardial Infarction"),
        ("LMNOP",      "Lasix | Morphine | Nitrates | O₂ | Position (upright) — Acute pulmonary edema"),
        ("4H 4T",      "Reversible causes of cardiac arrest (see Emergency #1)"),
        ("SBAR",       "Situation | Background | Assessment | Recommendation — Handoff communication"),
        ("SAMPLE",     "Signs/Symptoms | Allergies | Medications | Past history | Last oral intake | Events"),
        ("PPH 4T's",   "Tone (atony) | Tissue (retained placenta) | Trauma (laceration) | Thrombin (coagulopathy)"),
        ("RICE",       "Rest | Ice | Compression | Elevation — Musculoskeletal injury"),
        ("Parkland",   "4 × weight(kg) × %TBSA = mL Lactated Ringer's (½ in first 8 hrs; ½ in next 16 hrs)"),
        ("Rule of 9s", "Head 9% | Each arm 9% | Chest 9% | Abd 9% | Each thigh 9% | Each lower leg 9% | Perineum 1%"),
        ("Rule of 15", "Hypoglycemia: 15g carbs PO → recheck BGL in 15 min → repeat if still <70 mg/dL"),
    ]))
    story.append(sp(10))

    # ── HIGH-YIELD EXAM POINTS ────────────────────────────────────────────────
    story.append(section_header("TOP 15 HIGH-YIELD EXAM POINTS", C_RED, "🔺"))
    story.append(sp(5))
    hiyield = [
        ("1", "EPINEPHRINE is ALWAYS 1st in anaphylaxis — NOT antihistamine (diphenhydramine)"),
        ("2", "tPA is CONTRAINDICATED in hemorrhagic stroke — always confirm with CT first"),
        ("3", "No ASPIRIN in children <18 years (Reye's syndrome risk)"),
        ("4", "Potassium must be ≥3.5 mEq/L BEFORE starting insulin in DKA"),
        ("5", "Thiamine 100 mg IV BEFORE glucose in alcoholics (prevents Wernicke's encephalopathy)"),
        ("6", "NEVER perform LP before CT scan if raised ICP is suspected (herniation risk)"),
        ("7", "CPR ratio: 30:2 adults | 30:2 child (1 rescuer) | 15:2 child (2 rescuers)"),
        ("8", "JAW THRUST (not head-tilt) is used in suspected cervical spine injury"),
        ("9", "Magnesium antidote = Calcium Gluconate — MUST keep at bedside during Mg infusion"),
        ("10", "Urine output target in shock: >0.5 mL/kg/hr | In burns: 0.5–1.0 mL/kg/hr"),
        ("11", "Primary PCI within 90 minutes (door-to-balloon time) for STEMI"),
        ("12", "Oxygen NOT given in COPD if SpO₂ >88–92% (hypercapnic respiratory drive)"),
        ("13", "Trendelenburg is NOT recommended in most shock types (current evidence-based update)"),
        ("14", "Stroke ischemic window: tPA ≤4.5 hrs | Thrombectomy ≤24 hrs (large vessel)"),
        ("15", '"Not dead until WARM and dead" — continue CPR in hypothermia until core temp >32°C'),
    ]
    hy_data = []
    for num, point in hiyield:
        hy_data.append([
            Paragraph(f"<b>{num}</b>", ParagraphStyle("num", fontName="Helvetica-Bold",
                fontSize=9, textColor=C_WHITE, alignment=TA_CENTER, leading=11)),
            Paragraph(point, TABLE_CELL)
        ])
    hy_t = Table(hy_data, colWidths=[0.9*cm, USABLE_W - 0.9*cm])
    hy_t.setStyle(TableStyle([
        ("ROWBACKGROUNDS", (0,0), (-1,-1), [colors.HexColor("#FDEDEC"), colors.HexColor("#FFF3E0")]),
        ("BACKGROUND",     (0,0), (0,-1), C_RED),
        ("GRID",           (0,0), (-1,-1), 0.3, colors.HexColor("#F1948A")),
        ("TOPPADDING",     (0,0), (-1,-1), 5), ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING",    (0,0), (-1,-1), 6), ("VALIGN", (0,0), (-1,-1), "MIDDLE"),
    ]))
    story.append(hy_t)
    story.append(sp(8))

    # ── Nursing Priority Rules ─────────────────────────────────────────────────
    story.append(section_header("NURSING DELEGATION & PRIORITY RULES", C_TEAL, "🏥"))
    story.append(sp(4))
    story.append(mnemonic_table([
        ("Maslow First", "Physiological needs (airway > breathing > circulation) always before safety or psychological needs"),
        ("ABC Rule",     "Airway is ALWAYS first — unless DNR (Do Not Resuscitate) order exists"),
        ("Assess First", "ASSESS before intervening — except cardiac arrest (act immediately)"),
        ("Delegation",   "RN: Assessment, teaching, unstable pts | LPN/LVN: Stable, routine care | UAP: Bathing, stable vitals"),
        ("Priority",     "Acute > Chronic | Unstable > Stable | Life-threatening > Comfort needs"),
        ("Safety",       "Seizure precautions | Fall precautions | Infection control (hand hygiene)"),
    ], bg_color=colors.HexColor("#E8F8F5")))
    story.append(sp(6))
    story.append(Paragraph(
        "<i>Sources: ROSEN's Emergency Medicine • Goldman-Cecil Medicine • Miller's Anesthesia • "
        "ACLS/ATLS/Sepsis Surviving Sepsis Campaign Guidelines • Sabiston Textbook of Surgery</i>",
        SMALL))

    doc.build(story)
    print(f"PDF created: {OUTPUT}")

if __name__ == "__main__":
    build()
Your credits are exhausted. Your daily credits reset tomorrow, or you can purchase a top-up for more.

Try again

Your credits are exhausted. Your daily credits reset tomorrow, or you can purchase a top-up for more.

Generate a Word document with all 18 emergencies

Your credits are exhausted. Your daily credits reset tomorrow, or you can purchase a top-up for more.

Generate a PowerPoint presentation for quick exam review

Your credits are exhausted. Your daily credits reset tomorrow, or you can purchase a top-up for more.

Shut

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.