@hedia/recommendation-screen 1.8.2 → 2.0.1
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 +29 -23
- package/App.tsx +42 -30
- 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 +33 -19
- package/src/__tests__/RecommendationUtils.test.ts +41 -22
- 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 +21 -19
- package/src/__tests__/Utils.test.ts +31 -20
- package/src/__tests__/Validations.test.d.ts +0 -0
- package/src/__tests__/Validations.test.js +40 -26
- package/src/__tests__/Validations.test.ts +54 -35
- 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 +5 -2
- package/src/__tests__/utils.jsx +23 -8
- package/src/__tests__/utils.tsx +28 -9
- 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 +110 -106
- package/src/locale/de/messages.js +1 -1
- package/src/locale/de/messages.po +110 -106
- package/src/locale/en/messages.js +1 -1
- package/src/locale/en/messages.po +113 -109
- package/src/locale/es/messages.js +1 -1
- package/src/locale/es/messages.po +107 -103
- package/src/locale/fr/messages.js +1 -1
- package/src/locale/fr/messages.po +106 -102
- 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 +108 -104
- package/src/types/enum.d.ts +51 -44
- package/src/types/enum.js +66 -56
- package/src/types/enum.ts +57 -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 +1 -0
- package/src/utils/RecommendationError.jsx +43 -40
- package/src/utils/RecommendationError.tsx +10 -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 +5 -4
- package/src/utils/Utils.ts +10 -8
- package/src/utils/Validations.d.ts +9 -9
- package/src/utils/Validations.js +39 -55
- package/src/utils/Validations.ts +54 -71
- 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
|
|
|
@@ -86,9 +88,7 @@ export const TargetBGLError = (): RecommendationError =>
|
|
|
86
88
|
|
|
87
89
|
export const BolusInsulinDoseError = (): RecommendationError =>
|
|
88
90
|
new RecommendationError(
|
|
89
|
-
i18n._(
|
|
90
|
-
t`Error. Hedia Calculator does not support an insulin dose greater than ${Calculator.SAFETY_INSULIN_LIMIT} units`,
|
|
91
|
-
),
|
|
91
|
+
i18n._(t`Error. Hedia Calculator does not support an insulin dose greater than ${SAFETY_INSULIN_LIMIT} units`),
|
|
92
92
|
RecommendationErrorEnum.BolusInsulinDose,
|
|
93
93
|
);
|
|
94
94
|
|
|
@@ -98,6 +98,12 @@ export const BolusInsulinSecondsPassedError = (): RecommendationError =>
|
|
|
98
98
|
RecommendationErrorEnum.BolusInsulinSecondsPassed,
|
|
99
99
|
);
|
|
100
100
|
|
|
101
|
+
export const RecentBolusError = (): RecommendationError =>
|
|
102
|
+
new RecommendationError(
|
|
103
|
+
i18n._(t`Error. Hedia Calculator could not find your recent boluses`),
|
|
104
|
+
RecommendationErrorEnum.RecentBolus,
|
|
105
|
+
);
|
|
106
|
+
|
|
101
107
|
export const UserReminderError = (): RecommendationError =>
|
|
102
108
|
new RecommendationError(
|
|
103
109
|
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 isInClosedInterval(value: number, interval: IInterval): boolean;
|
|
4
|
+
static getRounding(method: UserSettings.Enums.InjectionMethod): number;
|
|
5
|
+
static roundValue(value: number, injectMethod: UserSettings.Enums.InjectionMethod): number;
|
|
6
|
+
static isInClosedInterval(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}`);
|
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 isInClosedInterval(value: number, interval: IInterval): boolean {
|
|
30
|
+
public static isInClosedInterval(value: number | null, interval: IInterval): boolean {
|
|
29
31
|
if (value === null) {
|
|
30
32
|
return false;
|
|
31
33
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
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 } from "../types/types";
|
|
5
4
|
export declare function validateParams(props: IRecommendationProps): void;
|
|
6
|
-
export declare function checkLanguage(language:
|
|
7
|
-
export declare function checkInjectionMethod(injectionMethod: InjectionMethod): void;
|
|
5
|
+
export declare function checkLanguage(language: Languages): void;
|
|
6
|
+
export declare function checkInjectionMethod(injectionMethod: UserSettings.Enums.InjectionMethod): void;
|
|
8
7
|
export declare function checkBGLUnit(unit: BloodGlucoseUnit): void;
|
|
9
8
|
export declare function checkBKLUnit(unit: BloodKetonesUnit): void;
|
|
10
9
|
export declare function checkUserReminder(userReminder: number): void;
|
|
11
|
-
export declare function checkActivity(activity: IActivityParams): void;
|
|
10
|
+
export declare function checkActivity(activity: IActivityParams | null): void;
|
|
11
|
+
export declare function checkRecentBolus(recentBoluses: Array<IRecentBolus>): void;
|
|
12
12
|
export declare function checkRecentBolusesInsulinDose(recentBoluses: Array<IRecentBolus>): void;
|
|
13
13
|
export declare function checkRecentBolusesSecondsPassed(recentBoluses: Array<IRecentBolus>): void;
|
|
14
14
|
export declare function checkActivityDuration(activityDuration: number): void;
|
|
15
|
-
export declare function checkActivityIntensity(activityIntensity: ActivityIntensity): void;
|
|
16
|
-
export declare function checkActivityType(activityType: ActivityEnum): void;
|
|
15
|
+
export declare function checkActivityIntensity(activityIntensity: Activity.Enums.ActivityIntensity): void;
|
|
16
|
+
export declare function checkActivityType(activityType: Activity.Enums.ActivityEnum | null): void;
|
|
17
17
|
export declare function checkActivityDate(activity: IActivityParams): void;
|
|
18
|
-
export declare function checkActivitySettings(activitySettings:
|
|
18
|
+
export declare function checkActivitySettings(activitySettings: ActivitySettings): void;
|
|
19
19
|
export declare function checkActivityTargetBGL(activitySettingsTargetBGL: number): void;
|
|
20
20
|
export declare function checkCurrentBGL(currentBGL: number): void;
|
|
21
21
|
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.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);
|
|
@@ -25,39 +25,29 @@ function validateParams(props) {
|
|
|
25
25
|
}
|
|
26
26
|
exports.validateParams = validateParams;
|
|
27
27
|
function checkLanguage(language) {
|
|
28
|
-
if (!Object.values(
|
|
28
|
+
if (!Object.values(types_1.Languages).includes(language)) {
|
|
29
29
|
throw RecommendationError_1.LanguageError();
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
exports.checkLanguage = checkLanguage;
|
|
33
33
|
function checkInjectionMethod(injectionMethod) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
case enum_1.InjectionMethod.Pump:
|
|
38
|
-
break;
|
|
39
|
-
default:
|
|
40
|
-
throw RecommendationError_1.InjectionMethodError();
|
|
34
|
+
const check = Object.values(types_1.UserSettings.Enums.InjectionMethod).some((method) => method === injectionMethod);
|
|
35
|
+
if (!check) {
|
|
36
|
+
throw RecommendationError_1.InjectionMethodError();
|
|
41
37
|
}
|
|
42
38
|
}
|
|
43
39
|
exports.checkInjectionMethod = checkInjectionMethod;
|
|
44
40
|
function checkBGLUnit(unit) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
break;
|
|
49
|
-
default:
|
|
50
|
-
throw RecommendationError_1.BloodGlucoseUnitError();
|
|
41
|
+
const check = Object.values(types_1.BloodGlucoseUnit).some((enumUnit) => enumUnit === unit);
|
|
42
|
+
if (!check) {
|
|
43
|
+
throw RecommendationError_1.BloodGlucoseUnitError();
|
|
51
44
|
}
|
|
52
45
|
}
|
|
53
46
|
exports.checkBGLUnit = checkBGLUnit;
|
|
54
47
|
function checkBKLUnit(unit) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
break;
|
|
59
|
-
default:
|
|
60
|
-
throw RecommendationError_1.BloodKetoneUnitError();
|
|
48
|
+
const check = Object.values(types_1.BloodKetonesUnit).some((enumUnit) => enumUnit === unit);
|
|
49
|
+
if (!check) {
|
|
50
|
+
throw RecommendationError_1.BloodKetoneUnitError();
|
|
61
51
|
}
|
|
62
52
|
}
|
|
63
53
|
exports.checkBKLUnit = checkBKLUnit;
|
|
@@ -74,6 +64,7 @@ function checkCalculatorParams(calculatorParams) {
|
|
|
74
64
|
checkTargetBGL(calculatorParams.targetBGL);
|
|
75
65
|
checkInsulinToCarbRatio(calculatorParams.carbohydrateRatio);
|
|
76
66
|
checkInsulinSensitivity(calculatorParams.insulinSensitivity);
|
|
67
|
+
checkRecentBolus(calculatorParams.recentBoluses);
|
|
77
68
|
checkRecentBolusesInsulinDose(calculatorParams.recentBoluses);
|
|
78
69
|
checkRecentBolusesSecondsPassed(calculatorParams.recentBoluses);
|
|
79
70
|
}
|
|
@@ -87,24 +78,26 @@ function checkActivity(activity) {
|
|
|
87
78
|
}
|
|
88
79
|
}
|
|
89
80
|
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
|
-
});
|
|
81
|
+
function checkRecentBolus(recentBoluses) {
|
|
82
|
+
if (recentBoluses === null || recentBoluses === undefined) {
|
|
83
|
+
throw RecommendationError_1.RecentBolusError();
|
|
97
84
|
}
|
|
98
85
|
}
|
|
86
|
+
exports.checkRecentBolus = checkRecentBolus;
|
|
87
|
+
function checkRecentBolusesInsulinDose(recentBoluses) {
|
|
88
|
+
recentBoluses.forEach((bolus) => {
|
|
89
|
+
if (!Utils_1.Utils.isInClosedInterval(bolus.insulinDose, Constants_1.INSULIN_DOSE_LIMITS)) {
|
|
90
|
+
throw RecommendationError_1.BolusInsulinDoseError();
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
99
94
|
exports.checkRecentBolusesInsulinDose = checkRecentBolusesInsulinDose;
|
|
100
95
|
function checkRecentBolusesSecondsPassed(recentBoluses) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
});
|
|
107
|
-
}
|
|
96
|
+
recentBoluses.forEach((bolus) => {
|
|
97
|
+
if (!Utils_1.Utils.isInClosedInterval(bolus.secondsPassed, Constants_1.BOLUS_SECONDS_PASSED_LIMITS)) {
|
|
98
|
+
throw RecommendationError_1.BolusInsulinSecondsPassedError();
|
|
99
|
+
}
|
|
100
|
+
});
|
|
108
101
|
}
|
|
109
102
|
exports.checkRecentBolusesSecondsPassed = checkRecentBolusesSecondsPassed;
|
|
110
103
|
function checkActivityDuration(activityDuration) {
|
|
@@ -114,26 +107,16 @@ function checkActivityDuration(activityDuration) {
|
|
|
114
107
|
}
|
|
115
108
|
exports.checkActivityDuration = checkActivityDuration;
|
|
116
109
|
function checkActivityIntensity(activityIntensity) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
case RecommendationCalculator_1.ActivityIntensity.Light:
|
|
121
|
-
break;
|
|
122
|
-
default:
|
|
123
|
-
throw RecommendationError_1.ActivityIntensityError();
|
|
110
|
+
const check = Object.values(types_1.Activity.Enums.ActivityIntensity).some((method) => method === activityIntensity);
|
|
111
|
+
if (!check) {
|
|
112
|
+
throw RecommendationError_1.ActivityIntensityError();
|
|
124
113
|
}
|
|
125
114
|
}
|
|
126
115
|
exports.checkActivityIntensity = checkActivityIntensity;
|
|
127
116
|
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();
|
|
117
|
+
const check = Object.values(types_1.Activity.Enums.ActivityEnum).some((method) => method === activityType);
|
|
118
|
+
if (!check) {
|
|
119
|
+
throw RecommendationError_1.ActivityTypeError();
|
|
137
120
|
}
|
|
138
121
|
}
|
|
139
122
|
exports.checkActivityType = checkActivityType;
|
|
@@ -148,10 +131,11 @@ function checkActivityDate(activity) {
|
|
|
148
131
|
exports.checkActivityDate = checkActivityDate;
|
|
149
132
|
function checkActivitySettings(activitySettings) {
|
|
150
133
|
for (const intensity of Object.keys(activitySettings)) {
|
|
151
|
-
|
|
134
|
+
const reductionIntervals = activitySettings[intensity];
|
|
135
|
+
for (const interval of Object.keys(reductionIntervals)) {
|
|
152
136
|
const value = activitySettings[intensity][interval];
|
|
153
137
|
const isInInterval = Utils_1.Utils.isInClosedInterval(value, Constants_1.ACTIVITY_SETTINGS_INTERVAL_LIMITS);
|
|
154
|
-
if (intensity ===
|
|
138
|
+
if (intensity === hard && interval === fromFortysix) {
|
|
155
139
|
if (!isInInterval && value !== null) {
|
|
156
140
|
throw RecommendationError_1.ActivitySettingsError();
|
|
157
141
|
}
|