Skip to content

Commit

Permalink
Merge branch 'refs/heads/10.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
1t5j0y committed Sep 24, 2024
2 parents 79d14ca + 58b4e8d commit b84371a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import _ from 'lodash';
import CustomDashboardService, {CustomDashboardType} from "../../service/customDashboard/CustomDashboardService";
import CustomDashboardService from "../../service/customDashboard/CustomDashboardService";
import DashboardSectionCardMappingService from "../../service/customDashboard/DashboardSectionCardMappingService";
import EntityService from "../../service/EntityService";
import {ReportCard, NestedReportCardResult} from "openchs-models";
import {ReportCard} from "openchs-models";
import ReportCardService from "../../service/customDashboard/ReportCardService";
import General from "../../utility/General";
import DashboardFilterService from "../../service/reports/DashboardFilterService";
Expand Down Expand Up @@ -133,7 +133,7 @@ class CustomDashboardActions {

const newState = {...state};

if (newState.dashboards.length === 0) {
if (_.isNil(newState.dashboards) || newState.dashboards.length === 0) {
return newState;
}

Expand Down
9 changes: 8 additions & 1 deletion packages/openchs-android/src/service/CustomFilterService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
40 changes: 40 additions & 0 deletions packages/openchs-android/test/DateSpikeTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import moment from 'moment';

const scheduledOrCompletedEncountersOfType = function (nextVisitDate) {
const nextDateMonth = moment(nextVisitDate).month();
const nextDateYear = moment(nextVisitDate).year();

return [
{earliestVisitDateTime: new Date("2024-06-30T18:30:00.000Z")},
{earliestVisitDateTime: new Date("2024-07-31T18:30:00.000Z")},
{earliestVisitDateTime: new Date("2024-08-31T18:30:00.000Z")},
].filter((enc) =>
moment(enc.earliestVisitDateTime).year() === nextDateYear &&
moment(enc.earliestVisitDateTime).month() === nextDateMonth
);
};

xit('should ', function () {
// console.log("nextDate", moment(new Date("2024-08-31T18:30:00.000Z")).add(1, 'M').startOf('month').toDate());
// console.log("nextDate", moment(new Date("2024-08-21T18:30:00.000Z")).add(1, 'M').startOf('month').toDate());

// perform, should schedule next visit
let currentEncountersEarliestDate = new Date("2024-08-31T18:30:00.000Z");
let nextDate = moment(currentEncountersEarliestDate).add(1, 'M').startOf('month').toDate();
console.log("found visits", scheduledOrCompletedEncountersOfType(nextDate).length, "Next date", nextDate);

currentEncountersEarliestDate = new Date("2024-08-31T18:30:00.000Z") || new Date("2024-09-05T10:30:00.000Z");
nextDate = moment(currentEncountersEarliestDate).add(1, 'M').startOf('month').toDate();
console.log("found visits", scheduledOrCompletedEncountersOfType(nextDate).length, "Next date", nextDate);

currentEncountersEarliestDate = new Date("2024-07-31T18:30:00.000Z");
nextDate = moment(currentEncountersEarliestDate).add(1, 'M').startOf('month').toDate();
console.log("found visits", scheduledOrCompletedEncountersOfType(nextDate).length, "Next date", nextDate);

console.log("Month", moment(new Date("2024-08-31T18:30:00.000Z")).format("MMMM"));
console.log("Month", moment(new Date()).month());

console.log("Month", moment(new Date("2024-01-20T18:30:00.000Z")).format("MMMM"));

console.log("timezone", new Date().getTimezoneOffset());
});

0 comments on commit b84371a

Please sign in to comment.