@hedia/recommendation-screen 2.0.2 → 2.1.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 (114) hide show
  1. package/App.d.ts +2 -2
  2. package/coverage/clover.xml +700 -0
  3. package/coverage/coverage-final.json +28 -0
  4. package/coverage/lcov-report/base.css +224 -0
  5. package/coverage/lcov-report/block-navigation.js +79 -0
  6. package/coverage/lcov-report/favicon.png +0 -0
  7. package/coverage/lcov-report/index.html +201 -0
  8. package/coverage/lcov-report/prettify.css +1 -0
  9. package/coverage/lcov-report/prettify.js +2 -0
  10. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  11. package/coverage/lcov-report/sorter.js +170 -0
  12. package/coverage/lcov-report/src/RecommendationScreen.tsx.html +1460 -0
  13. package/coverage/lcov-report/src/__tests__/index.html +111 -0
  14. package/coverage/lcov-report/src/__tests__/utils.tsx.html +512 -0
  15. package/coverage/lcov-report/src/components/Header.tsx.html +347 -0
  16. package/coverage/lcov-report/src/components/InfoBars.tsx.html +404 -0
  17. package/coverage/lcov-report/src/components/InvisibleNumberInput.tsx.html +374 -0
  18. package/coverage/lcov-report/src/components/LimitationMessage.tsx.html +191 -0
  19. package/coverage/lcov-report/src/components/LineSeparator.tsx.html +152 -0
  20. package/coverage/lcov-report/src/components/RecentInsulin.tsx.html +383 -0
  21. package/coverage/lcov-report/src/components/RecommendationModal.tsx.html +737 -0
  22. package/coverage/lcov-report/src/components/RecommendedCarbs.tsx.html +857 -0
  23. package/coverage/lcov-report/src/components/RecommendedInsulin.tsx.html +605 -0
  24. package/coverage/lcov-report/src/components/Remeasure.tsx.html +440 -0
  25. package/coverage/lcov-report/src/components/TransferToLogbook.tsx.html +380 -0
  26. package/coverage/lcov-report/src/components/TwoOptionModal.tsx.html +635 -0
  27. package/coverage/lcov-report/src/components/activity/Activity.tsx.html +311 -0
  28. package/coverage/lcov-report/src/components/activity/ActivityIcon.tsx.html +242 -0
  29. package/coverage/lcov-report/src/components/activity/ActivityIntensity.tsx.html +257 -0
  30. package/coverage/lcov-report/src/components/activity/index.html +141 -0
  31. package/coverage/lcov-report/src/components/index.html +276 -0
  32. package/coverage/lcov-report/src/components/mood/Emotion.tsx.html +278 -0
  33. package/coverage/lcov-report/src/components/mood/MoodIcon.tsx.html +260 -0
  34. package/coverage/lcov-report/src/components/mood/index.html +126 -0
  35. package/coverage/lcov-report/src/index.html +111 -0
  36. package/coverage/lcov-report/src/locale/i18nUtils.ts.html +161 -0
  37. package/coverage/lcov-report/src/locale/index.html +111 -0
  38. package/coverage/lcov-report/src/utils/AttentionMessages.tsx.html +326 -0
  39. package/coverage/lcov-report/src/utils/Constants.ts.html +176 -0
  40. package/coverage/lcov-report/src/utils/RecommendationError.tsx.html +500 -0
  41. package/coverage/lcov-report/src/utils/RecommendationUtils.ts.html +467 -0
  42. package/coverage/lcov-report/src/utils/Translations.ts.html +107 -0
  43. package/coverage/lcov-report/src/utils/Utils.ts.html +263 -0
  44. package/coverage/lcov-report/src/utils/Validations.ts.html +815 -0
  45. package/coverage/lcov-report/src/utils/index.html +201 -0
  46. package/coverage/lcov.info +1581 -0
  47. package/jest.config.js +2 -1
  48. package/package.json +2 -2
  49. package/src/RecommendationScreen.d.ts +2 -3
  50. package/src/__tests__/components/Emotion.test.jsx +7 -8
  51. package/src/components/Icon.d.ts +13 -0
  52. package/src/components/Icon.jsx +42 -0
  53. package/src/components/LimitationMessage.d.ts +1 -2
  54. package/src/components/RecommendationModal.d.ts +2 -3
  55. package/src/components/RecommendationModal.jsx +2 -1
  56. package/src/components/activity/ActivityIntensity.jsx +4 -3
  57. package/src/utils/AttentionMessages.d.ts +16 -10
  58. package/src/utils/AttentionMessages.jsx +15 -10
  59. package/src/utils/RecommendationUtils.d.ts +2 -3
  60. package/src/utils/RecommendationUtils.js +10 -6
  61. package/src/utils/Utils.d.ts +1 -0
  62. package/src/utils/Utils.js +4 -0
  63. package/tsconfig.json +7 -5
  64. package/App.tsx +0 -140
  65. package/index.ts +0 -6
  66. package/src/RecommendationScreen.tsx +0 -461
  67. package/src/__tests__/RecommendationScreen.test.tsx +0 -1231
  68. package/src/__tests__/RecommendationUtils.test.ts +0 -332
  69. package/src/__tests__/Translate.test.tsx +0 -31
  70. package/src/__tests__/Utils.test.ts +0 -91
  71. package/src/__tests__/Validations.test.ts +0 -648
  72. package/src/__tests__/components/Activity.test.tsx +0 -163
  73. package/src/__tests__/components/Emotion.test.tsx +0 -110
  74. package/src/__tests__/components/Header.test.tsx +0 -44
  75. package/src/__tests__/components/InfoBars.test.tsx +0 -152
  76. package/src/__tests__/components/InvisibleNumberInput.test.tsx +0 -294
  77. package/src/__tests__/components/LimitationMessage.test.tsx +0 -58
  78. package/src/__tests__/components/MoodIcon.test.tsx +0 -45
  79. package/src/__tests__/components/RecommendationModal.test.tsx +0 -169
  80. package/src/__tests__/components/RecommendedCarbs.test.tsx +0 -234
  81. package/src/__tests__/components/RecommendedInsulin.test.tsx +0 -241
  82. package/src/__tests__/components/Remeasure.test.tsx +0 -97
  83. package/src/__tests__/components/TransferToLogbook.test.tsx +0 -38
  84. package/src/__tests__/components/TwoOptionModal.test.tsx +0 -72
  85. package/src/__tests__/utils.tsx +0 -144
  86. package/src/components/Header.tsx +0 -89
  87. package/src/components/Icon.js +0 -41
  88. package/src/components/InfoBars.tsx +0 -108
  89. package/src/components/InvisibleNumberInput.tsx +0 -98
  90. package/src/components/LimitationMessage.tsx +0 -38
  91. package/src/components/LineSeparator.tsx +0 -24
  92. package/src/components/RecentInsulin.tsx +0 -101
  93. package/src/components/RecommendationModal.tsx +0 -224
  94. package/src/components/RecommendedCarbs.tsx +0 -259
  95. package/src/components/RecommendedInsulin.tsx +0 -175
  96. package/src/components/Remeasure.tsx +0 -120
  97. package/src/components/TransferToLogbook.tsx +0 -100
  98. package/src/components/TwoOptionModal.tsx +0 -185
  99. package/src/components/activity/Activity.tsx +0 -77
  100. package/src/components/activity/ActivityIcon.tsx +0 -54
  101. package/src/components/activity/ActivityIntensity.tsx +0 -58
  102. package/src/components/mood/Emotion.tsx +0 -66
  103. package/src/components/mood/MoodIcon.tsx +0 -60
  104. package/src/locale/CleanLanguage.ts +0 -13
  105. package/src/locale/i18nUtils.ts +0 -27
  106. package/src/types/enum.ts +0 -108
  107. package/src/types/types.ts +0 -16
  108. package/src/utils/AttentionMessages.tsx +0 -75
  109. package/src/utils/Constants.ts +0 -32
  110. package/src/utils/RecommendationError.tsx +0 -140
  111. package/src/utils/RecommendationUtils.ts +0 -125
  112. package/src/utils/Translations.ts +0 -9
  113. package/src/utils/Utils.ts +0 -57
  114. package/src/utils/Validations.ts +0 -245
