@hedia/recommendation-screen 1.1.2 → 1.2.1

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.
@@ -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 InsulinWasLimitedActivity: (activityReduction?: number) => string;
20
+ static InsulinWasLimited: (activityReduction?: number) => string;
21
21
  }
@@ -49,14 +49,15 @@ Messages.Reminder15Minutes = () => i18nUtils_1.i18n._(macro_1.t `You will be rem
49
49
  Messages.PostponePhysicalActivity = () => i18nUtils_1.i18n._(macro_1.t `If it is possible, postpone your planned exercise.`);
50
50
  Messages.HighBGL = () => i18nUtils_1.i18n._(macro_1.t `You have a high blood glucose level.`);
51
51
  Messages.InsulinKetones = () => i18nUtils_1.i18n._(macro_1.t `You should take rapid-acting insulin and measure ketones.`);
52
- Messages.RecommendationWasLimited = () => i18nUtils_1.i18n._(macro_1.t `Your recommendation would have been higher than ${Calculator.SAFETY_INSULIN_LIMIT} units of insulin, but it has been limited for safety reasons.`);
52
+ Messages.RecommendationWasLimited = () => i18nUtils_1.i18n._(macro_1.t `Your recommendation would have been higher than ${Calculator.SAFETY_INSULIN_LIMIT} units of insulin, but it has been limited for safety reasons.
53
+ Hedia never recommends more than ${Calculator.SAFETY_INSULIN_LIMIT} units of insulin per calculation.`);
53
54
  Messages.RecommendationWasLimitedActivity = (activityReduction) => i18nUtils_1.i18n._(macro_1.t `Your recommendation would have been higher than ${getLimitedValue(activityReduction)}
54
55
  units of insulin, but it has been limited for safety reasons.${`\n\n`}
55
56
  Hedia never recommends more than ${Calculator.SAFETY_INSULIN_LIMIT}
56
57
  units of insulin per calculation, but because of the physical activity
57
58
  you entered it has been further reduced by ${(activityReduction * 100).toFixed(0)}% to
58
59
  ${getLimitedValue(activityReduction)}.`);
59
- Messages.InsulinWasLimitedActivity = (activityReduction) => activityReduction
60
- ? i18nUtils_1.i18n._(macro_1.t `Hedia doesn't support more than ${Calculator.SAFETY_INSULIN_LIMIT} units of insulin per log, but because of the physical activity you entered it has been further reduced by
61
- ${(activityReduction * 100).toFixed(0)}% to ${getLimitedValue(activityReduction)} units for this log.`)
62
- : i18nUtils_1.i18n._(macro_1.t `Your recommendation would have been higher than ${Calculator.SAFETY_INSULIN_LIMIT} units of insulin, but it has been limited for safety reasons.`);
60
+ Messages.InsulinWasLimited = (activityReduction) => activityReduction
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
+ ${(activityReduction * 100).toFixed(0)}% to ${getLimitedValue(activityReduction)} units for this calculation.`)
63
+ : i18nUtils_1.i18n._(macro_1.t `Hedia does not support more than ${Calculator.SAFETY_INSULIN_LIMIT} units of insulin per calculation.`);
@@ -34,7 +34,8 @@ export class Messages {
34
34
  public static InsulinKetones = (): string => i18n._(t`You should take rapid-acting insulin and measure ketones.`);
35
35
  public static RecommendationWasLimited = (): string =>
36
36
  i18n._(
37
- t`Your recommendation would have been higher than ${Calculator.SAFETY_INSULIN_LIMIT} units of insulin, but it has been limited for safety reasons.`,
37
+ t`Your recommendation would have been higher than ${Calculator.SAFETY_INSULIN_LIMIT} units of insulin, but it has been limited for safety reasons.
38
+ Hedia never recommends more than ${Calculator.SAFETY_INSULIN_LIMIT} units of insulin per calculation.`,
38
39
  );
39
40
  public static RecommendationWasLimitedActivity = (activityReduction: number): string =>
40
41
  i18n._(
@@ -45,15 +46,15 @@ export class Messages {
45
46
  you entered it has been further reduced by ${(activityReduction * 100).toFixed(0)}% to
46
47
  ${getLimitedValue(activityReduction)}.`,
47
48
  );
48
- public static InsulinWasLimitedActivity = (activityReduction?: number): string =>
49
+ public static InsulinWasLimited = (activityReduction?: number): string =>
49
50
  activityReduction
50
51
  ? i18n._(
51
52
  t`Hedia doesn't support more than ${
52
53
  Calculator.SAFETY_INSULIN_LIMIT
53
- } units of insulin per log, but because of the physical activity you entered it has been further reduced by
54
- ${(activityReduction * 100).toFixed(0)}% to ${getLimitedValue(activityReduction)} units for this log.`,
54
+ } units of insulin per calculation, but because of the physical activity you entered it has been further reduced by
55
+ ${(activityReduction * 100).toFixed(0)}% to ${getLimitedValue(activityReduction)} units for this calculation.`,
55
56
  )
56
57
  : i18n._(
57
- t`Your recommendation would have been higher than ${Calculator.SAFETY_INSULIN_LIMIT} units of insulin, but it has been limited for safety reasons.`,
58
+ t`Hedia does not support more than ${Calculator.SAFETY_INSULIN_LIMIT} units of insulin per calculation.`,
58
59
  );
59
60
  }
