// Fixtures of the analysis tab and of its journey to Seguimiento, shaped like the answers of the cohort API // (`GET /cama/analisis/indicadores?corte=` and the list `GET /cama/seguimiento` of a cohort). import { HttpErrorResponse, HttpInterceptorFn } from '@angular/common/http'; import { throwError } from 'rxjs'; import { AnalisisAgregado } from './indicadores-analisis.service'; export const REVISION = 'dae23030398f86a24e8ad910471d27ce02502ac6b174063c98e5163dea0ce7a7'; export const CORTE = '2026-10-20'; export const CONTEXTO = { cohorte: 'cama_birads_v1', escenario: 'diagnostico', revision: REVISION }; /** One published category (BI-RADS 5, six patients) and five suppressed ones. */ export const agregado = (extra: Partial = {}): AnalisisAgregado => ({ simulado: true, ...CONTEXTO, corte: CORTE, umbral_supresion: 5, unidad: 'paciente', denominador: 'pacientes elegibles con última mastografía reportada BI-RADS 4 a 6', grupos: [ { codigo: 'BIRADS_4', n: null, suprimido: true }, { codigo: 'BIRADS_4A', n: null, suprimido: true }, { codigo: 'BIRADS_4B', n: null, suprimido: true }, { codigo: 'BIRADS_4C', n: null, suprimido: true }, { codigo: 'BIRADS_5', n: 6, suprimido: false }, { codigo: 'BIRADS_6', n: null, suprimido: true }, ], ...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; page?: number; size?: number; n?: number; meses?: number; revision?: string } = {}): Record { const { corte = CORTE, filtros = {}, page = 1, size = 50, n = 6, meses = 0, revision = REVISION } = 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, revision, 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 = {}) => ({ ...agregado(), horizonte_dias: 0, indicadores: [], ...extra }); /** * For specs of the analysis tab that are about its BI-RADS aggregate and its way to Seguimiento: the descriptive sections * below it (catalog, indicators, distribution, comparison, map, trend) answer «not published» and never reach the test * backend, so those specs keep counting only the requests they are about. */ export const sinAnalisisDescriptivo: HttpInterceptorFn = (req, next) => /^\/[a-z]+\/analisis(\/(resumen|distribucion|comparacion|mapa|tendencia))?$/.test(req.url) ? throwError(() => new HttpErrorResponse({ status: 404, url: req.url })) : next(req);