From c15f20f85bd31a66ccad93ae5a9c0af7b32120d1 Mon Sep 17 00:00:00 2001 From: Pela2silveira Date: Tue, 24 Mar 2026 22:00:38 -0300 Subject: [PATCH] fix(hl7v2): remove empty char in hl7v2 id --- modules/hl7v2/Hl7v2.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/hl7v2/Hl7v2.ts b/modules/hl7v2/Hl7v2.ts index 3ba7decc7b..2898b0361e 100644 --- a/modules/hl7v2/Hl7v2.ts +++ b/modules/hl7v2/Hl7v2.ts @@ -17,6 +17,10 @@ const SEXO_FEMENINO_HL7 = 'F'; const SEXO_OTRO_HL7 = 'O'; const USE_DNI_ID = true; +function normalizeIdentifierEntity(entity: string = ''): string { + return entity.replace(/\s+/g, ''); +} + interface PatientIdentifier { identificador: string; assigning_authority: string; @@ -73,7 +77,9 @@ export async function adt04(turno: any): Promise { }); // Controlar que no lo tenga y agregarlo si es necesario - if (!paciente.identificadores?.some(id => id.entidad === IDENTIFIER_ENTITY_ANDESHL7V2 && id.valor === hl7id)) { + if (!paciente.identificadores?.some(id => + normalizeIdentifierEntity(id.entidad) === IDENTIFIER_ENTITY_ANDESHL7V2 && id.valor === hl7id + )) { if (!paciente.identificadores) { paciente.identificadores = []; }