47 lines
1.5 KiB
JavaScript
47 lines
1.5 KiB
JavaScript
const { test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
function loadVitals() {
|
|
const raw = fs.readFileSync(path.join(__dirname, '..', 'public', 'data', 'calculators', 'vitals.json'), 'utf8');
|
|
return JSON.parse(raw);
|
|
}
|
|
|
|
test('vitals.json exposes all calculator age groups', () => {
|
|
const data = loadVitals();
|
|
assert.equal(data.version, '1.0');
|
|
assert.deepEqual(Object.keys(data.ageGroups), [
|
|
'premie',
|
|
'0-3mo',
|
|
'3-6mo',
|
|
'6-12mo',
|
|
'1-3yr',
|
|
'3-6yr',
|
|
'6-12yr',
|
|
'>12yr'
|
|
]);
|
|
});
|
|
|
|
test('vitals.json preserves key Harriet Lane ranges', () => {
|
|
const groups = loadVitals().ageGroups;
|
|
assert.equal(groups.premie.hr.awake, '120-170');
|
|
assert.equal(groups.premie.spo2, '88-95% (target)');
|
|
assert.equal(groups['0-3mo'].sbp, '65-85');
|
|
assert.equal(groups['3-6mo'].rr, '30-45');
|
|
assert.equal(groups['1-3yr'].weight, '10-15 kg');
|
|
assert.equal(groups['6-12yr'].hr.sleeping, '50-85');
|
|
assert.equal(groups['>12yr'].dbp, '65-85');
|
|
});
|
|
|
|
test('vitals.json entries have complete renderable fields', () => {
|
|
const groups = loadVitals().ageGroups;
|
|
Object.entries(groups).forEach(([key, group]) => {
|
|
assert.ok(group.label, `${key}.label`);
|
|
assert.ok(group.hr && group.hr.awake && group.hr.sleeping, `${key}.hr`);
|
|
['rr', 'sbp', 'dbp', 'temp', 'weight', 'spo2'].forEach((field) => {
|
|
assert.ok(group[field], `${key}.${field}`);
|
|
});
|
|
assert.ok(Array.isArray(group.notes) && group.notes.length > 0, `${key}.notes`);
|
|
});
|
|
});
|