CaCu record: the NCI reference comparison section and probability curves at the published horizons
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
import type { Parameters } from 'fhir/r4';
|
||||
import { horizonLabel, referenceView } from './reference-risk';
|
||||
|
||||
const part = (name: string, extra: object) => ({ name, ...extra }) as any;
|
||||
const answer = (...parameter: object[]): Parameters =>
|
||||
({ resourceType: 'Parameters', parameter }) as Parameters;
|
||||
const resolved = (comparison: object[] = []) =>
|
||||
answer(
|
||||
part('status', { valueCode: 'resolved' }),
|
||||
part('cutoff', { valueDate: '2026-11-30' }),
|
||||
part('scenario', {
|
||||
part: [
|
||||
part('table', { valueCode: 'screening' }),
|
||||
part('label', { valueString: 'Tamizaje' }),
|
||||
part('key', {
|
||||
part: [
|
||||
part('name', { valueCode: 'history' }),
|
||||
part('value', { valueString: 'Cotest-negative' }),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
part('horizon', {
|
||||
part: [
|
||||
part('years', { valueInteger: 0 }),
|
||||
part('published', { valueBoolean: true }),
|
||||
part('reference', { valueDecimal: 0 }),
|
||||
...comparison,
|
||||
],
|
||||
}),
|
||||
part('horizon', {
|
||||
part: [part('years', { valueInteger: 5 }), part('published', { valueBoolean: false })],
|
||||
}),
|
||||
);
|
||||
|
||||
describe('the reference answer as the section shows it', () => {
|
||||
it('names the horizons and never calls a year the immediate risk', () => {
|
||||
expect(horizonLabel(0)).toBe('Inmediato (al índice)');
|
||||
expect(horizonLabel(1)).toBe('1 año');
|
||||
expect(horizonLabel(5)).toBe('5 años');
|
||||
});
|
||||
it('keeps a published zero as zero and a blank as absent', () => {
|
||||
const view = referenceView(resolved());
|
||||
expect(view.horizons.map((h) => [h.years, h.reference, h.published])).toEqual([
|
||||
[0, 0, true],
|
||||
[5, undefined, false],
|
||||
]);
|
||||
expect(view.scenario).toEqual({
|
||||
label: 'Tamizaje',
|
||||
keys: [{ name: 'Antecedente más reciente', value: 'Cotest-negative' }],
|
||||
});
|
||||
});
|
||||
it('reads a comparison with its model, its figures and its reasons, and a difference only when one is given', () => {
|
||||
const view = referenceView(
|
||||
resolved([
|
||||
part('comparison', {
|
||||
part: [
|
||||
part('model', { valueCode: 'cacu.cin2_pim' }),
|
||||
part('title', { valueString: 'Riesgo LIEAG+' }),
|
||||
part('institutional', { valueDecimal: 0.05 }),
|
||||
part('status', { valueCode: 'not_comparable' }),
|
||||
part('reason', { valueCode: 'outcome_differs' }),
|
||||
],
|
||||
}),
|
||||
]),
|
||||
);
|
||||
const [c] = view.horizons[0].comparisons;
|
||||
expect(c).toMatchObject({
|
||||
model: 'cacu.cin2_pim',
|
||||
institutional: 0.05,
|
||||
status: 'not_comparable',
|
||||
reasons: ['outcome_differs'],
|
||||
});
|
||||
expect(c.differencePp).toBeUndefined();
|
||||
});
|
||||
it('an unresolved answer has its state and reasons and no horizons', () => {
|
||||
const view = referenceView(
|
||||
answer(
|
||||
part('status', { valueCode: 'history_not_demonstrable' }),
|
||||
part('reason', { valueCode: 'no_earlier_test_registered' }),
|
||||
),
|
||||
);
|
||||
expect(view).toMatchObject({
|
||||
status: 'history_not_demonstrable',
|
||||
reasons: ['no_earlier_test_registered'],
|
||||
horizons: [],
|
||||
used: [],
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user