feat(tea): seguimiento con resumen por paciente y resumen por periodo

- Pestaña Seguimiento de TEA: tabla de pacientes con filtro de alteraciones EEG
  y fila desplegable con ADOS-2 por reactivo, calidad del EEG y mapa topográfico
  (GET /tea/seguimiento/<id>).
- Indicadores destacados: M21 y M22 (pacientes con TEA con y sin EEG).
- Con un solo periodo elegido, TEA muestra un párrafo de resumen en lugar de
  las tarjetas.
This commit is contained in:
2026-10-29 02:38:43 +00:00
parent 8c63ed83ac
commit 2cbb994667
21 changed files with 677 additions and 37 deletions
@@ -0,0 +1,62 @@
import { NgTemplateOutlet } from '@angular/common';
import { Component, Input } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { IndicadorKpiPanel } from './indicador-kpi-panel';
interface Valor { texto: string; estado: 'listo' | 'cargando' | 'sin_dato'; detalle?: string; }
// TEA summary for one explicit period. It reads the results of the (hidden) KPI panels, so the
// requests, contract checks and suppression rules stay those of the cards. Each sentence names
// its own population: M23, M24, M25 and M21/M22 do not count the same patients.
@Component({
selector: 'app-tea-resumen-periodo',
imports: [MatButtonModule, NgTemplateOutlet],
template: `
<article class="resumen" [attr.aria-busy]="cargando">
<p>
Para el periodo <span class="dato listo">{{ periodo }}</span>, se evaluaron <ng-container *ngTemplateOutlet="dato; context: { $implicit: valor('M23_pacientes_evaluados', '') }" />
pacientes. De los pacientes con nota médica, <ng-container *ngTemplateOutlet="dato; context: { $implicit: valor('M24_confirmacion_diagnostico', ' %') }" />
tuvo diagnóstico de TEA (CIE-10 F84.0). La mediana del tiempo desde la aplicación del M-CHAT por psicología hasta el diagnóstico fue de
<ng-container *ngTemplateOutlet="dato; context: { $implicit: valor('M25_dias_mchat_diagnostico', ' días') }" />.
De los pacientes con TEA positivo por ADOS-2 (16 a 36 meses), <ng-container *ngTemplateOutlet="dato; context: { $implicit: valor('M21_diagnosticados_con_eeg', ' %') }" />
tenían EEG y <ng-container *ngTemplateOutlet="dato; context: { $implicit: valor('M22_diagnosticados_sin_eeg', ' %') }" /> no lo tenían.
</p>
@if (conError.length) {
<button type="button" mat-stroked-button (click)="reintentar()">Reintentar consulta</button>
}
</article>
<ng-template #dato let-v>
<span class="dato" [class.listo]="v.estado === 'listo'" [class.sin-dato]="v.estado === 'sin_dato'" [attr.title]="v.detalle ?? null">{{ v.texto }}@if (v.detalle) {<span class="visually-hidden"> ({{ v.detalle }})</span>}</span>
</ng-template>
`,
styles: `
:host { display: block; min-width: 0; }
.resumen { box-sizing: border-box; padding: var(--issste-space-6); background: var(--issste-surface); color: var(--issste-text);
border: 1px solid var(--issste-border); border-radius: var(--issste-radius); }
p { margin: 0; font-family: var(--issste-font-heading); font-size: 1.25rem; line-height: 2.1; overflow-wrap: anywhere; }
.dato { display: inline-block; padding: 0 .5em; border-radius: var(--issste-radius); line-height: 1.6; font-weight: 700; white-space: nowrap;
background: var(--issste-background); border: 1px dashed var(--issste-border); color: var(--issste-text-secondary); }
.dato.listo { background: color-mix(in srgb, var(--issste-accent) 22%, var(--issste-surface)); border: 1px solid var(--issste-accent); color: var(--issste-text); }
.dato.sin-dato { font-weight: 400; font-style: italic; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
button { margin-top: var(--issste-space-4); }
`,
})
export class TeaResumenPeriodo {
@Input({ required: true }) periodo!: string;
@Input({ required: true }) paneles: readonly IndicadorKpiPanel[] = [];
// Panels render after this paragraph, so on their first pass their inputs are not set yet.
private panel(id: string) { return this.paneles.find(p => p.definition?.id === id); }
valor(id: string, sufijo: string): Valor {
const result = this.panel(id)?.result();
if (!result) return { texto: 'sin dato', estado: 'sin_dato', detalle: 'Indicador no publicado' };
if (result.loading) return { texto: '…', estado: 'cargando', detalle: 'Cargando' };
// Never show a value from another period in a sentence about this one.
if (result.state !== 'Disponible' || result.value === undefined || result.period !== this.periodo)
return { texto: 'sin dato', estado: 'sin_dato', detalle: result.state };
return { texto: result.value + sufijo, estado: 'listo' };
}
get cargando() { return this.paneles.some(p => p.result().loading); }
get conError() { return this.paneles.filter(p => p.result().state === 'Error de consulta'); }
reintentar() { this.conError.forEach(p => p.retry()); }
}