// ============================================================ // bedside/seizure.js // SEIZURE MANAGEMENT (status epilepticus pathway). // Keeps its own local `d` + `row` helpers used by the refractory // infusion rendering. // ============================================================ 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; } function row(phase, drug, dose, route, notes) { return '' + phase + '' + drug + '' + dose + '' + route + '' + notes + ''; } // Visual pathway row — time badge + step card linked by vertical line function stepRow(time, color, title, bodyHtml, isLast) { return '
' + '
' + '
' + time + '
' + (isLast ? '' : '
') + '
' + '
' + '
' + title + '
' + '
' + bodyHtml + '
' + '
' + '
'; } // Fallback inline data — mirrors the non-refractory seizure entries in // drugs.json. Refractory infusion drips are kept inline below because // their dose strings (bolus → gtt range) don't map cleanly to the // single-row JSON schema. var SEIZURE_FALLBACK = [ { name: 'Lorazepam', phase: '1st benzo', dose_mg_per_kg: 0.1, max_mg: 4, unit: 'mg', route: 'IV / IO', label_suffix: ' (IV preferred)', notes: 'Slow push over 1-2 min.' }, { name: 'Midazolam', phase: '1st benzo', dose_mg_per_kg: 0.2, max_mg: 10, unit: 'mg', route: 'IM / IN / buccal', notes: 'Use 5 mg/mL concentrate for IN; split between nares.' }, { name: 'Diazepam', phase: '1st benzo', dose_mg_per_kg: 0.5, max_mg: 20, unit: 'mg', route: 'PR', notes: 'Only if no IV/IM/IN access.' }, { name: 'Levetiracetam', phase: '2nd-line', dose_mg_per_kg: 60, max_mg: 4500, unit: 'mg', route: 'IV over 5-15 min', label_suffix: ' (preferred)', notes: 'Best tolerability. No ECG monitoring needed.' }, { name: 'Fosphenytoin', phase: '2nd-line', dose_mg_per_kg: 20, max_mg: 1500, unit: 'mg PE', route: 'IV over 10 min', notes: 'Max rate 3 mg PE/kg/min. Monitor ECG, BP. Avoid if cardiac dysrhythmia.' }, { name: 'Valproic acid', phase: '2nd-line', dose_mg_per_kg: 40, max_mg: 3000, unit: 'mg', route: 'IV over 10 min', notes: 'Avoid <2 yr, hepatic / mitochondrial disease, pregnancy.' }, { name: 'Phenobarbital', phase: '2nd-line', dose_mg_per_kg: 20, max_mg: 1000, unit: 'mg', route: 'IV over 20 min', notes: 'Last-choice 2nd line. High risk of resp depression + hypotension.' } ]; function seizureDrugs() { var s = window._DRUGS && window._DRUGS.sections && window._DRUGS.sections.seizure; if (s && s.drugs && s.drugs.length) { return s.drugs.map(function(dg) { var fb = SEIZURE_FALLBACK.filter(function(x) { return x.name === dg.name; })[0] || {}; return Object.assign({}, fb, dg); }); } return SEIZURE_FALLBACK; } // Build the joined S.drugRow output for one phase ("1st benzo" / "2nd-line"). function seizureRowsByPhase(wt, phase) { return seizureDrugs().filter(function(dg) { return dg.phase === phase; }).map(function(dg) { var label = dg.name + (dg.label_suffix || ''); var unitArg = dg.unit && dg.unit !== 'mg' ? ' ' + dg.unit : undefined; var dose = unitArg ? S.dStr(wt, dg.dose_mg_per_kg, dg.max_mg, unitArg) : S.dStr(wt, dg.dose_mg_per_kg, dg.max_mg); return S.drugRow(label, dose, dg.route, dg.notes); }).join(''); } function calcSeizure() { var wt = parseFloat(document.getElementById('seizure-weight').value); var resultDiv = document.getElementById('seizure-result'); if (!wt) { resultDiv.innerHTML = '

Enter weight (kg).

