@hedia/recommendation-screen 2.1.73 → 2.1.74-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (408) hide show
  1. package/lib/commonjs/RecommendationScreen.js +768 -0
  2. package/lib/commonjs/RecommendationScreen.js.map +1 -0
  3. package/lib/commonjs/assets/IconsSVG/Close.js +20 -0
  4. package/lib/commonjs/assets/IconsSVG/Close.js.map +1 -0
  5. package/lib/commonjs/assets/IconsSVG/CloseOutlined.js +28 -0
  6. package/lib/commonjs/assets/IconsSVG/CloseOutlined.js.map +1 -0
  7. package/lib/commonjs/assets/IconsSVG/Edit.js +23 -0
  8. package/lib/commonjs/assets/IconsSVG/Edit.js.map +1 -0
  9. package/lib/commonjs/assets/IconsSVG/activity/Cycling.js +43 -0
  10. package/lib/commonjs/assets/IconsSVG/activity/Cycling.js.map +1 -0
  11. package/lib/commonjs/assets/IconsSVG/activity/Running.js +33 -0
  12. package/lib/commonjs/assets/IconsSVG/activity/Running.js.map +1 -0
  13. package/lib/commonjs/assets/IconsSVG/activity/Stretching.js +33 -0
  14. package/lib/commonjs/assets/IconsSVG/activity/Stretching.js.map +1 -0
  15. package/lib/commonjs/assets/IconsSVG/activity/Swimming.js +48 -0
  16. package/lib/commonjs/assets/IconsSVG/activity/Swimming.js.map +1 -0
  17. package/lib/commonjs/assets/IconsSVG/activity/Walking.js +38 -0
  18. package/lib/commonjs/assets/IconsSVG/activity/Walking.js.map +1 -0
  19. package/lib/commonjs/assets/IconsSVG/mood/Happy.js +34 -0
  20. package/lib/commonjs/assets/IconsSVG/mood/Happy.js.map +1 -0
  21. package/lib/commonjs/assets/IconsSVG/mood/Neutral.js +34 -0
  22. package/lib/commonjs/assets/IconsSVG/mood/Neutral.js.map +1 -0
  23. package/lib/commonjs/assets/IconsSVG/mood/Sad.js +34 -0
  24. package/lib/commonjs/assets/IconsSVG/mood/Sad.js.map +1 -0
  25. package/lib/commonjs/assets/IconsSVG/mood/SemiHappy.js +34 -0
  26. package/lib/commonjs/assets/IconsSVG/mood/SemiHappy.js.map +1 -0
  27. package/lib/commonjs/assets/IconsSVG/mood/SemiSad.js +34 -0
  28. package/lib/commonjs/assets/IconsSVG/mood/SemiSad.js.map +1 -0
  29. package/lib/commonjs/components/ExitModal.js +124 -0
  30. package/lib/commonjs/components/ExitModal.js.map +1 -0
  31. package/lib/commonjs/components/InfoBars.js +123 -0
  32. package/lib/commonjs/components/InfoBars.js.map +1 -0
  33. package/lib/commonjs/components/InvisibleNumberInput.js +150 -0
  34. package/lib/commonjs/components/InvisibleNumberInput.js.map +1 -0
  35. package/lib/commonjs/components/LineSeparator.js +27 -0
  36. package/lib/commonjs/components/LineSeparator.js.map +1 -0
  37. package/lib/commonjs/components/RecentInsulin.js +105 -0
  38. package/lib/commonjs/components/RecentInsulin.js.map +1 -0
  39. package/lib/commonjs/components/RecommendationModal.js +302 -0
  40. package/lib/commonjs/components/RecommendationModal.js.map +1 -0
  41. package/lib/commonjs/components/RecommendedCarbs.js +289 -0
  42. package/lib/commonjs/components/RecommendedCarbs.js.map +1 -0
  43. package/lib/commonjs/components/RecommendedInsulin.js +208 -0
  44. package/lib/commonjs/components/RecommendedInsulin.js.map +1 -0
  45. package/lib/commonjs/components/Remeasure.js +131 -0
  46. package/lib/commonjs/components/Remeasure.js.map +1 -0
  47. package/lib/commonjs/components/Text.js +25 -0
  48. package/lib/commonjs/components/Text.js.map +1 -0
  49. package/lib/commonjs/components/TimeoutModal.js +113 -0
  50. package/lib/commonjs/components/TimeoutModal.js.map +1 -0
  51. package/lib/commonjs/components/TransferToLogbook.js +83 -0
  52. package/lib/commonjs/components/TransferToLogbook.js.map +1 -0
  53. package/lib/commonjs/components/activity/Activity.js +112 -0
  54. package/lib/commonjs/components/activity/Activity.js.map +1 -0
  55. package/lib/commonjs/components/activity/ActivityIcon.js +86 -0
  56. package/lib/commonjs/components/activity/ActivityIcon.js.map +1 -0
  57. package/lib/commonjs/components/activity/ActivityIntensity.js +65 -0
  58. package/lib/commonjs/components/activity/ActivityIntensity.js.map +1 -0
  59. package/lib/commonjs/components/mood/Emotion.js +86 -0
  60. package/lib/commonjs/components/mood/Emotion.js.map +1 -0
  61. package/lib/commonjs/components/mood/MoodIcon.js +107 -0
  62. package/lib/commonjs/components/mood/MoodIcon.js.map +1 -0
  63. package/lib/commonjs/components/styles/fonts.js +154 -0
  64. package/lib/commonjs/components/styles/fonts.js.map +1 -0
  65. package/lib/commonjs/index.js +21 -0
  66. package/lib/commonjs/index.js.map +1 -0
  67. package/lib/commonjs/locales/da/translations.json +82 -0
  68. package/lib/commonjs/locales/de/translations.json +81 -0
  69. package/lib/commonjs/locales/en/translations.json +84 -0
  70. package/lib/commonjs/locales/es/translations.json +81 -0
  71. package/lib/commonjs/locales/fr/translations.json +81 -0
  72. package/lib/commonjs/locales/it/translations.json +81 -0
  73. package/lib/commonjs/locales/translate.js +63 -0
  74. package/lib/commonjs/locales/translate.js.map +1 -0
  75. package/lib/commonjs/types/enum.js +179 -0
  76. package/lib/commonjs/types/enum.js.map +1 -0
  77. package/lib/commonjs/types/types.js +6 -0
  78. package/lib/commonjs/types/types.js.map +1 -0
  79. package/lib/commonjs/utils/AttentionMessages.js +141 -0
  80. package/lib/commonjs/utils/AttentionMessages.js.map +1 -0
  81. package/lib/commonjs/utils/Constants.js +138 -0
  82. package/lib/commonjs/utils/Constants.js.map +1 -0
  83. package/lib/commonjs/utils/RecommendationError.js +116 -0
  84. package/lib/commonjs/utils/RecommendationError.js.map +1 -0
  85. package/lib/commonjs/utils/RecommendationUtils.js +212 -0
  86. package/lib/commonjs/utils/RecommendationUtils.js.map +1 -0
  87. package/lib/commonjs/utils/Translations.js +22 -0
  88. package/lib/commonjs/utils/Translations.js.map +1 -0
  89. package/lib/commonjs/utils/Utils.js +162 -0
  90. package/lib/commonjs/utils/Utils.js.map +1 -0
  91. package/lib/commonjs/utils/Validations.js +468 -0
  92. package/lib/commonjs/utils/Validations.js.map +1 -0
  93. package/lib/module/RecommendationScreen.js +758 -0
  94. package/lib/module/RecommendationScreen.js.map +1 -0
  95. package/lib/module/assets/IconsSVG/Close.js +11 -0
  96. package/lib/module/assets/IconsSVG/Close.js.map +1 -0
  97. package/lib/module/assets/IconsSVG/CloseOutlined.js +19 -0
  98. package/lib/module/assets/IconsSVG/CloseOutlined.js.map +1 -0
  99. package/lib/module/assets/IconsSVG/Edit.js +14 -0
  100. package/lib/module/assets/IconsSVG/Edit.js.map +1 -0
  101. package/lib/module/assets/IconsSVG/activity/Cycling.js +34 -0
  102. package/lib/module/assets/IconsSVG/activity/Cycling.js.map +1 -0
  103. package/lib/module/assets/IconsSVG/activity/Running.js +24 -0
  104. package/lib/module/assets/IconsSVG/activity/Running.js.map +1 -0
  105. package/lib/module/assets/IconsSVG/activity/Stretching.js +24 -0
  106. package/lib/module/assets/IconsSVG/activity/Stretching.js.map +1 -0
  107. package/lib/module/assets/IconsSVG/activity/Swimming.js +39 -0
  108. package/lib/module/assets/IconsSVG/activity/Swimming.js.map +1 -0
  109. package/lib/module/assets/IconsSVG/activity/Walking.js +29 -0
  110. package/lib/module/assets/IconsSVG/activity/Walking.js.map +1 -0
  111. package/lib/module/assets/IconsSVG/mood/Happy.js +25 -0
  112. package/lib/module/assets/IconsSVG/mood/Happy.js.map +1 -0
  113. package/lib/module/assets/IconsSVG/mood/Neutral.js +25 -0
  114. package/lib/module/assets/IconsSVG/mood/Neutral.js.map +1 -0
  115. package/lib/module/assets/IconsSVG/mood/Sad.js +25 -0
  116. package/lib/module/assets/IconsSVG/mood/Sad.js.map +1 -0
  117. package/lib/module/assets/IconsSVG/mood/SemiHappy.js +25 -0
  118. package/lib/module/assets/IconsSVG/mood/SemiHappy.js.map +1 -0
  119. package/lib/module/assets/IconsSVG/mood/SemiSad.js +25 -0
  120. package/lib/module/assets/IconsSVG/mood/SemiSad.js.map +1 -0
  121. package/lib/module/components/ExitModal.js +114 -0
  122. package/lib/module/components/ExitModal.js.map +1 -0
  123. package/lib/module/components/InfoBars.js +114 -0
  124. package/lib/module/components/InfoBars.js.map +1 -0
  125. package/lib/module/components/InvisibleNumberInput.js +142 -0
  126. package/lib/module/components/InvisibleNumberInput.js.map +1 -0
  127. package/lib/module/components/LineSeparator.js +19 -0
  128. package/lib/module/components/LineSeparator.js.map +1 -0
  129. package/lib/module/components/RecentInsulin.js +97 -0
  130. package/lib/module/components/RecentInsulin.js.map +1 -0
  131. package/lib/module/components/RecommendationModal.js +291 -0
  132. package/lib/module/components/RecommendationModal.js.map +1 -0
  133. package/lib/module/components/RecommendedCarbs.js +281 -0
  134. package/lib/module/components/RecommendedCarbs.js.map +1 -0
  135. package/lib/module/components/RecommendedInsulin.js +200 -0
  136. package/lib/module/components/RecommendedInsulin.js.map +1 -0
  137. package/lib/module/components/Remeasure.js +123 -0
  138. package/lib/module/components/Remeasure.js.map +1 -0
  139. package/lib/module/components/Text.js +16 -0
  140. package/lib/module/components/Text.js.map +1 -0
  141. package/lib/module/components/TimeoutModal.js +103 -0
  142. package/lib/module/components/TimeoutModal.js.map +1 -0
  143. package/lib/module/components/TransferToLogbook.js +75 -0
  144. package/lib/module/components/TransferToLogbook.js.map +1 -0
  145. package/lib/module/components/activity/Activity.js +104 -0
  146. package/lib/module/components/activity/Activity.js.map +1 -0
  147. package/lib/module/components/activity/ActivityIcon.js +78 -0
  148. package/lib/module/components/activity/ActivityIcon.js.map +1 -0
  149. package/lib/module/components/activity/ActivityIntensity.js +57 -0
  150. package/lib/module/components/activity/ActivityIntensity.js.map +1 -0
  151. package/lib/module/components/mood/Emotion.js +78 -0
  152. package/lib/module/components/mood/Emotion.js.map +1 -0
  153. package/lib/module/components/mood/MoodIcon.js +97 -0
  154. package/lib/module/components/mood/MoodIcon.js.map +1 -0
  155. package/lib/module/components/styles/fonts.js +145 -0
  156. package/lib/module/components/styles/fonts.js.map +1 -0
  157. package/lib/module/index.js +5 -0
  158. package/lib/module/index.js.map +1 -0
  159. package/lib/module/locales/da/translations.json +82 -0
  160. package/lib/module/locales/de/translations.json +81 -0
  161. package/lib/module/locales/en/translations.json +84 -0
  162. package/lib/module/locales/es/translations.json +81 -0
  163. package/lib/module/locales/fr/translations.json +81 -0
  164. package/lib/module/locales/it/translations.json +81 -0
  165. package/lib/module/locales/translate.js +55 -0
  166. package/lib/module/locales/translate.js.map +1 -0
  167. package/lib/module/types/enum.js +170 -0
  168. package/lib/module/types/enum.js.map +1 -0
  169. package/lib/module/types/types.js.map +1 -0
  170. package/lib/module/utils/AttentionMessages.js +131 -0
  171. package/lib/module/utils/AttentionMessages.js.map +1 -0
  172. package/{dist/src → lib/module}/utils/Constants.js +78 -35
  173. package/lib/module/utils/Constants.js.map +1 -0
  174. package/{dist/src → lib/module}/utils/RecommendationError.js +28 -6
  175. package/lib/module/utils/RecommendationError.js.map +1 -0
  176. package/{dist/src → lib/module}/utils/RecommendationUtils.js +89 -90
  177. package/lib/module/utils/RecommendationUtils.js.map +1 -0
  178. package/{dist/src → lib/module}/utils/Translations.js +5 -3
  179. package/lib/module/utils/Translations.js.map +1 -0
  180. package/lib/module/utils/Utils.js +155 -0
  181. package/lib/module/utils/Utils.js.map +1 -0
  182. package/{dist/src → lib/module}/utils/Validations.js +155 -128
  183. package/lib/module/utils/Validations.js.map +1 -0
  184. package/{dist/src → lib/typescript}/RecommendationScreen.d.ts +2 -1
  185. package/lib/typescript/RecommendationScreen.d.ts.map +1 -0
  186. package/{dist/src → lib/typescript}/assets/IconsSVG/Close.d.ts +1 -0
  187. package/lib/typescript/assets/IconsSVG/Close.d.ts.map +1 -0
  188. package/{dist/src → lib/typescript}/assets/IconsSVG/CloseOutlined.d.ts +1 -0
  189. package/lib/typescript/assets/IconsSVG/CloseOutlined.d.ts.map +1 -0
  190. package/{dist/src → lib/typescript}/assets/IconsSVG/Edit.d.ts +1 -0
  191. package/lib/typescript/assets/IconsSVG/Edit.d.ts.map +1 -0
  192. package/{dist/src → lib/typescript}/assets/IconsSVG/activity/Cycling.d.ts +1 -0
  193. package/lib/typescript/assets/IconsSVG/activity/Cycling.d.ts.map +1 -0
  194. package/{dist/src → lib/typescript}/assets/IconsSVG/activity/Running.d.ts +1 -0
  195. package/lib/typescript/assets/IconsSVG/activity/Running.d.ts.map +1 -0
  196. package/{dist/src → lib/typescript}/assets/IconsSVG/activity/Stretching.d.ts +1 -0
  197. package/lib/typescript/assets/IconsSVG/activity/Stretching.d.ts.map +1 -0
  198. package/{dist/src → lib/typescript}/assets/IconsSVG/activity/Swimming.d.ts +1 -0
  199. package/lib/typescript/assets/IconsSVG/activity/Swimming.d.ts.map +1 -0
  200. package/{dist/src → lib/typescript}/assets/IconsSVG/activity/Walking.d.ts +1 -0
  201. package/lib/typescript/assets/IconsSVG/activity/Walking.d.ts.map +1 -0
  202. package/{dist/src → lib/typescript}/assets/IconsSVG/mood/Happy.d.ts +1 -0
  203. package/lib/typescript/assets/IconsSVG/mood/Happy.d.ts.map +1 -0
  204. package/{dist/src → lib/typescript}/assets/IconsSVG/mood/Neutral.d.ts +1 -0
  205. package/lib/typescript/assets/IconsSVG/mood/Neutral.d.ts.map +1 -0
  206. package/{dist/src → lib/typescript}/assets/IconsSVG/mood/Sad.d.ts +1 -0
  207. package/lib/typescript/assets/IconsSVG/mood/Sad.d.ts.map +1 -0
  208. package/{dist/src → lib/typescript}/assets/IconsSVG/mood/SemiHappy.d.ts +1 -0
  209. package/lib/typescript/assets/IconsSVG/mood/SemiHappy.d.ts.map +1 -0
  210. package/{dist/src → lib/typescript}/assets/IconsSVG/mood/SemiSad.d.ts +1 -0
  211. package/lib/typescript/assets/IconsSVG/mood/SemiSad.d.ts.map +1 -0
  212. package/{dist/src → lib/typescript}/components/ExitModal.d.ts +1 -0
  213. package/lib/typescript/components/ExitModal.d.ts.map +1 -0
  214. package/{dist/src → lib/typescript}/components/InfoBars.d.ts +1 -0
  215. package/lib/typescript/components/InfoBars.d.ts.map +1 -0
  216. package/{dist/src → lib/typescript}/components/InvisibleNumberInput.d.ts +1 -0
  217. package/lib/typescript/components/InvisibleNumberInput.d.ts.map +1 -0
  218. package/{dist/src → lib/typescript}/components/LineSeparator.d.ts +1 -0
  219. package/lib/typescript/components/LineSeparator.d.ts.map +1 -0
  220. package/{dist/src → lib/typescript}/components/RecentInsulin.d.ts +1 -0
  221. package/lib/typescript/components/RecentInsulin.d.ts.map +1 -0
  222. package/{dist/src → lib/typescript}/components/RecommendationModal.d.ts +1 -0
  223. package/lib/typescript/components/RecommendationModal.d.ts.map +1 -0
  224. package/{dist/src → lib/typescript}/components/RecommendedCarbs.d.ts +1 -0
  225. package/lib/typescript/components/RecommendedCarbs.d.ts.map +1 -0
  226. package/{dist/src → lib/typescript}/components/RecommendedInsulin.d.ts +1 -0
  227. package/lib/typescript/components/RecommendedInsulin.d.ts.map +1 -0
  228. package/{dist/src → lib/typescript}/components/Remeasure.d.ts +1 -0
  229. package/lib/typescript/components/Remeasure.d.ts.map +1 -0
  230. package/{dist/src → lib/typescript}/components/Text.d.ts +1 -0
  231. package/lib/typescript/components/Text.d.ts.map +1 -0
  232. package/{dist/src → lib/typescript}/components/TimeoutModal.d.ts +1 -0
  233. package/lib/typescript/components/TimeoutModal.d.ts.map +1 -0
  234. package/{dist/src → lib/typescript}/components/TransferToLogbook.d.ts +1 -0
  235. package/lib/typescript/components/TransferToLogbook.d.ts.map +1 -0
  236. package/{dist/src → lib/typescript}/components/activity/Activity.d.ts +1 -0
  237. package/lib/typescript/components/activity/Activity.d.ts.map +1 -0
  238. package/{dist/src → lib/typescript}/components/activity/ActivityIcon.d.ts +1 -0
  239. package/lib/typescript/components/activity/ActivityIcon.d.ts.map +1 -0
  240. package/{dist/src → lib/typescript}/components/activity/ActivityIntensity.d.ts +1 -0
  241. package/lib/typescript/components/activity/ActivityIntensity.d.ts.map +1 -0
  242. package/{dist/src → lib/typescript}/components/mood/Emotion.d.ts +1 -0
  243. package/lib/typescript/components/mood/Emotion.d.ts.map +1 -0
  244. package/{dist/src → lib/typescript}/components/mood/MoodIcon.d.ts +1 -0
  245. package/lib/typescript/components/mood/MoodIcon.d.ts.map +1 -0
  246. package/{dist/src → lib/typescript}/components/styles/fonts.d.ts +1 -0
  247. package/lib/typescript/components/styles/fonts.d.ts.map +1 -0
  248. package/lib/typescript/index.d.ts +5 -0
  249. package/lib/typescript/index.d.ts.map +1 -0
  250. package/{dist/src → lib/typescript}/locales/translate.d.ts +1 -0
  251. package/lib/typescript/locales/translate.d.ts.map +1 -0
  252. package/{dist/src → lib/typescript}/types/enum.d.ts +1 -0
  253. package/lib/typescript/types/enum.d.ts.map +1 -0
  254. package/{dist/src → lib/typescript}/types/types.d.ts +1 -0
  255. package/lib/typescript/types/types.d.ts.map +1 -0
  256. package/{dist/src → lib/typescript}/utils/AttentionMessages.d.ts +1 -0
  257. package/lib/typescript/utils/AttentionMessages.d.ts.map +1 -0
  258. package/{dist/src → lib/typescript}/utils/Constants.d.ts +1 -0
  259. package/lib/typescript/utils/Constants.d.ts.map +1 -0
  260. package/{dist/src → lib/typescript}/utils/RecommendationError.d.ts +1 -0
  261. package/lib/typescript/utils/RecommendationError.d.ts.map +1 -0
  262. package/{dist/src → lib/typescript}/utils/RecommendationUtils.d.ts +1 -0
  263. package/lib/typescript/utils/RecommendationUtils.d.ts.map +1 -0
  264. package/{dist/src → lib/typescript}/utils/Translations.d.ts +1 -0
  265. package/lib/typescript/utils/Translations.d.ts.map +1 -0
  266. package/{dist/src → lib/typescript}/utils/Utils.d.ts +1 -0
  267. package/lib/typescript/utils/Utils.d.ts.map +1 -0
  268. package/{dist/src → lib/typescript}/utils/Validations.d.ts +1 -0
  269. package/lib/typescript/utils/Validations.d.ts.map +1 -0
  270. package/package.json +27 -7
  271. package/src/RecommendationScreen.tsx +854 -0
  272. package/src/assets/IconsSVG/Close.tsx +13 -0
  273. package/src/assets/IconsSVG/CloseOutlined.tsx +23 -0
  274. package/src/assets/IconsSVG/Edit.tsx +16 -0
  275. package/src/assets/IconsSVG/activity/Cycling.tsx +41 -0
  276. package/src/assets/IconsSVG/activity/Running.tsx +29 -0
  277. package/src/assets/IconsSVG/activity/Stretching.tsx +29 -0
  278. package/src/assets/IconsSVG/activity/Swimming.tsx +47 -0
  279. package/src/assets/IconsSVG/activity/Walking.tsx +35 -0
  280. package/src/assets/IconsSVG/mood/Happy.tsx +30 -0
  281. package/src/assets/IconsSVG/mood/Neutral.tsx +30 -0
  282. package/src/assets/IconsSVG/mood/Sad.tsx +30 -0
  283. package/src/assets/IconsSVG/mood/SemiHappy.tsx +30 -0
  284. package/src/assets/IconsSVG/mood/SemiSad.tsx +30 -0
  285. package/src/components/ExitModal.tsx +134 -0
  286. package/src/components/InfoBars.tsx +122 -0
  287. package/src/components/InvisibleNumberInput.tsx +170 -0
  288. package/src/components/LineSeparator.tsx +29 -0
  289. package/src/components/RecentInsulin.tsx +109 -0
  290. package/src/components/RecommendationModal.tsx +319 -0
  291. package/src/components/RecommendedCarbs.tsx +303 -0
  292. package/src/components/RecommendedInsulin.tsx +219 -0
  293. package/src/components/Remeasure.tsx +135 -0
  294. package/src/components/Text.tsx +27 -0
  295. package/src/components/TimeoutModal.tsx +121 -0
  296. package/src/components/TransferToLogbook.tsx +92 -0
  297. package/src/components/activity/Activity.tsx +107 -0
  298. package/src/components/activity/ActivityIcon.tsx +77 -0
  299. package/src/components/activity/ActivityIntensity.tsx +67 -0
  300. package/src/components/mood/Emotion.tsx +97 -0
  301. package/src/components/mood/MoodIcon.tsx +91 -0
  302. package/src/components/styles/fonts.ts +145 -0
  303. package/src/index.ts +5 -0
  304. package/src/locales/da/translations.json +82 -0
  305. package/src/locales/de/translations.json +81 -0
  306. package/src/locales/en/translations.json +84 -0
  307. package/src/locales/es/translations.json +81 -0
  308. package/src/locales/fr/translations.json +81 -0
  309. package/src/locales/it/translations.json +81 -0
  310. package/src/locales/translate.ts +62 -0
  311. package/src/types/enum.ts +164 -0
  312. package/src/types/types.ts +19 -0
  313. package/src/utils/AttentionMessages.ts +167 -0
  314. package/src/utils/Constants.ts +77 -0
  315. package/src/utils/RecommendationError.ts +182 -0
  316. package/src/utils/RecommendationUtils.ts +232 -0
  317. package/src/utils/Translations.ts +17 -0
  318. package/src/utils/Utils.ts +156 -0
  319. package/src/utils/Validations.ts +490 -0
  320. package/dist/index.d.ts +0 -5
  321. package/dist/index.js +0 -6
  322. package/dist/index.js.map +0 -1
  323. package/dist/src/RecommendationScreen.js +0 -537
  324. package/dist/src/RecommendationScreen.js.map +0 -1
  325. package/dist/src/assets/IconsSVG/Close.js +0 -7
  326. package/dist/src/assets/IconsSVG/Close.js.map +0 -1
  327. package/dist/src/assets/IconsSVG/CloseOutlined.js +0 -9
  328. package/dist/src/assets/IconsSVG/CloseOutlined.js.map +0 -1
  329. package/dist/src/assets/IconsSVG/Edit.js +0 -8
  330. package/dist/src/assets/IconsSVG/Edit.js.map +0 -1
  331. package/dist/src/assets/IconsSVG/activity/Cycling.js +0 -12
  332. package/dist/src/assets/IconsSVG/activity/Cycling.js.map +0 -1
  333. package/dist/src/assets/IconsSVG/activity/Running.js +0 -10
  334. package/dist/src/assets/IconsSVG/activity/Running.js.map +0 -1
  335. package/dist/src/assets/IconsSVG/activity/Stretching.js +0 -10
  336. package/dist/src/assets/IconsSVG/activity/Stretching.js.map +0 -1
  337. package/dist/src/assets/IconsSVG/activity/Swimming.js +0 -13
  338. package/dist/src/assets/IconsSVG/activity/Swimming.js.map +0 -1
  339. package/dist/src/assets/IconsSVG/activity/Walking.js +0 -11
  340. package/dist/src/assets/IconsSVG/activity/Walking.js.map +0 -1
  341. package/dist/src/assets/IconsSVG/mood/Happy.js +0 -11
  342. package/dist/src/assets/IconsSVG/mood/Happy.js.map +0 -1
  343. package/dist/src/assets/IconsSVG/mood/Neutral.js +0 -11
  344. package/dist/src/assets/IconsSVG/mood/Neutral.js.map +0 -1
  345. package/dist/src/assets/IconsSVG/mood/Sad.js +0 -11
  346. package/dist/src/assets/IconsSVG/mood/Sad.js.map +0 -1
  347. package/dist/src/assets/IconsSVG/mood/SemiHappy.js +0 -11
  348. package/dist/src/assets/IconsSVG/mood/SemiHappy.js.map +0 -1
  349. package/dist/src/assets/IconsSVG/mood/SemiSad.js +0 -11
  350. package/dist/src/assets/IconsSVG/mood/SemiSad.js.map +0 -1
  351. package/dist/src/components/ExitModal.js +0 -91
  352. package/dist/src/components/ExitModal.js.map +0 -1
  353. package/dist/src/components/InfoBars.js +0 -98
  354. package/dist/src/components/InfoBars.js.map +0 -1
  355. package/dist/src/components/InvisibleNumberInput.js +0 -123
  356. package/dist/src/components/InvisibleNumberInput.js.map +0 -1
  357. package/dist/src/components/LineSeparator.js +0 -17
  358. package/dist/src/components/LineSeparator.js.map +0 -1
  359. package/dist/src/components/RecentInsulin.js +0 -90
  360. package/dist/src/components/RecentInsulin.js.map +0 -1
  361. package/dist/src/components/RecommendationModal.js +0 -241
  362. package/dist/src/components/RecommendationModal.js.map +0 -1
  363. package/dist/src/components/RecommendedCarbs.js +0 -234
  364. package/dist/src/components/RecommendedCarbs.js.map +0 -1
  365. package/dist/src/components/RecommendedInsulin.js +0 -166
  366. package/dist/src/components/RecommendedInsulin.js.map +0 -1
  367. package/dist/src/components/Remeasure.js +0 -103
  368. package/dist/src/components/Remeasure.js.map +0 -1
  369. package/dist/src/components/Text.js +0 -14
  370. package/dist/src/components/Text.js.map +0 -1
  371. package/dist/src/components/TimeoutModal.js +0 -84
  372. package/dist/src/components/TimeoutModal.js.map +0 -1
  373. package/dist/src/components/TransferToLogbook.js +0 -68
  374. package/dist/src/components/TransferToLogbook.js.map +0 -1
  375. package/dist/src/components/activity/Activity.js +0 -93
  376. package/dist/src/components/activity/Activity.js.map +0 -1
  377. package/dist/src/components/activity/ActivityIcon.js +0 -66
  378. package/dist/src/components/activity/ActivityIcon.js.map +0 -1
  379. package/dist/src/components/activity/ActivityIntensity.js +0 -55
  380. package/dist/src/components/activity/ActivityIntensity.js.map +0 -1
  381. package/dist/src/components/mood/Emotion.js +0 -69
  382. package/dist/src/components/mood/Emotion.js.map +0 -1
  383. package/dist/src/components/mood/MoodIcon.js +0 -68
  384. package/dist/src/components/mood/MoodIcon.js.map +0 -1
  385. package/dist/src/components/styles/fonts.js +0 -145
  386. package/dist/src/components/styles/fonts.js.map +0 -1
  387. package/dist/src/locales/da/translations.json +0 -82
  388. package/dist/src/locales/de/translations.json +0 -81
  389. package/dist/src/locales/en/translations.json +0 -84
  390. package/dist/src/locales/es/translations.json +0 -81
  391. package/dist/src/locales/fr/translations.json +0 -81
  392. package/dist/src/locales/it/translations.json +0 -81
  393. package/dist/src/locales/translate.js +0 -53
  394. package/dist/src/locales/translate.js.map +0 -1
  395. package/dist/src/types/enum.js +0 -154
  396. package/dist/src/types/enum.js.map +0 -1
  397. package/dist/src/types/types.js.map +0 -1
  398. package/dist/src/utils/AttentionMessages.js +0 -123
  399. package/dist/src/utils/AttentionMessages.js.map +0 -1
  400. package/dist/src/utils/Constants.js.map +0 -1
  401. package/dist/src/utils/RecommendationError.js.map +0 -1
  402. package/dist/src/utils/RecommendationUtils.js.map +0 -1
  403. package/dist/src/utils/Translations.js.map +0 -1
  404. package/dist/src/utils/Utils.js +0 -142
  405. package/dist/src/utils/Utils.js.map +0 -1
  406. package/dist/src/utils/Validations.js.map +0 -1
  407. package/dist/tsconfig.tsbuildinfo +0 -1
  408. /package/{dist/src → lib/module}/types/types.js +0 -0
