From 91a3241c0e8b16eb65ddbc74ca655b53bacf3fb4 Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Thu, 6 Jun 2024 17:45:55 +0530 Subject: [PATCH 01/10] #1416 - use the same approach as used elsewhere subjects registered at = "all selected and descendants of lowest selected ones" --- .../src/action/mydashboard/FiltersActions.js | 7 +++---- .../src/action/mydashboard/MyDashboardActions.js | 1 - .../openchs-android/src/service/AddressLevelService.js | 10 +++++++++- .../src/service/query/IndividualSearchCriteria.js | 7 ------- .../src/service/reports/DashboardFilterService.js | 5 ++--- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/packages/openchs-android/src/action/mydashboard/FiltersActions.js b/packages/openchs-android/src/action/mydashboard/FiltersActions.js index f0b4e7c5e..83097174d 100644 --- a/packages/openchs-android/src/action/mydashboard/FiltersActions.js +++ b/packages/openchs-android/src/action/mydashboard/FiltersActions.js @@ -4,6 +4,7 @@ import _ from "lodash"; import FormMappingService from "../../service/FormMappingService"; import {ArrayUtil} from "openchs-models"; import AddressLevelState from '../common/AddressLevelsState'; +import General from "../../utility/General"; class FiltersActions { @@ -64,10 +65,8 @@ class FiltersActions { addressLevelState: action.addressLevelState }; const addressLevelService = beans.get(AddressLevelService); - const lowestSelectedAddressLevels = action.addressLevelState.lowestSelectedAddresses; - const lowestAddressLevels = lowestSelectedAddressLevels - .reduce((acc, parent) => acc.concat(addressLevelService.getDescendantsOfNode(parent)), []); - newState.locationSearchCriteria.toggleLowestAddresses(lowestAddressLevels); + const toMatchAddresses = [...action.addressLevelState.selectedAddresses].concat(addressLevelService.getAllDescendants(action.addressLevelState.selectedAddresses)); + newState.locationSearchCriteria.toggleLowestAddresses(toMatchAddresses); return newState; } diff --git a/packages/openchs-android/src/action/mydashboard/MyDashboardActions.js b/packages/openchs-android/src/action/mydashboard/MyDashboardActions.js index a1940ab98..66b7ff826 100644 --- a/packages/openchs-android/src/action/mydashboard/MyDashboardActions.js +++ b/packages/openchs-android/src/action/mydashboard/MyDashboardActions.js @@ -10,7 +10,6 @@ import {firebaseEvents, logEvent} from "../../utility/Analytics"; import RealmQueryService from "../../service/query/RealmQueryService"; import SubjectTypeService from "../../service/SubjectTypeService"; import {DashboardCacheFilter} from "openchs-models"; -import General from "../../utility/General"; function getApplicableEncounterTypes(holder) { return _.isEmpty(holder.selectedGeneralEncounterTypes) ? holder.selectedEncounterTypes : holder.selectedGeneralEncounterTypes; diff --git a/packages/openchs-android/src/service/AddressLevelService.js b/packages/openchs-android/src/service/AddressLevelService.js index a285769b7..d28955109 100644 --- a/packages/openchs-android/src/service/AddressLevelService.js +++ b/packages/openchs-android/src/service/AddressLevelService.js @@ -1,6 +1,7 @@ import Service from '../framework/bean/Service'; -import {AddressLevel} from 'avni-models'; +import {AddressLevel} from 'openchs-models'; import BaseAddressLevelService from "./BaseAddressLevelService"; +import _ from "lodash"; @Service("addressLevelService") class AddressLevelService extends BaseAddressLevelService { @@ -11,6 +12,13 @@ class AddressLevelService extends BaseAddressLevelService { getSchema() { return AddressLevel.schema.name; } + + getAllDescendants(addresses) { + const addressLevelService = this; + return addresses + .filter(location => location.level === _.get(_.minBy(addresses, 'level'), 'level')) + .reduce((acc, parent) => acc.concat(addressLevelService.getDescendantsOfNode(parent)), []); + } } export default AddressLevelService; diff --git a/packages/openchs-android/src/service/query/IndividualSearchCriteria.js b/packages/openchs-android/src/service/query/IndividualSearchCriteria.js index 1139a1693..0c32c5891 100644 --- a/packages/openchs-android/src/service/query/IndividualSearchCriteria.js +++ b/packages/openchs-android/src/service/query/IndividualSearchCriteria.js @@ -98,13 +98,6 @@ class IndividualSearchCriteria { this.allowedSubjectUUIDs = subjectUUIDs; } - toggleLowestAddress(lowestAddress) { - if (BaseEntity.collectionHasEntity(this.lowestAddressLevels, lowestAddress)) - BaseEntity.removeFromCollection(this.lowestAddressLevels, lowestAddress); - else - this.lowestAddressLevels.push(lowestAddress); - } - toggleLowestAddresses(lowestAddresses) { this.lowestAddressLevels = lowestAddresses; } diff --git a/packages/openchs-android/src/service/reports/DashboardFilterService.js b/packages/openchs-android/src/service/reports/DashboardFilterService.js index cf79dc8d5..e6b268bc1 100644 --- a/packages/openchs-android/src/service/reports/DashboardFilterService.js +++ b/packages/openchs-android/src/service/reports/DashboardFilterService.js @@ -80,9 +80,8 @@ class DashboardFilterService extends BaseService { } else { const addressLevelService = this.getService(AddressLevelService); const addressFilterValues = [...filterValue.selectedAddresses]; - const descendants = filterValue.selectedAddresses - .filter(location => location.level === _.get(_.minBy(filterValue.selectedAddresses, 'level'), 'level')) - .reduce((acc, parent) => acc.concat(addressLevelService.getDescendantsOfNode(parent)), []); + + const descendants = addressLevelService.getAllDescendants(filterValue.selectedAddresses); ruleInput.filterValue = addressFilterValues.concat(descendants .map(addressLevel => _.pick(addressLevel, ['uuid', 'name', 'level', 'type', 'parentUuid']))); General.logDebug('DashboardFilterService', `Effective address filters: ${JSON.stringify(_.countBy(ruleInput.filterValue, "type"))}`); From 6517fefcb7e1222310683e85e4a8d48f8bc4cbab Mon Sep 17 00:00:00 2001 From: himeshr Date: Tue, 11 Jun 2024 11:35:48 +0530 Subject: [PATCH 02/10] #1418 | Show chevron at the bottom-right in cardListView --- .../src/views/customDashboard/CardListView.js | 10 +++++----- .../src/views/customDashboard/CardTileView.js | 1 + .../src/views/customDashboard/CountResult.js | 9 ++++++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/openchs-android/src/views/customDashboard/CardListView.js b/packages/openchs-android/src/views/customDashboard/CardListView.js index 544d80ba3..9cadc3bcf 100644 --- a/packages/openchs-android/src/views/customDashboard/CardListView.js +++ b/packages/openchs-android/src/views/customDashboard/CardListView.js @@ -3,7 +3,7 @@ import React from 'react'; import Styles from '../primitives/Styles'; import {CountResult} from './CountResult'; import _, {get} from 'lodash'; -import MCIcon from 'react-native-vector-icons/MaterialCommunityIcons'; +import Colors from '../primitives/Colors'; export const CardListView = ({reportCard, I18n, onCardPress, countResult, index, isLastCard}) => { const {name, colour, itemKey} = reportCard; @@ -11,6 +11,7 @@ export const CardListView = ({reportCard, I18n, onCardPress, countResult, index, const textColor = (countResult && countResult.textColor) || Styles.blackColor; const descriptionColor = (countResult && countResult.textColor) || Styles.blackColor; const cardColor = (countResult && countResult.cardColor) || colour || '#999999'; + const chevronColor = Colors.darker(0.1, cardColor); const clickable = get(countResult, 'clickable'); const renderNumber = () => { @@ -22,6 +23,9 @@ export const CardListView = ({reportCard, I18n, onCardPress, countResult, index, secondary={countResult.secondaryValue} primaryStyle={[styles.primaryTextStyle, {color: textColor}, countResult.hasErrorMsg && styles.cardPrimaryTextErrorStyle]} secondaryStyle={[styles.secondaryTextStyle, {color: textColor}, countResult.hasErrorMsg && styles.cardSecondaryTextErrorStyle]} + clickable={clickable} + chevronColor={chevronColor} + colour={textColor} /> ); }; @@ -34,10 +38,6 @@ export const CardListView = ({reportCard, I18n, onCardPress, countResult, index, ]}> {I18n.t(cardName)} - - {clickable && - } - {renderNumber()} diff --git a/packages/openchs-android/src/views/customDashboard/CardTileView.js b/packages/openchs-android/src/views/customDashboard/CardTileView.js index b8a32da06..4b84e04b6 100644 --- a/packages/openchs-android/src/views/customDashboard/CardTileView.js +++ b/packages/openchs-android/src/views/customDashboard/CardTileView.js @@ -58,6 +58,7 @@ export const CardTileView = ({index, reportCard, I18n, onCardPress, countResult} width: cardWidth, backgroundColor: cardColor, borderColor: cardBorderColor, + borderWidth: 2, paddingLeft: 16, }]}> diff --git a/packages/openchs-android/src/views/customDashboard/CountResult.js b/packages/openchs-android/src/views/customDashboard/CountResult.js index 58cf8c3ae..4dcf51a43 100644 --- a/packages/openchs-android/src/views/customDashboard/CountResult.js +++ b/packages/openchs-android/src/views/customDashboard/CountResult.js @@ -1,7 +1,8 @@ import React from 'react'; import {Text, View} from "react-native"; +import MCIcon from 'react-native-vector-icons/MaterialCommunityIcons'; -export const CountResult = ({primary, secondary, primaryStyle, secondaryStyle, direction}) => { +export const CountResult = ({primary, secondary, primaryStyle, secondaryStyle, direction, clickable, chevronColor, colour}) => { return ( {primary} @@ -10,6 +11,12 @@ export const CountResult = ({primary, secondary, primaryStyle, secondaryStyle, d {secondary} : null} + + + {clickable && + } + ) }; From 5bc95456257641c204e6acb225b3ba1dda923e7b Mon Sep 17 00:00:00 2001 From: himeshr Date: Tue, 11 Jun 2024 12:32:17 +0530 Subject: [PATCH 03/10] #1418 | Styling changes for CustomDashboard list and card views --- .../src/views/customDashboard/CardListView.js | 14 +++++++------- .../src/views/customDashboard/CardTileView.js | 19 ++++++++++--------- .../src/views/customDashboard/CountResult.js | 2 +- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/packages/openchs-android/src/views/customDashboard/CardListView.js b/packages/openchs-android/src/views/customDashboard/CardListView.js index 9cadc3bcf..662989e33 100644 --- a/packages/openchs-android/src/views/customDashboard/CardListView.js +++ b/packages/openchs-android/src/views/customDashboard/CardListView.js @@ -51,7 +51,7 @@ const styles = StyleSheet.create({ rowContainer: { flexDirection: 'row', flexWrap: 'nowrap', - height: 100, + minHeight: 100, borderWidth: StyleSheet.hairlineWidth, borderColor: '#DCDCDC' }, @@ -70,17 +70,16 @@ const styles = StyleSheet.create({ }, nameContainer: { marginLeft: 5, - paddingHorizontal: 3, + paddingHorizontal: 16, flex: 0.7, flexDirection: 'row', - paddingLeft: 16, + alignItems: 'center', borderRightWidth: StyleSheet.hairlineWidth, borderColor: '#DCDCDC' }, nameTextStyle: { - paddingTop: 15, - fontSize: Styles.titleSize, - width: '90%' + paddingVertical: 15, + fontSize: Styles.normalTextSize }, numberContainer: { flex: 0.3, @@ -92,7 +91,8 @@ const styles = StyleSheet.create({ fontStyle: 'normal', }, secondaryTextStyle: { - fontSize: 16, + fontSize: 14, + fontWeight: '300', fontStyle: 'normal', }, cardPrimaryTextErrorStyle: { diff --git a/packages/openchs-android/src/views/customDashboard/CardTileView.js b/packages/openchs-android/src/views/customDashboard/CardTileView.js index 4b84e04b6..5bc67ef34 100644 --- a/packages/openchs-android/src/views/customDashboard/CardTileView.js +++ b/packages/openchs-android/src/views/customDashboard/CardTileView.js @@ -36,7 +36,7 @@ const renderNumber = function (countResult = {}, textColor) { ); }; -const cardGap = 16; +const cardGap = 14; export const CardTileView = ({index, reportCard, I18n, onCardPress, countResult}) => { const {name, colour, itemKey, iconName} = reportCard; @@ -56,9 +56,10 @@ export const CardTileView = ({index, reportCard, I18n, onCardPress, countResult} marginTop: cardGap, marginLeft: index % 2 !== 0 ? cardGap : 0, width: cardWidth, + minHeight: 100, backgroundColor: cardColor, borderColor: cardBorderColor, - borderWidth: 2, + borderWidth: 1, paddingLeft: 16, }]}> @@ -70,14 +71,14 @@ export const CardTileView = ({index, reportCard, I18n, onCardPress, countResult} {iconName && renderIcon(iconName, textColor)} - + {clickable && - } + } @@ -91,11 +92,11 @@ const styles = StyleSheet.create({ borderWidth: StyleSheet.hairlineWidth, }, cardNameTextStyle: { - fontSize: 18, + fontSize: Styles.normalTextSize, fontStyle: 'normal' }, cardNameContainerStyle: { - paddingBottom: 40, + paddingBottom: 20, marginRight: 12 }, cardPrimaryTextStyle: { @@ -104,7 +105,7 @@ const styles = StyleSheet.create({ fontStyle: 'normal', }, cardSecondaryTextStyle: { - fontSize: 16, + fontSize: 14, fontStyle: 'normal', }, iconContainer: { diff --git a/packages/openchs-android/src/views/customDashboard/CountResult.js b/packages/openchs-android/src/views/customDashboard/CountResult.js index 4dcf51a43..9e6843b2d 100644 --- a/packages/openchs-android/src/views/customDashboard/CountResult.js +++ b/packages/openchs-android/src/views/customDashboard/CountResult.js @@ -8,7 +8,7 @@ export const CountResult = ({primary, secondary, primaryStyle, secondaryStyle, d {primary} {secondary ? - {secondary} + ({secondary}) : null} From c431eda779f0372d80a6f3ac60f08ab06aad7597 Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Wed, 12 Jun 2024 11:12:15 +0530 Subject: [PATCH 04/10] #1420 - model version after merge --- packages/openchs-android/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/openchs-android/package.json b/packages/openchs-android/package.json index 92741d135..3921e10e2 100644 --- a/packages/openchs-android/package.json +++ b/packages/openchs-android/package.json @@ -58,7 +58,7 @@ "lodash": "4.17.21", "moment": "2.29.4", "native-base": "3.4.9", - "openchs-models": "1.31.80", + "openchs-models": "1.31.81", "prop-types": "15.8.1", "react": "18.2.0", "react-native": "0.72.3", From a326c38288be1685d7ccd3d113e4095b79a08aef Mon Sep 17 00:00:00 2001 From: Joy A Date: Thu, 13 Jun 2024 15:03:21 +0530 Subject: [PATCH 05/10] #1423 | Use composite accumulation of address level by level+type in AddressLevelState to aid sorting and grouping --- .../src/action/common/AddressLevelsState.js | 9 ++++++--- .../test/model/TestAddressLevelFactory.js | 4 ++-- .../test/state/AddressLevelStateTest.js | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/packages/openchs-android/src/action/common/AddressLevelsState.js b/packages/openchs-android/src/action/common/AddressLevelsState.js index 00f74a63e..b6f8d4f6e 100644 --- a/packages/openchs-android/src/action/common/AddressLevelsState.js +++ b/packages/openchs-android/src/action/common/AddressLevelsState.js @@ -4,7 +4,10 @@ class AddressLevelsState { constructor(levels = []) { const unsortedLevels = Object.entries(_.uniqBy(levels, l => l.uuid) .reduce((acc, {locationMappings, uuid, name, level, type, parentUuid, typeUuid, isSelected = false}) => { - acc[level] = _.defaultTo(acc[level], []).concat([{ + const accumulatorKey = level + "->" + type; + // accumulating just by type affects our ability to sort the levels. accumulating just by level affects our ability to group levels of the same type + // hence using a composite key of level + type with a separator + acc[accumulatorKey] = _.defaultTo(acc[accumulatorKey], []).concat([{ uuid, name, level, @@ -16,8 +19,8 @@ class AddressLevelsState { }]); return acc; }, {})); - const levelTypeOrderedUnsortedLevels = _.orderBy(unsortedLevels, ([level, value]) => level, ['desc']); - this.levels = levelTypeOrderedUnsortedLevels.map(([levelNum, levels]) => { + const sortedLevels = _.orderBy(unsortedLevels, ([levelKey, value]) => levelKey, ['desc']); + this.levels = sortedLevels.map(([levelKey, levels]) => { const levelType = levels[0].type; const other = _.find(levels, (level) => _.startsWith(level.name, "Other")); if(!_.isNil(other)) { diff --git a/packages/openchs-android/test/model/TestAddressLevelFactory.js b/packages/openchs-android/test/model/TestAddressLevelFactory.js index bdd7957f8..2b2228312 100644 --- a/packages/openchs-android/test/model/TestAddressLevelFactory.js +++ b/packages/openchs-android/test/model/TestAddressLevelFactory.js @@ -3,11 +3,11 @@ import General from "../../src/utility/General"; import _ from 'lodash'; class TestAddressLevelFactory { - static createWithDefaults({parent, level, name}) { + static createWithDefaults({parent, level, name, type}) { const addressLevel = new AddressLevel(); addressLevel.uuid = General.randomUUID(); addressLevel.name = _.defaultTo(name, addressLevel.uuid); - addressLevel.type = level+'_level'; + addressLevel.type = type || level+'_level'; addressLevel.level = level; if (!_.isNil(parent)) { const locationMapping = new LocationMapping(); diff --git a/packages/openchs-android/test/state/AddressLevelStateTest.js b/packages/openchs-android/test/state/AddressLevelStateTest.js index 8e769b06b..23b743809 100644 --- a/packages/openchs-android/test/state/AddressLevelStateTest.js +++ b/packages/openchs-android/test/state/AddressLevelStateTest.js @@ -35,4 +35,22 @@ it('should sort addressLevels by levelType and within each levelType by name', f assert.equal(levels[0].locationMappings[0].parent.uuid, parentLevelElement[0].uuid); } }); +}); + +it ('should treat multiple address level types at the same level as separate', function() { + const addrLevel1 = TestAddressLevelFactory.createWithDefaults({level: 1, type: 'a', name: 'location1'}); + const addrLevel2 = TestAddressLevelFactory.createWithDefaults({level: 1, type: 'b', name: 'location2'}); + const addrLevel3 = TestAddressLevelFactory.createWithDefaults({level: 1, type: 'c', name: 'location3'}); + + const allLevels = [ + addrLevel1, addrLevel2, addrLevel3, + ] + // Shuffle the addressLevels + let addressLevelsState = new AddressLevelsState(_.shuffle(allLevels)); + assert.equal(addressLevelsState.levels.length, 3); + addressLevelsState.levels.map(([levelType, levels]) => { + assert.equal(levels.length, 1); // 1 group for each levelType + assert.equal(levels[0].type, levelType); // group consists of same type of addressLevels + }); + }); \ No newline at end of file From e29d825c0d9ddc68ae4b91ce89c6ad439f925bf1 Mon Sep 17 00:00:00 2001 From: Joy A Date: Mon, 17 Jun 2024 11:24:54 +0530 Subject: [PATCH 06/10] #1430 | Throw rule failure if visits are scheduled without earliestVisitDateTime Return empty array instead of pre-existing visits if error occurs during visit schedule rule execution Check for null before converting toISTDate --- packages/openchs-android/package-lock.json | 14 +++++++------- .../src/service/RuleEvaluationService.js | 19 ++++++++++++++++--- .../openchs-android/src/utility/General.js | 2 +- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/packages/openchs-android/package-lock.json b/packages/openchs-android/package-lock.json index fa0d45324..5f5182187 100644 --- a/packages/openchs-android/package-lock.json +++ b/packages/openchs-android/package-lock.json @@ -35,7 +35,7 @@ "lodash": "4.17.21", "moment": "2.29.4", "native-base": "3.4.9", - "openchs-models": "1.31.76", + "openchs-models": "1.31.81", "prop-types": "15.8.1", "react": "18.2.0", "react-native": "0.72.3", @@ -16441,9 +16441,9 @@ } }, "node_modules/openchs-models": { - "version": "1.31.76", - "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.31.76.tgz", - "integrity": "sha512-URaXmaUwxukzqjBpO9A5rmJEp++oDwzJ8UgjvOr4f8OdxECVLKrO6NkapAMvnIG55NwBCrgjdwNuwk5K/ji2iA==", + "version": "1.31.81", + "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.31.81.tgz", + "integrity": "sha512-V+s6vzD9F0kMzExxe09tTo2Q2Fs9fuDjgOArMjvnRPa4GNC1rPk8Eod9Uf61C48Ke1NXIR8oW40s7IUTScZRpA==", "dependencies": { "uuid": "^9.0.1" }, @@ -35181,9 +35181,9 @@ } }, "openchs-models": { - "version": "1.31.76", - "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.31.76.tgz", - "integrity": "sha512-URaXmaUwxukzqjBpO9A5rmJEp++oDwzJ8UgjvOr4f8OdxECVLKrO6NkapAMvnIG55NwBCrgjdwNuwk5K/ji2iA==", + "version": "1.31.81", + "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.31.81.tgz", + "integrity": "sha512-V+s6vzD9F0kMzExxe09tTo2Q2Fs9fuDjgOArMjvnRPa4GNC1rPk8Eod9Uf61C48Ke1NXIR8oW40s7IUTScZRpA==", "requires": { "uuid": "^9.0.1" } diff --git a/packages/openchs-android/src/service/RuleEvaluationService.js b/packages/openchs-android/src/service/RuleEvaluationService.js index aa520d997..eedec1f64 100644 --- a/packages/openchs-android/src/service/RuleEvaluationService.js +++ b/packages/openchs-android/src/service/RuleEvaluationService.js @@ -464,9 +464,10 @@ class RuleEvaluationService extends BaseService { params: _.merge({visitSchedule: scheduledVisits, entity, entityContext, services: this.services}, this.getCommonParams()), imports: getImports() }); + this.checkIfScheduledVisitsAreValid(nextVisits); return nextVisits; } catch (e) { - General.logDebug("Rule-Failure", `New enrolment decision failed for form: ${form.uuid}`); + General.logDebug("Rule-Failure", `Visit Schedule failed for form: ${form.uuid}`); this.saveFailedRules(e, form.uuid, this.getIndividualUUID(entity, entityName)); } } else { @@ -476,9 +477,21 @@ class RuleEvaluationService extends BaseService { return this.runRuleAndSaveFailure(rule, entityName, entity, schedule, visitScheduleConfig, null, entityContext); }, scheduledVisits); General.logDebug("RuleEvaluationService - Next Visits", nextVisits); - return nextVisits; + try { + this.checkIfScheduledVisitsAreValid(nextVisits); + return nextVisits; + } catch(e) { + General.logDebug("Rule-Failure", `Visit Schedule (old) failed for form: ${form.uuid}`); + this.saveFailedRules(e, form.uuid, this.getIndividualUUID(entity, entityName)); + } + } + return defaultVisitSchedule; + } + + checkIfScheduledVisitsAreValid(nextVisits) { + if (nextVisits.map(visit => _.isNil(visit.earliestVisitDateTime)).length > 0) { + throw new Error("Visit(s) scheduled without earliestVisitDateTime"); } - return scheduledVisits; } getChecklists(entity, entityName, defaultChecklists = []) { diff --git a/packages/openchs-android/src/utility/General.js b/packages/openchs-android/src/utility/General.js index b15dd54f4..3291cd4bf 100644 --- a/packages/openchs-android/src/utility/General.js +++ b/packages/openchs-android/src/utility/General.js @@ -202,7 +202,7 @@ class General { } static toISTDate(x) { - if (x.toString().includes("18:30:00")) + if (x && x.toString().includes("18:30:00")) return moment(x).add(330, "m").toDate(); return x; } From 889332867d569bdf2942257bf6afff3ef1320127 Mon Sep 17 00:00:00 2001 From: Joy A Date: Mon, 17 Jun 2024 14:48:18 +0530 Subject: [PATCH 07/10] #1430 | Check if old visit schedule rule exists before processing it since the pre-existing visits are returned by default --- packages/openchs-android/src/service/RuleEvaluationService.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/openchs-android/src/service/RuleEvaluationService.js b/packages/openchs-android/src/service/RuleEvaluationService.js index eedec1f64..3fb199ae2 100644 --- a/packages/openchs-android/src/service/RuleEvaluationService.js +++ b/packages/openchs-android/src/service/RuleEvaluationService.js @@ -470,7 +470,7 @@ class RuleEvaluationService extends BaseService { General.logDebug("Rule-Failure", `Visit Schedule failed for form: ${form.uuid}`); this.saveFailedRules(e, form.uuid, this.getIndividualUUID(entity, entityName)); } - } else { + } else if (!_.isEmpty(rulesFromTheBundle)) { const nextVisits = rulesFromTheBundle .reduce((schedule, rule) => { General.logDebug(`RuleEvaluationService`, `Executing Rule: ${rule.name} Class: ${rule.fnName}`); From 499c74c11e8cdd5d30d2aaf17727320b74c07707 Mon Sep 17 00:00:00 2001 From: Joy A Date: Mon, 24 Jun 2024 14:41:27 +0530 Subject: [PATCH 08/10] #1430 | Validate visit schedule rules using earliestDate instead of earliestVisitDateTime field --- packages/openchs-android/src/service/RuleEvaluationService.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/openchs-android/src/service/RuleEvaluationService.js b/packages/openchs-android/src/service/RuleEvaluationService.js index 3fb199ae2..d4ead055f 100644 --- a/packages/openchs-android/src/service/RuleEvaluationService.js +++ b/packages/openchs-android/src/service/RuleEvaluationService.js @@ -489,8 +489,8 @@ class RuleEvaluationService extends BaseService { } checkIfScheduledVisitsAreValid(nextVisits) { - if (nextVisits.map(visit => _.isNil(visit.earliestVisitDateTime)).length > 0) { - throw new Error("Visit(s) scheduled without earliestVisitDateTime"); + if (_.some(nextVisits, visit => _.isNil(visit.earliestDate))) { + throw new Error("Visit(s) scheduled without earliestDate"); } } From 50f8a107a71f9b5dba9f6ded4c05bb6783229f94 Mon Sep 17 00:00:00 2001 From: himeshr Date: Tue, 23 Jul 2024 15:53:02 +0530 Subject: [PATCH 09/10] #1469 | Upgrade "react-native-video" to "5.2.1" --- makefiles/patches.mk | 1 - packages/openchs-android/package-lock.json | 28 ++++++++++--------- packages/openchs-android/package.json | 2 +- .../patches/react-native-video+5.2.0.patch | 27 ------------------ 4 files changed, 16 insertions(+), 42 deletions(-) delete mode 100644 packages/openchs-android/patches/react-native-video+5.2.0.patch diff --git a/makefiles/patches.mk b/makefiles/patches.mk index c4b026bb3..4cdc1ffc4 100644 --- a/makefiles/patches.mk +++ b/makefiles/patches.mk @@ -8,7 +8,6 @@ patch-history: cd packages/openchs-android && npx patch-package realm --include "build.gradle" cd packages/openchs-android && npx patch-package react-native-background-worker cd packages/openchs-android && npx patch-package react-native-smooth-pincode-input --include "index.js" - cd packages/openchs-android && npx patch-package react-native-video --include "Video.js" cd packages/openchs-android && npx patch-package react-native-video-player --include "index.js" cd packages/openchs-android && npx patch-package react-native-deprecated-custom-components --include "(Navigator.js)|(NavigatorBreadcrumbNavigationBar.js)|(NavigatorNavigationBar.js)" cd packages/openchs-android && npx patch-package react-native-background-job --include "build.gradle" diff --git a/packages/openchs-android/package-lock.json b/packages/openchs-android/package-lock.json index 2dfef8558..b09561a50 100644 --- a/packages/openchs-android/package-lock.json +++ b/packages/openchs-android/package-lock.json @@ -67,7 +67,7 @@ "react-native-smooth-pincode-input": "1.0.9", "react-native-svg": "12.4.3", "react-native-vector-icons": "9.2.0", - "react-native-video": "5.2.0", + "react-native-video": "5.2.1", "react-native-video-player": "0.12.0", "react-native-webview": "11.23.0", "react-native-zip-archive": "6.0.8", @@ -8379,9 +8379,9 @@ "dev": true }, "node_modules/eme-encryption-scheme-polyfill": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/eme-encryption-scheme-polyfill/-/eme-encryption-scheme-polyfill-2.1.1.tgz", - "integrity": "sha512-njD17wcUrbqCj0ArpLu5zWXtaiupHb/2fIUQGdInf83GlI+Q6mmqaPGLdrke4savKAu15J/z1Tg/ivDgl14g0g==" + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/eme-encryption-scheme-polyfill/-/eme-encryption-scheme-polyfill-2.1.5.tgz", + "integrity": "sha512-z9BKXV4TCYjmar0wiZLObZ0J8HE13VIg7Zq/iyPWdbEfROtxVXEJalknWKtBR5XNezzy15/zWS964TGbcAWlPg==" }, "node_modules/emittery": { "version": "0.10.2", @@ -18011,10 +18011,11 @@ } }, "node_modules/react-native-video": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/react-native-video/-/react-native-video-5.2.0.tgz", - "integrity": "sha512-5SK1lxyzrCkZF+WuxUxLR1Pt65E0rsWB1w1GrGxSLdC9zWYBumcmuHl+wPJ7UQvznjaH2Ze7uU1R3arejI7+WQ==", + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/react-native-video/-/react-native-video-5.2.1.tgz", + "integrity": "sha512-aJlr9MeTuQ0LpZ4n+EC9RvhoKeiPbLtI2Rxy8u7zo/wzGevbRpWHSBj9xZ5YDBXnAVXzuqyNIkGhdw7bfdIBZw==", "dependencies": { + "deprecated-react-native-prop-types": "^2.2.0", "keymirror": "^0.1.1", "prop-types": "^15.7.2", "shaka-player": "^2.5.9" @@ -29024,9 +29025,9 @@ } }, "eme-encryption-scheme-polyfill": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/eme-encryption-scheme-polyfill/-/eme-encryption-scheme-polyfill-2.1.1.tgz", - "integrity": "sha512-njD17wcUrbqCj0ArpLu5zWXtaiupHb/2fIUQGdInf83GlI+Q6mmqaPGLdrke4savKAu15J/z1Tg/ivDgl14g0g==" + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/eme-encryption-scheme-polyfill/-/eme-encryption-scheme-polyfill-2.1.5.tgz", + "integrity": "sha512-z9BKXV4TCYjmar0wiZLObZ0J8HE13VIg7Zq/iyPWdbEfROtxVXEJalknWKtBR5XNezzy15/zWS964TGbcAWlPg==" }, "emittery": { "version": "0.10.2", @@ -36562,10 +36563,11 @@ } }, "react-native-video": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/react-native-video/-/react-native-video-5.2.0.tgz", - "integrity": "sha512-5SK1lxyzrCkZF+WuxUxLR1Pt65E0rsWB1w1GrGxSLdC9zWYBumcmuHl+wPJ7UQvznjaH2Ze7uU1R3arejI7+WQ==", + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/react-native-video/-/react-native-video-5.2.1.tgz", + "integrity": "sha512-aJlr9MeTuQ0LpZ4n+EC9RvhoKeiPbLtI2Rxy8u7zo/wzGevbRpWHSBj9xZ5YDBXnAVXzuqyNIkGhdw7bfdIBZw==", "requires": { + "deprecated-react-native-prop-types": "^2.2.0", "keymirror": "^0.1.1", "prop-types": "^15.7.2", "shaka-player": "^2.5.9" diff --git a/packages/openchs-android/package.json b/packages/openchs-android/package.json index c7f12d491..9afbf0bf0 100644 --- a/packages/openchs-android/package.json +++ b/packages/openchs-android/package.json @@ -89,7 +89,7 @@ "react-native-smooth-pincode-input": "1.0.9", "react-native-svg": "12.4.3", "react-native-vector-icons": "9.2.0", - "react-native-video": "5.2.0", + "react-native-video": "5.2.1", "react-native-video-player": "0.12.0", "react-native-webview": "11.23.0", "react-native-zip-archive": "6.0.8", diff --git a/packages/openchs-android/patches/react-native-video+5.2.0.patch b/packages/openchs-android/patches/react-native-video+5.2.0.patch deleted file mode 100644 index 09654c75b..000000000 --- a/packages/openchs-android/patches/react-native-video+5.2.0.patch +++ /dev/null @@ -1,27 +0,0 @@ -diff --git a/node_modules/react-native-video/Video.js b/node_modules/react-native-video/Video.js -index b492d48..2a09fdb 100644 ---- a/node_modules/react-native-video/Video.js -+++ b/node_modules/react-native-video/Video.js -@@ -1,11 +1,12 @@ - import React, { Component } from 'react'; - import PropTypes from 'prop-types'; --import { StyleSheet, requireNativeComponent, NativeModules, View, ViewPropTypes, Image, Platform, findNodeHandle } from 'react-native'; -+import { StyleSheet, requireNativeComponent, NativeModules, View, Image, Platform, findNodeHandle } from 'react-native'; - import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource'; - import TextTrackType from './TextTrackType'; - import FilterType from './FilterType'; - import DRMType from './DRMType'; - import VideoResizeMode from './VideoResizeMode.js'; -+const {ImagePropTypes, ViewPropTypes} = require('deprecated-react-native-prop-types'); - - const styles = StyleSheet.create({ - base: { -@@ -415,7 +416,7 @@ Video.propTypes = { - maxBitRate: PropTypes.number, - resizeMode: PropTypes.string, - poster: PropTypes.string, -- posterResizeMode: Image.propTypes.resizeMode, -+ posterResizeMode: ImagePropTypes.resizeMode, - repeat: PropTypes.bool, - automaticallyWaitsToMinimizeStalling: PropTypes.bool, - allowsExternalPlayback: PropTypes.bool, From 65621a0516e3e045a900f0fb8af81e041f67951c Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Wed, 24 Jul 2024 10:23:43 +0530 Subject: [PATCH 10/10] #1470 - model version --- packages/openchs-android/package-lock.json | 14 +++++++------- packages/openchs-android/package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/openchs-android/package-lock.json b/packages/openchs-android/package-lock.json index b09561a50..a22827e89 100644 --- a/packages/openchs-android/package-lock.json +++ b/packages/openchs-android/package-lock.json @@ -35,7 +35,7 @@ "lodash": "4.17.21", "moment": "2.29.4", "native-base": "3.4.9", - "openchs-models": "1.31.87", + "openchs-models": "1.31.97", "prop-types": "15.8.1", "react": "18.2.0", "react-native": "0.72.3", @@ -16441,9 +16441,9 @@ } }, "node_modules/openchs-models": { - "version": "1.31.87", - "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.31.87.tgz", - "integrity": "sha512-ZA2+8v2PDI9qv/Q99yb6joGjYud54v8WJsHPL2+3IYoHzz3AMsROIdEYq7bGBgZESltOrPjVFyskm4F9FWS2Pw==", + "version": "1.31.97", + "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.31.97.tgz", + "integrity": "sha512-00u3mxCdgigygeh6n7lUN8SqkYuojxQQhhQ+hV2wB5kiRZWa4lE2iln5lYWOt/4rIXIcwJ/RmV0jjQ760jhsXQ==", "dependencies": { "uuid": "^9.0.1" }, @@ -35182,9 +35182,9 @@ } }, "openchs-models": { - "version": "1.31.87", - "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.31.87.tgz", - "integrity": "sha512-ZA2+8v2PDI9qv/Q99yb6joGjYud54v8WJsHPL2+3IYoHzz3AMsROIdEYq7bGBgZESltOrPjVFyskm4F9FWS2Pw==", + "version": "1.31.97", + "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.31.97.tgz", + "integrity": "sha512-00u3mxCdgigygeh6n7lUN8SqkYuojxQQhhQ+hV2wB5kiRZWa4lE2iln5lYWOt/4rIXIcwJ/RmV0jjQ760jhsXQ==", "requires": { "uuid": "^9.0.1" } diff --git a/packages/openchs-android/package.json b/packages/openchs-android/package.json index 9afbf0bf0..7808ee513 100644 --- a/packages/openchs-android/package.json +++ b/packages/openchs-android/package.json @@ -58,7 +58,7 @@ "lodash": "4.17.21", "moment": "2.29.4", "native-base": "3.4.9", - "openchs-models": "1.31.87", + "openchs-models": "1.31.97", "prop-types": "15.8.1", "react": "18.2.0", "react-native": "0.72.3",