// ============================================================
// bedside/ventilation.js
// O2 & VENTILATION (teaching reference).
// ============================================================
import { S } from './shared.js';
function showVent() {
var wt = parseFloat(document.getElementById('vent-weight').value);
var age = parseFloat(document.getElementById('vent-age').value);
var el = document.getElementById('vent-result');
var html = '';
// ── Target SpO2 quick reference ──
html += '
Target SpO2
';
html += '
';
html += '
Patient
Target
Notes
';
html += '
Most children
94-98%
Normal
';
html += '
Bronchiolitis (AAP 2014/2023)
≥90%
Don\'t chase higher saturations
';
html += '
Chronic lung disease / CF
90-94%
Avoid hyperoxia in CO2 retainers
';
html += '
Preterm neonate
90-95%
Minimize ROP risk
';
html += '
Term neonate (min of life)
Per NRP ladder
1 min 60-65%, 10 min 85-95%
';
html += '
';
// ── Escalation ladder ──
html += '
Escalation ladder (step up when target not reached / work of breathing)
';
html += S.stepBox('#10b981',
'1. Nasal cannula (low-flow)',
'0.5-6 L/min · FiO2 ~24-40% (rough: room air 21% + 4% per L/min) · comfortable, no humidification needed. Good for mild hypoxia or baseline support.');
html += S.stepBox('#3b82f6',
'2. Simple face mask',
'6-10 L/min · FiO2 35-60%. Must keep flow >6 L/min to flush CO2. Tolerated less well than NC.');
html += S.stepBox('#8b5cf6',
'3. Non-rebreather mask',
'10-15 L/min · FiO2 60-90%. Reservoir bag must stay inflated. For severe hypoxia with intact breathing.');
html += S.stepBox('#f59e0b',
'4. High-flow nasal cannula (HFNC)',
'' + (wt ? '1-2 L/kg/min = ' + S.d(wt, 1) + '-' + S.d(wt, 2) + ' L/min' : '1-2 L/kg/min') + ' (max ~50-60 L/min adults) · heated + humidified · FiO2 30-100% titratable · generates ~2-5 cmH2O PEEP · works for bronchiolitis, early resp failure. Reassess at 1-2 h — no improvement → step up.');
html += S.stepBox('#ef4444',
'5. Non-invasive ventilation (CPAP / BiPAP)',
'CPAP 5-10 cmH2O (pure PEEP) · BiPAP IPAP 10-14 / EPAP 5 (adds pressure support) · FiO2 as needed. Needs cooperative patient, intact airway reflexes, no copious secretions. Contraindicated: coma, apnea, unstable hemodynamics, facial trauma.');
html += S.stepBox('#dc2626',
'6. Intubate + mechanical ventilation',
'When NIV fails, airway compromised, apnea, or GCS ≤8. See RSI under the Airway tab for drugs.');
// ── BVM how-to ──
html += '
Bag-Valve-Mask (BVM)
';
html += '
';
html += 'When: apnea, bradycardia (HR <60 in neonate; inadequate breathing at any age), during resuscitation. ';
html += 'Rate: Newborn 40-60 /min · Infant-child 20-30 /min · Adolescent 10-12 /min (1 breath q5-6 sec). ';
html += 'Tidal volume: 6-8 mL/kg — only enough to see gentle chest rise. Avoid over-ventilation (gastric distension, ↓venous return, lung injury). ';
html += 'Technique: head tilt / jaw thrust, proper mask seal (E-C grip or 2-thumb), squeeze 1 sec, release fully before next breath. Attach O2 at 10-15 L/min + reservoir. ';
html += 'If not ventilating: MR SOPA — Mask reseal, Reposition airway, Suction mouth+nose, Open mouth, Pressure ↑, Alternative airway (LMA or ETT).';
html += '
';
// ── Mechanical vent settings ──
html += '
Mechanical ventilator — starting settings
';
var rate = age == null ? '' : (age < 0.1 ? '30-40' : age < 1 ? '25-35' : age < 5 ? '20-25' : age < 12 ? '16-20' : '12-16');
html += '
';
html += 'Mode: Volume-control (set TV, get pressure) OR Pressure-control (set pressure, get TV). PRVC / SIMV-PS are hybrids. Pick what your unit uses. ';
html += 'Tidal volume:' + (wt ? S.d(wt, 6) + '-' + S.d(wt, 8) + ' mL' : '6-8 mL/kg') + '(6-8 mL/kg). Use lower (4-6 mL/kg) for ARDS. ';
html += 'Rate: ' + (rate ? rate + ' /min (for age ' + age + ' yr)' : 'Newborn 30-40 · Infant 25-35 · Child 16-20 · Adolescent 12-16') + '. ';
html += 'PEEP: start 5 cmH2O (routine). Increase to 8-12+ for refractory hypoxia (ARDS). ';
html += 'FiO2: start 100%, wean rapidly to lowest that maintains target SpO2 (usually <60%). ';
html += 'I:E ratio: 1:2 normally. 1:3-4 for obstructive disease (asthma, bronchiolitis) to allow exhalation. ';
html += 'Inspiratory time: 0.5 s infant · 0.7-1 s child · 1-1.2 s adolescent. ';
html += 'Pressure limits: keep plateau <30 cmH2O (ideally <28) to avoid barotrauma.';
html += '
';
// ── Pressure-time waveform ──
html += '
Pressure-time waveform (what the monitor shows)
';
html += '
';
html += '';
html += '
PIP = peak pressure during inspiration (depends on TV, airway resistance, lung compliance). Plateau = static pressure at end-inspiration with brief breath-hold (reflects alveolar pressure — keep <30). PEEP = baseline end-expiratory pressure keeping alveoli open. Ti / Te = inspiratory / expiratory time. Rate × (Ti+Te) = 60 s.