@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.
Files changed (283) hide show
  1. package/.github/workflows/ci.yml +0 -0
  2. package/.github/workflows/publish.yml +48 -0
  3. package/.github/workflows/version-check.yml +45 -0
  4. package/.linguirc +0 -0
  5. package/.npmpackagejsonlintrc.json +0 -0
  6. package/.prettierignore +0 -0
  7. package/.prettierrc +0 -0
  8. package/App.d.ts +4 -5
  9. package/App.jsx +23 -34
  10. package/App.tsx +36 -41
  11. package/Changelog.md +0 -0
  12. package/README.md +0 -0
  13. package/android/app/BUCK +0 -0
  14. package/android/app/build.gradle +0 -0
  15. package/android/app/build_defs.bzl +0 -0
  16. package/android/app/debug.keystore +0 -0
  17. package/android/app/proguard-rules.pro +0 -0
  18. package/android/app/src/debug/AndroidManifest.xml +0 -0
  19. package/android/app/src/debug/java/com/hediarecommendationscreen/ReactNativeFlipper.java +0 -0
  20. package/android/app/src/main/AndroidManifest.xml +0 -0
  21. package/android/app/src/main/assets/fonts/AntDesign.ttf +0 -0
  22. package/android/app/src/main/assets/fonts/Entypo.ttf +0 -0
  23. package/android/app/src/main/assets/fonts/EvilIcons.ttf +0 -0
  24. package/android/app/src/main/assets/fonts/Feather.ttf +0 -0
  25. package/android/app/src/main/assets/fonts/FontAwesome.ttf +0 -0
  26. package/android/app/src/main/assets/fonts/FontAwesome5_Brands.ttf +0 -0
  27. package/android/app/src/main/assets/fonts/FontAwesome5_Regular.ttf +0 -0
  28. package/android/app/src/main/assets/fonts/FontAwesome5_Solid.ttf +0 -0
  29. package/android/app/src/main/assets/fonts/Foundation.ttf +0 -0
  30. package/android/app/src/main/assets/fonts/Ionicons.ttf +0 -0
  31. package/android/app/src/main/assets/fonts/MaterialCommunityIcons.ttf +0 -0
  32. package/android/app/src/main/assets/fonts/MaterialIcons.ttf +0 -0
  33. package/android/app/src/main/assets/fonts/Octicons.ttf +0 -0
  34. package/android/app/src/main/assets/fonts/Roboto-Black.ttf +0 -0
  35. package/android/app/src/main/assets/fonts/Roboto-BlackItalic.ttf +0 -0
  36. package/android/app/src/main/assets/fonts/Roboto-Bold.ttf +0 -0
  37. package/android/app/src/main/assets/fonts/Roboto-BoldItalic.ttf +0 -0
  38. package/android/app/src/main/assets/fonts/Roboto-Italic.ttf +0 -0
  39. package/android/app/src/main/assets/fonts/Roboto-Light.ttf +0 -0
  40. package/android/app/src/main/assets/fonts/Roboto-LightItalic.ttf +0 -0
  41. package/android/app/src/main/assets/fonts/Roboto-Medium.ttf +0 -0
  42. package/android/app/src/main/assets/fonts/Roboto-MediumItalic.ttf +0 -0
  43. package/android/app/src/main/assets/fonts/Roboto-Regular.ttf +0 -0
  44. package/android/app/src/main/assets/fonts/Roboto-Thin.ttf +0 -0
  45. package/android/app/src/main/assets/fonts/Roboto-ThinItalic.ttf +0 -0
  46. package/android/app/src/main/assets/fonts/SimpleLineIcons.ttf +0 -0
  47. package/android/app/src/main/assets/fonts/Zocial.ttf +0 -0
  48. package/android/app/src/main/java/com/hediarecommendationscreen/MainActivity.java +0 -0
  49. package/android/app/src/main/java/com/hediarecommendationscreen/MainApplication.java +0 -0
  50. package/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  51. package/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  52. package/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  53. package/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  54. package/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  55. package/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  56. package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  57. package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  58. package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  59. package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  60. package/android/app/src/main/res/values/color.xml +0 -0
  61. package/android/app/src/main/res/values/strings.xml +0 -0
  62. package/android/app/src/main/res/values/styles.xml +0 -0
  63. package/android/build.gradle +0 -0
  64. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  65. package/android/gradle/wrapper/gradle-wrapper.properties +0 -0
  66. package/android/gradle.properties +0 -0
  67. package/android/gradlew.bat +0 -0
  68. package/android/settings.gradle +0 -0
  69. package/app.json +0 -0
  70. package/assets/fonts/Roboto/LICENSE.txt +0 -0
  71. package/assets/fonts/Roboto/Roboto-Black.ttf +0 -0
  72. package/assets/fonts/Roboto/Roboto-BlackItalic.ttf +0 -0
  73. package/assets/fonts/Roboto/Roboto-Bold.ttf +0 -0
  74. package/assets/fonts/Roboto/Roboto-BoldItalic.ttf +0 -0
  75. package/assets/fonts/Roboto/Roboto-Italic.ttf +0 -0
  76. package/assets/fonts/Roboto/Roboto-Light.ttf +0 -0
  77. package/assets/fonts/Roboto/Roboto-LightItalic.ttf +0 -0
  78. package/assets/fonts/Roboto/Roboto-Medium.ttf +0 -0
  79. package/assets/fonts/Roboto/Roboto-MediumItalic.ttf +0 -0
  80. package/assets/fonts/Roboto/Roboto-Regular.ttf +0 -0
  81. package/assets/fonts/Roboto/Roboto-Thin.ttf +0 -0
  82. package/assets/fonts/Roboto/Roboto-ThinItalic.ttf +0 -0
  83. package/babel.config.js +0 -0
  84. package/ignore-git.sh +1 -1
  85. package/ignore-publish.sh +2 -1
  86. package/index.d.ts +2 -2
  87. package/index.js +2 -3
  88. package/index.ts +2 -2
  89. package/ios/HediaRecommendationScreen/AppDelegate.h +0 -0
  90. package/ios/HediaRecommendationScreen/AppDelegate.m +0 -0
  91. package/ios/HediaRecommendationScreen/Base.lproj/LaunchScreen.xib +0 -0
  92. package/ios/HediaRecommendationScreen/Images.xcassets/AppIcon.appiconset/Contents.json +0 -0
  93. package/ios/HediaRecommendationScreen/Images.xcassets/Contents.json +0 -0
  94. package/ios/HediaRecommendationScreen/Info.plist +0 -0
  95. package/ios/HediaRecommendationScreen/main.m +0 -0
  96. package/ios/HediaRecommendationScreen-tvOS/Info.plist +0 -0
  97. package/ios/HediaRecommendationScreen-tvOSTests/Info.plist +0 -0
  98. package/ios/HediaRecommendationScreen.xcodeproj/project.pbxproj +0 -0
  99. package/ios/HediaRecommendationScreen.xcodeproj/xcshareddata/xcschemes/HediaRecommendationScreen-tvOS.xcscheme +0 -0
  100. package/ios/HediaRecommendationScreen.xcodeproj/xcshareddata/xcschemes/HediaRecommendationScreen.xcscheme +0 -0
  101. package/ios/HediaRecommendationScreen.xcworkspace/contents.xcworkspacedata +0 -0
  102. package/ios/HediaRecommendationScreen.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
  103. package/ios/HediaRecommendationScreenTests/HediaRecommendationScreenTests.m +0 -0
  104. package/ios/HediaRecommendationScreenTests/Info.plist +0 -0
  105. package/ios/Podfile +0 -0
  106. package/ios/Podfile.lock +0 -0
  107. package/jest.config.js +0 -0
  108. package/jest.mock.js +0 -0
  109. package/metro.config.js +0 -0
  110. package/package.json +8 -10
  111. package/react-native.config.js +0 -0
  112. package/src/RecommendationScreen.d.ts +18 -20
  113. package/src/RecommendationScreen.jsx +26 -15
  114. package/src/RecommendationScreen.tsx +60 -37
  115. package/src/__tests__/RecommendationScreen.test.d.ts +0 -0
  116. package/src/__tests__/RecommendationScreen.test.jsx +163 -138
  117. package/src/__tests__/RecommendationScreen.test.tsx +256 -159
  118. package/src/__tests__/RecommendationUtils.test.d.ts +0 -0
  119. package/src/__tests__/RecommendationUtils.test.js +30 -39
  120. package/src/__tests__/RecommendationUtils.test.ts +38 -43
  121. package/src/__tests__/Translate.test.d.ts +0 -0
  122. package/src/__tests__/Translate.test.jsx +13 -12
  123. package/src/__tests__/Translate.test.tsx +15 -14
  124. package/src/__tests__/Utils.test.d.ts +0 -0
  125. package/src/__tests__/Utils.test.js +22 -20
  126. package/src/__tests__/Utils.test.ts +32 -21
  127. package/src/__tests__/Validations.test.d.ts +0 -0
  128. package/src/__tests__/Validations.test.js +59 -33
  129. package/src/__tests__/Validations.test.ts +83 -41
  130. package/src/__tests__/components/Activity.test.d.ts +0 -0
  131. package/src/__tests__/components/Activity.test.jsx +39 -18
  132. package/src/__tests__/components/Activity.test.tsx +99 -45
  133. package/src/__tests__/components/Emotion.test.d.ts +0 -0
  134. package/src/__tests__/components/Emotion.test.jsx +34 -25
  135. package/src/__tests__/components/Emotion.test.tsx +41 -24
  136. package/src/__tests__/components/Header.test.d.ts +0 -0
  137. package/src/__tests__/components/Header.test.jsx +10 -9
  138. package/src/__tests__/components/Header.test.tsx +12 -11
  139. package/src/__tests__/components/InfoBars.test.d.ts +0 -0
  140. package/src/__tests__/components/InfoBars.test.jsx +1 -0
  141. package/src/__tests__/components/InfoBars.test.tsx +7 -6
  142. package/src/__tests__/components/InvisibleNumberInput.test.d.ts +0 -0
  143. package/src/__tests__/components/InvisibleNumberInput.test.jsx +40 -24
  144. package/src/__tests__/components/InvisibleNumberInput.test.tsx +41 -17
  145. package/src/__tests__/components/LimitationMessage.test.d.ts +0 -0
  146. package/src/__tests__/components/LimitationMessage.test.jsx +11 -30
  147. package/src/__tests__/components/LimitationMessage.test.tsx +15 -13
  148. package/src/__tests__/components/MoodIcon.test.d.ts +0 -0
  149. package/src/__tests__/components/MoodIcon.test.jsx +12 -8
  150. package/src/__tests__/components/MoodIcon.test.tsx +13 -5
  151. package/src/__tests__/components/RecommendationModal.test.d.ts +0 -0
  152. package/src/__tests__/components/RecommendationModal.test.jsx +22 -21
  153. package/src/__tests__/components/RecommendationModal.test.tsx +29 -27
  154. package/src/__tests__/components/RecommendedCarbs.test.d.ts +0 -0
  155. package/src/__tests__/components/RecommendedCarbs.test.jsx +7 -10
  156. package/src/__tests__/components/RecommendedCarbs.test.tsx +9 -10
  157. package/src/__tests__/components/RecommendedInsulin.test.d.ts +0 -0
  158. package/src/__tests__/components/RecommendedInsulin.test.jsx +57 -41
  159. package/src/__tests__/components/RecommendedInsulin.test.tsx +57 -31
  160. package/src/__tests__/components/Remeasure.test.d.ts +0 -0
  161. package/src/__tests__/components/Remeasure.test.jsx +7 -3
  162. package/src/__tests__/components/Remeasure.test.tsx +11 -3
  163. package/src/__tests__/components/TransferToLogbook.test.d.ts +0 -0
  164. package/src/__tests__/components/TransferToLogbook.test.jsx +2 -2
  165. package/src/__tests__/components/TransferToLogbook.test.tsx +2 -2
  166. package/src/__tests__/components/TwoOptionModal.test.d.ts +0 -0
  167. package/src/__tests__/components/TwoOptionModal.test.jsx +5 -4
  168. package/src/__tests__/components/TwoOptionModal.test.tsx +6 -4
  169. package/src/__tests__/utils.d.ts +7 -2
  170. package/src/__tests__/utils.jsx +59 -15
  171. package/src/__tests__/utils.tsx +63 -16
  172. package/src/assets/activity/Cyclist.png +0 -0
  173. package/src/assets/activity/Other.png +0 -0
  174. package/src/assets/activity/Runner.png +0 -0
  175. package/src/assets/activity/Swimmer.png +0 -0
  176. package/src/assets/activity/Walk.png +0 -0
  177. package/src/assets/mood/happy.png +0 -0
  178. package/src/assets/mood/happy_active.png +0 -0
  179. package/src/assets/mood/neutral.png +0 -0
  180. package/src/assets/mood/neutral_active.png +0 -0
  181. package/src/assets/mood/sad.png +0 -0
  182. package/src/assets/mood/sad_active.png +0 -0
  183. package/src/assets/mood/semi_happy.png +0 -0
  184. package/src/assets/mood/semi_happy_active.png +0 -0
  185. package/src/assets/mood/semi_sad.png +0 -0
  186. package/src/assets/mood/semi_sad_active.png +0 -0
  187. package/src/components/Header.d.ts +0 -0
  188. package/src/components/Header.jsx +2 -1
  189. package/src/components/Header.tsx +2 -1
  190. package/src/components/Icon.js +0 -0
  191. package/src/components/InfoBars.d.ts +1 -1
  192. package/src/components/InfoBars.jsx +0 -0
  193. package/src/components/InfoBars.tsx +1 -1
  194. package/src/components/InvisibleNumberInput.d.ts +2 -1
  195. package/src/components/InvisibleNumberInput.jsx +7 -2
  196. package/src/components/InvisibleNumberInput.tsx +10 -3
  197. package/src/components/LimitationMessage.d.ts +1 -1
  198. package/src/components/LimitationMessage.jsx +3 -2
  199. package/src/components/LimitationMessage.tsx +3 -1
  200. package/src/components/LineSeparator.d.ts +0 -0
  201. package/src/components/LineSeparator.jsx +0 -0
  202. package/src/components/LineSeparator.tsx +0 -0
  203. package/src/components/RecentInsulin.d.ts +0 -0
  204. package/src/components/RecentInsulin.jsx +3 -2
  205. package/src/components/RecentInsulin.tsx +3 -0
  206. package/src/components/RecommendationModal.d.ts +4 -4
  207. package/src/components/RecommendationModal.jsx +10 -9
  208. package/src/components/RecommendationModal.tsx +19 -8
  209. package/src/components/RecommendedCarbs.d.ts +4 -3
  210. package/src/components/RecommendedCarbs.jsx +12 -9
  211. package/src/components/RecommendedCarbs.tsx +31 -16
  212. package/src/components/RecommendedInsulin.d.ts +7 -7
  213. package/src/components/RecommendedInsulin.jsx +11 -7
  214. package/src/components/RecommendedInsulin.tsx +24 -12
  215. package/src/components/Remeasure.d.ts +2 -2
  216. package/src/components/Remeasure.jsx +7 -2
  217. package/src/components/Remeasure.tsx +10 -4
  218. package/src/components/TransferToLogbook.d.ts +0 -0
  219. package/src/components/TransferToLogbook.jsx +2 -1
  220. package/src/components/TransferToLogbook.tsx +2 -0
  221. package/src/components/TwoOptionModal.d.ts +5 -3
  222. package/src/components/TwoOptionModal.jsx +44 -13
  223. package/src/components/TwoOptionModal.tsx +50 -14
  224. package/src/components/activity/Activity.d.ts +2 -3
  225. package/src/components/activity/Activity.jsx +5 -2
  226. package/src/components/activity/Activity.tsx +7 -5
  227. package/src/components/activity/ActivityIcon.d.ts +1 -1
  228. package/src/components/activity/ActivityIcon.jsx +9 -8
  229. package/src/components/activity/ActivityIcon.tsx +12 -10
  230. package/src/components/activity/ActivityIntensity.d.ts +1 -1
  231. package/src/components/activity/ActivityIntensity.jsx +2 -8
  232. package/src/components/activity/ActivityIntensity.tsx +3 -12
  233. package/src/components/mood/Emotion.d.ts +5 -4
  234. package/src/components/mood/Emotion.jsx +4 -3
  235. package/src/components/mood/Emotion.tsx +9 -7
  236. package/src/components/mood/MoodIcon.d.ts +2 -2
  237. package/src/components/mood/MoodIcon.jsx +3 -2
  238. package/src/components/mood/MoodIcon.tsx +4 -2
  239. package/src/locale/CleanLanguage.ts +0 -0
  240. package/src/locale/da/messages.js +1 -1
  241. package/src/locale/da/messages.po +115 -107
  242. package/src/locale/de/messages.js +1 -1
  243. package/src/locale/de/messages.po +115 -107
  244. package/src/locale/en/messages.js +1 -1
  245. package/src/locale/en/messages.po +118 -110
  246. package/src/locale/es/messages.js +1 -1
  247. package/src/locale/es/messages.po +112 -104
  248. package/src/locale/fr/messages.js +1 -1
  249. package/src/locale/fr/messages.po +111 -103
  250. package/src/locale/i18nUtils.d.ts +3 -4
  251. package/src/locale/i18nUtils.js +13 -12
  252. package/src/locale/i18nUtils.ts +14 -14
  253. package/src/locale/it/messages.js +1 -1
  254. package/src/locale/it/messages.po +113 -105
  255. package/src/types/enum.d.ts +52 -44
  256. package/src/types/enum.js +67 -56
  257. package/src/types/enum.ts +58 -34
  258. package/src/types/types.d.ts +9 -23
  259. package/src/types/types.js +0 -0
  260. package/src/types/types.ts +9 -25
  261. package/src/utils/AttentionMessages.d.ts +1 -4
  262. package/src/utils/AttentionMessages.jsx +8 -30
  263. package/src/utils/AttentionMessages.tsx +11 -16
  264. package/src/utils/Constants.d.ts +0 -0
  265. package/src/utils/Constants.js +0 -0
  266. package/src/utils/Constants.ts +0 -0
  267. package/src/utils/RecommendationError.d.ts +2 -0
  268. package/src/utils/RecommendationError.jsx +45 -40
  269. package/src/utils/RecommendationError.tsx +17 -4
  270. package/src/utils/RecommendationUtils.d.ts +7 -8
  271. package/src/utils/RecommendationUtils.js +15 -7
  272. package/src/utils/RecommendationUtils.ts +24 -14
  273. package/src/utils/Translations.d.ts +2 -0
  274. package/src/utils/Translations.js +10 -0
  275. package/src/utils/Translations.ts +9 -0
  276. package/src/utils/Utils.d.ts +4 -5
  277. package/src/utils/Utils.js +6 -5
  278. package/src/utils/Utils.ts +10 -8
  279. package/src/utils/Validations.d.ts +10 -9
  280. package/src/utils/Validations.js +61 -65
  281. package/src/utils/Validations.ts +76 -81
  282. package/tsconfig.json +2 -2
  283. package/tslint.json +0 -0
