@hedia/recommendation-screen 2.1.15 → 2.1.17-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish-alpha.yaml +58 -0
- package/.github/workflows/publish.yml +3 -0
- package/coverage/clover.xml +586 -588
- package/coverage/coverage-final.json +27 -27
- package/coverage/lcov-report/index.html +7 -7
- package/coverage/lcov-report/src/RecommendationScreen.tsx.html +979 -10
- package/coverage/lcov-report/src/__tests__/index.html +1 -1
- package/coverage/lcov-report/src/__tests__/utils.tsx.html +29 -8
- package/coverage/lcov-report/src/components/Header.tsx.html +13 -4
- package/coverage/lcov-report/src/components/InfoBars.tsx.html +86 -2
- package/coverage/lcov-report/src/components/InvisibleNumberInput.tsx.html +196 -4
- package/coverage/lcov-report/src/components/LimitationMessage.tsx.html +20 -2
- package/coverage/lcov-report/src/components/LineSeparator.tsx.html +12 -3
- package/coverage/lcov-report/src/components/RecentInsulin.tsx.html +30 -3
- package/coverage/lcov-report/src/components/RecommendationModal.tsx.html +184 -4
- package/coverage/lcov-report/src/components/RecommendedCarbs.tsx.html +205 -7
- package/coverage/lcov-report/src/components/RecommendedInsulin.tsx.html +187 -19
- package/coverage/lcov-report/src/components/Remeasure.tsx.html +114 -3
- package/coverage/lcov-report/src/components/TransferToLogbook.tsx.html +67 -4
- package/coverage/lcov-report/src/components/TwoOptionModal.tsx.html +34 -10
- package/coverage/lcov-report/src/components/activity/Activity.tsx.html +58 -7
- package/coverage/lcov-report/src/components/activity/ActivityIcon.tsx.html +42 -3
- package/coverage/lcov-report/src/components/activity/ActivityIntensity.tsx.html +30 -6
- package/coverage/lcov-report/src/components/activity/index.html +1 -1
- package/coverage/lcov-report/src/components/index.html +10 -10
- package/coverage/lcov-report/src/components/mood/Emotion.tsx.html +78 -3
- package/coverage/lcov-report/src/components/mood/MoodIcon.tsx.html +80 -5
- package/coverage/lcov-report/src/components/mood/index.html +1 -1
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/locale/i18nUtils.ts.html +41 -2
- package/coverage/lcov-report/src/locale/index.html +1 -1
- package/coverage/lcov-report/src/utils/AttentionMessages.tsx.html +231 -3
- package/coverage/lcov-report/src/utils/Constants.ts.html +71 -2
- package/coverage/lcov-report/src/utils/RecommendationError.tsx.html +89 -2
- package/coverage/lcov-report/src/utils/RecommendationUtils.ts.html +306 -9
- package/coverage/lcov-report/src/utils/Translations.ts.html +27 -3
- package/coverage/lcov-report/src/utils/Utils.ts.html +278 -2
- package/coverage/lcov-report/src/utils/Validations.ts.html +716 -14
- package/coverage/lcov-report/src/utils/index.html +1 -1
- package/coverage/lcov.info +1158 -1164
- package/ignore-git.sh +1 -0
- package/ignore-publish.sh +1 -0
- package/package.json +5 -3
- package/pre-release.sh +5 -0
- package/src/RecommendationScreen.d.ts +323 -6
- package/src/RecommendationScreen.js +234 -1
- package/src/__tests__/RecommendationScreen.test.js +1 -1
- package/src/__tests__/utils.d.ts +5 -5
- package/src/__tests__/utils.js +1 -1
- package/src/components/Header.d.ts +4 -43
- package/src/components/Header.js +3 -1
- package/src/components/Icon.d.ts +9 -2
- package/src/components/Icon.js +6 -1
- package/src/components/InfoBars.d.ts +28 -0
- package/src/components/InfoBars.js +23 -0
- package/src/components/InvisibleNumberInput.d.ts +66 -3
- package/src/components/InvisibleNumberInput.js +53 -0
- package/src/components/LimitationMessage.d.ts +6 -0
- package/src/components/LimitationMessage.js +4 -0
- package/src/components/LineSeparator.d.ts +4 -2
- package/src/components/LineSeparator.js +2 -0
- package/src/components/RecentInsulin.d.ts +10 -2
- package/src/components/RecentInsulin.js +7 -0
- package/src/components/RecommendationModal.d.ts +61 -3
- package/src/components/RecommendationModal.js +45 -0
- package/src/components/RecommendedCarbs.d.ts +71 -4
- package/src/components/RecommendedCarbs.js +56 -0
- package/src/components/RecommendedInsulin.d.ts +66 -4
- package/src/components/RecommendedInsulin.js +51 -5
- package/src/components/Remeasure.d.ts +38 -2
- package/src/components/Remeasure.js +31 -0
- package/src/components/TransferToLogbook.d.ts +23 -3
- package/src/components/TransferToLogbook.js +18 -0
- package/src/components/TwoOptionModal.d.ts +12 -1
- package/src/components/TwoOptionModal.js +3 -3
- package/src/components/activity/Activity.d.ts +21 -5
- package/src/components/activity/Activity.js +14 -0
- package/src/components/activity/ActivityIcon.d.ts +15 -0
- package/src/components/activity/ActivityIcon.js +14 -1
- package/src/components/activity/ActivityIntensity.d.ts +11 -4
- package/src/components/activity/ActivityIntensity.js +7 -0
- package/src/components/mood/Emotion.d.ts +26 -1
- package/src/components/mood/Emotion.js +20 -0
- package/src/components/mood/MoodIcon.d.ts +28 -2
- package/src/components/mood/MoodIcon.js +20 -2
- package/src/locale/i18nUtils.d.ts +13 -0
- package/src/locale/i18nUtils.js +13 -0
- package/src/types/enum.d.ts +10 -0
- package/src/types/enum.js +9 -0
- package/src/types/types.d.ts +9 -7
- package/src/utils/AttentionMessages.d.ts +65 -0
- package/src/utils/AttentionMessages.js +65 -1
- package/src/utils/Constants.d.ts +23 -0
- package/src/utils/Constants.js +23 -0
- package/src/utils/RecommendationError.d.ts +29 -0
- package/src/utils/RecommendationError.js +29 -0
- package/src/utils/RecommendationUtils.d.ts +98 -6
- package/src/utils/RecommendationUtils.js +92 -0
- package/src/utils/Translations.d.ts +7 -0
- package/src/utils/Translations.js +7 -0
- package/src/utils/Utils.d.ts +92 -0
- package/src/utils/Utils.js +92 -0
- package/src/utils/Validations.d.ts +232 -9
- package/src/utils/Validations.js +225 -2
- package/typedoc.json +13 -0
package/src/utils/Constants.js
CHANGED
|
@@ -1,24 +1,47 @@
|
|
|
1
1
|
import { BolusCalculator } from "@hedia/types";
|
|
2
|
+
/** Reusable color definition. */
|
|
2
3
|
export const BACKGROUND_COLOUR_PURPLE = `rgba(27, 31, 72, 1)`;
|
|
4
|
+
/** Reusable color definition. */
|
|
3
5
|
export const BORDER_COLOUR_GREY = `rgba(74, 91, 134, 1)`;
|
|
6
|
+
/** Reusable color definition. */
|
|
4
7
|
export const BORDER_COLOUR_TEAL = `rgba(1, 255, 252, 0.8)`;
|
|
8
|
+
/** The threshold above which hyperglycemia is considered to be severe in mmol/L */
|
|
5
9
|
export const SEVERE_HYPERGLYCEMIA_START_MMOL = 15;
|
|
10
|
+
/** The number of seconds in four hours. */
|
|
6
11
|
export const FOUR_HOURS_SECONDS = 14400;
|
|
12
|
+
/** The number of minutes in one hour. */
|
|
7
13
|
export const ONE_HOUR_MINUTES = 60;
|
|
14
|
+
/** Extra time before an activity starts or stops. */
|
|
8
15
|
export const ACTIVITY_BUFFER_MINUTES = 10;
|
|
16
|
+
/** The lower and upper limits for the amount of carbohydrates in grams. */
|
|
9
17
|
export const CARBOHYDRATES_LIMTS = { min: 0, max: 300 };
|
|
18
|
+
/** The lower and upper limits for the insulin dose in units. The upper limit is represented by the SAFETY_INSULIN_LIMIT constant while the lower limit is 0. */
|
|
10
19
|
export const INSULIN_DOSE_LIMITS = { min: 0, max: BolusCalculator.Constants.SAFETY_INSULIN_LIMIT };
|
|
20
|
+
/** The lower and upper limits for the age of boluses that gets taken into account for calculating insulin on board. */
|
|
11
21
|
export const BOLUS_SECONDS_PASSED_LIMITS = { min: 0, max: FOUR_HOURS_SECONDS };
|
|
22
|
+
/** The lower and upper limits for the duration of an activity in minutes. */
|
|
12
23
|
export const ACTIVITY_DURATION_MINUTES_LIMITS = { min: 1, max: ONE_HOUR_MINUTES };
|
|
24
|
+
/** The lower and upper limits of insulin sensitivity settings. */
|
|
13
25
|
export const INSULIN_SENSITIVITY_MMOL_LIMITS = { min: 0.3, max: 10 };
|
|
26
|
+
/** The lower and upper limits of insulin-to-carbs ratio settings. */
|
|
14
27
|
export const INSULIN_TO_CARBS_RATIO_LIMITS = { min: 1, max: 50 };
|
|
28
|
+
/** The lower and upper limits of the entered blood glucose level value in mmol/L. */
|
|
15
29
|
export const CURRENT_BGL_MMOL_LIMITS = { min: 1.1, max: 33.3 };
|
|
30
|
+
/** The conversion factor to multiply a blood glucose value with to go from mmol/L to mg/dL. */
|
|
16
31
|
export const MMOLL_PER_MGDL_BGL = 0.0555;
|
|
32
|
+
/** The conversion factor to multiply a blood glucose value with to go from mg/dL to mmol/L. */
|
|
17
33
|
export const MGDL_PER_MMOLL_BGL = 1 / MMOLL_PER_MGDL_BGL;
|
|
34
|
+
/** The lower and upper limits of the entered blood ketones value in mmol/L. */
|
|
18
35
|
export const CURRENT_BKL_MMOL_LIMITS = { min: 0, max: 8 };
|
|
36
|
+
/** The conversion factor to multiply a blood ketones value with to go from mmol/L to mg/dL. */
|
|
19
37
|
export const MMOLL_PER_MGDL_BKL = 0.096;
|
|
38
|
+
/** The conversion factor to multiply a blood ketones value with to go from mg/dL to mmol/L. */
|
|
20
39
|
export const MGDL_PER_MMOLL_BKL = 1 / MMOLL_PER_MGDL_BKL;
|
|
40
|
+
/** The lower and upper limits for a valid BGL target in mmol/L. */
|
|
21
41
|
export const TARGET_BGL_MMOL_LIMITS = { min: 5, max: 13.9 };
|
|
42
|
+
/** The lower and upper limits for a valid activity BGL target in mmol/L. */
|
|
22
43
|
export const ACTIVITY_TARGET_BGL_MMOL_LIMITS = { min: 5, max: 13.9 };
|
|
44
|
+
/** The lower and upper limits for how long the reminder notification timer may be. */
|
|
23
45
|
export const REMINDER_HOURS_LIMITS = { min: 0, max: 6 };
|
|
46
|
+
/** The lower and upper limits for activity reduction. */
|
|
24
47
|
export const ACTIVITY_SETTINGS_INTERVAL_LIMITS = { min: 0, max: 1 };
|
|
@@ -1,27 +1,56 @@
|
|
|
1
1
|
import { RecommendationErrorEnum } from "../types/enum";
|
|
2
|
+
/**
|
|
3
|
+
* Defines a set of human readable error messages.
|
|
4
|
+
* Each of them is defined as a function that returns the required translatable error message.
|
|
5
|
+
* The app should generally prevent the user from entering invalid values at the time of entry, so in almost all of these cases,
|
|
6
|
+
* the use of any of these errors indicate that something might have gone really wrong, and the user will be prevented
|
|
7
|
+
* from getting a recommendation until the problem is solved.
|
|
8
|
+
*/
|
|
2
9
|
export declare class RecommendationError extends Error {
|
|
3
10
|
readonly type: RecommendationErrorEnum;
|
|
4
11
|
constructor(message: string, type: RecommendationErrorEnum);
|
|
5
12
|
}
|
|
13
|
+
/** The given activity settings are corrupt. */
|
|
6
14
|
export declare const ActivitySettingsError: () => RecommendationError;
|
|
15
|
+
/** The duration of the given activity is invalid. */
|
|
7
16
|
export declare const ActivityDurationError: () => RecommendationError;
|
|
17
|
+
/** The start date of the given activity is invalid. */
|
|
8
18
|
export declare const ActivityDateError: () => RecommendationError;
|
|
19
|
+
/** The intensity of the given activity is invalid. */
|
|
9
20
|
export declare const ActivityIntensityError: () => RecommendationError;
|
|
21
|
+
/** Type of the given activity is invalid. */
|
|
10
22
|
export declare const ActivityTypeError: () => RecommendationError;
|
|
23
|
+
/** The user’s activity target BGL setting is invalid. */
|
|
11
24
|
export declare const ActivityTargetBGLError: () => RecommendationError;
|
|
25
|
+
/** More than 300 g carbohydrates entered. */
|
|
12
26
|
export declare const CarbohydrateLimitError: () => RecommendationError;
|
|
27
|
+
/** The user’s insulin sensitivity setting is outside of the valid range. */
|
|
13
28
|
export declare const InsulinSensitivityError: () => RecommendationError;
|
|
29
|
+
/** The user’s insulin-to-carbs ratio setting is outside of the valid range. */
|
|
14
30
|
export declare const InsulinToCarbsRatioError: () => RecommendationError;
|
|
31
|
+
/** The entered current blood glucose level is outside of the valid range. */
|
|
15
32
|
export declare const CurrentBGLError: () => RecommendationError;
|
|
33
|
+
/** The blood glucose level of the latest logbook entry from the last 6 hours is outside of the valid range. */
|
|
16
34
|
export declare const LatestLogbook6HoursBGLError: () => RecommendationError;
|
|
35
|
+
/** The entered current blood ketones concentration is outside of the valid range. */
|
|
17
36
|
export declare const CurrentBKLError: () => RecommendationError;
|
|
37
|
+
/** The user’s target BGL setting is outside of the valid range. */
|
|
18
38
|
export declare const TargetBGLError: () => RecommendationError;
|
|
39
|
+
/** At least one of the recent (within the previous 4 hours) logbook entries has an insulin amount that exceeds the safety insulin threshold. */
|
|
19
40
|
export declare const BolusInsulinDoseError: () => RecommendationError;
|
|
41
|
+
/** At least one entry from the list of recent logbook entries is older than 4 hours. */
|
|
20
42
|
export declare const BolusInsulinSecondsPassedError: () => RecommendationError;
|
|
43
|
+
/** The user’s recent boluses entries are not in the allowed format. */
|
|
21
44
|
export declare const RecentBolusError: () => RecommendationError;
|
|
45
|
+
/** The user’s setting for initial reminder time is outside of the valid range. */
|
|
22
46
|
export declare const UserReminderError: () => RecommendationError;
|
|
47
|
+
/** The user’s insulin injection method setting is invalid. */
|
|
23
48
|
export declare const InjectionMethodError: () => RecommendationError;
|
|
49
|
+
/**The user’s language setting is not supported by the bolus calculator or it is in the wrong format */
|
|
24
50
|
export declare const LanguageError: () => RecommendationError;
|
|
51
|
+
/** The user’s blood ketones unit setting is invalid. */
|
|
25
52
|
export declare const BloodKetoneUnitError: () => RecommendationError;
|
|
53
|
+
/** The user’s blood glucose level measuring unit setting is invalid. */
|
|
26
54
|
export declare const BloodGlucoseUnitError: () => RecommendationError;
|
|
55
|
+
/** The user has provided a blood ketone level but the blood ketone measuring unit is not defined. */
|
|
27
56
|
export declare const BloodKetonePropsError: () => RecommendationError;
|
|
@@ -3,31 +3,60 @@ import { t } from "@lingui/macro";
|
|
|
3
3
|
import { i18n } from "../locale/i18nUtils";
|
|
4
4
|
import { RecommendationErrorEnum } from "../types/enum";
|
|
5
5
|
const SAFETY_INSULIN_LIMIT = BolusCalculator.Constants.SAFETY_INSULIN_LIMIT;
|
|
6
|
+
/**
|
|
7
|
+
* Defines a set of human readable error messages.
|
|
8
|
+
* Each of them is defined as a function that returns the required translatable error message.
|
|
9
|
+
* The app should generally prevent the user from entering invalid values at the time of entry, so in almost all of these cases,
|
|
10
|
+
* the use of any of these errors indicate that something might have gone really wrong, and the user will be prevented
|
|
11
|
+
* from getting a recommendation until the problem is solved.
|
|
12
|
+
*/
|
|
6
13
|
export class RecommendationError extends Error {
|
|
7
14
|
constructor(message, type) {
|
|
8
15
|
super(message);
|
|
9
16
|
this.type = type;
|
|
10
17
|
}
|
|
11
18
|
}
|
|
19
|
+
/** The given activity settings are corrupt. */
|
|
12
20
|
export const ActivitySettingsError = () => new RecommendationError(i18n._(t `Error. Please verify that your activity settings are set up correctly.`), RecommendationErrorEnum.ActivitySettings);
|
|
21
|
+
/** The duration of the given activity is invalid. */
|
|
13
22
|
export const ActivityDurationError = () => new RecommendationError(i18n._(t `Error. Hedia Calculator only supports activities with a duration of maximum 60 minutes.`), RecommendationErrorEnum.ActivityDuration);
|
|
23
|
+
/** The start date of the given activity is invalid. */
|
|
14
24
|
export const ActivityDateError = () => new RecommendationError(i18n._(t `Hedia Calculator does not support activities that finished more than 4 hours ago.`), RecommendationErrorEnum.ActivityDate);
|
|
25
|
+
/** The intensity of the given activity is invalid. */
|
|
15
26
|
export const ActivityIntensityError = () => new RecommendationError(i18n._(t `Error. Hedia Calculator does not support your activity intensity value`), RecommendationErrorEnum.ActivityIntensity);
|
|
27
|
+
/** Type of the given activity is invalid. */
|
|
16
28
|
export const ActivityTypeError = () => new RecommendationError(i18n._(t `Error. Hedia Calculator does not support your activity type value`), RecommendationErrorEnum.ActivityType);
|
|
29
|
+
/** The user’s activity target BGL setting is invalid. */
|
|
17
30
|
export const ActivityTargetBGLError = () => new RecommendationError(i18n._(t `Error. Please verify that your activity target blood glucose value is correct.`), RecommendationErrorEnum.ActivityTargetBGL);
|
|
31
|
+
/** More than 300 g carbohydrates entered. */
|
|
18
32
|
export const CarbohydrateLimitError = () => new RecommendationError(i18n._(t `Hedia Calculator does not support insulin recommendations with more than 300 grams of carbohydrates present.`), RecommendationErrorEnum.CarbohydrateLimit);
|
|
33
|
+
/** The user’s insulin sensitivity setting is outside of the valid range. */
|
|
19
34
|
export const InsulinSensitivityError = () => new RecommendationError(i18n._(t `Error. Please verify that your insulin sensitivity value is correct.`), RecommendationErrorEnum.InsulinSensitivity);
|
|
35
|
+
/** The user’s insulin-to-carbs ratio setting is outside of the valid range. */
|
|
20
36
|
export const InsulinToCarbsRatioError = () => new RecommendationError(i18n._(t `Error. Please verify that your insulin to carb ratio value is correct.`), RecommendationErrorEnum.InsulinToCarbsRatio);
|
|
37
|
+
/** The entered current blood glucose level is outside of the valid range. */
|
|
21
38
|
export const CurrentBGLError = () => new RecommendationError(i18n._(t `Error. Hedia Calculator does not support your current blood glucose level.`), RecommendationErrorEnum.CurrentBGL);
|
|
39
|
+
/** The blood glucose level of the latest logbook entry from the last 6 hours is outside of the valid range. */
|
|
22
40
|
export const LatestLogbook6HoursBGLError = () => new RecommendationError(i18n._(t `Error. Hedia Calculator does not support the blood glucose level of your latest logbook entry from the last 6 hours.`), RecommendationErrorEnum.LatestLogbook6HoursBGL);
|
|
41
|
+
/** The entered current blood ketones concentration is outside of the valid range. */
|
|
23
42
|
export const CurrentBKLError = () => new RecommendationError(i18n._(t `Error. Hedia Calculator does not support your current blood ketone level.`), RecommendationErrorEnum.CurrentBKL);
|
|
43
|
+
/** The user’s target BGL setting is outside of the valid range. */
|
|
24
44
|
export const TargetBGLError = () => new RecommendationError(i18n._(t `Error. Please verify that your target blood glucose value is correct.`), RecommendationErrorEnum.TargetBGL);
|
|
45
|
+
/** At least one of the recent (within the previous 4 hours) logbook entries has an insulin amount that exceeds the safety insulin threshold. */
|
|
25
46
|
export const BolusInsulinDoseError = () => new RecommendationError(i18n._(t `Error. Hedia Calculator does not support an insulin dose greater than ${SAFETY_INSULIN_LIMIT} units`), RecommendationErrorEnum.BolusInsulinDose);
|
|
47
|
+
/** At least one entry from the list of recent logbook entries is older than 4 hours. */
|
|
26
48
|
export const BolusInsulinSecondsPassedError = () => new RecommendationError(i18n._(t `Error. Hedia Calculator does not support insulin recommendations with boluses older than 4 hours`), RecommendationErrorEnum.BolusInsulinSecondsPassed);
|
|
49
|
+
/** The user’s recent boluses entries are not in the allowed format. */
|
|
27
50
|
export const RecentBolusError = () => new RecommendationError(i18n._(t `Error. Hedia Calculator could not find your recent boluses`), RecommendationErrorEnum.RecentBolus);
|
|
51
|
+
/** The user’s setting for initial reminder time is outside of the valid range. */
|
|
28
52
|
export const UserReminderError = () => new RecommendationError(i18n._(t `Error. Please verify your notifications settings.`), RecommendationErrorEnum.UserReminder);
|
|
53
|
+
/** The user’s insulin injection method setting is invalid. */
|
|
29
54
|
export const InjectionMethodError = () => new RecommendationError(i18n._(t `Error. Hedia Calculator does not support your injection method.`), RecommendationErrorEnum.InjectionMethod);
|
|
55
|
+
/**The user’s language setting is not supported by the bolus calculator or it is in the wrong format */
|
|
30
56
|
export const LanguageError = () => new RecommendationError(i18n._(t `Error. Hedia Calculator does not support your current language.`), RecommendationErrorEnum.Language);
|
|
57
|
+
/** The user’s blood ketones unit setting is invalid. */
|
|
31
58
|
export const BloodKetoneUnitError = () => new RecommendationError(i18n._(t `Error. Hedia Calculator does not support your current blood ketone unit.`), RecommendationErrorEnum.BloodKetoneUnit);
|
|
59
|
+
/** The user’s blood glucose level measuring unit setting is invalid. */
|
|
32
60
|
export const BloodGlucoseUnitError = () => new RecommendationError(i18n._(t `Error. Hedia Calculator does not support your current blood glucose unit.`), RecommendationErrorEnum.BloodGlucoseUnit);
|
|
61
|
+
/** The user has provided a blood ketone level but the blood ketone measuring unit is not defined. */
|
|
33
62
|
export const BloodKetonePropsError = () => new RecommendationError(i18n._(t `Error. Your blood ketone settings are invalid.`), RecommendationErrorEnum.BloodKetoneProps);
|
|
@@ -1,8 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions for processing and categorising user inputs for determining which warnings and messages to display.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
import { BolusCalculator, Logbook } from "@hedia/types";
|
|
1
6
|
import { BgLevel } from "../types/enum";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* 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.
|
|
9
|
+
*
|
|
10
|
+
* Steps:
|
|
11
|
+
* 1. If currentBGL is null return BgLevel.BGLevelNotProvided.
|
|
12
|
+
* 2. If currentBGL is in the interval [1.1; 2] return BgLevel.SevereHypoglycemia.
|
|
13
|
+
* 3. If currentBGL is in the interval ]2; 3.5] return BgLevel.Hypoglycemia.
|
|
14
|
+
* 4. If currentBGL is in the interval ]3.5; 4] return BgLevel.MildHypoglycemia.
|
|
15
|
+
* 5. If currentBGL is in the interval ]4; 5[ return BgLevel.NormoglycemiaUnder5MMOL.
|
|
16
|
+
* 6. If currentBGL is in the interval [5; 7] return BgLevel.Normoglycemia.
|
|
17
|
+
* 7. If currentBGL is in the interval ]7; 15[ return BgLevel.MildHyperglycemia.
|
|
18
|
+
* 8. If currentBGL is in the interval ]15; 33.3] and calling isSevereHyperglycemia() with latestLogbookFrom6Hours returns true then return BgLevel.SevereHyperglycemia.
|
|
19
|
+
* 9. If currentBGL is in the interval [15; 33.3] return BgLevel.Hyperglycemia.
|
|
20
|
+
* @param currentBGL The blood glucose level entered by the user or null if they didn’t enter it.
|
|
21
|
+
* @param latestLogbookFrom6Hours The latest saved logbook entry if one was logged within the last 6 hours. Otherwise null.
|
|
22
|
+
* @returns Indication of the category that the blood glucose level belongs to {@link BgLevel}.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getBGLevel(currentBGL: number | null, latestLogbookFrom6Hours: Logbook.Types.ILogbookEntry | null): BgLevel;
|
|
25
|
+
/**
|
|
26
|
+
* Calculate the initial value for the calibration reminder time slider.
|
|
27
|
+
*
|
|
28
|
+
* Steps:
|
|
29
|
+
* 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.
|
|
30
|
+
* 2. Use a switch statement on {@link BgLevel} to determine the appropriate reminder value to return:
|
|
31
|
+
* - If it is SevereHypoglycemia, Hypoglycemia, or MildHypoglycemia then return Reminder15Minutes.
|
|
32
|
+
* - If it is NormoglycemiaUnder5MMOL, Normoglycemia, MildHyperglycemia, or BGLevelNotProvided then return the value of reminder
|
|
33
|
+
* if the user entered carbohydrates or an activity, or ReminderOff otherwise.
|
|
34
|
+
* - If it is Hyperglycemia, or SevereHyperglycemia then return Reminder15Minutes if isActivityWithin15Minutes() given the activity
|
|
35
|
+
* is true and return Reminder60Minutes otherwise.
|
|
36
|
+
* - If none of the above conditions were triggered, throw a CurrentBGLError().
|
|
37
|
+
* @param bgLevel The severity category that the user’s current BGL belongs to.
|
|
38
|
+
* @param carbohydrates The amount of carbohydrates that the user is ingesting.
|
|
39
|
+
* @param userReminder The user’s preferred initial reminder time interval in hours.
|
|
40
|
+
* @param activity The activity that the user entered.
|
|
41
|
+
* @returns The initial value of the remeasurement reminder timer slider in hours {@link RecommendationReminders}.
|
|
42
|
+
*/
|
|
43
|
+
export declare function getReminder(bgLevel: BgLevel, carbohydrates: number, userReminder: number, activity: BolusCalculator.Types.IActivityParams | null): number;
|
|
44
|
+
/**
|
|
45
|
+
* Get the attention message that fits with the user’s entered blood glucose level and activity.
|
|
46
|
+
*
|
|
47
|
+
* Steps:
|
|
48
|
+
* 1. Use at switch statement on bgLevel to determine the appropriate action to take:
|
|
49
|
+
* - If it is BGLevelNotProvided, Normoglycemia, or MildHyperglycemia then return null.
|
|
50
|
+
* - If it is NormoglycemiaUnder5MMOL then do the following:
|
|
51
|
+
* - If an activity is going to start within 15 minuts as determined by isActivityWithin15Minutes() then return AttentionMessage.NormoglycemiaActivityUnder5MMOL().
|
|
52
|
+
* Otherwise return null.
|
|
53
|
+
* - If it is SevereHypoglycemia, Hypoglycemia, or MildHypoglycemia then do the following:
|
|
54
|
+
* - If an activity is going to start within 15 minuts as determined by isActivityWithin15Minutes() then
|
|
55
|
+
* return the AttentionMessage that corresponds to the bgLevel and append a message about postponing the activity using addPostponeActivityMessage().
|
|
56
|
+
* Otherwise return the AttentionMessage that corresponds to the {@link BgLevel} without further modification.
|
|
57
|
+
* - If it is Hyperglycemia then do the following:
|
|
58
|
+
* - If an activity is going to start within 15 minuts as determined by isActivityWithin15Minutes() then return AttentionMessage.HyperglycemiaActivity().
|
|
59
|
+
* Otherwise return null.
|
|
60
|
+
* - If it is SevereHyperglycemia then do the following:
|
|
61
|
+
* - If an activity is going to start within 15 minuts as determined by isActivityWithin15Minutes() then return AttentionMessage.SevereHyperglycemiaActivity().
|
|
62
|
+
* Otherwise return AttentionMessage.SevereHyperglycemia().
|
|
63
|
+
* - If none of the above conditions were triggered, throw a CurrentBGLError() {@link RecommendationError}.
|
|
64
|
+
* @param bgLevel The category of the user’s blood glucose level.
|
|
65
|
+
* @param activity The activity that the user entered
|
|
66
|
+
* @returns The appropriate attention message {@link AttentionMessage} to display to the user or null if there is no message to be displayed.
|
|
67
|
+
*/
|
|
68
|
+
export declare function getAttentionMessage(bgLevel: BgLevel, activity: BolusCalculator.Types.IActivityParams | null): string | null;
|
|
69
|
+
/**
|
|
70
|
+
* Determine based on on the previously measured BGL if the hyperglycemia should be categorized as severe.
|
|
71
|
+
*
|
|
72
|
+
* Steps:
|
|
73
|
+
* 1. If the logbook is not null or undefined, return the result of comparing if the blood_glucose_millimolar property of latestLogbookFrom6Hours
|
|
74
|
+
* is strictly larger than the threshold for severe hyperglycemia (15) {@link Constants}.
|
|
75
|
+
* @param logbook The latest previous logbook entry - if any - from the past 6 hours.
|
|
76
|
+
* @returns True if the BGL from the previous logbook entry is above the threshold for severe hyperglycemia. False otherwise.
|
|
77
|
+
*/
|
|
78
|
+
export declare function isSevereHyperglycemia(logbook?: Logbook.Types.ILogbookEntry | null): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Determine whether an activity is either ongoing or is starting within 15 minutes from now.
|
|
81
|
+
*
|
|
82
|
+
* Steps:
|
|
83
|
+
* 1. Extract the duration from the activity.
|
|
84
|
+
* 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.
|
|
85
|
+
* @param activity The activity whose start time should be checked.
|
|
86
|
+
* @returns Indication of whether the activity is ongoing or imminent.
|
|
87
|
+
*/
|
|
88
|
+
export declare function isActivityWithin15Minutes(activity: BolusCalculator.Types.IActivityParams | null): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* The appropriate message for informing the user if the insulin recommendation was limited.
|
|
91
|
+
*
|
|
92
|
+
* Steps:
|
|
93
|
+
* 1. Set message to the return value of RecommendationWasLimitedActivity() if activityReduction is truthy or to the return value of RecommendationWasLimited() otherwise.
|
|
94
|
+
* 2. Return message if wasLimited is true or undefined otherwise.
|
|
95
|
+
* @param wasLimited Indicator of whether or not the user’s insulin recommendation was limited.
|
|
96
|
+
* @param activityReduction The fraction by which the insulin recommendation and the safety insulin limit has been reduced due to physical activity.
|
|
97
|
+
* @returns Callable that returns the appropriate message {@link Messages} for informing the user about the limitation.
|
|
98
|
+
* If no limitation message should be displayed to the user then null is returned.
|
|
99
|
+
*/
|
|
8
100
|
export declare function getLimitationMessage(wasLimited: boolean, activityReduction: number | null): string | null;
|
|
@@ -1,9 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions for processing and categorising user inputs for determining which warnings and messages to display.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
1
5
|
import moment from "moment";
|
|
2
6
|
import { BgLevel, RecommendationReminders } from "../types/enum";
|
|
3
7
|
import { addPostponeActivityMessageUnder5MMOL, AttentionMessage, Messages } from "./AttentionMessages";
|
|
4
8
|
import { SEVERE_HYPERGLYCEMIA_START_MMOL } from "./Constants";
|
|
5
9
|
import { CurrentBGLError } from "./RecommendationError";
|
|
6
10
|
import { Utils } from "./Utils";
|
|
11
|
+
/**
|
|
12
|
+
* 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.
|
|
13
|
+
*
|
|
14
|
+
* Steps:
|
|
15
|
+
* 1. If currentBGL is null return BgLevel.BGLevelNotProvided.
|
|
16
|
+
* 2. If currentBGL is in the interval [1.1; 2] return BgLevel.SevereHypoglycemia.
|
|
17
|
+
* 3. If currentBGL is in the interval ]2; 3.5] return BgLevel.Hypoglycemia.
|
|
18
|
+
* 4. If currentBGL is in the interval ]3.5; 4] return BgLevel.MildHypoglycemia.
|
|
19
|
+
* 5. If currentBGL is in the interval ]4; 5[ return BgLevel.NormoglycemiaUnder5MMOL.
|
|
20
|
+
* 6. If currentBGL is in the interval [5; 7] return BgLevel.Normoglycemia.
|
|
21
|
+
* 7. If currentBGL is in the interval ]7; 15[ return BgLevel.MildHyperglycemia.
|
|
22
|
+
* 8. If currentBGL is in the interval ]15; 33.3] and calling isSevereHyperglycemia() with latestLogbookFrom6Hours returns true then return BgLevel.SevereHyperglycemia.
|
|
23
|
+
* 9. If currentBGL is in the interval [15; 33.3] return BgLevel.Hyperglycemia.
|
|
24
|
+
* @param currentBGL The blood glucose level entered by the user or null if they didn’t enter it.
|
|
25
|
+
* @param latestLogbookFrom6Hours The latest saved logbook entry if one was logged within the last 6 hours. Otherwise null.
|
|
26
|
+
* @returns Indication of the category that the blood glucose level belongs to {@link BgLevel}.
|
|
27
|
+
*/
|
|
7
28
|
export function getBGLevel(currentBGL, latestLogbookFrom6Hours) {
|
|
8
29
|
if (currentBGL === null) {
|
|
9
30
|
return BgLevel.BGLevelNotProvided;
|
|
@@ -36,6 +57,24 @@ export function getBGLevel(currentBGL, latestLogbookFrom6Hours) {
|
|
|
36
57
|
}
|
|
37
58
|
return BgLevel.UnsupportedBGLevel;
|
|
38
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Calculate the initial value for the calibration reminder time slider.
|
|
62
|
+
*
|
|
63
|
+
* Steps:
|
|
64
|
+
* 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.
|
|
65
|
+
* 2. Use a switch statement on {@link BgLevel} to determine the appropriate reminder value to return:
|
|
66
|
+
* - If it is SevereHypoglycemia, Hypoglycemia, or MildHypoglycemia then return Reminder15Minutes.
|
|
67
|
+
* - If it is NormoglycemiaUnder5MMOL, Normoglycemia, MildHyperglycemia, or BGLevelNotProvided then return the value of reminder
|
|
68
|
+
* if the user entered carbohydrates or an activity, or ReminderOff otherwise.
|
|
69
|
+
* - If it is Hyperglycemia, or SevereHyperglycemia then return Reminder15Minutes if isActivityWithin15Minutes() given the activity
|
|
70
|
+
* is true and return Reminder60Minutes otherwise.
|
|
71
|
+
* - If none of the above conditions were triggered, throw a CurrentBGLError().
|
|
72
|
+
* @param bgLevel The severity category that the user’s current BGL belongs to.
|
|
73
|
+
* @param carbohydrates The amount of carbohydrates that the user is ingesting.
|
|
74
|
+
* @param userReminder The user’s preferred initial reminder time interval in hours.
|
|
75
|
+
* @param activity The activity that the user entered.
|
|
76
|
+
* @returns The initial value of the remeasurement reminder timer slider in hours {@link RecommendationReminders}.
|
|
77
|
+
*/
|
|
39
78
|
export function getReminder(bgLevel, carbohydrates, userReminder, activity) {
|
|
40
79
|
const reminder = userReminder === undefined ? RecommendationReminders.HediaReminderDefault : userReminder;
|
|
41
80
|
switch (bgLevel) {
|
|
@@ -57,6 +96,30 @@ export function getReminder(bgLevel, carbohydrates, userReminder, activity) {
|
|
|
57
96
|
throw CurrentBGLError();
|
|
58
97
|
}
|
|
59
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Get the attention message that fits with the user’s entered blood glucose level and activity.
|
|
101
|
+
*
|
|
102
|
+
* Steps:
|
|
103
|
+
* 1. Use at switch statement on bgLevel to determine the appropriate action to take:
|
|
104
|
+
* - If it is BGLevelNotProvided, Normoglycemia, or MildHyperglycemia then return null.
|
|
105
|
+
* - If it is NormoglycemiaUnder5MMOL then do the following:
|
|
106
|
+
* - If an activity is going to start within 15 minuts as determined by isActivityWithin15Minutes() then return AttentionMessage.NormoglycemiaActivityUnder5MMOL().
|
|
107
|
+
* Otherwise return null.
|
|
108
|
+
* - If it is SevereHypoglycemia, Hypoglycemia, or MildHypoglycemia then do the following:
|
|
109
|
+
* - If an activity is going to start within 15 minuts as determined by isActivityWithin15Minutes() then
|
|
110
|
+
* return the AttentionMessage that corresponds to the bgLevel and append a message about postponing the activity using addPostponeActivityMessage().
|
|
111
|
+
* Otherwise return the AttentionMessage that corresponds to the {@link BgLevel} without further modification.
|
|
112
|
+
* - If it is Hyperglycemia then do the following:
|
|
113
|
+
* - If an activity is going to start within 15 minuts as determined by isActivityWithin15Minutes() then return AttentionMessage.HyperglycemiaActivity().
|
|
114
|
+
* Otherwise return null.
|
|
115
|
+
* - If it is SevereHyperglycemia then do the following:
|
|
116
|
+
* - If an activity is going to start within 15 minuts as determined by isActivityWithin15Minutes() then return AttentionMessage.SevereHyperglycemiaActivity().
|
|
117
|
+
* Otherwise return AttentionMessage.SevereHyperglycemia().
|
|
118
|
+
* - If none of the above conditions were triggered, throw a CurrentBGLError() {@link RecommendationError}.
|
|
119
|
+
* @param bgLevel The category of the user’s blood glucose level.
|
|
120
|
+
* @param activity The activity that the user entered
|
|
121
|
+
* @returns The appropriate attention message {@link AttentionMessage} to display to the user or null if there is no message to be displayed.
|
|
122
|
+
*/
|
|
60
123
|
export function getAttentionMessage(bgLevel, activity) {
|
|
61
124
|
const key = Utils.getKeyFromValue(BgLevel, bgLevel);
|
|
62
125
|
const isAttentionMessageNull = AttentionMessage[key] === null;
|
|
@@ -84,6 +147,15 @@ export function getAttentionMessage(bgLevel, activity) {
|
|
|
84
147
|
throw CurrentBGLError();
|
|
85
148
|
}
|
|
86
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Determine based on on the previously measured BGL if the hyperglycemia should be categorized as severe.
|
|
152
|
+
*
|
|
153
|
+
* Steps:
|
|
154
|
+
* 1. If the logbook is not null or undefined, return the result of comparing if the blood_glucose_millimolar property of latestLogbookFrom6Hours
|
|
155
|
+
* is strictly larger than the threshold for severe hyperglycemia (15) {@link Constants}.
|
|
156
|
+
* @param logbook The latest previous logbook entry - if any - from the past 6 hours.
|
|
157
|
+
* @returns True if the BGL from the previous logbook entry is above the threshold for severe hyperglycemia. False otherwise.
|
|
158
|
+
*/
|
|
87
159
|
export function isSevereHyperglycemia(logbook) {
|
|
88
160
|
if (logbook !== null && logbook !== undefined) {
|
|
89
161
|
const { blood_glucose_millimolar } = logbook;
|
|
@@ -93,12 +165,32 @@ export function isSevereHyperglycemia(logbook) {
|
|
|
93
165
|
}
|
|
94
166
|
return false;
|
|
95
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Determine whether an activity is either ongoing or is starting within 15 minutes from now.
|
|
170
|
+
*
|
|
171
|
+
* Steps:
|
|
172
|
+
* 1. Extract the duration from the activity.
|
|
173
|
+
* 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.
|
|
174
|
+
* @param activity The activity whose start time should be checked.
|
|
175
|
+
* @returns Indication of whether the activity is ongoing or imminent.
|
|
176
|
+
*/
|
|
96
177
|
export function isActivityWithin15Minutes(activity) {
|
|
97
178
|
const minutes = activity?.activityDuration;
|
|
98
179
|
return moment
|
|
99
180
|
.utc(activity?.activityDate)
|
|
100
181
|
.isBetween(moment.utc().subtract(minutes, `minutes`), moment.utc().add(15, `minutes`));
|
|
101
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* The appropriate message for informing the user if the insulin recommendation was limited.
|
|
185
|
+
*
|
|
186
|
+
* Steps:
|
|
187
|
+
* 1. Set message to the return value of RecommendationWasLimitedActivity() if activityReduction is truthy or to the return value of RecommendationWasLimited() otherwise.
|
|
188
|
+
* 2. Return message if wasLimited is true or undefined otherwise.
|
|
189
|
+
* @param wasLimited Indicator of whether or not the user’s insulin recommendation was limited.
|
|
190
|
+
* @param activityReduction The fraction by which the insulin recommendation and the safety insulin limit has been reduced due to physical activity.
|
|
191
|
+
* @returns Callable that returns the appropriate message {@link Messages} for informing the user about the limitation.
|
|
192
|
+
* If no limitation message should be displayed to the user then null is returned.
|
|
193
|
+
*/
|
|
102
194
|
export function getLimitationMessage(wasLimited, activityReduction) {
|
|
103
195
|
const message = activityReduction
|
|
104
196
|
? Messages.RecommendationWasLimitedActivity(activityReduction)
|
|
@@ -1,2 +1,9 @@
|
|
|
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
|
+
*/
|
|
1
5
|
import { Activity } from "@hedia/types";
|
|
6
|
+
/**
|
|
7
|
+
* Object used for storing the translations of a physical activity intensity in order to be presented to the user
|
|
8
|
+
*/
|
|
2
9
|
export declare const ActivityIntensityTranslations: Record<Activity.Enums.ActivityIntensity, () => string>;
|
|
@@ -1,5 +1,12 @@
|
|
|
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
|
+
*/
|
|
1
5
|
import { t } from "@lingui/macro";
|
|
2
6
|
import { i18n } from "../locale/i18nUtils";
|
|
7
|
+
/**
|
|
8
|
+
* Object used for storing the translations of a physical activity intensity in order to be presented to the user
|
|
9
|
+
*/
|
|
3
10
|
export const ActivityIntensityTranslations = {
|
|
4
11
|
light: () => i18n._(t `Light`),
|
|
5
12
|
moderate: () => i18n._(t `Moderate`),
|
package/src/utils/Utils.d.ts
CHANGED
|
@@ -1,13 +1,105 @@
|
|
|
1
1
|
import { BloodGlucoseUnit, BloodKetonesUnit, UserSettings } from "@hedia/types";
|
|
2
2
|
import { IInterval } from "../types/types";
|
|
3
|
+
/** Helper functions used for displaying data to the user. */
|
|
3
4
|
export declare class Utils {
|
|
5
|
+
/**
|
|
6
|
+
* Get the inverse of the precision to an insulin amount should be rounded based on the user’s injection method.
|
|
7
|
+
*
|
|
8
|
+
* Steps:
|
|
9
|
+
* 1. Use a switch statement to return the appropriate number depending on the value of the method argument:
|
|
10
|
+
* - If PenWhole, return 1.
|
|
11
|
+
* - If PenHalf, return 2.
|
|
12
|
+
* - If Pump, return 10.
|
|
13
|
+
* - Otherwise throw an exception.
|
|
14
|
+
* @param method The method by which the user injects insulin.
|
|
15
|
+
* @returns The inverse of the precision to which an insulin amount should be rounded based on the user’s injection method.
|
|
16
|
+
*/
|
|
4
17
|
static getRounding(method: UserSettings.Enums.InjectionMethod): number;
|
|
18
|
+
/**
|
|
19
|
+
* Round an insulin amount to the precision that is dictated by the user’s injection method.
|
|
20
|
+
*
|
|
21
|
+
* Steps:
|
|
22
|
+
* 1. Get the inverse rounding precision by calling getRounding() with injectMethod as argument.
|
|
23
|
+
* 2. Return the rounded insulin amount calculated by the following operations:
|
|
24
|
+
* - Multiply the insulin value prop by the inverse rounding precision.
|
|
25
|
+
* - Round to the nearest whole number.
|
|
26
|
+
* - Divide by the inverse rounding precision and return the result.
|
|
27
|
+
* @param value The amount of insulin to be rounded.
|
|
28
|
+
* @param injectMethod The method by which the user injects insulin.
|
|
29
|
+
* @returns The rounded insulin amount.
|
|
30
|
+
*/
|
|
5
31
|
static roundValue(value: number, injectMethod: UserSettings.Enums.InjectionMethod): number;
|
|
32
|
+
/**
|
|
33
|
+
* Determine whether a numerical value is in the given closed interval.
|
|
34
|
+
*
|
|
35
|
+
* Steps:
|
|
36
|
+
* 1. If value is null then return false. (Note that we only need to check explicitly for null comparing it
|
|
37
|
+
* to a number returns true while comparing undefined to a number returns false).
|
|
38
|
+
* 2. Evaluate whether value >= the interval argument’s min property && value <= the interval argument’s max property and return the result.
|
|
39
|
+
* @param value The number that will be checked for membership of the interval.
|
|
40
|
+
* @param interval The interval to compare the value to.
|
|
41
|
+
* @returns Boolean value indicating whether the value is in the closed interval.
|
|
42
|
+
*/
|
|
6
43
|
static isInRange(value: number | null, interval: IInterval): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Convert a blood glucose level value from mmol/L to mg/dL.
|
|
46
|
+
*
|
|
47
|
+
* Steps:
|
|
48
|
+
* 1. Return the result of rounding the product of multiplying value with MGDL_PER_MMOLL_BGL.
|
|
49
|
+
* @param value The blood glucose level value in mmol/L to be converted.
|
|
50
|
+
* @returns The blood glucose value in mg/dL that corresponds to the given value in mmol/L.
|
|
51
|
+
*/
|
|
7
52
|
static convertBGLToMGDL(value: number): number;
|
|
53
|
+
/**
|
|
54
|
+
* Depending on the blood glucose unit passed, returns the value as a string or returns a stringified call to the convertBGLToMGDL method.
|
|
55
|
+
*
|
|
56
|
+
* Steps:
|
|
57
|
+
* 1. Using a ternary operator on the unit argument return the passed value argument in case unit is a MMOL_L.
|
|
58
|
+
* Otherwise, return a call to the convertBGLToMGDL method with the value passed as an argument.
|
|
59
|
+
* @param value The blood glucose level value in mmol/L to be converted.
|
|
60
|
+
* @param unit The blood glucose measurement unit.
|
|
61
|
+
* @returns The blood glucose value that will be displayed to the user.
|
|
62
|
+
*/
|
|
8
63
|
static displayedBGLValue(value: number, unit: BloodGlucoseUnit): string;
|
|
64
|
+
/**
|
|
65
|
+
* Convert a blood ketones concentration from mmol/L to mg/dL.
|
|
66
|
+
* Steps:
|
|
67
|
+
* 1. Return the result of rounding the product of multiplying value with MGDL_PER_MMOLL_BKL.
|
|
68
|
+
* @param value The blood ketones concentration in mmol/L to be converted.
|
|
69
|
+
* @returns The blood ketones concentration in mg/dL that corresponds to the given value in mmol/L.
|
|
70
|
+
*/
|
|
9
71
|
static convertBKLToMGDL(value: number): number;
|
|
72
|
+
/**
|
|
73
|
+
* Depending on the blood ketone unit passed, returns the value as a string or returns a call to the convertBKLToMGDL method.
|
|
74
|
+
*
|
|
75
|
+
* Steps:
|
|
76
|
+
* 1. Using a ternary operator on the unit argument return the passed value argument in case unit is a MMOL_L.
|
|
77
|
+
* Otherwise, return a call to the convertBKLToMGDL method with the value passed as an argument.
|
|
78
|
+
* @param value The blood ketone level value in mmol/L to be converted.
|
|
79
|
+
* @param unit The blood ketone measurement unit.
|
|
80
|
+
* @returns The blood ketone value that will be displayed to the user.
|
|
81
|
+
*/
|
|
10
82
|
static displayedBKLValue(value: number, unit: BloodKetonesUnit): string;
|
|
83
|
+
/**
|
|
84
|
+
* Format a measurement unit for displaying to the user. More concrete, it is used to display the litre symbol with uppercase "L".
|
|
85
|
+
*
|
|
86
|
+
* Steps:
|
|
87
|
+
* 1. Set unitWithoutLastLetter to be unit except for the last character.
|
|
88
|
+
* 2. Set lastLetterUppercase to be the last letter of unit converted to uppercase.
|
|
89
|
+
* 3. Return unitWithoutLastLetter concatenated with lastLetterUppercase.
|
|
90
|
+
* @param unit The measurement unit to format.
|
|
91
|
+
* @returns The measurement unit formatted for displaying to the user.
|
|
92
|
+
*/
|
|
11
93
|
static formatUnit: (unit: BloodGlucoseUnit | BloodKetonesUnit) => string;
|
|
94
|
+
/**
|
|
95
|
+
* Returns the key of key/value object when passing the key value as argument.
|
|
96
|
+
*
|
|
97
|
+
* Steps:
|
|
98
|
+
* 1. Save all the values of the keys object into the values constant
|
|
99
|
+
* 2. From the array of keys, return the one at the index of the first occurence of the value in the values constant
|
|
100
|
+
* @param keys The keys of the T object.
|
|
101
|
+
* @param value The value for the requested key.
|
|
102
|
+
* @returns The key of the passed value.
|
|
103
|
+
*/
|
|
12
104
|
static getKeyFromValue<T>(keys: T, value: T[keyof T]): keyof T;
|
|
13
105
|
}
|