fixed bug (#4069)
Co-authored-by: leif stawnyczy <leifstawnyczy@leifs-MacBook-Pro.local>
This commit is contained in:
parent
917cf8d062
commit
389bdce372
|
@ -162,3 +162,6 @@ Snap.*
|
|||
|
||||
# VS Code
|
||||
.vscode
|
||||
|
||||
|
||||
/database/
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
type: fix
|
||||
issue: 4067
|
||||
jira: SMILE-5186
|
||||
title: "Fixed a bug where /Patient/$export would fail if _type=Patient parameter
|
||||
was not included."
|
|
@ -12,6 +12,7 @@ import ca.uhn.fhir.jpa.bulk.export.model.BulkExportJobStatusEnum;
|
|||
import ca.uhn.fhir.jpa.bulk.export.model.BulkExportResponseJson;
|
||||
import ca.uhn.fhir.jpa.bulk.export.provider.BulkDataExportProvider;
|
||||
import ca.uhn.fhir.jpa.model.util.JpaConstants;
|
||||
import ca.uhn.fhir.rest.annotation.Validate;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.client.apache.ResourceEntity;
|
||||
import ca.uhn.fhir.rest.server.HardcodedServerAddressStrategy;
|
||||
|
@ -43,6 +44,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
|||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
|
@ -641,6 +643,32 @@ public class BulkDataExportProviderTest {
|
|||
assertThat(bp.getFilters(), containsInAnyOrder("Patient?gender=male", "Patient?gender=female"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitiateBulkExportOnPatient_noTypeParam_addsTypeBeforeBulkExport() throws IOException {
|
||||
// when
|
||||
when(myJobRunner.startNewJob(any()))
|
||||
.thenReturn(createJobStartResponse());
|
||||
|
||||
Parameters input = new Parameters();
|
||||
input.addParameter(JpaConstants.PARAM_EXPORT_OUTPUT_FORMAT, new StringType(Constants.CT_FHIR_NDJSON));
|
||||
|
||||
// call
|
||||
HttpPost post = new HttpPost("http://localhost:" + myPort + "/Patient/" + JpaConstants.OPERATION_EXPORT);
|
||||
post.addHeader(Constants.HEADER_PREFER, Constants.HEADER_PREFER_RESPOND_ASYNC);
|
||||
post.setEntity(new ResourceEntity(myCtx, input));
|
||||
ourLog.info("Request: {}", post);
|
||||
try (CloseableHttpResponse response = myClient.execute(post)) {
|
||||
ourLog.info("Response: {}", response.toString());
|
||||
assertEquals(202, response.getStatusLine().getStatusCode());
|
||||
assertEquals("Accepted", response.getStatusLine().getReasonPhrase());
|
||||
assertEquals("http://localhost:" + myPort + "/$export-poll-status?_jobId=" + A_JOB_ID, response.getFirstHeader(Constants.HEADER_CONTENT_LOCATION).getValue());
|
||||
}
|
||||
|
||||
BulkExportParameters bp = verifyJobStart();
|
||||
assertEquals(Constants.CT_FHIR_NDJSON, bp.getOutputFormat());
|
||||
assertThat(bp.getResourceTypes(), containsInAnyOrder("Patient"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitiatePatientExportRequest() throws IOException {
|
||||
// when
|
||||
|
|
|
@ -268,7 +268,6 @@ public class BulkDataExportTest extends BaseResourceProviderR4Test {
|
|||
verifyBulkExportResults(options, List.of("\"P1\"", "\"" + obsId + "\"", "\"" + encId + "\"", "\"P2\"", "\"" + obsId2 + "\"", "\"" + encId2 + "\""), List.of("\"P3\"", "\"" + obsId3 + "\"", "\"" + encId3 + "\""));
|
||||
}
|
||||
|
||||
|
||||
private void verifyBulkExportResults(BulkDataExportOptions theOptions, List<String> theContainedList, List<String> theExcludedList) {
|
||||
Batch2JobStartResponse startResponse = myJobRunner.startNewJob(BulkExportUtils.createBulkExportJobParametersFromExportOptions(theOptions));
|
||||
|
||||
|
|
|
@ -100,6 +100,7 @@ public class BulkExportUseCaseTest extends BaseResourceProviderR4Test {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
public class SystemBulkExportTests {
|
||||
@Test
|
||||
|
@ -197,7 +198,6 @@ public class BulkExportUseCaseTest extends BaseResourceProviderR4Test {
|
|||
|
||||
@Test
|
||||
public void testPatientExportIgnoresResourcesNotInPatientCompartment() {
|
||||
|
||||
Patient patient = new Patient();
|
||||
patient.setId("pat-1");
|
||||
myPatientDao.update(patient);
|
||||
|
@ -220,11 +220,9 @@ public class BulkExportUseCaseTest extends BaseResourceProviderR4Test {
|
|||
Map<String, String> typeToContents = convertJobResultsToStringContents(bulkExportJobResults);
|
||||
assertThat(typeToContents.get("Observation"), containsString("obs-included"));
|
||||
assertThat(typeToContents.get("Observation"), not(containsString("obs-excluded")));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Nested
|
||||
public class GroupBulkExportTests {
|
||||
@Test
|
||||
|
@ -257,8 +255,6 @@ public class BulkExportUseCaseTest extends BaseResourceProviderR4Test {
|
|||
assertThat(firstMap.get("Group"), hasSize(1));
|
||||
assertThat(firstMap.get("Patient"), hasSize(600));
|
||||
assertThat(firstMap.get("Observation"), hasSize(600));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -293,8 +289,6 @@ public class BulkExportUseCaseTest extends BaseResourceProviderR4Test {
|
|||
Map<String, List<IBaseResource>> firstMap = convertJobResultsToResources(bulkExportJobResults);
|
||||
assertThat(firstMap.get("Patient"), hasSize(1));
|
||||
assertThat(firstMap.get("Group"), hasSize(1));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -703,6 +697,7 @@ public class BulkExportUseCaseTest extends BaseResourceProviderR4Test {
|
|||
String contents = new String(binary.getContent(), Constants.CHARSET_UTF8);
|
||||
return contents;
|
||||
}
|
||||
|
||||
BulkExportJobResults startGroupBulkExportJobAndAwaitCompletion(HashSet<String> theResourceTypes, HashSet<String> theFilters, String theGroupId) {
|
||||
return startBulkExportJobAndAwaitCompletion(BulkDataExportOptions.ExportStyle.GROUP, theResourceTypes, theFilters, theGroupId);
|
||||
}
|
||||
|
@ -710,8 +705,8 @@ public class BulkExportUseCaseTest extends BaseResourceProviderR4Test {
|
|||
BulkExportJobResults startSystemBulkExportJobAndAwaitCompletion(HashSet<String> theResourceTypes, HashSet<String> theFilters) {
|
||||
return startBulkExportJobAndAwaitCompletion(BulkDataExportOptions.ExportStyle.SYSTEM, theResourceTypes, theFilters, null);
|
||||
}
|
||||
BulkExportJobResults startBulkExportJobAndAwaitCompletion(BulkDataExportOptions.ExportStyle theExportStyle, HashSet<String> theResourceTypes, HashSet<String> theFilters, String theGroupOrPatientId) {
|
||||
|
||||
BulkExportJobResults startBulkExportJobAndAwaitCompletion(BulkDataExportOptions.ExportStyle theExportStyle, HashSet<String> theResourceTypes, HashSet<String> theFilters, String theGroupOrPatientId) {
|
||||
BulkDataExportOptions options = new BulkDataExportOptions();
|
||||
options.setResourceTypes(theResourceTypes);
|
||||
options.setFilters(theFilters);
|
||||
|
@ -736,7 +731,6 @@ public class BulkExportUseCaseTest extends BaseResourceProviderR4Test {
|
|||
String report = myJobRunner.getJobInfo(startResponse.getJobId()).getReport();
|
||||
BulkExportJobResults results = JsonUtil.deserialize(report, BulkExportJobResults.class);
|
||||
return results;
|
||||
|
||||
}
|
||||
|
||||
private void verifyBulkExportResults(String theGroupId, HashSet<String> theFilters, List<String> theContainedList, List<String> theExcludedList) {
|
||||
|
@ -781,6 +775,4 @@ public class BulkExportUseCaseTest extends BaseResourceProviderR4Test {
|
|||
private BulkExportJobResults startPatientBulkExportJobAndAwaitResults(HashSet<String> theTypes, HashSet<String> theFilters, String thePatientId) {
|
||||
return startBulkExportJobAndAwaitCompletion(BulkDataExportOptions.ExportStyle.PATIENT, theTypes, theFilters, thePatientId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import ca.uhn.fhir.jpa.bulk.export.model.BulkExportJobStatusEnum;
|
|||
import ca.uhn.fhir.jpa.bulk.export.model.BulkExportResponseJson;
|
||||
import ca.uhn.fhir.jpa.model.util.JpaConstants;
|
||||
import ca.uhn.fhir.jpa.util.BulkExportUtils;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.Operation;
|
||||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||
|
@ -124,7 +125,6 @@ public class BulkDataExportProvider {
|
|||
// get cache boolean
|
||||
boolean useCache = shouldUseCache(theRequestDetails);
|
||||
|
||||
|
||||
BulkExportParameters parameters = BulkExportUtils.createBulkExportJobParametersFromExportOptions(theOptions);
|
||||
parameters.setUseExistingJobsFirst(useCache);
|
||||
|
||||
|
@ -391,7 +391,12 @@ public class BulkDataExportProvider {
|
|||
}
|
||||
|
||||
private BulkDataExportOptions buildPatientBulkExportOptions(IPrimitiveType<String> theOutputFormat, IPrimitiveType<String> theType, IPrimitiveType<Date> theSince, List<IPrimitiveType<String>> theTypeFilter, List<IPrimitiveType<String>> thePatientIds) {
|
||||
BulkDataExportOptions bulkDataExportOptions = buildBulkDataExportOptions(theOutputFormat, theType, theSince, theTypeFilter, BulkDataExportOptions.ExportStyle.PATIENT);
|
||||
IPrimitiveType<String> type = theType;
|
||||
if (type == null) {
|
||||
// Type is optional, but the job requires it
|
||||
type = new StringDt("Patient");
|
||||
}
|
||||
BulkDataExportOptions bulkDataExportOptions = buildBulkDataExportOptions(theOutputFormat, type, theSince, theTypeFilter, BulkDataExportOptions.ExportStyle.PATIENT);
|
||||
if (thePatientIds != null) {
|
||||
bulkDataExportOptions.setPatientIds(thePatientIds.stream().map((pid) -> new IdType(pid.getValueAsString())).collect(Collectors.toSet()));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue