@openmrs/esm-form-engine-lib 4.2.2-pre.2687 → 4.3.0
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/dist/src/utils/zscore-service.d.ts.map +1 -1
- package/dist/utils/zscore-service.js +23 -12
- package/dist/zscore/hfa_girls_5_above.json +1680 -1680
- package/package.json +2 -3
- package/src/utils/zscore-service.ts +25 -12
- package/src/zscore/hfa_girls_5_above.json +1680 -1680
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-form-engine-lib",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"description": "React Form Engine for O3",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -100,6 +100,5 @@
|
|
|
100
100
|
"*.{ts,tsx}": "eslint --cache --fix --max-warnings 0",
|
|
101
101
|
"*.{css,scss,ts,tsx}": "prettier --write --list-different"
|
|
102
102
|
},
|
|
103
|
-
"packageManager": "yarn@4.10.3"
|
|
104
|
-
"stableVersion": "4.2.1"
|
|
103
|
+
"packageManager": "yarn@4.10.3"
|
|
105
104
|
}
|
|
@@ -64,13 +64,20 @@ function getTable(name: ZScoreTableName) {
|
|
|
64
64
|
return table;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
/**
|
|
68
|
+
* The under-5 tables (the WHO child growth standards) go up to day 1,856, and the 5 to 19 year tables (the WHO
|
|
69
|
+
* growth reference) start at 61 months.
|
|
70
|
+
*/
|
|
71
|
+
const lastDayOfUnderFiveTables = 1856;
|
|
72
|
+
const firstMonthOfOlderChildTables = 61;
|
|
73
|
+
|
|
67
74
|
export function getWeightForHeightRef(gender, birthDate, refdate) {
|
|
68
75
|
const age = getAge(birthDate, refdate, 'years');
|
|
69
76
|
|
|
70
|
-
if (gender === 'F' && age < 5) {
|
|
77
|
+
if (gender === 'F' && age !== null && age < 5) {
|
|
71
78
|
return getTable('wflFemaleBelow5');
|
|
72
79
|
}
|
|
73
|
-
if (gender === 'M' && age < 5) {
|
|
80
|
+
if (gender === 'M' && age !== null && age < 5) {
|
|
74
81
|
return getTable('wflMaleBelow5');
|
|
75
82
|
}
|
|
76
83
|
return null;
|
|
@@ -80,21 +87,22 @@ export function getHeightForAgeRef(gender, birthDate, refdate) {
|
|
|
80
87
|
const age = getAge(birthDate, refdate, 'years');
|
|
81
88
|
const ageInMonths = getAge(birthDate, refdate, 'months');
|
|
82
89
|
const ageInDays = getAge(birthDate, refdate, 'days');
|
|
90
|
+
const olderChildMonth = Math.max(ageInMonths, firstMonthOfOlderChildTables);
|
|
83
91
|
|
|
84
92
|
if (gender === 'F') {
|
|
85
|
-
if (
|
|
93
|
+
if (ageInDays !== null && ageInDays <= lastDayOfUnderFiveTables) {
|
|
86
94
|
return getScoreReference(getTable('hfaFemaleBelow5'), 'Day', ageInDays);
|
|
87
95
|
}
|
|
88
|
-
if (
|
|
89
|
-
return getScoreReference(getTable('hfaFemale5Above'), 'Month',
|
|
96
|
+
if (ageInDays > lastDayOfUnderFiveTables && age < 18) {
|
|
97
|
+
return getScoreReference(getTable('hfaFemale5Above'), 'Month', olderChildMonth);
|
|
90
98
|
}
|
|
91
99
|
}
|
|
92
100
|
if (gender === 'M') {
|
|
93
|
-
if (
|
|
101
|
+
if (ageInDays !== null && ageInDays <= lastDayOfUnderFiveTables) {
|
|
94
102
|
return getScoreReference(getTable('hfaMaleBelow5'), 'Day', ageInDays);
|
|
95
103
|
}
|
|
96
|
-
if (
|
|
97
|
-
return getScoreReference(getTable('hfaMale5Above'), 'Month',
|
|
104
|
+
if (ageInDays > lastDayOfUnderFiveTables && age < 18) {
|
|
105
|
+
return getScoreReference(getTable('hfaMale5Above'), 'Month', olderChildMonth);
|
|
98
106
|
}
|
|
99
107
|
}
|
|
100
108
|
return null;
|
|
@@ -103,12 +111,14 @@ export function getHeightForAgeRef(gender, birthDate, refdate) {
|
|
|
103
111
|
export function getBmiForAgeRef(gender, birthDate, refdate) {
|
|
104
112
|
const age = getAge(birthDate, refdate, 'years');
|
|
105
113
|
const ageInMonths = getAge(birthDate, refdate, 'months');
|
|
114
|
+
const ageInDays = getAge(birthDate, refdate, 'days');
|
|
115
|
+
const olderChildMonth = Math.max(ageInMonths, firstMonthOfOlderChildTables);
|
|
106
116
|
|
|
107
|
-
if (gender === 'F' &&
|
|
108
|
-
return getScoreReference(getTable('bfaFemale5Above'), 'Month',
|
|
117
|
+
if (gender === 'F' && ageInDays > lastDayOfUnderFiveTables && age < 18) {
|
|
118
|
+
return getScoreReference(getTable('bfaFemale5Above'), 'Month', olderChildMonth);
|
|
109
119
|
}
|
|
110
|
-
if (gender === 'M' &&
|
|
111
|
-
return getScoreReference(getTable('bfaMale5Above'), 'Month',
|
|
120
|
+
if (gender === 'M' && ageInDays > lastDayOfUnderFiveTables && age < 18) {
|
|
121
|
+
return getScoreReference(getTable('bfaMale5Above'), 'Month', olderChildMonth);
|
|
112
122
|
}
|
|
113
123
|
return null;
|
|
114
124
|
}
|
|
@@ -123,6 +133,9 @@ function getAge(birthdate, refDate, ageIn) {
|
|
|
123
133
|
if (birthdate && refDate && ageIn) {
|
|
124
134
|
const todayMoment: any = dayjs(refDate);
|
|
125
135
|
const birthDateMoment: any = dayjs(birthdate);
|
|
136
|
+
if (!todayMoment.isValid() || !birthDateMoment.isValid()) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
126
139
|
return todayMoment.diff(birthDateMoment, ageIn);
|
|
127
140
|
}
|
|
128
141
|
return null;
|