From 4336fcbf97fc8616b3c8f12d7a51cdfaca595ff9 Mon Sep 17 00:00:00 2001 From: bradsawadye Date: Wed, 8 May 2024 16:38:44 +0200 Subject: [PATCH] Fix bug in update logic The patient's link (jempi interaction id) should not be changed. The update endpoint for jempi returns a different result from the registration endpoint. Patient Id returned for update is the golden id not the interaction id. The link was being updated with the golden id instead of the interaction id --- src/utils/kafkaFhir.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/utils/kafkaFhir.ts b/src/utils/kafkaFhir.ts index 2763329..47e147d 100644 --- a/src/utils/kafkaFhir.ts +++ b/src/utils/kafkaFhir.ts @@ -178,16 +178,19 @@ export const processBundle = async (bundle: Bundle): Promise { + let guttedPatient: ResponseObject; + let id: string; + if (patientEntry.fullUrl) { // Check if patient already exists and perform update - const guttedPatient = await sendRequest({ + guttedPatient = await sendRequest({ ...fhirDatastoreRequestDetails, method: 'GET', path: `/fhir/Patient/${patientEntry.fullUrl.split('/').pop()}`, }); if (isHttpStatusOk(guttedPatient.status)) { - const id: string = Object.assign(guttedPatient.body).link[0].other.reference.split('/').pop(); + id = Object.assign(guttedPatient.body).link[0].other.reference.split('/').pop(); let mpiPatient = await sendRequest({ ...clientRegistryRequestDetails, @@ -224,7 +227,12 @@ export const processBundle = async (bundle: Bundle): Promise { + if (isHttpStatusOk(guttedPatient.status)) { + return {status: response.status, body: {...response.body, id}} + } + return response; + }); }); const clientRegistryResponses = await Promise.all(promises);