From d32c802c48fa7eaaae3b27b752bd7ff2b934da84 Mon Sep 17 00:00:00 2001 From: Alejandro Gomez Auad Date: Thu, 16 Jul 2026 23:32:44 +0000 Subject: [PATCH] Revert ITI-67 patient subject back to fullUrl reference DocumentReference.subject must be a literal reference (min=1 on .reference per the DocumentReferenceOrigenAR profile), not an identifier token: the Bus rejects subject.identifier. Go back to using the Patient entry's fullUrl as the reference in both ITI-65 and ITI-67 (ITI-65 was never committed with the identifier-based version, so only ITI-67 needed the revert here), dropping the now-unused extractNationalIdentifier helper. Co-Authored-By: Claude Sonnet 5 --- bus-gateway/controllers/iti67.js | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/bus-gateway/controllers/iti67.js b/bus-gateway/controllers/iti67.js index 5024ad3..6ab7fc7 100644 --- a/bus-gateway/controllers/iti67.js +++ b/bus-gateway/controllers/iti67.js @@ -4,16 +4,6 @@ const { getBusToken } = require('../utils/busAuth'); const { findPatient } = require('../services/patient'); const { findDocumentReferenceByPatient } = require('../services/documentReference'); -const NATIONAL_ID_SYSTEM = 'https://federador.msal.gob.ar/patient-id'; - -/** - * Extracts the Federador national identifier from a Patient resource. - */ -function extractNationalIdentifier(patient) { - const identifiers = Array.isArray(patient.identifier) ? patient.identifier : []; - return identifiers.find(id => id.system === NATIONAL_ID_SYSTEM) || null; -} - /** @@ -56,15 +46,13 @@ async function listDocumentReference(req, res, next) { config.bus.documentRegistryScope ].join(',') ); - // 1. Obtengo el identificador nacional del paciente (identifier con system - // NATIONAL_ID_SYSTEM), como token FHIR `system|value`. + // 1. Obtengo el identificador nacional del paciente en forma de referencia + // (fullUrl del recurso Patient en el Bus). const patientSearchset = await findPatient(token, { identifier: localPatientIdentifier }); - const patientResource = patientSearchset?.entry?.[0]?.resource; - const nationalIdentifier = patientResource && extractNationalIdentifier(patientResource); - if (!nationalIdentifier) { + if (!patientSearchset || !Array.isArray(patientSearchset.entry) || patientSearchset.entry.length === 0) { throw createError(422, 'Could not resolve national identifier for the given patient'); } - const patientNationalId = `${nationalIdentifier.system}|${nationalIdentifier.value}`; + const patientNationalId = patientSearchset.entry[0].fullUrl; // 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)