Skip to content

Commit

Permalink
Merge pull request #40 from jembi/hotfix
Browse files Browse the repository at this point in the history
Hotfix
  • Loading branch information
bradsawadye authored Apr 10, 2024
2 parents d9aecb5 + 10d560c commit 70b34ed
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mpi-mediator",
"version": "v2.1.0",
"version": "v2.1.1",
"description": "An OpenHIM mediator to handle all interactions with an MPI component",
"main": "index.ts",
"scripts": {
Expand Down
12 changes: 10 additions & 2 deletions src/utils/kafkaFhir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,15 @@ export const sendToFhirAndKafka = async (
// Restore full patient resources to the bundle for sending to Kafka
Object.keys(newPatientRef).forEach((fullUrl) => {
const patientData = newPatientRef[fullUrl];
const url = `Patient/${patientData.mpiResponsePatient?.id}`;

if (patientData.restoredPatient && bundle.entry) {
const patientEntry: BundleEntry = {
fullUrl: fullUrl,
fullUrl,
resource: patientData.restoredPatient,
request: {
method: 'PUT',
url: `Patient/${patientData.mpiResponsePatient?.id}`,
url
},
};

Expand All @@ -101,6 +102,13 @@ export const sendToFhirAndKafka = async (
);
bundle.entry.push(patientEntry);
}

// Replace the old patient reference in the resources
const oldId = fullUrl.split('/').pop();

if (oldId) {
bundle = JSON.parse(JSON.stringify(bundle).replace(RegExp(`Patient/${oldId}`, 'g'), url));
}
}
});

Expand Down

0 comments on commit 70b34ed

Please sign in to comment.