@hedia/recommendation-screen 1.2.0 → 1.3.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/.idea/workspace.xml +60 -98
- package/package.json +1 -1
- package/src/RecommendationScreen.d.ts +3 -0
- package/src/RecommendationScreen.jsx +51 -42
- package/src/RecommendationScreen.tsx +82 -57
- package/src/components/InfoBars.d.ts +2 -0
- package/src/components/InfoBars.jsx +4 -4
- package/src/components/InfoBars.tsx +6 -6
- package/src/components/InvisibleNumberInput.d.ts +1 -0
- package/src/components/InvisibleNumberInput.jsx +1 -1
- package/src/components/InvisibleNumberInput.tsx +3 -0
- package/src/components/RecommendedCarbs.d.ts +0 -2
- package/src/components/RecommendedCarbs.jsx +8 -3
- package/src/components/RecommendedCarbs.tsx +10 -5
- package/src/components/RecommendedInsulin.d.ts +3 -3
- package/src/components/RecommendedInsulin.jsx +18 -6
- package/src/components/RecommendedInsulin.tsx +24 -10
- package/src/components/activity/ActivityIcon.jsx +1 -1
- package/src/components/activity/ActivityIcon.tsx +1 -1
- package/src/types/enum.d.ts +9 -10
- package/src/types/enum.js +9 -10
- package/src/types/enum.ts +0 -1
- package/src/types/types.ts +1 -0
- package/src/utils/AttentionMessages.d.ts +1 -1
- package/src/utils/AttentionMessages.jsx +1 -1
- package/src/utils/AttentionMessages.tsx +1 -1
- package/src/utils/Constants.d.ts +3 -0
- package/src/utils/Constants.js +4 -1
- package/src/utils/Constants.ts +5 -0
- package/src/utils/RecommendationError.d.ts +0 -1
- package/src/utils/RecommendationError.jsx +1 -3
- package/src/utils/RecommendationError.tsx +0 -7
- package/src/utils/RecommendationUtils.d.ts +2 -3
- package/src/utils/RecommendationUtils.js +3 -4
- package/src/utils/RecommendationUtils.ts +2 -4
- package/src/utils/Utils.d.ts +1 -0
- package/src/utils/Utils.js +4 -0
- package/src/utils/Utils.ts +4 -0
- package/src/utils/Validations.js +15 -11
- package/src/utils/Validations.ts +16 -11
|
@@ -27,7 +27,7 @@ class ActivityIcon extends react_1.default.Component {
|
|
|
27
27
|
const label = `${enum_1.ActivityEnum[activityType]}_activity`;
|
|
28
28
|
return (<react_native_1.View style={activityIconStyles.container}>
|
|
29
29
|
<react_native_1.Image style={activityIconStyles.activityIcon} source={this.getActivityIcon()} accessibilityLabel={label}/>
|
|
30
|
-
<react_native_1.Text style={activityIconStyles.activityTitle}>{activityTitle
|
|
30
|
+
<react_native_1.Text style={activityIconStyles.activityTitle}>{activityTitle || i18nUtils_1.i18n._(macro_1.t `Untitled Activity`)}</react_native_1.Text>
|
|
31
31
|
</react_native_1.View>);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -28,7 +28,7 @@ export default class ActivityIcon extends React.Component<IActivityType & IActiv
|
|
|
28
28
|
source={this.getActivityIcon()}
|
|
29
29
|
accessibilityLabel={label}
|
|
30
30
|
/>
|
|
31
|
-
<Text style={activityIconStyles.activityTitle}>{activityTitle
|
|
31
|
+
<Text style={activityIconStyles.activityTitle}>{activityTitle || i18n._(t`Untitled Activity`)}</Text>
|
|
32
32
|
</View>
|
|
33
33
|
);
|
|
34
34
|
}
|
package/src/types/enum.d.ts
CHANGED
|
@@ -39,16 +39,15 @@ export declare enum RecommendationErrorEnum {
|
|
|
39
39
|
BolusInsulinDosis = 5,
|
|
40
40
|
BolusInsulinSecondsPassed = 6,
|
|
41
41
|
CarbohydrateLimit = 7,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
TimeoutLimit = 17
|
|
42
|
+
InsulinSensitivity = 8,
|
|
43
|
+
InsulinToCarbsRatio = 9,
|
|
44
|
+
CurrentBGL = 10,
|
|
45
|
+
TargetBGL = 11,
|
|
46
|
+
UserReminder = 12,
|
|
47
|
+
Language = 13,
|
|
48
|
+
InjectionMethod = 14,
|
|
49
|
+
Unit = 15,
|
|
50
|
+
TimeoutLimit = 16
|
|
52
51
|
}
|
|
53
52
|
export declare enum Milliseconds {
|
|
54
53
|
Second = 1000,
|
package/src/types/enum.js
CHANGED
|
@@ -49,16 +49,15 @@ var RecommendationErrorEnum;
|
|
|
49
49
|
RecommendationErrorEnum[RecommendationErrorEnum["BolusInsulinDosis"] = 5] = "BolusInsulinDosis";
|
|
50
50
|
RecommendationErrorEnum[RecommendationErrorEnum["BolusInsulinSecondsPassed"] = 6] = "BolusInsulinSecondsPassed";
|
|
51
51
|
RecommendationErrorEnum[RecommendationErrorEnum["CarbohydrateLimit"] = 7] = "CarbohydrateLimit";
|
|
52
|
-
RecommendationErrorEnum[RecommendationErrorEnum["
|
|
53
|
-
RecommendationErrorEnum[RecommendationErrorEnum["
|
|
54
|
-
RecommendationErrorEnum[RecommendationErrorEnum["
|
|
55
|
-
RecommendationErrorEnum[RecommendationErrorEnum["
|
|
56
|
-
RecommendationErrorEnum[RecommendationErrorEnum["
|
|
57
|
-
RecommendationErrorEnum[RecommendationErrorEnum["
|
|
58
|
-
RecommendationErrorEnum[RecommendationErrorEnum["
|
|
59
|
-
RecommendationErrorEnum[RecommendationErrorEnum["
|
|
60
|
-
RecommendationErrorEnum[RecommendationErrorEnum["
|
|
61
|
-
RecommendationErrorEnum[RecommendationErrorEnum["TimeoutLimit"] = 17] = "TimeoutLimit";
|
|
52
|
+
RecommendationErrorEnum[RecommendationErrorEnum["InsulinSensitivity"] = 8] = "InsulinSensitivity";
|
|
53
|
+
RecommendationErrorEnum[RecommendationErrorEnum["InsulinToCarbsRatio"] = 9] = "InsulinToCarbsRatio";
|
|
54
|
+
RecommendationErrorEnum[RecommendationErrorEnum["CurrentBGL"] = 10] = "CurrentBGL";
|
|
55
|
+
RecommendationErrorEnum[RecommendationErrorEnum["TargetBGL"] = 11] = "TargetBGL";
|
|
56
|
+
RecommendationErrorEnum[RecommendationErrorEnum["UserReminder"] = 12] = "UserReminder";
|
|
57
|
+
RecommendationErrorEnum[RecommendationErrorEnum["Language"] = 13] = "Language";
|
|
58
|
+
RecommendationErrorEnum[RecommendationErrorEnum["InjectionMethod"] = 14] = "InjectionMethod";
|
|
59
|
+
RecommendationErrorEnum[RecommendationErrorEnum["Unit"] = 15] = "Unit";
|
|
60
|
+
RecommendationErrorEnum[RecommendationErrorEnum["TimeoutLimit"] = 16] = "TimeoutLimit";
|
|
62
61
|
})(RecommendationErrorEnum = exports.RecommendationErrorEnum || (exports.RecommendationErrorEnum = {}));
|
|
63
62
|
var Milliseconds;
|
|
64
63
|
(function (Milliseconds) {
|
package/src/types/enum.ts
CHANGED
package/src/types/types.ts
CHANGED
|
@@ -17,5 +17,5 @@ export declare class Messages {
|
|
|
17
17
|
static InsulinKetones: () => string;
|
|
18
18
|
static RecommendationWasLimited: () => string;
|
|
19
19
|
static RecommendationWasLimitedActivity: (activityReduction: number) => string;
|
|
20
|
-
static
|
|
20
|
+
static InsulinInputWasLimited: (activityReduction?: number) => string;
|
|
21
21
|
}
|
|
@@ -57,7 +57,7 @@ Messages.RecommendationWasLimitedActivity = (activityReduction) => i18nUtils_1.i
|
|
|
57
57
|
units of insulin per calculation, but because of the physical activity
|
|
58
58
|
you entered it has been further reduced by ${(activityReduction * 100).toFixed(0)}% to
|
|
59
59
|
${getLimitedValue(activityReduction)}.`);
|
|
60
|
-
Messages.
|
|
60
|
+
Messages.InsulinInputWasLimited = (activityReduction) => activityReduction
|
|
61
61
|
? i18nUtils_1.i18n._(macro_1.t `Hedia doesn't support more than ${Calculator.SAFETY_INSULIN_LIMIT} units of insulin per calculation, but because of the physical activity you entered it has been further reduced by
|
|
62
62
|
${(activityReduction * 100).toFixed(0)}% to ${getLimitedValue(activityReduction)} units for this calculation.`)
|
|
63
63
|
: i18nUtils_1.i18n._(macro_1.t `Hedia does not support more than ${Calculator.SAFETY_INSULIN_LIMIT} units of insulin per calculation.`);
|
|
@@ -46,7 +46,7 @@ export class Messages {
|
|
|
46
46
|
you entered it has been further reduced by ${(activityReduction * 100).toFixed(0)}% to
|
|
47
47
|
${getLimitedValue(activityReduction)}.`,
|
|
48
48
|
);
|
|
49
|
-
public static
|
|
49
|
+
public static InsulinInputWasLimited = (activityReduction?: number): string =>
|
|
50
50
|
activityReduction
|
|
51
51
|
? i18n._(
|
|
52
52
|
t`Hedia doesn't support more than ${
|
package/src/utils/Constants.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare const BORDER_COLOUR_TEAL = "rgba(1, 255, 252, 0.8)";
|
|
|
5
5
|
export declare const SEVERE_HYPERGLYCEMIA_START_MMOL = 15;
|
|
6
6
|
export declare const FOUR_HOURS_SECONDS = 14400;
|
|
7
7
|
export declare const ONE_HOUR_MINUTES = 60;
|
|
8
|
+
export declare const ACTIVITY_BUFFER_MINUTES = 10;
|
|
8
9
|
export declare const CARBOHYDRATES_LIMTS: IInterval;
|
|
9
10
|
export declare const INSULIN_DOSIS_LIMITS: IInterval;
|
|
10
11
|
export declare const BOLUS_SECONDS_PASSED_LIMITS: IInterval;
|
|
@@ -12,6 +13,8 @@ export declare const ACTIVITY_DURATION_MINUTES_LIMITS: IInterval;
|
|
|
12
13
|
export declare const INSULIN_SENSITIVITY_MMOL_LIMITS: IInterval;
|
|
13
14
|
export declare const INSULIN_TO_CARBS_RATIO_LIMITS: IInterval;
|
|
14
15
|
export declare const CURRENT_BGL_MMOL_LIMITS: IInterval;
|
|
16
|
+
export declare const MMOLL_PER_MGDL: number;
|
|
17
|
+
export declare const MGDL_PER_MMOLL: number;
|
|
15
18
|
export declare const TARGET_BGL_MMOL_LIMITS: IInterval;
|
|
16
19
|
export declare const ACTIVITY_TARGET_BGL_MMOL_LIMITS: IInterval;
|
|
17
20
|
export declare const REMINDER_HOURS_LIMITS: IInterval;
|
package/src/utils/Constants.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ACTIVITY_SETTINGS_INTERVAL_LIMITS = exports.REMINDER_HOURS_LIMITS = exports.ACTIVITY_TARGET_BGL_MMOL_LIMITS = exports.TARGET_BGL_MMOL_LIMITS = exports.CURRENT_BGL_MMOL_LIMITS = exports.INSULIN_TO_CARBS_RATIO_LIMITS = exports.INSULIN_SENSITIVITY_MMOL_LIMITS = exports.ACTIVITY_DURATION_MINUTES_LIMITS = exports.BOLUS_SECONDS_PASSED_LIMITS = exports.INSULIN_DOSIS_LIMITS = exports.CARBOHYDRATES_LIMTS = exports.ONE_HOUR_MINUTES = exports.FOUR_HOURS_SECONDS = exports.SEVERE_HYPERGLYCEMIA_START_MMOL = exports.BORDER_COLOUR_TEAL = exports.BORDER_COLOUR_GREY = exports.BACKGROUND_COLOUR_PURPLE = void 0;
|
|
3
|
+
exports.ACTIVITY_SETTINGS_INTERVAL_LIMITS = exports.REMINDER_HOURS_LIMITS = exports.ACTIVITY_TARGET_BGL_MMOL_LIMITS = exports.TARGET_BGL_MMOL_LIMITS = exports.MGDL_PER_MMOLL = exports.MMOLL_PER_MGDL = exports.CURRENT_BGL_MMOL_LIMITS = exports.INSULIN_TO_CARBS_RATIO_LIMITS = exports.INSULIN_SENSITIVITY_MMOL_LIMITS = exports.ACTIVITY_DURATION_MINUTES_LIMITS = exports.BOLUS_SECONDS_PASSED_LIMITS = exports.INSULIN_DOSIS_LIMITS = exports.CARBOHYDRATES_LIMTS = exports.ACTIVITY_BUFFER_MINUTES = exports.ONE_HOUR_MINUTES = exports.FOUR_HOURS_SECONDS = exports.SEVERE_HYPERGLYCEMIA_START_MMOL = exports.BORDER_COLOUR_TEAL = exports.BORDER_COLOUR_GREY = exports.BACKGROUND_COLOUR_PURPLE = void 0;
|
|
4
4
|
exports.BACKGROUND_COLOUR_PURPLE = `rgba(27, 31, 72, 1)`;
|
|
5
5
|
exports.BORDER_COLOUR_GREY = `rgba(74, 91, 134, 1)`;
|
|
6
6
|
exports.BORDER_COLOUR_TEAL = `rgba(1, 255, 252, 0.8)`;
|
|
7
7
|
exports.SEVERE_HYPERGLYCEMIA_START_MMOL = 15;
|
|
8
8
|
exports.FOUR_HOURS_SECONDS = 14400;
|
|
9
9
|
exports.ONE_HOUR_MINUTES = 60;
|
|
10
|
+
exports.ACTIVITY_BUFFER_MINUTES = 10;
|
|
10
11
|
exports.CARBOHYDRATES_LIMTS = { min: 0, max: 300 };
|
|
11
12
|
exports.INSULIN_DOSIS_LIMITS = { min: 0, max: 50 };
|
|
12
13
|
exports.BOLUS_SECONDS_PASSED_LIMITS = { min: 0, max: exports.FOUR_HOURS_SECONDS };
|
|
@@ -14,6 +15,8 @@ exports.ACTIVITY_DURATION_MINUTES_LIMITS = { min: 1, max: exports.ONE_HOUR_MINUT
|
|
|
14
15
|
exports.INSULIN_SENSITIVITY_MMOL_LIMITS = { min: 0.3, max: 10 };
|
|
15
16
|
exports.INSULIN_TO_CARBS_RATIO_LIMITS = { min: 1, max: 50 };
|
|
16
17
|
exports.CURRENT_BGL_MMOL_LIMITS = { min: 1.1, max: 33.3 };
|
|
18
|
+
exports.MMOLL_PER_MGDL = 0.0555;
|
|
19
|
+
exports.MGDL_PER_MMOLL = 1 / exports.MMOLL_PER_MGDL;
|
|
17
20
|
exports.TARGET_BGL_MMOL_LIMITS = { min: 5, max: 13.9 };
|
|
18
21
|
exports.ACTIVITY_TARGET_BGL_MMOL_LIMITS = { min: 5, max: 13.9 };
|
|
19
22
|
exports.REMINDER_HOURS_LIMITS = { min: 0, max: 6 };
|
package/src/utils/Constants.ts
CHANGED
|
@@ -8,6 +8,8 @@ export const SEVERE_HYPERGLYCEMIA_START_MMOL = 15;
|
|
|
8
8
|
|
|
9
9
|
export const FOUR_HOURS_SECONDS = 14400;
|
|
10
10
|
export const ONE_HOUR_MINUTES = 60;
|
|
11
|
+
export const ACTIVITY_BUFFER_MINUTES = 10;
|
|
12
|
+
|
|
11
13
|
export const CARBOHYDRATES_LIMTS: IInterval = { min: 0, max: 300 };
|
|
12
14
|
export const INSULIN_DOSIS_LIMITS: IInterval = { min: 0, max: 50 };
|
|
13
15
|
export const BOLUS_SECONDS_PASSED_LIMITS: IInterval = { min: 0, max: FOUR_HOURS_SECONDS };
|
|
@@ -17,6 +19,9 @@ export const INSULIN_SENSITIVITY_MMOL_LIMITS: IInterval = { min: 0.3, max: 10 };
|
|
|
17
19
|
export const INSULIN_TO_CARBS_RATIO_LIMITS: IInterval = { min: 1, max: 50 };
|
|
18
20
|
|
|
19
21
|
export const CURRENT_BGL_MMOL_LIMITS: IInterval = { min: 1.1, max: 33.3 };
|
|
22
|
+
export const MMOLL_PER_MGDL: number = 0.0555;
|
|
23
|
+
export const MGDL_PER_MMOLL: number = 1 / MMOLL_PER_MGDL;
|
|
24
|
+
|
|
20
25
|
export const TARGET_BGL_MMOL_LIMITS: IInterval = { min: 5, max: 13.9 };
|
|
21
26
|
export const ACTIVITY_TARGET_BGL_MMOL_LIMITS: IInterval = { min: 5, max: 13.9 };
|
|
22
27
|
export const REMINDER_HOURS_LIMITS: IInterval = { min: 0, max: 6 };
|
|
@@ -9,7 +9,6 @@ export declare const ActivityDateError: () => RecommendationError;
|
|
|
9
9
|
export declare const ActivityIntensityError: () => RecommendationError;
|
|
10
10
|
export declare const ActivityTargetBGLError: () => RecommendationError;
|
|
11
11
|
export declare const CarbohydrateLimitError: () => RecommendationError;
|
|
12
|
-
export declare const InsulinLimitError: (activityReduction?: number) => RecommendationError;
|
|
13
12
|
export declare const InsulinSensitivityError: () => RecommendationError;
|
|
14
13
|
export declare const InsulinToCarbsRatioError: () => RecommendationError;
|
|
15
14
|
export declare const CurrentBGLError: () => RecommendationError;
|
|
@@ -19,12 +19,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.TimeoutLimitError = exports.UnitError = exports.LanguageError = exports.InjectionMethodError = exports.UserReminderError = exports.BolusInsulinSecondsPassedError = exports.BolusInsulinDosisError = exports.TargetBGLError = exports.CurrentBGLError = exports.InsulinToCarbsRatioError = exports.InsulinSensitivityError = exports.
|
|
22
|
+
exports.TimeoutLimitError = exports.UnitError = exports.LanguageError = exports.InjectionMethodError = exports.UserReminderError = exports.BolusInsulinSecondsPassedError = exports.BolusInsulinDosisError = exports.TargetBGLError = exports.CurrentBGLError = exports.InsulinToCarbsRatioError = exports.InsulinSensitivityError = exports.CarbohydrateLimitError = exports.ActivityTargetBGLError = exports.ActivityIntensityError = exports.ActivityDateError = exports.ActivityDurationError = exports.ActivitySettingsError = exports.RecommendationError = void 0;
|
|
23
23
|
const Calculator = __importStar(require("@hedia/recommendation-calculator"));
|
|
24
24
|
const macro_1 = require("@lingui/macro");
|
|
25
25
|
const i18nUtils_1 = require("../locale/i18nUtils");
|
|
26
26
|
const enum_1 = require("../types/enum");
|
|
27
|
-
const AttentionMessages_1 = require("./AttentionMessages");
|
|
28
27
|
class RecommendationError extends Error {
|
|
29
28
|
constructor(message, type) {
|
|
30
29
|
super(message);
|
|
@@ -38,7 +37,6 @@ exports.ActivityDateError = () => new RecommendationError(i18nUtils_1.i18n._(mac
|
|
|
38
37
|
exports.ActivityIntensityError = () => new RecommendationError(i18nUtils_1.i18n._(macro_1.t `Error. Hedia Calculator does not support your activity intensity value`), enum_1.RecommendationErrorEnum.ActivityIntensity);
|
|
39
38
|
exports.ActivityTargetBGLError = () => new RecommendationError(i18nUtils_1.i18n._(macro_1.t `Error. Please verify that your activity target blood glucose value is correct.`), enum_1.RecommendationErrorEnum.ActivityTargetBGL);
|
|
40
39
|
exports.CarbohydrateLimitError = () => new RecommendationError(i18nUtils_1.i18n._(macro_1.t `Hedia Calculator does not support insulin recommendations with more than 300 grams of carbohydrates present.`), enum_1.RecommendationErrorEnum.CarbohydrateLimit);
|
|
41
|
-
exports.InsulinLimitError = (activityReduction) => new RecommendationError(activityReduction ? AttentionMessages_1.Messages.InsulinWasLimited(activityReduction) : AttentionMessages_1.Messages.InsulinWasLimited(), enum_1.RecommendationErrorEnum.InsulinLimit);
|
|
42
40
|
exports.InsulinSensitivityError = () => new RecommendationError(i18nUtils_1.i18n._(macro_1.t `Error. Please verify that your insulin sensitivity value is correct.`), enum_1.RecommendationErrorEnum.InsulinSensitivity);
|
|
43
41
|
exports.InsulinToCarbsRatioError = () => new RecommendationError(i18nUtils_1.i18n._(macro_1.t `Error. Please verify that your insulin to carb ratio value is correct.`), enum_1.RecommendationErrorEnum.InsulinToCarbsRatio);
|
|
44
42
|
exports.CurrentBGLError = () => new RecommendationError(i18nUtils_1.i18n._(macro_1.t `Error. Hedia Calculator does not support your current blood glucose level.`), enum_1.RecommendationErrorEnum.CurrentBGL);
|
|
@@ -2,7 +2,6 @@ import * as Calculator from "@hedia/recommendation-calculator";
|
|
|
2
2
|
import { t } from "@lingui/macro";
|
|
3
3
|
import { i18n } from "../locale/i18nUtils";
|
|
4
4
|
import { RecommendationErrorEnum } from "../types/enum";
|
|
5
|
-
import { Messages } from "./AttentionMessages";
|
|
6
5
|
|
|
7
6
|
export class RecommendationError extends Error {
|
|
8
7
|
public readonly type: RecommendationErrorEnum;
|
|
@@ -51,12 +50,6 @@ export const CarbohydrateLimitError = (): RecommendationError =>
|
|
|
51
50
|
RecommendationErrorEnum.CarbohydrateLimit,
|
|
52
51
|
);
|
|
53
52
|
|
|
54
|
-
export const InsulinLimitError = (activityReduction?: number): RecommendationError =>
|
|
55
|
-
new RecommendationError(
|
|
56
|
-
activityReduction ? Messages.InsulinWasLimited(activityReduction) : Messages.InsulinWasLimited(),
|
|
57
|
-
RecommendationErrorEnum.InsulinLimit,
|
|
58
|
-
);
|
|
59
|
-
|
|
60
53
|
export const InsulinSensitivityError = (): RecommendationError =>
|
|
61
54
|
new RecommendationError(
|
|
62
55
|
i18n._(t`Error. Please verify that your insulin sensitivity value is correct.`),
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { IRecommendationParams } from "@hedia/recommendation-calculator";
|
|
2
|
-
import { IRecommendationProps } from "../RecommendationScreen";
|
|
3
2
|
import { BgLevel } from "../types/enum";
|
|
4
|
-
import {
|
|
3
|
+
import { logbookEntry } from "../types/types";
|
|
5
4
|
import { AttentionMessage, Messages } from "./AttentionMessages";
|
|
6
5
|
export declare function getBGLevel(currentBGL: number, latestLogbookFrom6Hours: logbookEntry): BgLevel;
|
|
7
6
|
export declare function getReminder(bgLevel: BgLevel, carbohydrates: number, userReminder: number, activity: IRecommendationParams["activity"]): number;
|
|
@@ -9,4 +8,4 @@ export declare function getAttentionMessage(bgLevel: BgLevel, activity: IRecomme
|
|
|
9
8
|
export declare function isSevereHyperglycemia(latestLogbookFrom6Hours: logbookEntry): boolean;
|
|
10
9
|
export declare function isActivityWithin15Minutes(activity: IRecommendationParams["activity"]): boolean;
|
|
11
10
|
export declare function getLimitationMessage(wasLimited: boolean, activityReduction: number): Messages;
|
|
12
|
-
export declare function
|
|
11
|
+
export declare function assignTargetBGL(calculatorParams: IRecommendationParams): IRecommendationParams;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.assignTargetBGL = exports.getLimitationMessage = exports.isActivityWithin15Minutes = exports.isSevereHyperglycemia = exports.getAttentionMessage = exports.getReminder = exports.getBGLevel = void 0;
|
|
7
7
|
const moment_1 = __importDefault(require("moment"));
|
|
8
8
|
const enum_1 = require("../types/enum");
|
|
9
9
|
const AttentionMessages_1 = require("./AttentionMessages");
|
|
@@ -106,8 +106,7 @@ function getLimitationMessage(wasLimited, activityReduction) {
|
|
|
106
106
|
return wasLimited ? message : undefined;
|
|
107
107
|
}
|
|
108
108
|
exports.getLimitationMessage = getLimitationMessage;
|
|
109
|
-
function
|
|
110
|
-
const { calculatorParams } = props;
|
|
109
|
+
function assignTargetBGL(calculatorParams) {
|
|
111
110
|
const activityTarget = calculatorParams.activity?.activitySettings?.target;
|
|
112
111
|
const paramsWithAssignedCurrentBGL = {
|
|
113
112
|
...calculatorParams,
|
|
@@ -115,4 +114,4 @@ function getParams(props) {
|
|
|
115
114
|
};
|
|
116
115
|
return calculatorParams.currentBGL === null ? paramsWithAssignedCurrentBGL : calculatorParams;
|
|
117
116
|
}
|
|
118
|
-
exports.
|
|
117
|
+
exports.assignTargetBGL = assignTargetBGL;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { IRecommendationParams } from "@hedia/recommendation-calculator";
|
|
2
2
|
import moment from "moment";
|
|
3
|
-
import { IRecommendationProps } from "../RecommendationScreen";
|
|
4
3
|
import { BgLevel, RecommendationReminders } from "../types/enum";
|
|
5
|
-
import {
|
|
4
|
+
import { logbookEntry } from "../types/types";
|
|
6
5
|
import { addPostponeActivityMessage, AttentionMessage, Messages } from "./AttentionMessages";
|
|
7
6
|
import { SEVERE_HYPERGLYCEMIA_START_MMOL } from "./Constants";
|
|
8
7
|
import { CurrentBGLError } from "./RecommendationError";
|
|
@@ -117,8 +116,7 @@ export function getLimitationMessage(wasLimited: boolean, activityReduction: num
|
|
|
117
116
|
return wasLimited ? message : undefined;
|
|
118
117
|
}
|
|
119
118
|
|
|
120
|
-
export function
|
|
121
|
-
const { calculatorParams } = props;
|
|
119
|
+
export function assignTargetBGL(calculatorParams: IRecommendationParams): IRecommendationParams {
|
|
122
120
|
const activityTarget = calculatorParams.activity?.activitySettings?.target;
|
|
123
121
|
const paramsWithAssignedCurrentBGL = {
|
|
124
122
|
...calculatorParams,
|
package/src/utils/Utils.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ export declare class Utils {
|
|
|
4
4
|
static getRounding(method: InjectionMethod): number;
|
|
5
5
|
static roundValue(value: number, injectMethod: InjectionMethod): number;
|
|
6
6
|
static isInClosedInterval(value: number, interval: IInterval): boolean;
|
|
7
|
+
static convertToMGDL(bglValueMMOL: number): number;
|
|
7
8
|
}
|
package/src/utils/Utils.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Utils = void 0;
|
|
4
4
|
const enum_1 = require("../types/enum");
|
|
5
|
+
const Constants_1 = require("./Constants");
|
|
5
6
|
class Utils {
|
|
6
7
|
static getRounding(method) {
|
|
7
8
|
switch (method) {
|
|
@@ -26,5 +27,8 @@ class Utils {
|
|
|
26
27
|
}
|
|
27
28
|
return value >= interval.min && value <= interval.max;
|
|
28
29
|
}
|
|
30
|
+
static convertToMGDL(bglValueMMOL) {
|
|
31
|
+
return Math.round(bglValueMMOL * Constants_1.MGDL_PER_MMOLL);
|
|
32
|
+
}
|
|
29
33
|
}
|
|
30
34
|
exports.Utils = Utils;
|
package/src/utils/Utils.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { InjectionMethod } from "../types/enum";
|
|
2
2
|
import { IInterval } from "../types/types";
|
|
3
|
+
import { MGDL_PER_MMOLL } from "./Constants";
|
|
3
4
|
|
|
4
5
|
export class Utils {
|
|
5
6
|
public static getRounding(method: InjectionMethod): number {
|
|
@@ -31,4 +32,7 @@ export class Utils {
|
|
|
31
32
|
|
|
32
33
|
return value >= interval.min && value <= interval.max;
|
|
33
34
|
}
|
|
35
|
+
public static convertToMGDL(bglValueMMOL: number): number {
|
|
36
|
+
return Math.round(bglValueMMOL * MGDL_PER_MMOLL);
|
|
37
|
+
}
|
|
34
38
|
}
|
package/src/utils/Validations.js
CHANGED
|
@@ -76,19 +76,23 @@ function checkActivity(activity) {
|
|
|
76
76
|
}
|
|
77
77
|
exports.checkActivity = checkActivity;
|
|
78
78
|
function checkRecentBolusesInsulinDosis(recentBoluses) {
|
|
79
|
-
recentBoluses
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
if (recentBoluses !== null) {
|
|
80
|
+
recentBoluses.forEach((bolus) => {
|
|
81
|
+
if (!Utils_1.Utils.isInClosedInterval(bolus.insulinDosis, Constants_1.INSULIN_DOSIS_LIMITS)) {
|
|
82
|
+
throw RecommendationError_1.BolusInsulinDosisError();
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
84
86
|
}
|
|
85
87
|
exports.checkRecentBolusesInsulinDosis = checkRecentBolusesInsulinDosis;
|
|
86
88
|
function checkRecentBolusesSecondsPassed(recentBoluses) {
|
|
87
|
-
recentBoluses
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
if (recentBoluses !== null) {
|
|
90
|
+
recentBoluses.forEach((bolus) => {
|
|
91
|
+
if (!Utils_1.Utils.isInClosedInterval(bolus.secondsPassed, Constants_1.BOLUS_SECONDS_PASSED_LIMITS)) {
|
|
92
|
+
throw RecommendationError_1.BolusInsulinSecondsPassedError();
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
92
96
|
}
|
|
93
97
|
exports.checkRecentBolusesSecondsPassed = checkRecentBolusesSecondsPassed;
|
|
94
98
|
function checkActivityDuration(activityDuration) {
|
|
@@ -112,7 +116,7 @@ exports.checkActivityIntensity = checkActivityIntensity;
|
|
|
112
116
|
function checkActivityDate(activity) {
|
|
113
117
|
const maximumDate = moment_1.default
|
|
114
118
|
.utc(activity.activityDate)
|
|
115
|
-
.add(activity.activityDuration + Constants_1.ONE_HOUR_MINUTES * 4, `minutes`);
|
|
119
|
+
.add(activity.activityDuration + Constants_1.ONE_HOUR_MINUTES * 4 + Constants_1.ACTIVITY_BUFFER_MINUTES, `minutes`);
|
|
116
120
|
if (!moment_1.default.utc().isBefore(maximumDate)) {
|
|
117
121
|
throw RecommendationError_1.ActivityDateError();
|
|
118
122
|
}
|
package/src/utils/Validations.ts
CHANGED
|
@@ -9,6 +9,7 @@ import moment from "moment";
|
|
|
9
9
|
import { IRecommendationProps } from "../RecommendationScreen";
|
|
10
10
|
import { ActivityInterval, BGUnit, InjectionMethod, Languages } from "../types/enum";
|
|
11
11
|
import {
|
|
12
|
+
ACTIVITY_BUFFER_MINUTES,
|
|
12
13
|
ACTIVITY_DURATION_MINUTES_LIMITS,
|
|
13
14
|
ACTIVITY_SETTINGS_INTERVAL_LIMITS,
|
|
14
15
|
ACTIVITY_TARGET_BGL_MMOL_LIMITS,
|
|
@@ -109,19 +110,23 @@ export function checkActivity(activity: IRecommendationParams["activity"]): void
|
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
export function checkRecentBolusesInsulinDosis(recentBoluses: Array<IRecentBolus>): void {
|
|
112
|
-
recentBoluses
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
if (recentBoluses !== null) {
|
|
114
|
+
recentBoluses.forEach((bolus: IRecentBolus): void => {
|
|
115
|
+
if (!Utils.isInClosedInterval(bolus.insulinDosis, INSULIN_DOSIS_LIMITS)) {
|
|
116
|
+
throw BolusInsulinDosisError();
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
117
120
|
}
|
|
118
121
|
|
|
119
122
|
export function checkRecentBolusesSecondsPassed(recentBoluses: Array<IRecentBolus>): void {
|
|
120
|
-
recentBoluses
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
if (recentBoluses !== null) {
|
|
124
|
+
recentBoluses.forEach((bolus: IRecentBolus): void => {
|
|
125
|
+
if (!Utils.isInClosedInterval(bolus.secondsPassed, BOLUS_SECONDS_PASSED_LIMITS)) {
|
|
126
|
+
throw BolusInsulinSecondsPassedError();
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
125
130
|
}
|
|
126
131
|
|
|
127
132
|
export function checkActivityDuration(activityDuration: IRecommendationParams["activity"]["activityDuration"]): void {
|
|
@@ -146,7 +151,7 @@ export function checkActivityIntensity(
|
|
|
146
151
|
export function checkActivityDate(activity: IRecommendationParams["activity"]): void {
|
|
147
152
|
const maximumDate = moment
|
|
148
153
|
.utc(activity.activityDate)
|
|
149
|
-
.add(activity.activityDuration + ONE_HOUR_MINUTES * 4, `minutes`);
|
|
154
|
+
.add(activity.activityDuration + ONE_HOUR_MINUTES * 4 + ACTIVITY_BUFFER_MINUTES, `minutes`);
|
|
150
155
|
if (!moment.utc().isBefore(maximumDate)) {
|
|
151
156
|
throw ActivityDateError();
|
|
152
157
|
}
|