CMHealth is the easiest way to add secure, HIPAA compliant cloud data storage and user management to your ResearchKit clinical study iOS app. Built and backed by CloudMine and the CloudMine Connected Health Cloud.
CMHealth is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "CMHealth"
The SDK provides category methods on standard ResearchKit classes, allowing you
to save and fetch ORKResult
object subclasses, such as ORKTaskResult
and ORKStepResult
,
to and from the CloudMine Connected Health Cloud.
You can see the full documentation and class references on CocoaPods or GitHub.
#import <CMHealth/CMHealth.h>
// surveyResult is an instance of ORKTaskResult, or any ORKResult subclass
[surveyResult cmh_saveToStudyWithDescriptor:@"MyClinicalStudy" withCompletion:^(NSString *uploadStatus, NSError *error) {
if (nil == uploadStatus) {
// handle error
return;
}
if ([uploadStatus isEqualToString:@"created"]) {
// A new research kit result was saved
} else if ([uploadStatus isEqualToString:@"updated"]) {
// An existing research kit result was updated
}
}];
#import <CMHealth/CMHealth.h>
[ORKTaskResult cmh_fetchUserResultsForStudyWithDescriptor:@"MyClinicalStudy" withCompletion:^(NSArray *results, NSError *error) {
if (nil == results) {
// handle error
return;
}
for (ORKTaskResult *result in results) {
// use your result
}
}];
The SDK provides a user abstraction for managing your participant accounts, with straightforward methods for user authentication.
#import <CMHealth/CMHealth.h>
[[CMHUser currentUser] signUpWithEmail:email password:password andCompletion:^(NSError *error) {
if (nil != error) {
// handle error
return;
}
// The user is now signed up
}];
The SDK also provides preconfigured screens for participant authentication.
For convenience, the SDK provides preconfigured view controllers for user sign up and login. These screens can be presented modally and handle the collection and validation of user email and password. Data is returned via delegation.
#import "MyViewController.h"
#import <CMHealth/CMHealth.h>
@interface MyViewController () <CMHAuthViewDelegate>
@end
@implementation MyViewController
- (IBAction)loginButtonDidPress:(UIButton *)sender
{
CMHAuthViewController *loginViewController = [CMHAuthViewController loginViewController];
loginViewController.delegate = self;
[self presentViewController:loginViewController animated:YES completion:nil];
}
#pragma mark CMHAuthViewDelegate
- (void)authViewCancelledType:(CMHAuthType)authType
{
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)authViewOfType:(CMHAuthType)authType didSubmitWithEmail:(NSString *)email andPassword:(NSString *)password
{
[self dismissViewControllerAnimated:YES completion:nil];
switch (authType) {
case CMHAuthTypeLogin:
[self loginWithEmail:email andPassword:password];
break;
case CMHAuthTypeSignup:
[self signupWithEmail:email andPassword:password];
break;
default:
break;
}
}
#pragma mark Private
- (void)signupWithEmail:(NSString *)email andPassword:(NSString *)password
{
// Sign user up
}
- (void)loginWithEmail:(NSString *)email andPassword:(NSString *a)password
{
// Log user in
}
@end
The SDK provides specific methods for archiving and fetching participant consent.
In ResearchKit, user consent is collected in any ORKTask
with special consent and signature
steps included. CMHealth allows you to archive the resulting ORKTaskResult
object
containing the user's consent. The SDK ensures that a consent step is present in the result hierarchy and that a signature has been collected. It handles uploading the signature image seamlessly.
#import <CMHealth/CMHealth.h>
// `consentResults` is an instance of `ORKTaskResult`
[[CMHUser currentUser] uploadUserConsent:consentResults forStudyWithDescriptor:@"MyClinicalStudy" andCompletion:^(NSError * consentError) {
if (nil != error) {
// handle error
return;
}
// consent uploaded successfully
}];
To ensure your participants have a valid consent on file before allowing them to participate in study activities, you can fetch any user's consent object.
#import <CMHealth/CMHealth.h>
[[CMHUser currentUser] fetchUserConsentForStudyWithDescriptor:@"MyClinicalStudy" andCompletion:^(CMHConsent *consent, NSError *error) {
if (nil != error) {
// Something went wrong
return;
}
if (nil == consent) {
// No consent on file
return;
}
// User has valid consent on file
}];
CMHealth includes and extends the CloudMine iOS SDK, so you get all of the core CloudMine functionality for free. To go beyond the ResearchKit specific parts of CMHealth, start with the CloudMine iOS documentation.
To get a sense of how CMHealth works seamlessly with ResearchKit, you can check out the CloudMine AsthmaHealth demo application. AsthmaHealth can also serve as a starting point for your own ResearchKit enabled app.
For general CMHealth support, please email [email protected] - we are here to help!
For the more advantageous, we encourage getting directly involved via standard GitHub fork, issue tracker, and pull request pathways. See the CONTRIBUTING document to get started.
CMHealth is available under the MIT license. See the LICENSE file for more info.