@hedia/recommendation-screen 1.8.2 → 2.0.2
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/.github/workflows/ci.yml +0 -0
- package/.github/workflows/publish.yml +48 -0
- package/.github/workflows/version-check.yml +45 -0
- package/.linguirc +0 -0
- package/.npmpackagejsonlintrc.json +0 -0
- package/.prettierignore +0 -0
- package/.prettierrc +0 -0
- package/App.d.ts +4 -5
- package/App.jsx +23 -34
- package/App.tsx +36 -41
- package/Changelog.md +0 -0
- package/README.md +0 -0
- package/android/app/BUCK +0 -0
- package/android/app/build.gradle +0 -0
- package/android/app/build_defs.bzl +0 -0
- package/android/app/debug.keystore +0 -0
- package/android/app/proguard-rules.pro +0 -0
- package/android/app/src/debug/AndroidManifest.xml +0 -0
- package/android/app/src/debug/java/com/hediarecommendationscreen/ReactNativeFlipper.java +0 -0
- package/android/app/src/main/AndroidManifest.xml +0 -0
- package/android/app/src/main/assets/fonts/AntDesign.ttf +0 -0
- package/android/app/src/main/assets/fonts/Entypo.ttf +0 -0
- package/android/app/src/main/assets/fonts/EvilIcons.ttf +0 -0
- package/android/app/src/main/assets/fonts/Feather.ttf +0 -0
- package/android/app/src/main/assets/fonts/FontAwesome.ttf +0 -0
- package/android/app/src/main/assets/fonts/FontAwesome5_Brands.ttf +0 -0
- package/android/app/src/main/assets/fonts/FontAwesome5_Regular.ttf +0 -0
- package/android/app/src/main/assets/fonts/FontAwesome5_Solid.ttf +0 -0
- package/android/app/src/main/assets/fonts/Foundation.ttf +0 -0
- package/android/app/src/main/assets/fonts/Ionicons.ttf +0 -0
- package/android/app/src/main/assets/fonts/MaterialCommunityIcons.ttf +0 -0
- package/android/app/src/main/assets/fonts/MaterialIcons.ttf +0 -0
- package/android/app/src/main/assets/fonts/Octicons.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-Black.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-BlackItalic.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-Bold.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-BoldItalic.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-Italic.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-Light.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-LightItalic.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-Medium.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-MediumItalic.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-Regular.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-Thin.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-ThinItalic.ttf +0 -0
- package/android/app/src/main/assets/fonts/SimpleLineIcons.ttf +0 -0
- package/android/app/src/main/assets/fonts/Zocial.ttf +0 -0
- package/android/app/src/main/java/com/hediarecommendationscreen/MainActivity.java +0 -0
- package/android/app/src/main/java/com/hediarecommendationscreen/MainApplication.java +0 -0
- package/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/android/app/src/main/res/values/color.xml +0 -0
- package/android/app/src/main/res/values/strings.xml +0 -0
- package/android/app/src/main/res/values/styles.xml +0 -0
- package/android/build.gradle +0 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -0
- package/android/gradle.properties +0 -0
- package/android/gradlew.bat +0 -0
- package/android/settings.gradle +0 -0
- package/app.json +0 -0
- package/assets/fonts/Roboto/LICENSE.txt +0 -0
- package/assets/fonts/Roboto/Roboto-Black.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-BlackItalic.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-Bold.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-BoldItalic.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-Italic.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-Light.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-LightItalic.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-Medium.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-MediumItalic.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-Regular.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-Thin.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-ThinItalic.ttf +0 -0
- package/babel.config.js +0 -0
- package/ignore-git.sh +1 -1
- package/ignore-publish.sh +2 -1
- package/index.d.ts +2 -2
- package/index.js +2 -3
- package/index.ts +2 -2
- package/ios/HediaRecommendationScreen/AppDelegate.h +0 -0
- package/ios/HediaRecommendationScreen/AppDelegate.m +0 -0
- package/ios/HediaRecommendationScreen/Base.lproj/LaunchScreen.xib +0 -0
- package/ios/HediaRecommendationScreen/Images.xcassets/AppIcon.appiconset/Contents.json +0 -0
- package/ios/HediaRecommendationScreen/Images.xcassets/Contents.json +0 -0
- package/ios/HediaRecommendationScreen/Info.plist +0 -0
- package/ios/HediaRecommendationScreen/main.m +0 -0
- package/ios/HediaRecommendationScreen-tvOS/Info.plist +0 -0
- package/ios/HediaRecommendationScreen-tvOSTests/Info.plist +0 -0
- package/ios/HediaRecommendationScreen.xcodeproj/project.pbxproj +0 -0
- package/ios/HediaRecommendationScreen.xcodeproj/xcshareddata/xcschemes/HediaRecommendationScreen-tvOS.xcscheme +0 -0
- package/ios/HediaRecommendationScreen.xcodeproj/xcshareddata/xcschemes/HediaRecommendationScreen.xcscheme +0 -0
- package/ios/HediaRecommendationScreen.xcworkspace/contents.xcworkspacedata +0 -0
- package/ios/HediaRecommendationScreen.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
- package/ios/HediaRecommendationScreenTests/HediaRecommendationScreenTests.m +0 -0
- package/ios/HediaRecommendationScreenTests/Info.plist +0 -0
- package/ios/Podfile +0 -0
- package/ios/Podfile.lock +0 -0
- package/jest.config.js +0 -0
- package/jest.mock.js +0 -0
- package/metro.config.js +0 -0
- package/package.json +8 -10
- package/react-native.config.js +0 -0
- package/src/RecommendationScreen.d.ts +18 -20
- package/src/RecommendationScreen.jsx +26 -15
- package/src/RecommendationScreen.tsx +60 -37
- package/src/__tests__/RecommendationScreen.test.d.ts +0 -0
- package/src/__tests__/RecommendationScreen.test.jsx +163 -138
- package/src/__tests__/RecommendationScreen.test.tsx +256 -159
- package/src/__tests__/RecommendationUtils.test.d.ts +0 -0
- package/src/__tests__/RecommendationUtils.test.js +30 -39
- package/src/__tests__/RecommendationUtils.test.ts +38 -43
- package/src/__tests__/Translate.test.d.ts +0 -0
- package/src/__tests__/Translate.test.jsx +13 -12
- package/src/__tests__/Translate.test.tsx +15 -14
- package/src/__tests__/Utils.test.d.ts +0 -0
- package/src/__tests__/Utils.test.js +22 -20
- package/src/__tests__/Utils.test.ts +32 -21
- package/src/__tests__/Validations.test.d.ts +0 -0
- package/src/__tests__/Validations.test.js +59 -33
- package/src/__tests__/Validations.test.ts +83 -41
- package/src/__tests__/components/Activity.test.d.ts +0 -0
- package/src/__tests__/components/Activity.test.jsx +39 -18
- package/src/__tests__/components/Activity.test.tsx +99 -45
- package/src/__tests__/components/Emotion.test.d.ts +0 -0
- package/src/__tests__/components/Emotion.test.jsx +34 -25
- package/src/__tests__/components/Emotion.test.tsx +41 -24
- package/src/__tests__/components/Header.test.d.ts +0 -0
- package/src/__tests__/components/Header.test.jsx +10 -9
- package/src/__tests__/components/Header.test.tsx +12 -11
- package/src/__tests__/components/InfoBars.test.d.ts +0 -0
- package/src/__tests__/components/InfoBars.test.jsx +1 -0
- package/src/__tests__/components/InfoBars.test.tsx +7 -6
- package/src/__tests__/components/InvisibleNumberInput.test.d.ts +0 -0
- package/src/__tests__/components/InvisibleNumberInput.test.jsx +40 -24
- package/src/__tests__/components/InvisibleNumberInput.test.tsx +41 -17
- package/src/__tests__/components/LimitationMessage.test.d.ts +0 -0
- package/src/__tests__/components/LimitationMessage.test.jsx +11 -30
- package/src/__tests__/components/LimitationMessage.test.tsx +15 -13
- package/src/__tests__/components/MoodIcon.test.d.ts +0 -0
- package/src/__tests__/components/MoodIcon.test.jsx +12 -8
- package/src/__tests__/components/MoodIcon.test.tsx +13 -5
- package/src/__tests__/components/RecommendationModal.test.d.ts +0 -0
- package/src/__tests__/components/RecommendationModal.test.jsx +22 -21
- package/src/__tests__/components/RecommendationModal.test.tsx +29 -27
- package/src/__tests__/components/RecommendedCarbs.test.d.ts +0 -0
- package/src/__tests__/components/RecommendedCarbs.test.jsx +7 -10
- package/src/__tests__/components/RecommendedCarbs.test.tsx +9 -10
- package/src/__tests__/components/RecommendedInsulin.test.d.ts +0 -0
- package/src/__tests__/components/RecommendedInsulin.test.jsx +57 -41
- package/src/__tests__/components/RecommendedInsulin.test.tsx +57 -31
- package/src/__tests__/components/Remeasure.test.d.ts +0 -0
- package/src/__tests__/components/Remeasure.test.jsx +7 -3
- package/src/__tests__/components/Remeasure.test.tsx +11 -3
- package/src/__tests__/components/TransferToLogbook.test.d.ts +0 -0
- package/src/__tests__/components/TransferToLogbook.test.jsx +2 -2
- package/src/__tests__/components/TransferToLogbook.test.tsx +2 -2
- package/src/__tests__/components/TwoOptionModal.test.d.ts +0 -0
- package/src/__tests__/components/TwoOptionModal.test.jsx +5 -4
- package/src/__tests__/components/TwoOptionModal.test.tsx +6 -4
- package/src/__tests__/utils.d.ts +7 -2
- package/src/__tests__/utils.jsx +59 -15
- package/src/__tests__/utils.tsx +63 -16
- package/src/assets/activity/Cyclist.png +0 -0
- package/src/assets/activity/Other.png +0 -0
- package/src/assets/activity/Runner.png +0 -0
- package/src/assets/activity/Swimmer.png +0 -0
- package/src/assets/activity/Walk.png +0 -0
- package/src/assets/mood/happy.png +0 -0
- package/src/assets/mood/happy_active.png +0 -0
- package/src/assets/mood/neutral.png +0 -0
- package/src/assets/mood/neutral_active.png +0 -0
- package/src/assets/mood/sad.png +0 -0
- package/src/assets/mood/sad_active.png +0 -0
- package/src/assets/mood/semi_happy.png +0 -0
- package/src/assets/mood/semi_happy_active.png +0 -0
- package/src/assets/mood/semi_sad.png +0 -0
- package/src/assets/mood/semi_sad_active.png +0 -0
- package/src/components/Header.d.ts +0 -0
- package/src/components/Header.jsx +2 -1
- package/src/components/Header.tsx +2 -1
- package/src/components/Icon.js +0 -0
- package/src/components/InfoBars.d.ts +1 -1
- package/src/components/InfoBars.jsx +0 -0
- package/src/components/InfoBars.tsx +1 -1
- package/src/components/InvisibleNumberInput.d.ts +2 -1
- package/src/components/InvisibleNumberInput.jsx +7 -2
- package/src/components/InvisibleNumberInput.tsx +10 -3
- package/src/components/LimitationMessage.d.ts +1 -1
- package/src/components/LimitationMessage.jsx +3 -2
- package/src/components/LimitationMessage.tsx +3 -1
- package/src/components/LineSeparator.d.ts +0 -0
- package/src/components/LineSeparator.jsx +0 -0
- package/src/components/LineSeparator.tsx +0 -0
- package/src/components/RecentInsulin.d.ts +0 -0
- package/src/components/RecentInsulin.jsx +3 -2
- package/src/components/RecentInsulin.tsx +3 -0
- package/src/components/RecommendationModal.d.ts +4 -4
- package/src/components/RecommendationModal.jsx +10 -9
- package/src/components/RecommendationModal.tsx +19 -8
- package/src/components/RecommendedCarbs.d.ts +4 -3
- package/src/components/RecommendedCarbs.jsx +12 -9
- package/src/components/RecommendedCarbs.tsx +31 -16
- package/src/components/RecommendedInsulin.d.ts +7 -7
- package/src/components/RecommendedInsulin.jsx +11 -7
- package/src/components/RecommendedInsulin.tsx +24 -12
- package/src/components/Remeasure.d.ts +2 -2
- package/src/components/Remeasure.jsx +7 -2
- package/src/components/Remeasure.tsx +10 -4
- package/src/components/TransferToLogbook.d.ts +0 -0
- package/src/components/TransferToLogbook.jsx +2 -1
- package/src/components/TransferToLogbook.tsx +2 -0
- package/src/components/TwoOptionModal.d.ts +5 -3
- package/src/components/TwoOptionModal.jsx +44 -13
- package/src/components/TwoOptionModal.tsx +50 -14
- package/src/components/activity/Activity.d.ts +2 -3
- package/src/components/activity/Activity.jsx +5 -2
- package/src/components/activity/Activity.tsx +7 -5
- package/src/components/activity/ActivityIcon.d.ts +1 -1
- package/src/components/activity/ActivityIcon.jsx +9 -8
- package/src/components/activity/ActivityIcon.tsx +12 -10
- package/src/components/activity/ActivityIntensity.d.ts +1 -1
- package/src/components/activity/ActivityIntensity.jsx +2 -8
- package/src/components/activity/ActivityIntensity.tsx +3 -12
- package/src/components/mood/Emotion.d.ts +5 -4
- package/src/components/mood/Emotion.jsx +4 -3
- package/src/components/mood/Emotion.tsx +9 -7
- package/src/components/mood/MoodIcon.d.ts +2 -2
- package/src/components/mood/MoodIcon.jsx +3 -2
- package/src/components/mood/MoodIcon.tsx +4 -2
- package/src/locale/CleanLanguage.ts +0 -0
- package/src/locale/da/messages.js +1 -1
- package/src/locale/da/messages.po +115 -107
- package/src/locale/de/messages.js +1 -1
- package/src/locale/de/messages.po +115 -107
- package/src/locale/en/messages.js +1 -1
- package/src/locale/en/messages.po +118 -110
- package/src/locale/es/messages.js +1 -1
- package/src/locale/es/messages.po +112 -104
- package/src/locale/fr/messages.js +1 -1
- package/src/locale/fr/messages.po +111 -103
- package/src/locale/i18nUtils.d.ts +3 -4
- package/src/locale/i18nUtils.js +13 -12
- package/src/locale/i18nUtils.ts +14 -14
- package/src/locale/it/messages.js +1 -1
- package/src/locale/it/messages.po +113 -105
- package/src/types/enum.d.ts +52 -44
- package/src/types/enum.js +67 -56
- package/src/types/enum.ts +58 -34
- package/src/types/types.d.ts +9 -23
- package/src/types/types.js +0 -0
- package/src/types/types.ts +9 -25
- package/src/utils/AttentionMessages.d.ts +1 -4
- package/src/utils/AttentionMessages.jsx +8 -30
- package/src/utils/AttentionMessages.tsx +11 -16
- package/src/utils/Constants.d.ts +0 -0
- package/src/utils/Constants.js +0 -0
- package/src/utils/Constants.ts +0 -0
- package/src/utils/RecommendationError.d.ts +2 -0
- package/src/utils/RecommendationError.jsx +45 -40
- package/src/utils/RecommendationError.tsx +17 -4
- package/src/utils/RecommendationUtils.d.ts +7 -8
- package/src/utils/RecommendationUtils.js +15 -7
- package/src/utils/RecommendationUtils.ts +24 -14
- package/src/utils/Translations.d.ts +2 -0
- package/src/utils/Translations.js +10 -0
- package/src/utils/Translations.ts +9 -0
- package/src/utils/Utils.d.ts +4 -5
- package/src/utils/Utils.js +6 -5
- package/src/utils/Utils.ts +10 -8
- package/src/utils/Validations.d.ts +10 -9
- package/src/utils/Validations.js +61 -65
- package/src/utils/Validations.ts +76 -81
- package/tsconfig.json +2 -2
- package/tslint.json +0 -0
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { BolusCalculator } from "@hedia/types";
|
|
2
2
|
import { t } from "@lingui/macro";
|
|
3
3
|
import { i18n } from "../locale/i18nUtils";
|
|
4
4
|
import { RecommendationErrorEnum } from "../types/enum";
|
|
5
5
|
|
|
6
|
+
const SAFETY_INSULIN_LIMIT = BolusCalculator.Constants.SAFETY_INSULIN_LIMIT;
|
|
7
|
+
|
|
6
8
|
export class RecommendationError extends Error {
|
|
7
9
|
public readonly type: RecommendationErrorEnum;
|
|
8
10
|
|
|
@@ -72,6 +74,13 @@ export const CurrentBGLError = (): RecommendationError =>
|
|
|
72
74
|
i18n._(t`Error. Hedia Calculator does not support your current blood glucose level.`),
|
|
73
75
|
RecommendationErrorEnum.CurrentBGL,
|
|
74
76
|
);
|
|
77
|
+
export const LatestLogbook6HoursBGLError = (): RecommendationError =>
|
|
78
|
+
new RecommendationError(
|
|
79
|
+
i18n._(
|
|
80
|
+
t`Error. Hedia Calculator does not support the blood glucose level of your latest logbook entry from the last 6 hours.`,
|
|
81
|
+
),
|
|
82
|
+
RecommendationErrorEnum.LatestLogbook6HoursBGL,
|
|
83
|
+
);
|
|
75
84
|
export const CurrentBKLError = (): RecommendationError =>
|
|
76
85
|
new RecommendationError(
|
|
77
86
|
i18n._(t`Error. Hedia Calculator does not support your current blood ketone level.`),
|
|
@@ -86,9 +95,7 @@ export const TargetBGLError = (): RecommendationError =>
|
|
|
86
95
|
|
|
87
96
|
export const BolusInsulinDoseError = (): RecommendationError =>
|
|
88
97
|
new RecommendationError(
|
|
89
|
-
i18n._(
|
|
90
|
-
t`Error. Hedia Calculator does not support an insulin dose greater than ${Calculator.SAFETY_INSULIN_LIMIT} units`,
|
|
91
|
-
),
|
|
98
|
+
i18n._(t`Error. Hedia Calculator does not support an insulin dose greater than ${SAFETY_INSULIN_LIMIT} units`),
|
|
92
99
|
RecommendationErrorEnum.BolusInsulinDose,
|
|
93
100
|
);
|
|
94
101
|
|
|
@@ -98,6 +105,12 @@ export const BolusInsulinSecondsPassedError = (): RecommendationError =>
|
|
|
98
105
|
RecommendationErrorEnum.BolusInsulinSecondsPassed,
|
|
99
106
|
);
|
|
100
107
|
|
|
108
|
+
export const RecentBolusError = (): RecommendationError =>
|
|
109
|
+
new RecommendationError(
|
|
110
|
+
i18n._(t`Error. Hedia Calculator could not find your recent boluses`),
|
|
111
|
+
RecommendationErrorEnum.RecentBolus,
|
|
112
|
+
);
|
|
113
|
+
|
|
101
114
|
export const UserReminderError = (): RecommendationError =>
|
|
102
115
|
new RecommendationError(
|
|
103
116
|
i18n._(t`Error. Please verify your notifications settings.`),
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { IActivityParams } from "@hedia/recommendation-calculator/src/RecommendationCalculator";
|
|
2
1
|
import { BgLevel } from "../types/enum";
|
|
3
|
-
import { logbookEntry } from "../types/types";
|
|
2
|
+
import { IActivityParams, logbookEntry } from "../types/types";
|
|
4
3
|
import { AttentionMessage, Messages } from "./AttentionMessages";
|
|
5
|
-
export declare function getBGLevel(currentBGL: number, latestLogbookFrom6Hours: logbookEntry): BgLevel;
|
|
6
|
-
export declare function getReminder(bgLevel: BgLevel, carbohydrates: number, userReminder: number, activity: IActivityParams): number;
|
|
7
|
-
export declare function getAttentionMessage(bgLevel: BgLevel, activity: IActivityParams): AttentionMessage;
|
|
8
|
-
export declare function isSevereHyperglycemia(
|
|
9
|
-
export declare function isActivityWithin15Minutes(activity: IActivityParams): boolean;
|
|
10
|
-
export declare function getLimitationMessage(wasLimited: boolean, activityReduction: number): Messages;
|
|
4
|
+
export declare function getBGLevel(currentBGL: number, latestLogbookFrom6Hours: logbookEntry | null): BgLevel;
|
|
5
|
+
export declare function getReminder(bgLevel: BgLevel, carbohydrates: number, userReminder: number, activity: IActivityParams | null): number;
|
|
6
|
+
export declare function getAttentionMessage(bgLevel: BgLevel, activity: IActivityParams | null): AttentionMessage | null;
|
|
7
|
+
export declare function isSevereHyperglycemia(logbook?: logbookEntry | null): boolean;
|
|
8
|
+
export declare function isActivityWithin15Minutes(activity: IActivityParams | null): boolean;
|
|
9
|
+
export declare function getLimitationMessage(wasLimited: boolean, activityReduction: number | null): Messages | null;
|
|
@@ -31,7 +31,9 @@ function getBGLevel(currentBGL, latestLogbookFrom6Hours) {
|
|
|
31
31
|
if (currentBGL > 7 && currentBGL < 15) {
|
|
32
32
|
return enum_1.BgLevel.MildHyperglycemia;
|
|
33
33
|
}
|
|
34
|
-
if (currentBGL > 15 && currentBGL <= 33.3 &&
|
|
34
|
+
if (currentBGL > 15 && currentBGL <= 33.3 && latestLogbookFrom6Hours
|
|
35
|
+
? isSevereHyperglycemia(latestLogbookFrom6Hours)
|
|
36
|
+
: false) {
|
|
35
37
|
return enum_1.BgLevel.SevereHyperglycemia;
|
|
36
38
|
}
|
|
37
39
|
if (currentBGL >= 15 && currentBGL <= 33.3) {
|
|
@@ -67,9 +69,9 @@ function getAttentionMessage(bgLevel, activity) {
|
|
|
67
69
|
case enum_1.BgLevel.BGLevelNotProvided:
|
|
68
70
|
case enum_1.BgLevel.Normoglycemia:
|
|
69
71
|
case enum_1.BgLevel.MildHyperglycemia:
|
|
70
|
-
return
|
|
72
|
+
return null;
|
|
71
73
|
case enum_1.BgLevel.NormoglycemiaUnder5MMOL:
|
|
72
|
-
return isActivityWithin15Minutes(activity) ? AttentionMessages_1.AttentionMessage.NormoglycemiaActivityUnder5MMOL() :
|
|
74
|
+
return isActivityWithin15Minutes(activity) ? AttentionMessages_1.AttentionMessage.NormoglycemiaActivityUnder5MMOL() : null;
|
|
73
75
|
case enum_1.BgLevel.SevereHypoglycemia:
|
|
74
76
|
case enum_1.BgLevel.Hypoglycemia:
|
|
75
77
|
case enum_1.BgLevel.MildHypoglycemia:
|
|
@@ -77,7 +79,7 @@ function getAttentionMessage(bgLevel, activity) {
|
|
|
77
79
|
? AttentionMessages_1.addPostponeActivityMessageUnder5MMOL(AttentionMessages_1.AttentionMessage[enum_1.BgLevel[bgLevel]]())
|
|
78
80
|
: AttentionMessages_1.AttentionMessage[enum_1.BgLevel[bgLevel]]();
|
|
79
81
|
case enum_1.BgLevel.Hyperglycemia:
|
|
80
|
-
return isActivityWithin15Minutes(activity) ? AttentionMessages_1.AttentionMessage.HyperglycemiaActivity() :
|
|
82
|
+
return isActivityWithin15Minutes(activity) ? AttentionMessages_1.AttentionMessage.HyperglycemiaActivity() : null;
|
|
81
83
|
case enum_1.BgLevel.SevereHyperglycemia:
|
|
82
84
|
return isActivityWithin15Minutes(activity)
|
|
83
85
|
? AttentionMessages_1.AttentionMessage.SevereHyperglycemiaActivity()
|
|
@@ -87,8 +89,14 @@ function getAttentionMessage(bgLevel, activity) {
|
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
exports.getAttentionMessage = getAttentionMessage;
|
|
90
|
-
function isSevereHyperglycemia(
|
|
91
|
-
|
|
92
|
+
function isSevereHyperglycemia(logbook) {
|
|
93
|
+
if (logbook !== null && logbook !== undefined) {
|
|
94
|
+
const { blood_glucose_millimolar } = logbook;
|
|
95
|
+
if (blood_glucose_millimolar !== null) {
|
|
96
|
+
return blood_glucose_millimolar > Constants_1.SEVERE_HYPERGLYCEMIA_START_MMOL;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return false;
|
|
92
100
|
}
|
|
93
101
|
exports.isSevereHyperglycemia = isSevereHyperglycemia;
|
|
94
102
|
function isActivityWithin15Minutes(activity) {
|
|
@@ -102,6 +110,6 @@ function getLimitationMessage(wasLimited, activityReduction) {
|
|
|
102
110
|
const message = activityReduction
|
|
103
111
|
? AttentionMessages_1.Messages.RecommendationWasLimitedActivity(activityReduction)
|
|
104
112
|
: AttentionMessages_1.Messages.RecommendationWasLimited();
|
|
105
|
-
return wasLimited ? message :
|
|
113
|
+
return wasLimited ? message : null;
|
|
106
114
|
}
|
|
107
115
|
exports.getLimitationMessage = getLimitationMessage;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { IActivityParams } from "@hedia/recommendation-calculator/src/RecommendationCalculator";
|
|
2
1
|
import moment from "moment";
|
|
3
2
|
import { BgLevel, RecommendationReminders } from "../types/enum";
|
|
4
|
-
import { logbookEntry } from "../types/types";
|
|
3
|
+
import { IActivityParams, logbookEntry } from "../types/types";
|
|
5
4
|
import { addPostponeActivityMessageUnder5MMOL, AttentionMessage, Messages } from "./AttentionMessages";
|
|
6
5
|
import { SEVERE_HYPERGLYCEMIA_START_MMOL } from "./Constants";
|
|
7
6
|
import { CurrentBGLError } from "./RecommendationError";
|
|
8
7
|
|
|
9
|
-
export function getBGLevel(currentBGL: number, latestLogbookFrom6Hours: logbookEntry): BgLevel {
|
|
8
|
+
export function getBGLevel(currentBGL: number, latestLogbookFrom6Hours: logbookEntry | null): BgLevel {
|
|
10
9
|
if (currentBGL === null) {
|
|
11
10
|
return BgLevel.BGLevelNotProvided;
|
|
12
11
|
}
|
|
@@ -28,7 +27,11 @@ export function getBGLevel(currentBGL: number, latestLogbookFrom6Hours: logbookE
|
|
|
28
27
|
if (currentBGL > 7 && currentBGL < 15) {
|
|
29
28
|
return BgLevel.MildHyperglycemia;
|
|
30
29
|
}
|
|
31
|
-
if (
|
|
30
|
+
if (
|
|
31
|
+
currentBGL > 15 && currentBGL <= 33.3 && latestLogbookFrom6Hours
|
|
32
|
+
? isSevereHyperglycemia(latestLogbookFrom6Hours)
|
|
33
|
+
: false
|
|
34
|
+
) {
|
|
32
35
|
return BgLevel.SevereHyperglycemia;
|
|
33
36
|
}
|
|
34
37
|
if (currentBGL >= 15 && currentBGL <= 33.3) {
|
|
@@ -41,7 +44,7 @@ export function getReminder(
|
|
|
41
44
|
bgLevel: BgLevel,
|
|
42
45
|
carbohydrates: number,
|
|
43
46
|
userReminder: number,
|
|
44
|
-
activity: IActivityParams,
|
|
47
|
+
activity: IActivityParams | null,
|
|
45
48
|
): number {
|
|
46
49
|
const reminder = userReminder === undefined ? RecommendationReminders.HediaReminderDefault : userReminder;
|
|
47
50
|
switch (bgLevel) {
|
|
@@ -67,15 +70,15 @@ export function getReminder(
|
|
|
67
70
|
}
|
|
68
71
|
}
|
|
69
72
|
|
|
70
|
-
export function getAttentionMessage(bgLevel: BgLevel, activity: IActivityParams): AttentionMessage {
|
|
73
|
+
export function getAttentionMessage(bgLevel: BgLevel, activity: IActivityParams | null): AttentionMessage | null {
|
|
71
74
|
switch (bgLevel) {
|
|
72
75
|
case BgLevel.BGLevelNotProvided:
|
|
73
76
|
case BgLevel.Normoglycemia:
|
|
74
77
|
case BgLevel.MildHyperglycemia:
|
|
75
|
-
return
|
|
78
|
+
return null;
|
|
76
79
|
|
|
77
80
|
case BgLevel.NormoglycemiaUnder5MMOL:
|
|
78
|
-
return isActivityWithin15Minutes(activity) ? AttentionMessage.NormoglycemiaActivityUnder5MMOL() :
|
|
81
|
+
return isActivityWithin15Minutes(activity) ? AttentionMessage.NormoglycemiaActivityUnder5MMOL() : null;
|
|
79
82
|
|
|
80
83
|
case BgLevel.SevereHypoglycemia:
|
|
81
84
|
case BgLevel.Hypoglycemia:
|
|
@@ -85,7 +88,7 @@ export function getAttentionMessage(bgLevel: BgLevel, activity: IActivityParams)
|
|
|
85
88
|
: AttentionMessage[BgLevel[bgLevel]]();
|
|
86
89
|
|
|
87
90
|
case BgLevel.Hyperglycemia:
|
|
88
|
-
return isActivityWithin15Minutes(activity) ? AttentionMessage.HyperglycemiaActivity() :
|
|
91
|
+
return isActivityWithin15Minutes(activity) ? AttentionMessage.HyperglycemiaActivity() : null;
|
|
89
92
|
|
|
90
93
|
case BgLevel.SevereHyperglycemia:
|
|
91
94
|
return isActivityWithin15Minutes(activity)
|
|
@@ -96,20 +99,27 @@ export function getAttentionMessage(bgLevel: BgLevel, activity: IActivityParams)
|
|
|
96
99
|
}
|
|
97
100
|
}
|
|
98
101
|
|
|
99
|
-
export function isSevereHyperglycemia(
|
|
100
|
-
|
|
102
|
+
export function isSevereHyperglycemia(logbook?: logbookEntry | null): boolean {
|
|
103
|
+
if (logbook !== null && logbook !== undefined) {
|
|
104
|
+
const { blood_glucose_millimolar } = logbook;
|
|
105
|
+
if (blood_glucose_millimolar !== null) {
|
|
106
|
+
return blood_glucose_millimolar > SEVERE_HYPERGLYCEMIA_START_MMOL;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return false;
|
|
101
111
|
}
|
|
102
112
|
|
|
103
|
-
export function isActivityWithin15Minutes(activity: IActivityParams): boolean {
|
|
113
|
+
export function isActivityWithin15Minutes(activity: IActivityParams | null): boolean {
|
|
104
114
|
const minutes = activity?.activityDuration;
|
|
105
115
|
return moment
|
|
106
116
|
.utc(activity?.activityDate)
|
|
107
117
|
.isBetween(moment.utc().subtract(minutes, `minutes`), moment.utc().add(15, `minutes`));
|
|
108
118
|
}
|
|
109
119
|
|
|
110
|
-
export function getLimitationMessage(wasLimited: boolean, activityReduction: number): Messages {
|
|
120
|
+
export function getLimitationMessage(wasLimited: boolean, activityReduction: number | null): Messages | null {
|
|
111
121
|
const message = activityReduction
|
|
112
122
|
? Messages.RecommendationWasLimitedActivity(activityReduction)
|
|
113
123
|
: Messages.RecommendationWasLimited();
|
|
114
|
-
return wasLimited ? message :
|
|
124
|
+
return wasLimited ? message : null;
|
|
115
125
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ActivityIntensityTranslations = void 0;
|
|
4
|
+
const macro_1 = require("@lingui/macro");
|
|
5
|
+
const i18nUtils_1 = require("../locale/i18nUtils");
|
|
6
|
+
exports.ActivityIntensityTranslations = {
|
|
7
|
+
light: () => i18nUtils_1.i18n._(macro_1.t `Light`),
|
|
8
|
+
moderate: () => i18nUtils_1.i18n._(macro_1.t `Moderate`),
|
|
9
|
+
hard: () => i18nUtils_1.i18n._(macro_1.t `Hard`),
|
|
10
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Activity } from "@hedia/types";
|
|
2
|
+
import { t } from "@lingui/macro";
|
|
3
|
+
import { i18n } from "../locale/i18nUtils";
|
|
4
|
+
|
|
5
|
+
export const ActivityIntensityTranslations: Record<Activity.Enums.ActivityIntensity, () => string> = {
|
|
6
|
+
light: (): string => i18n._(t`Light`),
|
|
7
|
+
moderate: (): string => i18n._(t`Moderate`),
|
|
8
|
+
hard: (): string => i18n._(t`Hard`),
|
|
9
|
+
};
|
package/src/utils/Utils.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { BloodGlucoseUnit, BloodKetonesUnit } from "@hedia/types";
|
|
2
|
-
import { InjectionMethod } from "../types/enum";
|
|
1
|
+
import { BloodGlucoseUnit, BloodKetonesUnit, UserSettings } from "@hedia/types";
|
|
3
2
|
import { IInterval } from "../types/types";
|
|
4
3
|
export declare class Utils {
|
|
5
|
-
static getRounding(method: InjectionMethod): number;
|
|
6
|
-
static roundValue(value: number, injectMethod: InjectionMethod): number;
|
|
7
|
-
static
|
|
4
|
+
static getRounding(method: UserSettings.Enums.InjectionMethod): number;
|
|
5
|
+
static roundValue(value: number, injectMethod: UserSettings.Enums.InjectionMethod): number;
|
|
6
|
+
static isInRange(value: number | null, interval: IInterval): boolean;
|
|
8
7
|
static convertBGLToMGDL(value: number): number;
|
|
9
8
|
static displayedBGLValue(value: number, unit: BloodGlucoseUnit): number;
|
|
10
9
|
static convertBKLToMGDL(value: number): number;
|
package/src/utils/Utils.js
CHANGED
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Utils = void 0;
|
|
4
4
|
const types_1 = require("@hedia/types");
|
|
5
|
-
const enum_1 = require("../types/enum");
|
|
6
5
|
const Constants_1 = require("./Constants");
|
|
6
|
+
const InjectionMethod = types_1.UserSettings.Enums.InjectionMethod;
|
|
7
|
+
const { PenHalf, PenWhole, Pump } = InjectionMethod;
|
|
7
8
|
class Utils {
|
|
8
9
|
static getRounding(method) {
|
|
9
10
|
switch (method) {
|
|
10
|
-
case
|
|
11
|
+
case PenWhole:
|
|
11
12
|
return 1;
|
|
12
|
-
case
|
|
13
|
+
case PenHalf:
|
|
13
14
|
return 2;
|
|
14
|
-
case
|
|
15
|
+
case Pump:
|
|
15
16
|
return 10;
|
|
16
17
|
default:
|
|
17
18
|
throw Error(`Unsupported InjectionMethod: ${method}`);
|
|
@@ -21,7 +22,7 @@ class Utils {
|
|
|
21
22
|
const rounding = Utils.getRounding(injectMethod);
|
|
22
23
|
return Math.round(value * rounding) / rounding;
|
|
23
24
|
}
|
|
24
|
-
static
|
|
25
|
+
static isInRange(value, interval) {
|
|
25
26
|
if (value === null) {
|
|
26
27
|
return false;
|
|
27
28
|
}
|
package/src/utils/Utils.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { BloodGlucoseUnit, BloodKetonesUnit } from "@hedia/types";
|
|
2
|
-
import { InjectionMethod } from "../types/enum";
|
|
1
|
+
import { BloodGlucoseUnit, BloodKetonesUnit, UserSettings } from "@hedia/types";
|
|
3
2
|
import { IInterval } from "../types/types";
|
|
4
3
|
import { MGDL_PER_MMOLL_BGL, MGDL_PER_MMOLL_BKL } from "./Constants";
|
|
5
4
|
|
|
5
|
+
const InjectionMethod = UserSettings.Enums.InjectionMethod;
|
|
6
|
+
const { PenHalf, PenWhole, Pump } = InjectionMethod;
|
|
7
|
+
|
|
6
8
|
export class Utils {
|
|
7
|
-
public static getRounding(method: InjectionMethod): number {
|
|
9
|
+
public static getRounding(method: UserSettings.Enums.InjectionMethod): number {
|
|
8
10
|
switch (method) {
|
|
9
|
-
case
|
|
11
|
+
case PenWhole:
|
|
10
12
|
return 1;
|
|
11
13
|
|
|
12
|
-
case
|
|
14
|
+
case PenHalf:
|
|
13
15
|
return 2;
|
|
14
16
|
|
|
15
|
-
case
|
|
17
|
+
case Pump:
|
|
16
18
|
return 10;
|
|
17
19
|
|
|
18
20
|
default:
|
|
@@ -20,12 +22,12 @@ export class Utils {
|
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
public static roundValue(value: number, injectMethod: InjectionMethod): number {
|
|
25
|
+
public static roundValue(value: number, injectMethod: UserSettings.Enums.InjectionMethod): number {
|
|
24
26
|
const rounding: number = Utils.getRounding(injectMethod);
|
|
25
27
|
return Math.round(value * rounding) / rounding;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
public static
|
|
30
|
+
public static isInRange(value: number | null, interval: IInterval): boolean {
|
|
29
31
|
if (value === null) {
|
|
30
32
|
return false;
|
|
31
33
|
}
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BloodGlucoseUnit, BloodKetonesUnit } from "@hedia/types";
|
|
1
|
+
import { Activity, BloodGlucoseUnit, BloodKetonesUnit, Languages, UserSettings } from "@hedia/types";
|
|
3
2
|
import { IRecommendationProps } from "../RecommendationScreen";
|
|
4
|
-
import {
|
|
3
|
+
import { ActivitySettings, IActivityParams, IRecentBolus, logbookEntry } from "../types/types";
|
|
5
4
|
export declare function validateParams(props: IRecommendationProps): void;
|
|
6
|
-
export declare function checkLanguage(language:
|
|
7
|
-
export declare function
|
|
5
|
+
export declare function checkLanguage(language: Languages): void;
|
|
6
|
+
export declare function checkLatestLogbook6Hours(logbook: logbookEntry | null): void;
|
|
7
|
+
export declare function checkInjectionMethod(injectionMethod: UserSettings.Enums.InjectionMethod): void;
|
|
8
8
|
export declare function checkBGLUnit(unit: BloodGlucoseUnit): void;
|
|
9
9
|
export declare function checkBKLUnit(unit: BloodKetonesUnit): void;
|
|
10
10
|
export declare function checkUserReminder(userReminder: number): void;
|
|
11
|
-
export declare function checkActivity(activity: IActivityParams): void;
|
|
11
|
+
export declare function checkActivity(activity: IActivityParams | null): void;
|
|
12
|
+
export declare function checkRecentBolus(recentBoluses: Array<IRecentBolus>): void;
|
|
12
13
|
export declare function checkRecentBolusesInsulinDose(recentBoluses: Array<IRecentBolus>): void;
|
|
13
14
|
export declare function checkRecentBolusesSecondsPassed(recentBoluses: Array<IRecentBolus>): void;
|
|
14
15
|
export declare function checkActivityDuration(activityDuration: number): void;
|
|
15
|
-
export declare function checkActivityIntensity(activityIntensity: ActivityIntensity): void;
|
|
16
|
-
export declare function checkActivityType(activityType: ActivityEnum): void;
|
|
16
|
+
export declare function checkActivityIntensity(activityIntensity: Activity.Enums.ActivityIntensity): void;
|
|
17
|
+
export declare function checkActivityType(activityType: Activity.Enums.ActivityEnum | null): void;
|
|
17
18
|
export declare function checkActivityDate(activity: IActivityParams): void;
|
|
18
|
-
export declare function checkActivitySettings(activitySettings:
|
|
19
|
+
export declare function checkActivitySettings(activitySettings: ActivitySettings): void;
|
|
19
20
|
export declare function checkActivityTargetBGL(activitySettingsTargetBGL: number): void;
|
|
20
21
|
export declare function checkCurrentBGL(currentBGL: number): void;
|
|
21
22
|
export declare function checkTargetBGL(targetBGL: number): void;
|
package/src/utils/Validations.js
CHANGED
|
@@ -3,14 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.checkCarbohydrates = exports.checkInsulinToCarbRatio = exports.checkInsulinSensitivity = exports.checkBloodKetoneLevel = exports.checkTargetBGL = exports.checkCurrentBGL = exports.checkActivityTargetBGL = exports.checkActivitySettings = exports.checkActivityDate = exports.checkActivityType = exports.checkActivityIntensity = exports.checkActivityDuration = exports.checkRecentBolusesSecondsPassed = exports.checkRecentBolusesInsulinDose = exports.checkActivity = exports.checkUserReminder = exports.checkBKLUnit = exports.checkBGLUnit = exports.checkInjectionMethod = exports.checkLanguage = exports.validateParams = void 0;
|
|
7
|
-
const RecommendationCalculator_1 = require("@hedia/recommendation-calculator/src/RecommendationCalculator");
|
|
6
|
+
exports.checkCarbohydrates = exports.checkInsulinToCarbRatio = exports.checkInsulinSensitivity = exports.checkBloodKetoneLevel = exports.checkTargetBGL = exports.checkCurrentBGL = exports.checkActivityTargetBGL = exports.checkActivitySettings = exports.checkActivityDate = exports.checkActivityType = exports.checkActivityIntensity = exports.checkActivityDuration = exports.checkRecentBolusesSecondsPassed = exports.checkRecentBolusesInsulinDose = exports.checkRecentBolus = exports.checkActivity = exports.checkUserReminder = exports.checkBKLUnit = exports.checkBGLUnit = exports.checkInjectionMethod = exports.checkLatestLogbook6Hours = exports.checkLanguage = exports.validateParams = void 0;
|
|
8
7
|
const types_1 = require("@hedia/types");
|
|
9
8
|
const moment_1 = __importDefault(require("moment"));
|
|
10
|
-
const enum_1 = require("../types/enum");
|
|
11
9
|
const Constants_1 = require("./Constants");
|
|
12
10
|
const RecommendationError_1 = require("./RecommendationError");
|
|
13
11
|
const Utils_1 = require("./Utils");
|
|
12
|
+
const { hard } = types_1.Activity.Enums.ActivityIntensity;
|
|
13
|
+
const { fromFortysix } = types_1.Activity.Enums.ActivityReductionIntervals;
|
|
14
14
|
function validateParams(props) {
|
|
15
15
|
checkCalculatorParams(props.calculatorParams);
|
|
16
16
|
checkBGLUnit(props.bloodGlucoseUnit);
|
|
@@ -19,50 +19,52 @@ function validateParams(props) {
|
|
|
19
19
|
checkInjectionMethod(props.injectionMethod);
|
|
20
20
|
checkUserReminder(props.userReminder);
|
|
21
21
|
checkLanguage(props.language);
|
|
22
|
+
checkLatestLogbook6Hours(props.latestLogbookFrom6Hours);
|
|
22
23
|
if (props?.calculatorParams?.activity && props?.activityDisplayProps) {
|
|
23
24
|
checkActivityType(props.activityDisplayProps.activityType);
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
exports.validateParams = validateParams;
|
|
27
28
|
function checkLanguage(language) {
|
|
28
|
-
if (!Object.values(
|
|
29
|
+
if (!Object.values(types_1.Languages).includes(language)) {
|
|
29
30
|
throw RecommendationError_1.LanguageError();
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
exports.checkLanguage = checkLanguage;
|
|
34
|
+
function checkLatestLogbook6Hours(logbook) {
|
|
35
|
+
if (logbook === undefined) {
|
|
36
|
+
throw RecommendationError_1.LatestLogbook6HoursBGLError();
|
|
37
|
+
}
|
|
38
|
+
if (logbook !== null) {
|
|
39
|
+
if (!Utils_1.Utils.isInRange(logbook.blood_glucose_millimolar, Constants_1.CURRENT_BGL_MMOL_LIMITS)) {
|
|
40
|
+
throw RecommendationError_1.LatestLogbook6HoursBGLError();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.checkLatestLogbook6Hours = checkLatestLogbook6Hours;
|
|
33
45
|
function checkInjectionMethod(injectionMethod) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
case enum_1.InjectionMethod.Pump:
|
|
38
|
-
break;
|
|
39
|
-
default:
|
|
40
|
-
throw RecommendationError_1.InjectionMethodError();
|
|
46
|
+
const check = Object.values(types_1.UserSettings.Enums.InjectionMethod).some((method) => method === injectionMethod);
|
|
47
|
+
if (!check) {
|
|
48
|
+
throw RecommendationError_1.InjectionMethodError();
|
|
41
49
|
}
|
|
42
50
|
}
|
|
43
51
|
exports.checkInjectionMethod = checkInjectionMethod;
|
|
44
52
|
function checkBGLUnit(unit) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
break;
|
|
49
|
-
default:
|
|
50
|
-
throw RecommendationError_1.BloodGlucoseUnitError();
|
|
53
|
+
const check = Object.values(types_1.BloodGlucoseUnit).some((enumUnit) => enumUnit === unit);
|
|
54
|
+
if (!check) {
|
|
55
|
+
throw RecommendationError_1.BloodGlucoseUnitError();
|
|
51
56
|
}
|
|
52
57
|
}
|
|
53
58
|
exports.checkBGLUnit = checkBGLUnit;
|
|
54
59
|
function checkBKLUnit(unit) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
break;
|
|
59
|
-
default:
|
|
60
|
-
throw RecommendationError_1.BloodKetoneUnitError();
|
|
60
|
+
const check = Object.values(types_1.BloodKetonesUnit).some((enumUnit) => enumUnit === unit);
|
|
61
|
+
if (!check) {
|
|
62
|
+
throw RecommendationError_1.BloodKetoneUnitError();
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
65
|
exports.checkBKLUnit = checkBKLUnit;
|
|
64
66
|
function checkUserReminder(userReminder) {
|
|
65
|
-
if (!Utils_1.Utils.
|
|
67
|
+
if (!Utils_1.Utils.isInRange(userReminder, Constants_1.REMINDER_HOURS_LIMITS)) {
|
|
66
68
|
throw RecommendationError_1.UserReminderError();
|
|
67
69
|
}
|
|
68
70
|
}
|
|
@@ -74,6 +76,7 @@ function checkCalculatorParams(calculatorParams) {
|
|
|
74
76
|
checkTargetBGL(calculatorParams.targetBGL);
|
|
75
77
|
checkInsulinToCarbRatio(calculatorParams.carbohydrateRatio);
|
|
76
78
|
checkInsulinSensitivity(calculatorParams.insulinSensitivity);
|
|
79
|
+
checkRecentBolus(calculatorParams.recentBoluses);
|
|
77
80
|
checkRecentBolusesInsulinDose(calculatorParams.recentBoluses);
|
|
78
81
|
checkRecentBolusesSecondsPassed(calculatorParams.recentBoluses);
|
|
79
82
|
}
|
|
@@ -87,53 +90,45 @@ function checkActivity(activity) {
|
|
|
87
90
|
}
|
|
88
91
|
}
|
|
89
92
|
exports.checkActivity = checkActivity;
|
|
90
|
-
function
|
|
91
|
-
if (recentBoluses
|
|
92
|
-
|
|
93
|
-
if (!Utils_1.Utils.isInClosedInterval(bolus.insulinDose, Constants_1.INSULIN_DOSE_LIMITS)) {
|
|
94
|
-
throw RecommendationError_1.BolusInsulinDoseError();
|
|
95
|
-
}
|
|
96
|
-
});
|
|
93
|
+
function checkRecentBolus(recentBoluses) {
|
|
94
|
+
if (recentBoluses === null || recentBoluses === undefined) {
|
|
95
|
+
throw RecommendationError_1.RecentBolusError();
|
|
97
96
|
}
|
|
98
97
|
}
|
|
98
|
+
exports.checkRecentBolus = checkRecentBolus;
|
|
99
|
+
function checkRecentBolusesInsulinDose(recentBoluses) {
|
|
100
|
+
recentBoluses.forEach((bolus) => {
|
|
101
|
+
if (!Utils_1.Utils.isInRange(bolus.insulinDose, Constants_1.INSULIN_DOSE_LIMITS)) {
|
|
102
|
+
throw RecommendationError_1.BolusInsulinDoseError();
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
99
106
|
exports.checkRecentBolusesInsulinDose = checkRecentBolusesInsulinDose;
|
|
100
107
|
function checkRecentBolusesSecondsPassed(recentBoluses) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
+
recentBoluses.forEach((bolus) => {
|
|
109
|
+
if (!Utils_1.Utils.isInRange(bolus.secondsPassed, Constants_1.BOLUS_SECONDS_PASSED_LIMITS)) {
|
|
110
|
+
throw RecommendationError_1.BolusInsulinSecondsPassedError();
|
|
111
|
+
}
|
|
112
|
+
});
|
|
108
113
|
}
|
|
109
114
|
exports.checkRecentBolusesSecondsPassed = checkRecentBolusesSecondsPassed;
|
|
110
115
|
function checkActivityDuration(activityDuration) {
|
|
111
|
-
if (!Utils_1.Utils.
|
|
116
|
+
if (!Utils_1.Utils.isInRange(activityDuration, Constants_1.ACTIVITY_DURATION_MINUTES_LIMITS)) {
|
|
112
117
|
throw RecommendationError_1.ActivityDurationError();
|
|
113
118
|
}
|
|
114
119
|
}
|
|
115
120
|
exports.checkActivityDuration = checkActivityDuration;
|
|
116
121
|
function checkActivityIntensity(activityIntensity) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
case RecommendationCalculator_1.ActivityIntensity.Light:
|
|
121
|
-
break;
|
|
122
|
-
default:
|
|
123
|
-
throw RecommendationError_1.ActivityIntensityError();
|
|
122
|
+
const check = Object.values(types_1.Activity.Enums.ActivityIntensity).some((method) => method === activityIntensity);
|
|
123
|
+
if (!check) {
|
|
124
|
+
throw RecommendationError_1.ActivityIntensityError();
|
|
124
125
|
}
|
|
125
126
|
}
|
|
126
127
|
exports.checkActivityIntensity = checkActivityIntensity;
|
|
127
128
|
function checkActivityType(activityType) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
case enum_1.ActivityEnum.Run:
|
|
132
|
-
case enum_1.ActivityEnum.Swim:
|
|
133
|
-
case enum_1.ActivityEnum.Walk:
|
|
134
|
-
break;
|
|
135
|
-
default:
|
|
136
|
-
throw RecommendationError_1.ActivityTypeError();
|
|
129
|
+
const check = Object.values(types_1.Activity.Enums.ActivityEnum).some((method) => method === activityType);
|
|
130
|
+
if (!check) {
|
|
131
|
+
throw RecommendationError_1.ActivityTypeError();
|
|
137
132
|
}
|
|
138
133
|
}
|
|
139
134
|
exports.checkActivityType = checkActivityType;
|
|
@@ -148,10 +143,11 @@ function checkActivityDate(activity) {
|
|
|
148
143
|
exports.checkActivityDate = checkActivityDate;
|
|
149
144
|
function checkActivitySettings(activitySettings) {
|
|
150
145
|
for (const intensity of Object.keys(activitySettings)) {
|
|
151
|
-
|
|
146
|
+
const reductionIntervals = activitySettings[intensity];
|
|
147
|
+
for (const interval of Object.keys(reductionIntervals)) {
|
|
152
148
|
const value = activitySettings[intensity][interval];
|
|
153
|
-
const isInInterval = Utils_1.Utils.
|
|
154
|
-
if (intensity ===
|
|
149
|
+
const isInInterval = Utils_1.Utils.isInRange(value, Constants_1.ACTIVITY_SETTINGS_INTERVAL_LIMITS);
|
|
150
|
+
if (intensity === hard && interval === fromFortysix) {
|
|
155
151
|
if (!isInInterval && value !== null) {
|
|
156
152
|
throw RecommendationError_1.ActivitySettingsError();
|
|
157
153
|
}
|
|
@@ -164,47 +160,47 @@ function checkActivitySettings(activitySettings) {
|
|
|
164
160
|
}
|
|
165
161
|
exports.checkActivitySettings = checkActivitySettings;
|
|
166
162
|
function checkActivityTargetBGL(activitySettingsTargetBGL) {
|
|
167
|
-
if (!Utils_1.Utils.
|
|
163
|
+
if (!Utils_1.Utils.isInRange(activitySettingsTargetBGL, Constants_1.ACTIVITY_TARGET_BGL_MMOL_LIMITS)) {
|
|
168
164
|
throw RecommendationError_1.ActivityTargetBGLError();
|
|
169
165
|
}
|
|
170
166
|
}
|
|
171
167
|
exports.checkActivityTargetBGL = checkActivityTargetBGL;
|
|
172
168
|
function checkCurrentBGL(currentBGL) {
|
|
173
169
|
if (currentBGL !== null) {
|
|
174
|
-
if (!Utils_1.Utils.
|
|
170
|
+
if (!Utils_1.Utils.isInRange(currentBGL, Constants_1.CURRENT_BGL_MMOL_LIMITS)) {
|
|
175
171
|
throw RecommendationError_1.CurrentBGLError();
|
|
176
172
|
}
|
|
177
173
|
}
|
|
178
174
|
}
|
|
179
175
|
exports.checkCurrentBGL = checkCurrentBGL;
|
|
180
176
|
function checkTargetBGL(targetBGL) {
|
|
181
|
-
if (!Utils_1.Utils.
|
|
177
|
+
if (!Utils_1.Utils.isInRange(targetBGL, Constants_1.TARGET_BGL_MMOL_LIMITS)) {
|
|
182
178
|
throw RecommendationError_1.TargetBGLError();
|
|
183
179
|
}
|
|
184
180
|
}
|
|
185
181
|
exports.checkTargetBGL = checkTargetBGL;
|
|
186
182
|
function checkBloodKetoneLevel(currentBKL) {
|
|
187
183
|
if (currentBKL !== null) {
|
|
188
|
-
if (!Utils_1.Utils.
|
|
184
|
+
if (!Utils_1.Utils.isInRange(currentBKL, Constants_1.CURRENT_BKL_MMOL_LIMITS)) {
|
|
189
185
|
throw RecommendationError_1.CurrentBKLError();
|
|
190
186
|
}
|
|
191
187
|
}
|
|
192
188
|
}
|
|
193
189
|
exports.checkBloodKetoneLevel = checkBloodKetoneLevel;
|
|
194
190
|
function checkInsulinSensitivity(insulinSensitivity) {
|
|
195
|
-
if (!Utils_1.Utils.
|
|
191
|
+
if (!Utils_1.Utils.isInRange(insulinSensitivity, Constants_1.INSULIN_SENSITIVITY_MMOL_LIMITS)) {
|
|
196
192
|
throw RecommendationError_1.InsulinSensitivityError();
|
|
197
193
|
}
|
|
198
194
|
}
|
|
199
195
|
exports.checkInsulinSensitivity = checkInsulinSensitivity;
|
|
200
196
|
function checkInsulinToCarbRatio(insulinToCarbRatio) {
|
|
201
|
-
if (!Utils_1.Utils.
|
|
197
|
+
if (!Utils_1.Utils.isInRange(insulinToCarbRatio, Constants_1.INSULIN_TO_CARBS_RATIO_LIMITS)) {
|
|
202
198
|
throw RecommendationError_1.InsulinToCarbsRatioError();
|
|
203
199
|
}
|
|
204
200
|
}
|
|
205
201
|
exports.checkInsulinToCarbRatio = checkInsulinToCarbRatio;
|
|
206
202
|
function checkCarbohydrates(carbohydrates) {
|
|
207
|
-
if (!Utils_1.Utils.
|
|
203
|
+
if (!Utils_1.Utils.isInRange(carbohydrates, Constants_1.CARBOHYDRATES_LIMTS)) {
|
|
208
204
|
throw RecommendationError_1.CarbohydrateLimitError();
|
|
209
205
|
}
|
|
210
206
|
}
|