Skip to content

Commit

Permalink
Add mapping for Time In Daylight (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
vishnuravi authored Dec 5, 2024
1 parent 87a9257 commit a1a7125
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 2 deletions.
1 change: 1 addition & 0 deletions Scripts/support_table_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"HKQuantityTypeIdentifierRestingHeartRate",
"HKQuantityTypeIdentifierStepCount",
"HKQuantityTypeIdentifierSwimmingStrokeCount",
"HKQuantityTypeIdentifierTimeInDaylight",
"HKQuantityTypeIdentifierUVExposure",
"HKQuantityTypeIdentifierVO2Max",
"HKQuantityTypeIdentifierWaistCircumference",
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 86 of 88 quantity types.
- HealthKitOnFHIR supports 87 of 89 quantity types.

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

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

|HKQuantityType|Supported|Code|Unit|
|----|----|----|----|
Expand Down Expand Up @@ -95,6 +95,7 @@ HealthKitOnFHIR supports 86 of 88 quantity types.
|[RestingHeartRate](https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierRestingHeartRate)||[40443-4](http://loinc.org/40443-4)|[beats/minute](http://unitsofmeasure.org)|
|[StepCount](https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierStepCount)||[55423-8](http://loinc.org/55423-8)|steps|
|[SwimmingStrokeCount](https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierSwimmingStrokeCount)||[HKQuantityTypeIdentifierSwimmingStrokeCount](http://developer.apple.com/documentation/healthkit)|strokes|
|[TimeInDaylight](https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierTimeInDaylight)||[HKQuantityTypeIdentifierTimeInDaylight](http://developer.apple.com/documentation/healthkit)|[min](http://unitsofmeasure.org)|
|[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)|
Expand Down
15 changes: 15 additions & 0 deletions Sources/HealthKitOnFHIR/Resources/HKSampleMapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -2029,6 +2029,21 @@
"unit": "strokes"
}
},
"HKQuantityTypeIdentifierTimeInDaylight": {
"codings": [
{
"code": "HKQuantityTypeIdentifierTimeInDaylight",
"display": "Time in Daylight",
"system": "http://developer.apple.com/documentation/healthkit"
}
],
"unit": {
"code": "min",
"hkunit": "min",
"system": "http://unitsofmeasure.org",
"unit": "min"
}
},
"HKQuantityTypeIdentifierUVExposure": {
"codings": [
{
Expand Down
31 changes: 31 additions & 0 deletions Tests/HealthKitOnFHIRTests/HKQuantitySampleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1764,6 +1764,37 @@ class HKQuantitySampleTests: XCTestCase {
)
}

@available(iOS 17.0, *)
func testTimeInDaylight() throws {
let observation = try createObservationFrom(
type: HKQuantityType(.timeInDaylight),
quantity: HKQuantity(unit: .minute(), doubleValue: 100)
)

XCTAssertEqual(
observation.code.coding,
[
createCoding(
code: "HKQuantityTypeIdentifierTimeInDaylight",
display: "Time in Daylight",
system: .apple
)
]
)

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

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

0 comments on commit a1a7125

Please sign in to comment.