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

MON-5942: cumulative update of dietary #17

Merged
merged 16 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: lucaspbordignon
assignees: @ornament-health/mobiledev
---

**Describe the bug**
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: lucaspbordignon
assignees: @ornament-health/mobiledev
---

**Is your feature request related to a problem? Please describe.**
Expand Down
16 changes: 15 additions & 1 deletion RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ - (nullable HKObjectType *)getReadPermFromText:(nonnull NSString*)key {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierBodyMassIndex];
} else if ([@"LeanBodyMass" isEqualToString: key]) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierLeanBodyMass];
} else if ([@"AppleSleepingWristTemperature" isEqualToString: key] && systemVersion >= 16.0) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierAppleSleepingWristTemperature];
}

// Hearing Identifiers
Expand Down Expand Up @@ -81,6 +83,8 @@ - (nullable HKObjectType *)getReadPermFromText:(nonnull NSString*)key {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierNikeFuel];
} else if ([@"AppleExerciseTime" isEqualToString: key] && systemVersion >= 9.3) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierAppleExerciseTime];
} else if ([@"DistanceWheelchair" isEqualToString: key] && systemVersion >= 10.0) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDistanceWheelchair];
} else if ([@"AppleStandHour" isEqualToString: key]) {
return [HKObjectType quantityTypeForIdentifier:HKCategoryTypeIdentifierAppleStandHour];
} else if ([@"RunningPower" isEqualToString:key]) {
Expand Down Expand Up @@ -320,6 +324,10 @@ - (nullable HKObjectType *)getReadPermFromText:(nonnull NSString*)key {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierRespiratoryRate];
} else if ([@"OxygenSaturation" isEqualToString: key]) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierOxygenSaturation];
} else if ([@"heartRateRecoveryOneMinute" isEqualToString: key] && systemVersion >= 16.0) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierHeartRateRecoveryOneMinute];
} else if ([@"AtrialFibrillationBurden" isEqualToString: key] && systemVersion >= 16.0) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierAtrialFibrillationBurden];
}
if (@available(iOS 12.2, *)) {
if ([@"HighHeartRateEvent" isEqualToString: key]) {
Expand Down Expand Up @@ -415,13 +423,19 @@ - (nullable HKObjectType *)getReadPermFromText:(nonnull NSString*)key {
return [HKObjectType workoutType];
} else if ([@"Workout" isEqualToString: key]) {
return [HKObjectType workoutType];
}else if ([@"WorkoutRoute" isEqualToString:key]){
} else if ([@"WorkoutRoute" isEqualToString:key]){
return [HKSeriesType workoutRouteType];
}

// Lab and tests
if ([@"BloodAlcoholContent" isEqualToString: key]) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierBloodAlcoholContent];
} else if ([@"NumberOfTimesFallen" isEqualToString:key]) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierNumberOfTimesFallen];
} else if ([@"PeakExpiratoryFlowRate" isEqualToString:key]) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierPeakExpiratoryFlowRate];
} else if ([@"PeripheralPerfusionIndex" isEqualToString:key]) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierPeripheralPerfusionIndex];
}

// Activity Summary
Expand Down
204 changes: 198 additions & 6 deletions RCTAppleHealthKit/RCTAppleHealthKit.m
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,18 @@ + (BOOL)requiresMainQueueSetup
[self statistics_getStatisticDietarySugar:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryFatMonounsaturated:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDietaryFatMonounsaturated:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryFatPolyunsaturated:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDietaryFatPolyunsaturated:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryFatSaturated:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
Expand All @@ -725,18 +737,96 @@ + (BOOL)requiresMainQueueSetup
[self statistics_getStatisticDietaryCarbohydrates:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryThiamin:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDietaryThiamin:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryRiboflavin:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDietaryRiboflavin:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryNiacin:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDietaryNiacin:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryPantothenicAcid:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDietaryPantothenicAcid:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryVitaminB6:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDietaryVitaminB6:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryBiotin:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDietaryBiotin:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryVitaminB12:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDietaryVitaminB12:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryVitaminE:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDietaryVitaminE:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryVitaminK:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDietaryVitaminK:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryFolate:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDietaryFolate:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryCalcium:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDietaryCalcium:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryChloride:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDietaryChloride:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryIron:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDietaryIron:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryMagnesium:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDietaryMagnesium:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryPhosphorus:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDietaryPhosphorus:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryPotassium:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
Expand Down Expand Up @@ -767,12 +857,114 @@ + (BOOL)requiresMainQueueSetup
[self statistics_getStatisticDietaryVitaminD:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryZinc:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDietaryZinc:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryCaffeine:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDietaryCaffeine:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryChromium:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDietaryChromium:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryCopper:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDietaryCopper:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryIodine:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDietaryIodine:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryManganese:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDietaryManganese:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietaryMolybdenum:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDietaryMolybdenum:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDietarySelenium:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDietarySelenium:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticInsulinDelivery:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticInsulinDelivery:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticDistanceWheelchair:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticDistanceWheelchair:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticAppleExerciseTime:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticAppleExerciseTime:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticAppleSleepingWristTemperature:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticAppleSleepingWristTemperature:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticHeartRateRecoveryOneMinute:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticHeartRateRecoveryOneMinute:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticAtrialFibrillationBurden:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticAtrialFibrillationBurden:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticNumberOfTimesFallen:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticNumberOfTimesFallen:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticPeakExpiratoryFlowRate:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticPeakExpiratoryFlowRate:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticPeripheralPerfusionIndex:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticPeripheralPerfusionIndex:input callback:callback];
}

RCT_EXPORT_METHOD(getStatisticUvExposure:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
[self statistics_getStatisticUvExposure:input callback:callback];
}

RCT_EXPORT_METHOD(getMedianStatistic:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self _initializeHealthStore];
Expand Down Expand Up @@ -876,9 +1068,9 @@ - (void)initializeHealthKit:(NSDictionary *)input callback:(RCTResponseSenderBlo
@"SleepAnalysis",
@"InsulinDelivery"
];

NSArray *templates = @[@"healthKit:%@:new", @"healthKit:%@:failure", @"healthKit:%@:enabled", @"healthKit:%@:sample", @"healthKit:%@:setup:success", @"healthKit:%@:setup:failure"];

NSMutableArray *supportedEvents = [[NSMutableArray alloc] init];

for(NSString * type in types) {
Expand All @@ -904,7 +1096,7 @@ - (void)getModuleInfo:(NSDictionary *)input callback:(RCTResponseSenderBlock)cal

- (void)getAuthorizationStatus:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback
{

[self _initializeHealthStore];
if ([HKHealthStore isHealthDataAvailable]) {

Expand Down Expand Up @@ -977,7 +1169,7 @@ - (void)initializeBackgroundObservers:(RCTBridge *)bridge
for(NSString * type in fitnessObservers) {
[self fitness_registerObserver:type bridge:bridge hasListeners:hasListeners];
}

NSArray *clinicalObservers = @[
@"AllergyRecord",
@"ConditionRecord",
Expand All @@ -988,11 +1180,11 @@ - (void)initializeBackgroundObservers:(RCTBridge *)bridge
@"ProcedureRecord",
@"VitalSignRecord"
];

for(NSString * type in clinicalObservers) {
[self clinical_registerObserver:type bridge:bridge hasListeners:hasListeners];
}

[self results_registerObservers:bridge hasListeners:hasListeners];

NSLog(@"[HealthKit] Background observers added to the app");
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions RCTAppleHealthKit/RCTTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
// Copyright (c) 2021 Greg Wilson. All rights reserved.
//

#import "Types/RCTInterval.h"
#import "Types/RCTAggregatorType.h"
#import "Types/RCTStatisticRequest.h"
#import "RCTInterval.h"
#import "RCTAggregatorType.h"
#import "RCTStatisticRequest.h"
Loading