@hedia/recommendation-screen 2.1.14 → 2.1.16

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 (102) hide show
  1. package/coverage/clover.xml +588 -590
  2. package/coverage/coverage-final.json +27 -27
  3. package/coverage/lcov-report/index.html +7 -7
  4. package/coverage/lcov-report/src/RecommendationScreen.tsx.html +1039 -70
  5. package/coverage/lcov-report/src/__tests__/index.html +1 -1
  6. package/coverage/lcov-report/src/__tests__/utils.tsx.html +35 -14
  7. package/coverage/lcov-report/src/components/Header.tsx.html +14 -5
  8. package/coverage/lcov-report/src/components/InfoBars.tsx.html +97 -13
  9. package/coverage/lcov-report/src/components/InvisibleNumberInput.tsx.html +206 -14
  10. package/coverage/lcov-report/src/components/LimitationMessage.tsx.html +20 -2
  11. package/coverage/lcov-report/src/components/LineSeparator.tsx.html +13 -4
  12. package/coverage/lcov-report/src/components/RecentInsulin.tsx.html +30 -3
  13. package/coverage/lcov-report/src/components/RecommendationModal.tsx.html +200 -20
  14. package/coverage/lcov-report/src/components/RecommendedCarbs.tsx.html +218 -20
  15. package/coverage/lcov-report/src/components/RecommendedInsulin.tsx.html +195 -27
  16. package/coverage/lcov-report/src/components/Remeasure.tsx.html +125 -14
  17. package/coverage/lcov-report/src/components/TransferToLogbook.tsx.html +71 -8
  18. package/coverage/lcov-report/src/components/TwoOptionModal.tsx.html +34 -10
  19. package/coverage/lcov-report/src/components/activity/Activity.tsx.html +58 -7
  20. package/coverage/lcov-report/src/components/activity/ActivityIcon.tsx.html +42 -3
  21. package/coverage/lcov-report/src/components/activity/ActivityIntensity.tsx.html +30 -6
  22. package/coverage/lcov-report/src/components/activity/index.html +1 -1
  23. package/coverage/lcov-report/src/components/index.html +10 -10
  24. package/coverage/lcov-report/src/components/mood/Emotion.tsx.html +85 -10
  25. package/coverage/lcov-report/src/components/mood/MoodIcon.tsx.html +87 -12
  26. package/coverage/lcov-report/src/components/mood/index.html +1 -1
  27. package/coverage/lcov-report/src/index.html +1 -1
  28. package/coverage/lcov-report/src/locale/i18nUtils.ts.html +47 -8
  29. package/coverage/lcov-report/src/locale/index.html +1 -1
  30. package/coverage/lcov-report/src/utils/AttentionMessages.tsx.html +235 -7
  31. package/coverage/lcov-report/src/utils/Constants.ts.html +71 -2
  32. package/coverage/lcov-report/src/utils/RecommendationError.tsx.html +89 -2
  33. package/coverage/lcov-report/src/utils/RecommendationUtils.ts.html +337 -40
  34. package/coverage/lcov-report/src/utils/Translations.ts.html +27 -3
  35. package/coverage/lcov-report/src/utils/Utils.ts.html +295 -19
  36. package/coverage/lcov-report/src/utils/Validations.ts.html +763 -61
  37. package/coverage/lcov-report/src/utils/index.html +1 -1
  38. package/coverage/lcov.info +1243 -1249
  39. package/ignore-git.sh +1 -0
  40. package/ignore-publish.sh +1 -0
  41. package/package.json +5 -3
  42. package/src/RecommendationScreen.d.ts +323 -6
  43. package/src/RecommendationScreen.js +234 -1
  44. package/src/__tests__/RecommendationScreen.test.js +35 -1
  45. package/src/__tests__/utils.d.ts +5 -5
  46. package/src/__tests__/utils.js +1 -1
  47. package/src/components/Header.d.ts +4 -43
  48. package/src/components/Header.js +3 -1
  49. package/src/components/Icon.d.ts +9 -2
  50. package/src/components/Icon.js +6 -1
  51. package/src/components/InfoBars.d.ts +28 -0
  52. package/src/components/InfoBars.js +23 -0
  53. package/src/components/InvisibleNumberInput.d.ts +66 -3
  54. package/src/components/InvisibleNumberInput.js +53 -0
  55. package/src/components/LimitationMessage.d.ts +6 -0
  56. package/src/components/LimitationMessage.js +4 -0
  57. package/src/components/LineSeparator.d.ts +4 -2
  58. package/src/components/LineSeparator.js +2 -0
  59. package/src/components/RecentInsulin.d.ts +10 -2
  60. package/src/components/RecentInsulin.js +7 -0
  61. package/src/components/RecommendationModal.d.ts +61 -3
  62. package/src/components/RecommendationModal.js +45 -0
  63. package/src/components/RecommendedCarbs.d.ts +71 -4
  64. package/src/components/RecommendedCarbs.js +56 -0
  65. package/src/components/RecommendedInsulin.d.ts +66 -4
  66. package/src/components/RecommendedInsulin.js +51 -5
  67. package/src/components/Remeasure.d.ts +38 -2
  68. package/src/components/Remeasure.js +31 -0
  69. package/src/components/TransferToLogbook.d.ts +23 -3
  70. package/src/components/TransferToLogbook.js +18 -0
  71. package/src/components/TwoOptionModal.d.ts +12 -1
  72. package/src/components/TwoOptionModal.js +3 -3
  73. package/src/components/activity/Activity.d.ts +21 -5
  74. package/src/components/activity/Activity.js +14 -0
  75. package/src/components/activity/ActivityIcon.d.ts +15 -0
  76. package/src/components/activity/ActivityIcon.js +14 -1
  77. package/src/components/activity/ActivityIntensity.d.ts +11 -4
  78. package/src/components/activity/ActivityIntensity.js +7 -0
  79. package/src/components/mood/Emotion.d.ts +26 -1
  80. package/src/components/mood/Emotion.js +20 -0
  81. package/src/components/mood/MoodIcon.d.ts +28 -2
  82. package/src/components/mood/MoodIcon.js +20 -2
  83. package/src/locale/i18nUtils.d.ts +13 -0
  84. package/src/locale/i18nUtils.js +13 -0
  85. package/src/types/enum.d.ts +10 -0
  86. package/src/types/enum.js +9 -0
  87. package/src/types/types.d.ts +9 -7
  88. package/src/utils/AttentionMessages.d.ts +65 -0
  89. package/src/utils/AttentionMessages.js +65 -1
  90. package/src/utils/Constants.d.ts +23 -0
  91. package/src/utils/Constants.js +23 -0
  92. package/src/utils/RecommendationError.d.ts +29 -0
  93. package/src/utils/RecommendationError.js +29 -0
  94. package/src/utils/RecommendationUtils.d.ts +98 -6
  95. package/src/utils/RecommendationUtils.js +92 -0
  96. package/src/utils/Translations.d.ts +7 -0
  97. package/src/utils/Translations.js +7 -0
  98. package/src/utils/Utils.d.ts +92 -0
  99. package/src/utils/Utils.js +94 -2
  100. package/src/utils/Validations.d.ts +232 -9
  101. package/src/utils/Validations.js +225 -2
  102. package/typedoc.json +13 -0
