Skip to content

Commit

Permalink
Cater for sante mpi
Browse files Browse the repository at this point in the history
  • Loading branch information
bradsawadye committed May 3, 2024
1 parent 1bc2af7 commit 6b154ef
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/utils/kafkaFhir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,24 @@ export const processBundle = async (bundle: Bundle): Promise<MpiMediatorResponse
method: 'GET',
path: `/fhir/Patient/${patientEntry.fullUrl.split('/').pop()}`,
});

if (isHttpStatusOk(guttedPatient.status)) {
const mpiPatient = await sendRequest({
const id: string = Object.assign(guttedPatient.body).link[0].other.reference.split('/').pop();

let mpiPatient = await sendRequest({
...clientRegistryRequestDetails,
method: 'GET',
path: `/fhir/links/Patient/${Object.assign(guttedPatient.body).link[0].other.reference}`,
path: `/fhir/links/Patient/${id}`,
});

if (!isHttpStatusOk(mpiPatient.status)) {
mpiPatient = await sendRequest({
...clientRegistryRequestDetails,
method: 'GET',
path: `/fhir/Patient/${id}`,
});
}

clientRegistryRequestDetails.method = 'PUT';
clientRegistryRequestDetails.path = `/fhir/Patient/${
Object.assign(mpiPatient.body).id
Expand Down

0 comments on commit 6b154ef

Please sign in to comment.