Skip to content

Commit

Permalink
Adds support for additional gait metrics (#43)
Browse files Browse the repository at this point in the history
# Adds support for additional gait metrics

## ♻️ Current situation & Problem

Two gait metrics present in HealthKit are not currently supported by
HealthKitOnFHIR:

- [Walking Asymmetry
Percentage](https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifier/3552086-walkingasymmetrypercentage)
- [Apple Walking
Steadiness](https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifier/3747016-applewalkingsteadiness)

## ⚙️ Release Notes 
Adds support for the above HK quantity types.

## 📚 Documentation
Updates the documentation to reflect the new types.

## ✅ Testing
Adds a test for each new type.

### Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md):
- [X] I agree to follow the [Code of
Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md).

---------

Co-authored-by: Paul Schmiedmayer <[email protected]>
  • Loading branch information
vishnuravi and PSchmiedmayer authored Apr 14, 2024
1 parent d6ceecf commit 418929f
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ jobs:
uses: StanfordBDHG/.github/.github/workflows/create-and-upload-coverage-report.yml@v2
with:
coveragereports: HealthKitOnFHIR.xcresult TestApp.xcresult
secrets:
token: ${{ secrets.CODECOV_TOKEN }}
4 changes: 3 additions & 1 deletion Scripts/support_table_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
ALL_QUANTITY_TYPES = [
"HKQuantityTypeIdentifierActiveEnergyBurned",
"HKQuantityTypeIdentifierAppleExerciseTime",
"HKQuantityTypeIdentifierAppleWalkingSteadiness",
"HKQuantityTypeIdentifierBasalBodyTemperature",
"HKQuantityTypeIdentifierBasalEnergyBurned",
"HKQuantityTypeIdentifierBloodAlcoholContent",
Expand Down Expand Up @@ -103,7 +104,8 @@
"HKQuantityTypeIdentifierUVExposure",
"HKQuantityTypeIdentifierVO2Max",
"HKQuantityTypeIdentifierWaistCircumference",
"HKQuantityTypeIdentifierWalkingHeartRateAverage"
"HKQuantityTypeIdentifierWalkingHeartRateAverage",
"HKQuantityTypeIdentifierWalkingAsymmetryPercentage"
]

ALL_CORRELATION_TYPES = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ SPDX-License-Identifier: MIT
- [HKClinicalType](<doc:SupportedHKClinicalTypes>)
- HealthKitOnFHIR supports 8 of 8 clinical types.
- [HKQuantityType](<doc:SupportedHKQuantityTypes>)
- HealthKitOnFHIR supports 82 of 84 quantity types.
- HealthKitOnFHIR supports 85 of 87 quantity types.

Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ SPDX-License-Identifier: MIT
-->

HealthKitOnFHIR supports 82 of 84 quantity types.
HealthKitOnFHIR supports 85 of 87 quantity types.

|HKQuantityType|Supported|Code|Unit|
|----|----|----|----|
|[ActiveEnergyBurned](https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierActiveEnergyBurned)||[41981-2](http://loinc.org/41981-2)|[kcal](http://unitsofmeasure.org)|
|[AppleExerciseTime](https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierAppleExerciseTime)||[HKQuantityTypeIdentifierAppleExerciseTime](http://developer.apple.com/documentation/healthkit)|[min](http://unitsofmeasure.org)|
|[AppleMoveTime](https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierAppleMoveTime)||[HKQuantityTypeIdentifierAppleMoveTime](http://developer.apple.com/documentation/healthkit)|[min](http://unitsofmeasure.org)|
|[AppleStandTime](https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierAppleStandTime)||[HKQuantityTypeIdentifierAppleStandTime](http://developer.apple.com/documentation/healthkit)|[min](http://unitsofmeasure.org)|
|[AppleWalkingSteadiness](https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierAppleWalkingSteadiness)||[HKQuantityTypeIdentifierAppleWalkingSteadiness](http://developer.apple.com/documentation/healthkit)|[%](http://unitsofmeasure.org)|
|[BasalBodyTemperature](https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierBasalBodyTemperature)||[HKQuantityTypeIdentifierBasalBodyTemperature](http://developer.apple.com/documentation/healthkit)|[C](http://unitsofmeasure.org)|
|[BasalEnergyBurned](https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierBasalEnergyBurned)||[HKQuantityTypeIdentifierBasalEnergyBurned](http://developer.apple.com/documentation/healthkit)|[kcal](http://unitsofmeasure.org)|
|[BloodAlcoholContent](https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierBloodAlcoholContent)||[74859-0](http://loinc.org/74859-0)|[%](http://unitsofmeasure.org)|
Expand Down Expand Up @@ -97,4 +98,5 @@ HealthKitOnFHIR supports 82 of 84 quantity types.
|[UVExposure](https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierUVExposure)||[HKQuantityTypeIdentifierUVExposure](http://developer.apple.com/documentation/healthkit)|count|
|[VO2Max](https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierVO2Max)||[HKQuantityTypeIdentifierVO2Max](http://developer.apple.com/documentation/healthkit)|[mL/kg/min](http://unitsofmeasure.org)|
|[WaistCircumference](https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierWaistCircumference)||[8280-0](http://loinc.org/8280-0)|[in](http://unitsofmeasure.org)|
|[WalkingAsymmetryPercentage](https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierWalkingAsymmetryPercentage)||[HKQuantityTypeIdentifierWalkingAsymmetryPercentage](http://developer.apple.com/documentation/healthkit)|[%](http://unitsofmeasure.org)|
|[WalkingHeartRateAverage](https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierWalkingHeartRateAverage)||[HKQuantityTypeIdentifierWalkingHeartRateAverage](http://developer.apple.com/documentation/healthkit)|[beats/minute](http://unitsofmeasure.org)|
30 changes: 30 additions & 0 deletions Sources/HealthKitOnFHIR/Resources/HKSampleMapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,21 @@
"unit": "min"
}
},
"HKQuantityTypeIdentifierAppleWalkingSteadiness": {
"codings": [
{
"code": "HKQuantityTypeIdentifierAppleWalkingSteadiness",
"display": "Apple Walking Steadiness",
"system": "http://developer.apple.com/documentation/healthkit"
}
],
"unit": {
"code": "%",
"hkunit": "%",
"system": "http://unitsofmeasure.org",
"unit": "%"
}
},
"HKQuantityTypeIdentifierBasalBodyTemperature": {
"codings": [
{
Expand Down Expand Up @@ -2061,6 +2076,21 @@
"unit": "in"
}
},
"HKQuantityTypeIdentifierWalkingAsymmetryPercentage": {
"codings": [
{
"code": "HKQuantityTypeIdentifierWalkingAsymmetryPercentage",
"display": "Walking Asymmetry Percentage",
"system": "http://developer.apple.com/documentation/healthkit"
}
],
"unit": {
"code": "%",
"hkunit": "%",
"system": "http://unitsofmeasure.org",
"unit": "%"
}
},
"HKQuantityTypeIdentifierWalkingHeartRateAverage": {
"codings": [
{
Expand Down
60 changes: 60 additions & 0 deletions Tests/HealthKitOnFHIRTests/HKQuantitySampleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1531,6 +1531,36 @@ class HKQuantitySampleTests: XCTestCase {
)
}

func testWalkingAsymmetryPercentage() throws {
let observation = try createObservationFrom(
type: HKQuantityType(.walkingAsymmetryPercentage),
quantity: HKQuantity(unit: .percent(), doubleValue: 50)
)

XCTAssertEqual(
observation.code.coding,
[
createCoding(
code: "HKQuantityTypeIdentifierWalkingAsymmetryPercentage",
display: "Walking Asymmetry Percentage",
system: .apple
)
]
)

XCTAssertEqual(
observation.value,
.quantity(
Quantity(
code: "%",
system: "http://unitsofmeasure.org".asFHIRURIPrimitive(),
unit: "%",
value: 50.asFHIRDecimalPrimitive()
)
)
)
}

func testHeartRateVariabilitySDNN() throws {
let observation = try createObservationFrom(
type: HKQuantityType(.heartRateVariabilitySDNN),
Expand Down Expand Up @@ -2349,6 +2379,36 @@ class HKQuantitySampleTests: XCTestCase {
)
}

func testAppleWalkingSteadiness() throws {
let observation = try createObservationFrom(
type: HKQuantityType(.appleWalkingSteadiness),
quantity: HKQuantity(unit: .percent(), doubleValue: 50)
)

XCTAssertEqual(
observation.code.coding,
[
createCoding(
code: "HKQuantityTypeIdentifierAppleWalkingSteadiness",
display: "Apple Walking Steadiness",
system: .apple
)
]
)

XCTAssertEqual(
observation.value,
.quantity(
Quantity(
code: "%",
system: "http://unitsofmeasure.org".asFHIRURIPrimitive(),
unit: "%",
value: 50.asFHIRDecimalPrimitive()
)
)
)
}

func testDistanceCycling() throws {
let observation = try createObservationFrom(
type: HKQuantityType(.distanceCycling),
Expand Down

0 comments on commit 418929f

Please sign in to comment.