// ============================================================
// bedside/airway.js
// AIRWAY / RSI.
// ============================================================
import { S } from './shared.js';
function calcAirway() {
var wt = parseFloat(document.getElementById('airway-weight').value);
var age = parseFloat(document.getElementById('airway-age').value);
var el = document.getElementById('airway-result');
if (!wt) { el.innerHTML = '
Enter weight (kg).
'; return; }
// Equipment sizing
var ettUncuff = age ? Math.round(((age/4) + 4) * 2) / 2 : null;
var ettCuff = age ? Math.round(((age/4) + 3.5) * 2) / 2 : null;
var ettDepth = ettUncuff ? Math.round(ettUncuff * 3 * 10) / 10 : null;
var bladeSize = age != null ? (age < 1 ? 'Miller 0-1' : age < 2 ? 'Miller 1 / Mac 1' : age < 8 ? 'Miller 2 / Mac 2' : 'Miller/Mac 3') : '—';
var lmaSize = wt < 5 ? '1' : wt < 10 ? '1.5' : wt < 20 ? '2' : wt < 30 ? '2.5' : wt < 50 ? '3' : wt < 70 ? '4' : '5';
var html = 'RSI doses & equipment — ' + wt + ' kg' + (age ? ', ~' + age + ' yr' : '') + '
';
// Pre-medication
html += 'Pre-medication (optional)
';
html += S.drugTable(
S.drugRow('Atropine', S.dStr(wt, 0.02, 1, ' mg') + ' (min 0.1 mg)', 'IV', 'Consider <1 yr or if using succinylcholine, or bradycardia risk') +
S.drugRow('Lidocaine 2%', S.dStr(wt, 1.5, 100, ' mg'), 'IV over 1 min', 'For ↑ICP, asthma; give 2-3 min pre-induction') +
S.drugRow('Fentanyl', S.dStr(wt, 2, 150, ' mcg') + ' (2-3 mcg/kg)', 'IV over 1 min', 'Blunts sympathetic response; avoid if hypotensive')
);
// Induction
html += 'Induction
';
html += S.drugTable(
S.drugRow('Ketamine', S.dStr(wt, 1.5, 150, ' mg') + ' (1-2 mg/kg)', 'IV', 'Preserves BP. First-line for shock, asthma, sepsis') +
S.drugRow('Etomidate', S.dStr(wt, 0.3, 30, ' mg'), 'IV', 'Hemodynamically neutral. Avoid in septic shock (adrenal suppression)') +
S.drugRow('Propofol', S.dStr(wt, 2, 200, ' mg') + ' (1-2 mg/kg)', 'IV', 'Causes hypotension. Avoid in shock') +
S.drugRow('Midazolam', S.dStr(wt, 0.2, 10, ' mg'), 'IV', 'Less optimal induction — slower onset')
);
// Paralytics
html += 'Paralytics
';
html += S.drugTable(
S.drugRow('Rocuronium', S.dStr(wt, 1.2, 100, ' mg') + ' (1-1.2 mg/kg)', 'IV', '30-60 sec onset; 30-45 min duration. First-line non-depolarizing.') +
S.drugRow('Succinylcholine', S.dStr(wt, (wt < 10 ? 2 : 1.5), 150, ' mg'), 'IV', '<10kg: 2 mg/kg; ≥10kg: 1.5 mg/kg. Avoid in burns/crush/hyperK/MH/NM dz. IM option: 4 mg/kg.') +
S.drugRow('Vecuronium', S.dStr(wt, 0.1, 10, ' mg'), 'IV', '2-3 min onset; longer duration than roc')
);
// Post-intubation sedation
html += 'Maintenance sedation / analgesia
';
html += S.drugTable(
S.drugRow('Midazolam gtt', S.dStr(wt, 0.05, 2, ' mg') + '-' + S.dStr(wt, 0.2, 10, ' mg') + '/hr', 'IV infusion', '0.05-0.2 mg/kg/hr') +
S.drugRow('Fentanyl gtt', S.dStr(wt, 1, 100, ' mcg') + '-' + S.dStr(wt, 4, 200, ' mcg') + '/hr', 'IV infusion', '1-4 mcg/kg/hr') +
S.drugRow('Ketamine gtt', S.dStr(wt, 0.5, 30, ' mg') + '-' + S.dStr(wt, 2, 100, ' mg') + '/hr', 'IV infusion', '0.5-2 mg/kg/hr. Good for asthma') +
S.drugRow('Dexmedetomidine gtt', '0.2-1.4 mcg/kg/hr', 'IV infusion', 'No resp depression; causes bradycardia + hypotension') +
S.drugRow('Rocuronium gtt', '10-12 mcg/kg/min', 'IV infusion', 'If continued paralysis needed — only with adequate sedation')
);
// Equipment
html += 'Equipment sizing
';
html += '';
if (age != null) {
html += '
ETT (uncuffed): ' + ettUncuff + ' mm
ETT (cuffed): ' + ettCuff + ' mm
Depth at lip: ~' + ettDepth + ' cm
';
html += '
Laryngoscope blade:
' + bladeSize + '
';
} else {
html += '
Enter age for ETT/blade sizing.
ETT (uncuffed) = (age/4) + 4
ETT (cuffed) = (age/4) + 3.5
Depth = ETT size × 3
';
}
html += '
LMA size: ' + lmaSize + '
OPA = corner mouth → angle mandible
NPA = tip nose → tragus
';
html += '
Suction catheter (Fr): ETT size × 2
NG tube: ETT × 2
Chest tube: 4 × ETT
';
html += '
';
// Ventilator starting settings
html += 'Ventilator — starting settings
';
html += '';
html += 'Mode: Volume or pressure control
';
html += 'Tidal volume: 6-8 mL/kg (= ' + S.d(wt, 6) + '-' + S.d(wt, 8) + ' mL). Use lower (4-6 mL/kg) for ARDS.
';
html += 'Rate: Infant 25-30, Child 15-25, Adolescent 12-16
';
html += 'PEEP: 5 cmH2O (↑ for oxygenation problems)
';
html += 'FiO2: Start 100%, wean to SpO2 92-97%
';
html += 'I:E ratio: 1:2 (1:3-4 for obstructive disease)';
html += '
';
html += S.ref('Harriet Lane Handbook 23rd ed / PALS 2020. Always confirm doses against institutional protocols.');
el.innerHTML = html;
}
export function init() {
document.addEventListener('click', function(e) {
if (e.target.id === 'btn-airway-calc' || e.target.closest('#btn-airway-calc')) calcAirway();
});
}