@@ -213,19 +213,19 @@ map, searchRuntime, new SystemRequestDetails(), theParams.getPartitionIdOrAllPar
213
213
return pids ;
214
214
}
215
215
216
- private static void filterBySpecificPatient (
216
+ private void filterBySpecificPatient (
217
217
ExportPIDIteratorParameters theParams ,
218
218
String resourceType ,
219
219
String patientSearchParam ,
220
220
SearchParameterMap map ) {
221
221
if (resourceType .equalsIgnoreCase ("Patient" )) {
222
222
if (theParams .getPatientIds () != null ) {
223
- ReferenceOrListParam referenceOrListParam = getReferenceOrListParam (theParams );
223
+ ReferenceOrListParam referenceOrListParam = makeReferenceOrListParam (theParams . getPatientIds () );
224
224
map .add (PARAM_ID , referenceOrListParam );
225
225
}
226
226
} else {
227
227
if (theParams .getPatientIds () != null ) {
228
- ReferenceOrListParam referenceOrListParam = getReferenceOrListParam (theParams );
228
+ ReferenceOrListParam referenceOrListParam = makeReferenceOrListParam (theParams . getPatientIds () );
229
229
map .add (patientSearchParam , referenceOrListParam );
230
230
} else {
231
231
map .add (patientSearchParam , new ReferenceParam ().setMissing (false ));
@@ -234,11 +234,9 @@ private static void filterBySpecificPatient(
234
234
}
235
235
236
236
@ Nonnull
237
- private static ReferenceOrListParam getReferenceOrListParam (ExportPIDIteratorParameters theParams ) {
238
- ReferenceOrListParam referenceOrListParam = new ReferenceOrListParam ();
239
- for (String patientId : theParams .getPatientIds ()) {
240
- referenceOrListParam .addOr (new ReferenceParam (patientId ));
241
- }
237
+ private ReferenceOrListParam makeReferenceOrListParam (@ Nonnull List <String > thePatientIds ) {
238
+ final ReferenceOrListParam referenceOrListParam = new ReferenceOrListParam ();
239
+ thePatientIds .forEach (patientId -> referenceOrListParam .addOr (new ReferenceParam (patientId )));
242
240
return referenceOrListParam ;
243
241
}
244
242
@@ -443,14 +441,8 @@ private LinkedHashSet<JpaPid> getExpandedPatientList(ExportPIDIteratorParameters
443
441
@ SuppressWarnings ("unchecked" )
444
442
private List <JpaPid > getMembersFromGroupWithFilter (
445
443
ExportPIDIteratorParameters theParameters , boolean theConsiderDateRange ) throws IOException {
446
- RuntimeResourceDefinition def = myContext .getResourceDefinition ("Patient" );
447
- List <JpaPid > resPids = new ArrayList <>();
448
-
449
- List <SearchParameterMap > maps = myBulkExportHelperSvc .createSearchParameterMapsForResourceType (
450
- def , theParameters , theConsiderDateRange );
451
-
452
- maps .forEach (map -> addMembershipToGroupClause (map , theParameters .getGroupId ()));
453
-
444
+ final List <SearchParameterMap > maps = makeSearchParameterMaps (theParameters , theConsiderDateRange );
445
+ final List <JpaPid > resPids = new ArrayList <>();
454
446
for (SearchParameterMap map : maps ) {
455
447
ISearchBuilder <JpaPid > searchBuilder = getSearchBuilderForResourceType ("Patient" );
456
448
ourLog .debug (
@@ -472,17 +464,26 @@ private List<JpaPid> getMembersFromGroupWithFilter(
472
464
return resPids ;
473
465
}
474
466
475
- /**
476
- * This method takes an {@link SearchParameterMap} and adds a clause to it that will filter the search results to only
477
- * return members of the defined group.
478
- *
479
- * @param theMap the map to add the clause to.
480
- * @param theGroupId the group ID to filter by.
481
- */
482
- private void addMembershipToGroupClause (SearchParameterMap theMap , String theGroupId ) {
483
- HasOrListParam hasOrListParam = new HasOrListParam ();
484
- hasOrListParam .addOr (new HasParam ("Group" , "member" , "_id" , theGroupId ));
485
- theMap .add (PARAM_HAS , hasOrListParam );
467
+ @ Nonnull
468
+ private List <SearchParameterMap > makeSearchParameterMaps (
469
+ @ Nonnull ExportPIDIteratorParameters theParameters , boolean theConsiderDateRange ) {
470
+ final RuntimeResourceDefinition def = myContext .getResourceDefinition ("Patient" );
471
+ final List <SearchParameterMap > maps = myBulkExportHelperSvc .createSearchParameterMapsForResourceType (
472
+ def , theParameters , theConsiderDateRange );
473
+ maps .forEach (map -> {
474
+ map .add (PARAM_HAS , makeGroupMemberHasOrListParam (theParameters .getGroupId ()));
475
+ final List <String > patientIds = theParameters .getPatientIds ();
476
+ if (patientIds != null && !patientIds .isEmpty ()) {
477
+ map .add (PARAM_ID , makeReferenceOrListParam (patientIds ));
478
+ }
479
+ });
480
+ return maps ;
481
+ }
482
+
483
+ @ Nonnull
484
+ private HasOrListParam makeGroupMemberHasOrListParam (@ Nonnull String theGroupId ) {
485
+ final HasParam hasParam = new HasParam ("Group" , "member" , "_id" , theGroupId );
486
+ return new HasOrListParam ().addOr (hasParam );
486
487
}
487
488
488
489
/**
0 commit comments