From d159067efd4cfd270269eecdf72206911e639559 Mon Sep 17 00:00:00 2001 From: Angel Capetillo Zavala Date: Thu, 12 Nov 2026 00:01:17 -0600 Subject: [PATCH] feat(indicadores): CaMa clinical section heading and counter, without search, pins, navigation or representation selector MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CaMa's graphic section reads «Indicadores clínicos» and counts the indicators it draws. The search box, pins, floating navigation, representation selector and figure count are not drawn for CaMa; CaCu and TEA keep them. (cherry picked from commit e54ee5a55aa3722f6895300fa7e8cefb28f12ebb) --- .../indicadores/indicador-catalog-card.ts | 18 ++-- .../indicadores-cama-resumen-clinico.spec.ts | 91 +++++++++++++++++++ .../indicadores-navegacion-lateral.spec.ts | 11 ++- .../indicadores/indicadores-page.html | 4 +- .../features/indicadores/indicadores-page.ts | 8 +- .../indicadores/indicadores-pinning.spec.ts | 3 +- 6 files changed, 118 insertions(+), 17 deletions(-) create mode 100644 src/app/features/indicadores/indicadores-cama-resumen-clinico.spec.ts diff --git a/src/app/features/indicadores/indicador-catalog-card.ts b/src/app/features/indicadores/indicador-catalog-card.ts index 25e56cd..39c133b 100644 --- a/src/app/features/indicadores/indicador-catalog-card.ts +++ b/src/app/features/indicadores/indicador-catalog-card.ts @@ -33,13 +33,15 @@ import { parTiempos } from './indicadores-tiempos-pareados';

{{ indicador.titulo }}

