remove legacy well visit schedule data

This commit is contained in:
Daniel 2026-05-08 08:59:23 +02:00
parent e731780c7b
commit df87d93306
3 changed files with 23 additions and 2142 deletions

File diff suppressed because it is too large Load diff

View file

@ -10,15 +10,15 @@ var { authMiddleware } = require('../middleware/auth');
var logger = require('../utils/logger');
var { wrapUserText, INJECTION_GUARD } = require('../utils/promptSafe');
// Load growth reference and BMI classification data
// Load growth reference and BMI classification data from the same JSON used by the browser.
var scheduleData;
try {
scheduleData = require('../../public/js/pediatricScheduleData');
scheduleData = require('../../public/data/well-visit/schedule.json');
} catch(e) {
scheduleData = {};
}
var GROWTH_REFERENCE = scheduleData.GROWTH_REFERENCE || {};
var BMI_CLASSIFICATION = scheduleData.BMI_CLASSIFICATION || {};
var GROWTH_REFERENCE = scheduleData.growthReference || {};
var BMI_CLASSIFICATION = scheduleData.bmiClassification || {};
// Map visit age text to GROWTH_REFERENCE keys
function getGrowthRefForAge(ageStr) {

View file

@ -8,27 +8,22 @@ function loadScheduleJson() {
return JSON.parse(raw);
}
function loadLegacyScheduleData() {
return require('../public/js/pediatricScheduleData.js');
}
test('schedule.json exactly mirrors existing pediatric schedule constants', () => {
test('schedule.json exposes complete well-visit schedule data', () => {
const json = loadScheduleJson();
const legacy = loadLegacyScheduleData();
assert.equal(json.version, '2025.1');
assert.deepEqual(json.visitAges, legacy.VISIT_AGES);
assert.deepEqual(json.wellVisitCodes, legacy.WELL_VISIT_CODES);
assert.deepEqual(json.vaccines, legacy.VACCINES);
assert.deepEqual(json.periodicity, legacy.PERIODICITY);
assert.deepEqual(json.catchUpSchedule, legacy.CATCH_UP_SCHEDULE);
assert.deepEqual(json.anticipatoryGuidance, legacy.ANTICIPATORY_GUIDANCE);
assert.deepEqual(json.aapFootnotes, legacy.AAP_FOOTNOTES);
assert.deepEqual(json.dyslipidemiaSchedule, legacy.DYSLIPIDEMIA_SCHEDULE);
assert.deepEqual(json.newbornScreening, legacy.NEWBORN_SCREENING);
assert.deepEqual(json.growthReference, legacy.GROWTH_REFERENCE);
assert.deepEqual(json.reflexesReference, legacy.REFLEXES_REFERENCE);
assert.deepEqual(json.bmiClassification, legacy.BMI_CLASSIFICATION);
assert.ok(Array.isArray(json.visitAges));
assert.ok(json.wellVisitCodes && json.wellVisitCodes['2mo']);
assert.ok(json.vaccines && json.vaccines.DTaP);
assert.ok(json.periodicity && json.periodicity['12mo']);
assert.ok(json.catchUpSchedule && json.catchUpSchedule.DTaP);
assert.ok(json.anticipatoryGuidance && json.anticipatoryGuidance.newborn_to_1mo);
assert.ok(json.aapFootnotes && json.aapFootnotes['1']);
assert.ok(json.dyslipidemiaSchedule && json.dyslipidemiaSchedule.universal);
assert.ok(json.newbornScreening && json.newbornScreening.mandatoryComponents);
assert.ok(json.growthReference && json.growthReference['2mo']);
assert.ok(json.reflexesReference && json.reflexesReference.newborn);
assert.ok(json.bmiClassification && Array.isArray(json.bmiClassification.categories));
});
test('schedule.json preserves expected well-visit anchors', () => {
@ -81,3 +76,9 @@ test('index loads wellVisit as a module without the legacy schedule data script'
assert.match(indexHtml, /<script type="module" src="\/js\/wellVisit\.js"><\/script>/);
assert.doesNotMatch(indexHtml, /src="\/js\/pediatricScheduleData\.js"/);
});
test('server well-visit route reads schedule JSON instead of legacy browser data file', () => {
const source = fs.readFileSync(path.join(__dirname, '..', 'src', 'routes', 'wellVisit.js'), 'utf8');
assert.match(source, /public\/data\/well-visit\/schedule\.json/);
assert.doesNotMatch(source, /pediatricScheduleData/);
});