@@ -3,6 +3,7 @@ import { IInterval } from "../types/types";
3
3
  export const BACKGROUND_COLOUR_PURPLE = `rgba(27, 31, 72, 1)`;
4
4
  export const BORDER_COLOUR_GREY = `rgba(74, 91, 134, 1)`;
5
5
  export const BORDER_COLOUR_TEAL = `rgba(1, 255, 252, 0.8)`;
6
+
6
7
  export const SEVERE_HYPERGLYCEMIA_START_MMOL = 15;
7
8
 
8
9
  export const FOUR_HOURS_SECONDS = 14400;
@@ -1,6 +1,26 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
2
21
  Object.defineProperty(exports, "__esModule", { value: true });
3
22
  exports.TimeoutLimitError = exports.UnitError = exports.LanguageError = exports.InjectionMethodError = exports.UserReminderError = exports.BolusInsulinSecondsPassedError = exports.BolusInsulinDosisError = exports.TargetBGLError = exports.CurrentBGLError = exports.InsulinToCarbsRatioError = exports.InsulinSensitivityError = exports.InsulinLimitError = exports.CarbohydrateLimitError = exports.ActivityTargetBGLError = exports.ActivityIntensityError = exports.ActivityDateError = exports.ActivityDurationError = exports.ActivitySettingsError = exports.RecommendationError = void 0;
23
+ const Calculator = __importStar(require("@hedia/recommendation-calculator"));
4
24
  const macro_1 = require("@lingui/macro");
5
25
  const i18nUtils_1 = require("../locale/i18nUtils");
6
26
  const enum_1 = require("../types/enum");
@@ -18,14 +38,12 @@ exports.ActivityDateError = () => new RecommendationError(i18nUtils_1.i18n._(mac
18
38
  exports.ActivityIntensityError = () => new RecommendationError(i18nUtils_1.i18n._(macro_1.t `Error. Hedia Calculator does not support your activity intensity value`), enum_1.RecommendationErrorEnum.ActivityIntensity);
19
39
  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);
20
40
  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);
21
- exports.InsulinLimitError = (activityReduction) => new RecommendationError(activityReduction
22
- ? AttentionMessages_1.Messages.InsulinWasLimitedActivity(activityReduction)
23
- : AttentionMessages_1.Messages.InsulinWasLimitedActivity(), enum_1.RecommendationErrorEnum.InsulinLimit);
41
+ exports.InsulinLimitError = (activityReduction) => new RecommendationError(activityReduction ? AttentionMessages_1.Messages.InsulinWasLimited(activityReduction) : AttentionMessages_1.Messages.InsulinWasLimited(), enum_1.RecommendationErrorEnum.InsulinLimit);
24
42
  exports.InsulinSensitivityError = () => new RecommendationError(i18nUtils_1.i18n._(macro_1.t `Error. Please verify that your insulin sensitivity value is correct.`), enum_1.RecommendationErrorEnum.InsulinSensitivity);