- + @if (!sobrio) { + + }
- + @if (!sobrio) { } @if (isEu7) {
@@ -53,7 +55,7 @@ import { parTiempos } from './indicadores-tiempos-pareados';
} @else if (selectedFigure) { - @if (!pair.length || otherFigures.length) { + @if (!sobrio && (!pair.length || otherFigures.length)) { Representación gráfica this.updateNumeric()); }); } + // CaMa's cards carry no pin, representation selector or figure count, as in the mockup. + get sobrio() { return this.dominio === 'cama'; } get pair() { return dualFigures(this.indicador); } get isEu7() { return this.dominio === 'cacu' && this.indicador.id === 'cacu_eu7'; } get isConfirmacion() { return this.dominio === 'cacu' && this.indicador.id === ID_CONFIRMACION; } diff --git a/src/app/features/indicadores/indicadores-cama-resumen-clinico.spec.ts b/src/app/features/indicadores/indicadores-cama-resumen-clinico.spec.ts new file mode 100644 index 0000000..76deebd --- /dev/null +++ b/src/app/features/indicadores/indicadores-cama-resumen-clinico.spec.ts @@ -0,0 +1,91 @@ +// Covers the clinical section of CaMa's summary: its heading and counter, and the controls the mockup does not +// have (search, pins, floating navigation, representation selector, figure count), which CaCu and TEA keep. +// Fixtures are catalogs shaped like //indicadores; no figure is requested (the cards stay out of view). +import { TestBed } from '@angular/core/testing'; +import { provideHttpClient } from '@angular/common/http'; +import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing'; +import { provideRouter } from '@angular/router'; +import { IndicadoresPage } from './indicadores-page'; +import { IndicadoresMemory } from './indicadores-memory'; +import { Dominio } from './indicadores.models'; + +const item = (id: string, titulo: string, contrato: string, figuras: string[]) => ({ id, titulo, contrato, figuras, tipos_periodo: ['semestre', 'mes'] }); +// The catalog 18080 publishes for CaMa. +const CAMA = [ + item('cama_biopsias', 'Distribución de resultados de biopsia', 'C2', ['fig_c2_donas', 'fig_c2_barras']), + item('cama_birads_456_mastografia', 'Porcentaje individual de mastografías', 'C2', ['fig_c2_donas', 'fig_c2_barras']), + item('cama_birads_456_paciente', 'Porcentaje de pacientes con resultados de BI-RADS 4, 5 y 6', 'C2', ['fig_c2_donas', 'fig_c2_barras']), + item('cama_confirmacion_birads45', 'Tasa de confirmación histopatológica', 'C1', ['fig_c1_puntos']), + item('cama_dias_toma_diagnostico', 'Tiempo de tamizaje a diagnóstico', 'C3r', ['fig_c3r_caja']), + item('cama_eu38a', 'Días de la toma de la mastografía a su resultado', 'C3r', ['fig_c3r_caja']), +]; +const OTRO = (prefijo: string) => ['a', 'b', 'c', 'd', 'e', 'f'].map(letra => item(`${prefijo}_${letra}`, `Indicador ${letra}`, 'C2', ['f', 'g'])); + +describe('Resumen clínico de CaMa y los demás dominios', () => { + let fixture: ReturnType>, http: HttpTestingController; + beforeEach(() => { + vi.stubGlobal('IntersectionObserver', class { observe() {} unobserve() {} disconnect() {} }); + TestBed.configureTestingModule({ imports: [IndicadoresPage], providers: [provideRouter([]), provideHttpClient(), provideHttpClientTesting()] }); + for (const domain of ['tea', 'cacu', 'cama'] as const) TestBed.inject(IndicadoresMemory).finishInitialKpiPresentation(domain); + fixture = TestBed.createComponent(IndicadoresPage); http = TestBed.inject(HttpTestingController); + http.expectOne('/tea/indicadores').flush([]); fixture.detectChanges(); + }); + // The KPI and period requests are not what these tests are about. + afterEach(() => { fixture.destroy(); http.match(() => true); http.verify(); vi.unstubAllGlobals(); }); + function open(domain: Dominio, catalog: unknown[]) { + // The page starts in TEA, whose catalog is already answered: leave it first to load it again. + if (domain === fixture.componentInstance.dominio) { + fixture.componentInstance.changeDominio(domain === 'cacu' ? 'cama' : 'cacu'); fixture.detectChanges(); + http.match(() => true); + } + fixture.componentInstance.changeDominio(domain); fixture.detectChanges(); + http.expectOne('/' + domain + '/indicadores').flush(catalog); fixture.detectChanges(); + http.match(() => true); fixture.detectChanges(); + } + const root = () => fixture.nativeElement as HTMLElement; + const section = () => root().querySelector('.graphic-section') as HTMLElement; + const titles = () => [...root().querySelectorAll('.catalog-grid app-indicador-catalog-card h2')].map(e => e.textContent?.trim()); + + it('CaMa: «Indicadores clínicos» y un contador que cuenta lo que la sección muestra', () => { + // Fails if the heading or the counter go back to the whole catalog (6) while a card is not drawn. + open('cama', CAMA); + expect(root().querySelector('#graphic-section-title')?.textContent).toBe('Indicadores clínicos'); + expect(titles()).not.toContain('Distribución de resultados de biopsia'); + expect(root().querySelector('.catalog-count')?.textContent?.trim()).toBe(titles().length + ' indicadores publicados'); + }); + it('CaMa: sin buscador, indicadores fijados, navegación flotante, selector de representación ni conteo de figuras', () => { + // Fails if any of the controls the mockup does not have comes back to CaMa's summary. + open('cama', CAMA); + expect(root().querySelector('.catalog-search')).toBeNull(); + expect(section().textContent).not.toContain('Buscar indicadores'); + expect(root().querySelector('.pin-toggle')).toBeNull(); + expect(section().textContent).not.toContain('Fijar indicador'); + expect(root().querySelector('.graphic-navigation-trigger')).toBeNull(); + expect(section().querySelector('mat-form-field')).toBeNull(); + expect(section().textContent).not.toContain('Representación gráfica'); + expect(section().textContent).not.toContain('figuras publicadas'); + }); + it('CaMa: las figuras guardadas como fijadas no reordenan las tarjetas', () => { + // Fails if a pin saved earlier (the control is gone) still changes the order of CaMa's cards. + open('cama', CAMA); + const before = titles(); + fixture.componentInstance.togglePinned(CAMA[5] as never); fixture.detectChanges(); + expect(titles()).toEqual(before); + }); + it.each(['tea', 'cacu'] as const)('%s conserva buscador, fijados, navegación flotante, selector y conteo de figuras', domain => { + // Fails if CaMa's simplified section leaks into the other domains. + open(domain, OTRO(domain)); + expect(root().querySelector('.catalog-search')).not.toBeNull(); + expect(root().querySelectorAll('.pin-toggle').length).toBe(6); + expect(root().querySelector('.graphic-navigation-trigger')).not.toBeNull(); + expect(section().querySelector('app-indicador-catalog-card mat-form-field')).not.toBeNull(); + expect(section().textContent).toContain('2 figuras publicadas'); + expect(root().querySelector('.catalog-count')?.textContent?.trim()).toBe('6 indicadores publicados'); + }); + it('CaCu conserva su encabezado «Indicadores clínicos» y TEA «Indicadores gráficos»', () => { + open('cacu', OTRO('cacu')); + expect(root().querySelector('#graphic-section-title')?.textContent).toBe('Indicadores clínicos'); + open('tea', OTRO('tea')); + expect(root().querySelector('#graphic-section-title')?.textContent).toBe('Indicadores gráficos'); + }); +}); diff --git a/src/app/features/indicadores/indicadores-navegacion-lateral.spec.ts b/src/app/features/indicadores/indicadores-navegacion-lateral.spec.ts index f531f6c..639ee05 100644 --- a/src/app/features/indicadores/indicadores-navegacion-lateral.spec.ts +++ b/src/app/features/indicadores/indicadores-navegacion-lateral.spec.ts @@ -65,7 +65,8 @@ describe('UX-10 navegación lateral del catálogo gráfico', () => { } function expectNoFigureRequests() { http.expectNone(request => request.url.includes('/figuras/') || request.url.endsWith('/datos')); } - it.each(['tea', 'cacu', 'cama'] as const)('aparece solo en Resumen para el dominio %s', async domain => { + // CaMa follows the mockup and has no floating navigation (indicadores-cama-resumen-clinico.spec.ts). + it.each(['tea', 'cacu'] as const)('aparece solo en Resumen para el dominio %s', async domain => { await load([item('chart', 'Indicador gráfico')], domain); expect(trigger()).not.toBeNull(); page.changeSection('seguimiento'); fixture.detectChanges(); @@ -160,7 +161,7 @@ describe('UX-10 navegación lateral del catálogo gráfico', () => { it('mantiene keys únicas para títulos duplicados y navega a la tarjeta elegida', async () => { const items = [item('duplicate-a', 'Resultado clínico'), item('duplicate-b', 'Resultado clínico')]; - await load(items, 'cama'); + await load(items, 'cacu'); const scroll = vi.fn(); const focus = vi.spyOn(HTMLElement.prototype, 'focus'); for (const card of fixture.nativeElement.querySelectorAll('app-indicador-catalog-card')) { @@ -173,7 +174,7 @@ describe('UX-10 navegación lateral del catálogo gráfico', () => { fixture.detectChanges(); await fixture.whenStable(); fixture.detectChanges(); - const targetId = identityElementId(indicatorIdentity('cama', 'duplicate-b')); + const targetId = identityElementId(indicatorIdentity('cacu', 'duplicate-b')); expect(scroll).toHaveBeenCalledOnce(); expect(scroll.mock.instances[0]).toBe(fixture.nativeElement.querySelector('#' + targetId)); expect(focus).toHaveBeenCalled(); @@ -394,8 +395,8 @@ describe('UX-10 navegación lateral del catálogo gráfico', () => { vi.advanceTimersByTime(500); expect(page.navigationOpen()).toBe(true); pointer(trigger()!, 'pointerleave'); - page.changeDominio('cama'); - http.expectOne('/cama/indicadores').flush([item('b', 'CaMa')]); fixture.detectChanges(); + page.changeDominio('cacu'); + http.expectOne('/cacu/indicadores').flush([item('b', 'CaCu')]); fixture.detectChanges(); expect(page.navigationAttached()).toBe(false); pointer(trigger()!, 'pointerenter'); vi.advanceTimersByTime(500); diff --git a/src/app/features/indicadores/indicadores-page.html b/src/app/features/indicadores/indicadores-page.html index d871e29..5893415 100644 --- a/src/app/features/indicadores/indicadores-page.html +++ b/src/app/features/indicadores/indicadores-page.html @@ -97,9 +97,9 @@
-

