diff --git a/packages/openchs-android/src/service/CustomFilterService.js b/packages/openchs-android/src/service/CustomFilterService.js index 2f3010128..bfb46a111 100644 --- a/packages/openchs-android/src/service/CustomFilterService.js +++ b/packages/openchs-android/src/service/CustomFilterService.js @@ -363,12 +363,19 @@ class CustomFilterService extends BaseService { } applyCustomFilters(customFilters, filterName, includeVoided = false) { + General.logDebugTemp("CustomFilterService", "Applying custom filters"); let uniqueSubjectUUIDs = []; _.forEach(this.getSettings()[filterName], filter => { const selectedOptions = customFilters[filter.titleKey]; const {scopeParameters, scope, conceptUUID, type, widget} = filter; const selectedAnswerFilterQueryFunction = this.getFilterQueryByTypeFunction(filter, selectedOptions); - uniqueSubjectUUIDs = _.intersection(uniqueSubjectUUIDs, this.getSubjects(conceptUUID, selectedOptions, type, scope, scopeParameters, widget, selectedAnswerFilterQueryFunction, includeVoided)); + const subjects = this.getSubjects(conceptUUID, selectedOptions, type, scope, scopeParameters, widget, selectedAnswerFilterQueryFunction, includeVoided); + const filterHasValue = !_.isEmpty(selectedOptions) && !_.isNil(selectedOptions) + if (!filterHasValue || _.isEmpty(uniqueSubjectUUIDs)) { + uniqueSubjectUUIDs = subjects; + } else { + uniqueSubjectUUIDs = _.intersection(uniqueSubjectUUIDs, subjects); + } }); return uniqueSubjectUUIDs; } diff --git a/packages/openchs-android/test/DateSpikeTest.js b/packages/openchs-android/test/DateSpikeTest.js new file mode 100644 index 000000000..2858a88bc --- /dev/null +++ b/packages/openchs-android/test/DateSpikeTest.js @@ -0,0 +1,21 @@ +import moment from 'moment'; + +const scheduledOrCompletedEncountersOfType = function (nextVisitDate) { + const nextDateMonth = moment(nextVisitDate).month(); + const nextDateYear = moment(nextVisitDate).year(); + + const data = [{earliestVisitDateTime: new Date("2024-06-30T18:30:00.000Z")}].filter((enc) => + moment(enc.earliestVisitDateTime).year() === nextDateYear && + moment(enc.earliestVisitDateTime).month() === nextDateMonth + ); + return data; +}; + +it('should ', function () { + const date = new Date("2024-06-30T18:30:00.000Z"); + // console.log(moment(date).month()); + // console.log(scheduledOrCompletedEncountersOfType(date)); + let date2 = moment(date).add(1, 'M').startOf('month').toDate(); + console.log(date2); + // console.log("to server", JSON.stringify(date2)); +}); diff --git a/packages/openchs-android/test/model/reportNDashboard/TestStandardReportCardTypeFactory.js b/packages/openchs-android/test/model/reportNDashboard/TestStandardReportCardTypeFactory.js index b49b19e30..b9f212a7c 100644 --- a/packages/openchs-android/test/model/reportNDashboard/TestStandardReportCardTypeFactory.js +++ b/packages/openchs-android/test/model/reportNDashboard/TestStandardReportCardTypeFactory.js @@ -6,6 +6,7 @@ class TestStandardReportCardTypeFactory { const standardReportCardType = new StandardReportCardType(); standardReportCardType.uuid = uuid; standardReportCardType.name = name; + standardReportCardType.type = name; return standardReportCardType; } }