One shell with the current look: indicators, follow-up list and patient view from FHIR; /conectar canvas; /revision; Playwright page tests
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import type { RiskAssessment } from 'fhir/r4';
|
||||
import { ageGroup, currentRisk, windowStart } from './follow-up';
|
||||
import { periods } from './measures';
|
||||
|
||||
describe('follow-up list', () => {
|
||||
it('starts the window the day after the same day months before (core.follow_up)', () => {
|
||||
expect(windowStart('2026-11-22', 3)).toBe('2026-08-23');
|
||||
expect(windowStart('2026-05-31', 3)).toBe('2026-03-01'); // 2026-02-28, plus one
|
||||
expect(windowStart('2026-01-15', 1)).toBe('2025-12-16');
|
||||
});
|
||||
|
||||
it('groups ages at the cut-off, open at both ends', () => {
|
||||
expect(ageGroup('1980-11-23', '2026-11-22')).toBe('45-54');
|
||||
expect(ageGroup('2002-01-01', '2026-11-22')).toBe('<25');
|
||||
expect(ageGroup('1950-01-01', '2026-11-22')).toBe('65+');
|
||||
expect(ageGroup(undefined, '2026-11-22')).toBe('Sin dato');
|
||||
});
|
||||
|
||||
it('takes the latest index date, the highest risk there', () => {
|
||||
const risk = (model: string, at: string, p: number): RiskAssessment => ({
|
||||
resourceType: 'RiskAssessment',
|
||||
status: 'final',
|
||||
subject: {},
|
||||
occurrenceDateTime: at,
|
||||
method: { coding: [{ code: model }] },
|
||||
prediction: [{ probabilityDecimal: p, whenRange: { high: { value: 5 } } }],
|
||||
});
|
||||
const risks = [
|
||||
risk('cacu.cin2_pim', '2025-01-01', 0.9),
|
||||
risk('cacu.cin2_logistic', '2026-01-01', 0.2),
|
||||
risk('cacu.cin2_pim_post_colposcopy', '2026-01-01', 0.3),
|
||||
risk('cacu.cancer_pim', '2026-01-01', 0.05),
|
||||
];
|
||||
expect(currentRisk(risks, 'cin2', 5)).toBe(0.3);
|
||||
expect(currentRisk(risks, 'cancer', 5)).toBe(0.05);
|
||||
expect(currentRisk(risks, 'cin2', 3)).toBeUndefined();
|
||||
});
|
||||
|
||||
it('lists periods most recent first', () => {
|
||||
expect(periods('semester', 1, new Date(2026, 10, 25))).toEqual(['2026-S2', '2026-S1']);
|
||||
expect(periods('month', 1, new Date(2026, 1, 3)).slice(0, 3)).toEqual([
|
||||
'2026-02',
|
||||
'2026-01',
|
||||
'2025-12',
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user