-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/peak-flow
- Loading branch information
Showing
80 changed files
with
5,561 additions
and
2,699 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
RCTAppleHealthKit/RCTAppleHealthKit+Methods_ClinicalRecords.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
73
RCTAppleHealthKit/RCTAppleHealthKit+Methods_ClinicalRecords.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.