// ============================================================ // 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 = '
'; html += '
STEP 1: Epinephrine IM — GIVE IMMEDIATELY
'; html += '
Epinephrine 1:1000 (1 mg/mL): ' + epiDose + ' mg (' + epiVol + ' mL) IM to lateral thigh
'; html += '
' + epi.dose_mg_per_kg + ' mg/kg (max ' + epi.max_mg + ' mg) | Auto-injector: ' + autoInjector + '
'; html += '
May repeat every 5-15 minutes if symptoms persist. No contraindications in anaphylaxis.
'; html += '
'; html += '
'; html += ''; html += ''; html += ''; html += ''; html += ''; html += ''; html += ''; html += ''; html += ''; html += '
StepDrugDoseRouteNotes
STEP 2PositionSupine + legs elevatedIf dyspneic: sitting position. If vomiting: recovery position
STEP 3O2High flow 10-15 L/minFace mask100% O2. Prepare for airway management
STEP 4IV fluidsNS ' + S.dStr(wt, fluids.dose_mg_per_kg, fluids.max_mg, ' mL') + ' bolusIV/IORepeat up to 60 mL/kg for hypotension
STEP 5Diphenhydramine' + S.dStr(wt, dph.dose_mg_per_kg, dph.max_mg) + 'IV/IM/POH1 blocker. NOT first-line — adjunct only
Ranitidine' + S.dStr(wt, rnt.dose_mg_per_kg, rnt.max_mg) + 'IV over 5 minH2 blocker. Optional adjunct
STEP 6Dexamethasone' + S.dStr(wt, dex.dose_mg_per_kg, dex.max_mg) + 'IV/IM/POPrevents biphasic reaction (4-6 hrs later)
Methylprednisolone' + S.dStr(wt, mpn.dose_mg_per_kg, mpn.max_mg) + 'IVAlternative steroid
IF REFRACTORYEpinephrine gtt0.1-1 mcg/kg/minIV infusionFor persistent hypotension despite fluids + IM epi
Glucagon' + S.dStr(wt, glc.dose_mg_per_kg, glc.max_mg) + 'IV/IMFor patients on beta-blockers not responding to epi
'; html += '
Observe minimum 4-6 hours after last dose of epinephrine (biphasic reactions occur in 5-20% of cases). Discharge with EpiPen prescription and anaphylaxis action plan. Refer to allergist.
'; html += '

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(); }); }