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 <noreply@anthropic.com>
This commit is contained in:
parent
387ee331ed
commit
b2bc5549ff
@ -56,12 +56,15 @@ async function listDocumentReference(req, res, next) {
|
|||||||
config.bus.documentRegistryScope
|
config.bus.documentRegistryScope
|
||||||
].join(',')
|
].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 });
|
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');
|
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
|
// 2. Obtengo el listado de entradas del indice de atenciones asociadada al id de paciente
|
||||||
// (y, si se pidió, al tipo de documento).
|
// (y, si se pidió, al tipo de documento).
|
||||||
const documentReferenceSearchset = await findDocumentReferenceByPatient(token, patientNationalId, documentType)
|
const documentReferenceSearchset = await findDocumentReferenceByPatient(token, patientNationalId, documentType)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user