Files
WebApp/src/app/ados2.spec.ts
T
alberto 414fb60f33 F7a: ADOS-2 scoring from the manual algorithm sheets
Algorithm scores 0, 1, 2, 3 -> 0, 1, 2, 2 and 7, 8, 9 -> 0, with the Toddler
B-1 exception (1 -> 2). The algorithm column comes from completed months and
item A-1 (new catalog field language_level): Toddler 12-20 months few words,
21-30 by A-1; Module 1 by A-1; Module 2 under five or not. The total adds only
the column's items. Classification from the manual's total cuts; Toddler CSS
from Esler 2015 table 3; Modules 1-2 CSS from the manual's comparison tables
(test transcription, in code for now). Module 3 is not scored (no items in
the ADOS-2 list). Labels non_tea / autism_spectrum / autism and little_or_no /
mild_to_moderate / moderate_to_severe concern. A-1 travels to FHIR, follow-up
(ados2_language_level), association input, synthetic hospital, pipelines and
the Gobernanza preview. Ported from the tea library 0.4.0 (patches 0001/0002).
2026-12-03 21:13:24 -06:00

103 lines
3.1 KiB
TypeScript

import type { Observation, ObservationComponent } from 'fhir/r4';
import { describe, expect, it } from 'vitest';
import { ados2Component, ados2Groups } from './ados2';
import { EXT } from './fhir';
function item(
field: string,
domain: string,
subdomain: string,
code: string,
title: string,
value?: number,
): ObservationComponent {
return {
code: {
coding: [{ code: `ados2.${field}` }, { code, display: title }],
text: title,
},
extension: [
{ url: EXT + 'ados2-domain', valueCoding: { code: domain[0], display: domain } },
{ url: EXT + 'ados2-subdomain', valueCoding: { code: subdomain, display: subdomain } },
],
valueQuantity: value == null ? undefined : { value },
};
}
const AS = 'Afectación social (AS)';
const CRR = 'Comportamiento restringido y repetitivo (CRR)';
const observation: Observation = {
resourceType: 'Observation',
status: 'final',
code: { coding: [{ code: 'ados2' }] },
component: [
{ code: { coding: [{ code: 'ados2.module' }] }, valueCodeableConcept: { text: 'Módulo 1' } },
{ code: { coding: [{ code: 'ados2.language_level' }] }, valueQuantity: { value: 3 } },
item('pointing', AS, 'Comunicación', 'A-7', 'Señalar', 2),
item('gestures', AS, 'Comunicación', 'A-8', 'Gestos', 1),
item(
'unusual_eye_contact',
AS,
'Interacción social recíproca',
'B-1',
'Contacto visual inusual',
),
item(
'intonation',
CRR,
'Comportamientos restringidos y repetitivos',
'A-3',
'Entonación de las vocalizaciones o verbalizaciones',
3,
),
{ code: { coding: [{ code: 'ados2.response_to_name' }] } },
],
};
describe('Ítems del ADOS-2', () => {
it('agrupa los ítems del módulo por dominio y subdominio en su orden', () => {
expect(ados2Groups(observation)).toEqual([
{
domain: AS,
subdomains: [
{
subdomain: 'Comunicación',
items: [
{ code: 'A-7', title: 'Señalar', score: 2 },
{ code: 'A-8', title: 'Gestos', score: 1 },
],
},
{
subdomain: 'Interacción social recíproca',
items: [{ code: 'B-1', title: 'Contacto visual inusual', score: undefined }],
},
],
},
{
domain: CRR,
subdomains: [
{
subdomain: 'Comportamientos restringidos y repetitivos',
items: [
{
code: 'A-3',
title: 'Entonación de las vocalizaciones o verbalizaciones',
score: 3,
},
],
},
],
},
]);
expect(ados2Groups(undefined)).toEqual([]);
});
it('encuentra el ítem de una asociación por su número', () => {
expect(ados2Component(observation, 2)?.code.text).toBe('Señalar');
expect(ados2Component(observation, 8)?.code.coding?.[0].code).toBe('ados2.response_to_name');
expect(ados2Component(observation, 0)).toBeUndefined();
expect(ados2Component(observation, 23)?.valueQuantity?.value).toBe(3);
});
});