Accept 64-bit patient identifiers

This commit is contained in:
Angel Capetillo Zavala
2026-11-13 18:23:45 -06:00
parent 3b246b4f1f
commit 01d6e71f07
2 changed files with 2 additions and 1 deletions
@@ -28,6 +28,7 @@ describe('Identidad de un renglón', () => {
it('refuses a pac_id that is not a plain decimal string, without falling back to id_seudonimo', () => {
for (const malo of [42, '042', '-1', '4 2', '1e3', '', 'P-X', '12345678901234567890', {}]) expect(identidadDe({ pac_id: malo, id_seudonimo: 'P-X' })).toBeNull();
expect(identidadDe({ pac_id: '0' })?.id).toBe('0');
expect(identidadDe({ pac_id: '9223372036854775807' })?.id).toBe('9223372036854775807');
});
// Fails if a row with no identifier opens a record for nobody.
@@ -18,7 +18,7 @@ export const ETIQUETA_IDENTIDAD: Readonly<Record<CampoIdentidad, string>> = {
};
// No leading zeros and no sign: the value is compared and sent as text, so it has one spelling.
const PAC_ID = /^(0|[1-9][0-9]{0,17})$/;
const PAC_ID = /^(0|[1-9][0-9]{0,18})$/;
/** The fields of a row that matter here; a typed row or a plain record both fit. */
export interface FilaConIdentidad { readonly pac_id?: unknown; readonly id_seudonimo?: unknown }
const texto = (v: unknown): v is string => typeof v === 'string' && v.length > 0;