diff --git a/src/app/features/indicadores/indicadores-c1-donut.spec.ts b/src/app/features/indicadores/indicadores-c1-donut.spec.ts index 73fe78b..4eda91e 100644 --- a/src/app/features/indicadores/indicadores-c1-donut.spec.ts +++ b/src/app/features/indicadores/indicadores-c1-donut.spec.ts @@ -43,14 +43,17 @@ describe('Dona de dos anillos para C1', () => { expect(result.legend.map(e => e.label)).toEqual(['Con EEG', 'Sin EEG', '16 a 23 meses', '24 a 29 meses', '30 a 36 meses']); expect(result.figure.layout['title']).toEqual({ text: 'Porcentaje de pacientes con diagnóstico de TEA con EEG, 2025-S2' }); }); - it('dona por grupo de edad: sin anillo interior y con el porcentaje total al centro', () => { + it('dona por grupo de edad: solo los pacientes con el evento, con el porcentaje total al centro', () => { const result = c1DonutFigure(datos(), { ...selection, figura: 'fig_c1_dona_edad' }); if (result.status !== 'supported') throw new Error(result.reason); expect(result.figure.data).toHaveLength(1); - const [ring] = result.figure.data as { labels: string[]; values: number[] }[]; - expect(ring.values).toEqual([16, 13, 17, 8, 5, 5]); + // Only the patients with EEG, by age group; each slice is its share of those 46 patients. + const [ring] = result.figure.data as { labels: string[]; values: number[]; text: string[] }[]; + expect(ring.labels).toEqual(['16 a 23 meses', '24 a 29 meses', '30 a 36 meses']); + expect(ring.values).toEqual([16, 13, 17]); + expect(ring.text[0]).toMatch(/^16 a 23 meses
34.8/); expect((result.figure.layout['annotations'] as { text: string }[])[0].text).toBe('71.9 %'); - expect(result.legend.map(e => e.label)).toEqual(['Con EEG', 'Sin EEG', '16 a 23 meses', '24 a 29 meses', '30 a 36 meses']); + expect(result.legend.map(e => e.label)).toEqual(['16 a 23 meses', '24 a 29 meses', '30 a 36 meses']); }); it('barras por grupo de edad: una barra por grupo con su porcentaje', () => { const result = c1DonutFigure({ ...datos([fila('16-23', 8, 24), fila('24-29', 5, 18), fila('30-36', 5, 22)]), id: 'M22_diagnosticados_sin_eeg' }, diff --git a/src/app/features/indicadores/indicadores-c1-donut.ts b/src/app/features/indicadores/indicadores-c1-donut.ts index a7142e5..e7e18dc 100644 --- a/src/app/features/indicadores/indicadores-c1-donut.ts +++ b/src/app/features/indicadores/indicadores-c1-donut.ts @@ -7,7 +7,7 @@ import { FigureSelection, IndicadorDatos, PlotlyFigure } from './indicadores.mod // Figures by age group for a C1 proportion over one semester, built from the age-stratified C1 rows: // - fig_c1_donas: double donut drawn like CaCu's «Distribución de resultados citológicos»; the inner ring // splits the denominator into patients with and without the event, the outer ring each of them by age group. -// - fig_c1_dona_edad: only that outer ring, with the overall percentage in the centre. +// - fig_c1_dona_edad: only the patients with the event, by age group, with the overall percentage in the centre. // - fig_c1_barras_edad: one bar per age group with its percentage. export const C1_DONUT = 'fig_c1_donas'; export const C1_RING = 'fig_c1_dona_edad'; @@ -92,11 +92,18 @@ export function c1DonutFigure(data: IndicadorDatos, selection: FigureSelection): return n / total < .05 ? '' : escape(g.etiqueta) + '
' + percentNumber(100 * n / total) + ' %'; }); if (selection.figura === C1_RING) { - // Only the outer ring, wider, around the overall percentage of the event. + // Only the patients with the event, by age group, around the overall percentage of the event. + // Each slice is its age group's share of those patients. const numerador = strata.reduce((sum, s) => sum + (s.numerador as number), 0); - figure.data = [{ ...outer, hole: .6 }]; - figure.layout = { ...figure.layout, annotations: [{ x: .5, y: .5, xref: 'paper', yref: 'paper', showarrow: false, + const values = strata.map(s => s.numerador as number); + figure.data = [{ ...outer, hole: .6, values, labels: strata.map(s => escape(s.label)), + marker: { ...(outer['marker'] as object), colors: categorias.slice(0, strata.length).map(c => c.color) }, + text: values.map((n, i) => !numerador || n / numerador < .05 ? '' : escape(strata[i].label) + '
' + shareText(n, numerador)), + customdata: values.map(n => [n, numerador ? percentNumber(100 * n / numerador) : '0']), + hovertemplate: '%{label}
%{customdata[0]} pacientes, %{customdata[1]} % de los ' + numerador + ' ' + escape(what(labels[0])) + '' }]; + figure.layout = { ...figure.layout, title, annotations: [{ x: .5, y: .5, xref: 'paper', yref: 'paper', showarrow: false, text: '' + percentNumber(100 * numerador / total) + ' %', font: { size: 26, color: c2Theme(selection.tema).text } }] }; + return { status: 'supported', figure, legend: strata.map((s, i) => ({ label: s.label, color: categorias[i].color })), total, notes }; } } figure.layout = { ...figure.layout, title }; @@ -106,12 +113,13 @@ export function c1DonutFigure(data: IndicadorDatos, selection: FigureSelection): return { status: 'supported', figure, legend, total, notes }; } +// "Con EEG" -> "con EEG", to follow «pacientes». +const what = (label: string) => label.charAt(0).toLowerCase() + label.slice(1); // One bar per age group: the share of its patients with the event. function ageBars(strata: readonly { label: string; numerador: unknown; denominador: unknown }[], event: string, selection: FigureSelection): PlotlyFigure { const theme = c2Theme(selection.tema); const x = strata.map(s => escape(s.label)); const y = strata.map(s => (s.denominador as number) ? 100 * (s.numerador as number) / (s.denominador as number) : null); - const what = event.charAt(0).toLowerCase() + event.slice(1); return { data: [{ type: 'bar', x, y, marker: { color: RING_COLORS[0], line: { color: theme.background, width: 1 } }, text: y.map(v => v === null ? '' : percentNumber(v) + ' %'), textposition: 'outside', cliponaxis: false, customdata: strata.map(s => [s.numerador, s.denominador]), @@ -119,6 +127,6 @@ function ageBars(strata: readonly { label: string; numerador: unknown; denominad layout: { autosize: true, height: 400, margin: { t: 24, l: 72, r: 24, b: 64 }, showlegend: false, paper_bgcolor: theme.background, plot_bgcolor: theme.background, font: { color: theme.text }, xaxis: { type: 'category', title: { text: 'Grupo de edad' }, automargin: true }, - yaxis: { title: { text: '% de pacientes ' + escape(what) }, range: [0, 100], ticksuffix: ' %', gridcolor: theme.grid, zeroline: false } }, + yaxis: { title: { text: '% de pacientes ' + escape(what(event)) }, range: [0, 100], ticksuffix: ' %', gridcolor: theme.grid, zeroline: false } }, config: { displayModeBar: false } }; } diff --git a/src/app/features/indicadores/tea-paciente-resumen.html b/src/app/features/indicadores/tea-paciente-resumen.html index 71b4bb2..1d4696b 100644 --- a/src/app/features/indicadores/tea-paciente-resumen.html +++ b/src/app/features/indicadores/tea-paciente-resumen.html @@ -4,8 +4,8 @@ } @if (status() === 'ready' && detalle(); as d) { -
-
+
+

ADOS-2

@if (d.ados2; as a) {

Módulo {{ a.modulo }} · {{ a.algoritmo }} · {{ a.fecha }}

@@ -19,7 +19,8 @@
} -
+ +
Puntajes por reactivo @@ -36,7 +37,7 @@ } @else {

Sin evaluación ADOS-2 registrada.

} -
+

Calidad del EEG

@if (d.eeg; as e) {

{{ e.fecha }} · {{ e.duracion_min }} min · {{ e.canales }} canales

@@ -86,7 +87,7 @@

Zonas más afectadas

{{ e.mapa.metrica }} · mapa ilustrativo

@if (figura) { - }
    diff --git a/src/app/features/indicadores/tea-paciente-resumen.scss b/src/app/features/indicadores/tea-paciente-resumen.scss index a8fb22d..6b64fa3 100644 --- a/src/app/features/indicadores/tea-paciente-resumen.scss +++ b/src/app/features/indicadores/tea-paciente-resumen.scss @@ -1,6 +1,5 @@ -:host { display: block; } +:host { display: block; container-type: inline-size; } .resumen { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: .75rem; } -.resumen.amplio { grid-template-columns: repeat(auto-fit, minmax(26rem, 1fr)); gap: 1rem; } .panel { min-width: 0; padding: .75rem; border: 1px solid var(--issste-border); border-radius: var(--issste-radius); background: var(--issste-surface); } h3 { margin: 0 0 .15rem; font-size: 1rem; } .meta { margin: 0 0 .5rem; font-size: .8rem; color: var(--issste-text-secondary); } @@ -46,3 +45,29 @@ li[data-estado=no_evaluable] .estado { color: var(--issste-text-secondary); font .efectos-titulo { margin: .3rem 0 .1rem; font-size: .8rem; font-weight: 600; } .efectos { padding-inline-start: 1.1rem; list-style: disc; font-size: .8rem; } button { min-height: 44px; padding: .6rem; border: 1px solid var(--issste-border); border-radius: 4px; background: var(--issste-surface); color: inherit; font: inherit; cursor: pointer; } + +// Own window: three columns. ADOS-2 with its item scores on the left, EEG quality over its alterations +// in the middle, the map with its regions on the right. Narrower windows fall back to two, then one. +.resumen.amplio { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-areas: "ados calidad mapa" "ados alteraciones mapa"; + grid-template-rows: auto 1fr; gap: 1rem; align-items: start; } +.resumen.amplio.sin-eeg { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "ados calidad"; grid-template-rows: auto; } +.resumen.amplio > .ados { grid-area: ados; } +.resumen.amplio > .calidad { grid-area: calidad; } +.resumen.amplio > .alteraciones { grid-area: alteraciones; } +.resumen.amplio > .mapa { grid-area: mapa; } +.resumen.amplio > .panel { padding: 1rem; } +.resumen.amplio h3 { font-size: 1.1rem; } +@container (max-width: 68rem) { + // The tall ADOS-2 panel spans both rows: the second one takes the leftover height, so no gap opens. + .resumen.amplio { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "ados calidad" "ados alteraciones" "mapa mapa"; grid-template-rows: auto 1fr auto; } + // The map spans the width: put its region list beside it. + .resumen.amplio > .mapa { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); grid-template-areas: "titulo titulo" "meta meta" "grafico lista"; column-gap: 1.5rem; align-items: center; } + .resumen.amplio > .mapa > h3 { grid-area: titulo; } + .resumen.amplio > .mapa > .meta { grid-area: meta; } + .resumen.amplio > .mapa > app-plotly-chart { grid-area: grafico; } + .resumen.amplio > .mapa > .regiones { grid-area: lista; } +} +@container (max-width: 42rem) { + .resumen.amplio, .resumen.amplio.sin-eeg { grid-template-columns: minmax(0, 1fr); grid-template-areas: "ados" "calidad" "alteraciones" "mapa"; grid-template-rows: auto; } + .resumen.amplio > .mapa { display: block; } +}
ReactivoPuntajeAlgoritmo