25
43
  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);
26
44
  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);
27
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);
28
- exports.BolusInsulinDosisError = () => new RecommendationError(i18nUtils_1.i18n._(macro_1.t `Error. Hedia Calculator does not support an insulin dosis greater that 50 units`), enum_1.RecommendationErrorEnum.BolusInsulinDosis);
46
+ exports.BolusInsulinDosisError = () => new RecommendationError(i18nUtils_1.i18n._(macro_1.t `Error. Hedia Calculator does not support an insulin dosis greater than ${Calculator.SAFETY_INSULIN_LIMIT} units`), enum_1.RecommendationErrorEnum.BolusInsulinDosis);
29
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);
30
48
  exports.UserReminderError = () => new RecommendationError(i18nUtils_1.i18n._(macro_1.t `Error. Please verify your notifications settings.`), enum_1.RecommendationErrorEnum.UserReminder);
31
49
  exports.InjectionMethodError = () => new RecommendationError(i18nUtils_1.i18n._(macro_1.t `Error. Hedia Calculator does not support your injection method.`), enum_1.RecommendationErrorEnum.InjectionMethod);
@@ -1,3 +1,4 @@
1
+ import * as Calculator from "@hedia/recommendation-calculator";
1
2
  import { t } from "@lingui/macro";
2
3
  import { i18n } from "../locale/i18nUtils";
3
4
  import { RecommendationErrorEnum } from "../types/enum";
@@ -52,9 +53,7 @@ export const CarbohydrateLimitError = (): RecommendationError =>
52
53
 
53
54
  export const InsulinLimitError = (activityReduction?: number): RecommendationError =>
54
55
  new RecommendationError(
55
- activityReduction
56
- ? Messages.InsulinWasLimitedActivity(activityReduction)
57
- : Messages.InsulinWasLimitedActivity(),
56
+ activityReduction ? Messages.InsulinWasLimited(activityReduction) : Messages.InsulinWasLimited(),
58
57
  RecommendationErrorEnum.InsulinLimit,
59
58
  );
60
59
 
@@ -84,7 +83,9 @@ export const TargetBGLError = (): RecommendationError =>
84
83
 
85
84
  export const BolusInsulinDosisError = (): RecommendationError =>
86
85
  new RecommendationError(
87
- i18n._(t`Error. Hedia Calculator does not support an insulin dosis greater that 50 units`),
86
+ i18n._(
87
+ t`Error. Hedia Calculator does not support an insulin dosis greater than ${Calculator.SAFETY_INSULIN_LIMIT} units`,
88
+ ),
88
89
  RecommendationErrorEnum.BolusInsulinDosis,
89
90
  );
90
91
 
