feat(tea): cambios de la reunión del 5 de noviembre
Resumen - Estado del caso (completo, en proceso, fuera del protocolo) al cierre del periodo, en una figura y en el párrafo, separado de diagnóstico confirmado. - Tiempos por paso: M-CHAT a ADOS-2, ADOS-2 a diagnóstico y total. - Un solo formato: barras. M24 son barras apiladas por grupo de edad. - «Descargar reporte» abre la impresión con el periodo y los indicadores seleccionados. Histórico - Porcentaje de casos en proceso, tiempos por paso en la misma escala y calidad de los EEG (indicador solo de esta pestaña, con `vistas`). - Ejes con unidades y fechas como «mar 2025». Seguimiento - Columna y filtro de estado del caso, con lo que falta. - Filtro por tipo de alteración y resumen de EEG que sigue los filtros. - Módulo de ADOS-2 junto al puntaje. - Tarjetas de alteraciones: al elegir una se apartan y aparece su mapa, sin caja, con leyenda de colores. Referencia por grupo de edad. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import { isoDate, SeguimientoQuery, SeguimientoResponse, SeguimientoStatus } fro
|
||||
import { validSeguimientoQuery } from './cacu-seguimiento.service';
|
||||
|
||||
export type AlteracionesEeg = 'normal' | 'anormal';
|
||||
export type EstadoCaso = 'completo' | 'en_proceso' | 'fuera_protocolo';
|
||||
export interface TeaSeguimientoPaciente {
|
||||
id_seudonimo: string;
|
||||
grupo_edad: string;
|
||||
@@ -12,10 +13,23 @@ export interface TeaSeguimientoPaciente {
|
||||
mchat: number | null;
|
||||
css_ados2: number | null;
|
||||
alteraciones_eeg: AlteracionesEeg | null;
|
||||
modulo_ados2: string | null;
|
||||
estado_caso: EstadoCaso;
|
||||
// What a case in process still lacks.
|
||||
pendientes: string[];
|
||||
// Codes of the alterations found.
|
||||
alteraciones: string[];
|
||||
}
|
||||
export interface TeaResumenEeg {
|
||||
normales: number; anormales: number; sin_eeg: number;
|
||||
por_alteracion: { codigo: string; etiqueta: string; n: number }[];
|
||||
}
|
||||
export interface TeaSeguimientoResponse extends Pick<SeguimientoResponse, 'simulado' | 'corte' | 'ventana' | 'paginacion'> {
|
||||
filtros: { alteraciones_eeg: AlteracionesEeg | null };
|
||||
items: TeaSeguimientoPaciente[];
|
||||
tipos_alteracion: { codigo: string; etiqueta: string }[];
|
||||
// Of every patient that matches the filters, not only this page's.
|
||||
resumen_eeg: TeaResumenEeg;
|
||||
}
|
||||
export interface TeaAdosReactivo { codigo: string; etiqueta: string; puntaje: number; puntaje_algoritmo: number }
|
||||
export interface TeaAdosDominio { codigo: string; etiqueta: string; puntaje: number; maximo: number; reactivos: TeaAdosReactivo[] }
|
||||
@@ -31,16 +45,19 @@ export interface TeaEegAlteracion {
|
||||
codigo: string; etiqueta: string; unidad: string; referencia: { min: number; max: number };
|
||||
valor: number | null; valor_z: number | null; estado: TeaAlteracionEstado; efectos: string[];
|
||||
}
|
||||
export interface TeaEegMapa { codigo: string; metrica: string; z: (number | null)[][]; regiones: TeaEegRegion[] }
|
||||
export interface TeaEeg {
|
||||
fecha: string; duracion_min: number; canales: number;
|
||||
// The overall rating is in words, like Automagic, and is the worst of its criteria, which report numbers.
|
||||
calidad: TeaNivelCalidad; criterios_calidad: { codigo: string; etiqueta: string; valor: number; unidad: string; nivel: TeaNivelCalidad }[];
|
||||
regiones: TeaEegRegion[];
|
||||
alteraciones: TeaEegAlteracion[];
|
||||
mapa: { metrica: string; x: number[]; y: number[]; z: (number | null)[][]; electrodos: { nombre: string; x: number; y: number }[] };
|
||||
// One map per alteration that could be evaluated, on shared axes.
|
||||
mapas: TeaEegMapa[];
|
||||
ejes_mapa: { x: number[]; y: number[]; electrodos: { nombre: string; x: number; y: number }[] };
|
||||
}
|
||||
export interface TeaPacienteDetalle { simulado: true; id_seudonimo: string; grupo_edad: string; ados2: TeaAdos2 | null; eeg: TeaEeg | null }
|
||||
// TEA has no follow-up status; its third filter is the EEG result, using the CaCu status shape.
|
||||
export const ESTADOS_CASO: Record<EstadoCaso, string> = { completo: 'Completo', en_proceso: 'En proceso', fuera_protocolo: 'Fuera del protocolo' };
|
||||
export const GRUPOS_EDAD_TEA = ['16-23 meses', '24-29 meses', '30-36 meses'];
|
||||
// M-CHAT-R/F risk bands, and the ADOS-2 calibrated severity levels used in the patient summary.
|
||||
export const RANGOS_MCHAT = [
|
||||
@@ -60,6 +77,11 @@ const record = (v: unknown): v is Record<string, unknown> => !!v && typeof v ===
|
||||
const integer = (v: unknown, min = 0) => typeof v === 'number' && Number.isSafeInteger(v) && v >= min;
|
||||
const eeg = (v: unknown) => v === null || v === 'normal' || v === 'anormal';
|
||||
const score = (v: unknown, min: number, max: number) => v === null || typeof v === 'number' && Number.isSafeInteger(v) && v >= min && v <= max;
|
||||
const textos = (v: unknown) => Array.isArray(v) && v.every(t => typeof t === 'string');
|
||||
function validResumenEeg(r: unknown): boolean {
|
||||
return record(r) && integer(r['normales']) && integer(r['anormales']) && integer(r['sin_eeg']) && Array.isArray(r['por_alteracion'])
|
||||
&& r['por_alteracion'].every(a => record(a) && typeof a['codigo'] === 'string' && typeof a['etiqueta'] === 'string' && integer(a['n']));
|
||||
}
|
||||
export function teaSeguimientoResponse(v: unknown): TeaSeguimientoResponse {
|
||||
// Same rule as CaCu: demonstration records only.
|
||||
if (!record(v) || v['simulado'] !== true) throw new Error('Esta vista solo admite datos de demostración.');
|
||||
@@ -72,7 +94,10 @@ export function teaSeguimientoResponse(v: unknown): TeaSeguimientoResponse {
|
||||
&& typeof item['id_seudonimo'] === 'string' && typeof item['grupo_edad'] === 'string'
|
||||
&& (item['ultimo_eeg'] === null || isoDate(item['ultimo_eeg']))
|
||||
&& score(item['mchat'], 0, 20) && score(item['css_ados2'], 1, 10)
|
||||
&& eeg(item['alteraciones_eeg'])))
|
||||
&& eeg(item['alteraciones_eeg']) && (item['modulo_ados2'] === null || typeof item['modulo_ados2'] === 'string')
|
||||
&& Object.hasOwn(ESTADOS_CASO, item['estado_caso'] as string) && textos(item['pendientes']) && textos(item['alteraciones']))
|
||||
|| !Array.isArray(v['tipos_alteracion']) || !v['tipos_alteracion'].every(t => record(t) && typeof t['codigo'] === 'string' && typeof t['etiqueta'] === 'string')
|
||||
|| !validResumenEeg(v['resumen_eeg']))
|
||||
throw new Error('Respuesta de seguimiento inválida');
|
||||
return v as unknown as TeaSeguimientoResponse;
|
||||
}
|
||||
@@ -108,14 +133,15 @@ function validEeg(e: unknown): boolean {
|
||||
if (!record(e) || !isoDate(e['fecha']) || !integer(e['duracion_min'], 1) || !integer(e['canales'], 1) || !nivel(e['calidad'])
|
||||
|| !Array.isArray(e['criterios_calidad']) || !e['criterios_calidad'].every(c => record(c) && text(c['codigo']) && text(c['etiqueta']) && nivel(c['nivel']) && text(c['unidad'])
|
||||
&& integer(c['valor']) && (c['unidad'] !== 'canales' || (c['valor'] as number) <= (e['canales'] as number)))) return false;
|
||||
const mapa = e['mapa'];
|
||||
if (!Array.isArray(e['regiones']) || !e['regiones'].every(r => record(r) && text(r['codigo']) && text(r['etiqueta']) && finite(r['valor_z']))) return false;
|
||||
if (!Array.isArray(e['alteraciones']) || !e['alteraciones'].every(validAlteracion)) return false;
|
||||
if (!record(mapa) || !text(mapa['metrica']) || !Array.isArray(mapa['x']) || !Array.isArray(mapa['y']) || !Array.isArray(mapa['z'])) return false;
|
||||
const x = mapa['x'], y = mapa['y'], z = mapa['z'];
|
||||
return x.every(finite) && y.every(finite) && z.length === y.length
|
||||
&& z.every(row => Array.isArray(row) && row.length === x.length && row.every(v => v === null || finite(v)))
|
||||
&& Array.isArray(mapa['electrodos']) && mapa['electrodos'].every(p => record(p) && text(p['nombre']) && finite(p['x']) && finite(p['y']));
|
||||
const ejes = e['ejes_mapa'];
|
||||
if (!record(ejes) || !Array.isArray(ejes['x']) || !Array.isArray(ejes['y']) || !Array.isArray(e['mapas'])) return false;
|
||||
const x = ejes['x'], y = ejes['y'];
|
||||
return x.every(finite) && y.every(finite)
|
||||
&& Array.isArray(ejes['electrodos']) && ejes['electrodos'].every(p => record(p) && text(p['nombre']) && finite(p['x']) && finite(p['y']))
|
||||
&& e['mapas'].every(m => record(m) && text(m['codigo']) && text(m['metrica']) && Array.isArray(m['z']) && m['z'].length === y.length
|
||||
&& m['z'].every(row => Array.isArray(row) && row.length === x.length && row.every(v => v === null || finite(v)))
|
||||
&& Array.isArray(m['regiones']) && m['regiones'].every(r => record(r) && text(r['codigo']) && text(r['etiqueta']) && finite(r['valor_z'])));
|
||||
}
|
||||
export function teaPacienteDetalle(v: unknown, id: string): TeaPacienteDetalle {
|
||||
if (!record(v) || v['simulado'] !== true) throw new Error('Esta vista solo admite datos de demostración.');
|
||||
@@ -137,6 +163,8 @@ export class TeaSeguimientoService {
|
||||
const mchat = RANGOS_MCHAT.find(r => r.codigo === query.mchat), css = RANGOS_CSS.find(r => r.codigo === query.css);
|
||||
if (mchat) params = params.set('mchat_min', mchat.min).set('mchat_max', mchat.max);
|
||||
if (css) params = params.set('css_min', css.min).set('css_max', css.max);
|
||||
if (query.estado_caso) params = params.set('estado_caso', query.estado_caso);
|
||||
if (query.alteracion) params = params.set('alteracion', query.alteracion);
|
||||
return this.http.get<unknown>('/tea/seguimiento', { params }).pipe(map(teaSeguimientoResponse));
|
||||
}
|
||||
detalle(id: string) {
|
||||
|
||||
Reference in New Issue
Block a user