import { ANTECEDENTS, group, split } from './record-groups'; const fact = (study: string, field: string, title: string, value: string) => ({ study, field, title, value, }); describe('the record of a cytology by what its facts are', () => { it('splits a catalog code into its study and its field', () => { expect(split('cervical_cytology.hpv_16')).toEqual({ study: 'cervical_cytology', field: 'hpv_16', }); expect(split('plain')).toEqual({ study: '', field: 'plain' }); }); it('keeps the form antecedents apart from the results and the findings', () => { const found = group([ fact( 'cervical_cytology', 'screening_history', 'Detección de cáncer de cérvix', 'Primera vez en la vida', ), fact( 'cervical_cytology', 'gynecologic_condition', 'Condición ginecoobstétrica a la detección', 'DIU in situ', ), fact('cervical_cytology', 'presenting_symptom', 'Actualmente presenta', 'Flujo'), fact('cervical_cytology', 'cervix_appearance', 'A la exploración se observa', 'Cuello sano'), fact('cervical_cytology', 'adequacy', 'Calidad de la muestra', 'Satisfactoria'), fact( 'cervical_cytology', 'result', 'Resultado (Bethesda)', 'Negativo para lesión intraepitelial o malignidad', ), fact('cervical_cytology', 'hpv', 'VPH de alto riesgo', 'negativo'), fact('cervical_cytology', 'findings', 'Hallazgos adicionales', 'Inflamación.'), fact('cervical_cytology', 'finding_inflammation', 'Hallazgo: inflamación', 'positivo'), ]); expect(Object.keys(found.antecedents)).toEqual(ANTECEDENTS.map((a) => a.field)); expect(found.antecedents['gynecologic_condition']).toBe('DIU in situ'); expect(found.results).toEqual([ 'Calidad de la muestra: Satisfactoria', 'Resultado (Bethesda): Negativo para lesión intraepitelial o malignidad', 'VPH de alto riesgo: negativo', ]); expect(found.findings).toEqual(['Texto del informe: Inflamación.', 'Inflamación']); }); it('nothing is lost: every fact lands in exactly one place', () => { const facts = [ fact('cervical_cytology', 'screening_history', 'a', '1'), fact('cervical_cytology', 'result', 'b', '2'), fact('cervical_cytology', 'finding_atrophy', 'Hallazgo: atrofia', 'positivo'), fact('cervical_biopsy', 'histology', 'Histología', 'LIEAG'), ]; const found = group(facts); expect( Object.keys(found.antecedents).length + found.results.length + found.findings.length, ).toBe(facts.length); }); it('a study that is not the cytology has no antecedents and no collapsed findings', () => { const found = group([fact('cervical_biopsy', 'histology', 'Histología', 'LIEAG (CIN 2 y 3)')]); expect(found.antecedents).toEqual({}); expect(found.findings).toEqual([]); expect(found.results).toEqual(['Histología: LIEAG (CIN 2 y 3)']); }); it('a stated finding keeps a value that is not simply "positivo"', () => { expect( group([fact('cervical_cytology', 'finding_none', 'Hallazgo: ninguno', 'negativo')]).findings, ).toEqual(['Ninguno: negativo']); }); });