diff --git a/src/app/features/indicadores/ajuste-mastografias-demo.spec.ts b/src/app/features/indicadores/ajuste-mastografias-demo.spec.ts new file mode 100644 index 0000000..115d59b --- /dev/null +++ b/src/app/features/indicadores/ajuste-mastografias-demo.spec.ts @@ -0,0 +1,32 @@ +// Covers the x2 shown for CaMa's mastographies in the demonstration build, on hand-made C2 rows. +import { ajustarMastografiasDemo } from './ajuste-mastografias-demo'; +import { IndicadorDatos } from './indicadores.models'; + +const datos = (): IndicadorDatos => ({ + id: 'cama_birads_456_mastografia', contrato: 'C2', tipo_periodo: 'semestre', periodos: ['2025-S1', '2025-S2'], + filas: [ + { periodo: '2025-S1', categoria: 'BIRADS_4', n: 10, suprimido: 0 }, + { periodo: '2025-S2', categoria: 'BIRADS_4', n: 10, suprimido: 0 }, + { periodo: '2025-S2', categoria: 'BIRADS_5', n: null, suprimido: 1 }, + ], +}); + +describe('Mastografías en la demostración', () => { + it('duplica el conteo de todos los periodos y deja intactas las celdas suprimidas', () => { + // Fails if a period is left out (the factor must not depend on the filter), a suppressed cell becomes a number, or the factor changes. + const r = ajustarMastografiasDemo('cama', 'cama_birads_456_mastografia', datos()); + expect(r.filas.map(f => f['n'])).toEqual([20, 20, null]); + }); + it('no modifica los datos recibidos', () => { + // Fails if the cached API payload is mutated, which would double again on every read. + const original = datos(); + ajustarMastografiasDemo('cama', 'cama_birads_456_mastografia', original); + expect(original.filas.map(f => f['n'])).toEqual([10, 10, null]); + }); + it('no afecta a otros indicadores ni a otros dominios', () => { + // Fails if the factor leaks to the patients' count or to another domain with the same indicator id. + const d = datos(); + expect(ajustarMastografiasDemo('cama', 'cama_birads_456_paciente', d)).toBe(d); + expect(ajustarMastografiasDemo('cacu', 'cama_birads_456_mastografia', d)).toBe(d); + }); +}); diff --git a/src/app/features/indicadores/ajuste-mastografias-demo.ts b/src/app/features/indicadores/ajuste-mastografias-demo.ts new file mode 100644 index 0000000..315e892 --- /dev/null +++ b/src/app/features/indicadores/ajuste-mastografias-demo.ts @@ -0,0 +1,19 @@ +import { IndicadorDatos } from './indicadores.models'; + +// The demonstration build shows twice the mastographies the API reports, in every period, for CaMa's BI-RADS 4, 5 +// or 6 indicator. Resumen and Histórico read it through the same service call, so both show the same counts. +const INDICADOR = 'cama_birads_456_mastografia'; +export const FACTOR_MASTOGRAFIAS = 2; + +const doble = >(fila: T): T => + typeof fila['n'] === 'number' && Number.isFinite(fila['n']) ? { ...fila, n: fila['n'] * FACTOR_MASTOGRAFIAS } : fila; + +/** The data with each published count `n`, and each stratum total, multiplied; suppressed or missing cells stay as they are. */ +export function ajustarMastografiasDemo(dominio: string, indicador: string, datos: IndicadorDatos): IndicadorDatos { + if (dominio !== 'cama' || indicador !== INDICADOR) return datos; + return { + ...datos, + filas: datos.filas.map(doble), + ...(Array.isArray(datos['totales_estrato']) ? { totales_estrato: (datos['totales_estrato'] as Record[]).map(doble) } : {}), + }; +} diff --git a/src/app/features/indicadores/indicador-conteos-pareados.html b/src/app/features/indicadores/indicador-conteos-pareados.html index b16e730..2aac49c 100644 --- a/src/app/features/indicadores/indicador-conteos-pareados.html +++ b/src/app/features/indicadores/indicador-conteos-pareados.html @@ -7,7 +7,7 @@ @case ('incompatible') {

Respuesta incompatible: {{ message }}

} } @if (status() === 'ready' && model; as m) { - @let tituloMastografias = 'Porcentaje de mastografías con resultado en la clasificación de BI-RADS 4, 5 y 6, ' + m.periodo; + @let tituloMastografias = 'Porcentaje de mastografías con resultado en la clasificación de BI-RADS 4, 5 o 6, ' + m.periodo; @let tituloPacientes = 'Porcentaje de pacientes con resultados de BI-RADS 4, 5 o 6, ' + m.periodo; @if (pages.length > 1) {