From eaaffa9ebe1e7e6cd63e5ffd302b2d541f2f9d31 Mon Sep 17 00:00:00 2001 From: rockdrigo Date: Mon, 9 Nov 2026 19:14:30 -0600 Subject: [PATCH] Revert "feat(indicadores): Resumen as a story of questions, for the domains that have one" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit How: reverts e5ff342 entirely: indicadores-relato.ts and its spec are removed, Resumen goes back to the opportunity cards followed by the clinical charts for every domain, and the specs read cáncer de mama's cards in KPI order again. Implications: no domain has a questions layout; RELATO_BY_DOMAIN is gone, so nothing outside the KPI list and the catalog orders Resumen. The search threshold and the equal card heights stay. --- .../indicadores/indicador-kpi-panel.spec.ts | 5 +- .../indicadores-global-filters.spec.ts | 4 +- .../indicadores/indicadores-page.html | 69 ------------------- .../indicadores/indicadores-page.scss | 21 ------ .../features/indicadores/indicadores-page.ts | 5 -- .../indicadores-periodos-integration.spec.ts | 3 +- .../indicadores/indicadores-relato.spec.ts | 28 -------- .../indicadores/indicadores-relato.ts | 45 ------------ 8 files changed, 4 insertions(+), 176 deletions(-) delete mode 100644 src/app/features/indicadores/indicadores-relato.spec.ts delete mode 100644 src/app/features/indicadores/indicadores-relato.ts diff --git a/src/app/features/indicadores/indicador-kpi-panel.spec.ts b/src/app/features/indicadores/indicador-kpi-panel.spec.ts index ed4b3e2..8529db5 100644 --- a/src/app/features/indicadores/indicador-kpi-panel.spec.ts +++ b/src/app/features/indicadores/indicador-kpi-panel.spec.ts @@ -194,10 +194,9 @@ describe('KPI integración con autoridad global', () => { flushAll(domain, { notas: ['Nota del pie de la figura.'] }); const cards = [...fixture.nativeElement.querySelectorAll('app-indicador-kpi-card')]; expect(cards).toHaveLength(domain === 'cacu' ? 5 : 4); - // Cáncer de mama's cards follow its questions: patients, the two times, then the detection rate. - expect(cards.map(card => card.querySelector('.value')?.firstChild?.textContent?.trim())).toEqual(domain === 'cacu' ? ['5', undefined, '7', undefined, undefined] : ['5', '7', '7', '40.0']); + expect(cards.map(card => card.querySelector('.value')?.firstChild?.textContent?.trim())).toEqual(domain === 'cacu' ? ['5', undefined, '7', undefined, undefined] : ['5', '40.0', '7', '7']); expect(cards.map(card => card.querySelector('.value span')?.textContent.trim())).toEqual(domain === 'cacu' ? ['pacientes', undefined, 'días (mediana)', undefined, undefined] - : ['pacientes', 'días (mediana)', 'días (mediana)', '%']); + : ['pacientes', '%', 'días (mediana)', 'días (mediana)']); expect(cards.map(card => card.querySelector('.kpi-state')?.textContent.trim())).toEqual(domain === 'cacu' ? [undefined, 'Selección no consolidable', undefined, 'Indicador no disponible', 'Indicador no disponible'] : Array(4).fill(undefined)); expect(cards.map(card => card.textContent)).toEqual(expect.arrayContaining([ expect.stringContaining('2025-S1'), diff --git a/src/app/features/indicadores/indicadores-global-filters.spec.ts b/src/app/features/indicadores/indicadores-global-filters.spec.ts index 6de735c..797883d 100644 --- a/src/app/features/indicadores/indicadores-global-filters.spec.ts +++ b/src/app/features/indicadores/indicadores-global-filters.spec.ts @@ -60,9 +60,7 @@ describe('D.2 integración de autoridad global y consumidores', () => { const sections = fixture.nativeElement.querySelectorAll('#panel-resumen > section') as NodeListOf; expect(sections[0].textContent).toContain('Filtros generales de ' + page.domainLabels[domain]); expect(fixture.nativeElement.querySelectorAll('.kpi-section app-indicador-kpi-card')).toHaveLength(0); - // A domain with a story (relato) shows its questions instead of the charts section. - if (domain === 'cama') expect(sections[1].classList.contains('relato')).toBe(true); - else expect(sections[1].getAttribute('aria-labelledby')).toBe('graphic-section-title'); + expect(sections[1].getAttribute('aria-labelledby')).toBe('graphic-section-title'); expect(page.filters!.applied.selection.mode).toBe('todos'); expect(fixture.nativeElement.querySelector('.apply-button').disabled).toBe(true); http.expectNone(() => true); diff --git a/src/app/features/indicadores/indicadores-page.html b/src/app/features/indicadores/indicadores-page.html index eca20f2..4051f2e 100644 --- a/src/app/features/indicadores/indicadores-page.html +++ b/src/app/features/indicadores/indicadores-page.html @@ -44,74 +44,6 @@ } @else if (initialPeriodState() === 'manual') {

La búsqueda inicial se detuvo para conservar tu selección. Pulsa Aplicar para consultar.

} - @if (relato; as preguntas) { - -
- @if (catalogLoading()) { - -

Cargando catálogo de indicadores…

- } @else if (catalogError()) { -

{{ catalogError() }}

-
- } @else if (!catalog().length) { -

No hay indicadores disponibles en el catálogo.

-
- } @else if (!initialPeriodBlocked) { - @for (pregunta of preguntas; track pregunta.id; let i = $index) { - @let r = respuesta(pregunta); -
-
- -

{{ pregunta.pregunta }}

{{ pregunta.lectura }}

-
- @if (r.kpis.length || r.items.length) { -
- @if (r.kpis.length) { -
- @for (definition of r.kpis; track dominio + ':' + definition.id) { - - } -
- } - @if (r.items.length) { -
- @for (item of r.items; track cardIdentity(item)) { - - } -
- } -
- } - @if (pregunta.enlace; as enlace) { - - } -
- } - @let resto = sinPregunta; - @if (resto.kpis.length || resto.items.length) { -
-

Otros indicadores

-
- @if (resto.kpis.length) { -
- @for (definition of resto.kpis; track dominio + ':' + definition.id) { } -
- } - @if (resto.items.length) { -
- @for (item of resto.items; track cardIdentity(item)) { } -
- } -
-
- } - } -
- } @else { @let kpis = opportunityKpis; @if (kpis.length && !initialPeriodBlocked) {
@@ -185,7 +117,6 @@ }
- } @if (conHistorico) { diff --git a/src/app/features/indicadores/indicadores-page.scss b/src/app/features/indicadores/indicadores-page.scss index 7e7cc92..5c7082c 100644 --- a/src/app/features/indicadores/indicadores-page.scss +++ b/src/app/features/indicadores/indicadores-page.scss @@ -63,24 +63,3 @@ header p { color: var(--mat-sys-on-surface-variant); margin-bottom: 1.5rem; } .section-panel { padding-block: var(--issste-space-6); } .section-panel[hidden] { display: none; } @media (max-width: 550px) { .section-tabs button { flex: 1 1 auto; padding-inline: .65rem; } } - -// Resumen as questions. Every opportunity card has the same size (--kpi-ancho by --kpi-alto); next to charts -// they stack in a column, alone they sit in a row. Charts take equal halves; an interactive (dual) card, the full width. -.relato { --kpi-ancho: 17rem; --kpi-alto: 12.5rem; display: grid; gap: var(--issste-space-6); margin-top: var(--issste-space-4); } -.pregunta { padding: var(--issste-space-4) var(--issste-space-6) var(--issste-space-6); background: var(--issste-surface); - border: 1px solid var(--issste-border); border-left: 4px solid var(--issste-accent); border-radius: var(--issste-radius); min-width: 0; } -.pregunta > header { display: flex; align-items: flex-start; gap: var(--issste-space-3); margin-bottom: var(--issste-space-4); } -.pregunta > header p { margin: var(--issste-space-1) 0 0; color: var(--issste-text-secondary); font: var(--mat-sys-body-medium); } -.numero { flex: 0 0 auto; display: inline-grid; place-items: center; width: 2rem; height: 2rem; border: 1px solid var(--issste-text); - border-radius: var(--issste-radius); font-weight: 500; line-height: 1; } -.respuesta { display: grid; gap: var(--issste-space-6); grid-template-columns: minmax(0, 1fr); align-items: start; } -.kpi-tarjetas { display: flex; flex-wrap: wrap; gap: var(--issste-space-4); } -.kpi-tarjetas > app-indicador-kpi-panel { flex: 0 0 var(--kpi-ancho); max-width: 100%; min-height: var(--kpi-alto); - display: grid; grid-template-rows: 1fr auto; } -.respuesta .catalog-grid { grid-template-columns: minmax(0, 1fr); } -.continuar { margin-top: var(--issste-space-4); } -@container dashboard (min-width: 900px) { - .respuesta.con-graficas:has(.kpi-tarjetas) { grid-template-columns: var(--kpi-ancho) minmax(0, 1fr); } - .respuesta.con-graficas .kpi-tarjetas { flex-direction: column; } - .respuesta .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } -} diff --git a/src/app/features/indicadores/indicadores-page.ts b/src/app/features/indicadores/indicadores-page.ts index 7f7ba65..13e5e51 100644 --- a/src/app/features/indicadores/indicadores-page.ts +++ b/src/app/features/indicadores/indicadores-page.ts @@ -13,7 +13,6 @@ import { MatProgressBarModule } from '@angular/material/progress-bar'; import { catchError, first, map, of, startWith, Subject, switchMap, takeUntil } from 'rxjs'; import { Dominio, isDominio, Indicador, Tema } from './indicadores.models'; import { vistaEscenario } from './indicadores-eu7-escenario'; -import { PreguntaRelato, RELATO_BY_DOMAIN, respuesta, sinPregunta } from './indicadores-relato'; import { IndicadoresService } from './indicadores.service'; import { applyGlobal, domainTypes, GlobalFilterState, IndicadoresMemory, pending, validDraft } from './indicadores-memory'; import { IndicadorPeriodFilters } from './indicador-period-filters'; @@ -358,10 +357,6 @@ export class IndicadoresPage { this.filtersEdited(); this.changeDetector.markForCheck(); } - // Resumen as a story of questions, for the domains that have one. - get relato(): readonly PreguntaRelato[] | undefined { return RELATO_BY_DOMAIN[this.dominio]; } - respuesta(pregunta: PreguntaRelato) { return respuesta(pregunta, this.opportunityKpis, this.searchResults().items); } - get sinPregunta() { return sinPregunta(this.relato ?? [], this.opportunityKpis, this.searchResults().items); } cardIdentity(item: Indicador) { return indicatorIdentity(this.dominio, item.id); } cardElementId(item: Indicador) { return identityElementId(this.cardIdentity(item)); } // «Ir» in the indicator selector: show the indicator if it was filtered out, then scroll to its card. diff --git a/src/app/features/indicadores/indicadores-periodos-integration.spec.ts b/src/app/features/indicadores/indicadores-periodos-integration.spec.ts index 72b0fa9..9b5b36c 100644 --- a/src/app/features/indicadores/indicadores-periodos-integration.spec.ts +++ b/src/app/features/indicadores/indicadores-periodos-integration.spec.ts @@ -72,8 +72,7 @@ describe('P0.1 selección publicada y último periodo por KPI', () => { const requests = flushDatos(domain); expect(requests.map(r => r.request.params.get('periodos'))).toEqual(KPIS[domain].slice(1).map(() => '2026-S1')); expect(panels().map(p => p.temporalReference)).toEqual(KPIS[domain].map(() => '2026-S1')); - // Cáncer de mama shows its cards in the order of its questions: patients, time, detection rate. - expect(panels().map(p => p.result().value)).toEqual(domain === 'cacu' ? [4, 0] : [4, 0, '0.0']); + expect(panels().map(p => p.result().value)).toEqual(domain === 'cacu' ? [4, 0] : [4, '0.0', 0]); expect(fixture.componentInstance.filters!.applied.selection).toEqual({ mode: 'explicit', periodos: ['2026-S1'] }); expect(fixture.componentInstance.filters!.applied.revision).toBe(1); fixture.componentInstance.applyFilters(); fixture.detectChanges(); http.expectNone(() => true); diff --git a/src/app/features/indicadores/indicadores-relato.spec.ts b/src/app/features/indicadores/indicadores-relato.spec.ts deleted file mode 100644 index 8625211..0000000 --- a/src/app/features/indicadores/indicadores-relato.spec.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { KPI_BY_DOMAIN } from './indicadores-kpi'; -import { Indicador } from './indicadores.models'; -import { RELATO_BY_DOMAIN, respuesta, sinPregunta } from './indicadores-relato'; - -// Covers how Resumen's questions pick their cards and charts. Fixtures: cáncer de mama's real KPI list and a -// small catalog built below with its chart ids plus one indicator no question claims. -const item = (id: string): Indicador => ({ id, titulo: id, contrato: 'C2', figuras: [], tipos_periodo: ['semestre'] }); -const catalogo = ['cama_histopatologia_birads', 'cama_birads_456_paciente', 'cama_birads_456_mastografia', 'nuevo'].map(item); -const preguntas = RELATO_BY_DOMAIN.cama!; - -describe('Resumen como preguntas', () => { - it('cada pregunta toma sus tarjetas y gráficas en su propio orden', () => { - // Fails if a question takes the catalog's order instead of its own, or loses a card it names. - const hallazgo = respuesta(preguntas[0], KPI_BY_DOMAIN.cama, catalogo); - expect(hallazgo.kpis.map(k => k.id)).toEqual(['cama_birads_456_paciente']); - expect(hallazgo.items.map(i => i.id)).toEqual(['cama_birads_456_paciente', 'cama_birads_456_mastografia']); - }); - it('omite lo que la página no tiene', () => { - // Fails if a question names an indicator missing from the catalog and the page tries to draw it. - expect(respuesta(preguntas[2], KPI_BY_DOMAIN.cama, []).items).toEqual([]); - }); - it('todas las tarjetas de cáncer de mama tienen pregunta, y lo nuevo queda al final', () => { - // Fails if a card is left out of every question, or a new indicator disappears instead of going to «Otros». - const resto = sinPregunta(preguntas, KPI_BY_DOMAIN.cama, catalogo); - expect(resto.kpis).toEqual([]); - expect(resto.items.map(i => i.id)).toEqual(['nuevo']); - }); -}); diff --git a/src/app/features/indicadores/indicadores-relato.ts b/src/app/features/indicadores/indicadores-relato.ts deleted file mode 100644 index f576b6f..0000000 --- a/src/app/features/indicadores/indicadores-relato.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { Dominio, Indicador } from './indicadores.models'; -import { KpiDefinition } from './indicadores-kpi'; - -// Resumen read as the patient's route through screening: each question gathers, in order, the cards and the -// charts that answer it, so the page reads from the suspicious finding to the patients still waiting. -export interface PreguntaRelato { - id: string; - pregunta: string; - // What the answer is made of, in one line. - lectura: string; - kpis: readonly string[]; - indicadores: readonly string[]; - // The tab that continues the answer: its evolution, or the patients behind it. - enlace?: { seccion: 'historico' | 'seguimiento'; texto: string }; -} - -export const RELATO_BY_DOMAIN: Partial> = { - cama: [ - { id: 'hallazgo', pregunta: '¿Cuántas pacientes tienen un hallazgo sospechoso?', - lectura: 'Mastografías con BI-RADS 4, 5 o 6, y las pacientes que las tienen.', - kpis: ['cama_birads_456_paciente'], indicadores: ['cama_birads_456_paciente', 'cama_birads_456_mastografia'] }, - { id: 'oportunidad', pregunta: '¿Qué tan pronto llega el diagnóstico?', - lectura: 'Mediana de días de cada tramo: de la mastografía a su resultado, y del resultado al diagnóstico.', - kpis: ['cama_eu38a', 'cama_dias_resultado_diagnostico'], indicadores: [], - enlace: { seccion: 'historico', texto: 'Ver su evolución en Histórico' } }, - { id: 'confirmacion', pregunta: '¿Cuántos cánceres confirma la biopsia, y en qué categorías?', - lectura: 'Biopsias con resultado maligno, en total y por categoría BI-RADS.', - kpis: ['cama_tasa_deteccion_histopatologica'], indicadores: ['cama_histopatologia_birads'] }, - { id: 'pendientes', pregunta: '¿Quiénes siguen pendientes?', - lectura: 'Pacientes con biopsia o resultado por llegar, ordenadas por prioridad.', - kpis: [], indicadores: [], enlace: { seccion: 'seguimiento', texto: 'Abrir la lista de Seguimiento' } }, - ], -}; - -// The cards and charts of one question, in the question's order, out of those the page has. -export function respuesta(pregunta: PreguntaRelato, kpis: readonly KpiDefinition[], items: readonly Indicador[]) { - const ordenar = (ids: readonly string[], todos: readonly T[]) => - ids.map(id => todos.find(item => item.id === id)).filter((item): item is T => !!item); - return { kpis: ordenar(pregunta.kpis, kpis), items: ordenar(pregunta.indicadores, items) }; -} -// What no question claims, so a new indicator still shows up at the end. -export function sinPregunta(preguntas: readonly PreguntaRelato[], kpis: readonly KpiDefinition[], items: readonly Indicador[]) { - const usados = new Set(preguntas.flatMap(p => [...p.kpis, ...p.indicadores])); - return { kpis: kpis.filter(k => !usados.has(k.id)), items: items.filter(i => !usados.has(i.id)) }; -}