{{ dominio === 'cacu' ? 'Indicadores clínicos' : 'Indicadores gráficos' }}

+

{{ dominio === 'cacu' || dominio === 'cama' ? 'Indicadores clínicos' : 'Indicadores gráficos' }}

@if (!catalogLoading() && !catalogError() && catalog().length) { -

{{ catalog().length }} indicadores publicados

+

{{ shownIndicators }} indicadores publicados

}
@if (catalogLoading()) { diff --git a/src/app/features/indicadores/indicadores-page.ts b/src/app/features/indicadores/indicadores-page.ts index c8f4b40..d209a54 100644 --- a/src/app/features/indicadores/indicadores-page.ts +++ b/src/app/features/indicadores/indicadores-page.ts @@ -289,6 +289,8 @@ export class IndicadoresPage { } return undefined; } + // How many indicators the graphic section shows: all the catalog, except in CaMa, which draws only some of them. + get shownIndicators() { return this.dominio === 'cama' ? this.searchResults().items.length : this.catalog().length; } get availableKpis() { return this.kpisByDomain[this.dominio].filter(definition => this.catalog().some(item => item.id === definition.id)); } get opportunityKpis() { const definitions = this.availableKpis; @@ -306,13 +308,15 @@ export class IndicadoresPage { private readonly catalogRequests = new Subject(); readonly catalog = signal([]); readonly searchQuery = signal(''); - readonly searchVisible = computed(() => this.catalog().length >= 5); + // CaMa follows the mockup: no search box and no pins; its cards are the ones the summary draws. + readonly searchVisible = computed(() => this.dominio !== 'cama' && this.catalog().length >= 5); readonly searchResults = computed(() => { const catalog = this.catalog(); // Stable presentation priority; search matches and pins still take precedence. const items = this.dominio === 'cacu' ? [...catalog.filter(item => item.id === 'cacu_eu7'), ...catalog.filter(item => item.id !== 'cacu_eu7')] : this.dominio === 'cama' ? catalog.filter(item => !CAMA_FUERA_DEL_RESUMEN.includes(item.id)) : catalog; + if (this.dominio === 'cama') return { items, active: false, count: 0 }; const query = this.normalizeSearch(this.searchQuery()); const prioritize = (group: Indicador[]) => [ ...group.filter(item => this.isPinned(item)), @@ -360,7 +364,7 @@ export class IndicadoresPage { cardIdentity(item: Indicador) { return indicatorIdentity(this.dominio, item.id); } cardElementId(item: Indicador) { return identityElementId(this.cardIdentity(item)); } get showGraphicNavigation() { - return this.activeSection() === 'resumen' && !this.fichaPacienteAbierta() && !this.catalogLoading() + return this.dominio !== 'cama' && this.activeSection() === 'resumen' && !this.fichaPacienteAbierta() && !this.catalogLoading() && !this.catalogError() && !this.initialPeriodBlocked && this.navigationItems().length > 0; } toggleGraphicNavigation(event?: MouseEvent) { diff --git a/src/app/features/indicadores/indicadores-pinning.spec.ts b/src/app/features/indicadores/indicadores-pinning.spec.ts index 8906a5e..cec6032 100644 --- a/src/app/features/indicadores/indicadores-pinning.spec.ts +++ b/src/app/features/indicadores/indicadores-pinning.spec.ts @@ -85,8 +85,9 @@ describe('UX-06E.D.3.B fijación temporal', () => { }); it('memoria independiente por dominio y persistente al recrear la página', async () => { await pin('i3'); page.changeDominio('cacu'); load('cacu'); expect(ids()).toEqual(items.map(i => i.id)); + // CaMa has no pin control (the mockup has none), so it neither keeps nor applies pins. await pin('i1'); page.changeDominio('cama'); load('cama'); expect(ids()).toEqual(items.map(i => i.id)); - await pin('i4'); page.changeDominio('cacu'); load('cacu'); expect(ids()[0]).toBe('i1'); + page.changeDominio('cacu'); load('cacu'); expect(ids()[0]).toBe('i1'); page.changeDominio('tea'); load(); expect(ids()[0]).toBe('i3'); fixture.destroy(); create(); load(); expect(ids()[0]).toBe('i3'); http.expectNone(() => true); });