@hedia/recommendation-screen 2.0.2 → 2.1.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/App.d.ts +2 -2
- package/coverage/clover.xml +700 -0
- package/coverage/coverage-final.json +28 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +79 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +201 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +170 -0
- package/coverage/lcov-report/src/RecommendationScreen.tsx.html +1460 -0
- package/coverage/lcov-report/src/__tests__/index.html +111 -0
- package/coverage/lcov-report/src/__tests__/utils.tsx.html +512 -0
- package/coverage/lcov-report/src/components/Header.tsx.html +347 -0
- package/coverage/lcov-report/src/components/InfoBars.tsx.html +404 -0
- package/coverage/lcov-report/src/components/InvisibleNumberInput.tsx.html +374 -0
- package/coverage/lcov-report/src/components/LimitationMessage.tsx.html +191 -0
- package/coverage/lcov-report/src/components/LineSeparator.tsx.html +152 -0
- package/coverage/lcov-report/src/components/RecentInsulin.tsx.html +383 -0
- package/coverage/lcov-report/src/components/RecommendationModal.tsx.html +737 -0
- package/coverage/lcov-report/src/components/RecommendedCarbs.tsx.html +857 -0
- package/coverage/lcov-report/src/components/RecommendedInsulin.tsx.html +605 -0
- package/coverage/lcov-report/src/components/Remeasure.tsx.html +440 -0
- package/coverage/lcov-report/src/components/TransferToLogbook.tsx.html +380 -0
- package/coverage/lcov-report/src/components/TwoOptionModal.tsx.html +635 -0
- package/coverage/lcov-report/src/components/activity/Activity.tsx.html +311 -0
- package/coverage/lcov-report/src/components/activity/ActivityIcon.tsx.html +242 -0
- package/coverage/lcov-report/src/components/activity/ActivityIntensity.tsx.html +257 -0
- package/coverage/lcov-report/src/components/activity/index.html +141 -0
- package/coverage/lcov-report/src/components/index.html +276 -0
- package/coverage/lcov-report/src/components/mood/Emotion.tsx.html +278 -0
- package/coverage/lcov-report/src/components/mood/MoodIcon.tsx.html +260 -0
- package/coverage/lcov-report/src/components/mood/index.html +126 -0
- package/coverage/lcov-report/src/index.html +111 -0
- package/coverage/lcov-report/src/locale/i18nUtils.ts.html +161 -0
- package/coverage/lcov-report/src/locale/index.html +111 -0
- package/coverage/lcov-report/src/utils/AttentionMessages.tsx.html +326 -0
- package/coverage/lcov-report/src/utils/Constants.ts.html +176 -0
- package/coverage/lcov-report/src/utils/RecommendationError.tsx.html +500 -0
- package/coverage/lcov-report/src/utils/RecommendationUtils.ts.html +467 -0
- package/coverage/lcov-report/src/utils/Translations.ts.html +107 -0
- package/coverage/lcov-report/src/utils/Utils.ts.html +263 -0
- package/coverage/lcov-report/src/utils/Validations.ts.html +815 -0
- package/coverage/lcov-report/src/utils/index.html +201 -0
- package/coverage/lcov.info +1581 -0
- package/jest.config.js +2 -1
- package/package.json +2 -2
- package/src/RecommendationScreen.d.ts +2 -3
- package/src/__tests__/components/Emotion.test.jsx +7 -8
- package/src/components/Icon.d.ts +13 -0
- package/src/components/Icon.jsx +42 -0
- package/src/components/LimitationMessage.d.ts +1 -2
- package/src/components/RecommendationModal.d.ts +2 -3
- package/src/components/RecommendationModal.jsx +2 -1
- package/src/components/activity/ActivityIntensity.jsx +4 -3
- package/src/utils/AttentionMessages.d.ts +16 -10
- package/src/utils/AttentionMessages.jsx +15 -10
- package/src/utils/RecommendationUtils.d.ts +2 -3
- package/src/utils/RecommendationUtils.js +10 -6
- package/src/utils/Utils.d.ts +1 -0
- package/src/utils/Utils.js +4 -0
- package/tsconfig.json +7 -5
- package/App.tsx +0 -140
- package/index.ts +0 -6
- package/src/RecommendationScreen.tsx +0 -461
- package/src/__tests__/RecommendationScreen.test.tsx +0 -1231
- package/src/__tests__/RecommendationUtils.test.ts +0 -332
- package/src/__tests__/Translate.test.tsx +0 -31
- package/src/__tests__/Utils.test.ts +0 -91
- package/src/__tests__/Validations.test.ts +0 -648
- package/src/__tests__/components/Activity.test.tsx +0 -163
- package/src/__tests__/components/Emotion.test.tsx +0 -110
- package/src/__tests__/components/Header.test.tsx +0 -44
- package/src/__tests__/components/InfoBars.test.tsx +0 -152
- package/src/__tests__/components/InvisibleNumberInput.test.tsx +0 -294
- package/src/__tests__/components/LimitationMessage.test.tsx +0 -58
- package/src/__tests__/components/MoodIcon.test.tsx +0 -45
- package/src/__tests__/components/RecommendationModal.test.tsx +0 -169
- package/src/__tests__/components/RecommendedCarbs.test.tsx +0 -234
- package/src/__tests__/components/RecommendedInsulin.test.tsx +0 -241
- package/src/__tests__/components/Remeasure.test.tsx +0 -97
- package/src/__tests__/components/TransferToLogbook.test.tsx +0 -38
- package/src/__tests__/components/TwoOptionModal.test.tsx +0 -72
- package/src/__tests__/utils.tsx +0 -144
- package/src/components/Header.tsx +0 -89
- package/src/components/Icon.js +0 -41
- package/src/components/InfoBars.tsx +0 -108
- package/src/components/InvisibleNumberInput.tsx +0 -98
- package/src/components/LimitationMessage.tsx +0 -38
- package/src/components/LineSeparator.tsx +0 -24
- package/src/components/RecentInsulin.tsx +0 -101
- package/src/components/RecommendationModal.tsx +0 -224
- package/src/components/RecommendedCarbs.tsx +0 -259
- package/src/components/RecommendedInsulin.tsx +0 -175
- package/src/components/Remeasure.tsx +0 -120
- package/src/components/TransferToLogbook.tsx +0 -100
- package/src/components/TwoOptionModal.tsx +0 -185
- package/src/components/activity/Activity.tsx +0 -77
- package/src/components/activity/ActivityIcon.tsx +0 -54
- package/src/components/activity/ActivityIntensity.tsx +0 -58
- package/src/components/mood/Emotion.tsx +0 -66
- package/src/components/mood/MoodIcon.tsx +0 -60
- package/src/locale/CleanLanguage.ts +0 -13
- package/src/locale/i18nUtils.ts +0 -27
- package/src/types/enum.ts +0 -108
- package/src/types/types.ts +0 -16
- package/src/utils/AttentionMessages.tsx +0 -75
- package/src/utils/Constants.ts +0 -32
- package/src/utils/RecommendationError.tsx +0 -140
- package/src/utils/RecommendationUtils.ts +0 -125
- package/src/utils/Translations.ts +0 -9
- package/src/utils/Utils.ts +0 -57
- package/src/utils/Validations.ts +0 -245
package/jest.config.js
CHANGED
|
@@ -24,7 +24,8 @@ module.exports = {
|
|
|
24
24
|
"!src/types/**.*",
|
|
25
25
|
"!src/App.tsx",
|
|
26
26
|
"!src/locale/CleanLanguage.ts",
|
|
27
|
-
"!src/utils/RecommendationError.ts"
|
|
27
|
+
"!src/utils/RecommendationError.ts",
|
|
28
|
+
"!src/components/Icon.tsx"
|
|
28
29
|
],
|
|
29
30
|
// The directory where Jest should output its coverage files
|
|
30
31
|
coverageDirectory: "coverage",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hedia/recommendation-screen",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Hedia Recommendation Screen for Bolus and Carbohydrates",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"react-test-renderer": "16.13.1",
|
|
69
69
|
"tslint": "6.1.2",
|
|
70
70
|
"tslint-config-prettier": "1.18.0",
|
|
71
|
-
"typescript": "4.1.
|
|
71
|
+
"typescript": "4.1.5"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"moment": "2.27.0",
|
|
@@ -3,7 +3,6 @@ import { AppStateStatus } from "react-native";
|
|
|
3
3
|
import { BloodGlucoseUnit, BloodKetonesUnit, Languages, Logbook, UserSettings } from "@hedia/types";
|
|
4
4
|
import { RecommendationError } from "./utils/RecommendationError";
|
|
5
5
|
import { IActivityDisplayProps, IRecommendationParams, logbookEntry } from "./types/types";
|
|
6
|
-
import { AttentionMessage } from "./utils/AttentionMessages";
|
|
7
6
|
interface IResult {
|
|
8
7
|
suggested: number;
|
|
9
8
|
entered: number | null;
|
|
@@ -71,9 +70,9 @@ export default class RecommendationScreen extends React.Component<IRecommendatio
|
|
|
71
70
|
handleMoodSelected: (selectedMood: IState["selectedMood"]) => void;
|
|
72
71
|
updateInsulinRecommendation: (enteredInsulin: number) => void;
|
|
73
72
|
handleTransfer: () => void;
|
|
74
|
-
getBGLevelAttentionMessage: () =>
|
|
73
|
+
getBGLevelAttentionMessage: () => string | null;
|
|
75
74
|
getBGLevelRemeasurementReminder: () => number;
|
|
76
|
-
getLimitationAttentionMessage: () =>
|
|
75
|
+
getLimitationAttentionMessage: () => string | null;
|
|
77
76
|
render(): JSX.Element;
|
|
78
77
|
}
|
|
79
78
|
export {};
|
|
@@ -43,16 +43,15 @@ describe(`Emotion - Component`, () => {
|
|
|
43
43
|
react_native_testing_library_1.fireEvent(newIcon, `onPress`);
|
|
44
44
|
expect(mockedStateMood).toBe(mood);
|
|
45
45
|
wrapper.update(<Emotion_1.default moodSelected={mockSelected} currentMood={mockedStateMood}/>);
|
|
46
|
-
Object.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
expect(utils_1.getIcon(wrapper,
|
|
51
|
-
expect(utils_1.getIcon(wrapper, MoodEnum[key], false)).toBeNull();
|
|
46
|
+
const moodValues = Object.values(MoodEnum).filter((value) => typeof value === `string`);
|
|
47
|
+
moodValues.forEach((value) => {
|
|
48
|
+
if (moodName === value) {
|
|
49
|
+
expect(utils_1.getIcon(wrapper, value, true)).not.toBeNull();
|
|
50
|
+
expect(utils_1.getIcon(wrapper, value, false)).toBeNull();
|
|
52
51
|
}
|
|
53
52
|
else {
|
|
54
|
-
expect(utils_1.getIcon(wrapper,
|
|
55
|
-
expect(utils_1.getIcon(wrapper,
|
|
53
|
+
expect(utils_1.getIcon(wrapper, value, false)).not.toBeNull();
|
|
54
|
+
expect(utils_1.getIcon(wrapper, value, true)).toBeNull();
|
|
56
55
|
}
|
|
57
56
|
});
|
|
58
57
|
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyleSheet } from "react-native";
|
|
3
|
+
interface IProps {
|
|
4
|
+
iconIdentifier: string;
|
|
5
|
+
iconStyle: StyleSheet.NamedStyles<any>;
|
|
6
|
+
}
|
|
7
|
+
export default class Icon extends React.Component<IProps> {
|
|
8
|
+
static defaultProps: any;
|
|
9
|
+
_root: any;
|
|
10
|
+
setNativeProps(nativeProps: any): void;
|
|
11
|
+
render(): JSX.Element;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
// @ts-nocheck
|
|
7
|
+
/* tslint:disable */
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const IconSets = {
|
|
10
|
+
AntDesign: require(`react-native-vector-icons/AntDesign`),
|
|
11
|
+
Feather: require(`react-native-vector-icons/Feather`),
|
|
12
|
+
EvilIcons: require(`react-native-vector-icons/EvilIcons`),
|
|
13
|
+
Ionicons: require(`react-native-vector-icons/Ionicons`),
|
|
14
|
+
FontAwesome: require(`react-native-vector-icons/FontAwesome`),
|
|
15
|
+
Entypo: require(`react-native-vector-icons/Entypo`),
|
|
16
|
+
};
|
|
17
|
+
class Icon extends react_1.default.Component {
|
|
18
|
+
setNativeProps(nativeProps) {
|
|
19
|
+
this._root.setNativeProps(nativeProps);
|
|
20
|
+
}
|
|
21
|
+
render() {
|
|
22
|
+
const iconParts = this.props.iconIdentifier.split(`/`);
|
|
23
|
+
let iconPackageName = iconParts[0];
|
|
24
|
+
let iconName = iconParts[1];
|
|
25
|
+
if (!IconSets[iconPackageName]) {
|
|
26
|
+
iconPackageName = `FontAwesome`;
|
|
27
|
+
iconName = `question`;
|
|
28
|
+
}
|
|
29
|
+
const clonedProps = {
|
|
30
|
+
...this.props,
|
|
31
|
+
name: iconName,
|
|
32
|
+
iconIdentifier: undefined,
|
|
33
|
+
ref: (component) => (this._root = component),
|
|
34
|
+
};
|
|
35
|
+
const IconClass = IconSets[iconPackageName].default;
|
|
36
|
+
return <IconClass {...clonedProps}/>;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.default = Icon;
|
|
40
|
+
Icon.defaultProps = {
|
|
41
|
+
iconIdentifier: `FontAwesome/question`,
|
|
42
|
+
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { AttentionMessage } from "../utils/AttentionMessages";
|
|
3
2
|
export interface ILimitationMessageProps {
|
|
4
|
-
limitationMessage:
|
|
3
|
+
limitationMessage: string | null;
|
|
5
4
|
onPressNextButton(): void;
|
|
6
5
|
}
|
|
7
6
|
export default class LimitationMessage extends React.Component<ILimitationMessageProps> {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { AttentionMessage } from "../utils/AttentionMessages";
|
|
3
2
|
interface IModalProps {
|
|
4
3
|
isVisible: boolean;
|
|
5
4
|
suggestedCarbohydrates: number | null;
|
|
6
|
-
attentionMessage:
|
|
7
|
-
limitationMessage:
|
|
5
|
+
attentionMessage: string | null;
|
|
6
|
+
limitationMessage: string | null;
|
|
8
7
|
onClickOkButton(): void;
|
|
9
8
|
onAcceptCarbohydrates(): void;
|
|
10
9
|
onDeclineCarbohydrates(): void;
|
|
@@ -95,7 +95,8 @@ class RecommendationModal extends React.Component {
|
|
|
95
95
|
</React.Fragment>);
|
|
96
96
|
};
|
|
97
97
|
this.firstPage = () => {
|
|
98
|
-
|
|
98
|
+
const { limitationMessage } = this.props;
|
|
99
|
+
return <LimitationMessage_1.default limitationMessage={limitationMessage} onPressNextButton={this.onPressNextButton}/>;
|
|
99
100
|
};
|
|
100
101
|
this.state = {
|
|
101
102
|
firstPageVisible: !!this.props.limitationMessage,
|
|
@@ -3,6 +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
|
+
const types_1 = require("@hedia/types");
|
|
6
7
|
const react_1 = __importDefault(require("react"));
|
|
7
8
|
const react_native_1 = require("react-native");
|
|
8
9
|
const Translations_1 = require("../../utils/Translations");
|
|
@@ -35,13 +36,13 @@ const activityIntensityStyles = react_native_1.StyleSheet.create({
|
|
|
35
36
|
padding: `5%`,
|
|
36
37
|
borderRadius: 5,
|
|
37
38
|
},
|
|
38
|
-
|
|
39
|
+
[types_1.Activity.Enums.ActivityIntensity.light]: {
|
|
39
40
|
backgroundColor: `#A5D871`,
|
|
40
41
|
},
|
|
41
|
-
|
|
42
|
+
[types_1.Activity.Enums.ActivityIntensity.moderate]: {
|
|
42
43
|
backgroundColor: `#F9BD5A`,
|
|
43
44
|
},
|
|
44
|
-
|
|
45
|
+
[types_1.Activity.Enums.ActivityIntensity.hard]: {
|
|
45
46
|
backgroundColor: `#EC5466`,
|
|
46
47
|
},
|
|
47
48
|
intensityContainer: {
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
export declare const AttentionMessage: {
|
|
2
|
+
SevereHypoglycemia: () => string;
|
|
3
|
+
Hypoglycemia: () => string;
|
|
4
|
+
MildHypoglycemia: () => string;
|
|
5
|
+
NormoglycemiaActivityUnder5MMOL: () => string;
|
|
6
|
+
HyperglycemiaActivity: () => string;
|
|
7
|
+
SevereHyperglycemia: () => string;
|
|
8
|
+
SevereHyperglycemiaActivity: () => string;
|
|
9
|
+
BGLevelNotProvided: null;
|
|
10
|
+
Hyperglycemia: null;
|
|
11
|
+
MildHyperglycemia: null;
|
|
12
|
+
Normoglycemia: null;
|
|
13
|
+
NormoglycemiaUnder5MMOL: null;
|
|
14
|
+
UnsupportedBGLevel: null;
|
|
15
|
+
};
|
|
16
|
+
export declare function addPostponeActivityMessageUnder5MMOL(message: string): string;
|
|
11
17
|
export declare class Messages {
|
|
12
18
|
static VeryLowBGL: () => string;
|
|
13
19
|
static LowBGL: () => string;
|
|
@@ -8,16 +8,21 @@ const types_1 = require("@hedia/types");
|
|
|
8
8
|
const macro_1 = require("@lingui/macro");
|
|
9
9
|
const moment_1 = __importDefault(require("moment"));
|
|
10
10
|
const i18nUtils_1 = require("../locale/i18nUtils");
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
exports.AttentionMessage = {
|
|
12
|
+
SevereHypoglycemia: () => `${Messages.VeryLowBGL()}${`\n`}${Messages.Reminder15Minutes()}`,
|
|
13
|
+
Hypoglycemia: () => `${Messages.LowBGL()}${`\n`}${Messages.Reminder15Minutes()}`,
|
|
14
|
+
MildHypoglycemia: () => Messages.Reminder15Minutes(),
|
|
15
|
+
NormoglycemiaActivityUnder5MMOL: () => Messages.PostponePhysicalActivityUnder5MMOL(),
|
|
16
|
+
HyperglycemiaActivity: () => `${Messages.HighBGL()}${`\n`}${Messages.InsulinKetones()}${`\n`}${Messages.Reminder15Minutes()}${`\n`}${Messages.PostponePhysicalActivity()}`,
|
|
17
|
+
SevereHyperglycemia: () => `${Messages.HighBGL()}${`\n`}${Messages.InsulinKetones()}${`\n`}`,
|
|
18
|
+
SevereHyperglycemiaActivity: () => `${Messages.HighBGL()}${`\n`}${Messages.InsulinKetones()}${`\n`}${Messages.Reminder15Minutes()}${`\n`}${Messages.PostponePhysicalActivity()}`,
|
|
19
|
+
BGLevelNotProvided: null,
|
|
20
|
+
Hyperglycemia: null,
|
|
21
|
+
MildHyperglycemia: null,
|
|
22
|
+
Normoglycemia: null,
|
|
23
|
+
NormoglycemiaUnder5MMOL: null,
|
|
24
|
+
UnsupportedBGLevel: null,
|
|
25
|
+
};
|
|
21
26
|
function addPostponeActivityMessageUnder5MMOL(message) {
|
|
22
27
|
return `${message}${`\n`}${Messages.PostponePhysicalActivityUnder5MMOL()}`;
|
|
23
28
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { BgLevel } from "../types/enum";
|
|
2
2
|
import { IActivityParams, logbookEntry } from "../types/types";
|
|
3
|
-
import { AttentionMessage, Messages } from "./AttentionMessages";
|
|
4
3
|
export declare function getBGLevel(currentBGL: number, latestLogbookFrom6Hours: logbookEntry | null): BgLevel;
|
|
5
4
|
export declare function getReminder(bgLevel: BgLevel, carbohydrates: number, userReminder: number, activity: IActivityParams | null): number;
|
|
6
|
-
export declare function getAttentionMessage(bgLevel: BgLevel, activity: IActivityParams | null):
|
|
5
|
+
export declare function getAttentionMessage(bgLevel: BgLevel, activity: IActivityParams | null): string | null;
|
|
7
6
|
export declare function isSevereHyperglycemia(logbook?: logbookEntry | null): boolean;
|
|
8
7
|
export declare function isActivityWithin15Minutes(activity: IActivityParams | null): boolean;
|
|
9
|
-
export declare function getLimitationMessage(wasLimited: boolean, activityReduction: number | null):
|
|
8
|
+
export declare function getLimitationMessage(wasLimited: boolean, activityReduction: number | null): string | null;
|
|
@@ -9,6 +9,7 @@ const enum_1 = require("../types/enum");
|
|
|
9
9
|
const AttentionMessages_1 = require("./AttentionMessages");
|
|
10
10
|
const Constants_1 = require("./Constants");
|
|
11
11
|
const RecommendationError_1 = require("./RecommendationError");
|
|
12
|
+
const Utils_1 = require("./Utils");
|
|
12
13
|
function getBGLevel(currentBGL, latestLogbookFrom6Hours) {
|
|
13
14
|
if (currentBGL === null) {
|
|
14
15
|
return enum_1.BgLevel.BGLevelNotProvided;
|
|
@@ -65,23 +66,26 @@ function getReminder(bgLevel, carbohydrates, userReminder, activity) {
|
|
|
65
66
|
}
|
|
66
67
|
exports.getReminder = getReminder;
|
|
67
68
|
function getAttentionMessage(bgLevel, activity) {
|
|
69
|
+
const key = Utils_1.Utils.getKeyFromValue(enum_1.BgLevel, bgLevel);
|
|
70
|
+
const isAttentionMessageNull = AttentionMessages_1.AttentionMessage[key] === null;
|
|
71
|
+
const isWithin15Minutes = isActivityWithin15Minutes(activity);
|
|
68
72
|
switch (bgLevel) {
|
|
69
73
|
case enum_1.BgLevel.BGLevelNotProvided:
|
|
70
74
|
case enum_1.BgLevel.Normoglycemia:
|
|
71
75
|
case enum_1.BgLevel.MildHyperglycemia:
|
|
72
76
|
return null;
|
|
73
77
|
case enum_1.BgLevel.NormoglycemiaUnder5MMOL:
|
|
74
|
-
return
|
|
78
|
+
return isWithin15Minutes ? AttentionMessages_1.AttentionMessage.NormoglycemiaActivityUnder5MMOL() : null;
|
|
75
79
|
case enum_1.BgLevel.SevereHypoglycemia:
|
|
76
80
|
case enum_1.BgLevel.Hypoglycemia:
|
|
77
81
|
case enum_1.BgLevel.MildHypoglycemia:
|
|
78
|
-
return
|
|
79
|
-
? AttentionMessages_1.addPostponeActivityMessageUnder5MMOL(AttentionMessages_1.AttentionMessage[
|
|
80
|
-
: AttentionMessages_1.AttentionMessage[
|
|
82
|
+
return isWithin15Minutes && !isAttentionMessageNull
|
|
83
|
+
? AttentionMessages_1.addPostponeActivityMessageUnder5MMOL(AttentionMessages_1.AttentionMessage[key]())
|
|
84
|
+
: AttentionMessages_1.AttentionMessage[key]();
|
|
81
85
|
case enum_1.BgLevel.Hyperglycemia:
|
|
82
|
-
return
|
|
86
|
+
return isWithin15Minutes ? AttentionMessages_1.AttentionMessage.HyperglycemiaActivity() : null;
|
|
83
87
|
case enum_1.BgLevel.SevereHyperglycemia:
|
|
84
|
-
return
|
|
88
|
+
return isWithin15Minutes
|
|
85
89
|
? AttentionMessages_1.AttentionMessage.SevereHyperglycemiaActivity()
|
|
86
90
|
: AttentionMessages_1.AttentionMessage.SevereHyperglycemia();
|
|
87
91
|
default:
|
package/src/utils/Utils.d.ts
CHANGED
|
@@ -9,4 +9,5 @@ export declare class Utils {
|
|
|
9
9
|
static convertBKLToMGDL(value: number): number;
|
|
10
10
|
static displayedBKLValue(value: number, unit: BloodKetonesUnit): number;
|
|
11
11
|
static formatUnit: (unit: BloodGlucoseUnit | BloodKetonesUnit) => string;
|
|
12
|
+
static getKeyFromValue<T>(keys: T, value: T[keyof T]): keyof T;
|
|
12
13
|
}
|
package/src/utils/Utils.js
CHANGED
|
@@ -40,6 +40,10 @@ class Utils {
|
|
|
40
40
|
static displayedBKLValue(value, unit) {
|
|
41
41
|
return unit === types_1.BloodKetonesUnit.MMOL_L ? value : Utils.convertBKLToMGDL(value);
|
|
42
42
|
}
|
|
43
|
+
static getKeyFromValue(keys, value) {
|
|
44
|
+
const values = Object.values(keys);
|
|
45
|
+
return Object.keys(keys)[values.indexOf(value)];
|
|
46
|
+
}
|
|
43
47
|
}
|
|
44
48
|
exports.Utils = Utils;
|
|
45
49
|
Utils.formatUnit = (unit) => {
|
package/tsconfig.json
CHANGED
|
@@ -28,12 +28,13 @@
|
|
|
28
28
|
|
|
29
29
|
/* Strict Type-Checking Options */
|
|
30
30
|
//"strict": true, /* Enable all strict type-checking options. */
|
|
31
|
-
|
|
31
|
+
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
32
32
|
"strictNullChecks": true, /* Enable strict null checks. */
|
|
33
|
-
|
|
33
|
+
"strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
34
34
|
"strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
"noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
36
|
+
"alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
37
|
+
"noStrictGenericChecks": true,
|
|
37
38
|
|
|
38
39
|
/* Additional Checks */
|
|
39
40
|
"noUnusedLocals": true, /* Report errors on unused locals. */
|
|
@@ -61,7 +62,8 @@
|
|
|
61
62
|
/* Experimental Options */
|
|
62
63
|
"experimentalDecorators": true /* Enables experimental support for ES7 decorators. */,
|
|
63
64
|
"emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */,
|
|
64
|
-
"skipLibCheck": true
|
|
65
|
+
"skipLibCheck": true,
|
|
66
|
+
"noErrorTruncation": true
|
|
65
67
|
},
|
|
66
68
|
"exclude": [
|
|
67
69
|
"src/locale/CleanLanguage.ts",
|
package/App.tsx
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { Activity, BloodGlucoseUnit, BloodKetonesUnit, Languages, UserSettings } from "@hedia/types";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import RecommendationScreen from "./src/RecommendationScreen";
|
|
4
|
-
import { IActivityDisplayProps, IRecommendationParams, logbookEntry } from "./src/types/types";
|
|
5
|
-
import { RecommendationError } from "./src/utils/RecommendationError";
|
|
6
|
-
import { generateActivityProps, generateDefaultLogbook } from "./src/__tests__/utils";
|
|
7
|
-
|
|
8
|
-
interface IState {
|
|
9
|
-
params: IRecommendationParams & IActivityDisplayProps;
|
|
10
|
-
carbs: number | null;
|
|
11
|
-
injectionMethod: UserSettings.Enums.InjectionMethod;
|
|
12
|
-
activityDisplayProps: IActivityDisplayProps;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const ActivityEnum = Activity.Enums.ActivityEnum;
|
|
16
|
-
|
|
17
|
-
const { Cycling } = ActivityEnum;
|
|
18
|
-
const { Pump } = UserSettings.Enums.InjectionMethod;
|
|
19
|
-
|
|
20
|
-
export default class App extends React.Component<{}, IState> {
|
|
21
|
-
constructor(props) {
|
|
22
|
-
super(props);
|
|
23
|
-
|
|
24
|
-
const params: IState["params"] = {
|
|
25
|
-
carbohydrateRatio: 10,
|
|
26
|
-
currentBGL: 33, // in order to recommend insulin
|
|
27
|
-
carbohydrates: 1, // in order not to have entered carbs = 0
|
|
28
|
-
insulinSensitivity: 4,
|
|
29
|
-
targetBGL: 6,
|
|
30
|
-
recentBoluses: [
|
|
31
|
-
{
|
|
32
|
-
insulinDose: 2,
|
|
33
|
-
secondsPassed: 1000,
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
insulinDose: 1.7,
|
|
37
|
-
secondsPassed: 10000,
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
activityTitle: `Moderate Activity Test Title`,
|
|
41
|
-
activityType: Cycling,
|
|
42
|
-
activity: generateActivityProps(),
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
this.state = {
|
|
46
|
-
params,
|
|
47
|
-
carbs: 25,
|
|
48
|
-
injectionMethod: Pump,
|
|
49
|
-
activityDisplayProps: {
|
|
50
|
-
activityType: params.activityType,
|
|
51
|
-
activityTitle: params.activityTitle,
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
public exitCallback = () => {
|
|
57
|
-
console.log(`exitcallback...`);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
public closeCalculationCallback = () => {
|
|
61
|
-
console.log(`closeCalculationCallback...`);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
public removeCarbs = () => {
|
|
65
|
-
this.setState({
|
|
66
|
-
carbs: null,
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
public changeCarbs = (carbs: number) => {
|
|
71
|
-
this.setState({
|
|
72
|
-
carbs,
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
public onYes = () => {
|
|
77
|
-
console.log(`Navigate to recent bolus screen`);
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
public updatedRecommendedInsulin = (val: number) => {
|
|
81
|
-
console.log(`Updated recommended insulin: `, val);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
public transferToLogbook = (...params) => {
|
|
85
|
-
console.log(`Transfered:`, params);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
public updateRemeasureTime = (remeasureTime: number) => {
|
|
89
|
-
console.log(`updateRemeasureTime:`, remeasureTime);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
public recommendationAnswer = (carbRecommendationAnswer: boolean) => {
|
|
93
|
-
console.log("carbRecommendationAnswer", carbRecommendationAnswer);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
public showBolusBar = (showBolusBar: boolean) => {
|
|
97
|
-
console.log("showBolusBar", showBolusBar);
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
public restartCalculation = () => {
|
|
101
|
-
console.log("restart calculation");
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
public handleError = (error: RecommendationError) => {
|
|
105
|
-
console.log(JSON.stringify(error));
|
|
106
|
-
|
|
107
|
-
switch (error.type) {
|
|
108
|
-
default:
|
|
109
|
-
throw error;
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
public render(): JSX.Element {
|
|
114
|
-
const logbook1: logbookEntry = {
|
|
115
|
-
...generateDefaultLogbook(),
|
|
116
|
-
blood_glucose_millimolar: 16,
|
|
117
|
-
};
|
|
118
|
-
return (
|
|
119
|
-
<RecommendationScreen
|
|
120
|
-
latestLogbookFrom6Hours={logbook1}
|
|
121
|
-
language={Languages.en}
|
|
122
|
-
injectionMethod={this.state.injectionMethod}
|
|
123
|
-
calculatorParams={this.state.params}
|
|
124
|
-
userReminder={5}
|
|
125
|
-
bloodGlucoseUnit={BloodGlucoseUnit.MMOL_L}
|
|
126
|
-
bloodKetoneUnit={BloodKetonesUnit.MG_DL}
|
|
127
|
-
currentBKL={0}
|
|
128
|
-
closeCalculationCallback={this.closeCalculationCallback}
|
|
129
|
-
exitCallback={this.exitCallback}
|
|
130
|
-
showBolusBar={this.showBolusBar}
|
|
131
|
-
onRecentInsulinYes={this.onYes}
|
|
132
|
-
transferToLogbook={this.transferToLogbook}
|
|
133
|
-
onError={this.handleError}
|
|
134
|
-
carbRecommendationAnswer={this.recommendationAnswer}
|
|
135
|
-
restartCalculation={this.restartCalculation}
|
|
136
|
-
activityDisplayProps={this.state.activityDisplayProps}
|
|
137
|
-
/>
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
}
|
package/index.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import RecommendationScreen from "./src/RecommendationScreen";
|
|
2
|
-
import { RecommendationErrorEnum } from "./src/types/enum";
|
|
3
|
-
import * as Errors from "./src/utils/RecommendationError";
|
|
4
|
-
|
|
5
|
-
export default RecommendationScreen;
|
|
6
|
-
export { Errors, RecommendationErrorEnum };
|