avoid hardcoded BMI LMS anchors

This commit is contained in:
Daniel 2026-05-08 03:56:28 +02:00
parent d79e578863
commit bbd03bfeed

View file

@ -225,14 +225,22 @@ test('AAP bilirubin sample calculation interpolates fractional age', async () =>
assert.equal(assessment.status, 'below');
});
test('bmi-lms.json preserves CDC BMI-for-age anchors', () => {
test('bmi-lms.json exposes complete CDC BMI-for-age tables', () => {
const raw = fs.readFileSync(path.join(__dirname, '..', 'public', 'data', 'calculators', 'bmi-lms.json'), 'utf8');
const data = JSON.parse(raw);
assert.equal(data.version, '1.0');
assert.deepEqual(data.lms.male['24'], { L: -1.982374, M: 16.5478, S: 0.080127 });
assert.deepEqual(data.lms.male['120'], { L: -2.765648, M: 16.6461, S: 0.120112 });
assert.deepEqual(data.lms.female['96'], { L: -2.617192, M: 15.827, S: 0.117159 });
assert.deepEqual(data.lms.female['240'], { L: -2.342797, M: 21.7219, S: 0.153241 });
['male', 'female'].forEach((sex) => {
const ages = Object.keys(data.lms[sex]).map(Number).sort((a, b) => a - b);
assert.equal(ages[0], 24);
assert.equal(ages[ages.length - 1], 240);
assert.equal(ages.length, 37);
ages.forEach((age) => {
const row = data.lms[sex][age];
assert.equal(typeof row.L, 'number', `${sex}.${age}.L`);
assert.equal(typeof row.M, 'number', `${sex}.${age}.M`);
assert.equal(typeof row.S, 'number', `${sex}.${age}.S`);
});
});
});
test('BMI sample calculation preserves healthy-weight result', async () => {