From b2bc5549ff24753ba6a0cb67f0389cf1fff88209 Mon Sep 17 00:00:00 2001 From: Alejandro Gomez Auad Date: Thu, 16 Jul 2026 22:28:22 +0000 Subject: [PATCH] Fix ITI-67 patient national ID resolution to use the Federador identifier listDocumentReference was using the Patient entry's fullUrl as the national ID passed to the document registry search. It now extracts the Patient identifier whose system is the Federador national-id system and builds a system|value token, wiring in the previously unused extractNationalIdentifier helper. Co-Authored-By: Claude Sonnet 5 --- bus-gateway/controllers/iti67.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bus-gateway/controllers/iti67.js b/bus-gateway/controllers/iti67.js index bb079b6..5024ad3 100644 --- a/bus-gateway/controllers/iti67.js +++ b/bus-gateway/controllers/iti67.js @@ -56,12 +56,15 @@ async function listDocumentReference(req, res, next) { config.bus.documentRegistryScope ].join(',') ); - // 1. Obtengo el identificador nacional del paciente en forma de referencia + // 1. Obtengo el identificador nacional del paciente (identifier con system + // NATIONAL_ID_SYSTEM), como token FHIR `system|value`. const patientSearchset = await findPatient(token, { identifier: localPatientIdentifier }); - if (!patientSearchset) { + const patientResource = patientSearchset?.entry?.[0]?.resource; + const nationalIdentifier = patientResource && extractNationalIdentifier(patientResource); + if (!nationalIdentifier) { throw createError(422, 'Could not resolve national identifier for the given patient'); } - const patientNationalId = patientSearchset.entry[0].fullUrl + const patientNationalId = `${nationalIdentifier.system}|${nationalIdentifier.value}`; // 2. Obtengo el listado de entradas del indice de atenciones asociadada al id de paciente // (y, si se pidió, al tipo de documento). const documentReferenceSearchset = await findDocumentReferenceByPatient(token, patientNationalId, documentType)