@@ -1,8 +1,10 @@
1
- import * as Calculator from "@hedia/recommendation-calculator";
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(latestLogbookFrom6Hours: logbookEntry): boolean;
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 && isSevereHyperglycemia(latestLogbookFrom6Hours)) {
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 undefined;
72
+ return null;
71
73
  case enum_1.BgLevel.NormoglycemiaUnder5MMOL:
72
- return isActivityWithin15Minutes(activity) ? AttentionMessages_1.AttentionMessage.NormoglycemiaActivityUnder5MMOL() : undefined;
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() : undefined;
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(latestLogbookFrom6Hours) {
91
- return latestLogbookFrom6Hours?.blood_glucose_millimolar > Constants_1.SEVERE_HYPERGLYCEMIA_START_MMOL;
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 : undefined;
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 (currentBGL > 15 && currentBGL <= 33.3 && isSevereHyperglycemia(latestLogbookFrom6Hours)) {
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 undefined;
78
+ return null;
76
79
 
77
80
  case BgLevel.NormoglycemiaUnder5MMOL:
78
- return isActivityWithin15Minutes(activity) ? AttentionMessage.NormoglycemiaActivityUnder5MMOL() : undefined;
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() : undefined;
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(latestLogbookFrom6Hours: logbookEntry): boolean {
100
- return latestLogbookFrom6Hours?.blood_glucose_millimolar > SEVERE_HYPERGLYCEMIA_START_MMOL;
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 : undefined;
124
+ return wasLimited ? message : null;
115
125
  }
@@ -0,0 +1,2 @@
1
+ import { Activity } from "@hedia/types";
2
+ export declare const ActivityIntensityTranslations: Record<Activity.Enums.ActivityIntensity, () => string>;
@@ -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
+ };
@@ -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 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;
@@ -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 enum_1.InjectionMethod.PenWhole:
11
+ case PenWhole:
11
12
  return 1;
12
- case enum_1.InjectionMethod.PenHalf:
13
+ case PenHalf:
13
14
  return 2;
14
- case enum_1.InjectionMethod.Pump:
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 isInClosedInterval(value, interval) {
25
+ static isInRange(value, interval) {
25
26
  if (value === null) {
26
27
  return false;
27
28
  }
@@ -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 InjectionMethod.PenWhole:
11
+ case PenWhole:
10
12
  return 1;
11
13
 
12
- case InjectionMethod.PenHalf:
14
+ case PenHalf:
13
15
  return 2;
14
16
 
15
- case InjectionMethod.Pump:
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 isInRange(value: number | null, interval: IInterval): boolean {
29
31
  if (value === null) {
30
32
  return false;
31
33
  }
@@ -1,21 +1,22 @@
1
- import { ActivityIntensity, IActivityParams, IActivitySettings, IRecentBolus } from "@hedia/recommendation-calculator/src/RecommendationCalculator";
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 { ActivityEnum, InjectionMethod, Language } from "../types/enum";
3
+ import { ActivitySettings, IActivityParams, IRecentBolus, logbookEntry } from "../types/types";
5
4
  export declare function validateParams(props: IRecommendationProps): void;
6
- export declare function checkLanguage(language: Language): void;
7
- export declare function checkInjectionMethod(injectionMethod: InjectionMethod): void;
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: IActivitySettings): void;
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;
@@ -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(enum_1.Language).includes(language)) {
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
- switch (injectionMethod) {
35
- case enum_1.InjectionMethod.PenHalf:
36
- case enum_1.InjectionMethod.PenWhole:
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
- switch (unit) {
46
- case types_1.BloodGlucoseUnit.MG_DL:
47
- case types_1.BloodGlucoseUnit.MMOL_L:
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
- switch (unit) {
56
- case types_1.BloodKetonesUnit.MG_DL:
57
- case types_1.BloodKetonesUnit.MMOL_L:
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.isInClosedInterval(userReminder, Constants_1.REMINDER_HOURS_LIMITS)) {
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 checkRecentBolusesInsulinDose(recentBoluses) {
91
- if (recentBoluses !== null) {
92
- recentBoluses.forEach((bolus) => {
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
- if (recentBoluses !== null) {
102
- recentBoluses.forEach((bolus) => {
103
- if (!Utils_1.Utils.isInClosedInterval(bolus.secondsPassed, Constants_1.BOLUS_SECONDS_PASSED_LIMITS)) {
104
- throw RecommendationError_1.BolusInsulinSecondsPassedError();
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.isInClosedInterval(activityDuration, Constants_1.ACTIVITY_DURATION_MINUTES_LIMITS)) {
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
- switch (activityIntensity) {
118
- case RecommendationCalculator_1.ActivityIntensity.Hard:
119
- case RecommendationCalculator_1.ActivityIntensity.Moderate:
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
- switch (activityType) {
129
- case enum_1.ActivityEnum.Cycling:
130
- case enum_1.ActivityEnum.Other:
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
- for (const interval of Object.keys(activitySettings[intensity])) {
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.isInClosedInterval(value, Constants_1.ACTIVITY_SETTINGS_INTERVAL_LIMITS);
154
- if (intensity === RecommendationCalculator_1.ActivityIntensity.Hard.toLowerCase() && interval === enum_1.ActivityInterval.fromFortysix) {
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.isInClosedInterval(activitySettingsTargetBGL, Constants_1.ACTIVITY_TARGET_BGL_MMOL_LIMITS)) {
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.isInClosedInterval(currentBGL, Constants_1.CURRENT_BGL_MMOL_LIMITS)) {
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.isInClosedInterval(targetBGL, Constants_1.TARGET_BGL_MMOL_LIMITS)) {
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.isInClosedInterval(currentBKL, Constants_1.CURRENT_BKL_MMOL_LIMITS)) {
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.isInClosedInterval(insulinSensitivity, Constants_1.INSULIN_SENSITIVITY_MMOL_LIMITS)) {
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.isInClosedInterval(insulinToCarbRatio, Constants_1.INSULIN_TO_CARBS_RATIO_LIMITS)) {
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.isInClosedInterval(carbohydrates, Constants_1.CARBOHYDRATES_LIMTS)) {
203
+ if (!Utils_1.Utils.isInRange(carbohydrates, Constants_1.CARBOHYDRATES_LIMTS)) {
208
204
  throw RecommendationError_1.CarbohydrateLimitError();
209
205
  }
210
206
  }