// ============================================================ // 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 += ''; html += ''; html += ''; html += ''; html += ''; html += ''; html += '
PatientTargetNotes
Most children94-98%Normal
Bronchiolitis (AAP 2014/2023)≥90%Don\'t chase higher saturations
Chronic lung disease / CF90-94%Avoid hyperoxia in CO2 retainers
Preterm neonate90-95%Minimize ROP risk
Term neonate (min of life)Per NRP ladder1 min 60-65%, 10 min 85-95%
'; // ── 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 += '' + // grid lines '' + '' + '' + '' + // axes '' + '' + // y-axis tick labels (cmH2O) '30' + '20' + '10' + '5' + '0' + // axis titles 'Time (seconds)' + 'Pressure (cmH₂O)' + // x-axis time markers '0' + '2' + '4' + '6' + // PEEP reference dashed line (y=180 = 5 cmH2O) '' + // Pressure curve — 3 breaths, each 2s (Ti=0.8s, Te=1.2s); 70px/sec; PEEP=5→y=180, PIP=25→y=80, Plateau=22→y=88 '' + // PIP label '' + 'PIP' + 'peak inspiratory' + // Plateau label '' + 'Plateau' + 'reflects alveolar pressure' + // PEEP label '' + 'PEEP' + // Ti bracket (x=90 to 155) '' + '' + '' + 'Ti' + // Te bracket (x=155 to 200) '' + '' + '' + 'Te' + ''; 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.
'; html += '
'; // ── Troubleshooting: "if this, change that" ── html += '
Adjusting for gas exchange
'; html += '
'; html += ''; html += ''; html += ''; html += ''; html += ''; html += ''; html += '
ProblemFirst leverSecond lever
Low SpO2 (oxygenation)↑ FiO2↑ PEEP (recruits collapsed alveoli)
↑ PCO2 (ventilation)↑ Rate↑ Tidal volume
↓ PCO2 (over-ventilating)↓ Rate↓ Tidal volume
High peak pressureCheck tube (kink, mucus plug), compliance, bronchospasmSuction, bronchodilator, lower TV
Auto-PEEP (asthma, bronchiolitis)↓ Rate, ↑ expiratory timeDisconnect + bag briefly if critical
'; // ── Mental model summary ── html += '
Mental model: Oxygenation is mostly FiO2 + PEEP. Ventilation (CO2) is mostly rate + tidal volume. Match mode to disease: obstructive (asthma, bronchiolitis) → long expiratory time, permissive hypercapnia. Restrictive (ARDS) → low TV, high PEEP, permissive hypercapnia + hypoxia.
'; html += S.ref('Based on AAP / PALS / AARC guidance. Tailor to individual patient and institutional protocols.'); el.innerHTML = html; } export function init() { document.addEventListener('click', function(e) { if (e.target.id === 'btn-vent-show' || e.target.closest('#btn-vent-show')) showVent(); }); }