@@ -0,0 +1,182 @@
1
+ import { BolusCalculator } from "@hedia/types";
2
+
3
+ import { t } from "../locales/translate";
4
+ import { RecommendationErrorEnum } from "../types/enum";
5
+
6
+ const SAFETY_INSULIN_LIMIT = BolusCalculator.Constants.SAFETY_INSULIN_LIMIT;
7
+
8
+ /**
9
+ * Defines a set of human readable error messages.
10
+ * Each of them is defined as a function that returns the required translatable error message.
11
+ * The app should generally prevent the user from entering invalid values at the time of entry, so in almost all of these cases,
12
+ * the use of any of these errors indicate that something might have gone really wrong, and the user will be prevented
13
+ * from getting a recommendation until the problem is solved.
14
+ */
15
+ export class RecommendationError extends Error {
16
+ public readonly type: RecommendationErrorEnum;
17
+
18
+ constructor(message: string, type: RecommendationErrorEnum) {
19
+ super(message);
20
+ this.type = type;
21
+ }
22
+ }
23
+
24
+ /** The given activity settings are corrupt. */
25
+ export const ActivitySettingsError = (): RecommendationError =>
26
+ new RecommendationError(
27
+ t(`Error. Please verify that your activity settings are set up correctly.`),
28
+ RecommendationErrorEnum.ActivitySettings,
29
+ );
30
+
31
+ /** The duration of the given activity is invalid. */
32
+ export const ActivityDurationError = (): RecommendationError =>
33
+ new RecommendationError(
34
+ t(`Error. Hedia Calculator only supports activities with a duration of maximum 60 minutes.`),
35
+ RecommendationErrorEnum.ActivityDuration,
36
+ );
37
+
38
+ /** The start date of the given activity is invalid. */
39
+ export const ActivityDateError = (): RecommendationError =>
40
+ new RecommendationError(
41
+ t(`Hedia Calculator does not support activities that finished more than 4 hours ago.`),
42
+ RecommendationErrorEnum.ActivityDate,
43
+ );
44
+
45
+ /** The intensity of the given activity is invalid. */
46
+ export const ActivityIntensityError = (): RecommendationError =>
47
+ new RecommendationError(
48
+ t(`Error. Hedia Calculator does not support your activity intensity value`),
49
+ RecommendationErrorEnum.ActivityIntensity,
50
+ );
51
+
52
+ /** Type of the given activity is invalid. */
53
+ export const ActivityTypeError = (): RecommendationError =>
54
+ new RecommendationError(
55
+ t(`Error. Hedia Calculator does not support your activity type value`),
56
+ RecommendationErrorEnum.ActivityType,
57
+ );
58
+
59
+ /** The user’s activity target BGL setting is invalid. */
60
+ export const ActivityTargetBGLError = (): RecommendationError =>
61
+ new RecommendationError(
62
+ t(`Error. Please verify that your activity target blood glucose value is correct.`),
63
+ RecommendationErrorEnum.ActivityTargetBGL,
64
+ );
65
+
66
+ /** More than 300 g carbohydrates entered. */
67
+ export const CarbohydrateLimitError = (): RecommendationError =>
68
+ new RecommendationError(
69
+ t(
70
+ `Hedia Calculator does not support insulin recommendations with more than 300 grams of carbohydrates present.`,
71
+ ),
72
+ RecommendationErrorEnum.CarbohydrateLimit,
73
+ );
74
+
75
+ /** The user’s insulin sensitivity setting is outside of the valid range. */
76
+ export const InsulinSensitivityError = (): RecommendationError =>
77
+ new RecommendationError(
78
+ t(`Error. Please verify that your insulin sensitivity value is correct.`),
79
+ RecommendationErrorEnum.InsulinSensitivity,
80
+ );
81
+
82
+ /** The user’s insulin-to-carbs ratio setting is outside of the valid range. */
83
+ export const InsulinToCarbsRatioError = (): RecommendationError =>
84
+ new RecommendationError(
85
+ t(`Error. Please verify that your insulin to carb ratio value is correct.`),
86
+ RecommendationErrorEnum.InsulinToCarbsRatio,
87
+ );
88
+
89
+ /** The entered current blood glucose level is outside of the valid range. */
90
+ export const CurrentBGLError = (): RecommendationError =>
91
+ new RecommendationError(
92
+ t(`Error. Hedia Calculator does not support your current blood glucose level.`),
93
+ RecommendationErrorEnum.CurrentBGL,
94
+ );
95
+
96
+ /** The blood glucose level of the latest logbook entry from the last 6 hours is outside of the valid range. */
97
+ export const LatestLogbook6HoursBGLError = (): RecommendationError =>
98
+ new RecommendationError(
99
+ t(
100
+ `Error. Hedia Calculator does not support the blood glucose level of your latest logbook entry from the last 6 hours.`,
101
+ ),
102
+ RecommendationErrorEnum.LatestLogbook6HoursBGL,
103
+ );
104
+
105
+ /** The entered current blood ketones concentration is outside of the valid range. */
106
+ export const CurrentBKLError = (): RecommendationError =>
107
+ new RecommendationError(
108
+ t(`Error. Hedia Calculator does not support your current blood ketone level.`),
109
+ RecommendationErrorEnum.CurrentBKL,
110
+ );
111
+
112
+ /** The user’s target BGL setting is outside of the valid range. */
113
+ export const TargetBGLError = (): RecommendationError =>
114
+ new RecommendationError(
115
+ t(`Error. Please verify that your target blood glucose value is correct.`),
116
+ RecommendationErrorEnum.TargetBGL,
117
+ );
118
+
119
+ /** At least one of the recent (within the previous 4 hours) logbook entries has an insulin amount that exceeds the safety insulin threshold. */
120
+ export const BolusInsulinDoseError = (): RecommendationError =>
121
+ new RecommendationError(
122
+ t(`Error. Hedia Calculator does not support an insulin dose greater than {SAFETY_INSULIN_LIMIT} units`, {
123
+ SAFETY_INSULIN_LIMIT,
124
+ }),
125
+ RecommendationErrorEnum.BolusInsulinDose,
126
+ );
127
+
128
+ /** At least one entry from the list of recent logbook entries is older than 4 hours. */
129
+ export const BolusInsulinSecondsPassedError = (): RecommendationError =>
130
+ new RecommendationError(
131
+ t(`Error. Hedia Calculator does not support insulin recommendations with boluses older than 4 hours`),
132
+ RecommendationErrorEnum.BolusInsulinSecondsPassed,
133
+ );
134
+
135
+ /** The user’s recent boluses entries are not in the allowed format. */
136
+ export const RecentBolusError = (): RecommendationError =>
137
+ new RecommendationError(
138
+ t(`Error. Hedia Calculator could not find your recent boluses`),
139
+ RecommendationErrorEnum.RecentBolus,
140
+ );
141
+
142
+ /** The user’s setting for initial reminder time is outside of the valid range. */
143
+ export const UserReminderError = (): RecommendationError =>
144
+ new RecommendationError(
145
+ t(`Error. Please verify your notifications settings.`),
146
+ RecommendationErrorEnum.UserReminder,
147
+ );
148
+
149
+ /** The user’s insulin injection method setting is invalid. */
150
+ export const InjectionMethodError = (): RecommendationError =>
151
+ new RecommendationError(
152
+ t(`Error. Hedia Calculator does not support your injection method.`),
153
+ RecommendationErrorEnum.InjectionMethod,
154
+ );
155
+
156
+ /**The user’s language setting is not supported by the bolus calculator or it is in the wrong format */
157
+ export const LanguageError = (): RecommendationError =>
158
+ new RecommendationError(
159
+ t(`Error. Hedia Calculator does not support your current language.`),
160
+ RecommendationErrorEnum.Language,
161
+ );
162
+
163
+ /** The user’s blood ketones unit setting is invalid. */
164
+ export const BloodKetoneUnitError = (): RecommendationError =>
165
+ new RecommendationError(
166
+ t(`Error. Hedia Calculator does not support your current blood ketone unit.`),
167
+ RecommendationErrorEnum.BloodKetoneUnit,
168
+ );
169
+
170
+ /** The user’s blood glucose level measuring unit setting is invalid. */
171
+ export const BloodGlucoseUnitError = (): RecommendationError =>
172
+ new RecommendationError(
173
+ t(`Error. Hedia Calculator does not support your current blood glucose unit.`),
174
+ RecommendationErrorEnum.BloodGlucoseUnit,
175
+ );
176
+
177
+ /** The user has provided a blood ketone level but the blood ketone measuring unit is not defined. */
178
+ export const BloodKetonePropsError = (): RecommendationError =>
179
+ new RecommendationError(
180
+ t(`Error. Your blood ketone settings are invalid.`),
181
+ RecommendationErrorEnum.BloodKetoneProps,
182
+ );
@@ -0,0 +1,232 @@
1
+ /**
2
+ * Helper functions for processing and categorising user inputs for determining which warnings and messages to display.
3
+ * @module
4
+ */
5
+
6
+ import moment from "moment";
7
+
8
+ import { BolusCalculator, Logbook } from "@hedia/types";
9
+
10
+ import { BgLevel, RecommendationReminders } from "../types/enum";
11
+ import { addPostponeActivityMessageUnder5MMOL, AttentionMessage, Messages } from "./AttentionMessages";
12
+ import { SEVERE_HYPERGLYCEMIA_START_MMOL } from "./Constants";
13
+ import { CurrentBGLError } from "./RecommendationError";
14
+ import { Utils } from "./Utils";
15
+
16
+ /**
17
+ * Determine the category of the blood glucose level based on the numerical value of the BGL itself and potentially the most recent previously entered BGL.
18
+ *
19
+ * Steps:
20
+ * 1. If currentBGL is null return BgLevel.BGLevelNotProvided.
21
+ * 2. If currentBGL is in the interval [1.1; 2] return BgLevel.SevereHypoglycemia.
22
+ * 3. If currentBGL is in the interval ]2; 3.5] return BgLevel.Hypoglycemia.
23
+ * 4. If currentBGL is in the interval ]3.5; 4] return BgLevel.MildHypoglycemia.
24
+ * 5. If currentBGL is in the interval ]4; 5[ return BgLevel.NormoglycemiaUnder5MMOL.
25
+ * 6. If currentBGL is in the interval [5; 7] return BgLevel.Normoglycemia.
26
+ * 7. If currentBGL is in the interval ]7; 15[ return BgLevel.MildHyperglycemia.
27
+ * 8. If currentBGL is in the interval ]15; 33.3] and calling isSevereHyperglycemia() with latestLogbookFrom6Hours returns true then return BgLevel.SevereHyperglycemia.
28
+ * 9. If currentBGL is in the interval [15; 33.3] return BgLevel.Hyperglycemia.
29
+ * @param currentBGL The blood glucose level entered by the user or null if they didn’t enter it.
30
+ * @param latestLogbookFrom6Hours The latest saved logbook entry if one was logged within the last 6 hours. Otherwise null.
31
+ * @returns Indication of the category that the blood glucose level belongs to {@link BgLevel}.
32
+ */
33
+ export function getBGLevel(
34
+ currentBGL: number | null,
35
+ latestLogbookFrom6Hours: Logbook.Types.ILogbookEntry | null,
36
+ ): BgLevel {
37
+ if (currentBGL === null) {
38
+ return BgLevel.BGLevelNotProvided;
39
+ }
40
+ if (currentBGL >= 1.1 && currentBGL <= 2) {
41
+ return BgLevel.SevereHypoglycemia;
42
+ }
43
+ if (currentBGL > 2 && currentBGL <= 3.5) {
44
+ return BgLevel.Hypoglycemia;
45
+ }
46
+ if (currentBGL > 3.5 && currentBGL <= 4) {
47
+ return BgLevel.MildHypoglycemia;
48
+ }
49
+ if (currentBGL > 4 && currentBGL < 5) {
50
+ return BgLevel.NormoglycemiaUnder5MMOL;
51
+ }
52
+ if (currentBGL >= 5 && currentBGL <= 7) {
53
+ return BgLevel.Normoglycemia;
54
+ }
55
+ if (currentBGL > 7 && currentBGL < 15) {
56
+ return BgLevel.MildHyperglycemia;
57
+ }
58
+ if (
59
+ currentBGL > 15 && currentBGL <= 33.3 && latestLogbookFrom6Hours
60
+ ? isSevereHyperglycemia(latestLogbookFrom6Hours)
61
+ : false
62
+ ) {
63
+ return BgLevel.SevereHyperglycemia;
64
+ }
65
+ if (currentBGL >= 15 && currentBGL <= 33.3) {
66
+ return BgLevel.Hyperglycemia;
67
+ }
68
+ return BgLevel.UnsupportedBGLevel;
69
+ }
70
+
71
+ /**
72
+ * Calculate the initial value for the calibration reminder time slider.
73
+ *
74
+ * Steps:
75
+ * 1. Set reminder to be the user’s preferred reminder time if it is defined or to the default reminder time of 1.5 (hours) otherwise.
76
+ * 2. Use a switch statement on {@link BgLevel} to determine the appropriate reminder value to return:
77
+ * - If it is SevereHypoglycemia, Hypoglycemia, or MildHypoglycemia then return Reminder15Minutes.
78
+ * - If it is NormoglycemiaUnder5MMOL, Normoglycemia, MildHyperglycemia, or BGLevelNotProvided then return the value of reminder
79
+ * if the user entered carbohydrates or an activity, or ReminderOff otherwise.
80
+ * - If it is Hyperglycemia, or SevereHyperglycemia then return Reminder15Minutes if isActivityWithin15Minutes() given the activity
81
+ * is true and return Reminder60Minutes otherwise.
82
+ * - If none of the above conditions were triggered, throw a CurrentBGLError().
83
+ * @param bgLevel The severity category that the user’s current BGL belongs to.
84
+ * @param carbohydrates The amount of carbohydrates that the user is ingesting.
85
+ * @param userReminder The user’s preferred initial reminder time interval in hours.
86
+ * @param activity The activity that the user entered.
87
+ * @returns The initial value of the remeasurement reminder timer slider in hours {@link RecommendationReminders}.
88
+ */
89
+ export function getReminder(
90
+ bgLevel: BgLevel,
91
+ carbohydrates: number,
92
+ userReminder: number,
93
+ activity: BolusCalculator.Types.IActivityParams | null,
94
+ ): number {
95
+ const reminder = userReminder === undefined ? RecommendationReminders.HediaReminderDefault : userReminder;
96
+ switch (bgLevel) {
97
+ case BgLevel.SevereHypoglycemia:
98
+ case BgLevel.Hypoglycemia:
99
+ case BgLevel.MildHypoglycemia:
100
+ return RecommendationReminders.Reminder15Minutes;
101
+
102
+ case BgLevel.NormoglycemiaUnder5MMOL:
103
+ case BgLevel.Normoglycemia:
104
+ case BgLevel.MildHyperglycemia:
105
+ case BgLevel.BGLevelNotProvided:
106
+ return carbohydrates || activity ? reminder : RecommendationReminders.ReminderOff;
107
+
108
+ case BgLevel.Hyperglycemia:
109
+ case BgLevel.SevereHyperglycemia:
110
+ return isActivityWithin15Minutes(activity)
111
+ ? RecommendationReminders.Reminder15Minutes
112
+ : RecommendationReminders.Reminder60Minutes;
113
+
114
+ default:
115
+ throw CurrentBGLError();
116
+ }
117
+ }
118
+
119
+ /**
120
+ * Get the attention message that fits with the user’s entered blood glucose level and activity.
121
+ *
122
+ * Steps:
123
+ * 1. Use at switch statement on bgLevel to determine the appropriate action to take:
124
+ * - If it is BGLevelNotProvided, Normoglycemia, or MildHyperglycemia then return null.
125
+ * - If it is NormoglycemiaUnder5MMOL then do the following:
126
+ * - If an activity is going to start within 15 minuts as determined by isActivityWithin15Minutes() then return AttentionMessage.NormoglycemiaActivityUnder5MMOL().
127
+ * Otherwise return null.
128
+ * - If it is SevereHypoglycemia, Hypoglycemia, or MildHypoglycemia then do the following:
129
+ * - If an activity is going to start within 15 minuts as determined by isActivityWithin15Minutes() then
130
+ * return the AttentionMessage that corresponds to the bgLevel and append a message about postponing the activity using addPostponeActivityMessage().
131
+ * Otherwise return the AttentionMessage that corresponds to the {@link BgLevel} without further modification.
132
+ * - If it is Hyperglycemia then do the following:
133
+ * - If an activity is going to start within 15 minuts as determined by isActivityWithin15Minutes() then return AttentionMessage.HyperglycemiaActivity().
134
+ * Otherwise return null.
135
+ * - If it is SevereHyperglycemia then do the following:
136
+ * - If an activity is going to start within 15 minuts as determined by isActivityWithin15Minutes() then return AttentionMessage.SevereHyperglycemiaActivity().
137
+ * Otherwise return AttentionMessage.SevereHyperglycemia().
138
+ * - If none of the above conditions were triggered, throw a CurrentBGLError() {@link RecommendationError}.
139
+ * @param bgLevel The category of the user’s blood glucose level.
140
+ * @param activity The activity that the user entered
141
+ * @returns The appropriate attention message {@link AttentionMessage} to display to the user or null if there is no message to be displayed.
142
+ */
143
+ export function getAttentionMessage(
144
+ bgLevel: BgLevel,
145
+ activity: BolusCalculator.Types.IActivityParams | null,
146
+ ): string | null {
147
+ const key = Utils.getKeyFromValue(BgLevel, bgLevel);
148
+ const isAttentionMessageNull = AttentionMessage[key] === null;
149
+ const isWithin15Minutes = isActivityWithin15Minutes(activity);
150
+ switch (bgLevel) {
151
+ case BgLevel.BGLevelNotProvided:
152
+ case BgLevel.Normoglycemia:
153
+ case BgLevel.MildHyperglycemia:
154
+ return null;
155
+
156
+ case BgLevel.NormoglycemiaUnder5MMOL:
157
+ return isWithin15Minutes ? AttentionMessage.NormoglycemiaActivityUnder5MMOL() : null;
158
+
159
+ case BgLevel.SevereHypoglycemia:
160
+ case BgLevel.Hypoglycemia:
161
+ case BgLevel.MildHypoglycemia:
162
+ return isWithin15Minutes && !isAttentionMessageNull
163
+ ? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
164
+ addPostponeActivityMessageUnder5MMOL(AttentionMessage[key]!())
165
+ : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
166
+ AttentionMessage[key]!();
167
+
168
+ case BgLevel.Hyperglycemia:
169
+ return isWithin15Minutes ? AttentionMessage.HyperglycemiaActivity() : null;
170
+
171
+ case BgLevel.SevereHyperglycemia:
172
+ return isWithin15Minutes
173
+ ? AttentionMessage.SevereHyperglycemiaActivity()
174
+ : AttentionMessage.SevereHyperglycemia();
175
+ default:
176
+ throw CurrentBGLError();
177
+ }
178
+ }
179
+
180
+ /**
181
+ * Determine based on on the previously measured BGL if the hyperglycemia should be categorized as severe.
182
+ *
183
+ * Steps:
184
+ * 1. If the logbook is not null or undefined, return the result of comparing if the blood_glucose_millimolar property of latestLogbookFrom6Hours
185
+ * is strictly larger than the threshold for severe hyperglycemia (15) {@link Constants}.
186
+ * @param logbook The latest previous logbook entry - if any - from the past 6 hours.
187
+ * @returns True if the BGL from the previous logbook entry is above the threshold for severe hyperglycemia. False otherwise.
188
+ */
189
+ export function isSevereHyperglycemia(logbook?: Logbook.Types.ILogbookEntry | null): boolean {
190
+ if (logbook !== null && logbook !== undefined) {
191
+ const { blood_glucose_millimolar } = logbook;
192
+ if (blood_glucose_millimolar !== null) {
193
+ return blood_glucose_millimolar > SEVERE_HYPERGLYCEMIA_START_MMOL;
194
+ }
195
+ }
196
+
197
+ return false;
198
+ }
199
+
200
+ /**
201
+ * Determine whether an activity is either ongoing or is starting within 15 minutes from now.
202
+ *
203
+ * Steps:
204
+ * 1. Extract the duration from the activity.
205
+ * 2. Check if the start date of the activity was between duration minutes in the past or 15 minutes in the future and return the result.
206
+ * @param activity The activity whose start time should be checked.
207
+ * @returns Indication of whether the activity is ongoing or imminent.
208
+ */
209
+ export function isActivityWithin15Minutes(activity: BolusCalculator.Types.IActivityParams | null): boolean {
210
+ const minutes = activity?.activityDuration;
211
+ return moment
212
+ .utc(activity?.activityDate)
213
+ .isBetween(moment.utc().subtract(minutes, `minutes`), moment.utc().add(15, `minutes`));
214
+ }
215
+
216
+ /**
217
+ * The appropriate message for informing the user if the insulin recommendation was limited.
218
+ *
219
+ * Steps:
220
+ * 1. Set message to the return value of RecommendationWasLimitedActivity() if activityReduction is truthy or to the return value of RecommendationWasLimited() otherwise.
221
+ * 2. Return message if wasLimited is true or undefined otherwise.
222
+ * @param wasLimited Indicator of whether or not the user’s insulin recommendation was limited.
223
+ * @param activityReduction The fraction by which the insulin recommendation and the safety insulin limit has been reduced due to physical activity.
224
+ * @returns Callable that returns the appropriate message {@link Messages} for informing the user about the limitation.
225
+ * If no limitation message should be displayed to the user then null is returned.
226
+ */
227
+ export function getLimitationMessage(wasLimited: boolean, activityReduction: number | null): string | null {
228
+ const message = activityReduction
229
+ ? Messages.RecommendationWasLimitedActivity(activityReduction)
230
+ : Messages.RecommendationWasLimited();
231
+ return wasLimited ? message : null;
232
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Used for storing Record type objects that contains translations about certain settings that needs to be presented to the user.
3
+ * @module
4
+ */
5
+
6
+ import { Activity } from "@hedia/types";
7
+
8
+ import { t } from "../locales/translate";
9
+
10
+ /**
11
+ * Object used for storing the translations of a physical activity intensity in order to be presented to the user
12
+ */
13
+ export const ActivityIntensityTranslations: Record<Activity.Enums.ActivityIntensity, () => string> = {
14
+ light: (): string => t(`Light`),
15
+ moderate: (): string => t(`Moderate`),
16
+ hard: (): string => t(`Hard`),
17
+ };
@@ -0,0 +1,156 @@
1
+ import { BloodGlucoseUnit, BloodKetonesUnit, UserSettings } from "@hedia/types";
2
+
3
+ import { IInterval } from "../types/types";
4
+ import { MGDL_PER_MMOLL_BGL, MGDL_PER_MMOLL_BKL } from "./Constants";
5
+ const InjectionMethod = UserSettings.Enums.InjectionMethod;
6
+ const { PenHalf, PenWhole, Pump } = InjectionMethod;
7
+
8
+ /** Helper functions used for displaying data to the user. */
9
+ export class Utils {
10
+ /**
11
+ * Get the inverse of the precision to an insulin amount should be rounded based on the user’s injection method.
12
+ *
13
+ * Steps:
14
+ * 1. Use a switch statement to return the appropriate number depending on the value of the method argument:
15
+ * - If PenWhole, return 1.
16
+ * - If PenHalf, return 2.
17
+ * - If Pump, return 10.
18
+ * - Otherwise throw an exception.
19
+ * @param method The method by which the user injects insulin.
20
+ * @returns The inverse of the precision to which an insulin amount should be rounded based on the user’s injection method.
21
+ */
22
+ public static getRounding(method: UserSettings.Enums.InjectionMethod): number {
23
+ switch (method) {
24
+ case PenWhole:
25
+ return 1;
26
+
27
+ case PenHalf:
28
+ return 2;
29
+
30
+ case Pump:
31
+ return 10;
32
+
33
+ default:
34
+ throw Error(`Unsupported InjectionMethod: ${method}`);
35
+ }
36
+ }
37
+
38
+ /**
39
+ * Round an insulin amount to the precision that is dictated by the user’s injection method.
40
+ *
41
+ * Steps:
42
+ * 1. Get the inverse rounding precision by calling getRounding() with injectMethod as argument.
43
+ * 2. Return the rounded insulin amount calculated by the following operations:
44
+ * - Multiply the insulin value prop by the inverse rounding precision.
45
+ * - Round to the nearest whole number.
46
+ * - Divide by the inverse rounding precision and return the result.
47
+ * @param value The amount of insulin to be rounded.
48
+ * @param injectMethod The method by which the user injects insulin.
49
+ * @returns The rounded insulin amount.
50
+ */
51
+ public static roundValue(value: number, injectMethod: UserSettings.Enums.InjectionMethod): number {
52
+ const rounding: number = Utils.getRounding(injectMethod);
53
+ return Math.round(value * rounding) / rounding;
54
+ }
55
+
56
+ /**
57
+ * Determine whether a numerical value is in the given closed interval.
58
+ *
59
+ * Steps:
60
+ * 1. If value is null then return false. (Note that we only need to check explicitly for null comparing it
61
+ * to a number returns true while comparing undefined to a number returns false).
62
+ * 2. Evaluate whether value >= the interval argument’s min property && value <= the interval argument’s max property and return the result.
63
+ * @param value The number that will be checked for membership of the interval.
64
+ * @param interval The interval to compare the value to.
65
+ * @returns Boolean value indicating whether the value is in the closed interval.
66
+ */
67
+ public static isInRange(value: number | null, interval: IInterval): boolean {
68
+ if (value === null) {
69
+ return false;
70
+ }
71
+
72
+ return value >= interval.min && value <= interval.max;
73
+ }
74
+
75
+ /**
76
+ * Convert a blood glucose level value from mmol/L to mg/dL.
77
+ *
78
+ * Steps:
79
+ * 1. Return the result of rounding the product of multiplying value with MGDL_PER_MMOLL_BGL.
80
+ * @param value The blood glucose level value in mmol/L to be converted.
81
+ * @returns The blood glucose value in mg/dL that corresponds to the given value in mmol/L.
82
+ */
83
+ public static convertBGLToMGDL(value: number): number {
84
+ return Math.round(value * MGDL_PER_MMOLL_BGL);
85
+ }
86
+
87
+ /**
88
+ * Depending on the blood glucose unit passed, returns the value as a string or returns a stringified call to the convertBGLToMGDL method.
89
+ *
90
+ * Steps:
91
+ * 1. Using a ternary operator on the unit argument return the passed value argument in case unit is a MMOL_L.
92
+ * Otherwise, return a call to the convertBGLToMGDL method with the value passed as an argument.
93
+ * @param value The blood glucose level value in mmol/L to be converted.
94
+ * @param unit The blood glucose measurement unit.
95
+ * @returns The blood glucose value that will be displayed to the user.
96
+ */
97
+ public static displayedBGLValue(value: number, unit: BloodGlucoseUnit): string {
98
+ return unit === BloodGlucoseUnit.MMOL_L ? value.toFixed(1) : `${Utils.convertBGLToMGDL(value)}`;
99
+ }
100
+
101
+ /**
102
+ * Convert a blood ketones concentration from mmol/L to mg/dL.
103
+ * Steps:
104
+ * 1. Return the result of rounding the product of multiplying value with MGDL_PER_MMOLL_BKL.
105
+ * @param value The blood ketones concentration in mmol/L to be converted.
106
+ * @returns The blood ketones concentration in mg/dL that corresponds to the given value in mmol/L.
107
+ */
108
+ public static convertBKLToMGDL(value: number): number {
109
+ return Math.round(value * MGDL_PER_MMOLL_BKL);
110
+ }
111
+
112
+ /**
113
+ * Depending on the blood ketone unit passed, returns the value as a string or returns a call to the convertBKLToMGDL method.
114
+ *
115
+ * Steps:
116
+ * 1. Using a ternary operator on the unit argument return the passed value argument in case unit is a MMOL_L.
117
+ * Otherwise, return a call to the convertBKLToMGDL method with the value passed as an argument.
118
+ * @param value The blood ketone level value in mmol/L to be converted.
119
+ * @param unit The blood ketone measurement unit.
120
+ * @returns The blood ketone value that will be displayed to the user.
121
+ */
122
+ public static displayedBKLValue(value: number, unit: BloodKetonesUnit): string {
123
+ return unit === BloodKetonesUnit.MMOL_L ? value.toFixed(1) : `${Utils.convertBKLToMGDL(value)}`;
124
+ }
125
+
126
+ /**
127
+ * Format a measurement unit for displaying to the user. More concrete, it is used to display the litre symbol with uppercase "L".
128
+ *
129
+ * Steps:
130
+ * 1. Set unitWithoutLastLetter to be unit except for the last character.
131
+ * 2. Set lastLetterUppercase to be the last letter of unit converted to uppercase.
132
+ * 3. Return unitWithoutLastLetter concatenated with lastLetterUppercase.
133
+ * @param unit The measurement unit to format.
134
+ * @returns The measurement unit formatted for displaying to the user.
135
+ */
136
+ public static formatUnit = (unit: BloodGlucoseUnit | BloodKetonesUnit): string => {
137
+ const unitWithoutLastLetter = unit.substring(0, unit.length - 1);
138
+ const lastLetterUppercase = unit.substring(unit.length - 1, unit.length).toUpperCase();
139
+ return `${unitWithoutLastLetter}${lastLetterUppercase}`;
140
+ };
141
+
142
+ /**
143
+ * Returns the key of key/value object when passing the key value as argument.
144
+ *
145
+ * Steps:
146
+ * 1. Save all the values of the keys object into the values constant
147
+ * 2. From the array of keys, return the one at the index of the first occurence of the value in the values constant
148
+ * @param keys The keys of the T object.
149
+ * @param value The value for the requested key.
150
+ * @returns The key of the passed value.
151
+ */
152
+ public static getKeyFromValue<T extends object>(keys: T, value: T[keyof T]): keyof T {
153
+ const values = Object.values(keys);
154
+ return Object.keys(keys)[values.indexOf(value)] as keyof T;
155
+ }
156
+ }