Skip to content

Commit

Permalink
Merge branch 'develop' into snyk-fix-595b8895e495493afac2d1ae75b64d2c
Browse files Browse the repository at this point in the history
  • Loading branch information
riddhi-desai authored Sep 10, 2024
2 parents 9d55a1a + e5f94fb commit e009e7b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public Map<String, Bundle> getTestCaseExportBundle(
// but we don't want to modify it permanently
if (exportDTO.getBundleType() != null) {
BundleType bundleType = BundleType.valueOf(exportDTO.getBundleType().name());
bundle = updateEntry(bundle, bundleType, parser);
bundle = updateEntry(bundle, bundleType, parser, testCase.getPatientId().toString());
String json = parser.encodeResourceToString(bundle);
testCase.setJson(json);
}
Expand All @@ -120,7 +120,8 @@ public Map<String, Bundle> getTestCaseExportBundle(
return testCaseBundle;
}

public Bundle updateEntry(Bundle bundle, BundleType bundleType, IParser parser) {
public Bundle updateEntry(
Bundle bundle, BundleType bundleType, IParser parser, String patientId) {
Bundle bundleCopy = bundle.copy();
org.hl7.fhir.r4.model.Bundle.BundleType fhirBundleType =
org.hl7.fhir.r4.model.Bundle.BundleType.valueOf(bundleType.toString().toUpperCase());
Expand All @@ -131,8 +132,8 @@ public Bundle updateEntry(Bundle bundle, BundleType bundleType, IParser parser)
// "Patient/madie-generated-uuid"
String bundleString = parser.encodeResourceToString(bundleCopy);
for (Bundle.BundleEntryComponent entry : bundleCopy.getEntry()) {
var resourceID = UUID.randomUUID().toString();
var resourceType = entry.getResource().getResourceType() + "/";
var resourceID = resourceType.equals("Patient/") ? patientId : UUID.randomUUID().toString();
bundleString =
bundleString.replaceAll(
resourceType + entry.getResource().getIdPart(), resourceType + resourceID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void updateEntryForTransactionBundleType() {
assertNull(patientEntry.getRequest().getMethod());

var updatedBundle =
testCaseBundleService.updateEntry(testBundle, BundleType.TRANSACTION, parser);
testCaseBundleService.updateEntry(testBundle, BundleType.TRANSACTION, parser, "123");

Bundle.BundleEntryComponent updatedPatientEntry = updatedBundle.getEntry().get(0);
Bundle.BundleEntryComponent updatedEncounterEntry = updatedBundle.getEntry().get(1);
Expand Down Expand Up @@ -147,7 +147,7 @@ void updateEntryForCollectionBundleType() {
assertNull(testBundle.getEntry().get(0).getRequest().getMethod());

var updatedBundle =
testCaseBundleService.updateEntry(testBundle, BundleType.COLLECTION, parser);
testCaseBundleService.updateEntry(testBundle, BundleType.COLLECTION, parser, "123");

Bundle.BundleEntryComponent updatedPatientEntry = updatedBundle.getEntry().get(0);
Bundle.BundleEntryComponent updatedEncounterEntry = updatedBundle.getEntry().get(1);
Expand Down

0 comments on commit e009e7b

Please sign in to comment.