Skip to content

Commit

Permalink
Merge branch 'master' into feature/peak-flow
Browse files Browse the repository at this point in the history
  • Loading branch information
GGGava committed Jan 23, 2023
2 parents cf3d46b + 0b57e9d commit ba27710
Show file tree
Hide file tree
Showing 80 changed files with 5,561 additions and 2,699 deletions.
18 changes: 0 additions & 18 deletions .github/auto_assign.yml

This file was deleted.

16 changes: 16 additions & 0 deletions RCTAppleHealthKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
61232F931E303758000A5026 /* RCTAppleHealthKit+Methods_Mindfulness.m in Sources */ = {isa = PBXBuildFile; fileRef = 61232F921E303758000A5026 /* RCTAppleHealthKit+Methods_Mindfulness.m */; };
64C42D4A1D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m in Sources */ = {isa = PBXBuildFile; fileRef = 64C42D491D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m */; };
64E0E73F1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m in Sources */ = {isa = PBXBuildFile; fileRef = 64E0E73E1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m */; };
8C640F40269DF69C004CAFED /* RCTAppleHealthKit+Methods_Hearing.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C640F3F269DF69C004CAFED /* RCTAppleHealthKit+Methods_Hearing.m */; };
8C79D960268E081A00DBDC40 /* RCTAppleHealthKit+Methods_ClinicalRecords.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C79D95F268E081A00DBDC40 /* RCTAppleHealthKit+Methods_ClinicalRecords.m */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand All @@ -38,6 +40,8 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
27B60163269770030034AB4E /* RCTAppleHealthKit+Methods_Summary.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RCTAppleHealthKit+Methods_Summary.h"; sourceTree = "<group>"; };
27B60164269770850034AB4E /* RCTAppleHealthKit+Methods_Summary.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Summary.m"; sourceTree = "<group>"; };
358330DD20931B8A000F0B94 /* RCTAppleHealthKit+Methods_Workout.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RCTAppleHealthKit+Methods_Workout.h"; sourceTree = "<group>"; };
358330DE20931B8A000F0B94 /* RCTAppleHealthKit+Methods_Workout.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Workout.m"; sourceTree = "<group>"; };
3774C88D1D2092F20000B3F3 /* libRCTAppleHealthKit.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTAppleHealthKit.a; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -67,6 +71,10 @@
64C42D491D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Vitals.m"; sourceTree = "<group>"; };
64E0E73D1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RCTAppleHealthKit+Methods_Results.h"; sourceTree = "<group>"; };
64E0E73E1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Results.m"; sourceTree = "<group>"; };
8C640F3E269DF680004CAFED /* RCTAppleHealthKit+Methods_Hearing.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RCTAppleHealthKit+Methods_Hearing.h"; sourceTree = "<group>"; };
8C640F3F269DF69C004CAFED /* RCTAppleHealthKit+Methods_Hearing.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Hearing.m"; sourceTree = "<group>"; };
8C79D95E268E07DB00DBDC40 /* RCTAppleHealthKit+Methods_ClinicalRecords.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RCTAppleHealthKit+Methods_ClinicalRecords.h"; sourceTree = "<group>"; };
8C79D95F268E081A00DBDC40 /* RCTAppleHealthKit+Methods_ClinicalRecords.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_ClinicalRecords.m"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -127,6 +135,12 @@
37837E7C1DCFE270000201A0 /* RCTAppleHealthKit+Methods_Sleep.m */,
358330DD20931B8A000F0B94 /* RCTAppleHealthKit+Methods_Workout.h */,
358330DE20931B8A000F0B94 /* RCTAppleHealthKit+Methods_Workout.m */,
8C640F3E269DF680004CAFED /* RCTAppleHealthKit+Methods_Hearing.h */,
8C640F3F269DF69C004CAFED /* RCTAppleHealthKit+Methods_Hearing.m */,
27B60163269770030034AB4E /* RCTAppleHealthKit+Methods_Summary.h */,
27B60164269770850034AB4E /* RCTAppleHealthKit+Methods_Summary.m */,
8C79D95E268E07DB00DBDC40 /* RCTAppleHealthKit+Methods_ClinicalRecords.h */,
8C79D95F268E081A00DBDC40 /* RCTAppleHealthKit+Methods_ClinicalRecords.m */,
);
path = RCTAppleHealthKit;
sourceTree = "<group>";
Expand Down Expand Up @@ -190,12 +204,14 @@
files = (
3774C89B1D2095450000B3F3 /* RCTAppleHealthKit+Queries.m in Sources */,
3774C8A11D20A6B90000B3F3 /* RCTAppleHealthKit+Utils.m in Sources */,
8C640F40269DF69C004CAFED /* RCTAppleHealthKit+Methods_Hearing.m in Sources */,
37837E7D1DCFE270000201A0 /* RCTAppleHealthKit+Methods_Sleep.m in Sources */,
3774C8D41D20C6390000B3F3 /* RCTAppleHealthKit+Methods_Body.m in Sources */,
61232F931E303758000A5026 /* RCTAppleHealthKit+Methods_Mindfulness.m in Sources */,
64E0E73F1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m in Sources */,
358330DF20931B8A000F0B94 /* RCTAppleHealthKit+Methods_Workout.m in Sources */,
64C42D4A1D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m in Sources */,
8C79D960268E081A00DBDC40 /* RCTAppleHealthKit+Methods_ClinicalRecords.m in Sources */,
3774C8931D2092F20000B3F3 /* RCTAppleHealthKit.m in Sources */,
377D44F31D247D0A004E35CB /* RCTAppleHealthKit+Methods_Characteristic.m in Sources */,
4F8095C92523C39D00A84ADB /* RCTAppleHealthKit+Methods_LabTests.m in Sources */,
Expand Down
1 change: 1 addition & 0 deletions RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- (void)body_saveWeight:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;

- (void)body_getLatestBodyMassIndex:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
- (void)body_getBodyMassIndexSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
- (void)body_saveBodyMassIndex:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;

- (void)body_getLatestHeight:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
Expand Down
31 changes: 31 additions & 0 deletions RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.m
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,37 @@ - (void)body_getLatestBodyMassIndex:(NSDictionary *)input callback:(RCTResponseS
}];
}

- (void)body_getBodyMassIndexSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback
{
HKQuantityType *bmiType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierBodyMassIndex];

HKUnit *countUnit = [HKUnit countUnit];
NSUInteger limit = [RCTAppleHealthKit uintFromOptions:input key:@"limit" withDefault:HKObjectQueryNoLimit];
BOOL ascending = [RCTAppleHealthKit boolFromOptions:input key:@"ascending" withDefault:false];
NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil];
NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]];
if(startDate == nil){
callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]);
return;
}
NSPredicate * predicate = [RCTAppleHealthKit predicateForSamplesBetweenDates:startDate endDate:endDate];

[self fetchQuantitySamplesOfType:bmiType
unit:countUnit
predicate:predicate
ascending:ascending
limit:limit
completion:^(NSArray *results, NSError *error) {
if(results){
callback(@[[NSNull null], results]);
return;
} else {
callback(@[RCTJSErrorFromNSError(error)]);
return;
}
}];
}


- (void)body_saveBodyMassIndex:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback
{
Expand Down
15 changes: 15 additions & 0 deletions RCTAppleHealthKit/RCTAppleHealthKit+Methods_ClinicalRecords.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// RCTAppleHealthKit+Methods_ClinicalRecords.h
// RCTAppleHealthKit
//
// This source code is licensed under the MIT-style license found in the
// LICENSE file in the root directory of this source tree.

#import "RCTAppleHealthKit.h"

@interface RCTAppleHealthKit (Methods_ClinicalRecords)

- (void)clinicalRecords_getClinicalRecords:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
- (void)clinical_registerObserver:(NSString *)type bridge:(RCTBridge *)bridge hasListeners:(bool)hasListeners;

@end
73 changes: 73 additions & 0 deletions RCTAppleHealthKit/RCTAppleHealthKit+Methods_ClinicalRecords.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// RCTAppleHealthKit+Methods_ClinicalRecords.m
// RCTAppleHealthKit
//
// This source code is licensed under the MIT-style license found in the
// LICENSE file in the root directory of this source tree.

#import "RCTAppleHealthKit+Methods_ClinicalRecords.h"
#import "RCTAppleHealthKit+Queries.h"
#import "RCTAppleHealthKit+Utils.h"

@implementation RCTAppleHealthKit (Methods_ClinicalRecords)

- (void)clinicalRecords_getClinicalRecords:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback
{
NSString *type = [RCTAppleHealthKit stringFromOptions:input key:@"type" withDefault:nil];
if(type == nil){
callback(@[RCTMakeError(@"type is required in options", nil, nil)]);
return;
}

if (
![type isEqual:@"AllergyRecord"] &&
![type isEqual:@"ConditionRecord"] &&
![type isEqual:@"CoverageRecord"] &&
![type isEqual:@"ImmunizationRecord"] &&
![type isEqual:@"LabResultRecord"] &&
![type isEqual:@"MedicationRecord"] &&
![type isEqual:@"ProcedureRecord"] &&
![type isEqual:@"VitalSignRecord"]
) {
callback(@[RCTMakeError(@"invalid type, type must be one of 'AllergyRecord'|'ConditionRecord'|'CoverageRecord'|'ImmunizationRecord'|'LabResultRecord'|'MedicationRecord'|'ProcedureRecord'|'VitalSignRecord'", nil, nil)]);
return;
}

HKObjectType *recordType = [RCTAppleHealthKit clinicalTypeFromName:type];
if (recordType == nil) {
callback(@[RCTMakeError(@"the requested clinical record type is not available for this iOS version", nil, nil)]);
return;
}

NSUInteger limit = [RCTAppleHealthKit uintFromOptions:input key:@"limit" withDefault:HKObjectQueryNoLimit];
BOOL ascending = [RCTAppleHealthKit boolFromOptions:input key:@"ascending" withDefault:false];

NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil];
if(startDate == nil){
callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]);
return;
}

NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]];
NSPredicate * predicate = [RCTAppleHealthKit predicateForSamplesBetweenDates:startDate endDate:endDate];

[self fetchClinicalRecordsOfType:recordType predicate:predicate ascending:ascending limit:limit completion:^(NSArray *results, NSError *error) {
if(results){
callback(@[[NSNull null], results]);
return;
} else {
callback(@[RCTJSErrorFromNSError(error)]);
return;
}
}];
}

- (void)clinical_registerObserver:(NSString *)type bridge:(RCTBridge *)bridge hasListeners:(bool)hasListeners
{
HKSampleType *recordType = [RCTAppleHealthKit clinicalTypeFromName:type];
if (recordType != nil) {
[self setObserverForType:recordType type:type bridge:bridge hasListeners:hasListeners];
}
}

@end
2 changes: 2 additions & 0 deletions RCTAppleHealthKit/RCTAppleHealthKit+Methods_Dietary.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

- (void)saveWater:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
- (void)getWater:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
- (void)getWaterSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;

- (void)dietary_getEnergyConsumedSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
- (void)dietary_getProteinSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
- (void)dietary_getTotalFatSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
@end
66 changes: 66 additions & 0 deletions RCTAppleHealthKit/RCTAppleHealthKit+Methods_Dietary.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,37 @@ - (void)dietary_getEnergyConsumedSamples:(NSDictionary *)input callback:(RCTResp
}];
}

- (void)dietary_getTotalFatSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback
{
HKQuantityType *fatTotalType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryFatTotal];
HKUnit *unit = [RCTAppleHealthKit hkUnitFromOptions:input key:@"unit" withDefault:[HKUnit gramUnit]];
NSUInteger limit = [RCTAppleHealthKit uintFromOptions:input key:@"limit" withDefault:HKObjectQueryNoLimit];
BOOL ascending = [RCTAppleHealthKit boolFromOptions:input key:@"ascending" withDefault:false];
NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil];
NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]];
if(startDate == nil){
callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]);
return;
}
NSPredicate * predicate = [RCTAppleHealthKit predicateForSamplesBetweenDates:startDate endDate:endDate];

[self fetchQuantitySamplesOfType:fatTotalType
unit:unit
predicate:predicate
ascending:ascending
limit:limit
completion:^(NSArray *results, NSError *error) {
if(results){
callback(@[[NSNull null], results]);
return;
} else {
NSLog(@"An error occured while retrieving the total fat sample %@. The error was: ", error);
callback(@[RCTMakeError(@"An error occured while retrieving the total fat sample", error, nil)]);
return;
}
}];
}

- (void)dietary_getProteinSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback
{
HKQuantityType *proteinType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryProtein];
Expand Down Expand Up @@ -502,4 +533,39 @@ - (void)getWater:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback
}];
}

- (void)getWaterSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback
{
HKQuantityType *dietaryWaterType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryWater];
HKUnit *literUnit = [HKUnit literUnit];
NSUInteger limit = [RCTAppleHealthKit uintFromOptions:input key:@"limit" withDefault:HKObjectQueryNoLimit];
BOOL ascending = [RCTAppleHealthKit boolFromOptions:input key:@"ascending" withDefault:false];
NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil];
NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]];
BOOL includeManuallyAdded = [RCTAppleHealthKit boolFromOptions:input key:@"includeManuallyAdded" withDefault:true];


if(startDate == nil) {
callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]);
return;
}

NSPredicate * predicate = [RCTAppleHealthKit predicateForSamplesBetweenDates:startDate endDate:endDate];

[self fetchQuantitySamplesOfType:dietaryWaterType
unit:literUnit
predicate:predicate
ascending:ascending
limit:limit
completion:^(NSArray *results, NSError *error) {
if(results){
callback(@[[NSNull null], results]);
return;
} else {
NSLog(@"An error occured while retrieving the water sample %@. The error was: ", error);
callback(@[RCTMakeError(@"An error occured while retrieving the water sample", error, nil)]);
return;
}
}];
}

@end
6 changes: 4 additions & 2 deletions RCTAppleHealthKit/RCTAppleHealthKit+Methods_Fitness.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
- (void)fitness_getSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
- (void)fitness_getDailyStepSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
- (void)fitness_saveSteps:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
- (void)fitness_initializeStepEventObserver:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
- (void)fitness_saveWalkingRunningDistance:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
- (void)fitness_initializeStepEventObserver:(NSDictionary *)input hasListeners:(bool)hasListeners callback:(RCTResponseSenderBlock)callback;
- (void)fitness_getDistanceWalkingRunningOnDay:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
- (void)fitness_getDailyDistanceWalkingRunningSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
- (void)fitness_getDistanceSwimmingOnDay:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
Expand All @@ -26,6 +27,7 @@

- (void)fitness_setObserver:(NSDictionary *)input __deprecated;
- (void)fitness_registerObserver:(NSString *)type
bridge:(RCTBridge *)bridge;
bridge:(RCTBridge *)bridge
hasListeners:(bool)hasListeners;

@end

0 comments on commit ba27710

Please sign in to comment.