Skip to content
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

[VIT-7375] Apple Health Kit: add support for nutritional data #239

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions Sources/VitalHealthKit/HealthKit/Abstractions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ extension VitalHealthKitStore {
return [.vitals(.heartRate)]

case HKSampleType.quantityType(forIdentifier: .heartRateVariabilitySDNN)!:
return [.vitals(.heartRateVariability)]
return [.meal, .vitals(.heartRateVariability)]

case HKSampleType.quantityType(forIdentifier: .dietaryWater)!:
return [.nutrition(.water)]
return [.meal, .nutrition(.water)]
ItachiEU marked this conversation as resolved.
Show resolved Hide resolved

case HKSampleType.quantityType(forIdentifier: .dietaryCaffeine)!:
return [.nutrition(.caffeine)]
Expand Down Expand Up @@ -183,9 +183,7 @@ extension VitalHealthKitStore {
HKQuantityType.quantityType(forIdentifier: .dietaryIodine)!,
HKQuantityType.quantityType(forIdentifier: .dietaryManganese)!,
HKQuantityType.quantityType(forIdentifier: .dietaryMolybdenum)!,
HKQuantityType.quantityType(forIdentifier: .dietarySelenium)!,
HKQuantityType.quantityType(forIdentifier: .dietaryWater)!,
HKQuantityType.quantityType(forIdentifier: .dietaryCaffeine)!:
HKQuantityType.quantityType(forIdentifier: .dietarySelenium)!:
return [.meal]

default:
Expand Down
8 changes: 0 additions & 8 deletions Sources/VitalHealthKit/HealthKit/HealthKitReads.swift
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,6 @@ func handleMeal(
HKQuantityType.quantityType(forIdentifier: .dietaryManganese)!,
HKQuantityType.quantityType(forIdentifier: .dietaryMolybdenum)!,
HKQuantityType.quantityType(forIdentifier: .dietarySelenium)!,
HKQuantityType.quantityType(forIdentifier: .dietaryWater)!,
HKQuantityType.quantityType(forIdentifier: .dietaryCaffeine)!
]

let sampleGroups = try await queryMulti(
Expand Down Expand Up @@ -655,12 +653,6 @@ func handleMeal(
},
selenium: groups[HKQuantityType.quantityType(forIdentifier: .dietarySelenium)!]?.map { nutrient in
LocalQuantitySample(nutrient as! HKQuantitySample, unit: QuantityUnit(.dietarySelenium))
},
water: groups[HKQuantityType.quantityType(forIdentifier: .dietaryWater)!]?.map { nutrient in
LocalQuantitySample(nutrient as! HKQuantitySample, unit: QuantityUnit(.dietaryWater))
},
caffeine: groups[HKQuantityType.quantityType(forIdentifier: .dietaryCaffeine)!]?.map { nutrient in
LocalQuantitySample(nutrient as! HKQuantitySample, unit: QuantityUnit(.dietaryCaffeine))
}
)
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,6 @@ func toHealthKitTypes(resource: VitalResource) -> HealthKitObjectTypeRequirement
HKQuantityType.quantityType(forIdentifier: .dietaryManganese)!,
HKQuantityType.quantityType(forIdentifier: .dietaryMolybdenum)!,
HKQuantityType.quantityType(forIdentifier: .dietarySelenium)!,
HKQuantityType.quantityType(forIdentifier: .dietaryWater)!,
HKQuantityType.quantityType(forIdentifier: .dietaryCaffeine)!
],
supplementary: []
)
Expand Down