diff --git a/src/app/features/indicadores/fixtures/regresion_cacu_tea_mapeo.json b/src/app/features/indicadores/fixtures/regresion_cacu_tea_mapeo.json index fb039d4..5942e66 100644 --- a/src/app/features/indicadores/fixtures/regresion_cacu_tea_mapeo.json +++ b/src/app/features/indicadores/fixtures/regresion_cacu_tea_mapeo.json @@ -384,7 +384,7 @@ "estrato": null, "valores_estrato": [], "grupos": { - "principal": "principal" + "total": "Total" }, "categorias": {}, "grupos_de_categoria": {}, @@ -410,7 +410,7 @@ "filas": [ { "periodo": "2021-S1", - "grupo": "principal", + "grupo": "total", "estrato": null, "suprimido": 0, "numerador": 0, @@ -423,7 +423,7 @@ }, { "periodo": "2025-S2", - "grupo": "principal", + "grupo": "total", "estrato": null, "suprimido": 0, "numerador": 1, @@ -463,7 +463,7 @@ "<25": "<25" }, "grupos": { - "principal": "principal" + "total": "Total" }, "categorias": {}, "grupos_de_categoria": {}, @@ -489,7 +489,7 @@ "filas": [ { "periodo": "2025-S2", - "grupo": "principal", + "grupo": "total", "estrato": "25-34", "suprimido": 0, "numerador": 0, @@ -502,7 +502,7 @@ }, { "periodo": "2025-S2", - "grupo": "principal", + "grupo": "total", "estrato": "35-44", "suprimido": 0, "numerador": 0, @@ -515,7 +515,7 @@ }, { "periodo": "2025-S2", - "grupo": "principal", + "grupo": "total", "estrato": "45-54", "suprimido": 0, "numerador": 1, @@ -528,7 +528,7 @@ }, { "periodo": "2025-S2", - "grupo": "principal", + "grupo": "total", "estrato": "55-64", "suprimido": 0, "numerador": 0, @@ -541,7 +541,7 @@ }, { "periodo": "2025-S2", - "grupo": "principal", + "grupo": "total", "estrato": "<25", "suprimido": 0, "numerador": 0, @@ -573,7 +573,7 @@ "PRE_COLPOSCOPIA": "PRE_COLPOSCOPIA" }, "grupos": { - "principal": "principal" + "total": "Total" }, "categorias": {}, "grupos_de_categoria": {}, @@ -599,7 +599,7 @@ "filas": [ { "periodo": "2025-S2", - "grupo": "principal", + "grupo": "total", "estrato": "PRE_COLPOSCOPIA", "suprimido": 0, "numerador": 1, @@ -845,7 +845,7 @@ "estrato": null, "valores_estrato": [], "grupos": { - "principal": "principal" + "total": "Total" }, "categorias": {}, "grupos_de_categoria": {}, @@ -871,7 +871,7 @@ "filas": [ { "periodo": "2021-S1", - "grupo": "principal", + "grupo": "total", "estrato": null, "suprimido": 0, "numerador": 0, @@ -884,7 +884,7 @@ }, { "periodo": "2025-S2", - "grupo": "principal", + "grupo": "total", "estrato": null, "suprimido": 0, "numerador": 19, diff --git a/src/app/features/indicadores/indicadores-cacu-fhir.spec.ts b/src/app/features/indicadores/indicadores-cacu-fhir.spec.ts index 482bce9..a4a773b 100644 --- a/src/app/features/indicadores/indicadores-cacu-fhir.spec.ts +++ b/src/app/features/indicadores/indicadores-cacu-fhir.spec.ts @@ -138,7 +138,7 @@ describe('Las medidas de CaCu como las publica el WebApi con figuras y etiquetas const eu13 = medida('CACU-EU13'); const cuenta = (code: string, count: number) => ({ code: { coding: [{ code }] }, count }); const reporte13 = { resourceType: 'MeasureReport', id: 'CACU-EU13-1', period: { start: '2025-01-01', end: '2025-06-30' }, - group: [{ id: 'principal', population: [cuenta('initial-population', 4), cuenta('denominator', 4), cuenta('numerator', 1)], + group: [{ code: { coding: [{ code: 'principal' }] }, population: [cuenta('initial-population', 4), cuenta('denominator', 4), cuenta('numerator', 1)], measureScore: { value: 0.25, extension: [{ url: `${STRUCTURE}/ic-bajo`, valueDecimal: 0.0456 }, { url: `${STRUCTURE}/ic-alto`, valueDecimal: 0.6994 }] } }] } as unknown as Report; const datos = datosDeReportes(eu13, [reporte13], 'semestre'); expect(datos.filas[0]).toMatchObject({ valor: 25, ic_bajo: 4.6, ic_alto: 69.9 }); @@ -146,4 +146,22 @@ describe('Las medidas de CaCu como las publica el WebApi con figuras y etiquetas expect(banda.name).toBe('Intervalo de confianza'); expect(banda.y).toEqual([69.9, 4.6]); }); + + it('un C1 de CaCu cuyo grupo se llama principal dibuja su tendencia en el histórico', () => { + // Pins down: the WebApi names the group of a proportion `principal`; the page reads it as `total`, the group the + // history trend draws, for CaCu as for CaMa. Fails if the rows keep the group `principal` and the trend comes out + // empty, with its period listed as having no data. + const cuenta = (code: string, count: number) => ({ code: { coding: [{ code }] }, count }); + for (const id of ['CACU-EU13', 'IND1']) { + const medida13 = medida(id); + const reporte = { resourceType: 'MeasureReport', id: id + '-1', period: { start: '2025-01-01', end: '2025-06-30' }, + group: [{ code: { coding: [{ code: 'principal' }] }, population: [cuenta('initial-population', 4), cuenta('denominator', 4), cuenta('numerator', 1)], + measureScore: { value: 0.25 } }] } as unknown as Report; + const datos = datosDeReportes(medida13, [reporte], 'semestre'); + expect(datos.filas[0]['grupo']).toBe('total'); + const figura = historicoFigura(datos, 'claro'); + expect((figura.figure as unknown as { data: { y: number[] }[] }).data[1].y).toEqual([25]); + expect(figura.sinDato).toEqual([]); + } + }); }); diff --git a/src/app/features/indicadores/indicadores-fhir.ts b/src/app/features/indicadores/indicadores-fhir.ts index 12645a4..70c7867 100644 --- a/src/app/features/indicadores/indicadores-fhir.ts +++ b/src/app/features/indicadores/indicadores-fhir.ts @@ -253,10 +253,10 @@ export function datosDeReportes(measure: Measure, reports: Report[], tipo: TipoP : { ...declaradas, ...Object.fromEntries([...extras].map(([categoria, etiqueta]) => [categoria, { etiqueta, color: null, grupo: null }])) }; const totales: Record[] = []; - // CaMa's page names the primary group of a proportion `total`; the WebApi names it `principal`. + // The page names the primary group of a proportion `total`; the WebApi names it `principal`. const nombre = (codigo: string | undefined) => { const grupo = codigo ?? 'TOTAL'; - return cama && kind === 'C1' && grupo === GRUPO_PRINCIPAL_FHIR ? GRUPO_PRINCIPAL_PAGINA : grupo; + return kind === 'C1' && grupo === GRUPO_PRINCIPAL_FHIR ? GRUPO_PRINCIPAL_PAGINA : grupo; }; const grupos = Object.fromEntries((measure.group ?? []).map(g => { const id = nombre(code(g.code)); diff --git a/src/app/features/indicadores/indicadores-regresion-fhir.spec.ts b/src/app/features/indicadores/indicadores-regresion-fhir.spec.ts index 0d166ab..fd28502 100644 --- a/src/app/features/indicadores/indicadores-regresion-fhir.spec.ts +++ b/src/app/features/indicadores/indicadores-regresion-fhir.spec.ts @@ -11,7 +11,7 @@ describe('Regresión del mapeo FHIR en CaCu y TEA', () => { it('las 16 medidas se mapean igual que antes: ids, catálogo, ficha y filas de datos', () => { // Pins down: ids, catalog entries, sheets and data rows of CaCu's seven and TEA's nine measures, over real reports, // equal the recorded ones; an error counts as a result too. Fails if a change meant for CaMa (its id table, its - // group name, its undeclared categories, its sheet code) reaches another domain. If the new result is the right one, + // undeclared categories, its sheet code) reaches another domain. If the new result is the right one, // regenerate the recorded mapping and say why in the change. const actual = mapeoDeCacuYTea({ indicadorId, indicadorDeMeasure, metadatosDeMeasure, datosDeReportes }); expect(Object.keys(actual)).toEqual(Object.keys(esperado));