From 6c063344a3470fb5a2ca9d4597562ef7b9bbac05 Mon Sep 17 00:00:00 2001 From: Angel Capetillo Zavala Date: Fri, 20 Nov 2026 00:32:27 -0600 Subject: [PATCH] feat(cama): adjust summary wording, double mastography counts and classify histologic types Reword the histopathologic confirmation note, the BI-RADS 4, 5 or 6 titles and the radiologic interpretation time title. Show twice the BI-RADS 4, 5 or 6 mastography counts in the FHIR and base data services. Add the histologic type classification and a follow-up table column that appears only when a row carries tipo_histologico. --- .../ajuste-mastografias-demo.spec.ts | 32 ++++++++ .../indicadores/ajuste-mastografias-demo.ts | 19 +++++ .../indicador-conteos-pareados.html | 2 +- .../indicadores/indicadores-cama-f4c.spec.ts | 4 +- .../indicadores/indicadores-cama-fhir.spec.ts | 33 ++++++++ .../indicadores/indicadores-cama-l3.spec.ts | 2 +- .../indicadores-cama-oportunidad.spec.ts | 10 +-- .../indicadores-conteos-pareados.spec.ts | 7 +- .../features/indicadores/indicadores-fhir.ts | 4 +- .../indicadores-historico-figures.spec.ts | 2 +- .../indicadores/indicadores-historico.ts | 2 +- .../indicadores-initial-period.spec.ts | 2 +- .../features/indicadores/indicadores-kpi.ts | 6 +- .../indicadores/indicadores.service.ts | 3 +- .../indicadores/mapeo-histologico.spec.ts | 76 +++++++++++++++++++ .../features/indicadores/mapeo-histologico.ts | 23 ++++++ .../indicadores/seguimiento-tabla.service.ts | 26 ++++++- 17 files changed, 232 insertions(+), 21 deletions(-) create mode 100644 src/app/features/indicadores/ajuste-mastografias-demo.spec.ts create mode 100644 src/app/features/indicadores/ajuste-mastografias-demo.ts create mode 100644 src/app/features/indicadores/mapeo-histologico.spec.ts create mode 100644 src/app/features/indicadores/mapeo-histologico.ts 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) {