diff --git a/src/app/features/indicadores/indicador-kpi-panel.spec.ts b/src/app/features/indicadores/indicador-kpi-panel.spec.ts index 429e79c..9e5ede1 100644 --- a/src/app/features/indicadores/indicador-kpi-panel.spec.ts +++ b/src/app/features/indicadores/indicador-kpi-panel.spec.ts @@ -187,7 +187,7 @@ describe('KPI integración con autoridad global', () => { expect(cards.map(card => card.querySelector('.value')?.firstChild?.textContent?.trim())).toEqual(['5', undefined, '7', undefined, undefined]); expect(cards.map(card => card.querySelector('.value span')?.textContent.trim())).toEqual(['pacientes', undefined, 'días (mediana)', undefined, undefined]); 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', 'Selección no consolidable', 'Disponible', 'Integración pendiente', 'Integración pendiente'] : ['Disponible', 'Integración pendiente', 'Disponible', 'Integración pendiente', 'Indicador no disponible']); expect(cards.map(card => card.textContent)).toEqual(expect.arrayContaining([ 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/indicadores-cacu-fhir.ts b/src/app/features/indicadores/indicadores-cacu-fhir.ts index fb0f1ac..12e4e14 100644 --- a/src/app/features/indicadores/indicadores-cacu-fhir.ts +++ b/src/app/features/indicadores/indicadores-cacu-fhir.ts @@ -8,10 +8,12 @@ export const CACU_MEASURE_IDS: Readonly> = { 'CACU-CONFIRMACION-CITOLOGIA': 'cacu_confirmacion_citologia', 'CACU-DIAS-BIOPSIA-DIAGNOSTICO': 'cacu_dias_biopsia_diagnostico', 'CACU-DIAS-COLPOSCOPIA-BIOPSIA': 'cacu_dias_colposcopia_biopsia', + 'CACU-DIAS-DIAGNOSTICO-TRATAMIENTO': 'cacu_dias_diagnostico_tratamiento', 'CACU-DIAS-RESULTADO-COLPOSCOPIA': 'cacu_dias_resultado_colposcopia', 'CACU-DIAS-TOMA-BIOPSIA': 'cacu_dias_toma_biopsia', 'CACU-DIAS-TOMA-COLPOSCOPIA': 'cacu_dias_toma_colposcopia', 'CACU-DIAS-TOMA-DIAGNOSTICO': 'cacu_dias_toma_diagnostico', + 'CACU-DIAS-TOMA-TRATAMIENTO': 'cacu_dias_toma_tratamiento', 'CACU-EU-TIEMPO-REPORTE': 'cacu_eu_tiempo_reporte', 'CACU-EU13': 'cacu_eu13', 'CACU-EU7': 'cacu_eu7', diff --git a/src/app/features/indicadores/indicadores-cacu-final.spec.ts b/src/app/features/indicadores/indicadores-cacu-final.spec.ts index bc3a893..acaf5ff 100644 --- a/src/app/features/indicadores/indicadores-cacu-final.spec.ts +++ b/src/app/features/indicadores/indicadores-cacu-final.spec.ts @@ -87,8 +87,8 @@ describe('CaCu: oportunidad y selección independiente de todos los reportes', ( 'Pacientes evaluadas', 'Días de toma a resultado', 'Tiempo de tamizaje a diagnóstico', 'Tiempo de tamizaje a tratamiento', 'Tiempo de diagnóstico a tratamiento', ]); for (const kpi of kpis.slice(3)) { - expect(kpi.querySelectorAll('p')).toHaveLength(1); - expect(kpi.querySelector('p')?.textContent).toBe('Indicador no disponible'); + expect(kpi.querySelector('.kpi-state')?.textContent?.trim()).toBe('Integración pendiente'); + expect(kpi.textContent).toContain('aún no está publicado'); } expect(root.querySelector('.kpi-grid')?.getAttribute('style')).toContain('--kpi-count: 5'); expect(fixture.debugElement.queryAll(By.directive(IndicadorKpiPanel))).toHaveLength(3); diff --git a/src/app/features/indicadores/indicadores-kpi-resultado.spec.ts b/src/app/features/indicadores/indicadores-kpi-resultado.spec.ts index c41e96c..7ce6983 100644 --- a/src/app/features/indicadores/indicadores-kpi-resultado.spec.ts +++ b/src/app/features/indicadores/indicadores-kpi-resultado.spec.ts @@ -130,7 +130,8 @@ describe('P0-C.1: cinco tarjetas de oportunidad', () => { expect(cards.map(c => c.querySelector('.value')?.firstChild?.textContent?.trim())).toEqual(['20', '12', '52', undefined, undefined]); expect(cards.map(c => c.querySelector('.value span')?.textContent)).toEqual(['pacientes', 'días (mediana)', 'días (mediana)', undefined, undefined]); for (const card of cards.slice(3)) { - expect(card.querySelectorAll('p')).toHaveLength(1); expect(card.querySelector('p')!.textContent).toBe('Indicador no disponible'); + expect(card.querySelector('.kpi-state')?.textContent?.trim()).toBe('Integración pendiente'); + expect(card.textContent).toContain('aún no está publicado'); } http.expectNone(() => true); } finally { f.destroy(); vi.unstubAllGlobals(); http.verify(); } diff --git a/src/app/features/indicadores/indicadores-kpi-tratamiento.spec.ts b/src/app/features/indicadores/indicadores-kpi-tratamiento.spec.ts new file mode 100644 index 0000000..83a991a --- /dev/null +++ b/src/app/features/indicadores/indicadores-kpi-tratamiento.spec.ts @@ -0,0 +1,22 @@ +// What this module covers: CaCu's two times to treatment: their ids from the API's measures, and their cards, which wait +// as pending until the catalog publishes them and then give way to the real ones. +import { CACU_MEASURE_IDS } from './indicadores-cacu-fhir'; +import { CACU_TRATAMIENTO_KPIS, cacuPendingKpiCards } from './indicadores-kpi'; + +describe('Tiempos a tratamiento de CaCu', () => { + it('las medidas del API se traducen a los ids de la web, sin quedar en mayúsculas', () => { + // Fails if a measure is missing from the map: it would reach the page as CACU_DIAS_TOMA_TRATAMIENTO. + expect(CACU_MEASURE_IDS['CACU-DIAS-TOMA-TRATAMIENTO']).toBe('cacu_dias_toma_tratamiento'); + expect(CACU_MEASURE_IDS['CACU-DIAS-DIAGNOSTICO-TRATAMIENTO']).toBe('cacu_dias_diagnostico_tratamiento'); + expect(CACU_TRATAMIENTO_KPIS.map(k => k.id)).toEqual(['cacu_dias_toma_tratamiento', 'cacu_dias_diagnostico_tratamiento']); + }); + it('sin ninguna tarjeta dibujada no se agrega nada', () => { + expect(cacuPendingKpiCards([])).toEqual([]); + }); + it('las que el catálogo aún no publica quedan pendientes, y las publicadas ya no', () => { + expect(cacuPendingKpiCards(['cacu_eu7']).map(c => [c.definition.id, c.pending])).toEqual([ + ['cacu_dias_toma_tratamiento', true], ['cacu_dias_diagnostico_tratamiento', true]]); + expect(cacuPendingKpiCards(['cacu_eu7', 'cacu_dias_toma_tratamiento']).map(c => c.definition.id)).toEqual(['cacu_dias_diagnostico_tratamiento']); + expect(cacuPendingKpiCards(['cacu_eu7', ...CACU_TRATAMIENTO_KPIS.map(k => k.id)])).toEqual([]); + }); +}); diff --git a/src/app/features/indicadores/indicadores-kpi.ts b/src/app/features/indicadores/indicadores-kpi.ts index b2c40b6..16c2f63 100644 --- a/src/app/features/indicadores/indicadores-kpi.ts +++ b/src/app/features/indicadores/indicadores-kpi.ts @@ -79,6 +79,16 @@ export function camaKpiCards(published: (id: string) => boolean): KpiCardSlot[] const cards = CAMA_OPORTUNIDAD_KPIS.map(definition => ({ definition, pending: !published(definition.id) })); return cards.some(card => !card.pending) ? cards : []; } +// CaCu's two times to treatment stay outside KPI_BY_DOMAIN: they are queried only once the catalog publishes them, and +// keep their cards, pending, until then. Nothing is added until some other card is drawn. +export const CACU_TRATAMIENTO_KPIS: KpiDefinition[] = [ + { id: 'cacu_dias_toma_tratamiento', title: 'Tiempo de tamizaje a tratamiento', contrato: 'C3r', unit: 'días (mediana)' }, + { id: 'cacu_dias_diagnostico_tratamiento', title: 'Tiempo de diagnóstico a tratamiento', contrato: 'C3r', unit: 'días (mediana)' }, +]; +export function cacuPendingKpiCards(drawn: readonly string[]): KpiCardSlot[] { + if (!drawn.length) return []; + return CACU_TRATAMIENTO_KPIS.filter(definition => !drawn.includes(definition.id)).map(definition => ({ definition, pending: true })); +} // Published CaMa indicators whose card the summary does not draw. // The summary draws the paired card and the histopathology card; the rest of CaMa's indicators are in Histórico // and in Datos y definiciones, which still list the whole catalog. diff --git a/src/app/features/indicadores/indicadores-page.html b/src/app/features/indicadores/indicadores-page.html index b03db42..7961ceb 100644 --- a/src/app/features/indicadores/indicadores-page.html +++ b/src/app/features/indicadores/indicadores-page.html @@ -52,7 +52,7 @@ @if (resumen) { } -
+
@for (card of kpis; track dominio + ':' + card.definition.id) { @if (card.pending) { } } - @if (dominio === 'cacu') { - - - } @else if (dominio === 'cama') { + @if (dominio === 'cama') { } diff --git a/src/app/features/indicadores/indicadores-page.ts b/src/app/features/indicadores/indicadores-page.ts index bc34ab2..daac41c 100644 --- a/src/app/features/indicadores/indicadores-page.ts +++ b/src/app/features/indicadores/indicadores-page.ts @@ -17,7 +17,7 @@ import { applyGlobal, domainTypes, GlobalFilterState, IndicadoresMemory, pending import { IndicadorPeriodFilters } from './indicador-period-filters'; import { IndicadorCatalogCard } from './indicador-catalog-card'; import { esSocioConteos } from './indicadores-conteos-pareados'; -import { CACU_RESULTADO_KPI, CAMA_FUERA_DEL_RESUMEN, ID_HISTOPATOLOGIA_CAMA, KPI_BY_DOMAIN, KPI_RESUMEN_TEA, KpiCardSlot, camaKpiCards } from './indicadores-kpi'; +import { CACU_RESULTADO_KPI, CACU_TRATAMIENTO_KPIS, CAMA_FUERA_DEL_RESUMEN, ID_HISTOPATOLOGIA_CAMA, KPI_BY_DOMAIN, KPI_RESUMEN_TEA, KpiCardSlot, cacuPendingKpiCards, camaKpiCards } from './indicadores-kpi'; import { TeaResumenPeriodo } from './tea-resumen-periodo'; import { IndicadorKpiPanel } from './indicador-kpi-panel'; import { IndicadorScreeningRoute } from './indicador-screening-route'; @@ -342,7 +342,10 @@ export class IndicadoresPage { return this.dominio === 'cacu' && ROUTE_IDS.every(id => this.catalog().some(item => item.id === id)); } // How many indicators the graphic section shows: all the catalog, except in CaMa, which draws only some of them. - get availableKpis() { return this.kpisByDomain[this.dominio].filter(definition => this.catalog().some(item => item.id === definition.id)); } + get availableKpis() { + const definitions = this.dominio === 'cacu' ? [...this.kpisByDomain.cacu, ...CACU_TRATAMIENTO_KPIS] : this.kpisByDomain[this.dominio]; + return definitions.filter(definition => this.catalog().some(item => item.id === definition.id)); + } // TEA shows a summary paragraph instead of its cards for exactly one explicitly chosen period. get teaResumenPeriodo(): string | undefined { const selection = this.filters?.applied.selection; @@ -359,7 +362,8 @@ export class IndicadoresPage { // What the KPI grid draws. CaMa adds explicit pending cards for opportunity indicators the catalog does not publish. get kpiCards(): KpiCardSlot[] { if (this.dominio === 'cama') return camaKpiCards(id => this.catalog().some(item => item.id === id)); - return this.opportunityKpis.map(definition => ({ definition, pending: false })); + const cards = this.opportunityKpis.map(definition => ({ definition, pending: false })); + return this.dominio === 'cacu' ? [...cards, ...cacuPendingKpiCards(cards.map(card => card.definition.id))] : cards; } private readonly catalogRequests = new Subject(); readonly catalog = signal([]);