import { NgTemplateOutlet } from '@angular/common'; import { Component, Input } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { IndicadorKpiPanel } from './indicador-kpi-panel'; import { M28_COMPLETO, M28_EN_PROCESO } from './indicadores-kpi'; 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: M28, M24, M25 and M21/M22 do not count the same patients. @Component({ selector: 'app-tea-resumen-periodo', imports: [MatButtonModule, NgTemplateOutlet], template: `

Al cierre del periodo {{ periodo }}, de los niños en el tamizaje, lo completaron con un EEG de buena calidad y siguen en proceso: solo con M-CHAT, hasta la evaluación psicológica y hasta la evaluación neuropediátrica. De los niños con diagnóstico confirmado o en proceso, tiene diagnóstico confirmado de TEA (CIE-10 F84.0). La mediana de M-CHAT a ADOS-2 fue de , de ADOS-2 a diagnóstico, de , y en total, de M-CHAT a diagnóstico, de . De los niños con diagnóstico confirmado, tienen un EEG de buena calidad y todavía no.

@if (conError.length) { }
{{ v.texto }}@if (v.detalle) { ({{ v.detalle }})} `, 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' }; } readonly completo = [M28_COMPLETO]; readonly enProceso = M28_EN_PROCESO; // The children of M28 in some stages, under the same rules as valor(). caso(categorias: readonly string[]): Valor { const base = this.valor('M28_casos_por_estado', ''); if (base.estado !== 'listo') return base; const counts = this.panel('M28_casos_por_estado')?.result().categorias; const n = categorias.map(c => counts?.[c]); return n.some(v => v === undefined) ? { texto: 'sin dato', estado: 'sin_dato', detalle: 'Etapa no publicada' } : { texto: String(n.reduce((s, v) => s! + v!, 0)), 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()); } }