From 34c6f2af3ae7cc38eec8afe0d3871b3bccf9cedc Mon Sep 17 00:00:00 2001 From: ulises Date: Sat, 21 Nov 2026 23:18:39 -0600 Subject: [PATCH] TEA seguimiento: the ADOS-2 relation panel reads the association's rows --- .../features/indicadores/indicadores-fhir.spec.ts | 15 ++++++++++++--- .../features/indicadores/tea-seguimiento-fhir.ts | 6 ++++-- .../features/indicadores/tea-seguimiento.spec.ts | 4 ++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/app/features/indicadores/indicadores-fhir.spec.ts b/src/app/features/indicadores/indicadores-fhir.spec.ts index b245b29..c23a7a9 100644 --- a/src/app/features/indicadores/indicadores-fhir.spec.ts +++ b/src/app/features/indicadores/indicadores-fhir.spec.ts @@ -35,12 +35,12 @@ const curva = { ], }; const prediccion = (zona: string, z: number | null) => ({ - outcome: { coding: [{ system: `${CS}/tea-catalogo`, code: 'ados2.sa_b9', display: 'Mostrar' }] }, + outcome: { coding: [{ system: `${CS}/tea-ados2-resultado`, code: 'ados2_item_11', display: 'Mostrar' }] }, probabilityDecimal: 0.41, extension: [ { url: `${SD}/biomarcador`, valueCoding: { system: `${CS}/tea-eeg-metrica`, code: 'RITMO_POSTERIOR', display: 'Ritmo posterior' } }, { url: `${SD}/zona`, valueCoding: { system: `${CS}/tea-eeg-zona`, code: zona, display: 'Occipital' } }, - { url: `${SD}/tipo`, valueString: 'item' }, { url: `${SD}/evento`, valueString: '>=2' }, + { url: `${SD}/tipo`, valueString: 'item' }, { url: `${SD}/evento`, valueString: '>=1' }, ...(z === null ? [] : [{ url: `${SD}/valor-z`, valueDecimal: z }]), { url: `${SD}/odds-ratio`, valueDecimal: 0.5 }, { url: `${SD}/ic-inf`, valueDecimal: 0.3 }, { url: `${SD}/ic-sup`, valueDecimal: 0.8 }, { url: `${SD}/q`, valueDecimal: 0.01 }, { url: `${SD}/probabilidad-referencia`, valueDecimal: 0.2 }, { url: `${SD}/observado`, valueInteger: 2 }, @@ -329,7 +329,7 @@ describe('Seguimiento de TEA sobre FHIR', () => { expect(relacion).toMatchObject({ version: '1.0.0', validado: false, nivel: 'item', n_cohorte: 40 }); expect(relacion.filas).toEqual([{ biomarcador: 'Ritmo posterior', zona: 'occipital', zona_etiqueta: 'Occipital', valor_z: -2.6, tipo: 'item', - resultado: 'ados2.sa_b9', resultado_etiqueta: 'Mostrar', evento: '>=2', or: 0.5, ic_inf: 0.3, ic_sup: 0.8, q: 0.01, + resultado: 'ados2_item_11', resultado_etiqueta: 'Mostrar', evento: '>=1', or: 0.5, ic_inf: 0.3, ic_sup: 0.8, q: 0.01, probabilidad: 0.41, probabilidad_referencia: 0.2, observado: 2 }]); }); @@ -356,4 +356,13 @@ describe('Seguimiento de TEA sobre FHIR', () => { expect(mapa.regiones.map(r => r.codigo)).toEqual(['occipital', 'parietal']); expect(mapa.regiones[0].valor_z).toBe(-2.6); }); + + it('las regiones del mapa son las zonas del análisis del EEG', () => { + // Pins down: Fz is its own region (frontal media) and the central region averages C3, Cz and C4 only, as the + // EEG analysis's zones do, so a region on the map is the zone the association model names. Fails if Fz goes + // back into the central average or the frontal media region disappears. + const mapa = mapaDeElectrodos('picos_paroxisticos', 'Picos paroxísticos', { Fz: 3, C3: 1, Cz: 1.5, C4: 2 }); + expect(mapa.regiones.map(r => [r.codigo, r.etiqueta, r.valor_z])).toEqual([ + ['frontal_media', 'Frontal media', 3], ['central', 'Central', 1.5]]); + }); }); diff --git a/src/app/features/indicadores/tea-seguimiento-fhir.ts b/src/app/features/indicadores/tea-seguimiento-fhir.ts index 4c3c61f..b41e26f 100644 --- a/src/app/features/indicadores/tea-seguimiento-fhir.ts +++ b/src/app/features/indicadores/tea-seguimiento-fhir.ts @@ -35,7 +35,8 @@ const CRITERIOS = 'urn:tea:validation'; const FILTRO_EEG: Record = { sin_eeg_valido: 'sin-eeg-valido' }; const INTERPRETACION: Record = { H: 'aumentado', L: 'disminuido', N: 'normal' }; -// The 10-20 electrodes on the page's head (x left to right, y back to front, radius 1) and the regions they average. +// The 10-20 electrodes on the page's head (x left to right, y back to front, radius 1) and the regions they average, +// the scalp zones of the EEG analysis (`tea.contracts.ZONES`). export const ELECTRODOS: Record = { Fp1: [-.25, .77], Fp2: [.25, .77], F7: [-.65, .47], F3: [-.33, .4], Fz: [0, .38], F4: [.33, .4], F8: [.65, .47], T3: [-.8, 0], C3: [-.4, 0], Cz: [0, 0], C4: [.4, 0], T4: [.8, 0], @@ -43,7 +44,8 @@ export const ELECTRODOS: Record = { }; const REGIONES: [string, string, string[]][] = [ ['frontal_izq', 'Frontal izquierda', ['Fp1', 'F3', 'F7']], ['frontal_der', 'Frontal derecha', ['Fp2', 'F4', 'F8']], - ['central', 'Central', ['Fz', 'C3', 'Cz', 'C4']], ['temporal_izq', 'Temporal izquierda', ['T3', 'T5']], + ['frontal_media', 'Frontal media', ['Fz']], ['central', 'Central', ['C3', 'Cz', 'C4']], + ['temporal_izq', 'Temporal izquierda', ['T3', 'T5']], ['temporal_der', 'Temporal derecha', ['T4', 'T6']], ['parietal', 'Parietal', ['P3', 'Pz', 'P4']], ['occipital', 'Occipital', ['O1', 'O2']], ]; const EJE = Array.from({ length: 41 }, (_, i) => Math.round((-1 + i * .05) * 100) / 100); diff --git a/src/app/features/indicadores/tea-seguimiento.spec.ts b/src/app/features/indicadores/tea-seguimiento.spec.ts index 51125d1..fb039d7 100644 --- a/src/app/features/indicadores/tea-seguimiento.spec.ts +++ b/src/app/features/indicadores/tea-seguimiento.spec.ts @@ -381,8 +381,8 @@ describe('Seguimiento TEA', () => { }); // The association model's panel (prototype, simulated data): the field is optional and checked when present. it('valida la relación con el ADOS-2 y solo muestra las zonas alteradas del paciente', () => { - const fila = { biomarcador: 'husos', zona: 'central', zona_etiqueta: 'Central', valor_z: -2.5, tipo: 'dominio', resultado: 'css_sa', - resultado_etiqueta: 'CSS afecto social', evento: 'Severidad alta (CSS ≥ 8)', or: 0.2, ic_inf: 0.13, ic_sup: 0.3, q: 0.0002, + const fila = { biomarcador: 'husos', zona: 'central', zona_etiqueta: 'Central', valor_z: -2.5, tipo: 'dominio', resultado: 'CSS', + resultado_etiqueta: 'Puntaje de severidad calibrado (CSS)', evento: '>=8', or: 0.2, ic_inf: 0.13, ic_sup: 0.3, q: 0.0002, probabilidad: 0.93, probabilidad_referencia: 0.18, observado: 10 }; const otra = { ...fila, zona: 'parietal', zona_etiqueta: 'Parietal', valor_z: 0.4, q: 0.01 }; const rel = (filas: object[]) => ({ ...detalle, relacion_ados2: { validado: false, nivel: 'item', n_cohorte: 46, version: 'v', filas } });