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 <noreply@anthropic.com>
This commit is contained in:
parent
b2bc5549ff
commit
d32c802c48
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user