diff --git a/public/js/bedside/respiratory.js b/public/js/bedside/respiratory.js index 499125b..d103c07 100644 --- a/public/js/bedside/respiratory.js +++ b/public/js/bedside/respiratory.js @@ -10,8 +10,17 @@ import { S } from './shared.js'; function dose(wt, mgPerKg, maxMg) { var d = Math.round(wt * mgPerKg * 10) / 10; return maxMg ? Math.min(d, maxMg) : d; } // Delegates to the shared S.dStr so the per-kg math is visible to the prescriber. function doseStr(wt, mgPerKg, maxMg, unit) { + if (!wt) { + unit = unit || ' mg'; + var uTrim = unit.trim() || 'mg'; + return mgPerKg + ' ' + uTrim + '/kg' + (maxMg != null ? ' (max ' + maxMg + ' ' + uTrim + ')' : ''); + } return S.dStr(wt, mgPerKg, maxMg, unit); } +function ipratropiumDose(wt) { + if (!wt) return '250 mcg (<20 kg) or 500 mcg (≥20 kg)'; + return wt < 20 ? '250 mcg' : '500 mcg'; +} function drugRow(name, doseText, route, notes) { return '
Speaks in phrases, some accessory muscle use, SpO2 90-93%
'; html += drugTable( drugRow('Albuterol (neb)', doseStr(wt, 0.15, 5, ' mg') + ' (min 2.5 mg)', 'Nebulized', 'q20min x 3 doses, then continuous if needed') + - drugRow('Ipratropium', wt < 20 ? '250 mcg' : '500 mcg', 'Nebulized', 'q20min x 3 doses with albuterol') + + drugRow('Ipratropium', ipratropiumDose(wt), 'Nebulized', 'q20min x 3 doses with albuterol') + drugRow('Dexamethasone', doseStr(wt, 0.6, 16), 'PO/IV/IM', 'Single dose') + drugRow('O2 supplemental', 'Target SpO2 ≥94%', 'Nasal cannula/mask', 'Titrate to effect') ); @@ -51,7 +59,7 @@ function asthmaManagement(severity) { html += 'Speaks in words only, significant accessory muscle use, SpO2 <90%. Consider ICU.
'; html += drugTable( drugRow('Albuterol continuous', doseStr(wt, 0.5, 20, ' mg') + '/hr', 'Continuous neb', 'Or 0.15-0.3 mg/kg q20min') + - drugRow('Ipratropium', wt < 20 ? '250 mcg' : '500 mcg', 'Nebulized', 'q20min x 3 doses with albuterol') + + drugRow('Ipratropium', ipratropiumDose(wt), 'Nebulized', 'q20min x 3 doses with albuterol') + drugRow('Dexamethasone', doseStr(wt, 0.6, 16), 'IV', 'Or methylprednisolone 2 mg/kg IV (max 60 mg)') + drugRow('Magnesium sulfate', doseStr(wt, 50, 2000) + ' IV over 20 min', 'IV', 'Single dose, monitor BP') + drugRow('Epinephrine (IM)', doseStr(wt, 0.01, 0.5) + ' (1:1000)', 'IM', 'If impending arrest / no IV access') + diff --git a/test/bedside-respiratory-ventilation.test.js b/test/bedside-respiratory-ventilation.test.js new file mode 100644 index 0000000..9c1ac92 --- /dev/null +++ b/test/bedside-respiratory-ventilation.test.js @@ -0,0 +1,22 @@ +const { test } = require('node:test'); +const assert = require('node:assert/strict'); +const fs = require('node:fs'); +const path = require('node:path'); + +const root = path.join(__dirname, '..'); + +function read(relativePath) { + return fs.readFileSync(path.join(root, relativePath), 'utf8'); +} + +test('Bedside respiratory and ventilation references render without requiring weight', () => { + const respiratory = read('public/js/bedside/respiratory.js'); + const ventilation = read('public/js/bedside/ventilation.js'); + + assert.doesNotMatch(respiratory, /Enter weight \(kg\)/); + assert.match(respiratory, /function ipratropiumDose\(wt\)/); + assert.match(respiratory, /return mgPerKg \+ ' ' \+ uTrim \+ '\/kg'/); + assert.match(ventilation, /wt \? '1-2 L\/kg\/min = '/); + assert.match(ventilation, /: '1-2 L\/kg\/min'/); + assert.match(ventilation, /wt \? S\.d\(wt, 6\) \+ '-' \+ S\.d\(wt, 8\) \+ ' mL' : '6-8 mL\/kg'/); +});