|
| 1 | +ResearchKit Framework |
| 2 | +=========== |
| 3 | + |
| 4 | +The ResearchKit™ framework is an open source software framework that makes it easy to |
| 5 | +create apps for medical research or for other research projects. |
| 6 | + |
| 7 | +* Getting Started: [Getting Started](#gettingstarted) |
| 8 | +* Documentation: ([Programming Guide](http://researchkit.org/docs/docs/Overview/GuideOverview.html)) ([API](http://researchkit.org/docs/index.html)) |
| 9 | +* Best practices: [Best Practices](../../wiki/best_practices) |
| 10 | +* Contributing to ResearchKit: [Contributing](../../wiki/contributing) |
| 11 | +* Website and blog: ([researchkit.org](http://researchkit.org/index.html)) ([Blog](http://researchkit.org/blog.html)) |
| 12 | +* ResearchKit BSD License: [License](#license) |
| 13 | + |
| 14 | +Getting More Information |
| 15 | +======================== |
| 16 | + |
| 17 | +* Join [researchkit-users](https://lists.apple.com/mailman/listinfo/researchkit-users) for discussing uses of the ResearchKit framework and related projects. |
| 18 | +* Join [researchkit-dev](https://lists.apple.com/mailman/listinfo/researchkit-dev) for discussing ongoing work to improve and expand the framework. |
| 19 | +* Or [contact us](https://developer.apple.com/contact/researchkit/) |
| 20 | + |
| 21 | +Use cases |
| 22 | +=========== |
| 23 | + |
| 24 | +A task in the ResearchKit framework contains a set of steps to present to a |
| 25 | +user. Everything, whether it’s a survey, the consent process, or active tasks, |
| 26 | +is represented as a task that can be presented with a task view controller. |
| 27 | + |
| 28 | +Surveys |
| 29 | +------- |
| 30 | + |
| 31 | +The ResearchKit framework provides a pre-built user interface for surveys, which can be |
| 32 | +presented modally on an iPhone, iPod Touch, or iPad. [Surveys](http://researchkit.org/docs/docs/Survey/CreatingSurveys.html) |
| 33 | + |
| 34 | + |
| 35 | +Consent |
| 36 | +---------------- |
| 37 | + |
| 38 | +The ResearchKit framework provides visual consent templates that you can customize to |
| 39 | +explain the details of your research study and obtain a signature if needed. [Consent](http://researchkit.org/docs/docs/InformedConsent/InformedConsent.html) |
| 40 | + |
| 41 | + |
| 42 | +Active Tasks |
| 43 | +------------ |
| 44 | + |
| 45 | +Some studies may need data beyond survey questions or the passive data collection |
| 46 | +capabilities available through use of the HealthKit and CoreMotion APIs if you are |
| 47 | +programming for iOS. ResearchKit's active tasks invite users to perform activities |
| 48 | +under semi-controlled conditions, while iPhone sensors actively collect data. [Active Tasks](http://researchkit.org/docs/docs/ActiveTasks/ActiveTasks.html) |
| 49 | + |
| 50 | + |
| 51 | +Getting started<a name="gettingstarted"></a> |
| 52 | +=============== |
| 53 | + |
| 54 | + |
| 55 | +Requirements |
| 56 | +------------ |
| 57 | + |
| 58 | +The primary ResearchKit framework codebase supports iOS and requires Xcode 6.3 |
| 59 | +or newer. The ResearchKit framework has a Base SDK version of 8.0, meaning that apps |
| 60 | +using the ResearchKit framework can run on devices with iOS 8.0 or newer. |
| 61 | + |
| 62 | + |
| 63 | +Installation |
| 64 | +------------ |
| 65 | + |
| 66 | +The lastest stable version of ResearchKit framework can be cloned with |
| 67 | + |
| 68 | +``` |
| 69 | +git clone -b stable https://github.com/ResearchKit/ResearchKit.git |
| 70 | +``` |
| 71 | + |
| 72 | +Or, for the latest changes, use the `master` branch: |
| 73 | + |
| 74 | +``` |
| 75 | +git clone https://github.com/ResearchKit/ResearchKit.git |
| 76 | +``` |
| 77 | + |
| 78 | +Building |
| 79 | +-------- |
| 80 | + |
| 81 | +Build the ResearchKit framework by opening `ResearchKit.xcodeproj` and running the |
| 82 | +`ResearchKit` framework target. Optionally, run the unit tests too. |
| 83 | + |
| 84 | + |
| 85 | +Adding the ResearchKit framework to your App |
| 86 | +------------------------------ |
| 87 | + |
| 88 | +This walk-through shows how to embed the ResearchKit framework in your app as a |
| 89 | +dynamic framework, and present a simple task view controller. |
| 90 | + |
| 91 | +###1. Add the ResearchKit framework to Your Project |
| 92 | + |
| 93 | +To get started, drag `ResearchKit.xcodeproj` from your checkout into |
| 94 | +your iOS app project in Xcode: |
| 95 | + |
| 96 | +<center> |
| 97 | +<figure> |
| 98 | + <img src="../../wiki/AddingResearchKitXcode.png" alt="Adding the ResearchKit framework to your project" align="middle"/> |
| 99 | +</figure> |
| 100 | +</center> |
| 101 | + |
| 102 | +Then, embed the ResearchKit framework as a dynamic framework in your app, by adding |
| 103 | +it to the Embedded Binaries section of the General pane for your |
| 104 | +target as shown in the figure below. |
| 105 | + |
| 106 | +<center> |
| 107 | +<figure> |
| 108 | + <img src="../../wiki/AddedBinaries.png" width="100%" alt="Adding the ResearchKit framework to Embedded Binaries" align="middle"/> |
| 109 | + <figcaption><center>Adding the ResearchKit framework to Embedded Binaries</center></figcaption> |
| 110 | +</figure> |
| 111 | +</center> |
| 112 | + |
| 113 | +###2. Create a Step |
| 114 | + |
| 115 | +In this walk-through, we will use the ResearchKit framework to modally present a |
| 116 | +simple single-step task showing a single instruction. |
| 117 | + |
| 118 | +Create a step for your task by adding some code, perhaps in |
| 119 | +`viewDidAppear:` of an existing view controller. To keep things |
| 120 | +simple, we'll use an instruction step (`ORKInstructionStep`) and name |
| 121 | +the step `myStep`. |
| 122 | + |
| 123 | +```objc |
| 124 | +ORKInstructionStep *myStep = |
| 125 | + [[ORKInstructionStep alloc] initWithIdentifier:@"intro"]; |
| 126 | +myStep.title = @"Welcome to ResearchKit"; |
| 127 | +``` |
| 128 | +
|
| 129 | +###3. Create a Task |
| 130 | +
|
| 131 | +Use the ordered task class (`ORKOrderedTask`) to create a task that |
| 132 | +contains myStep. An ordered task is just a task where the order and |
| 133 | +selection of later steps does not depend on the results of earlier |
| 134 | +ones. Name your task `task` and initialize it with `myStep`. |
| 135 | +
|
| 136 | +```objc |
| 137 | +ORKOrderedTask *task = |
| 138 | + [[ORKOrderedTask alloc] initWithIdentifier:@"task" steps:@[myStep]]; |
| 139 | +``` |
| 140 | + |
| 141 | +###4. Present the Task |
| 142 | + |
| 143 | +Create a task view controller (`ORKTaskViewController`) and initialize |
| 144 | +it with your `task`. A task view controller manages a task and collects the |
| 145 | +results of each step. In this case, your task view |
| 146 | +controller simply displays your instruction step. |
| 147 | + |
| 148 | +```objc |
| 149 | +ORKTaskViewController *taskViewController = |
| 150 | + [[ORKTaskViewController alloc] initWithTask:task taskRunUUID:nil]; |
| 151 | +taskViewController.delegate = self; |
| 152 | +[self presentViewController:taskViewController animated:YES completion:nil]; |
| 153 | +``` |
| 154 | +
|
| 155 | +The above snippet assumes that your class implements the |
| 156 | +`ORKTaskViewControllerDelegate` protocol. This has just one required method, |
| 157 | +which you must implement in order to handle the completion of the task: |
| 158 | +
|
| 159 | +```objc |
| 160 | +- (void)taskViewController:(ORKTaskViewController *)taskViewController |
| 161 | + didFinishWithReason:(ORKTaskViewControllerFinishReason)reason |
| 162 | + error:(NSError *)error { |
| 163 | +
|
| 164 | + ORKTaskResult *taskResult = [taskViewController result]; |
| 165 | + // You could do something with the result here. |
| 166 | +
|
| 167 | + // Then, dismiss the task view controller. |
| 168 | + [self dismissViewControllerAnimated:YES completion:nil]; |
| 169 | +} |
| 170 | +``` |
| 171 | + |
| 172 | + |
| 173 | +If you now run your app, you should see your first ResearchKit framework |
| 174 | +instruction step: |
| 175 | + |
| 176 | +<center> |
| 177 | +<figure> |
| 178 | + <img src="../../wiki/HelloWorld.png" width="50%" alt="HelloWorld example screenshot" align="middle"/> |
| 179 | +</figure> |
| 180 | +</center> |
| 181 | + |
| 182 | + |
| 183 | + |
| 184 | +What else can the ResearchKit framework do? |
| 185 | +----------------------------- |
| 186 | + |
| 187 | +The ResearchKit [`ORKCatalog`](samples/ORKCatalog) sample app is a |
| 188 | +good place to start. Find the project in ResearchKit's |
| 189 | +[`samples`](samples) directory. This project includes a list of all |
| 190 | +the types of steps supported by the ResearchKit framework in one tab, and displays a |
| 191 | +browser for the results of the last completed task in the other tab. |
| 192 | + |
| 193 | + |
| 194 | + |
| 195 | +License<a name="license"></a> |
| 196 | +======= |
| 197 | + |
| 198 | +The source in the ResearchKit repository is made available under the |
| 199 | +following license unless another license is explicitly identified: |
| 200 | + |
| 201 | +``` |
| 202 | +Copyright (c) 2015, Apple Inc. All rights reserved. |
| 203 | + |
| 204 | +Redistribution and use in source and binary forms, with or without modification, |
| 205 | +are permitted provided that the following conditions are met: |
| 206 | + |
| 207 | +1. Redistributions of source code must retain the above copyright notice, this |
| 208 | +list of conditions and the following disclaimer. |
| 209 | + |
| 210 | +2. Redistributions in binary form must reproduce the above copyright notice, |
| 211 | +this list of conditions and the following disclaimer in the documentation and/or |
| 212 | +other materials provided with the distribution. |
| 213 | + |
| 214 | +3. Neither the name of the copyright holder(s) nor the names of any contributors |
| 215 | +may be used to endorse or promote products derived from this software without |
| 216 | +specific prior written permission. No license is granted to the trademarks of |
| 217 | +the copyright holders even if such marks are included in this software. |
| 218 | + |
| 219 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 220 | +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 221 | +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 222 | +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE |
| 223 | +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 224 | +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 225 | +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 226 | +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 227 | +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 228 | +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 229 | +``` |
0 commit comments