-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #321 from agencyenterprise/feature/insulin
Support for Insulin Delivery samples
- Loading branch information
Showing
10 changed files
with
259 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# deleteInsulinDeliverySample | ||
|
||
Delete a insulin delivery value from HealthKit. | ||
|
||
`deleteInsulinDeliverySample` accepts an record's UUID string and a callback: | ||
|
||
Example input object: | ||
|
||
```javascript | ||
let id = "A11E708A-63A4-42DF-B1E1-F5E2F88B6CA1" | ||
``` | ||
|
||
Example usage: | ||
|
||
```javascript | ||
AppleHealthKit.deleteInsulinDeliverySample( | ||
id, | ||
(err: string, result: HealthValue) => { | ||
if (err) { | ||
console.log(err) | ||
return | ||
} | ||
// sample successfully deleted | ||
console.log(result) | ||
}, | ||
) | ||
``` | ||
|
||
Example output (1 if deleted): | ||
|
||
```json | ||
1 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# getInsulinDeliverySamples | ||
|
||
Query for insulin delivery samples. The options object is used to setup a query to retrieve relevant samples. | ||
|
||
Example input options: | ||
|
||
```javascript | ||
let options = { | ||
startDate: new Date(2021, 0, 0).toISOString(), // required | ||
endDate: new Date().toISOString(), // optional; default now | ||
ascending: false, // optional; default false | ||
limit: 10, // optional; default no limit | ||
} | ||
``` | ||
|
||
Insulin delivery samples are always in International Units. | ||
|
||
```javascript | ||
AppleHealthKit.getInsulinDeliverySamples( | ||
options, | ||
(callbackError: string, results: HealthValue[]) => { | ||
console.log(results) | ||
}, | ||
); | ||
``` | ||
|
||
Example output: | ||
|
||
```json | ||
[ | ||
{ | ||
"id": "8DE6A905-02B7-41D2-BB6E-67D1DD82DD6F", // The universally unique identifier (UUID) for this HealthKit object. | ||
"endDate": "2021-03-22T16:19:00.000-0300", | ||
"sourceId": "com.apple.Health", | ||
"sourceName": "Health", | ||
"startDate": "2021-03-22T16:19:00.000-0300", | ||
"value": 5, | ||
"metadata": { | ||
"HKWasUserEntered": true, | ||
"HKInsulinDeliveryReason": 2, // Basal = 1, Bolus = 2 | ||
} | ||
} | ||
] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# saveInsulinDeliverySample | ||
|
||
Save a insulin delivery value to HealthKit. | ||
|
||
`saveInsulinDeliverySample` accepts an options object containing insulin sample data and a callback: | ||
|
||
Example input object: | ||
|
||
```javascript | ||
let input = { | ||
value: 10, // IU | ||
startDate: '2021-03-22T16:19:00.000-0300', // Optional, defaults to now | ||
endDate: '2021-03-22T16:19:00.000-0300', // Optional, defaults to startDate | ||
metadata: { | ||
HKBloodGlucoseMealTime: 1, //Basal = 1, Bolus = 2 | ||
anyOtherKey: 'some data', // supports string, number, boolean | ||
} | ||
} | ||
``` | ||
|
||
Insulin delivery samples are always in International Units. | ||
|
||
Example usage: | ||
|
||
```javascript | ||
AppleHealthKit.saveInsulinDeliverySample( | ||
input, | ||
(err: Object, result: string) => { | ||
if (err) { | ||
return | ||
} | ||
// insulin delivery successfully saved | ||
console.log(result) | ||
}, | ||
) | ||
``` | ||
|
||
Example output (record's UUID): | ||
|
||
```json | ||
"619E37D3-C675-4186-B6A4-395EBFC6F46D" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters