Skip to content

Commit

Permalink
#1248 - fix for filter value being empty or not present
Browse files Browse the repository at this point in the history
  • Loading branch information
petmongrels committed Dec 25, 2023
1 parent d85a867 commit d2cfbed
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {ChecklistItem, Encounter, Individual, ProgramEncounter, ProgramEnrolment} from "openchs-models";
import _ from "lodash";
import AddressLevel from "../../views/common/AddressLevel";
import General from "../../utility/General";

const locationBasedQueries = new Map();
locationBasedQueries.set(Individual.schema.name, "lowestAddressLevel.uuid = ");
Expand All @@ -15,7 +16,7 @@ class RealmQueryService {
}

static filterBasedOnAddress(schema, entitiesResult, addressFilter) {
if (!_.isNil(addressFilter)) {
if (!_.isNil(addressFilter) && !_.isNil(addressFilter.filterValue) && addressFilter.filterValue.length > 0) {
const joinedQuery = addressFilter.filterValue.map((x: AddressLevel) => locationBasedQueries.get(schema) + `"${x.uuid}"`);
return entitiesResult.filtered(RealmQueryService.orQuery(joinedQuery));
}
Expand Down

0 comments on commit d2cfbed

Please sign in to comment.