package/App.jsx DELETED
@@ -1,94 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const RecommendationCalculator_1 = require("@hedia/recommendation-calculator/src/RecommendationCalculator");
7
- const react_1 = __importDefault(require("react"));
8
- const RecommendationScreen_1 = __importDefault(require("./src/RecommendationScreen"));
9
- const enum_1 = require("./src/types/enum");
10
- class App extends react_1.default.Component {
11
- constructor(props) {
12
- super(props);
13
- this.exitCallback = (showRecentInsulin) => {
14
- console.log(`Exiting...`, showRecentInsulin);
15
- };
16
- this.removeCarbs = () => {
17
- this.setState({
18
- carbs: null,
19
- });
20
- };
21
- this.changeCarbs = (carbs) => {
22
- this.setState({
23
- carbs,
24
- });
25
- };
26
- this.onYes = () => {
27
- console.log(`Navigate to recent bolus screen`);
28
- };
29
- this.updatedRecommendedInsulin = (val) => {
30
- console.log(`Updated recommended insulin: `, val);
31
- };
32
- this.transferToLogbook = (...params) => {
33
- console.log(`Transfered:`, params);
34
- };
35
- this.updateRemeasureTime = (remeasureTime) => {
36
- console.log(`updateRemeasureTime:`, remeasureTime);
37
- };
38
- this.recommendationAnswer = (carbRecommendationAnswer) => {
39
- console.log("carbRecommendationAnswer", carbRecommendationAnswer);
40
- };
41
- this.handleError = (error) => {
42
- console.log(JSON.stringify(error));
43
- switch (error.type) {
44
- default:
45
- throw error;
46
- }
47
- };
48
- const params = {
49
- currentBGL: 3,
50
- carbohydrates: 120,
51
- carbohydrateRatio: 22,
52
- insulinSensitivity: 0.3,
53
- targetBGL: 7,
54
- recentBoluses: [],
55
- activity: {
56
- activityDate: new Date(Date.now() - enum_1.Milliseconds.Minute * 2),
57
- activityDuration: 5,
58
- activityIntensity: RecommendationCalculator_1.ActivityIntensity.Moderate,
59
- activitySettings: {
60
- hard: { fromZero: 0.25, fromThirty: 0.55, fromFortysix: 0 },
61
- light: { fromZero: 0.25, fromThirty: 0.55, fromFortysix: 0.25 },
62
- post: { fromZero: 1, fromThirty: 0, fromFortysix: 0.25 },
63
- moderate: { fromZero: 0.25, fromThirty: 0.5, fromFortysix: 0.75 },
64
- target: 8.3,
65
- },
66
- activityTitle: `Moderate Activity Test Title`,
67
- },
68
- };
69
- this.state = {
70
- params,
71
- carbs: 25,
72
- injectionMethod: enum_1.InjectionMethod.Pump,
73
- };
74
- }
75
- render() {
76
- const logbook1 = {
77
- blood_glucose_millimolar: 15,
78
- carbohydrates_entered_grams: 25,
79
- carbohydrates_suggested_grams: 25,
80
- client_timestamp: `25`,
81
- client_version: 25,
82
- entry_timestamp: `25`,
83
- event_uuid: null,
84
- insulin_entered_units: 25,
85
- insulin_suggested_units: 25,
86
- is_deleted: null,
87
- mood: 2,
88
- settings_uuid: `25`,
89
- uuid: `aaa`,
90
- };
91
- return (<RecommendationScreen_1.default latestLogbookFrom6Hours={logbook1} language={enum_1.Languages.en} injectionMethod={this.state.injectionMethod} calculatorParams={this.state.params} userReminder={5} units={enum_1.BGUnit.MMOL_L} exitCallback={this.exitCallback} onRecentInsulinYes={this.onYes} transferToLogbook={this.transferToLogbook} onError={this.handleError} carbRecommendationAnswer={this.recommendationAnswer} activityType={enum_1.ActivityEnum.Walk}/>);
92
- }
93
- }
94
- exports.default = App;
@@ -1,26 +0,0 @@
1
- import * as React from "react";
2
- import { AttentionMessage } from "../utils/AttentionMessages";
3
- interface IModalProps {
4
- isVisible: boolean;
5
- suggestedCarbohydrates?: number;
6
- attentionMessage: AttentionMessage;
7
- limitationMessage: AttentionMessage;
8
- onClickOkButton(): void;
9
- onAcceptCarbohydrates(): void;
10
- onDeclineCarbohydrates(): void;
11
- }
12
- interface IModalState {
13
- firstPageVisible: boolean;
14
- }
15
- export default class HediaRecommendationModal extends React.Component<IModalProps, IModalState> {
16
- constructor(props: IModalProps);
17
- okayButton(): JSX.Element;
18
- nextButton(): JSX.Element;
19
- onPressNextButton: () => void;
20
- recommendationButtons: () => JSX.Element;
21
- recommendCarbohydrates: () => JSX.Element;
22
- secondPage: () => JSX.Element;
23
- firstPage: () => JSX.Element;
24
- render(): JSX.Element;
25
- }
26
- export {};