6c063344a3
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.
77 lines
5.4 KiB
TypeScript
77 lines
5.4 KiB
TypeScript
// Covers the histologic-type classification and its column in the follow-up table. It uses the CaMa follow-up
|
|
// fixture (fixtures/cama_seguimiento.json), to which each test adds a synthetic `tipo_histologico` per row.
|
|
import fixtureData from './fixtures/cama_seguimiento.json';
|
|
import { clasificacionHistologica, MAPEO_HISTOLOGICO, SIN_CLASIFICAR } from './mapeo-histologico';
|
|
import { seguimientoTablaResponse } from './seguimiento-tabla.service';
|
|
|
|
const respuesta = () => structuredClone(fixtureData) as unknown as { columnas: { clave: string; etiqueta: string }[]; items: Record<string, string | number | null>[] };
|
|
|
|
describe('Clasificación histológica', () => {
|
|
it.each([
|
|
['Ductal (NST)', 'Carcinoma invasor'], ['Lobulillar', 'Carcinoma invasor'], ['Ductal-lobulillar mixto', 'Carcinoma invasor'],
|
|
['Mucinoso', 'Carcinoma invasor'], ['Paget', 'Carcinoma in situ'], ['Papilar', 'Revisar (Benigno / In situ / Invasor)'],
|
|
['Tubular', 'Carcinoma invasor'], ['cribiforme', 'Revisar (In situ / Invasor)'], ['Micropapilar', 'Revisar (In situ / Invasor)'],
|
|
['Inflamatorio', 'Carcinoma invasor'], ['Medular', 'Carcinoma invasor'], ['Otros', 'Revisar (Benigno / In situ / Invasor)'],
|
|
['SIN MAPEAR', 'Sin clasificar'],
|
|
])('asigna a «%s» la clasificación «%s»', (tipo, clasificacion) => {
|
|
// Fails if a type is moved to another group or dropped from the mapping.
|
|
expect(clasificacionHistologica(tipo)).toBe(clasificacion);
|
|
});
|
|
it('la categoría combinada «Tubular / cribiforme» del gráfico es carcinoma invasor', () => {
|
|
// Fails if the chart's merged category stops being classified, which would leave its patients unclassified.
|
|
expect(clasificacionHistologica('Tubular / cribiforme')).toBe('Carcinoma invasor');
|
|
});
|
|
it('un tipo fuera del mapeo, incluido uno heredado del prototipo de objeto, es «Sin clasificar»', () => {
|
|
// Fails if the lookup returns inherited properties such as «constructor» instead of the fallback.
|
|
for (const tipo of ['Desconocido', '', 'constructor', 'toString']) expect(clasificacionHistologica(tipo)).toBe(SIN_CLASIFICAR);
|
|
});
|
|
it('el mapeo conserva sus trece tipos y sus cuatro clasificaciones directas', () => {
|
|
// Fails if a type is added or removed without reviewing its classification.
|
|
expect(Object.keys(MAPEO_HISTOLOGICO)).toHaveLength(14);
|
|
expect(new Set(Object.values(MAPEO_HISTOLOGICO))).toEqual(new Set([
|
|
'Carcinoma invasor', 'Carcinoma in situ', 'Revisar (Benigno / In situ / Invasor)', 'Revisar (In situ / Invasor)', 'Sin clasificar']));
|
|
});
|
|
});
|
|
|
|
describe('Seguimiento: columna de clasificación histológica', () => {
|
|
const tipos = ['Ductal (NST)', 'Paget', 'Otros', 'SIN MAPEAR', 'Zzz'];
|
|
it('cada paciente recibe la clasificación de su propio tipo, en una columna tras el tipo o tras el resultado de la biopsia', () => {
|
|
// Fails if the classification is computed from another row or placed away from the biopsy columns.
|
|
const datos = respuesta();
|
|
const conBiopsia = datos.items.filter(item => item['biopsia'] !== null);
|
|
conBiopsia.forEach((item, i) => { item['tipo_histologico'] = tipos[i % tipos.length]; });
|
|
const r = seguimientoTablaResponse(datos);
|
|
const claves = r.columnas.map(c => c.clave);
|
|
expect(claves[claves.indexOf('biopsia') + 1]).toBe('clasificacion_histologica');
|
|
expect(r.columnas.find(c => c.clave === 'clasificacion_histologica')!.etiqueta).toBe('Clasificación histológica');
|
|
for (const item of r.items.filter(item => typeof item['tipo_histologico'] === 'string')) {
|
|
expect(item['clasificacion_histologica']).toBe(clasificacionHistologica(item['tipo_histologico'] as string));
|
|
}
|
|
});
|
|
it('con una columna de tipo, la clasificación va justo después de ella', () => {
|
|
// Fails if the derived column ignores the type's own column and lands elsewhere.
|
|
const datos = respuesta();
|
|
datos.columnas.splice(datos.columnas.findIndex(c => c.clave === 'biopsia') + 1, 0, { clave: 'tipo_histologico', etiqueta: 'Tipo histológico' });
|
|
datos.items.forEach(item => { item['tipo_histologico'] = item['biopsia'] === null ? null : 'Lobulillar'; });
|
|
const claves = seguimientoTablaResponse(datos).columnas.map(c => c.clave);
|
|
expect(claves.slice(claves.indexOf('tipo_histologico'), claves.indexOf('tipo_histologico') + 2)).toEqual(['tipo_histologico', 'clasificacion_histologica']);
|
|
});
|
|
it('un paciente sin tipo no recibe clasificación y los demás campos quedan como llegaron', () => {
|
|
// Fails if a patient without biopsy is shown as «Sin clasificar», or if other row values are altered.
|
|
const datos = respuesta();
|
|
datos.items.forEach((item, i) => { item['tipo_histologico'] = item['biopsia'] === null ? null : 'Medular'; });
|
|
const original = structuredClone(datos.items);
|
|
const r = seguimientoTablaResponse(datos);
|
|
r.items.forEach((item, i) => {
|
|
if (original[i]['tipo_histologico'] === null) expect('clasificacion_histologica' in item).toBe(false);
|
|
expect({ ...item, clasificacion_histologica: undefined }).toEqual({ ...original[i], clasificacion_histologica: undefined });
|
|
});
|
|
});
|
|
it('una lista sin tipo histológico no cambia', () => {
|
|
// Fails if the column appears while the API does not send the field.
|
|
const r = seguimientoTablaResponse(respuesta());
|
|
expect(r.columnas.map(c => c.clave)).not.toContain('clasificacion_histologica');
|
|
expect(r.items.some(item => 'clasificacion_histologica' in item)).toBe(false);
|
|
});
|
|
});
|