@openmrs/esm-form-engine-lib 3.0.0-pre.1607 → 3.0.0-pre.1614
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/utils/common-expression-helpers.test.ts +1 -1
- package/src/utils/common-expression-helpers.ts +10 -7
- package/c8c43a398b93a8f0/c8c43a398b93a8f0.gz +0 -0
- package/e50e51afe8137309/e50e51afe8137309.gz +0 -0
- package/f375ac2a274e12f9/f375ac2a274e12f9.gz +0 -0
- package/f9635a94e6259844/f9635a94e6259844.gz +0 -0
package/package.json
CHANGED
@@ -171,7 +171,7 @@ describe('CommonExpressionHelpers', () => {
|
|
171
171
|
it('should return the correct number of months on ART', () => {
|
172
172
|
const artStartDate = new Date('2020-01-01');
|
173
173
|
const today = new Date();
|
174
|
-
const monthsOnART =
|
174
|
+
const monthsOnART = dayjs(today).diff(dayjs(artStartDate), 'months');
|
175
175
|
expect(helpers.calcMonthsOnART(artStartDate)).toBe(monthsOnART);
|
176
176
|
});
|
177
177
|
|
@@ -118,19 +118,22 @@ export class CommonExpressionHelpers {
|
|
118
118
|
};
|
119
119
|
|
120
120
|
calcMonthsOnART = (artStartDate: Date) => {
|
121
|
-
if (artStartDate == null)
|
121
|
+
if (artStartDate == null) {
|
122
|
+
return null;
|
123
|
+
}
|
122
124
|
|
123
125
|
if (!(artStartDate instanceof Date)) {
|
124
126
|
throw new Error('DateFormatException: value passed is not a valid date');
|
125
127
|
}
|
126
128
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
if (
|
131
|
-
|
129
|
+
const today = new Date();
|
130
|
+
const artInDays = Math.round((today.getTime() - artStartDate.getTime()) / 86400000);
|
131
|
+
|
132
|
+
if (artInDays < 30) {
|
133
|
+
return 0;
|
132
134
|
}
|
133
|
-
|
135
|
+
|
136
|
+
return dayjs(today).diff(artStartDate, 'month');
|
134
137
|
};
|
135
138
|
|
136
139
|
calcViralLoadStatus = (viralLoadCount: number) => {
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|