@@ -2,7 +2,20 @@ import { BloodGlucoseUnit, BloodKetonesUnit, UserSettings } from "@hedia/types";
2
2
  import { MGDL_PER_MMOLL_BGL, MGDL_PER_MMOLL_BKL } from "./Constants";
3
3
  const InjectionMethod = UserSettings.Enums.InjectionMethod;
4
4
  const { PenHalf, PenWhole, Pump } = InjectionMethod;
5
+ /** Helper functions used for displaying data to the user. */
5
6
  export class Utils {
7
+ /**
8
+ * Get the inverse of the precision to an insulin amount should be rounded based on the user’s injection method.
9
+ *
10
+ * Steps:
11
+ * 1. Use a switch statement to return the appropriate number depending on the value of the method argument:
12
+ * - If PenWhole, return 1.
13
+ * - If PenHalf, return 2.
14
+ * - If Pump, return 10.
15
+ * - Otherwise throw an exception.
16
+ * @param method The method by which the user injects insulin.
17
+ * @returns The inverse of the precision to which an insulin amount should be rounded based on the user’s injection method.
18
+ */
6
19
  static getRounding(method) {
7
20
  switch (method) {
8
21
  case PenWhole:
@@ -15,33 +28,112 @@ export class Utils {
15
28
  throw Error(`Unsupported InjectionMethod: ${method}`);
16
29
  }
17
30
  }
31
+ /**
32
+ * Round an insulin amount to the precision that is dictated by the user’s injection method.
33
+ *
34
+ * Steps:
35
+ * 1. Get the inverse rounding precision by calling getRounding() with injectMethod as argument.
36
+ * 2. Return the rounded insulin amount calculated by the following operations:
37
+ * - Multiply the insulin value prop by the inverse rounding precision.
38
+ * - Round to the nearest whole number.
39
+ * - Divide by the inverse rounding precision and return the result.
40
+ * @param value The amount of insulin to be rounded.
41
+ * @param injectMethod The method by which the user injects insulin.
42
+ * @returns The rounded insulin amount.
43
+ */
18
44
  static roundValue(value, injectMethod) {
19
45
  const rounding = Utils.getRounding(injectMethod);
20
46
  return Math.round(value * rounding) / rounding;
21
47
  }
48
+ /**
49
+ * Determine whether a numerical value is in the given closed interval.
50
+ *
51
+ * Steps:
52
+ * 1. If value is null then return false. (Note that we only need to check explicitly for null comparing it
53
+ * to a number returns true while comparing undefined to a number returns false).
54
+ * 2. Evaluate whether value >= the interval argument’s min property && value <= the interval argument’s max property and return the result.
55
+ * @param value The number that will be checked for membership of the interval.
56
+ * @param interval The interval to compare the value to.
57
+ * @returns Boolean value indicating whether the value is in the closed interval.
58
+ */
22
59
  static isInRange(value, interval) {
23
60
  if (value === null) {
24
61
  return false;
25
62
  }
26
63
  return value >= interval.min && value <= interval.max;
27
64
  }
65
+ /**
66
+ * Convert a blood glucose level value from mmol/L to mg/dL.
67
+ *
68
+ * Steps:
69
+ * 1. Return the result of rounding the product of multiplying value with MGDL_PER_MMOLL_BGL.
70
+ * @param value The blood glucose level value in mmol/L to be converted.
71
+ * @returns The blood glucose value in mg/dL that corresponds to the given value in mmol/L.
72
+ */
28
73
  static convertBGLToMGDL(value) {
29
74
  return Math.round(value * MGDL_PER_MMOLL_BGL);
30
75
  }
76
+ /**
77
+ * Depending on the blood glucose unit passed, returns the value as a string or returns a stringified call to the convertBGLToMGDL method.
78
+ *
79
+ * Steps:
80
+ * 1. Using a ternary operator on the unit argument return the passed value argument in case unit is a MMOL_L.
81
+ * Otherwise, return a call to the convertBGLToMGDL method with the value passed as an argument.
82
+ * @param value The blood glucose level value in mmol/L to be converted.
83
+ * @param unit The blood glucose measurement unit.
84
+ * @returns The blood glucose value that will be displayed to the user.
85
+ */
31
86
  static displayedBGLValue(value, unit) {
32
- return unit === BloodGlucoseUnit.MMOL_L ? `${value}` : `${Utils.convertBGLToMGDL(value)}`;
87
+ return unit === BloodGlucoseUnit.MMOL_L ? value.toFixed(1) : `${Utils.convertBGLToMGDL(value)}`;
33
88
  }
89
+ /**
90
+ * Convert a blood ketones concentration from mmol/L to mg/dL.
91
+ * Steps:
92
+ * 1. Return the result of rounding the product of multiplying value with MGDL_PER_MMOLL_BKL.
93
+ * @param value The blood ketones concentration in mmol/L to be converted.
94
+ * @returns The blood ketones concentration in mg/dL that corresponds to the given value in mmol/L.
95
+ */
34
96
  static convertBKLToMGDL(value) {
35
97
  return Math.round(value * MGDL_PER_MMOLL_BKL);
36
98
  }
99
+ /**
100
+ * Depending on the blood ketone unit passed, returns the value as a string or returns a call to the convertBKLToMGDL method.
101
+ *
102
+ * Steps:
103
+ * 1. Using a ternary operator on the unit argument return the passed value argument in case unit is a MMOL_L.
104
+ * Otherwise, return a call to the convertBKLToMGDL method with the value passed as an argument.
105
+ * @param value The blood ketone level value in mmol/L to be converted.
106
+ * @param unit The blood ketone measurement unit.
107
+ * @returns The blood ketone value that will be displayed to the user.
108
+ */
37
109
  static displayedBKLValue(value, unit) {
38
- return unit === BloodKetonesUnit.MMOL_L ? `${value}` : `${Utils.convertBKLToMGDL(value)}`;
110
+ return unit === BloodKetonesUnit.MMOL_L ? value.toFixed(1) : `${Utils.convertBKLToMGDL(value)}`;
39
111
  }
112
+ /**
113
+ * Returns the key of key/value object when passing the key value as argument.
114
+ *
115
+ * Steps:
116
+ * 1. Save all the values of the keys object into the values constant
117
+ * 2. From the array of keys, return the one at the index of the first occurence of the value in the values constant
118
+ * @param keys The keys of the T object.
119
+ * @param value The value for the requested key.
120
+ * @returns The key of the passed value.
121
+ */
40
122
  static getKeyFromValue(keys, value) {
41
123
  const values = Object.values(keys);
42
124
  return Object.keys(keys)[values.indexOf(value)];
43
125
  }
44
126
  }
127
+ /**
128
+ * Format a measurement unit for displaying to the user. More concrete, it is used to display the litre symbol with uppercase "L".
129
+ *
130
+ * Steps:
131
+ * 1. Set unitWithoutLastLetter to be unit except for the last character.
132
+ * 2. Set lastLetterUppercase to be the last letter of unit converted to uppercase.
133
+ * 3. Return unitWithoutLastLetter concatenated with lastLetterUppercase.
134
+ * @param unit The measurement unit to format.
135
+ * @returns The measurement unit formatted for displaying to the user.
136
+ */
45
137
  Utils.formatUnit = (unit) => {
46
138
  const unitWithoutLastLetter = unit.substring(0, unit.length - 1);
47
139
  const lastLetterUppercase = unit.substring(unit.length - 1, unit.length).toUpperCase();
@@ -1,27 +1,250 @@
1
- import { Activity, BloodGlucoseUnit, BloodKetonesUnit, Languages, UserSettings } from "@hedia/types";
1
+ /**
2
+ * The validations module contains functions for checking the integrity of every single value that is being passed in to the recommendation screen from the outside.
3
+ * If any of the individual integrity checks fails, then an exception will be thrown to indicate that the data that was passed in is untrustworthy
4
+ * and prevent a recommendation to be shown to the user based on the corrupted data.
5
+ * @module
6
+ */
7
+ import { Activity, BloodGlucoseUnit, BloodKetonesUnit, BolusCalculator, Languages, Logbook, UserSettings } from "@hedia/types";
2
8
  import { IRecommendationProps } from "../RecommendationScreen";
3
- import { ActivitySettings, IActivityParams, IRecentBolus, logbookEntry } from "../types/types";
9
+ /**
10
+ * Main function for validating all input properties for the insulin recommendation screen component.
11
+ * Throws an exception if any of the individual checks fail.
12
+ *
13
+ * Steps:
14
+ * 1. Call checkCalculatorParams() with the calculatorParams property of the props as argument.
15
+ * 2. Call checkBGLUnit() with the bloodGlucoseUnit property of the props as argument.
16
+ * 3. Call checkBKProps() with the bloodKetoneUnit and currentBKL properties of the props as arguments.
17
+ * 4. Call checkBKLUnit() with the bloodKetoneUnit property of the props as argument.
18
+ * 5. Call checkBloodKetoneLevel() with the currentBKL property of the props as argument.
19
+ * 6. Call checkInjectionMethod() with the injectionMethod property of the props as argument.
20
+ * 7. Call checkUserReminder() with the userReminder property of the props as argument.
21
+ * 8. Call checkLanguage() with the language property of the props as argument.
22
+ * 9. Call checkLatestLogbook6Hours() with the latestLogbookFrom6Hours property of the props as argument.
23
+ * 10. If the activity property of the calculatorParams prop is truthy, and the activityDisplayProps prop is truthy:
24
+ * call the checkActivityType method with the activityType property of the activityDisplayProps prop as the argument.
25
+ * @param props All the props that were passed in to the RecommendationScreen component.
26
+ */
4
27
  export declare function validateParams(props: IRecommendationProps): void;
28
+ /**
29
+ * In case the users is providing a blood ketone current level, check if the blood ketone unit is defined.
30
+ *
31
+ * Steps:
32
+ * 1. If the currentBKL is not null and the bloodKetoneUnit is null throw an BloodKetonePropsError
33
+ * @param bloodKetoneUnit The user’s blood ketone unit.
34
+ * @param currentBKL The users’s current blood ketone level.
35
+ */
5
36
  export declare function checkBKProps(bloodKetoneUnit: BloodKetonesUnit | null, currentBKL: number | null): void;
37
+ /**
38
+ * The user’s preferred language for using the app.
39
+ *
40
+ * Steps:
41
+ * 1. Search in the Languages enum values the language provided as an argument.
42
+ * If language is not present in the Languages enum values array, throw a LanguageError.
43
+ * @param language The user’s preferred language for using the app.
44
+ */
6
45
  export declare function checkLanguage(language: Languages): void;
7
- export declare function checkLatestLogbook6Hours(logbook: logbookEntry | null): void;
46
+ /**
47
+ * Check if the latest logbook from the last 6 hours is valid.
48
+ *
49
+ * Steps:
50
+ * 1. If logbook is undefined, throw an LatestLogbook6HoursBGLError.
51
+ * 2. If logbook is not null and if the blood_glucose_millimolar property of the logbook object is not null,
52
+ * check if the blood_glucose_millimolar is inside the allowed range for blood glucose level.
53
+ * If it is not, throw LatestLogbook6HoursBGLError.
54
+ * @param logbook The user’s latest logbook from the last 6 hours
55
+ */
56
+ export declare function checkLatestLogbook6Hours(logbook: Logbook.Types.ILogbookEntry | null): void;
57
+ /**
58
+ * Check if the injectionMethod parameter is valid.
59
+ *
60
+ * Steps:
61
+ * 1. Search in the InjectionMethod enum values the injectionMethod provided as an argument.
62
+ * If injectionMethod is not present in the InjectionMethod enum values array, throw a InjectionMethodError.
63
+ * @param injectionMethod The user’s insulin injection method.
64
+ */
8
65
  export declare function checkInjectionMethod(injectionMethod: UserSettings.Enums.InjectionMethod): void;
66
+ /**
67
+ * Check if the blood glucose unit parameter is valid.
68
+ * Steps:
69
+ * 1. Search in the BloodGlucoseUnit enum values the unit provided as an argument.
70
+ * If unit is not present in the BloodGlucoseUnit enum values array, throw a BloodGlucoseUnitError.
71
+ * @param unit The user’s preferred blood glucose unit for using the app.
72
+ */
9
73
  export declare function checkBGLUnit(unit: BloodGlucoseUnit): void;
74
+ /**
75
+ * Check if the blood ketones unit parameter is valid.
76
+ *
77
+ * Steps:
78
+ * 1. If the unit is not null, search in the BloodKetonesUnit enum values the unit provided as an argument.
79
+ * If unit is not present in the BloodKetonesUnit enum values array, throw a BloodKetoneUnitError.
80
+ * @param unit The user’s preferred blood ketones unit for using the app.
81
+ * It can be null if the user did not choose a measurement unit at the moment of this validation.
82
+ */
10
83
  export declare function checkBKLUnit(unit: BloodKetonesUnit | null): void;
84
+ /**
85
+ * Check if the users preferred default reminder duration is valid by verifying that it is within the allowed range.
86
+ *
87
+ * Steps:
88
+ * 1. Use isInRange() {@link Utils} to check if userReminder is in the interval [0; 6]. If it isn’t then throw an UserReminderError().
89
+ * @param userReminder The default reminder time in hours from the user’s settings
90
+ */
11
91
  export declare function checkUserReminder(userReminder: number): void;
12
- export declare function checkActivity(activity: IActivityParams | null): void;
13
- export declare function checkRecentBolus(recentBoluses: Array<IRecentBolus>): void;
14
- export declare function checkRecentBolusesInsulinDose(recentBoluses: Array<IRecentBolus>): void;
15
- export declare function checkRecentBolusesSecondsPassed(recentBoluses: Array<IRecentBolus>): void;
92
+ /**
93
+ * Check validity of the values that are used as input for the actual insulin recommendation calculation.
94
+ *
95
+ * Steps:
96
+ * 1. Call checkActivity() with the activity property of the calculatorParams as argument.
97
+ * 2. Call checkCarbohydrates() with the carbohydrates property of the calculatorParams as argument.
98
+ * 3. Call checkCurrentBGL() with the currentBGL property of the calculatorParams as argument.
99
+ * 4. Call checkTargetBGL() with the targetBGL property of the calculatorParams as argument.
100
+ * 5. Call checkInsulinToCarbRatio() with the carbohydrateRatio property of the calculatorParams as argument.
101
+ * 6. Call checkInsulinSensitivity() with the insulinSensitivity property of the calculatorParams as argument.
102
+ * 7. Call checkRecentBolus() with the recentBoluses property of the calculatorParams as argument.
103
+ * 8. Call checkRecentBolusesInsulinDose() with the recentBoluses property of the calculatorParams as argument.
104
+ * 9. Call checkRecentBolusesSecondsPassed() with the recentBoluses property of the calculatorParams as argument.
105
+ * @param calculatorParams The inputs for calculation to be checked
106
+ */
107
+ export declare function checkCalculatorParams(calculatorParams: BolusCalculator.Types.IRecommendationParams): void;
108
+ /**
109
+ * Check the validity of the values inputted for physical activity
110
+ *
111
+ * Steps:
112
+ * 1. If the activity argument is truthy do the following:
113
+ * - Call checkActivityDate() with the activity as argument
114
+ * - Call checkActivityDuration() with the activityDuration property of the activity as argument
115
+ * - Call checkActivityIntensity() with the activityIntensity property of the activity as argument
116
+ * - Call checkActivitySettings() with the activitySettings property of the activity as argument
117
+ * - Call checkActivityTargetBGL() with the activitySettings.target property of the activity as argument
118
+ * @param activity The activity that is associated with the calculation, or null if no activity was entered
119
+ */
120
+ export declare function checkActivity(activity: BolusCalculator.Types.IActivityParams | null): void;
121
+ /**
122
+ * Check if the recentBoluses is in the right format.
123
+ *
124
+ * Steps:
125
+ * 1. If recentBoluses is null or undefined throw a RecentBolusError.
126
+ * @param recentBoluses List of all known bolus injections from the past 4 hours including insulin amount and how many seconds has passed since the injection.
127
+ */
128
+ export declare function checkRecentBolus(recentBoluses: Array<BolusCalculator.Types.IRecentBolus>): void;
129
+ /**
130
+ * Check if the insulin dose in each of the given recent insulin injections is valid by verifying that they are within the allowed range.
131
+ *
132
+ * Steps
133
+ * 1. If recentBoluses isn’t null, for each bolus element in recentBoluses
134
+ * use isInRange() to check if the insulinDose parameter of the bolus element is in the interval [0; 50].
135
+ * If it isn’t then throw an BolusInsulinDoseError().
136
+ * @param recentBoluses List of all known bolus injections from the past 4 hours including insulin amount and how many seconds has passed since the injection.
137
+ */
138
+ export declare function checkRecentBolusesInsulinDose(recentBoluses: Array<BolusCalculator.Types.IRecentBolus>): void;
139
+ /**
140
+ * Check if the amount of time since each recent insulin injection is valid by verifying that they are within the allowed range.
141
+ *
142
+ * Steps:
143
+ * 1. If recentBoluses isn’t null, for each bolus element in recentBoluses
144
+ * use isInRange() to check if the secondsPassed parameter of the bolus element is in the interval [0; 1440].
145
+ * If it isn’t then throw an BolusInsulinSecondsPassedError().
146
+ * @param recentBoluses List of all known bolus injections from the past 4 hours including insulin amount and how many seconds has passed since the injection.
147
+ */
148
+ export declare function checkRecentBolusesSecondsPassed(recentBoluses: Array<BolusCalculator.Types.IRecentBolus>): void;
149
+ /**
150
+ * Check if the duration of an entered activity is valid by verifying that it is within the allowed range.
151
+ *
152
+ * Steps:
153
+ * 1. Use isInRange() to check if activityDuration is in the interval [0; 60]. If it isn’t then throw an ActivityDurationError().
154
+ * @param activityDuration The duration of an entered physical activity in minutes.
155
+ */
16
156
  export declare function checkActivityDuration(activityDuration: number): void;
157
+ /**
158
+ * Check if the activity intensity parameter is valid.
159
+ *
160
+ * Steps:
161
+ * 1. Search in the {@link ActivityIntensity} enum values the activityIntensity provided as an argument.
162
+ * If activityIntensity is not present in the ActivityIntensity enum values array, throw an ActivityIntensityError.
163
+ * @param activityIntensity The intensity of the entered activity.
164
+ */
17
165
  export declare function checkActivityIntensity(activityIntensity: Activity.Enums.ActivityIntensity): void;
166
+ /**
167
+ * Check if the activity type parameter is valid.
168
+ *
169
+ * Steps:
170
+ * 1. Search in the {@link ActivityEnum} enum values the activityType provided as an argument.
171
+ * If activityType is not present in the ActivityEnum enum values array, throw an ActivityTypeError.
172
+ * @param activityType The type of the entered activity.
173
+ */
18
174
  export declare function checkActivityType(activityType: Activity.Enums.ActivityEnum | null): void;
19
- export declare function checkActivityDate(activity: IActivityParams): void;
20
- export declare function checkActivitySettings(activitySettings: ActivitySettings): void;
175
+ /**
176
+ * Verify that the ending time of the given activity has not been passed by more than 4 hours and 10 minutes.
177
+ *
178
+ * Steps:
179
+ * 1. Use the moment library to create an object that represents the start time of the activity by loading from the activityDate property of the activity argument.
180
+ * Add to the object the duration of the activity plus 4 hours and 10 minutes and save the resulting date as maximumDate.
181
+ * 2. Check if the current time is after maximumDate throw an ActivityDateError().
182
+ * @param activity The activity for which we want to check the date
183
+ */
184
+ export declare function checkActivityDate(activity: BolusCalculator.Types.IActivityParams): void;
185
+ /**
186
+ * Steps:
187
+ * 1. Iterate over all combinations of activity intensities and activity duration intervals and for each one:
188
+ * - If the current intensity is hard and the duration is long (fromFortysix) then check that the value from activitySettings
189
+ * for the current combination of activity intensity is either null or in the interval [0; 1]
190
+ * - If the current intensity isn’t hard or the duration isn’t long then use isInRange() to check that the value from activitySettings
191
+ * for the current combination of activity intensity is in the interval [0; 1].
192
+ * @param activitySettings The user’s settings for doing physical activity
193
+ */
194
+ export declare function checkActivitySettings(activitySettings: Activity.Types.ActivitySettings): void;
195
+ /**
196
+ * Check if the target blood glucose level for doing exercise is valid by verifying that it is within the allowed range.
197
+ *
198
+ * Steps:
199
+ * 1. Use isInRange() to check if activitySettingsTargetBGL is in the interval [5.0; 13.9]. If it isn’t then throw an ActivityTargetBGLError().
200
+ * @param activitySettingsTargetBGL The target blood glucose level for doing exercise in mmol/L from the user’s settings.
201
+ */
21
202
  export declare function checkActivityTargetBGL(activitySettingsTargetBGL: number): void;
203
+ /**
204
+ * Check if the current blood glucose level is valid by verifying that it is either null or within the allowed range.
205
+ * Steps:
206
+ * 1. If currentBGL is not null then use isInRange() to check if currentBGL is in the interval [1.1; 33.3].
207
+ * If it isn’t then throw a CurrentBGLError().
208
+ * @param currentBGL The current blood glucose level in mmol/L entered by the user, or null to indicate that the value is unknown because it wasn’t given.
209
+ */
22
210
  export declare function checkCurrentBGL(currentBGL: number | null): void;
211
+ /**
212
+ * Check if the target blood glucose level is valid by verifying that it is within the allowed range.
213
+ *
214
+ * Steps:
215
+ * 1. Use isInRange() to check if targetBGL is in the interval [5.0; 13.9]. If it isn’t then throw a TargetBGLError().
216
+ * @param targetBGL The target blood glucose level in mmol/L extracted from the user’s settings depending on the time of day.
217
+ */
23
218
  export declare function checkTargetBGL(targetBGL: number): void;
219
+ /**
220
+ * Check if the current blood ketones concentration is valid by verifying that it is either null or within the allowed range.
221
+ *
222
+ * Steps:
223
+ * 1. If currentBKL is not null then use isInRange() to check if currentBGL is in the interval [0.0; 8.0]. If it isn’t then throw a CurrentBKLError().
224
+ * @param currentBKL The current blood ketones concentration in mmol/L entered by the user, or null to indicate that the value is unknown because it wasn’t given.
225
+ */
24
226
  export declare function checkBloodKetoneLevel(currentBKL: number | null): void;
227
+ /**
228
+ * Check if the insulin sensitivity is valid by verifying that it is within the allowed range.
229
+ *
230
+ * Steps:
231
+ * 1. Use isInRange() to check if insulinSensitivity is in the interval [0.3; 10]. If it isn’t then throw an InsulinSensitivityError().
232
+ * @param insulinSensitivity The insulin sensitivity in (mmol/L)/IU extracted from the user’s settings depending on the time of day.
233
+ */
25
234
  export declare function checkInsulinSensitivity(insulinSensitivity: number): void;
235
+ /**
236
+ * Check if the insulin-to-carbs ratio is valid by verifying that it is within the allowed range.
237
+ *
238
+ * Steps:
239
+ * 1. Use isInRange() to check if insulinToCarbRatio is in the interval [1; 50]. If it isn’t then throw an InsulinToCarbsRatioError().
240
+ * @param insulinToCarbRatio The insulin-to-carbs ratio in g/IU extracted from the user’s settings depending on the time of day.
241
+ */
26
242
  export declare function checkInsulinToCarbRatio(insulinToCarbRatio: number): void;
243
+ /**
244
+ * Check if the entered amount of carbohydrates is valid by verifying that it is within the allowed range.
245
+ *
246
+ * Steps:
247
+ * 1. Use isInRange() to check if carbohydrates is in the interval [0; 300]. If it isn’t then throw a CarbohydrateLimitError().
248
+ * @param carbohydrates The amount of carbohydrates that the user is eating in grams.
249
+ */
27
250
  export declare function checkCarbohydrates(carbohydrates: number): void;