Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAT-7565: use patient id for folder name #244

Merged
merged 3 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading