From d2cfbed55118dcc4d7bffea2da0e9985a63dd1a6 Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Mon, 25 Dec 2023 12:17:54 +0530 Subject: [PATCH] #1248 - fix for filter value being empty or not present --- .../openchs-android/src/service/query/RealmQueryService.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/openchs-android/src/service/query/RealmQueryService.js b/packages/openchs-android/src/service/query/RealmQueryService.js index eda1351a5..cd2d1535c 100644 --- a/packages/openchs-android/src/service/query/RealmQueryService.js +++ b/packages/openchs-android/src/service/query/RealmQueryService.js @@ -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 = "); @@ -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)); }