@hedia/recommendation-screen 2.2.0-alpha.30 → 2.2.0-alpha.32
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/dist/src/types/enum.d.ts +2 -1
- package/dist/src/types/enum.js +2 -1
- package/dist/src/utils/Constants.d.ts +4 -2
- package/dist/src/utils/Constants.js +4 -2
- package/dist/src/utils/RecommendationError.d.ts +4 -2
- package/dist/src/utils/RecommendationError.js +4 -2
- package/dist/src/utils/Validations.d.ts +11 -2
- package/dist/src/utils/Validations.js +23 -7
- package/package.json +1 -1
package/dist/src/types/enum.d.ts
CHANGED
|
@@ -106,7 +106,8 @@ export declare enum RecommendationErrorEnum {
|
|
|
106
106
|
BloodKetoneUnit = 19,
|
|
107
107
|
BloodGlucoseUnit = 20,
|
|
108
108
|
BloodKetoneProps = 21,
|
|
109
|
-
|
|
109
|
+
CGMOutsideRange = 22,
|
|
110
|
+
ForecastOutsideRange = 23
|
|
110
111
|
}
|
|
111
112
|
/** Indicates the category of the user’s blood glucose level. */
|
|
112
113
|
export declare enum BgLevel {
|
package/dist/src/types/enum.js
CHANGED
|
@@ -120,7 +120,8 @@ export var RecommendationErrorEnum;
|
|
|
120
120
|
RecommendationErrorEnum[RecommendationErrorEnum["BloodKetoneUnit"] = 19] = "BloodKetoneUnit";
|
|
121
121
|
RecommendationErrorEnum[RecommendationErrorEnum["BloodGlucoseUnit"] = 20] = "BloodGlucoseUnit";
|
|
122
122
|
RecommendationErrorEnum[RecommendationErrorEnum["BloodKetoneProps"] = 21] = "BloodKetoneProps";
|
|
123
|
-
RecommendationErrorEnum[RecommendationErrorEnum["
|
|
123
|
+
RecommendationErrorEnum[RecommendationErrorEnum["CGMOutsideRange"] = 22] = "CGMOutsideRange";
|
|
124
|
+
RecommendationErrorEnum[RecommendationErrorEnum["ForecastOutsideRange"] = 23] = "ForecastOutsideRange";
|
|
124
125
|
})(RecommendationErrorEnum || (RecommendationErrorEnum = {}));
|
|
125
126
|
/** Indicates the category of the user’s blood glucose level. */
|
|
126
127
|
export var BgLevel;
|
|
@@ -54,5 +54,7 @@ export declare const ACTIVITY_TARGET_BGL_MMOL_LIMITS: IInterval;
|
|
|
54
54
|
export declare const REMINDER_HOURS_LIMITS: IInterval;
|
|
55
55
|
/** The lower and upper limits for activity reduction. */
|
|
56
56
|
export declare const ACTIVITY_SETTINGS_INTERVAL_LIMITS: IInterval;
|
|
57
|
-
/** The
|
|
58
|
-
export declare const
|
|
57
|
+
/** The lower and upper limits of the cgm reading value in mmol/L. */
|
|
58
|
+
export declare const CGM_LIMITS: IInterval;
|
|
59
|
+
/** The lower and upper limits of the forecast predicted value in mmol/L. */
|
|
60
|
+
export declare const FORECAST_LIMITS: IInterval;
|
|
@@ -54,5 +54,7 @@ export const ACTIVITY_TARGET_BGL_MMOL_LIMITS = { min: 5, max: 13.9 };
|
|
|
54
54
|
export const REMINDER_HOURS_LIMITS = { min: 0, max: 6 };
|
|
55
55
|
/** The lower and upper limits for activity reduction. */
|
|
56
56
|
export const ACTIVITY_SETTINGS_INTERVAL_LIMITS = { min: 0, max: 1 };
|
|
57
|
-
/** The
|
|
58
|
-
export const
|
|
57
|
+
/** The lower and upper limits of the cgm reading value in mmol/L. */
|
|
58
|
+
export const CGM_LIMITS = { min: 2.2, max: 22.2 };
|
|
59
|
+
/** The lower and upper limits of the forecast predicted value in mmol/L. */
|
|
60
|
+
export const FORECAST_LIMITS = { min: 1.1, max: 25 };
|
|
@@ -54,5 +54,7 @@ export declare const BloodKetoneUnitError: () => RecommendationError;
|
|
|
54
54
|
export declare const BloodGlucoseUnitError: () => RecommendationError;
|
|
55
55
|
/** The user has provided a blood ketone level but the blood ketone measuring unit is not defined. */
|
|
56
56
|
export declare const BloodKetonePropsError: () => RecommendationError;
|
|
57
|
-
/** The user
|
|
58
|
-
export declare const
|
|
57
|
+
/** The user’s cgm reading value is outside of the valid range. */
|
|
58
|
+
export declare const CGMOutsideRangeError: () => RecommendationError;
|
|
59
|
+
/** The user’s forecasted value is outside of the valid range. */
|
|
60
|
+
export declare const ForecastOutsideRangeError: () => RecommendationError;
|
|
@@ -61,5 +61,7 @@ export const BloodKetoneUnitError = () => new RecommendationError(i18n._(t `Erro
|
|
|
61
61
|
export const BloodGlucoseUnitError = () => new RecommendationError(i18n._(t `Error. Hedia Calculator does not support your current blood glucose unit.`), RecommendationErrorEnum.BloodGlucoseUnit);
|
|
62
62
|
/** The user has provided a blood ketone level but the blood ketone measuring unit is not defined. */
|
|
63
63
|
export const BloodKetonePropsError = () => new RecommendationError(i18n._(t `Error. Your blood ketone settings are invalid.`), RecommendationErrorEnum.BloodKetoneProps);
|
|
64
|
-
/** The user
|
|
65
|
-
export const
|
|
64
|
+
/** The user’s cgm reading value is outside of the valid range. */
|
|
65
|
+
export const CGMOutsideRangeError = () => new RecommendationError(i18n._(t `Error. Your cgm reading value is outside range.`), RecommendationErrorEnum.CGMOutsideRange);
|
|
66
|
+
/** The user’s forecasted value is outside of the valid range. */
|
|
67
|
+
export const ForecastOutsideRangeError = () => new RecommendationError(i18n._(t `Error. Your forecasted value is outside range.`), RecommendationErrorEnum.ForecastOutsideRange);
|
|
@@ -248,11 +248,20 @@ export declare function checkInsulinToCarbRatio(insulinToCarbRatio: number): voi
|
|
|
248
248
|
* @param carbohydrates The amount of carbohydrates that the user is eating in grams.
|
|
249
249
|
*/
|
|
250
250
|
export declare function checkCarbohydrates(carbohydrates: number): void;
|
|
251
|
+
/**
|
|
252
|
+
* Check if the cgm reading value is in range.
|
|
253
|
+
*
|
|
254
|
+
* Steps:
|
|
255
|
+
* 1. Check if cgm reading value is in range. If it isn’t then throw a CGMOutsideRangeError().
|
|
256
|
+
* @param cgm The cgm data, that includes `latestCGMReadingMmoll` and `cgmTimestamp`
|
|
257
|
+
*
|
|
258
|
+
*/
|
|
259
|
+
export declare function checkCGM(cgm: Logbook.Types.ILogbookEntry[`cgm_reading`]): void;
|
|
251
260
|
/**
|
|
252
261
|
* Check if the forecasted glucose is not very low.
|
|
253
262
|
*
|
|
254
263
|
* Steps:
|
|
255
|
-
* 1. Check if forecasted glucose is
|
|
264
|
+
* 1. Check if forecasted glucose value is in range. If it isn’t then throw a ForecastOutsideRangeError().
|
|
256
265
|
* @param forecast The forecast data, that includes `forecastGlucoseMmoll` and `forecastTimestamp`
|
|
257
266
|
*/
|
|
258
|
-
export declare function
|
|
267
|
+
export declare function checkForecast(forecast: Logbook.Types.ILogbookEntry[`forecast_glucose`] | undefined): void;
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { Activity, BloodGlucoseUnit, BloodKetonesUnit, Languages, UserSettings, } from "@hedia/types";
|
|
8
8
|
import moment from "moment";
|
|
9
|
-
import { ACTIVITY_BUFFER_MINUTES, ACTIVITY_DURATION_MINUTES_LIMITS, ACTIVITY_SETTINGS_INTERVAL_LIMITS, ACTIVITY_TARGET_BGL_MMOL_LIMITS, BOLUS_SECONDS_PASSED_LIMITS, CARBOHYDRATES_LIMTS, CURRENT_BGL_MMOL_LIMITS, CURRENT_BKL_MMOL_LIMITS,
|
|
10
|
-
import { ActivityDateError, ActivityDurationError, ActivityIntensityError, ActivitySettingsError, ActivityTargetBGLError, ActivityTypeError, BloodGlucoseUnitError, BloodKetonePropsError, BloodKetoneUnitError, BolusInsulinDoseError, BolusInsulinSecondsPassedError, CarbohydrateLimitError, CurrentBGLError, CurrentBKLError,
|
|
9
|
+
import { ACTIVITY_BUFFER_MINUTES, ACTIVITY_DURATION_MINUTES_LIMITS, ACTIVITY_SETTINGS_INTERVAL_LIMITS, ACTIVITY_TARGET_BGL_MMOL_LIMITS, BOLUS_SECONDS_PASSED_LIMITS, CARBOHYDRATES_LIMTS, CGM_LIMITS, CURRENT_BGL_MMOL_LIMITS, CURRENT_BKL_MMOL_LIMITS, FORECAST_LIMITS, INSULIN_DOSE_LIMITS, INSULIN_SENSITIVITY_MMOL_LIMITS, INSULIN_TO_CARBS_RATIO_LIMITS, ONE_HOUR_MINUTES, REMINDER_HOURS_LIMITS, TARGET_BGL_MMOL_LIMITS, } from "./Constants";
|
|
10
|
+
import { ActivityDateError, ActivityDurationError, ActivityIntensityError, ActivitySettingsError, ActivityTargetBGLError, ActivityTypeError, BloodGlucoseUnitError, BloodKetonePropsError, BloodKetoneUnitError, BolusInsulinDoseError, BolusInsulinSecondsPassedError, CarbohydrateLimitError, CGMOutsideRangeError, CurrentBGLError, CurrentBKLError, ForecastOutsideRangeError, InjectionMethodError, InsulinSensitivityError, InsulinToCarbsRatioError, LanguageError, LatestLogbook6HoursBGLError, RecentBolusError, TargetBGLError, UserReminderError, } from "./RecommendationError";
|
|
11
11
|
import { Utils } from "./Utils";
|
|
12
12
|
const { hard } = Activity.Enums.ActivityIntensity;
|
|
13
13
|
const { fromFortysix } = Activity.Enums.ActivityReductionIntervals;
|
|
@@ -42,7 +42,8 @@ export function validateParams(props) {
|
|
|
42
42
|
if (props?.calculatorParams?.activity && props?.activityDisplayProps) {
|
|
43
43
|
checkActivityType(props.activityDisplayProps.activityType);
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
checkForecast(props.forecast);
|
|
46
|
+
checkCGM(props.cgm);
|
|
46
47
|
}
|
|
47
48
|
/**
|
|
48
49
|
* In case the users is providing a blood ketone current level, check if the blood ketone unit is defined.
|
|
@@ -408,17 +409,32 @@ export function checkCarbohydrates(carbohydrates) {
|
|
|
408
409
|
throw CarbohydrateLimitError();
|
|
409
410
|
}
|
|
410
411
|
}
|
|
412
|
+
/**
|
|
413
|
+
* Check if the cgm reading value is in range.
|
|
414
|
+
*
|
|
415
|
+
* Steps:
|
|
416
|
+
* 1. Check if cgm reading value is in range. If it isn’t then throw a CGMOutsideRangeError().
|
|
417
|
+
* @param cgm The cgm data, that includes `latestCGMReadingMmoll` and `cgmTimestamp`
|
|
418
|
+
*
|
|
419
|
+
*/
|
|
420
|
+
export function checkCGM(cgm) {
|
|
421
|
+
if (cgm?.latestCGMReadingMmoll) {
|
|
422
|
+
if (!Utils.isInRange(cgm.latestCGMReadingMmoll, CGM_LIMITS)) {
|
|
423
|
+
throw CGMOutsideRangeError();
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
411
427
|
/**
|
|
412
428
|
* Check if the forecasted glucose is not very low.
|
|
413
429
|
*
|
|
414
430
|
* Steps:
|
|
415
|
-
* 1. Check if forecasted glucose is
|
|
431
|
+
* 1. Check if forecasted glucose value is in range. If it isn’t then throw a ForecastOutsideRangeError().
|
|
416
432
|
* @param forecast The forecast data, that includes `forecastGlucoseMmoll` and `forecastTimestamp`
|
|
417
433
|
*/
|
|
418
|
-
export function
|
|
434
|
+
export function checkForecast(forecast) {
|
|
419
435
|
if (forecast?.forecastGlucoseMmoll) {
|
|
420
|
-
if (forecast.forecastGlucoseMmoll
|
|
421
|
-
throw
|
|
436
|
+
if (!Utils.isInRange(forecast.forecastGlucoseMmoll, FORECAST_LIMITS)) {
|
|
437
|
+
throw ForecastOutsideRangeError();
|
|
422
438
|
}
|
|
423
439
|
}
|
|
424
440
|
}
|