remove legacy well visit schedule data
This commit is contained in:
parent
e731780c7b
commit
df87d93306
3 changed files with 23 additions and 2142 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -10,15 +10,15 @@ var { authMiddleware } = require('../middleware/auth');
|
||||||
var logger = require('../utils/logger');
|
var logger = require('../utils/logger');
|
||||||
var { wrapUserText, INJECTION_GUARD } = require('../utils/promptSafe');
|
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;
|
var scheduleData;
|
||||||
try {
|
try {
|
||||||
scheduleData = require('../../public/js/pediatricScheduleData');
|
scheduleData = require('../../public/data/well-visit/schedule.json');
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
scheduleData = {};
|
scheduleData = {};
|
||||||
}
|
}
|
||||||
var GROWTH_REFERENCE = scheduleData.GROWTH_REFERENCE || {};
|
var GROWTH_REFERENCE = scheduleData.growthReference || {};
|
||||||
var BMI_CLASSIFICATION = scheduleData.BMI_CLASSIFICATION || {};
|
var BMI_CLASSIFICATION = scheduleData.bmiClassification || {};
|
||||||
|
|
||||||
// Map visit age text to GROWTH_REFERENCE keys
|
// Map visit age text to GROWTH_REFERENCE keys
|
||||||
function getGrowthRefForAge(ageStr) {
|
function getGrowthRefForAge(ageStr) {
|
||||||
|
|
|
||||||
|
|
@ -8,27 +8,22 @@ function loadScheduleJson() {
|
||||||
return JSON.parse(raw);
|
return JSON.parse(raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadLegacyScheduleData() {
|
test('schedule.json exposes complete well-visit schedule data', () => {
|
||||||
return require('../public/js/pediatricScheduleData.js');
|
|
||||||
}
|
|
||||||
|
|
||||||
test('schedule.json exactly mirrors existing pediatric schedule constants', () => {
|
|
||||||
const json = loadScheduleJson();
|
const json = loadScheduleJson();
|
||||||
const legacy = loadLegacyScheduleData();
|
|
||||||
|
|
||||||
assert.equal(json.version, '2025.1');
|
assert.equal(json.version, '2025.1');
|
||||||
assert.deepEqual(json.visitAges, legacy.VISIT_AGES);
|
assert.ok(Array.isArray(json.visitAges));
|
||||||
assert.deepEqual(json.wellVisitCodes, legacy.WELL_VISIT_CODES);
|
assert.ok(json.wellVisitCodes && json.wellVisitCodes['2mo']);
|
||||||
assert.deepEqual(json.vaccines, legacy.VACCINES);
|
assert.ok(json.vaccines && json.vaccines.DTaP);
|
||||||
assert.deepEqual(json.periodicity, legacy.PERIODICITY);
|
assert.ok(json.periodicity && json.periodicity['12mo']);
|
||||||
assert.deepEqual(json.catchUpSchedule, legacy.CATCH_UP_SCHEDULE);
|
assert.ok(json.catchUpSchedule && json.catchUpSchedule.DTaP);
|
||||||
assert.deepEqual(json.anticipatoryGuidance, legacy.ANTICIPATORY_GUIDANCE);
|
assert.ok(json.anticipatoryGuidance && json.anticipatoryGuidance.newborn_to_1mo);
|
||||||
assert.deepEqual(json.aapFootnotes, legacy.AAP_FOOTNOTES);
|
assert.ok(json.aapFootnotes && json.aapFootnotes['1']);
|
||||||
assert.deepEqual(json.dyslipidemiaSchedule, legacy.DYSLIPIDEMIA_SCHEDULE);
|
assert.ok(json.dyslipidemiaSchedule && json.dyslipidemiaSchedule.universal);
|
||||||
assert.deepEqual(json.newbornScreening, legacy.NEWBORN_SCREENING);
|
assert.ok(json.newbornScreening && json.newbornScreening.mandatoryComponents);
|
||||||
assert.deepEqual(json.growthReference, legacy.GROWTH_REFERENCE);
|
assert.ok(json.growthReference && json.growthReference['2mo']);
|
||||||
assert.deepEqual(json.reflexesReference, legacy.REFLEXES_REFERENCE);
|
assert.ok(json.reflexesReference && json.reflexesReference.newborn);
|
||||||
assert.deepEqual(json.bmiClassification, legacy.BMI_CLASSIFICATION);
|
assert.ok(json.bmiClassification && Array.isArray(json.bmiClassification.categories));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('schedule.json preserves expected well-visit anchors', () => {
|
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.match(indexHtml, /<script type="module" src="\/js\/wellVisit\.js"><\/script>/);
|
||||||
assert.doesNotMatch(indexHtml, /src="\/js\/pediatricScheduleData\.js"/);
|
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/);
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue