Skip to content

Commit

Permalink
Merge pull request #1209 from IBM/albert-master
Browse files Browse the repository at this point in the history
issue #1198 performance enhancement for patient/group export
  • Loading branch information
albertwang-ibm authored Jun 10, 2020
2 parents 35a3856 + 3754d4b commit 9c727c3
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import com.ibm.fhir.persistence.context.FHIRPersistenceContextFactory;
import com.ibm.fhir.persistence.helper.FHIRPersistenceHelper;
import com.ibm.fhir.persistence.helper.FHIRTransactionHelper;
import com.ibm.fhir.search.compartment.CompartmentUtil;
import com.ibm.fhir.search.context.FHIRSearchContext;
import com.ibm.fhir.search.util.SearchUtil;

Expand Down Expand Up @@ -133,6 +134,8 @@ protected void fillChunkDataBuffer(List<String> patientIds) throws Exception {
FHIRSearchContext searchContext;

if (chunkData != null) {
// TODO the following replaceAll can be dropped after issue(https://github.com/IBM/FHIR/issues/300) is fixed.
patientIds.replaceAll(x -> "Patient/" + x);
do {
Map<String, List<String>> queryParameters = new HashMap<>();
// Add the search parameters from the current typeFilter for current resource type.
Expand All @@ -154,12 +157,20 @@ protected void fillChunkDataBuffer(List<String> patientIds) throws Exception {
if (!searchCriteria.isEmpty()) {
queryParameters.put(Constants.FHIR_SEARCH_LASTUPDATED, searchCriteria);
}

queryParameters.put("_sort", Arrays.asList(new String[] { Constants.FHIR_SEARCH_LASTUPDATED }));

for (String patientId : patientIds) {
List<String> compartmentSearchCriterias = CompartmentUtil.getCompartmentResourceTypeInclusionCriteria("Patient", resourceType.getSimpleName());
if (compartmentSearchCriterias.size() > 1) {
isDoDuplicationCheck = true;
}

for (String compartmentSearchCriteria: compartmentSearchCriterias) {
HashMap<String, List<String>> queryTmpParameters = new HashMap<>();
queryTmpParameters.putAll(queryParameters);

queryTmpParameters.put(compartmentSearchCriteria, Arrays.asList(new String[] {String.join(",", patientIds)}));
searchContext = SearchUtil.parseQueryParameters(resourceType, queryTmpParameters);

searchContext = SearchUtil.parseQueryParameters("Patient", patientId, resourceType, queryParameters, true);
do {
searchContext.setPageSize(pageSize);
searchContext.setPageNumber(compartmentPageNum);
Expand Down Expand Up @@ -196,6 +207,7 @@ protected void fillChunkDataBuffer(List<String> patientIds) throws Exception {
}

} while (searchContext.getLastPageNumber() >= compartmentPageNum);
compartmentPageNum = 1;
}

indexOfCurrentTypeFilter++;
Expand Down

0 comments on commit 9c727c3

Please sign in to comment.