Bulk export with _typeFilter and no type experiment.
This commit is contained in:
parent
e37edfcf84
commit
35530151c6
|
@ -38,6 +38,7 @@ import org.apache.http.client.methods.HttpPost;
|
|||
import org.hl7.fhir.r4.model.IdType;
|
||||
import org.hl7.fhir.r4.model.InstantType;
|
||||
import org.hl7.fhir.r4.model.Parameters;
|
||||
import org.hl7.fhir.r4.model.ResourceType;
|
||||
import org.hl7.fhir.r4.model.StringType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
@ -59,6 +60,7 @@ import org.slf4j.LoggerFactory;
|
|||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -737,6 +739,62 @@ public class BulkDataExportProviderTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitiateGroupExportWithTypeAllergyIntolerance() throws IOException {
|
||||
// when
|
||||
when(myJobRunner.startNewJob(isNotNull(), any(Batch2BaseJobParameters.class)))
|
||||
.thenReturn(createJobStartResponse());
|
||||
|
||||
// http://localhost:8000/Group/1370/$export?_type=AllergyIntolerance
|
||||
final String url = String.format("%s/%s/%s/%s?%s=%s",
|
||||
myServer.getBaseUrl(),
|
||||
ResourceType.Group.name(),
|
||||
"123",
|
||||
JpaConstants.OPERATION_EXPORT,
|
||||
JpaConstants.PARAM_EXPORT_TYPE,
|
||||
ResourceType.AllergyIntolerance.name());
|
||||
|
||||
final HttpGet get = new HttpGet(url);
|
||||
get.addHeader(Constants.HEADER_PREFER, Constants.HEADER_PREFER_RESPOND_ASYNC);
|
||||
try (final CloseableHttpResponse execute = myClient.execute(get)) {
|
||||
// verify
|
||||
assertThat(execute.getStatusLine().getStatusCode(), is(equalTo(202)));
|
||||
|
||||
final BulkExportParameters bulkExportParameters = verifyJobStart();
|
||||
|
||||
assertEquals(Collections.singletonList(ResourceType.AllergyIntolerance.name()), bulkExportParameters.getResourceTypes());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitiateGroupExportWithTypeFilterAllergyIntolerance() throws IOException {
|
||||
// when
|
||||
when(myJobRunner.startNewJob(isNotNull(), any(Batch2BaseJobParameters.class)))
|
||||
.thenReturn(createJobStartResponse());
|
||||
|
||||
// http://localhost:8000/Group/1370/$export?_typeFilter=AllergyIntolerance?category=food
|
||||
final String url = String.format("%s/%s/%s/%s?%s=%s?%s=%s",
|
||||
myServer.getBaseUrl(),
|
||||
ResourceType.Group.name(),
|
||||
"123",
|
||||
JpaConstants.OPERATION_EXPORT,
|
||||
JpaConstants.PARAM_EXPORT_TYPE_FILTER,
|
||||
ResourceType.AllergyIntolerance.name(),
|
||||
"category",
|
||||
"food");
|
||||
|
||||
final HttpGet get = new HttpGet(url);
|
||||
get.addHeader(Constants.HEADER_PREFER, Constants.HEADER_PREFER_RESPOND_ASYNC);
|
||||
try (final CloseableHttpResponse execute = myClient.execute(get)) {
|
||||
|
||||
// verify
|
||||
assertThat(execute.getStatusLine().getStatusCode(), is(equalTo(202)));
|
||||
final BulkExportParameters bulkExportParameters = verifyJobStart();
|
||||
|
||||
assertEquals(Collections.singletonList(ResourceType.AllergyIntolerance.name()), bulkExportParameters.getResourceTypes());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitiateWithPostAndMultipleTypeFilters() throws IOException {
|
||||
// when
|
||||
|
|
|
@ -76,6 +76,7 @@ import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
|||
import org.hl7.fhir.r4.model.IdType;
|
||||
import org.hl7.fhir.r4.model.InstantType;
|
||||
import org.hl7.fhir.r4.model.Parameters;
|
||||
import org.hl7.fhir.r4.model.ResourceType;
|
||||
import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
|
@ -88,6 +89,7 @@ import java.util.Date;
|
|||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -226,8 +228,24 @@ public class BulkDataExportProvider {
|
|||
|
||||
BulkDataExportOptions bulkDataExportOptions = buildGroupBulkExportOptions(theOutputFormat, theType, theSince, theTypeFilter, theIdParam, theMdm, theExportIdentifier, theTypePostFetchFilterUrl);
|
||||
|
||||
if (isNotEmpty(bulkDataExportOptions.getResourceTypes())) {
|
||||
validateResourceTypesAllContainPatientSearchParams(bulkDataExportOptions.getResourceTypes());
|
||||
// TODO: theTypeFilter is not getting honoured here and as a result we're getting all resourceTypes
|
||||
// TODO: not a real fix, just an experiment
|
||||
// if (isNotEmpty(bulkDataExportOptions.getResourceTypes())) {
|
||||
if (isNotEmpty(bulkDataExportOptions.getResourceTypes()) || isNotEmpty(bulkDataExportOptions.getFilters())) {
|
||||
if (isNotEmpty(bulkDataExportOptions.getResourceTypes()) && ! isNotEmpty(bulkDataExportOptions.getFilters())) {
|
||||
validateResourceTypesAllContainPatientSearchParams(bulkDataExportOptions.getResourceTypes());
|
||||
} else if (! isNotEmpty(bulkDataExportOptions.getResourceTypes()) && isNotEmpty(bulkDataExportOptions.getFilters())) {
|
||||
ourLog.info("4748: ");
|
||||
final Set<String> resourceTypesFromTypeFilter = bulkDataExportOptions.getFilters()
|
||||
.stream()
|
||||
.filter(stringFilter -> stringFilter.contains("?"))
|
||||
.map(stringFiler -> stringFiler.split("\\?")[0])
|
||||
.filter(split -> Arrays.stream(ResourceType.values()).anyMatch(resType -> resType.name().equals(split)))
|
||||
.collect(Collectors.toUnmodifiableSet());
|
||||
|
||||
validateResourceTypesAllContainPatientSearchParams(resourceTypesFromTypeFilter);
|
||||
bulkDataExportOptions.setResourceTypes(resourceTypesFromTypeFilter);
|
||||
}
|
||||
} else {
|
||||
// all patient resource types
|
||||
bulkDataExportOptions.setResourceTypes(getPatientCompartmentResources());
|
||||
|
|
Loading…
Reference in New Issue