@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
package/src/utils/Validations.ts
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
ActivityIntensity,
|
|
4
|
-
IActivityInterval,
|
|
5
|
-
IActivityParams,
|
|
6
|
-
IActivitySettings,
|
|
7
|
-
IRecentBolus,
|
|
8
|
-
} from "@hedia/recommendation-calculator/src/RecommendationCalculator";
|
|
9
|
-
import { BloodGlucoseUnit, BloodKetonesUnit } from "@hedia/types";
|
|
1
|
+
import { Activity, BloodGlucoseUnit, BloodKetonesUnit, Languages, UserSettings } from "@hedia/types";
|
|
10
2
|
import moment from "moment";
|
|
11
3
|
import { IRecommendationProps } from "../RecommendationScreen";
|
|
12
|
-
import {
|
|
4
|
+
import { ActivitySettings, IActivityParams, IRecentBolus, IRecommendationParams, logbookEntry } from "../types/types";
|
|
13
5
|
import {
|
|
14
6
|
ACTIVITY_BUFFER_MINUTES,
|
|
15
7
|
ACTIVITY_DURATION_MINUTES_LIMITS,
|
|
@@ -44,11 +36,16 @@ import {
|
|
|
44
36
|
InsulinSensitivityError,
|
|
45
37
|
InsulinToCarbsRatioError,
|
|
46
38
|
LanguageError,
|
|
39
|
+
LatestLogbook6HoursBGLError,
|
|
40
|
+
RecentBolusError,
|
|
47
41
|
TargetBGLError,
|
|
48
42
|
UserReminderError,
|
|
49
43
|
} from "./RecommendationError";
|
|
50
44
|
import { Utils } from "./Utils";
|
|
51
45
|
|
|
46
|
+
const { hard } = Activity.Enums.ActivityIntensity;
|
|
47
|
+
const { fromFortysix } = Activity.Enums.ActivityReductionIntervals;
|
|
48
|
+
|
|
52
49
|
export function validateParams(props: IRecommendationProps): void {
|
|
53
50
|
checkCalculatorParams(props.calculatorParams);
|
|
54
51
|
checkBGLUnit(props.bloodGlucoseUnit);
|
|
@@ -59,49 +56,52 @@ export function validateParams(props: IRecommendationProps): void {
|
|
|
59
56
|
checkInjectionMethod(props.injectionMethod);
|
|
60
57
|
checkUserReminder(props.userReminder);
|
|
61
58
|
checkLanguage(props.language);
|
|
59
|
+
checkLatestLogbook6Hours(props.latestLogbookFrom6Hours);
|
|
62
60
|
if (props?.calculatorParams?.activity && props?.activityDisplayProps) {
|
|
63
61
|
checkActivityType(props.activityDisplayProps.activityType);
|
|
64
62
|
}
|
|
65
63
|
}
|
|
66
64
|
|
|
67
|
-
export function checkLanguage(language:
|
|
68
|
-
if (!Object.values(
|
|
65
|
+
export function checkLanguage(language: Languages): void {
|
|
66
|
+
if (!Object.values(Languages).includes(language)) {
|
|
69
67
|
throw LanguageError();
|
|
70
68
|
}
|
|
71
69
|
}
|
|
70
|
+
export function checkLatestLogbook6Hours(logbook: logbookEntry | null): void {
|
|
71
|
+
if (logbook === undefined) {
|
|
72
|
+
throw LatestLogbook6HoursBGLError();
|
|
73
|
+
}
|
|
74
|
+
if (logbook !== null) {
|
|
75
|
+
if (!Utils.isInRange(logbook.blood_glucose_millimolar, CURRENT_BGL_MMOL_LIMITS)) {
|
|
76
|
+
throw LatestLogbook6HoursBGLError();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
72
80
|
|
|
73
|
-
export function checkInjectionMethod(injectionMethod: InjectionMethod): void {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
default:
|
|
80
|
-
throw InjectionMethodError();
|
|
81
|
+
export function checkInjectionMethod(injectionMethod: UserSettings.Enums.InjectionMethod): void {
|
|
82
|
+
const check = Object.values(UserSettings.Enums.InjectionMethod).some(
|
|
83
|
+
(method): boolean => method === injectionMethod,
|
|
84
|
+
);
|
|
85
|
+
if (!check) {
|
|
86
|
+
throw InjectionMethodError();
|
|
81
87
|
}
|
|
82
88
|
}
|
|
83
89
|
|
|
84
90
|
export function checkBGLUnit(unit: BloodGlucoseUnit): void {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
break;
|
|
89
|
-
default:
|
|
90
|
-
throw BloodGlucoseUnitError();
|
|
91
|
+
const check = Object.values(BloodGlucoseUnit).some((enumUnit): boolean => enumUnit === unit);
|
|
92
|
+
if (!check) {
|
|
93
|
+
throw BloodGlucoseUnitError();
|
|
91
94
|
}
|
|
92
95
|
}
|
|
93
96
|
export function checkBKLUnit(unit: BloodKetonesUnit): void {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
break;
|
|
98
|
-
default:
|
|
99
|
-
throw BloodKetoneUnitError();
|
|
97
|
+
const check = Object.values(BloodKetonesUnit).some((enumUnit): boolean => enumUnit === unit);
|
|
98
|
+
if (!check) {
|
|
99
|
+
throw BloodKetoneUnitError();
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
export function checkUserReminder(userReminder: number): void {
|
|
104
|
-
if (!Utils.
|
|
104
|
+
if (!Utils.isInRange(userReminder, REMINDER_HOURS_LIMITS)) {
|
|
105
105
|
throw UserReminderError();
|
|
106
106
|
}
|
|
107
107
|
}
|
|
@@ -113,11 +113,12 @@ function checkCalculatorParams(calculatorParams: IRecommendationParams): void {
|
|
|
113
113
|
checkTargetBGL(calculatorParams.targetBGL);
|
|
114
114
|
checkInsulinToCarbRatio(calculatorParams.carbohydrateRatio);
|
|
115
115
|
checkInsulinSensitivity(calculatorParams.insulinSensitivity);
|
|
116
|
+
checkRecentBolus(calculatorParams.recentBoluses);
|
|
116
117
|
checkRecentBolusesInsulinDose(calculatorParams.recentBoluses);
|
|
117
118
|
checkRecentBolusesSecondsPassed(calculatorParams.recentBoluses);
|
|
118
119
|
}
|
|
119
120
|
|
|
120
|
-
export function checkActivity(activity: IActivityParams): void {
|
|
121
|
+
export function checkActivity(activity: IActivityParams | null): void {
|
|
121
122
|
if (activity) {
|
|
122
123
|
checkActivityDate(activity);
|
|
123
124
|
checkActivityDuration(activity.activityDuration);
|
|
@@ -127,53 +128,47 @@ export function checkActivity(activity: IActivityParams): void {
|
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
130
|
|
|
130
|
-
export function
|
|
131
|
-
if (recentBoluses
|
|
132
|
-
|
|
133
|
-
if (!Utils.isInClosedInterval(bolus.insulinDose, INSULIN_DOSE_LIMITS)) {
|
|
134
|
-
throw BolusInsulinDoseError();
|
|
135
|
-
}
|
|
136
|
-
});
|
|
131
|
+
export function checkRecentBolus(recentBoluses: Array<IRecentBolus>): void {
|
|
132
|
+
if (recentBoluses === null || recentBoluses === undefined) {
|
|
133
|
+
throw RecentBolusError();
|
|
137
134
|
}
|
|
138
135
|
}
|
|
139
136
|
|
|
137
|
+
export function checkRecentBolusesInsulinDose(recentBoluses: Array<IRecentBolus>): void {
|
|
138
|
+
recentBoluses.forEach((bolus: IRecentBolus): void => {
|
|
139
|
+
if (!Utils.isInRange(bolus.insulinDose, INSULIN_DOSE_LIMITS)) {
|
|
140
|
+
throw BolusInsulinDoseError();
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
140
145
|
export function checkRecentBolusesSecondsPassed(recentBoluses: Array<IRecentBolus>): void {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
});
|
|
147
|
-
}
|
|
146
|
+
recentBoluses.forEach((bolus: IRecentBolus): void => {
|
|
147
|
+
if (!Utils.isInRange(bolus.secondsPassed, BOLUS_SECONDS_PASSED_LIMITS)) {
|
|
148
|
+
throw BolusInsulinSecondsPassedError();
|
|
149
|
+
}
|
|
150
|
+
});
|
|
148
151
|
}
|
|
149
152
|
|
|
150
153
|
export function checkActivityDuration(activityDuration: number): void {
|
|
151
|
-
if (!Utils.
|
|
154
|
+
if (!Utils.isInRange(activityDuration, ACTIVITY_DURATION_MINUTES_LIMITS)) {
|
|
152
155
|
throw ActivityDurationError();
|
|
153
156
|
}
|
|
154
157
|
}
|
|
155
158
|
|
|
156
|
-
export function checkActivityIntensity(activityIntensity: ActivityIntensity): void {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
default:
|
|
163
|
-
throw ActivityIntensityError();
|
|
159
|
+
export function checkActivityIntensity(activityIntensity: Activity.Enums.ActivityIntensity): void {
|
|
160
|
+
const check = Object.values(Activity.Enums.ActivityIntensity).some(
|
|
161
|
+
(method): boolean => method === activityIntensity,
|
|
162
|
+
);
|
|
163
|
+
if (!check) {
|
|
164
|
+
throw ActivityIntensityError();
|
|
164
165
|
}
|
|
165
166
|
}
|
|
166
167
|
|
|
167
|
-
export function checkActivityType(activityType: ActivityEnum): void {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
case ActivityEnum.Run:
|
|
172
|
-
case ActivityEnum.Swim:
|
|
173
|
-
case ActivityEnum.Walk:
|
|
174
|
-
break;
|
|
175
|
-
default:
|
|
176
|
-
throw ActivityTypeError();
|
|
168
|
+
export function checkActivityType(activityType: Activity.Enums.ActivityEnum | null): void {
|
|
169
|
+
const check = Object.values(Activity.Enums.ActivityEnum).some((method): boolean => method === activityType);
|
|
170
|
+
if (!check) {
|
|
171
|
+
throw ActivityTypeError();
|
|
177
172
|
}
|
|
178
173
|
}
|
|
179
174
|
|
|
@@ -186,13 +181,13 @@ export function checkActivityDate(activity: IActivityParams): void {
|
|
|
186
181
|
}
|
|
187
182
|
}
|
|
188
183
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
for (const interval of Object.keys(
|
|
193
|
-
const value
|
|
194
|
-
const isInInterval: boolean = Utils.
|
|
195
|
-
if (intensity ===
|
|
184
|
+
export function checkActivitySettings(activitySettings: ActivitySettings): void {
|
|
185
|
+
for (const intensity of Object.keys(activitySettings) as Array<Activity.Enums.ActivityIntensity>) {
|
|
186
|
+
const reductionIntervals = activitySettings[intensity];
|
|
187
|
+
for (const interval of Object.keys(reductionIntervals) as Array<keyof typeof reductionIntervals>) {
|
|
188
|
+
const value = activitySettings[intensity][interval];
|
|
189
|
+
const isInInterval: boolean = Utils.isInRange(value, ACTIVITY_SETTINGS_INTERVAL_LIMITS);
|
|
190
|
+
if (intensity === hard && interval === fromFortysix) {
|
|
196
191
|
if (!isInInterval && value !== null) {
|
|
197
192
|
throw ActivitySettingsError();
|
|
198
193
|
}
|
|
@@ -204,47 +199,47 @@ export function checkActivitySettings(activitySettings: IActivitySettings): void
|
|
|
204
199
|
}
|
|
205
200
|
|
|
206
201
|
export function checkActivityTargetBGL(activitySettingsTargetBGL: number): void {
|
|
207
|
-
if (!Utils.
|
|
202
|
+
if (!Utils.isInRange(activitySettingsTargetBGL, ACTIVITY_TARGET_BGL_MMOL_LIMITS)) {
|
|
208
203
|
throw ActivityTargetBGLError();
|
|
209
204
|
}
|
|
210
205
|
}
|
|
211
206
|
|
|
212
207
|
export function checkCurrentBGL(currentBGL: number): void {
|
|
213
208
|
if (currentBGL !== null) {
|
|
214
|
-
if (!Utils.
|
|
209
|
+
if (!Utils.isInRange(currentBGL, CURRENT_BGL_MMOL_LIMITS)) {
|
|
215
210
|
throw CurrentBGLError();
|
|
216
211
|
}
|
|
217
212
|
}
|
|
218
213
|
}
|
|
219
214
|
|
|
220
215
|
export function checkTargetBGL(targetBGL: number): void {
|
|
221
|
-
if (!Utils.
|
|
216
|
+
if (!Utils.isInRange(targetBGL, TARGET_BGL_MMOL_LIMITS)) {
|
|
222
217
|
throw TargetBGLError();
|
|
223
218
|
}
|
|
224
219
|
}
|
|
225
220
|
|
|
226
221
|
export function checkBloodKetoneLevel(currentBKL: number): void {
|
|
227
222
|
if (currentBKL !== null) {
|
|
228
|
-
if (!Utils.
|
|
223
|
+
if (!Utils.isInRange(currentBKL, CURRENT_BKL_MMOL_LIMITS)) {
|
|
229
224
|
throw CurrentBKLError();
|
|
230
225
|
}
|
|
231
226
|
}
|
|
232
227
|
}
|
|
233
228
|
|
|
234
229
|
export function checkInsulinSensitivity(insulinSensitivity: number): void {
|
|
235
|
-
if (!Utils.
|
|
230
|
+
if (!Utils.isInRange(insulinSensitivity, INSULIN_SENSITIVITY_MMOL_LIMITS)) {
|
|
236
231
|
throw InsulinSensitivityError();
|
|
237
232
|
}
|
|
238
233
|
}
|
|
239
234
|
|
|
240
235
|
export function checkInsulinToCarbRatio(insulinToCarbRatio: number): void {
|
|
241
|
-
if (!Utils.
|
|
236
|
+
if (!Utils.isInRange(insulinToCarbRatio, INSULIN_TO_CARBS_RATIO_LIMITS)) {
|
|
242
237
|
throw InsulinToCarbsRatioError();
|
|
243
238
|
}
|
|
244
239
|
}
|
|
245
240
|
|
|
246
241
|
export function checkCarbohydrates(carbohydrates: number): void {
|
|
247
|
-
if (!Utils.
|
|
242
|
+
if (!Utils.isInRange(carbohydrates, CARBOHYDRATES_LIMTS)) {
|
|
248
243
|
throw CarbohydrateLimitError();
|
|
249
244
|
}
|
|
250
245
|
}
|
package/tsconfig.json
CHANGED
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
/* Strict Type-Checking Options */
|
|
30
30
|
//"strict": true, /* Enable all strict type-checking options. */
|
|
31
31
|
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
32
|
-
|
|
32
|
+
"strictNullChecks": true, /* Enable strict null checks. */
|
|
33
33
|
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
34
|
-
|
|
34
|
+
"strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
35
35
|
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
36
36
|
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
37
37
|
|
package/tslint.json
CHANGED
|
File without changes
|