@hedia/recommendation-screen 2.2.0-alpha.31 → 2.2.0-alpha.33
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/RecommendationScreen.d.ts +2 -2
- package/dist/src/components/ForecastInfoBar.d.ts +1 -1
- package/dist/src/components/ForecastInfoBar.js +1 -1
- 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 -0
- package/dist/src/utils/Constants.js +4 -0
- package/dist/src/utils/RecommendationError.d.ts +4 -0
- package/dist/src/utils/RecommendationError.js +4 -0
- package/dist/src/utils/Validations.d.ts +17 -0
- package/dist/src/utils/Validations.js +37 -2
- package/package.json +1 -1
|
@@ -30,9 +30,9 @@ export interface IRecommendationProps {
|
|
|
30
30
|
/** The properties of the entered activity that are not used for making the calculation itself, but will be used on the recommendation screen. */
|
|
31
31
|
activityDisplayProps: IActivityDisplayProps | null;
|
|
32
32
|
/** Forecast data received from the app */
|
|
33
|
-
forecast
|
|
33
|
+
forecast: Logbook.Types.ILogbookEntry[`forecast_glucose`];
|
|
34
34
|
/** CGM data received from the app */
|
|
35
|
-
cgm
|
|
35
|
+
cgm: Logbook.Types.ILogbookEntry[`cgm_reading`];
|
|
36
36
|
/**
|
|
37
37
|
* Callback function taking a single boolean argument and returning nothing.
|
|
38
38
|
* To be called when the user decides on a presented carbohydrate recommendation.
|
|
@@ -10,7 +10,7 @@ export interface IProps {
|
|
|
10
10
|
cgm: Logbook.Types.ILogbookEntry[`cgm_reading`];
|
|
11
11
|
/** Unit label to print after the value. */
|
|
12
12
|
unit: BloodGlucoseUnit;
|
|
13
|
-
/**
|
|
13
|
+
/** optional object that contains as properties a valueID and a unitID */
|
|
14
14
|
testID?: {
|
|
15
15
|
valueID: Testing.Id.InfoBarTestIds.Value;
|
|
16
16
|
unitID: Testing.Id.InfoBarTestIds.Unit;
|
|
@@ -46,7 +46,7 @@ const ForecastInfoBar = (props) => {
|
|
|
46
46
|
<View style={forecastSubtitle}>
|
|
47
47
|
<LinearGradient colors={colors.gradientMain} useAngle={true} angle={135} style={forecastDot}/>
|
|
48
48
|
<TextRegular style={forecastText}>{i18n._(t `Forecast time:`)}</TextRegular>
|
|
49
|
-
<TextRegular style={forecastTime}>{
|
|
49
|
+
<TextRegular style={forecastTime}>{`${forecast?.forecastTimestamp}`}</TextRegular>
|
|
50
50
|
</View>
|
|
51
51
|
</View>
|
|
52
52
|
|
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,3 +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 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,3 +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 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,3 +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’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,3 +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’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,3 +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;
|
|
260
|
+
/**
|
|
261
|
+
* Check if the forecasted glucose is not very low.
|
|
262
|
+
*
|
|
263
|
+
* Steps:
|
|
264
|
+
* 1. Check if forecasted glucose value is in range. If it isn’t then throw a ForecastOutsideRangeError().
|
|
265
|
+
* @param forecast The forecast data, that includes `forecastGlucoseMmoll` and `forecastTimestamp`
|
|
266
|
+
*/
|
|
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, 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, CurrentBGLError, CurrentBKLError, InjectionMethodError, InsulinSensitivityError, InsulinToCarbsRatioError, LanguageError, LatestLogbook6HoursBGLError, RecentBolusError, TargetBGLError, UserReminderError, } from "./RecommendationError";
|
|
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,6 +42,12 @@ export function validateParams(props) {
|
|
|
42
42
|
if (props?.calculatorParams?.activity && props?.activityDisplayProps) {
|
|
43
43
|
checkActivityType(props.activityDisplayProps.activityType);
|
|
44
44
|
}
|
|
45
|
+
if (props?.forecast) {
|
|
46
|
+
checkForecast(props.forecast);
|
|
47
|
+
}
|
|
48
|
+
if (props?.cgm) {
|
|
49
|
+
checkCGM(props.cgm);
|
|
50
|
+
}
|
|
45
51
|
}
|
|
46
52
|
/**
|
|
47
53
|
* In case the users is providing a blood ketone current level, check if the blood ketone unit is defined.
|
|
@@ -407,3 +413,32 @@ export function checkCarbohydrates(carbohydrates) {
|
|
|
407
413
|
throw CarbohydrateLimitError();
|
|
408
414
|
}
|
|
409
415
|
}
|
|
416
|
+
/**
|
|
417
|
+
* Check if the cgm reading value is in range.
|
|
418
|
+
*
|
|
419
|
+
* Steps:
|
|
420
|
+
* 1. Check if cgm reading value is in range. If it isn’t then throw a CGMOutsideRangeError().
|
|
421
|
+
* @param cgm The cgm data, that includes `latestCGMReadingMmoll` and `cgmTimestamp`
|
|
422
|
+
*
|
|
423
|
+
*/
|
|
424
|
+
export function checkCGM(cgm) {
|
|
425
|
+
if (cgm?.latestCGMReadingMmoll) {
|
|
426
|
+
if (!Utils.isInRange(cgm.latestCGMReadingMmoll, CGM_LIMITS)) {
|
|
427
|
+
throw CGMOutsideRangeError();
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Check if the forecasted glucose is not very low.
|
|
433
|
+
*
|
|
434
|
+
* Steps:
|
|
435
|
+
* 1. Check if forecasted glucose value is in range. If it isn’t then throw a ForecastOutsideRangeError().
|
|
436
|
+
* @param forecast The forecast data, that includes `forecastGlucoseMmoll` and `forecastTimestamp`
|
|
437
|
+
*/
|
|
438
|
+
export function checkForecast(forecast) {
|
|
439
|
+
if (forecast?.forecastGlucoseMmoll) {
|
|
440
|
+
if (!Utils.isInRange(forecast.forecastGlucoseMmoll, FORECAST_LIMITS)) {
|
|
441
|
+
throw ForecastOutsideRangeError();
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|