import { recordSheets } from './record-sheets'; describe('the PDF of a record', () => { const sheets = recordSheets( [['Nombre', 'Ana']], [ { label: 'Toma de muestra', day: '2026-01-10', state: 'recorded', sources: ['cytology-form'], }, { label: 'Colposcopía', day: '2026-02-01', state: 'inferred', sources: ['clinical-note', 'biopsy-order'], }, { label: 'Reporte de biopsia', state: 'pending', requested: '2026-02-05', sources: ['date-association'], }, { label: 'Diagnóstico', state: 'unknown' }, ], [{ date: '2026-03-01', kind: 'Diagnóstico', text: 'N87.9' }], [ { date: '2026-01-10', kind: 'Citología cervical', reported: '2026-01-20', results: ['Resultado (Bethesda): LIEAG'], findings: ['Texto del informe: Inflamación.', 'Inflamación'], }, ], [ { date: '2026-01-10', values: { screening_history: 'Primera vez en la vida', cervix_appearance: 'Cuello sano' }, }, ], [], ); const by = (title: string) => sheets.find((s) => s.title.startsWith(title))!; it('keeps every section, in the page order', () => { expect(sheets.map((s) => s.title.split(' (')[0])).toEqual([ 'Datos de la paciente', 'Etapas del tamizaje', 'Historial médico', 'Antecedentes y evaluación ginecológica', 'Pruebas y resultados', 'Riesgos', ]); }); it('writes each stage with its state, its day or its request, and where it comes from', () => { expect(by('Etapas').head).toEqual(['Etapa', 'Estado', 'Fecha', 'Procedencia']); expect(by('Etapas').rows).toEqual([ ['Toma de muestra', 'Registrada', '2026-01-10', 'Formulario de citología'], ['Colposcopía', 'Inferida por fechas', '2026-02-01', 'Nota clínica · Orden de biopsia'], ['Reporte de biopsia', 'Pendiente', 'Solicitada el 2026-02-05', 'Asociación por fechas'], ['Diagnóstico', 'Sin dato', '', ''], ]); }); it('gives the declared antecedents their own sheet, said as declared, with what is not documented', () => { const s = by('Antecedentes'); expect(s.title).toContain('no son diagnósticos confirmados'); expect(s.head).toEqual([ 'Toma', 'Detección de cáncer de cérvix', 'Condición ginecoobstétrica a la detección', 'Actualmente presenta', 'A la exploración se observa', ]); expect(s.rows).toEqual([ ['2026-01-10', 'Primera vez en la vida', 'No documentado', 'No documentado', 'Cuello sano'], ]); }); it('keeps the results and the extra findings of each test in their own columns', () => { expect(by('Pruebas').head).toEqual(['Toma', 'Estudio', 'Reporte', 'Resultados', 'Hallazgos']); expect(by('Pruebas').rows).toEqual([ [ '2026-01-10', 'Citología cervical', '2026-01-20', 'Resultado (Bethesda): LIEAG', 'Texto del informe: Inflamación. · Inflamación', ], ]); }); });