feat(cama): readable BI-RADS and age labels, the biopsy report date, and no export of a list that does not match its group
Contract review against WebApi 1d5f1e0 (webapi/cama_analysis.py, cama_cohort.py, docs/cama-cohort-api.md).
- The cohort's list is rewritten once on arrival so the table, the record and the PDF/XLSX show
"BI-RADS 5" and "50 a 59 años" (also "Menores de 40 años", "70 años o más", "Sin dato"); the codes
stay in `<clave>_codigo` and in the filter options, which are what the requests send. Only codes
whose meaning the API's own code confirms are labelled; biopsy grades are left as they arrive.
- The record calls the biopsy date what the list calls it ("Fecha de reporte"): in the cohort it is
the date of the biopsy report, which can be known while its result is not.
- With the same cohort revision, cut-off and filter the aggregate and the list are counted from the
same rows, so a different total breaks the contract: the list shows an alert and its PDF/XLSX
buttons are disabled.
- When no category is published the analysis says so and keeps "No publicado": the answer cannot
tell an empty cohort from categories under the threshold.
- Tests: the chosen cut-off reaches the aggregate, the list, the record and every page of the file.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import { inject, Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { map } from 'rxjs';
|
||||
import { isoDate } from './cacu-seguimiento.models';
|
||||
import { etiquetaDeFiltro } from './etiquetas-cohorte';
|
||||
import { Dominio, requireDominio } from './indicadores.models';
|
||||
|
||||
// A follow-up list whose filters and columns come with the answer, so the view needs no code of its own per
|
||||
@@ -94,9 +95,35 @@ export function seguimientoTablaResponse(v: unknown): SeguimientoTablaResponse {
|
||||
|| !v['items'].every(item => record(item) && text(item['id_seudonimo']) && Object.values(item).every(valor))) {
|
||||
throw new SeguimientoInvalido('Respuesta de seguimiento inválida');
|
||||
}
|
||||
return v as unknown as SeguimientoTablaResponse;
|
||||
const respuesta = v as unknown as SeguimientoTablaResponse;
|
||||
return respuesta.cohorte ? etiquetarCohorte(respuesta) : respuesta;
|
||||
}
|
||||
|
||||
/**
|
||||
* A cohort's list announces its filters with the code as the label and carries the codes as values. The answer is
|
||||
* rewritten once, here, so the table, the record and the files all show «BI-RADS 5» and «50 a 59 años»; the code stays
|
||||
* in `<clave>_codigo` and in the filters' options, which are what the requests send.
|
||||
*/
|
||||
export function etiquetarCohorte(r: SeguimientoTablaResponse): SeguimientoTablaResponse {
|
||||
const claves = Object.keys(ETIQUETADAS);
|
||||
return {
|
||||
...r,
|
||||
filtros_disponibles: r.filtros_disponibles.map(f => claves.includes(f.clave)
|
||||
? { ...f, opciones: f.opciones.map(o => o.etiqueta === o.codigo ? { ...o, etiqueta: etiquetaDeFiltro(f.clave, o.codigo) } : o) } : f),
|
||||
items: r.items.map(item => {
|
||||
const nuevo = { ...item };
|
||||
for (const k of claves) {
|
||||
const valor = item[k];
|
||||
if (typeof valor !== 'string' || etiquetaDeFiltro(k, valor) === valor) continue;
|
||||
if (nuevo[k + '_codigo'] === undefined) nuevo[k + '_codigo'] = valor;
|
||||
nuevo[k] = etiquetaDeFiltro(k, valor);
|
||||
}
|
||||
return nuevo;
|
||||
}),
|
||||
};
|
||||
}
|
||||
const ETIQUETADAS: Readonly<Record<string, true>> = { birads: true, grupo_edad: true };
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class SeguimientoTablaService {
|
||||
private readonly http = inject(HttpClient);
|
||||
|
||||
Reference in New Issue
Block a user