// ============================================================ // bedside/anaphylaxis.js // ANAPHYLAXIS MANAGEMENT. // ============================================================ import { S } from './shared.js'; function d(wt, mgPerKg, max) { var v = Math.round(wt * mgPerKg * 100) / 100; return max ? Math.min(v, max) : v; } // Lookup a drug entry (by name) from window._DRUGS.sections.anaphylaxis, // falling back to a hardcoded record so rendering stays identical if the // JSON fetch hasn't resolved (or failed). Returns an object exposing the // per-kg + max fields needed by S.dStr. var ANAPH_FALLBACK = { 'Epinephrine IM': { dose_mg_per_kg: 0.01, max_mg: 0.5, unit: 'mg' }, 'Normal saline bolus': { dose_mg_per_kg: 20, max_mg: null, unit: 'mL' }, 'Diphenhydramine': { dose_mg_per_kg: 1.25, max_mg: 50, unit: 'mg' }, 'Ranitidine': { dose_mg_per_kg: 1, max_mg: 50, unit: 'mg' }, 'Dexamethasone': { dose_mg_per_kg: 0.6, max_mg: 16, unit: 'mg' }, 'Methylprednisolone': { dose_mg_per_kg: 2, max_mg: 125, unit: 'mg' }, 'Glucagon': { dose_mg_per_kg: 0.02, max_mg: 1, unit: 'mg' } }; function anaphDrug(name) { var s = window._DRUGS && window._DRUGS.sections && window._DRUGS.sections.anaphylaxis; if (s && s.drugs) { var hit = s.drugs.filter(function(x) { return x.name === name; })[0]; if (hit) return hit; } return ANAPH_FALLBACK[name] || {}; } function calcAnaphylaxis() { var wt = parseFloat(document.getElementById('anaph-weight').value); var age = document.getElementById('anaph-age') ? document.getElementById('anaph-age').value : null; // kept for parity; not currently branched on void age; var resultDiv = document.getElementById('anaph-result'); if (!wt) { resultDiv.innerHTML = '
Enter weight (kg).
'; return; } var epi = anaphDrug('Epinephrine IM'); var fluids = anaphDrug('Normal saline bolus'); var dph = anaphDrug('Diphenhydramine'); var rnt = anaphDrug('Ranitidine'); var dex = anaphDrug('Dexamethasone'); var mpn = anaphDrug('Methylprednisolone'); var glc = anaphDrug('Glucagon'); var epiDose = d(wt, epi.dose_mg_per_kg, epi.max_mg); var epiVol = Math.round(epiDose * 10) / 10; // 1:1000 = 1 mg/mL var autoInjector = wt < 10 ? 'Draw up manually' : wt <= 25 ? 'EpiPen Jr / Auvi-Q 0.15 mg' : 'EpiPen / Auvi-Q 0.3 mg'; var html = '| Step | Drug | Dose | Route | Notes |
|---|---|---|---|---|
| STEP 2 | Position | Supine + legs elevated | — | If dyspneic: sitting position. If vomiting: recovery position |
| STEP 3 | O2 | High flow 10-15 L/min | Face mask | 100% O2. Prepare for airway management |
| STEP 4 | IV fluids | NS ' + S.dStr(wt, fluids.dose_mg_per_kg, fluids.max_mg, ' mL') + ' bolus | IV/IO | Repeat up to 60 mL/kg for hypotension |
| STEP 5 | Diphenhydramine | ' + S.dStr(wt, dph.dose_mg_per_kg, dph.max_mg) + ' | IV/IM/PO | H1 blocker. NOT first-line — adjunct only |
| Ranitidine | ' + S.dStr(wt, rnt.dose_mg_per_kg, rnt.max_mg) + ' | IV over 5 min | H2 blocker. Optional adjunct | |
| STEP 6 | Dexamethasone | ' + S.dStr(wt, dex.dose_mg_per_kg, dex.max_mg) + ' | IV/IM/PO | Prevents biphasic reaction (4-6 hrs later) |
| Methylprednisolone | ' + S.dStr(wt, mpn.dose_mg_per_kg, mpn.max_mg) + ' | IV | Alternative steroid | |
| IF REFRACTORY | Epinephrine gtt | 0.1-1 mcg/kg/min | IV infusion | For persistent hypotension despite fluids + IM epi |
| Glucagon | ' + S.dStr(wt, glc.dose_mg_per_kg, glc.max_mg) + ' | IV/IM | For patients on beta-blockers not responding to epi |
ASCIA Anaphylaxis Guidelines 2021. WAO Anaphylaxis Guidance 2020. AAP/ACAAI Practice Parameters.
'; resultDiv.innerHTML = html; } export function init() { document.addEventListener('click', function(e) { if (e.target.id === 'btn-anaph-calc' || e.target.closest('#btn-anaph-calc')) calcAnaphylaxis(); }); }