import type { CamaRow } from './follow-up'; import { camaFollowUpSheet } from './follow-up-sheet'; const row = (over: Partial = {}): CamaRow => ({ patient: { resourceType: 'Patient', id: 'abcdefghijklmnop' }, status: 'pending_biopsy', priority: 'high', ageGroup: '50-59', mammogram: { date: '2026-10-26', birads: '4A' }, ...over, }) as CamaRow; const priority = (c: string) => ({ high: 'Alta' })[c as 'high'] ?? c; // Each test fails if the list file invented a result or lost the query it answers. describe('CaMa follow-up list as a file', () => { it('has CaMa columns, the query and the count', () => { const sheet = camaFollowUpSheet([row()], [['Búsqueda', 'Ninguna']], priority); expect(sheet.head).toEqual([ 'Paciente', 'CURP', 'Grupo de edad', 'Última mastografía (BI-RADS)', 'Fecha de la mastografía', 'Última biopsia', 'Fecha de reporte de la biopsia', 'Estatus de seguimiento', 'Prioridad', ]); expect(sheet.query).toEqual([['Búsqueda', 'Ninguna'], ['Registros', '1']]); expect(sheet.head.join()).not.toMatch(/LIEAG|VPH|Cáncer|Etapas/); }); it('says what is missing: no biopsy, no BI-RADS, no CURP, no priority, never a made-up value', () => { const [r] = camaFollowUpSheet( [row({ mammogram: { date: '' }, priority: '' })], [], priority, ).rows; expect(r.slice(0, 2)).toEqual(['abcdefghij', 'No disponible']); expect(r.slice(3, 7)).toEqual(['Sin dato', 'No disponible', 'No disponible', 'No disponible']); expect(r[8]).toBe('No disponible'); }); it('shows a biopsy with its date, or no grade when it has none', () => { const rows = camaFollowUpSheet( [row({ biopsy: { date: '2026-11-30', histology: 'benign' } }), row({ biopsy: { date: '2026-11-01' } })], [], priority, ).rows; expect(rows[0].slice(5, 7)).toEqual(['Benigno', '2026-11-30']); expect(rows[1].slice(5, 7)).toEqual(['Sin resultado', '2026-11-01']); expect(rows[0][8]).toBe('Alta'); }); });