import { camaRecordSheets } from './cama-record-sheets'; const sheets = (over: Partial> = []) => camaRecordSheets( (over[0] as any) ?? [['Nombre', 'Ana'], ['CURP', undefined]], (over[1] as any) ?? [['Categoría BI-RADS de la última mastografía', '4B'], ['Resultado histopatológico', undefined]], (over[2] as any) ?? [{ date: '2025-01-02', kind: 'Procedimiento', text: 'Mastectomía' }], (over[3] as any) ?? [{ date: '2025-01-01', kind: 'Mastografía', reported: undefined, results: ['BI-RADS: 4B'], findings: [] }], (over[4] as any) ?? [], (over[5] as any) ?? [], ); const by = (s: ReturnType, title: string) => s.find((x) => x.title.startsWith(title))!; // Each test fails if the PDF made up a value, kept a section of CaCu or dropped what CaMa publishes. describe('the CaMa record as a PDF', () => { it('has only CaMa sections and says a missing value as such', () => { const s = sheets(); expect(s.map((x) => x.title)).toEqual([ 'Datos de la paciente', 'Última mastografía y resultado histopatológico', 'Historial médico', 'Pruebas y resultados', 'Riesgos y recomendaciones publicados', ]); expect(s.some((x) => /citolog|VPH|NCI|ASCCP|Etapas/i.test(x.title + x.head.join()))).toBe(false); expect(by(s, 'Datos').rows).toEqual([['Nombre', 'Ana'], ['CURP', 'No disponible']]); expect(by(s, 'Última').rows[1]).toEqual(['Resultado histopatológico', 'No disponible']); expect(by(s, 'Pruebas').rows[0].slice(0, 3)).toEqual(['2025-01-01', 'Mastografía', 'Pendiente']); }); it('without published estimates it says there are none, with no probability', () => { expect(by(sheets(), 'Riesgos').rows).toEqual([ ['Sin estimaciones publicadas', 'No disponible', 'No disponible', 'No disponible', 'No disponible'], ]); }); it('publishes each estimate by horizon with its interval, and a zero is a value', () => { const s = sheets([ undefined, undefined, undefined, undefined, [{ text: 'Supervivencia v2', index: '2026-01-01', predictions: [{ years: 0, p: 0, low: 0, high: 0.01 }, { years: 5, p: 0.8 }] }], ] as any); expect(by(s, 'Riesgos').rows).toEqual([ ['Supervivencia v2', '2026-01-01', 'Al índice', '0.00 %', '0.00 % a 1.00 %'], ['Supervivencia v2', '2026-01-01', '5 años', '80.00 %', 'No disponible'], ]); }); it('lists the scenario curves, the ones without a curve and the group nature of the estimates', () => { const s = sheets([ undefined, undefined, undefined, undefined, [], [{ title: 'Supervivencia', scenarios: ['A', 'B'], figures: ['A (n = 9, fallecidos = 6)'], undrawn: ['B'] }], ] as any); const sheet = by(s, 'Supervivencia y recurrencia'); expect(sheet.title).toContain('no predicciones individuales'); expect(sheet.rows).toEqual([ ['Supervivencia', 'A (n = 9, fallecidos = 6)', 'Curva publicada'], ['Supervivencia', 'B', 'No disponible: datos insuficientes'], ]); }); });