Skip to content

Commit

Permalink
Add mapping for HKQuantityTypeIdentifierWalkingSpeed (#44)
Browse files Browse the repository at this point in the history
# Add mapping for HKQuantityTypeIdentifierWalkingSpeed

## ♻️ Current situation & Problem
The HealthKitOnFHIR library currently does not have a mapping for
[HKQuantityTypeIdentifierWalkingSpeed](https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierwalkingspeed),
a quantity that represents the average speed of walking between the
start and end timestamps.


## ⚙️ Release Notes 
Adds a mapping for `HKQuantityTypeIdentifierWalkingSpeed`. As LOINC
codes for walking speed also include a fixed time duration over which
the average is taken (e.g. 24 hours), and this quantity does not have a
fixed time period, this quantity cannot be precisely mapped to a LOINC
code.

## 📚 Documentation
The mapping file has been updated and documentation generated
automatically.


## ✅ Testing
A unit test has been added.


### 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).
  • Loading branch information
vishnuravi authored Jul 12, 2024
1 parent 418929f commit b0cfe35
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 3 deletions.
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 85 of 87 quantity types.
- HealthKitOnFHIR supports 86 of 88 quantity types.

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

HealthKitOnFHIR supports 85 of 87 quantity types.
HealthKitOnFHIR supports 86 of 88 quantity types.

|HKQuantityType|Supported|Code|Unit|
|----|----|----|----|
Expand Down Expand Up @@ -100,3 +100,4 @@ HealthKitOnFHIR supports 85 of 87 quantity types.
|[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)|
|[WalkingSpeed](https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierWalkingSpeed)||[HKQuantityTypeIdentifierWalkingSpeed](http://developer.apple.com/documentation/healthkit)|[m/s](http://unitsofmeasure.org)|
15 changes: 15 additions & 0 deletions Sources/HealthKitOnFHIR/Resources/HKSampleMapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -2105,6 +2105,21 @@
"system": "http://unitsofmeasure.org",
"unit": "beats/minute"
}
},
"HKQuantityTypeIdentifierWalkingSpeed": {
"codings": [
{
"code": "HKQuantityTypeIdentifierWalkingSpeed",
"display": "Walking Speed",
"system": "http://developer.apple.com/documentation/healthkit"
}
],
"unit": {
"code": "m/s",
"hkunit": "m/s",
"system": "http://unitsofmeasure.org",
"unit": "m/s"
}
}
}
}
32 changes: 31 additions & 1 deletion Tests/HealthKitOnFHIRTests/HKQuantitySampleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,36 @@ class HKQuantitySampleTests: XCTestCase {
)
}

func testWalkingSpeed() throws {
let observation = try createObservationFrom(
type: HKQuantityType(.walkingSpeed),
quantity: HKQuantity(unit: HKUnit.meter().unitDivided(by: HKUnit.second()), doubleValue: 1.5)
)

XCTAssertEqual(
observation.code.coding,
[
createCoding(
code: "HKQuantityTypeIdentifierWalkingSpeed",
display: "Walking Speed",
system: .apple
)
]
)

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

func testHeartRateVariabilitySDNN() throws {
let observation = try createObservationFrom(
type: HKQuantityType(.heartRateVariabilitySDNN),
Expand Down Expand Up @@ -2408,7 +2438,7 @@ class HKQuantitySampleTests: XCTestCase {
)
)
}

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

0 comments on commit b0cfe35

Please sign in to comment.