@@ -1,245 +0,0 @@
1
- import { Activity, BloodGlucoseUnit, BloodKetonesUnit, Languages, UserSettings } from "@hedia/types";
2
- import moment from "moment";
3
- import { IRecommendationProps } from "../RecommendationScreen";
4
- import { ActivitySettings, IActivityParams, IRecentBolus, IRecommendationParams, logbookEntry } from "../types/types";
5
- import {
6
- ACTIVITY_BUFFER_MINUTES,
7
- ACTIVITY_DURATION_MINUTES_LIMITS,
8
- ACTIVITY_SETTINGS_INTERVAL_LIMITS,
9
- ACTIVITY_TARGET_BGL_MMOL_LIMITS,
10
- BOLUS_SECONDS_PASSED_LIMITS,
11
- CARBOHYDRATES_LIMTS,
12
- CURRENT_BGL_MMOL_LIMITS,
13
- CURRENT_BKL_MMOL_LIMITS,
14
- INSULIN_DOSE_LIMITS,
15
- INSULIN_SENSITIVITY_MMOL_LIMITS,
16
- INSULIN_TO_CARBS_RATIO_LIMITS,
17
- ONE_HOUR_MINUTES,
18
- REMINDER_HOURS_LIMITS,
19
- TARGET_BGL_MMOL_LIMITS,
20
- } from "./Constants";
21
- import {
22
- ActivityDateError,
23
- ActivityDurationError,
24
- ActivityIntensityError,
25
- ActivitySettingsError,
26
- ActivityTargetBGLError,
27
- ActivityTypeError,
28
- BloodGlucoseUnitError,
29
- BloodKetoneUnitError,
30
- BolusInsulinDoseError,
31
- BolusInsulinSecondsPassedError,
32
- CarbohydrateLimitError,
33
- CurrentBGLError,
34
- CurrentBKLError,
35
- InjectionMethodError,
36
- InsulinSensitivityError,
37
- InsulinToCarbsRatioError,
38
- LanguageError,
39
- LatestLogbook6HoursBGLError,
40
- RecentBolusError,
41
- TargetBGLError,
42
- UserReminderError,
43
- } from "./RecommendationError";
44
- import { Utils } from "./Utils";
45
-
46
- const { hard } = Activity.Enums.ActivityIntensity;
47
- const { fromFortysix } = Activity.Enums.ActivityReductionIntervals;
48
-
49
- export function validateParams(props: IRecommendationProps): void {
50
- checkCalculatorParams(props.calculatorParams);
51
- checkBGLUnit(props.bloodGlucoseUnit);
52
-
53
- checkBKLUnit(props.bloodKetoneUnit);
54
- checkBloodKetoneLevel(props.currentBKL);
55
-
56
- checkInjectionMethod(props.injectionMethod);
57
- checkUserReminder(props.userReminder);
58
- checkLanguage(props.language);
59
- checkLatestLogbook6Hours(props.latestLogbookFrom6Hours);
60
- if (props?.calculatorParams?.activity && props?.activityDisplayProps) {
61
- checkActivityType(props.activityDisplayProps.activityType);
62
- }
63
- }
64
-
65
- export function checkLanguage(language: Languages): void {
66
- if (!Object.values(Languages).includes(language)) {
67
- throw LanguageError();
68
- }
69
- }
70
- export function checkLatestLogbook6Hours(logbook: logbookEntry | null): void {
71
- if (logbook === undefined) {
72
- throw LatestLogbook6HoursBGLError();
73
- }
74
- if (logbook !== null) {
75
- if (!Utils.isInRange(logbook.blood_glucose_millimolar, CURRENT_BGL_MMOL_LIMITS)) {
76
- throw LatestLogbook6HoursBGLError();
77
- }
78
- }
79
- }
80
-
81
- export function checkInjectionMethod(injectionMethod: UserSettings.Enums.InjectionMethod): void {
82
- const check = Object.values(UserSettings.Enums.InjectionMethod).some(
83
- (method): boolean => method === injectionMethod,
84
- );
85
- if (!check) {
86
- throw InjectionMethodError();
87
- }
88
- }
89
-
90
- export function checkBGLUnit(unit: BloodGlucoseUnit): void {
91
- const check = Object.values(BloodGlucoseUnit).some((enumUnit): boolean => enumUnit === unit);
92
- if (!check) {
93
- throw BloodGlucoseUnitError();
94
- }
95
- }
96
- export function checkBKLUnit(unit: BloodKetonesUnit): void {
97
- const check = Object.values(BloodKetonesUnit).some((enumUnit): boolean => enumUnit === unit);
98
- if (!check) {
99
- throw BloodKetoneUnitError();
100
- }
101
- }
102
-
103
- export function checkUserReminder(userReminder: number): void {
104
- if (!Utils.isInRange(userReminder, REMINDER_HOURS_LIMITS)) {
105
- throw UserReminderError();
106
- }
107
- }
108
-
109
- function checkCalculatorParams(calculatorParams: IRecommendationParams): void {
110
- checkActivity(calculatorParams.activity);
111
- checkCarbohydrates(calculatorParams.carbohydrates);
112
- checkCurrentBGL(calculatorParams.currentBGL);
113
- checkTargetBGL(calculatorParams.targetBGL);
114
- checkInsulinToCarbRatio(calculatorParams.carbohydrateRatio);
115
- checkInsulinSensitivity(calculatorParams.insulinSensitivity);
116
- checkRecentBolus(calculatorParams.recentBoluses);
117
- checkRecentBolusesInsulinDose(calculatorParams.recentBoluses);
118
- checkRecentBolusesSecondsPassed(calculatorParams.recentBoluses);
119
- }
120
-
121
- export function checkActivity(activity: IActivityParams | null): void {
122
- if (activity) {
123
- checkActivityDate(activity);
124
- checkActivityDuration(activity.activityDuration);
125
- checkActivityIntensity(activity.activityIntensity);
126
- checkActivitySettings(activity.activitySettings);
127
- checkActivityTargetBGL(activity.activitySettings.target);
128
- }
129
- }
130
-
131
- export function checkRecentBolus(recentBoluses: Array<IRecentBolus>): void {
132
- if (recentBoluses === null || recentBoluses === undefined) {
133
- throw RecentBolusError();
134
- }
135
- }
136
-
137
- export function checkRecentBolusesInsulinDose(recentBoluses: Array<IRecentBolus>): void {
138
- recentBoluses.forEach((bolus: IRecentBolus): void => {
139
- if (!Utils.isInRange(bolus.insulinDose, INSULIN_DOSE_LIMITS)) {
140
- throw BolusInsulinDoseError();
141
- }
142
- });
143
- }
144
-
145
- export function checkRecentBolusesSecondsPassed(recentBoluses: Array<IRecentBolus>): void {
146
- recentBoluses.forEach((bolus: IRecentBolus): void => {
147
- if (!Utils.isInRange(bolus.secondsPassed, BOLUS_SECONDS_PASSED_LIMITS)) {
148
- throw BolusInsulinSecondsPassedError();
149
- }
150
- });
151
- }
152
-
153
- export function checkActivityDuration(activityDuration: number): void {
154
- if (!Utils.isInRange(activityDuration, ACTIVITY_DURATION_MINUTES_LIMITS)) {
155
- throw ActivityDurationError();
156
- }
157
- }
158
-
159
- export function checkActivityIntensity(activityIntensity: Activity.Enums.ActivityIntensity): void {
160
- const check = Object.values(Activity.Enums.ActivityIntensity).some(
161
- (method): boolean => method === activityIntensity,
162
- );
163
- if (!check) {
164
- throw ActivityIntensityError();
165
- }
166
- }
167
-
168
- export function checkActivityType(activityType: Activity.Enums.ActivityEnum | null): void {
169
- const check = Object.values(Activity.Enums.ActivityEnum).some((method): boolean => method === activityType);
170
- if (!check) {
171
- throw ActivityTypeError();
172
- }
173
- }
174
-
175
- export function checkActivityDate(activity: IActivityParams): void {
176
- const maximumDate = moment
177
- .utc(activity.activityDate)
178
- .add(activity.activityDuration + ONE_HOUR_MINUTES * 4 + ACTIVITY_BUFFER_MINUTES, `minutes`);
179
- if (moment.utc().isAfter(maximumDate)) {
180
- throw ActivityDateError();
181
- }
182
- }
183
-
184
- export function checkActivitySettings(activitySettings: ActivitySettings): void {
185
- for (const intensity of Object.keys(activitySettings) as Array<Activity.Enums.ActivityIntensity>) {
186
- const reductionIntervals = activitySettings[intensity];
187
- for (const interval of Object.keys(reductionIntervals) as Array<keyof typeof reductionIntervals>) {
188
- const value = activitySettings[intensity][interval];
189
- const isInInterval: boolean = Utils.isInRange(value, ACTIVITY_SETTINGS_INTERVAL_LIMITS);
190
- if (intensity === hard && interval === fromFortysix) {
191
- if (!isInInterval && value !== null) {
192
- throw ActivitySettingsError();
193
- }
194
- } else if (!isInInterval) {
195
- throw ActivitySettingsError();
196
- }
197
- }
198
- }
199
- }
200
-
201
- export function checkActivityTargetBGL(activitySettingsTargetBGL: number): void {
202
- if (!Utils.isInRange(activitySettingsTargetBGL, ACTIVITY_TARGET_BGL_MMOL_LIMITS)) {
203
- throw ActivityTargetBGLError();
204
- }
205
- }
206
-
207
- export function checkCurrentBGL(currentBGL: number): void {
208
- if (currentBGL !== null) {
209
- if (!Utils.isInRange(currentBGL, CURRENT_BGL_MMOL_LIMITS)) {
210
- throw CurrentBGLError();
211
- }
212
- }
213
- }
214
-
215
- export function checkTargetBGL(targetBGL: number): void {
216
- if (!Utils.isInRange(targetBGL, TARGET_BGL_MMOL_LIMITS)) {
217
- throw TargetBGLError();
218
- }
219
- }
220
-
221
- export function checkBloodKetoneLevel(currentBKL: number): void {
222
- if (currentBKL !== null) {
223
- if (!Utils.isInRange(currentBKL, CURRENT_BKL_MMOL_LIMITS)) {
224
- throw CurrentBKLError();
225
- }
226
- }
227
- }
228
-
229
- export function checkInsulinSensitivity(insulinSensitivity: number): void {
230
- if (!Utils.isInRange(insulinSensitivity, INSULIN_SENSITIVITY_MMOL_LIMITS)) {
231
- throw InsulinSensitivityError();
232
- }
233
- }
234
-
235
- export function checkInsulinToCarbRatio(insulinToCarbRatio: number): void {
236
- if (!Utils.isInRange(insulinToCarbRatio, INSULIN_TO_CARBS_RATIO_LIMITS)) {
237
- throw InsulinToCarbsRatioError();
238
- }
239
- }
240
-
241
- export function checkCarbohydrates(carbohydrates: number): void {
242
- if (!Utils.isInRange(carbohydrates, CARBOHYDRATES_LIMTS)) {
243
- throw CarbohydrateLimitError();
244
- }
245
- }