-
Notifications
You must be signed in to change notification settings - Fork 265
Add support for Peak Flow rate #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,25 @@ | ||
# getLatestPeakFlow | ||
|
||
Get the most recent Peak Flow rate value. | ||
|
||
On success, the callback function will be provided with a `peakFlow` object containing the Peak Flow Expiratory rate `value`, and the `startDate` and `endDate` of the Peak Flow sample. _Note: startDate and endDate will be the same as samples are saved at a specific point in time._ | ||
|
||
```javascript | ||
AppleHealthKit.getLatestPeakFlow({}, (err: string, results: HealthValue) => { | ||
if (err) { | ||
console.log('error getting latest Peak Flow rate: ', err) | ||
return | ||
} | ||
console.log(results) | ||
}) | ||
``` | ||
|
||
Example output: | ||
|
||
```json | ||
{ | ||
"value": 608, | ||
"startDate": "2021-07-21T11:08:05.366+0100", | ||
"endDate": "2021-07-21T11:08:05.366+0100" | ||
} | ||
``` |
This file contains hidden or 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,58 @@ | ||
# getPeakFlowSamples | ||
|
||
Query for Peak Flow Expiratory rate samples. The options object is used to setup a query to retrieve relevant samples. | ||
|
||
Example input options: | ||
|
||
```javascript | ||
let options = { | ||
unit: 'literPerMinute', // optional; default 'literPerMinute' | ||
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 | ||
} | ||
``` | ||
|
||
Call the method: | ||
|
||
```javascript | ||
AppleHealthKit.getPeakFlowSamples( | ||
options, | ||
(err: Object, results: Array<HealthValue>) => { | ||
if (err) { | ||
return | ||
} | ||
console.log(results) | ||
}, | ||
) | ||
``` | ||
|
||
Example output: | ||
|
||
Note the first item in the sample was saved from the app using `.savePeakFlow` hence it has the _sourceId_ and _sourceName_ of the app. The others have _Apple Health_ as a _sourceId_ since they were saved in Apple Health directly. | ||
|
||
```json | ||
[{ | ||
"endDate": "2021-07-21T09:32:24.222+0100", | ||
"id": "16C5F196-AB1D-4F84-9642-7178F05849A3", | ||
"sourceId": "com.mycompany.myapp", | ||
"sourceName": "MyApp", | ||
"startDate": "2021-07-21T09:32:24.222+0100", | ||
"value": 602 | ||
}, { | ||
"endDate": "2021-07-19T15:42:00.000+0100", | ||
"id": "803E42FC-2E5B-4C4B-A5DA-4DA74D870F18", | ||
"sourceId": "com.apple.Health", | ||
"sourceName": "Health", | ||
"startDate": "2021-07-19T15:42:00.000+0100", | ||
"value": 608 | ||
}, { | ||
"endDate": "2021-07-16T15:42:00.000+0100", | ||
"id": "93421AF8-5CCE-40D5-87D1-3E26404D139B", | ||
"sourceId": "com.apple.Health", | ||
"sourceName": "Health", | ||
"startDate": "2021-07-16T15:42:00.000+0100", | ||
"value": 605 | ||
}] | ||
``` |
This file contains hidden or 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,35 @@ | ||
# savePeakFlow | ||
|
||
save a numeric Peak Flow rate value to Healthkit. | ||
|
||
`savePeakFlow` accepts an options object containing a numeric Peak Expiratory Flow rate value: | ||
|
||
Example input options: | ||
|
||
```javascript | ||
let options = { | ||
value: 608, // liter per minute | ||
unit: 'literPerMinute' // this is the only accepted unit for Peak Flow rate | ||
} | ||
``` | ||
|
||
Call the method: | ||
|
||
```javascript | ||
AppleHealthKit.savePeakFlow( | ||
(options: HealthValueOptions), | ||
(err: Object, results: number) => { | ||
if (err) { | ||
console.error(err) | ||
return | ||
} | ||
// Peak flow successfully saved | ||
}, | ||
) | ||
``` | ||
|
||
Example output: | ||
|
||
```json | ||
608 | ||
``` |
This file contains hidden or 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 |
---|---|---|
|
@@ -14,6 +14,7 @@ The following units are supported by the library | |
hour | ||
inch | ||
joule | ||
literPerMinute | ||
meter | ||
mgPerdL | ||
mile | ||
|
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.