Skip to content

Commit

Permalink
Fix bug in update logic
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bradsawadye committed May 8, 2024
1 parent 7793cd2 commit 4336fcb
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/utils/kafkaFhir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,19 @@ export const processBundle = async (bundle: Bundle): Promise<MpiMediatorResponse
const newPatientMap: NewPatientMap = {};
// transform and send each patient resource and submit to MPI
const promises = patientEntries.map(async (patientEntry) => {
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,
Expand Down Expand Up @@ -224,7 +227,12 @@ export const processBundle = async (bundle: Bundle): Promise<MpiMediatorResponse
);
}

return sendRequest(clientRegistryRequestDetails);
return sendRequest(clientRegistryRequestDetails).then(response => {
if (isHttpStatusOk(guttedPatient.status)) {
return {status: response.status, body: {...response.body, id}}
}
return response;
});
});

const clientRegistryResponses = await Promise.all(promises);
Expand Down

0 comments on commit 4336fcb

Please sign in to comment.