'; return; } var d10Low = Math.round(wt * 2 * 10) / 10; var d10High = Math.round(wt * 5 * 10) / 10; var html = '
Status Epilepticus Pathway — ' + wt + ' kg
Time = 0 at seizure onset. Do not pause between steps for benzo to take effect — act on the clock.
'; // 0 min — STABILIZE html += stepRow('0 min', '#3b82f6', 'Stabilize', 'ABCs — position, 100% O2 via NC / NRB, suction. IV or IO × 2. Continuous SpO2, ECG, BP. ' + 'POC glucose — if <60 mg/dL: D10W ' + d10Low + '-' + d10High + ' mL IV (2-5 mL/kg). ' + 'Labs: CBC, CMP, Mg, Ca, Phos, VBG, lactate, AED levels, toxicology if unclear etiology. ' + 'Consider pyridoxine 100 mg IV in infants <18 mo or INH ingestion. Temperature: treat hyperthermia aggressively.' ); // 5 min — 1ST BENZO html += stepRow('5 min', '#8b5cf6', '1st benzodiazepine (give once, pick by access)', S.drugTable(seizureRowsByPhase(wt, '1st benzo')) ); // 10 min — 2ND BENZO html += stepRow('10 min', '#a855f7', '2nd benzodiazepine — if still seizing', 'Repeat same agent + dose once. Prepare 2nd-line now (don\'t wait to see if benzo works). If apnea/airway compromise: BVM, consider advanced airway.' ); // 20 min — 2ND-LINE html += stepRow('20 min', '#f59e0b', '2nd-line anti-epileptic — pick one (ESETT: equivalent efficacy)', S.drugTable(seizureRowsByPhase(wt, '2nd-line')) ); // 30 min — 2nd of 2nd-line (optional) html += stepRow('30 min', '#ef4444', 'Still seizing? Consider 2nd agent from 2nd-line OR proceed to refractory', 'If the first 2nd-line drug failed, give a different 2nd-line agent OR move directly to refractory therapy. Activate ICU, prepare for intubation. Confirm etiology not reversible (electrolytes, glucose, fever, toxin).' ); // 40 min — REFRACTORY html += stepRow('40 min', '#dc2626', 'Refractory status — intubate + continuous infusion + continuous EEG', S.drugTable( S.drugRow('Midazolam (1st-line infusion)', 'Bolus ' + d(wt, 0.2, 10) + ' mg → gtt ' + d(wt, 0.05, 2) + '-' + d(wt, 0.5, 18) + ' mg/hr (bolus 0.2 mg/kg, gtt 0.05-0.5 mg/kg/hr)', 'IV', 'Titrate to seizure control / burst suppression.') + S.drugRow('Pentobarbital', 'Bolus ' + d(wt, 5, 200) + ' mg → gtt ' + d(wt, 1, null) + '-' + d(wt, 5, null) + ' mg/hr (bolus 5 mg/kg, gtt 1-5 mg/kg/hr)', 'IV', 'Causes hypotension — often need pressors.') + S.drugRow('Propofol', 'Bolus ' + d(wt, 2, 100) + ' mg → gtt ' + d(wt, 2, null) + '-' + d(wt, 5, null) + ' mg/hr (bolus 2 mg/kg, gtt 2-5 mg/kg/hr)', 'IV', 'PRIS risk in children — limit to <4 mg/kg/hr and duration <48 h.') + S.drugRow('Ketamine', 'Bolus ' + d(wt, 2, 100) + ' mg → gtt ' + d(wt, 1, null) + '-' + d(wt, 5, null) + ' mg/hr (bolus 2 mg/kg, gtt 1-5 mg/kg/hr)', 'IV', 'NMDA antagonist — rescue. Good BP profile; useful if refractory to GABAergics.') ) + '
Continuous EEG within 1 h — target electrographic seizure suppression × 24-48 h, then wean. Reassess etiology: CNS imaging, LP, expanded workup.
' , true); // Key points html += '
Key points
' + '• Do NOT wait for benzo response before starting the 2nd-line — parallel preparation.
' + '• Maximum 2 benzo doses total (1 pre-hospital + 1 in ED, or 2 in ED).
' + '• Respiratory depression is common — have BVM, airway equipment, naloxone, flumazenil accessible (but avoid flumazenil here).
' + '• ESETT trial: levetiracetam = fosphenytoin = valproate for efficacy. Pick by tolerability / contraindications.
' + '• Always reassess: ongoing seizure? Non-convulsive status? Pseudo-seizure? → continuous EEG if any doubt.
'; html += '

Based on AES Guidelines 2016 and ESETT (Kapur et al., NEJM 2019). Verify all doses against institutional protocols.

'; resultDiv.innerHTML = html; } export function init() { document.addEventListener('click', function(e) { if (e.target.id === 'btn-seizure-calc' || e.target.closest('#btn-seizure-calc')) calcSeizure(); }); }