diff --git a/src/app/features/indicadores/indicador-kpi-card.ts b/src/app/features/indicadores/indicador-kpi-card.ts index 363d5b1..a76d6db 100644 --- a/src/app/features/indicadores/indicador-kpi-card.ts +++ b/src/app/features/indicadores/indicador-kpi-card.ts @@ -13,7 +13,7 @@ import { MatCardModule } from '@angular/material/card';
{{ value }}@if (unit) { {{ unit }} }
} @if (temporalReference) {{{ temporalReference }}
} -{{ state }}
+ @if (!(quietWhenAvailable && state === 'Disponible')) {{{ state }}
} @if (informationLine) {{{ informationLine }}
} `, @@ -28,6 +28,9 @@ import { MatCardModule } from '@angular/material/card'; .kpi-state, .additional-info { color: var(--issste-text-secondary); font: var(--mat-sys-body-medium); } .value { font: var(--mat-sys-headline-medium); } .value span { margin-inline-start: .3em; } + // CaMa's cards are as tall as their grid row. + :host-context(.kpi-section[data-domain='cama']) { display: flex; flex-direction: column; } + :host-context(.kpi-section[data-domain='cama']) mat-card { flex: 1 1 auto; height: auto; } `, }) export class IndicadorKpiCard { @@ -38,6 +41,8 @@ export class IndicadorKpiCard { @Input() loading = false; @Input() notes: string[] = []; @Input() state = 'Pendiente de definición'; + // A card that shows its value needs no "Disponible" line. + @Input() quietWhenAvailable = false; @Input() additionalInfo?: string; get informationLine(): string | undefined { const lines = [this.additionalInfo, ...this.notes].map(value => value?.trim()).filter((value): value is string => !!value); diff --git a/src/app/features/indicadores/indicador-kpi-panel.spec.ts b/src/app/features/indicadores/indicador-kpi-panel.spec.ts index 4c274ce..1dab35f 100644 --- a/src/app/features/indicadores/indicador-kpi-panel.spec.ts +++ b/src/app/features/indicadores/indicador-kpi-panel.spec.ts @@ -172,13 +172,14 @@ describe('KPI integración con autoridad global', () => { for (const domain of ['cacu', 'cama'] as const) { load(domain); const req = requests(); expect(req).toHaveLength(KPI_BY_DOMAIN[domain].length); - req.forEach((r, i) => r.flush({ ...response(i, domain), notas: ['Nota del pie de la figura.'] })); + // CaMa draws its cards in a different order than KPI_BY_DOMAIN: answer each request by its indicator. + req.forEach(r => r.flush({ ...response(KPI_BY_DOMAIN[domain].findIndex(d => r.request.url.endsWith('/' + d.id + '/datos')), domain), notas: ['Nota del pie de la figura.'] })); fixture.detectChanges(); const cards = [...fixture.nativeElement.querySelectorAll('app-indicador-kpi-card')]; - expect(cards).toHaveLength(domain === 'cacu' ? 5 : 3); - expect(cards.map(card => card.querySelector('.value')?.firstChild?.textContent?.trim())).toEqual(domain === 'cacu' ? ['5', undefined, '7', undefined, undefined] : ['5', '40.0', '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)']); - expect(cards.map(card => card.querySelector('.kpi-state')?.textContent.trim())).toEqual(domain === 'cacu' ? ['Disponible', 'Selección no consolidable', 'Disponible', 'Indicador no disponible', 'Indicador no disponible'] : ['Disponible', 'Disponible', 'Disponible']); + expect(cards).toHaveLength(domain === 'cacu' ? 5 : 6); + expect(cards.map(card => card.querySelector('.value')?.firstChild?.textContent?.trim())).toEqual(domain === 'cacu' ? ['5', undefined, '7', undefined, undefined] : ['5', undefined, '7', undefined, '40.0', '7']); + expect(cards.map(card => card.querySelector('.value span')?.textContent.trim())).toEqual(domain === 'cacu' ? ['pacientes', undefined, 'días (mediana)', undefined, undefined] : ['pacientes', undefined, 'días (mediana)', undefined, '%', 'días (mediana)']); + expect(cards.map(card => card.querySelector('.kpi-state')?.textContent.trim())).toEqual(domain === 'cacu' ? ['Disponible', 'Selección no consolidable', 'Disponible', 'Indicador no disponible', 'Indicador no disponible'] : [undefined, 'Integración pendiente', undefined, 'Integración pendiente', undefined, undefined]); expect(cards.map(card => card.textContent)).toEqual(expect.arrayContaining([ expect.stringContaining('2025-S1'), expect.stringContaining(domain === 'cacu' ? '5 citologías; primer cuartil: 3 días; tercer cuartil: 9 días.' : '5 mastografías; Q1 a Q3: 3 a 9 días.'), diff --git a/src/app/features/indicadores/indicador-kpi-panel.ts b/src/app/features/indicadores/indicador-kpi-panel.ts index 8cc7bcc..224161a 100644 --- a/src/app/features/indicadores/indicador-kpi-panel.ts +++ b/src/app/features/indicadores/indicador-kpi-panel.ts @@ -19,11 +19,15 @@ interface KpiDisplay extends KpiResult { period?: string; earlier?: boolean; ver imports: [IndicadorKpiCard, MatButtonModule], template: `La búsqueda inicial se detuvo para conservar tu selección. Pulsa Aplicar para consultar.
} - @let kpis = opportunityKpis; + @let kpis = kpiCards; @if (kpis.length && !initialPeriodBlocked) {