// ============================================================ // bedside/shared.js // Shared string-building helpers used by every Bedside section. // Pure functions with no side effects. Exports `S`; also sets // window._EM = S for back-compat with any stray lookups. // ============================================================ export const S = { d: function(wt, perKg, max) { var v = Math.round(wt * perKg * 100) / 100; return max ? Math.min(v, max) : v; }, // Dose string — always shows the per-kg used (and max when capped), so the // prescriber can verify the math without opening a drug ref. // S.dStr(30, 0.1, 4) → "3 mg (0.1 mg/kg, max 4 mg)" // S.dStr(60, 0.1, 4) → "4 mg (0.1 mg/kg, max 4 mg · capped)" // S.dStr(20, 2, 150, ' mcg') → "40 mcg (2 mcg/kg, max 150 mcg)" dStr: function(wt, perKg, max, unit) { unit = unit || ' mg'; var uTrim = unit.trim() || 'mg'; var raw = wt * perKg; var v = Math.round(raw * 100) / 100; var capped = max != null && v > max; var val = capped ? max : v; var perKgStr = '(' + perKg + ' ' + uTrim + '/kg'; if (max != null) perKgStr += ', max ' + max + ' ' + uTrim; if (capped) perKgStr += ' · capped'; perKgStr += ')'; return val + unit + ' ' + perKgStr + ''; }, drugTable: function(rows) { return '
' + rows + '
DrugDoseRouteNotes
'; }, drugRow: function(name, dose, route, notes) { return '' + name + '' + dose + '' + route + '' + (notes || '') + ''; }, stepBox: function(color, title, body) { return '
' + '
' + title + '
' + '
' + body + '
'; }, arrow: '
', badge: function(label, color) { return '' + label + ''; }, ref: function(text) { return '

' + text + '

'; } }; if (typeof window !== 'undefined') window._EM = S;