@hedia/recommendation-screen 2.1.33 → 2.1.34-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/HediaRecommendationScreen.xcodeproj/project.pbxproj +2 -2
- package/ios/Podfile.lock +207 -207
- package/package.json +1 -1
- package/index.d.ts +0 -5
- package/index.js +0 -5
- package/src/RecommendationScreen.d.ts +0 -413
- package/src/RecommendationScreen.js +0 -493
- package/src/__tests__/RecommendationScreen.test.d.ts +0 -1
- package/src/__tests__/RecommendationScreen.test.js +0 -965
- package/src/__tests__/RecommendationUtils.test.d.ts +0 -1
- package/src/__tests__/RecommendationUtils.test.js +0 -216
- package/src/__tests__/Translate.test.d.ts +0 -1
- package/src/__tests__/Translate.test.js +0 -27
- package/src/__tests__/Utils.test.d.ts +0 -1
- package/src/__tests__/Utils.test.js +0 -66
- package/src/__tests__/Validations.test.d.ts +0 -1
- package/src/__tests__/Validations.test.js +0 -465
- package/src/__tests__/components/Activity.test.d.ts +0 -1
- package/src/__tests__/components/Activity.test.js +0 -86
- package/src/__tests__/components/Emotion.test.d.ts +0 -1
- package/src/__tests__/components/Emotion.test.js +0 -70
- package/src/__tests__/components/Header.test.d.ts +0 -1
- package/src/__tests__/components/Header.test.js +0 -36
- package/src/__tests__/components/InfoBars.test.d.ts +0 -1
- package/src/__tests__/components/InfoBars.test.js +0 -130
- package/src/__tests__/components/InvisibleNumberInput.test.d.ts +0 -1
- package/src/__tests__/components/InvisibleNumberInput.test.js +0 -160
- package/src/__tests__/components/LimitationMessage.test.d.ts +0 -1
- package/src/__tests__/components/LimitationMessage.test.js +0 -47
- package/src/__tests__/components/MoodIcon.test.d.ts +0 -1
- package/src/__tests__/components/MoodIcon.test.js +0 -30
- package/src/__tests__/components/RecommendationModal.test.d.ts +0 -1
- package/src/__tests__/components/RecommendationModal.test.js +0 -98
- package/src/__tests__/components/RecommendedCarbs.test.d.ts +0 -1
- package/src/__tests__/components/RecommendedCarbs.test.js +0 -120
- package/src/__tests__/components/RecommendedInsulin.test.d.ts +0 -1
- package/src/__tests__/components/RecommendedInsulin.test.js +0 -154
- package/src/__tests__/components/Remeasure.test.d.ts +0 -1
- package/src/__tests__/components/Remeasure.test.js +0 -78
- package/src/__tests__/components/TransferToLogbook.test.d.ts +0 -1
- package/src/__tests__/components/TransferToLogbook.test.js +0 -30
- package/src/__tests__/components/TwoOptionModal.test.d.ts +0 -1
- package/src/__tests__/components/TwoOptionModal.test.js +0 -65
- package/src/__tests__/utils.d.ts +0 -16
- package/src/__tests__/utils.js +0 -126
- package/src/components/Header.d.ts +0 -10
- package/src/components/Header.js +0 -75
- package/src/components/Icon.d.ts +0 -20
- package/src/components/Icon.js +0 -41
- package/src/components/InfoBars.d.ts +0 -103
- package/src/components/InfoBars.js +0 -129
- package/src/components/InvisibleNumberInput.d.ts +0 -89
- package/src/components/InvisibleNumberInput.js +0 -122
- package/src/components/LimitationMessage.d.ts +0 -14
- package/src/components/LimitationMessage.js +0 -31
- package/src/components/LineSeparator.d.ts +0 -10
- package/src/components/LineSeparator.js +0 -18
- package/src/components/RecentInsulin.d.ts +0 -17
- package/src/components/RecentInsulin.js +0 -94
- package/src/components/RecommendationModal.d.ts +0 -207
- package/src/components/RecommendationModal.js +0 -213
- package/src/components/RecommendedCarbs.d.ts +0 -94
- package/src/components/RecommendedCarbs.js +0 -251
- package/src/components/RecommendedInsulin.d.ts +0 -84
- package/src/components/RecommendedInsulin.js +0 -170
- package/src/components/Remeasure.d.ts +0 -49
- package/src/components/Remeasure.js +0 -125
- package/src/components/TransferToLogbook.d.ts +0 -34
- package/src/components/TransferToLogbook.js +0 -94
- package/src/components/TwoOptionModal.d.ts +0 -145
- package/src/components/TwoOptionModal.js +0 -148
- package/src/components/activity/Activity.d.ts +0 -26
- package/src/components/activity/Activity.js +0 -80
- package/src/components/activity/ActivityIcon.d.ts +0 -22
- package/src/components/activity/ActivityIcon.js +0 -58
- package/src/components/activity/ActivityIntensity.d.ts +0 -16
- package/src/components/activity/ActivityIntensity.js +0 -59
- package/src/components/mood/Emotion.d.ts +0 -38
- package/src/components/mood/Emotion.js +0 -65
- package/src/components/mood/MoodIcon.d.ts +0 -40
- package/src/components/mood/MoodIcon.js +0 -66
- package/src/locale/i18nUtils.d.ts +0 -18
- package/src/locale/i18nUtils.js +0 -39
- package/src/types/enum.d.ts +0 -122
- package/src/types/enum.js +0 -138
- package/src/types/types.d.ts +0 -17
- package/src/types/types.js +0 -1
- package/src/utils/AttentionMessages.d.ts +0 -96
- package/src/utils/AttentionMessages.js +0 -118
- package/src/utils/Constants.d.ts +0 -47
- package/src/utils/Constants.js +0 -47
- package/src/utils/RecommendationError.d.ts +0 -56
- package/src/utils/RecommendationError.js +0 -62
- package/src/utils/RecommendationUtils.d.ts +0 -100
- package/src/utils/RecommendationUtils.js +0 -199
- package/src/utils/Translations.d.ts +0 -9
- package/src/utils/Translations.js +0 -14
- package/src/utils/Utils.d.ts +0 -105
- package/src/utils/Utils.js +0 -141
- package/src/utils/Validations.d.ts +0 -250
- package/src/utils/Validations.js +0 -409
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { BolusCalculator } from "@hedia/types";
|
|
2
|
-
import { t } from "@lingui/macro";
|
|
3
|
-
import moment from "moment";
|
|
4
|
-
import { i18n } from "../locale/i18nUtils";
|
|
5
|
-
/** Provides methods for getting variants of attention messages */
|
|
6
|
-
export const AttentionMessage = {
|
|
7
|
-
/**
|
|
8
|
-
* @return Concatenation of:
|
|
9
|
-
* {@link Messages.VeryLowBGL} +
|
|
10
|
-
* {@link Messages.Reminder15Minutes}
|
|
11
|
-
*/
|
|
12
|
-
SevereHypoglycemia: () => `${Messages.VeryLowBGL()}${`\n`}${Messages.Reminder15Minutes()}`,
|
|
13
|
-
/**
|
|
14
|
-
* @return Concatenation of:
|
|
15
|
-
* {@link Messages.LowBGL} +
|
|
16
|
-
* {@link Messages.Reminder15Minutes}
|
|
17
|
-
*/
|
|
18
|
-
Hypoglycemia: () => `${Messages.LowBGL()}${`\n`}${Messages.Reminder15Minutes()}`,
|
|
19
|
-
/** @return The value of: {@link Messages.Reminder15Minutes} */
|
|
20
|
-
MildHypoglycemia: () => Messages.Reminder15Minutes(),
|
|
21
|
-
/** @return The value of: {@link Messages.PostponePhysicalActivityUnder5MMOL} */
|
|
22
|
-
NormoglycemiaActivityUnder5MMOL: () => Messages.PostponePhysicalActivityUnder5MMOL(),
|
|
23
|
-
/**
|
|
24
|
-
* @return Concatenation of:
|
|
25
|
-
* {@link Messages.HighBGL} +
|
|
26
|
-
* {@link Messages.InsulinKetones} +
|
|
27
|
-
* {@link Messages.Reminder15Minutes} +
|
|
28
|
-
* {@link Messages.PostponePhysicalActivity}
|
|
29
|
-
*/
|
|
30
|
-
HyperglycemiaActivity: () => `${Messages.HighBGL()}${`\n`}${Messages.InsulinKetones()}${`\n`}${Messages.Reminder15Minutes()}${`\n`}${Messages.PostponePhysicalActivity()}`,
|
|
31
|
-
/**
|
|
32
|
-
* @return Concatenation of:
|
|
33
|
-
* {@link Messages.HighBGL} +
|
|
34
|
-
* {@link Messages.InsulinKetones}
|
|
35
|
-
*/
|
|
36
|
-
SevereHyperglycemia: () => `${Messages.HighBGL()}${`\n`}${Messages.InsulinKetones()}${`\n`}`,
|
|
37
|
-
/**
|
|
38
|
-
* @return Concatenation of:
|
|
39
|
-
* {@link Messages.HighBGL} +
|
|
40
|
-
* {@link Messages.InsulinKetones} +
|
|
41
|
-
* {@link Messages.Reminder15Minutes} +
|
|
42
|
-
* {@link Messages.PostponePhysicalActivity}
|
|
43
|
-
*/
|
|
44
|
-
SevereHyperglycemiaActivity: () => `${Messages.HighBGL()}${`\n`}${Messages.InsulinKetones()}${`\n`}${Messages.Reminder15Minutes()}${`\n`}${Messages.PostponePhysicalActivity()}`,
|
|
45
|
-
/** no message provided for this level */
|
|
46
|
-
BGLevelNotProvided: null,
|
|
47
|
-
/** no message provided for this level*/
|
|
48
|
-
Hyperglycemia: null,
|
|
49
|
-
/** no message provided for this level */
|
|
50
|
-
MildHyperglycemia: null,
|
|
51
|
-
/** no message provided for this level */
|
|
52
|
-
Normoglycemia: null,
|
|
53
|
-
/** no message provided for this level */
|
|
54
|
-
NormoglycemiaUnder5MMOL: null,
|
|
55
|
-
/** no message provided for this level */
|
|
56
|
-
UnsupportedBGLevel: null,
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* @param message The message to append the {@link Messages.PostponePhysicalActivityUnder5MMOL} to
|
|
60
|
-
* @returns The initial messaged concatenated with the {@link Messages.PostponePhysicalActivityUnder5MMOL}
|
|
61
|
-
*/
|
|
62
|
-
export function addPostponeActivityMessageUnder5MMOL(message) {
|
|
63
|
-
return `${message}${`\n`}${Messages.PostponePhysicalActivityUnder5MMOL()}`;
|
|
64
|
-
}
|
|
65
|
-
const SAFETY_INSULIN_LIMIT = BolusCalculator.Constants.SAFETY_INSULIN_LIMIT;
|
|
66
|
-
/**
|
|
67
|
-
* Calculate the limited insulin value based on the physical activity reduction value
|
|
68
|
-
* @param reduction The reduction percentage an activity reduce the total insulin intake
|
|
69
|
-
* @returns The limited insulin value.
|
|
70
|
-
*/
|
|
71
|
-
export function getLimitedValue(reduction) {
|
|
72
|
-
return SAFETY_INSULIN_LIMIT - SAFETY_INSULIN_LIMIT * reduction;
|
|
73
|
-
}
|
|
74
|
-
/** Provides methods for getting strings for composing attention messages and other important communications to the user. */
|
|
75
|
-
export class Messages {
|
|
76
|
-
}
|
|
77
|
-
/** Inform the user that their BGL is very low and what they should do about it. */
|
|
78
|
-
Messages.VeryLowBGL = () => i18n._(t `Your blood glucose level is very low. Take glucagon or eat carbohydrates if possible. Seek medical attention.`);
|
|
79
|
-
/** Inform the user that their BGL is very low. */
|
|
80
|
-
Messages.LowBGL = () => i18n._(t `Your blood glucose level is very low.`);
|
|
81
|
-
/** Inform the user that they will be reminded to remeasure their BGL soon. */
|
|
82
|
-
Messages.Reminder15Minutes = () => i18n._(t `You will be reminded to measure your blood glucose level in 15 min.`);
|
|
83
|
-
/** Encourages the user to postpone exercise. Specifically when their BGL is high. */
|
|
84
|
-
Messages.PostponePhysicalActivity = () => i18n._(t `If it is possible, postpone your planned exercise.`);
|
|
85
|
-
/** Encourages the user to postpone exercise. Specifically when their BGL is low. */
|
|
86
|
-
Messages.PostponePhysicalActivityUnder5MMOL = () => i18n._(t `Consider not to initiate physical activity before your blood glucose level is within the recommended ranges prior to physical activity.`);
|
|
87
|
-
/** Inform about high BGL. */
|
|
88
|
-
Messages.HighBGL = () => i18n._(t `You have a high blood glucose level.`);
|
|
89
|
-
/** Encourage user to measure ketones. */
|
|
90
|
-
Messages.InsulinKetones = () => i18n._(t `You should take rapid-acting insulin and measure ketones.`);
|
|
91
|
-
/** Inform the user that their insulin recommendation was limited for safety. */
|
|
92
|
-
Messages.RecommendationWasLimited = () => i18n._(t `Your recommendation would have been higher than ${SAFETY_INSULIN_LIMIT} units of insulin, but it has been limited for safety reasons.
|
|
93
|
-
Hedia never recommends more than ${SAFETY_INSULIN_LIMIT} units of insulin per calculation.`);
|
|
94
|
-
/** Inform the user that their insulin recommendation was limited for safety in combination with an activity. */
|
|
95
|
-
Messages.RecommendationWasLimitedActivity = (activityReduction) => i18n._(t `Your recommendation would have been higher than ${getLimitedValue(activityReduction)}
|
|
96
|
-
units of insulin, but it has been limited for safety reasons.${`\n\n`}
|
|
97
|
-
Hedia never recommends more than ${SAFETY_INSULIN_LIMIT}
|
|
98
|
-
units of insulin per calculation, but because of the physical activity
|
|
99
|
-
you entered it has been further reduced by ${(activityReduction * 100).toFixed(0)}% to
|
|
100
|
-
${getLimitedValue(activityReduction)}.`);
|
|
101
|
-
/** Inform the user that the insulin amount they entered is above HDA’s safety limit. */
|
|
102
|
-
Messages.InsulinInputWasLimited = (activityReduction) => activityReduction
|
|
103
|
-
? i18n._(t `Hedia doesn't support more than ${SAFETY_INSULIN_LIMIT} units of insulin per calculation, but because of the physical activity you entered it has been further reduced by
|
|
104
|
-
${(activityReduction * 100).toFixed(0)}% to ${getLimitedValue(activityReduction)} units for this calculation.`)
|
|
105
|
-
: i18n._(t `Hedia does not support more than ${SAFETY_INSULIN_LIMIT} units of insulin per calculation.`);
|
|
106
|
-
/** Title for the modal that informs the user that their calculation is too old. */
|
|
107
|
-
Messages.TimeoutPrompTitle = () => i18n._(t `More than 15 minutes has passed since this calculation was started.`);
|
|
108
|
-
/**
|
|
109
|
-
* Inform the user that their recommendation calculation is too old.
|
|
110
|
-
* Variant to show when they didn’t see the actual insulin recommendation because they didn’t tell whether they injected insulin recently.
|
|
111
|
-
*/
|
|
112
|
-
Messages.TimeoutRecommendationNotVisible = () => i18n._(t `Please go through the calculation steps with new measurements to ensure a safe recommendation.`);
|
|
113
|
-
/** Inform the user that their recommendation calculation is too old. */
|
|
114
|
-
Messages.TimeoutRecommendationVisible = (date) => {
|
|
115
|
-
const day = moment(date).format(`LL`);
|
|
116
|
-
const time = moment(date).format(`HH:mm`);
|
|
117
|
-
return i18n._(t `Recommendation from ${day} at ${time} was not transfered to your logbook.${`\n`}Did you use the recommendation?`);
|
|
118
|
-
};
|
package/src/utils/Constants.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { IInterval } from "../types/types";
|
|
2
|
-
/** Reusable color definition. */
|
|
3
|
-
export declare const BACKGROUND_COLOUR_PURPLE = "rgba(27, 31, 72, 1)";
|
|
4
|
-
/** Reusable color definition. */
|
|
5
|
-
export declare const BORDER_COLOUR_GREY = "rgba(74, 91, 134, 1)";
|
|
6
|
-
/** Reusable color definition. */
|
|
7
|
-
export declare const BORDER_COLOUR_TEAL = "rgba(1, 255, 252, 0.8)";
|
|
8
|
-
/** The threshold above which hyperglycemia is considered to be severe in mmol/L */
|
|
9
|
-
export declare const SEVERE_HYPERGLYCEMIA_START_MMOL = 15;
|
|
10
|
-
/** The number of seconds in four hours. */
|
|
11
|
-
export declare const FOUR_HOURS_SECONDS = 14400;
|
|
12
|
-
/** The number of minutes in one hour. */
|
|
13
|
-
export declare const ONE_HOUR_MINUTES = 60;
|
|
14
|
-
/** Extra time before an activity starts or stops. */
|
|
15
|
-
export declare const ACTIVITY_BUFFER_MINUTES = 10;
|
|
16
|
-
/** The lower and upper limits for the amount of carbohydrates in grams. */
|
|
17
|
-
export declare const CARBOHYDRATES_LIMTS: IInterval;
|
|
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. */
|
|
19
|
-
export declare const INSULIN_DOSE_LIMITS: IInterval;
|
|
20
|
-
/** The lower and upper limits for the age of boluses that gets taken into account for calculating insulin on board. */
|
|
21
|
-
export declare const BOLUS_SECONDS_PASSED_LIMITS: IInterval;
|
|
22
|
-
/** The lower and upper limits for the duration of an activity in minutes. */
|
|
23
|
-
export declare const ACTIVITY_DURATION_MINUTES_LIMITS: IInterval;
|
|
24
|
-
/** The lower and upper limits of insulin sensitivity settings. */
|
|
25
|
-
export declare const INSULIN_SENSITIVITY_MMOL_LIMITS: IInterval;
|
|
26
|
-
/** The lower and upper limits of insulin-to-carbs ratio settings. */
|
|
27
|
-
export declare const INSULIN_TO_CARBS_RATIO_LIMITS: IInterval;
|
|
28
|
-
/** The lower and upper limits of the entered blood glucose level value in mmol/L. */
|
|
29
|
-
export declare const CURRENT_BGL_MMOL_LIMITS: IInterval;
|
|
30
|
-
/** The conversion factor to multiply a blood glucose value with to go from mmol/L to mg/dL. */
|
|
31
|
-
export declare const MMOLL_PER_MGDL_BGL: number;
|
|
32
|
-
/** The conversion factor to multiply a blood glucose value with to go from mg/dL to mmol/L. */
|
|
33
|
-
export declare const MGDL_PER_MMOLL_BGL: number;
|
|
34
|
-
/** The lower and upper limits of the entered blood ketones value in mmol/L. */
|
|
35
|
-
export declare const CURRENT_BKL_MMOL_LIMITS: IInterval;
|
|
36
|
-
/** The conversion factor to multiply a blood ketones value with to go from mmol/L to mg/dL. */
|
|
37
|
-
export declare const MMOLL_PER_MGDL_BKL: number;
|
|
38
|
-
/** The conversion factor to multiply a blood ketones value with to go from mg/dL to mmol/L. */
|
|
39
|
-
export declare const MGDL_PER_MMOLL_BKL: number;
|
|
40
|
-
/** The lower and upper limits for a valid BGL target in mmol/L. */
|
|
41
|
-
export declare const TARGET_BGL_MMOL_LIMITS: IInterval;
|
|
42
|
-
/** The lower and upper limits for a valid activity BGL target in mmol/L. */
|
|
43
|
-
export declare const ACTIVITY_TARGET_BGL_MMOL_LIMITS: IInterval;
|
|
44
|
-
/** The lower and upper limits for how long the reminder notification timer may be. */
|
|
45
|
-
export declare const REMINDER_HOURS_LIMITS: IInterval;
|
|
46
|
-
/** The lower and upper limits for activity reduction. */
|
|
47
|
-
export declare const ACTIVITY_SETTINGS_INTERVAL_LIMITS: IInterval;
|
package/src/utils/Constants.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { BolusCalculator } from "@hedia/types";
|
|
2
|
-
/** Reusable color definition. */
|
|
3
|
-
export const BACKGROUND_COLOUR_PURPLE = `rgba(27, 31, 72, 1)`;
|
|
4
|
-
/** Reusable color definition. */
|
|
5
|
-
export const BORDER_COLOUR_GREY = `rgba(74, 91, 134, 1)`;
|
|
6
|
-
/** Reusable color definition. */
|
|
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 */
|
|
9
|
-
export const SEVERE_HYPERGLYCEMIA_START_MMOL = 15;
|
|
10
|
-
/** The number of seconds in four hours. */
|
|
11
|
-
export const FOUR_HOURS_SECONDS = 14400;
|
|
12
|
-
/** The number of minutes in one hour. */
|
|
13
|
-
export const ONE_HOUR_MINUTES = 60;
|
|
14
|
-
/** Extra time before an activity starts or stops. */
|
|
15
|
-
export const ACTIVITY_BUFFER_MINUTES = 10;
|
|
16
|
-
/** The lower and upper limits for the amount of carbohydrates in grams. */
|
|
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. */
|
|
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. */
|
|
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. */
|
|
23
|
-
export const ACTIVITY_DURATION_MINUTES_LIMITS = { min: 1, max: ONE_HOUR_MINUTES };
|
|
24
|
-
/** The lower and upper limits of insulin sensitivity settings. */
|
|
25
|
-
export const INSULIN_SENSITIVITY_MMOL_LIMITS = { min: 0.3, max: 10 };
|
|
26
|
-
/** The lower and upper limits of insulin-to-carbs ratio settings. */
|
|
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. */
|
|
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. */
|
|
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. */
|
|
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. */
|
|
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. */
|
|
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. */
|
|
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. */
|
|
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. */
|
|
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. */
|
|
45
|
-
export const REMINDER_HOURS_LIMITS = { min: 0, max: 6 };
|
|
46
|
-
/** The lower and upper limits for activity reduction. */
|
|
47
|
-
export const ACTIVITY_SETTINGS_INTERVAL_LIMITS = { min: 0, max: 1 };
|
|
@@ -1,56 +0,0 @@
|
|
|
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
|
-
*/
|
|
9
|
-
export declare class RecommendationError extends Error {
|
|
10
|
-
readonly type: RecommendationErrorEnum;
|
|
11
|
-
constructor(message: string, type: RecommendationErrorEnum);
|
|
12
|
-
}
|
|
13
|
-
/** The given activity settings are corrupt. */
|
|
14
|
-
export declare const ActivitySettingsError: () => RecommendationError;
|
|
15
|
-
/** The duration of the given activity is invalid. */
|
|
16
|
-
export declare const ActivityDurationError: () => RecommendationError;
|
|
17
|
-
/** The start date of the given activity is invalid. */
|
|
18
|
-
export declare const ActivityDateError: () => RecommendationError;
|
|
19
|
-
/** The intensity of the given activity is invalid. */
|
|
20
|
-
export declare const ActivityIntensityError: () => RecommendationError;
|
|
21
|
-
/** Type of the given activity is invalid. */
|
|
22
|
-
export declare const ActivityTypeError: () => RecommendationError;
|
|
23
|
-
/** The user’s activity target BGL setting is invalid. */
|
|
24
|
-
export declare const ActivityTargetBGLError: () => RecommendationError;
|
|
25
|
-
/** More than 300 g carbohydrates entered. */
|
|
26
|
-
export declare const CarbohydrateLimitError: () => RecommendationError;
|
|
27
|
-
/** The user’s insulin sensitivity setting is outside of the valid range. */
|
|
28
|
-
export declare const InsulinSensitivityError: () => RecommendationError;
|
|
29
|
-
/** The user’s insulin-to-carbs ratio setting is outside of the valid range. */
|
|
30
|
-
export declare const InsulinToCarbsRatioError: () => RecommendationError;
|
|
31
|
-
/** The entered current blood glucose level is outside of the valid range. */
|
|
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. */
|
|
34
|
-
export declare const LatestLogbook6HoursBGLError: () => RecommendationError;
|
|
35
|
-
/** The entered current blood ketones concentration is outside of the valid range. */
|
|
36
|
-
export declare const CurrentBKLError: () => RecommendationError;
|
|
37
|
-
/** The user’s target BGL setting is outside of the valid range. */
|
|
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. */
|
|
40
|
-
export declare const BolusInsulinDoseError: () => RecommendationError;
|
|
41
|
-
/** At least one entry from the list of recent logbook entries is older than 4 hours. */
|
|
42
|
-
export declare const BolusInsulinSecondsPassedError: () => RecommendationError;
|
|
43
|
-
/** The user’s recent boluses entries are not in the allowed format. */
|
|
44
|
-
export declare const RecentBolusError: () => RecommendationError;
|
|
45
|
-
/** The user’s setting for initial reminder time is outside of the valid range. */
|
|
46
|
-
export declare const UserReminderError: () => RecommendationError;
|
|
47
|
-
/** The user’s insulin injection method setting is invalid. */
|
|
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 */
|
|
50
|
-
export declare const LanguageError: () => RecommendationError;
|
|
51
|
-
/** The user’s blood ketones unit setting is invalid. */
|
|
52
|
-
export declare const BloodKetoneUnitError: () => RecommendationError;
|
|
53
|
-
/** The user’s blood glucose level measuring unit setting is invalid. */
|
|
54
|
-
export declare const BloodGlucoseUnitError: () => RecommendationError;
|
|
55
|
-
/** The user has provided a blood ketone level but the blood ketone measuring unit is not defined. */
|
|
56
|
-
export declare const BloodKetonePropsError: () => RecommendationError;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { BolusCalculator } from "@hedia/types";
|
|
2
|
-
import { t } from "@lingui/macro";
|
|
3
|
-
import { i18n } from "../locale/i18nUtils";
|
|
4
|
-
import { RecommendationErrorEnum } from "../types/enum";
|
|
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
|
-
*/
|
|
13
|
-
export class RecommendationError extends Error {
|
|
14
|
-
constructor(message, type) {
|
|
15
|
-
super(message);
|
|
16
|
-
this.type = type;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
/** The given activity settings are corrupt. */
|
|
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. */
|
|
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. */
|
|
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. */
|
|
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. */
|
|
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. */
|
|
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. */
|
|
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. */
|
|
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. */
|
|
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. */
|
|
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. */
|
|
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. */
|
|
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. */
|
|
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. */
|
|
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. */
|
|
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. */
|
|
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. */
|
|
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. */
|
|
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 */
|
|
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. */
|
|
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. */
|
|
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. */
|
|
62
|
-
export const BloodKetonePropsError = () => new RecommendationError(i18n._(t `Error. Your blood ketone settings are invalid.`), RecommendationErrorEnum.BloodKetoneProps);
|
|
@@ -1,100 +0,0 @@
|
|
|
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";
|
|
6
|
-
import { BgLevel } from "../types/enum";
|
|
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
|
-
*/
|
|
100
|
-
export declare function getLimitationMessage(wasLimited: boolean, activityReduction: number | null): string | null;
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Helper functions for processing and categorising user inputs for determining which warnings and messages to display.
|
|
3
|
-
* @module
|
|
4
|
-
*/
|
|
5
|
-
import moment from "moment";
|
|
6
|
-
import { BgLevel, RecommendationReminders } from "../types/enum";
|
|
7
|
-
import { addPostponeActivityMessageUnder5MMOL, AttentionMessage, Messages } from "./AttentionMessages";
|
|
8
|
-
import { SEVERE_HYPERGLYCEMIA_START_MMOL } from "./Constants";
|
|
9
|
-
import { CurrentBGLError } from "./RecommendationError";
|
|
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
|
-
*/
|
|
28
|
-
export function getBGLevel(currentBGL, latestLogbookFrom6Hours) {
|
|
29
|
-
if (currentBGL === null) {
|
|
30
|
-
return BgLevel.BGLevelNotProvided;
|
|
31
|
-
}
|
|
32
|
-
if (currentBGL >= 1.1 && currentBGL <= 2) {
|
|
33
|
-
return BgLevel.SevereHypoglycemia;
|
|
34
|
-
}
|
|
35
|
-
if (currentBGL > 2 && currentBGL <= 3.5) {
|
|
36
|
-
return BgLevel.Hypoglycemia;
|
|
37
|
-
}
|
|
38
|
-
if (currentBGL > 3.5 && currentBGL <= 4) {
|
|
39
|
-
return BgLevel.MildHypoglycemia;
|
|
40
|
-
}
|
|
41
|
-
if (currentBGL > 4 && currentBGL < 5) {
|
|
42
|
-
return BgLevel.NormoglycemiaUnder5MMOL;
|
|
43
|
-
}
|
|
44
|
-
if (currentBGL >= 5 && currentBGL <= 7) {
|
|
45
|
-
return BgLevel.Normoglycemia;
|
|
46
|
-
}
|
|
47
|
-
if (currentBGL > 7 && currentBGL < 15) {
|
|
48
|
-
return BgLevel.MildHyperglycemia;
|
|
49
|
-
}
|
|
50
|
-
if (currentBGL > 15 && currentBGL <= 33.3 && latestLogbookFrom6Hours
|
|
51
|
-
? isSevereHyperglycemia(latestLogbookFrom6Hours)
|
|
52
|
-
: false) {
|
|
53
|
-
return BgLevel.SevereHyperglycemia;
|
|
54
|
-
}
|
|
55
|
-
if (currentBGL >= 15 && currentBGL <= 33.3) {
|
|
56
|
-
return BgLevel.Hyperglycemia;
|
|
57
|
-
}
|
|
58
|
-
return BgLevel.UnsupportedBGLevel;
|
|
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
|
-
*/
|
|
78
|
-
export function getReminder(bgLevel, carbohydrates, userReminder, activity) {
|
|
79
|
-
const reminder = userReminder === undefined ? RecommendationReminders.HediaReminderDefault : userReminder;
|
|
80
|
-
switch (bgLevel) {
|
|
81
|
-
case BgLevel.SevereHypoglycemia:
|
|
82
|
-
case BgLevel.Hypoglycemia:
|
|
83
|
-
case BgLevel.MildHypoglycemia:
|
|
84
|
-
return RecommendationReminders.Reminder15Minutes;
|
|
85
|
-
case BgLevel.NormoglycemiaUnder5MMOL:
|
|
86
|
-
case BgLevel.Normoglycemia:
|
|
87
|
-
case BgLevel.MildHyperglycemia:
|
|
88
|
-
case BgLevel.BGLevelNotProvided:
|
|
89
|
-
return carbohydrates || activity ? reminder : RecommendationReminders.ReminderOff;
|
|
90
|
-
case BgLevel.Hyperglycemia:
|
|
91
|
-
case BgLevel.SevereHyperglycemia:
|
|
92
|
-
return isActivityWithin15Minutes(activity)
|
|
93
|
-
? RecommendationReminders.Reminder15Minutes
|
|
94
|
-
: RecommendationReminders.Reminder60Minutes;
|
|
95
|
-
default:
|
|
96
|
-
throw CurrentBGLError();
|
|
97
|
-
}
|
|
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
|
-
*/
|
|
123
|
-
export function getAttentionMessage(bgLevel, activity) {
|
|
124
|
-
const key = Utils.getKeyFromValue(BgLevel, bgLevel);
|
|
125
|
-
const isAttentionMessageNull = AttentionMessage[key] === null;
|
|
126
|
-
const isWithin15Minutes = isActivityWithin15Minutes(activity);
|
|
127
|
-
switch (bgLevel) {
|
|
128
|
-
case BgLevel.BGLevelNotProvided:
|
|
129
|
-
case BgLevel.Normoglycemia:
|
|
130
|
-
case BgLevel.MildHyperglycemia:
|
|
131
|
-
return null;
|
|
132
|
-
case BgLevel.NormoglycemiaUnder5MMOL:
|
|
133
|
-
return isWithin15Minutes ? AttentionMessage.NormoglycemiaActivityUnder5MMOL() : null;
|
|
134
|
-
case BgLevel.SevereHypoglycemia:
|
|
135
|
-
case BgLevel.Hypoglycemia:
|
|
136
|
-
case BgLevel.MildHypoglycemia:
|
|
137
|
-
return isWithin15Minutes && !isAttentionMessageNull
|
|
138
|
-
? addPostponeActivityMessageUnder5MMOL(AttentionMessage[key]())
|
|
139
|
-
: AttentionMessage[key]();
|
|
140
|
-
case BgLevel.Hyperglycemia:
|
|
141
|
-
return isWithin15Minutes ? AttentionMessage.HyperglycemiaActivity() : null;
|
|
142
|
-
case BgLevel.SevereHyperglycemia:
|
|
143
|
-
return isWithin15Minutes
|
|
144
|
-
? AttentionMessage.SevereHyperglycemiaActivity()
|
|
145
|
-
: AttentionMessage.SevereHyperglycemia();
|
|
146
|
-
default:
|
|
147
|
-
throw CurrentBGLError();
|
|
148
|
-
}
|
|
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
|
-
*/
|
|
159
|
-
export function isSevereHyperglycemia(logbook) {
|
|
160
|
-
if (logbook !== null && logbook !== undefined) {
|
|
161
|
-
const { blood_glucose_millimolar } = logbook;
|
|
162
|
-
if (blood_glucose_millimolar !== null) {
|
|
163
|
-
return blood_glucose_millimolar > SEVERE_HYPERGLYCEMIA_START_MMOL;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return false;
|
|
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
|
-
*/
|
|
177
|
-
export function isActivityWithin15Minutes(activity) {
|
|
178
|
-
const minutes = activity?.activityDuration;
|
|
179
|
-
return moment
|
|
180
|
-
.utc(activity?.activityDate)
|
|
181
|
-
.isBetween(moment.utc().subtract(minutes, `minutes`), moment.utc().add(15, `minutes`));
|
|
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
|
-
*/
|
|
194
|
-
export function getLimitationMessage(wasLimited, activityReduction) {
|
|
195
|
-
const message = activityReduction
|
|
196
|
-
? Messages.RecommendationWasLimitedActivity(activityReduction)
|
|
197
|
-
: Messages.RecommendationWasLimited();
|
|
198
|
-
return wasLimited ? message : null;
|
|
199
|
-
}
|