Add Device to the list of resource types considered for group bulk export async (#4384)

* Add Device to the list of resource types considered for group bulk export async. New unit test for bulk export.

* Add changelog.
This commit is contained in:
Luke deGruchy 2022-12-20 16:33:25 -05:00 committed by GitHub
parent 0d5f8da93f
commit 6e8db3626d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 59 additions and 2 deletions

View File

@ -0,0 +1,4 @@
---
type: add
issue: 4385
title: "Group bulk export async will not retrieve Device resources even if they're linked to a Patient and Group. This has been fixed by adding Device to the list of qualifying resources."

View File

@ -623,7 +623,13 @@ public class BulkDataExportProviderTest {
// verify // verify
assertThat(execute.getStatusLine().getStatusCode(), is(equalTo(202))); assertThat(execute.getStatusLine().getStatusCode(), is(equalTo(202)));
verifyJobStart(); final BulkExportParameters bulkExportParameters = verifyJobStart();
assertAll(
() -> assertTrue(bulkExportParameters.getResourceTypes().contains("Patient")),
() -> assertTrue(bulkExportParameters.getResourceTypes().contains("Group")),
() -> assertTrue(bulkExportParameters.getResourceTypes().contains("Device"))
);
} }
@Test @Test

View File

@ -34,6 +34,8 @@ import org.hl7.fhir.r4.model.Reference;
import org.hl7.fhir.r4.model.ServiceRequest; import org.hl7.fhir.r4.model.ServiceRequest;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -45,6 +47,7 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Stream;
import static org.apache.commons.lang3.StringUtils.isNotBlank; import static org.apache.commons.lang3.StringUtils.isNotBlank;
import static org.awaitility.Awaitility.await; import static org.awaitility.Awaitility.await;
@ -573,6 +576,49 @@ public class BulkDataExportTest extends BaseResourceProviderR4Test {
verifyBulkExportResults(options, List.of("Patient/P1", deviceId), Collections.emptyList()); verifyBulkExportResults(options, List.of("Patient/P1", deviceId), Collections.emptyList());
} }
@ParameterizedTest
@MethodSource("bulkExportOptionsResourceTypes")
public void testDeviceBulkExportWithPatientPartOfGroup(Set<String> resourceTypesForExport) {
final Patient patient = new Patient();
patient.setId("A");
patient.setActive(true);
final IIdType patientIdType = myClient.update().resource(patient).execute().getId().toUnqualifiedVersionless();
final Group group = new Group();
group.setId("B");
final Group.GroupMemberComponent groupMemberComponent = new Group.GroupMemberComponent();
final Reference patientReference = new Reference(patientIdType.getValue());
groupMemberComponent.setEntity(patientReference);
group.getMember().add(groupMemberComponent);
final IIdType groupIdType = myClient.update().resource(group).execute().getId().toUnqualifiedVersionless();
final Device device = new Device();
device.setId("C");
device.setStatus(Device.FHIRDeviceStatus.ACTIVE);
device.setPatient(patientReference);
final IIdType deviceIdType = myClient.create().resource(device).execute().getId().toUnqualifiedVersionless();
final BulkDataExportOptions options = new BulkDataExportOptions();
options.setResourceTypes(resourceTypesForExport);
options.setGroupId(new IdType("Group", "B"));
options.setFilters(new HashSet<>());
options.setExportStyle(BulkDataExportOptions.ExportStyle.GROUP);
options.setOutputFormat(Constants.CT_FHIR_NDJSON);
final List<String> expectedContainedIds;
if (resourceTypesForExport.contains("Device")) {
expectedContainedIds = List.of(patientIdType.getValue(), groupIdType.getValue(), deviceIdType.getValue());
} else {
expectedContainedIds = List.of(patientIdType.getValue(), groupIdType.getValue());
}
verifyBulkExportResults(options, expectedContainedIds, Collections.emptyList());
}
private static Stream<Set<String>> bulkExportOptionsResourceTypes() {
return Stream.of(Set.of("Patient", "Group"), Set.of("Patient", "Group", "Device"));
}
private void verifyBulkExportResults(BulkDataExportOptions theOptions, List<String> theContainedList, List<String> theExcludedList) { private void verifyBulkExportResults(BulkDataExportOptions theOptions, List<String> theContainedList, List<String> theExcludedList) {
Batch2JobStartResponse startResponse = myJobRunner.startNewJob(BulkExportUtils.createBulkExportJobParametersFromExportOptions(theOptions)); Batch2JobStartResponse startResponse = myJobRunner.startNewJob(BulkExportUtils.createBulkExportJobParametersFromExportOptions(theOptions));

View File

@ -237,7 +237,8 @@ public class BulkDataExportProvider {
private Set<String> getPatientCompartmentResources() { private Set<String> getPatientCompartmentResources() {
if (myCompartmentResources == null) { if (myCompartmentResources == null) {
myCompartmentResources = SearchParameterUtil.getAllResourceTypesThatAreInPatientCompartment(myFhirContext); myCompartmentResources = new HashSet<>(SearchParameterUtil.getAllResourceTypesThatAreInPatientCompartment(myFhirContext));
myCompartmentResources.add("Device");
} }
return myCompartmentResources; return myCompartmentResources;
} }