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, M29_MALO } from './indicadores-kpi'; interface Valor { texto: string; estado: 'listo' | 'cargando' | 'sin_dato'; detalle?: string; } const M21 = 'M21_diagnosticados_con_eeg', M22 = 'M22_diagnosticados_sin_eeg', M28 = 'M28_casos_por_estado', M29 = 'M29_calidad_eeg'; // 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, M21/M22 and M29 do not count the same patients or exams. @Component({ selector: 'app-tea-resumen-periodo', imports: [MatButtonModule, NgTemplateOutlet], template: `

Resumen

Al cierre del periodo {{ periodo }}, se evaluaron niños entre 16 y 36 meses; únicamente tienen M-CHAT, hasta la evaluación psicológica y presentan evaluación neuropediátrica. En este periodo el de los pacientes tiene diagnóstico confirmado de TEA (CIE-10 F84.0). Las ventanas de tiempo* de tamizaje son: de M-CHAT (psicología) a ADOS-2, de ADOS-2 a diagnóstico. El tiempo* de tamizaje completo de M-CHAT a diagnóstico fue de .
De los niños con diagnóstico confirmado en este periodo, presentan estudio de EEG y faltan por realizarlo. estudios de EEG no son aceptables para un análisis.

*tomando la mediana de los tiempos

@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); } h2 { margin: 0 0 var(--issste-space-3); font-family: var(--issste-font-heading); font-weight: 500; font-size: 1.125rem; } p { margin: 0; font-family: var(--issste-font-heading); font-size: 1.25rem; line-height: 2.1; overflow-wrap: anywhere; } p + p { margin-top: var(--issste-space-4); } p.nota { margin-top: var(--issste-space-2); font-size: .95rem; line-height: 1.5; color: var(--issste-text-secondary); } .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); } // Why a panel has no figure for this period, or undefined when it has one. private fallo(id: string): Valor | undefined { 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) return { texto: 'sin dato', estado: 'sin_dato', detalle: result.state }; if (result.period !== this.periodo) return this.sinDato('Sin datos para el periodo seleccionado'); return undefined; } private sinDato(detalle: string): Valor { return { texto: 'sin dato', estado: 'sin_dato', detalle }; } valor(id: string, sufijo: string): Valor { return this.fallo(id) ?? { texto: this.panel(id)!.result().value + sufijo, estado: 'listo' }; } // The children of M28 in some stages, under the same rules as valor(). readonly conNeuropediatria = ['NEUROPEDIATRIA', M28_COMPLETO]; caso(categorias: readonly string[]): Valor { const base = this.valor(M28, ''); if (base.estado !== 'listo') return base; const counts = this.panel(M28)?.result().categorias; const n = categorias.map(c => counts?.[c]); return n.some(v => v === undefined) ? this.sinDato('Etapa no publicada') : { texto: String(n.reduce((s, v) => s! + v!, 0)), estado: 'listo' }; } // M21 and M22 split the same confirmed children, so a count of either is only shown while their denominators agree. private poblacionComun(): boolean { if (this.fallo(M21) || this.fallo(M22)) return true; const a = this.panel(M21)?.result(), b = this.panel(M22)?.result(); return !(a?.denominador !== undefined && b?.denominador !== undefined && a.denominador !== b.denominador); } private conteo(id: string, parte: 'numerador' | 'denominador'): Valor { const fallo = this.fallo(id); if (fallo) return fallo; if (!this.poblacionComun()) return this.sinDato('Las poblaciones de M21 y M22 no coinciden'); const n = this.panel(id)!.result()[parte]; return n === undefined ? this.sinDato('Conteo no publicado') : { texto: String(n), estado: 'listo' }; } // Children with a confirmed diagnosis at the period's end, the denominator of M21 and M22. confirmados() { return this.conteo(M21, 'denominador'); } // Of them, those with a good EEG (M21's numerator) and those without yet (M22's). conEegBueno() { return this.conteo(M21, 'numerador'); } sinEegBueno() { return this.conteo(M22, 'numerador'); } // The period's EEGs (M29 counts exams, not patients) the analysis found not valid. eegNoAceptables(): Valor { const base = this.valor(M29, ''); if (base.estado !== 'listo') return base; const malos = this.panel(M29)!.result().categorias?.[M29_MALO]; return malos === undefined ? this.sinDato('Categoría no publicada') : { texto: String(malos), 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()); } }