@hedia/recommendation-screen 1.5.2 → 1.6.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 +118 -189
- package/package.json +2 -1
- package/src/RecommendationScreen.d.ts +6 -3
- package/src/RecommendationScreen.jsx +8 -6
- package/src/RecommendationScreen.tsx +32 -9
- package/src/components/InfoBars.d.ts +4 -1
- package/src/components/InfoBars.jsx +19 -3
- package/src/components/InfoBars.tsx +19 -4
- package/src/locale/da/messages.js +1 -1
- package/src/locale/da/messages.po +30 -18
- package/src/locale/en/messages.js +1 -1
- package/src/locale/en/messages.po +30 -18
- package/src/types/enum.d.ts +7 -9
- package/src/types/enum.js +8 -11
- package/src/types/enum.ts +3 -6
- package/src/utils/Constants.d.ts +5 -2
- package/src/utils/Constants.js +6 -3
- package/src/utils/Constants.ts +6 -2
- package/src/utils/RecommendationError.d.ts +3 -1
- package/src/utils/RecommendationError.jsx +4 -2
- package/src/utils/RecommendationError.tsx +12 -2
- package/src/utils/Utils.d.ts +6 -1
- package/src/utils/Utils.js +17 -2
- package/src/utils/Utils.ts +21 -3
- package/src/utils/Validations.d.ts +5 -2
- package/src/utils/Validations.js +28 -7
- package/src/utils/Validations.ts +32 -7
package/src/types/enum.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RecommendationReminders = exports.BgLevel = exports.Milliseconds = exports.RecommendationErrorEnum = exports.ActivityInterval = exports.Language = exports.InjectionMethod = exports.
|
|
3
|
+
exports.RecommendationReminders = exports.BgLevel = exports.Milliseconds = exports.RecommendationErrorEnum = exports.ActivityInterval = exports.Language = exports.InjectionMethod = exports.ActivityEnum = exports.MoodEnum = void 0;
|
|
4
4
|
var MoodEnum;
|
|
5
5
|
(function (MoodEnum) {
|
|
6
6
|
MoodEnum[MoodEnum["Sad"] = 1] = "Sad";
|
|
@@ -17,11 +17,6 @@ var ActivityEnum;
|
|
|
17
17
|
ActivityEnum[ActivityEnum["Swim"] = 3] = "Swim";
|
|
18
18
|
ActivityEnum[ActivityEnum["Other"] = 4] = "Other";
|
|
19
19
|
})(ActivityEnum = exports.ActivityEnum || (exports.ActivityEnum = {}));
|
|
20
|
-
var BGUnit;
|
|
21
|
-
(function (BGUnit) {
|
|
22
|
-
BGUnit["MMOL_L"] = "mmol/l";
|
|
23
|
-
BGUnit["MG_DL"] = "mg/dl";
|
|
24
|
-
})(BGUnit = exports.BGUnit || (exports.BGUnit = {}));
|
|
25
20
|
var InjectionMethod;
|
|
26
21
|
(function (InjectionMethod) {
|
|
27
22
|
InjectionMethod["PenHalf"] = "Pen-half";
|
|
@@ -53,11 +48,13 @@ var RecommendationErrorEnum;
|
|
|
53
48
|
RecommendationErrorEnum[RecommendationErrorEnum["InsulinSensitivity"] = 9] = "InsulinSensitivity";
|
|
54
49
|
RecommendationErrorEnum[RecommendationErrorEnum["InsulinToCarbsRatio"] = 10] = "InsulinToCarbsRatio";
|
|
55
50
|
RecommendationErrorEnum[RecommendationErrorEnum["CurrentBGL"] = 11] = "CurrentBGL";
|
|
56
|
-
RecommendationErrorEnum[RecommendationErrorEnum["
|
|
57
|
-
RecommendationErrorEnum[RecommendationErrorEnum["
|
|
58
|
-
RecommendationErrorEnum[RecommendationErrorEnum["
|
|
59
|
-
RecommendationErrorEnum[RecommendationErrorEnum["
|
|
60
|
-
RecommendationErrorEnum[RecommendationErrorEnum["
|
|
51
|
+
RecommendationErrorEnum[RecommendationErrorEnum["CurrentBKL"] = 12] = "CurrentBKL";
|
|
52
|
+
RecommendationErrorEnum[RecommendationErrorEnum["TargetBGL"] = 13] = "TargetBGL";
|
|
53
|
+
RecommendationErrorEnum[RecommendationErrorEnum["UserReminder"] = 14] = "UserReminder";
|
|
54
|
+
RecommendationErrorEnum[RecommendationErrorEnum["Language"] = 15] = "Language";
|
|
55
|
+
RecommendationErrorEnum[RecommendationErrorEnum["InjectionMethod"] = 16] = "InjectionMethod";
|
|
56
|
+
RecommendationErrorEnum[RecommendationErrorEnum["BloodKetoneUnit"] = 17] = "BloodKetoneUnit";
|
|
57
|
+
RecommendationErrorEnum[RecommendationErrorEnum["BloodGlucoseUnit"] = 18] = "BloodGlucoseUnit";
|
|
61
58
|
})(RecommendationErrorEnum = exports.RecommendationErrorEnum || (exports.RecommendationErrorEnum = {}));
|
|
62
59
|
var Milliseconds;
|
|
63
60
|
(function (Milliseconds) {
|
package/src/types/enum.ts
CHANGED
|
@@ -14,11 +14,6 @@ export enum ActivityEnum {
|
|
|
14
14
|
Other,
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export enum BGUnit {
|
|
18
|
-
MMOL_L = "mmol/l",
|
|
19
|
-
MG_DL = "mg/dl",
|
|
20
|
-
}
|
|
21
|
-
|
|
22
17
|
export enum InjectionMethod {
|
|
23
18
|
PenHalf = "Pen-half",
|
|
24
19
|
PenWhole = "Pen-whole",
|
|
@@ -48,11 +43,13 @@ export enum RecommendationErrorEnum {
|
|
|
48
43
|
InsulinSensitivity,
|
|
49
44
|
InsulinToCarbsRatio,
|
|
50
45
|
CurrentBGL,
|
|
46
|
+
CurrentBKL,
|
|
51
47
|
TargetBGL,
|
|
52
48
|
UserReminder,
|
|
53
49
|
Language,
|
|
54
50
|
InjectionMethod,
|
|
55
|
-
|
|
51
|
+
BloodKetoneUnit,
|
|
52
|
+
BloodGlucoseUnit,
|
|
56
53
|
}
|
|
57
54
|
|
|
58
55
|
export enum Milliseconds {
|
package/src/utils/Constants.d.ts
CHANGED
|
@@ -13,8 +13,11 @@ export declare const ACTIVITY_DURATION_MINUTES_LIMITS: IInterval;
|
|
|
13
13
|
export declare const INSULIN_SENSITIVITY_MMOL_LIMITS: IInterval;
|
|
14
14
|
export declare const INSULIN_TO_CARBS_RATIO_LIMITS: IInterval;
|
|
15
15
|
export declare const CURRENT_BGL_MMOL_LIMITS: IInterval;
|
|
16
|
-
export declare const
|
|
17
|
-
export declare const
|
|
16
|
+
export declare const MMOLL_PER_MGDL_BGL: number;
|
|
17
|
+
export declare const MGDL_PER_MMOLL_BGL: number;
|
|
18
|
+
export declare const CURRENT_BKL_MMOL_LIMITS: IInterval;
|
|
19
|
+
export declare const MMOLL_PER_MGDL_BKL: number;
|
|
20
|
+
export declare const MGDL_PER_MMOLL_BKL: number;
|
|
18
21
|
export declare const TARGET_BGL_MMOL_LIMITS: IInterval;
|
|
19
22
|
export declare const ACTIVITY_TARGET_BGL_MMOL_LIMITS: IInterval;
|
|
20
23
|
export declare const REMINDER_HOURS_LIMITS: IInterval;
|
package/src/utils/Constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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.
|
|
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_BKL = exports.MMOLL_PER_MGDL_BKL = exports.CURRENT_BKL_MMOL_LIMITS = exports.MGDL_PER_MMOLL_BGL = exports.MMOLL_PER_MGDL_BGL = 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_DOSE_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)`;
|
|
@@ -15,8 +15,11 @@ exports.ACTIVITY_DURATION_MINUTES_LIMITS = { min: 1, max: exports.ONE_HOUR_MINUT
|
|
|
15
15
|
exports.INSULIN_SENSITIVITY_MMOL_LIMITS = { min: 0.3, max: 10 };
|
|
16
16
|
exports.INSULIN_TO_CARBS_RATIO_LIMITS = { min: 1, max: 50 };
|
|
17
17
|
exports.CURRENT_BGL_MMOL_LIMITS = { min: 1.1, max: 33.3 };
|
|
18
|
-
exports.
|
|
19
|
-
exports.
|
|
18
|
+
exports.MMOLL_PER_MGDL_BGL = 0.0555;
|
|
19
|
+
exports.MGDL_PER_MMOLL_BGL = 1 / exports.MMOLL_PER_MGDL_BGL;
|
|
20
|
+
exports.CURRENT_BKL_MMOL_LIMITS = { min: 0, max: 10 };
|
|
21
|
+
exports.MMOLL_PER_MGDL_BKL = 0.096;
|
|
22
|
+
exports.MGDL_PER_MMOLL_BKL = 1 / exports.MMOLL_PER_MGDL_BKL;
|
|
20
23
|
exports.TARGET_BGL_MMOL_LIMITS = { min: 5, max: 13.9 };
|
|
21
24
|
exports.ACTIVITY_TARGET_BGL_MMOL_LIMITS = { min: 5, max: 13.9 };
|
|
22
25
|
exports.REMINDER_HOURS_LIMITS = { min: 0, max: 6 };
|
package/src/utils/Constants.ts
CHANGED
|
@@ -19,8 +19,12 @@ export const INSULIN_SENSITIVITY_MMOL_LIMITS: IInterval = { min: 0.3, max: 10 };
|
|
|
19
19
|
export const INSULIN_TO_CARBS_RATIO_LIMITS: IInterval = { min: 1, max: 50 };
|
|
20
20
|
|
|
21
21
|
export const CURRENT_BGL_MMOL_LIMITS: IInterval = { min: 1.1, max: 33.3 };
|
|
22
|
-
export const
|
|
23
|
-
export const
|
|
22
|
+
export const MMOLL_PER_MGDL_BGL: number = 0.0555;
|
|
23
|
+
export const MGDL_PER_MMOLL_BGL: number = 1 / MMOLL_PER_MGDL_BGL;
|
|
24
|
+
|
|
25
|
+
export const CURRENT_BKL_MMOL_LIMITS: IInterval = { min: 0, max: 10 };
|
|
26
|
+
export const MMOLL_PER_MGDL_BKL: number = 0.096;
|
|
27
|
+
export const MGDL_PER_MMOLL_BKL: number = 1 / MMOLL_PER_MGDL_BKL;
|
|
24
28
|
|
|
25
29
|
export const TARGET_BGL_MMOL_LIMITS: IInterval = { min: 5, max: 13.9 };
|
|
26
30
|
export const ACTIVITY_TARGET_BGL_MMOL_LIMITS: IInterval = { min: 5, max: 13.9 };
|
|
@@ -13,10 +13,12 @@ export declare const CarbohydrateLimitError: () => RecommendationError;
|
|
|
13
13
|
export declare const InsulinSensitivityError: () => RecommendationError;
|
|
14
14
|
export declare const InsulinToCarbsRatioError: () => RecommendationError;
|
|
15
15
|
export declare const CurrentBGLError: () => RecommendationError;
|
|
16
|
+
export declare const CurrentBKLError: () => RecommendationError;
|
|
16
17
|
export declare const TargetBGLError: () => RecommendationError;
|
|
17
18
|
export declare const BolusInsulinDoseError: () => RecommendationError;
|
|
18
19
|
export declare const BolusInsulinSecondsPassedError: () => RecommendationError;
|
|
19
20
|
export declare const UserReminderError: () => RecommendationError;
|
|
20
21
|
export declare const InjectionMethodError: () => RecommendationError;
|
|
21
22
|
export declare const LanguageError: () => RecommendationError;
|
|
22
|
-
export declare const
|
|
23
|
+
export declare const BloodKetoneUnitError: () => RecommendationError;
|
|
24
|
+
export declare const BloodGlucoseUnitError: () => RecommendationError;
|
|
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.
|
|
22
|
+
exports.BloodGlucoseUnitError = exports.BloodKetoneUnitError = exports.LanguageError = exports.InjectionMethodError = exports.UserReminderError = exports.BolusInsulinSecondsPassedError = exports.BolusInsulinDoseError = exports.TargetBGLError = exports.CurrentBKLError = exports.CurrentBGLError = exports.InsulinToCarbsRatioError = exports.InsulinSensitivityError = exports.CarbohydrateLimitError = exports.ActivityTargetBGLError = exports.ActivityTypeError = 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");
|
|
@@ -41,10 +41,12 @@ exports.CarbohydrateLimitError = () => new RecommendationError(i18nUtils_1.i18n.
|
|
|
41
41
|
exports.InsulinSensitivityError = () => new RecommendationError(i18nUtils_1.i18n._(macro_1.t `Error. Please verify that your insulin sensitivity value is correct.`), enum_1.RecommendationErrorEnum.InsulinSensitivity);
|
|
42
42
|
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);
|
|
43
43
|
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);
|
|
44
|
+
exports.CurrentBKLError = () => new RecommendationError(i18nUtils_1.i18n._(macro_1.t `Error. Hedia Calculator does not support your current blood ketone level.`), enum_1.RecommendationErrorEnum.CurrentBKL);
|
|
44
45
|
exports.TargetBGLError = () => new RecommendationError(i18nUtils_1.i18n._(macro_1.t `Error. Please verify that your target blood glucose value is correct.`), enum_1.RecommendationErrorEnum.TargetBGL);
|
|
45
46
|
exports.BolusInsulinDoseError = () => new RecommendationError(i18nUtils_1.i18n._(macro_1.t `Error. Hedia Calculator does not support an insulin dose greater than ${Calculator.SAFETY_INSULIN_LIMIT} units`), enum_1.RecommendationErrorEnum.BolusInsulinDose);
|
|
46
47
|
exports.BolusInsulinSecondsPassedError = () => new RecommendationError(i18nUtils_1.i18n._(macro_1.t `Error. Hedia Calculator does not support insulin recommendations with boluses older than 4 hours`), enum_1.RecommendationErrorEnum.BolusInsulinSecondsPassed);
|
|
47
48
|
exports.UserReminderError = () => new RecommendationError(i18nUtils_1.i18n._(macro_1.t `Error. Please verify your notifications settings.`), enum_1.RecommendationErrorEnum.UserReminder);
|
|
48
49
|
exports.InjectionMethodError = () => new RecommendationError(i18nUtils_1.i18n._(macro_1.t `Error. Hedia Calculator does not support your injection method.`), enum_1.RecommendationErrorEnum.InjectionMethod);
|
|
49
50
|
exports.LanguageError = () => new RecommendationError(i18nUtils_1.i18n._(macro_1.t `Error. Hedia Calculator does not support your current language.`), enum_1.RecommendationErrorEnum.Language);
|
|
50
|
-
exports.
|
|
51
|
+
exports.BloodKetoneUnitError = () => new RecommendationError(i18nUtils_1.i18n._(macro_1.t `Error. Hedia Calculator does not support your current blood ketone unit.`), enum_1.RecommendationErrorEnum.BloodKetoneUnit);
|
|
52
|
+
exports.BloodGlucoseUnitError = () => new RecommendationError(i18nUtils_1.i18n._(macro_1.t `Error. Hedia Calculator does not support your current blood glucose unit.`), enum_1.RecommendationErrorEnum.BloodGlucoseUnit);
|
|
@@ -72,6 +72,11 @@ export const CurrentBGLError = (): RecommendationError =>
|
|
|
72
72
|
i18n._(t`Error. Hedia Calculator does not support your current blood glucose level.`),
|
|
73
73
|
RecommendationErrorEnum.CurrentBGL,
|
|
74
74
|
);
|
|
75
|
+
export const CurrentBKLError = (): RecommendationError =>
|
|
76
|
+
new RecommendationError(
|
|
77
|
+
i18n._(t`Error. Hedia Calculator does not support your current blood ketone level.`),
|
|
78
|
+
RecommendationErrorEnum.CurrentBKL,
|
|
79
|
+
);
|
|
75
80
|
|
|
76
81
|
export const TargetBGLError = (): RecommendationError =>
|
|
77
82
|
new RecommendationError(
|
|
@@ -110,8 +115,13 @@ export const LanguageError = (): RecommendationError =>
|
|
|
110
115
|
i18n._(t`Error. Hedia Calculator does not support your current language.`),
|
|
111
116
|
RecommendationErrorEnum.Language,
|
|
112
117
|
);
|
|
113
|
-
export const
|
|
118
|
+
export const BloodKetoneUnitError = (): RecommendationError =>
|
|
119
|
+
new RecommendationError(
|
|
120
|
+
i18n._(t`Error. Hedia Calculator does not support your current blood ketone unit.`),
|
|
121
|
+
RecommendationErrorEnum.BloodKetoneUnit,
|
|
122
|
+
);
|
|
123
|
+
export const BloodGlucoseUnitError = (): RecommendationError =>
|
|
114
124
|
new RecommendationError(
|
|
115
125
|
i18n._(t`Error. Hedia Calculator does not support your current blood glucose unit.`),
|
|
116
|
-
RecommendationErrorEnum.
|
|
126
|
+
RecommendationErrorEnum.BloodGlucoseUnit,
|
|
117
127
|
);
|
package/src/utils/Utils.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import { BloodGlucoseUnit, BloodKetonesUnit } from "@hedia/types";
|
|
1
2
|
import { InjectionMethod } from "../types/enum";
|
|
2
3
|
import { IInterval } from "../types/types";
|
|
3
4
|
export declare class Utils {
|
|
4
5
|
static getRounding(method: InjectionMethod): number;
|
|
5
6
|
static roundValue(value: number, injectMethod: InjectionMethod): number;
|
|
6
7
|
static isInClosedInterval(value: number, interval: IInterval): boolean;
|
|
7
|
-
static
|
|
8
|
+
static convertBGLToMGDL(value: number): number;
|
|
9
|
+
static displayedBGLValue(value: number, unit: BloodGlucoseUnit): number;
|
|
10
|
+
static convertBKLToMGDL(value: number): number;
|
|
11
|
+
static displayedBKLValue(value: number, unit: BloodKetonesUnit): number;
|
|
12
|
+
static formatUnit: (unit: BloodGlucoseUnit | BloodKetonesUnit) => string;
|
|
8
13
|
}
|
package/src/utils/Utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Utils = void 0;
|
|
4
|
+
const types_1 = require("@hedia/types");
|
|
4
5
|
const enum_1 = require("../types/enum");
|
|
5
6
|
const Constants_1 = require("./Constants");
|
|
6
7
|
class Utils {
|
|
@@ -26,8 +27,22 @@ class Utils {
|
|
|
26
27
|
}
|
|
27
28
|
return value >= interval.min && value <= interval.max;
|
|
28
29
|
}
|
|
29
|
-
static
|
|
30
|
-
return Math.round(
|
|
30
|
+
static convertBGLToMGDL(value) {
|
|
31
|
+
return Math.round(value * Constants_1.MGDL_PER_MMOLL_BGL);
|
|
32
|
+
}
|
|
33
|
+
static displayedBGLValue(value, unit) {
|
|
34
|
+
return unit === types_1.BloodGlucoseUnit.MMOL_L ? value : Utils.convertBGLToMGDL(value);
|
|
35
|
+
}
|
|
36
|
+
static convertBKLToMGDL(value) {
|
|
37
|
+
return Math.round(value * Constants_1.MGDL_PER_MMOLL_BKL);
|
|
38
|
+
}
|
|
39
|
+
static displayedBKLValue(value, unit) {
|
|
40
|
+
return unit === types_1.BloodKetonesUnit.MMOL_L ? value : Utils.convertBKLToMGDL(value);
|
|
31
41
|
}
|
|
32
42
|
}
|
|
33
43
|
exports.Utils = Utils;
|
|
44
|
+
Utils.formatUnit = (unit) => {
|
|
45
|
+
const unitWithoutLastLetter = unit.substring(0, unit.length - 1);
|
|
46
|
+
const lastLetterUppercase = unit.substring(unit.length - 1, unit.length).toUpperCase();
|
|
47
|
+
return `${unitWithoutLastLetter}${lastLetterUppercase}`;
|
|
48
|
+
};
|
package/src/utils/Utils.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { BloodGlucoseUnit, BloodKetonesUnit } from "@hedia/types";
|
|
1
2
|
import { InjectionMethod } from "../types/enum";
|
|
2
3
|
import { IInterval } from "../types/types";
|
|
3
|
-
import {
|
|
4
|
+
import { MGDL_PER_MMOLL_BGL, MGDL_PER_MMOLL_BKL } from "./Constants";
|
|
4
5
|
|
|
5
6
|
export class Utils {
|
|
6
7
|
public static getRounding(method: InjectionMethod): number {
|
|
@@ -31,7 +32,24 @@ export class Utils {
|
|
|
31
32
|
|
|
32
33
|
return value >= interval.min && value <= interval.max;
|
|
33
34
|
}
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
|
|
36
|
+
public static convertBGLToMGDL(value: number): number {
|
|
37
|
+
return Math.round(value * MGDL_PER_MMOLL_BGL);
|
|
38
|
+
}
|
|
39
|
+
public static displayedBGLValue(value: number, unit: BloodGlucoseUnit): number {
|
|
40
|
+
return unit === BloodGlucoseUnit.MMOL_L ? value : Utils.convertBGLToMGDL(value);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public static convertBKLToMGDL(value: number): number {
|
|
44
|
+
return Math.round(value * MGDL_PER_MMOLL_BKL);
|
|
45
|
+
}
|
|
46
|
+
public static displayedBKLValue(value: number, unit: BloodKetonesUnit): number {
|
|
47
|
+
return unit === BloodKetonesUnit.MMOL_L ? value : Utils.convertBKLToMGDL(value);
|
|
36
48
|
}
|
|
49
|
+
|
|
50
|
+
public static formatUnit = (unit: BloodGlucoseUnit | BloodKetonesUnit): string => {
|
|
51
|
+
const unitWithoutLastLetter = unit.substring(0, unit.length - 1);
|
|
52
|
+
const lastLetterUppercase = unit.substring(unit.length - 1, unit.length).toUpperCase();
|
|
53
|
+
return `${unitWithoutLastLetter}${lastLetterUppercase}`;
|
|
54
|
+
};
|
|
37
55
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { ActivityIntensity, IActivityParams, IActivitySettings, IRecentBolus } from "@hedia/recommendation-calculator/src/RecommendationCalculator";
|
|
2
|
+
import { BloodGlucoseUnit, BloodKetonesUnit } from "@hedia/types";
|
|
2
3
|
import { IRecommendationProps } from "../RecommendationScreen";
|
|
3
|
-
import { ActivityEnum,
|
|
4
|
+
import { ActivityEnum, InjectionMethod, Language } from "../types/enum";
|
|
4
5
|
export declare function validateParams(props: IRecommendationProps): void;
|
|
5
6
|
export declare function checkLanguage(language: Language): void;
|
|
6
7
|
export declare function checkInjectionMethod(injectionMethod: InjectionMethod): void;
|
|
7
|
-
export declare function
|
|
8
|
+
export declare function checkBGLUnit(unit: BloodGlucoseUnit): void;
|
|
9
|
+
export declare function checkBKLUnit(unit: BloodKetonesUnit): void;
|
|
8
10
|
export declare function checkUserReminder(userReminder: number): void;
|
|
9
11
|
export declare function checkActivity(activity: IActivityParams): void;
|
|
10
12
|
export declare function checkRecentBolusesInsulinDose(recentBoluses: Array<IRecentBolus>): void;
|
|
@@ -17,6 +19,7 @@ export declare function checkActivitySettings(activitySettings: IActivitySetting
|
|
|
17
19
|
export declare function checkActivityTargetBGL(activitySettingsTargetBGL: number): void;
|
|
18
20
|
export declare function checkCurrentBGL(currentBGL: number): void;
|
|
19
21
|
export declare function checkTargetBGL(targetBGL: number): void;
|
|
22
|
+
export declare function checkBloodKetoneLevel(currentBKL: number): void;
|
|
20
23
|
export declare function checkInsulinSensitivity(insulinSensitivity: number): void;
|
|
21
24
|
export declare function checkInsulinToCarbRatio(insulinToCarbRatio: number): void;
|
|
22
25
|
export declare function checkCarbohydrates(carbohydrates: number): void;
|
package/src/utils/Validations.js
CHANGED
|
@@ -3,8 +3,9 @@ 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.checkCarbohydrates = exports.checkInsulinToCarbRatio = exports.checkInsulinSensitivity = exports.checkTargetBGL = exports.checkCurrentBGL = exports.checkActivityTargetBGL = exports.checkActivitySettings = exports.checkActivityDate = exports.checkActivityType = exports.checkActivityIntensity = exports.checkActivityDuration = exports.checkRecentBolusesSecondsPassed = exports.checkRecentBolusesInsulinDose = exports.checkActivity = exports.checkUserReminder = exports.
|
|
6
|
+
exports.checkCarbohydrates = exports.checkInsulinToCarbRatio = exports.checkInsulinSensitivity = exports.checkBloodKetoneLevel = exports.checkTargetBGL = exports.checkCurrentBGL = exports.checkActivityTargetBGL = exports.checkActivitySettings = exports.checkActivityDate = exports.checkActivityType = exports.checkActivityIntensity = exports.checkActivityDuration = exports.checkRecentBolusesSecondsPassed = exports.checkRecentBolusesInsulinDose = exports.checkActivity = exports.checkUserReminder = exports.checkBKLUnit = exports.checkBGLUnit = exports.checkInjectionMethod = exports.checkLanguage = exports.validateParams = void 0;
|
|
7
7
|
const RecommendationCalculator_1 = require("@hedia/recommendation-calculator/src/RecommendationCalculator");
|
|
8
|
+
const types_1 = require("@hedia/types");
|
|
8
9
|
const moment_1 = __importDefault(require("moment"));
|
|
9
10
|
const enum_1 = require("../types/enum");
|
|
10
11
|
const Constants_1 = require("./Constants");
|
|
@@ -12,7 +13,9 @@ const RecommendationError_1 = require("./RecommendationError");
|
|
|
12
13
|
const Utils_1 = require("./Utils");
|
|
13
14
|
function validateParams(props) {
|
|
14
15
|
checkCalculatorParams(props.calculatorParams);
|
|
15
|
-
|
|
16
|
+
checkBGLUnit(props.bloodGlucoseUnit);
|
|
17
|
+
checkBKLUnit(props.bloodKetoneUnit);
|
|
18
|
+
checkBloodKetoneLevel(props.currentBKL);
|
|
16
19
|
checkInjectionMethod(props.injectionMethod);
|
|
17
20
|
checkUserReminder(props.userReminder);
|
|
18
21
|
checkLanguage(props.language);
|
|
@@ -42,16 +45,26 @@ function checkInjectionMethod(injectionMethod) {
|
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
exports.checkInjectionMethod = checkInjectionMethod;
|
|
45
|
-
function
|
|
48
|
+
function checkBGLUnit(unit) {
|
|
46
49
|
switch (unit) {
|
|
47
|
-
case
|
|
48
|
-
case
|
|
50
|
+
case types_1.BloodGlucoseUnit.MG_DL:
|
|
51
|
+
case types_1.BloodGlucoseUnit.MMOL_L:
|
|
49
52
|
break;
|
|
50
53
|
default:
|
|
51
|
-
throw RecommendationError_1.
|
|
54
|
+
throw RecommendationError_1.BloodGlucoseUnitError();
|
|
52
55
|
}
|
|
53
56
|
}
|
|
54
|
-
exports.
|
|
57
|
+
exports.checkBGLUnit = checkBGLUnit;
|
|
58
|
+
function checkBKLUnit(unit) {
|
|
59
|
+
switch (unit) {
|
|
60
|
+
case types_1.BloodKetonesUnit.MG_DL:
|
|
61
|
+
case types_1.BloodKetonesUnit.MMOL_L:
|
|
62
|
+
break;
|
|
63
|
+
default:
|
|
64
|
+
throw RecommendationError_1.BloodKetoneUnitError();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.checkBKLUnit = checkBKLUnit;
|
|
55
68
|
function checkUserReminder(userReminder) {
|
|
56
69
|
if (!Utils_1.Utils.isInClosedInterval(userReminder, Constants_1.REMINDER_HOURS_LIMITS)) {
|
|
57
70
|
throw RecommendationError_1.UserReminderError();
|
|
@@ -174,6 +187,14 @@ function checkTargetBGL(targetBGL) {
|
|
|
174
187
|
}
|
|
175
188
|
}
|
|
176
189
|
exports.checkTargetBGL = checkTargetBGL;
|
|
190
|
+
function checkBloodKetoneLevel(currentBKL) {
|
|
191
|
+
if (currentBKL !== null) {
|
|
192
|
+
if (!Utils_1.Utils.isInClosedInterval(currentBKL, Constants_1.CURRENT_BKL_MMOL_LIMITS)) {
|
|
193
|
+
throw RecommendationError_1.CurrentBKLError();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
exports.checkBloodKetoneLevel = checkBloodKetoneLevel;
|
|
177
198
|
function checkInsulinSensitivity(insulinSensitivity) {
|
|
178
199
|
if (!Utils_1.Utils.isInClosedInterval(insulinSensitivity, Constants_1.INSULIN_SENSITIVITY_MMOL_LIMITS)) {
|
|
179
200
|
throw RecommendationError_1.InsulinSensitivityError();
|
package/src/utils/Validations.ts
CHANGED
|
@@ -6,9 +6,10 @@ import {
|
|
|
6
6
|
IActivitySettings,
|
|
7
7
|
IRecentBolus,
|
|
8
8
|
} from "@hedia/recommendation-calculator/src/RecommendationCalculator";
|
|
9
|
+
import { BloodGlucoseUnit, BloodKetonesUnit } from "@hedia/types";
|
|
9
10
|
import moment from "moment";
|
|
10
11
|
import { IRecommendationProps } from "../RecommendationScreen";
|
|
11
|
-
import { ActivityEnum, ActivityInterval,
|
|
12
|
+
import { ActivityEnum, ActivityInterval, InjectionMethod, Language } from "../types/enum";
|
|
12
13
|
import {
|
|
13
14
|
ACTIVITY_BUFFER_MINUTES,
|
|
14
15
|
ACTIVITY_DURATION_MINUTES_LIMITS,
|
|
@@ -17,6 +18,7 @@ import {
|
|
|
17
18
|
BOLUS_SECONDS_PASSED_LIMITS,
|
|
18
19
|
CARBOHYDRATES_LIMTS,
|
|
19
20
|
CURRENT_BGL_MMOL_LIMITS,
|
|
21
|
+
CURRENT_BKL_MMOL_LIMITS,
|
|
20
22
|
INSULIN_DOSE_LIMITS,
|
|
21
23
|
INSULIN_SENSITIVITY_MMOL_LIMITS,
|
|
22
24
|
INSULIN_TO_CARBS_RATIO_LIMITS,
|
|
@@ -31,23 +33,29 @@ import {
|
|
|
31
33
|
ActivitySettingsError,
|
|
32
34
|
ActivityTargetBGLError,
|
|
33
35
|
ActivityTypeError,
|
|
36
|
+
BloodGlucoseUnitError,
|
|
37
|
+
BloodKetoneUnitError,
|
|
34
38
|
BolusInsulinDoseError,
|
|
35
39
|
BolusInsulinSecondsPassedError,
|
|
36
40
|
CarbohydrateLimitError,
|
|
37
41
|
CurrentBGLError,
|
|
42
|
+
CurrentBKLError,
|
|
38
43
|
InjectionMethodError,
|
|
39
44
|
InsulinSensitivityError,
|
|
40
45
|
InsulinToCarbsRatioError,
|
|
41
46
|
LanguageError,
|
|
42
47
|
TargetBGLError,
|
|
43
|
-
UnitError,
|
|
44
48
|
UserReminderError,
|
|
45
49
|
} from "./RecommendationError";
|
|
46
50
|
import { Utils } from "./Utils";
|
|
47
51
|
|
|
48
52
|
export function validateParams(props: IRecommendationProps): void {
|
|
49
53
|
checkCalculatorParams(props.calculatorParams);
|
|
50
|
-
|
|
54
|
+
checkBGLUnit(props.bloodGlucoseUnit);
|
|
55
|
+
|
|
56
|
+
checkBKLUnit(props.bloodKetoneUnit);
|
|
57
|
+
checkBloodKetoneLevel(props.currentBKL);
|
|
58
|
+
|
|
51
59
|
checkInjectionMethod(props.injectionMethod);
|
|
52
60
|
checkUserReminder(props.userReminder);
|
|
53
61
|
checkLanguage(props.language);
|
|
@@ -77,13 +85,22 @@ export function checkInjectionMethod(injectionMethod: InjectionMethod): void {
|
|
|
77
85
|
}
|
|
78
86
|
}
|
|
79
87
|
|
|
80
|
-
export function
|
|
88
|
+
export function checkBGLUnit(unit: BloodGlucoseUnit): void {
|
|
81
89
|
switch (unit) {
|
|
82
|
-
case
|
|
83
|
-
case
|
|
90
|
+
case BloodGlucoseUnit.MG_DL:
|
|
91
|
+
case BloodGlucoseUnit.MMOL_L:
|
|
84
92
|
break;
|
|
85
93
|
default:
|
|
86
|
-
throw
|
|
94
|
+
throw BloodGlucoseUnitError();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export function checkBKLUnit(unit: BloodKetonesUnit): void {
|
|
98
|
+
switch (unit) {
|
|
99
|
+
case BloodKetonesUnit.MG_DL:
|
|
100
|
+
case BloodKetonesUnit.MMOL_L:
|
|
101
|
+
break;
|
|
102
|
+
default:
|
|
103
|
+
throw BloodKetoneUnitError();
|
|
87
104
|
}
|
|
88
105
|
}
|
|
89
106
|
|
|
@@ -210,6 +227,14 @@ export function checkTargetBGL(targetBGL: number): void {
|
|
|
210
227
|
}
|
|
211
228
|
}
|
|
212
229
|
|
|
230
|
+
export function checkBloodKetoneLevel(currentBKL: number): void {
|
|
231
|
+
if (currentBKL !== null) {
|
|
232
|
+
if (!Utils.isInClosedInterval(currentBKL, CURRENT_BKL_MMOL_LIMITS)) {
|
|
233
|
+
throw CurrentBKLError();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
213
238
|
export function checkInsulinSensitivity(insulinSensitivity: number): void {
|
|
214
239
|
if (!Utils.isInClosedInterval(insulinSensitivity, INSULIN_SENSITIVITY_MMOL_LIMITS)) {
|
|
215
240
|
throw InsulinSensitivityError();
|