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:
@@ -16,5 +16,32 @@ export const agregado = (extra: Partial<AnalisisAgregado> = {}): AnalisisAgregad
|
||||
],
|
||||
...extra,
|
||||
});
|
||||
/**
|
||||
* The answer of the cohort's list as the API sends it: only the two filters it announces, with the code as their label,
|
||||
* the codes as the values of the rows, the biopsy date being the date of the report (the result can still be unknown),
|
||||
* and the cohort quoted back. `n` rows M-0001…; the third row has a reported biopsy whose result is not known at the cut-off.
|
||||
*/
|
||||
export function listaCohorte(o: { corte?: string; filtros?: Record<string, string>; page?: number; size?: number; n?: number; meses?: number } = {}): Record<string, any> {
|
||||
const { corte = CORTE, filtros = {}, page = 1, size = 50, n = 6, meses = 0 } = o;
|
||||
const todos = Array.from({ length: n }, (_, i) => ({
|
||||
id_seudonimo: `M-${String(i + 1).padStart(4, '0')}`, grupo_edad: i % 2 ? '60-69' : '50-59', birads: 'BIRADS_5', mastografia_fecha: '2025-02-01',
|
||||
biopsia: i === 0 ? 'BENIGNO' : null, biopsia_fecha: i === 0 || i === 2 ? '2025-02-15' : null,
|
||||
}));
|
||||
const opciones = (codigos: string[]) => codigos.map(c => ({ codigo: c, etiqueta: c }));
|
||||
return {
|
||||
simulado: true, ...CONTEXTO, corte, ventana: { meses, desde: '2025-02-01', hasta: corte }, campo_ventana: 'mastografia_fecha',
|
||||
filtros: { birads: null, grupo_edad: null, ...filtros },
|
||||
filtros_disponibles: [
|
||||
{ clave: 'birads', etiqueta: 'Categoría BI-RADS', opciones: opciones(['BIRADS_4', 'BIRADS_4A', 'BIRADS_4B', 'BIRADS_4C', 'BIRADS_5', 'BIRADS_6']) },
|
||||
{ clave: 'grupo_edad', etiqueta: 'Grupo de edad', opciones: opciones(['MENOR_40', '40-49', '50-59', '60-69', '70+', 'SIN_DATO']) }],
|
||||
columnas: [
|
||||
{ clave: 'id_seudonimo', etiqueta: 'Identificador seudónimo' }, { clave: 'grupo_edad', etiqueta: 'Grupo de edad' },
|
||||
{ clave: 'birads', etiqueta: 'Última mastografía', detalles: [{ clave: 'mastografia_fecha', etiqueta: 'Fecha' }] },
|
||||
{ clave: 'biopsia', etiqueta: 'Resultado histopatológico', detalles: [{ clave: 'biopsia_fecha', etiqueta: 'Fecha de reporte' }] }],
|
||||
paginacion: { page, page_size: size, total_items: n, total_pages: Math.max(1, Math.ceil(n / size)) },
|
||||
items: todos.slice((page - 1) * size, page * size),
|
||||
};
|
||||
}
|
||||
|
||||
/** What the API sends on the wire: the aggregate plus the fields of the prototype it leaves empty. */
|
||||
export const agregadoJson = (extra: Record<string, unknown> = {}) => ({ ...agregado(), horizonte_dias: 0, indicadores: [], ...extra });
|
||||
|
||||
Reference in New Issue
Block a user