@hedia/recommendation-screen 1.2.1 → 1.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/.idea/workspace.xml +30 -30
- package/package.json +1 -1
- package/src/RecommendationScreen.d.ts +3 -0
- package/src/RecommendationScreen.jsx +50 -41
- package/src/RecommendationScreen.tsx +80 -56
- package/src/components/InvisibleNumberInput.d.ts +1 -0
- package/src/components/InvisibleNumberInput.jsx +1 -1
- package/src/components/InvisibleNumberInput.tsx +3 -0
- package/src/components/RecommendedCarbs.d.ts +0 -2
- package/src/components/RecommendedCarbs.jsx +8 -3
- package/src/components/RecommendedCarbs.tsx +10 -5
- package/src/components/RecommendedInsulin.d.ts +3 -3
- package/src/components/RecommendedInsulin.jsx +18 -6
- package/src/components/RecommendedInsulin.tsx +24 -10
- package/src/components/activity/ActivityIcon.jsx +1 -1
- package/src/components/activity/ActivityIcon.tsx +1 -1
- package/src/types/enum.d.ts +9 -10
- package/src/types/enum.js +9 -10
- package/src/types/enum.ts +0 -1
- package/src/types/types.ts +1 -0
- package/src/utils/AttentionMessages.d.ts +1 -1
- package/src/utils/AttentionMessages.jsx +1 -1
- package/src/utils/AttentionMessages.tsx +1 -1
- package/src/utils/Constants.d.ts +3 -0
- package/src/utils/Constants.js +4 -1
- package/src/utils/Constants.ts +5 -0
- package/src/utils/RecommendationError.d.ts +0 -1
- package/src/utils/RecommendationError.jsx +1 -3
- package/src/utils/RecommendationError.tsx +0 -7
- package/src/utils/RecommendationUtils.d.ts +2 -3
- package/src/utils/RecommendationUtils.js +3 -4
- package/src/utils/RecommendationUtils.ts +2 -4
- package/src/utils/Utils.d.ts +1 -0
- package/src/utils/Utils.js +4 -0
- package/src/utils/Utils.ts +4 -0
- package/src/utils/Validations.js +15 -11
- package/src/utils/Validations.ts +16 -11
package/src/utils/Validations.js
CHANGED
|
@@ -76,19 +76,23 @@ function checkActivity(activity) {
|
|
|
76
76
|
}
|
|
77
77
|
exports.checkActivity = checkActivity;
|
|
78
78
|
function checkRecentBolusesInsulinDosis(recentBoluses) {
|
|
79
|
-
recentBoluses
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
if (recentBoluses !== null) {
|
|
80
|
+
recentBoluses.forEach((bolus) => {
|
|
81
|
+
if (!Utils_1.Utils.isInClosedInterval(bolus.insulinDosis, Constants_1.INSULIN_DOSIS_LIMITS)) {
|
|
82
|
+
throw RecommendationError_1.BolusInsulinDosisError();
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
84
86
|
}
|
|
85
87
|
exports.checkRecentBolusesInsulinDosis = checkRecentBolusesInsulinDosis;
|
|
86
88
|
function checkRecentBolusesSecondsPassed(recentBoluses) {
|
|
87
|
-
recentBoluses
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
if (recentBoluses !== null) {
|
|
90
|
+
recentBoluses.forEach((bolus) => {
|
|
91
|
+
if (!Utils_1.Utils.isInClosedInterval(bolus.secondsPassed, Constants_1.BOLUS_SECONDS_PASSED_LIMITS)) {
|
|
92
|
+
throw RecommendationError_1.BolusInsulinSecondsPassedError();
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
92
96
|
}
|
|
93
97
|
exports.checkRecentBolusesSecondsPassed = checkRecentBolusesSecondsPassed;
|
|
94
98
|
function checkActivityDuration(activityDuration) {
|
|
@@ -112,7 +116,7 @@ exports.checkActivityIntensity = checkActivityIntensity;
|
|
|
112
116
|
function checkActivityDate(activity) {
|
|
113
117
|
const maximumDate = moment_1.default
|
|
114
118
|
.utc(activity.activityDate)
|
|
115
|
-
.add(activity.activityDuration + Constants_1.ONE_HOUR_MINUTES * 4, `minutes`);
|
|
119
|
+
.add(activity.activityDuration + Constants_1.ONE_HOUR_MINUTES * 4 + Constants_1.ACTIVITY_BUFFER_MINUTES, `minutes`);
|
|
116
120
|
if (!moment_1.default.utc().isBefore(maximumDate)) {
|
|
117
121
|
throw RecommendationError_1.ActivityDateError();
|
|
118
122
|
}
|
package/src/utils/Validations.ts
CHANGED
|
@@ -9,6 +9,7 @@ import moment from "moment";
|
|
|
9
9
|
import { IRecommendationProps } from "../RecommendationScreen";
|
|
10
10
|
import { ActivityInterval, BGUnit, InjectionMethod, Languages } from "../types/enum";
|
|
11
11
|
import {
|
|
12
|
+
ACTIVITY_BUFFER_MINUTES,
|
|
12
13
|
ACTIVITY_DURATION_MINUTES_LIMITS,
|
|
13
14
|
ACTIVITY_SETTINGS_INTERVAL_LIMITS,
|
|
14
15
|
ACTIVITY_TARGET_BGL_MMOL_LIMITS,
|
|
@@ -109,19 +110,23 @@ export function checkActivity(activity: IRecommendationParams["activity"]): void
|
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
export function checkRecentBolusesInsulinDosis(recentBoluses: Array<IRecentBolus>): void {
|
|
112
|
-
recentBoluses
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
if (recentBoluses !== null) {
|
|
114
|
+
recentBoluses.forEach((bolus: IRecentBolus): void => {
|
|
115
|
+
if (!Utils.isInClosedInterval(bolus.insulinDosis, INSULIN_DOSIS_LIMITS)) {
|
|
116
|
+
throw BolusInsulinDosisError();
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
117
120
|
}
|
|
118
121
|
|
|
119
122
|
export function checkRecentBolusesSecondsPassed(recentBoluses: Array<IRecentBolus>): void {
|
|
120
|
-
recentBoluses
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
if (recentBoluses !== null) {
|
|
124
|
+
recentBoluses.forEach((bolus: IRecentBolus): void => {
|
|
125
|
+
if (!Utils.isInClosedInterval(bolus.secondsPassed, BOLUS_SECONDS_PASSED_LIMITS)) {
|
|
126
|
+
throw BolusInsulinSecondsPassedError();
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
125
130
|
}
|
|
126
131
|
|
|
127
132
|
export function checkActivityDuration(activityDuration: IRecommendationParams["activity"]["activityDuration"]): void {
|
|
@@ -146,7 +151,7 @@ export function checkActivityIntensity(
|
|
|
146
151
|
export function checkActivityDate(activity: IRecommendationParams["activity"]): void {
|
|
147
152
|
const maximumDate = moment
|
|
148
153
|
.utc(activity.activityDate)
|
|
149
|
-
.add(activity.activityDuration + ONE_HOUR_MINUTES * 4, `minutes`);
|
|
154
|
+
.add(activity.activityDuration + ONE_HOUR_MINUTES * 4 + ACTIVITY_BUFFER_MINUTES, `minutes`);
|
|
150
155
|
if (!moment.utc().isBefore(maximumDate)) {
|
|
151
156
|
throw ActivityDateError();
|
|
152
157
|
}
|