Testing is key when it comes to developing awesome mobile apps. Our Lead Test Engineer Tomek and Project Manager Slawek talk about Polidea's unique testing methods.
Exploring Apple’s Open-Source: ResearchKit and CareKit
When people hear Apple and open-source in one sentence, the first thought that comes to their mind is: Swift. Then, some think: Darwin or WebKit, or coremltools. I guess only few would think of ResearchKit or CareKit. Do these names even ring a bell? Ever wondered what they are? If you’re keen on exploring the open-source world of Apple, let’s take a look at these two frameworks.
Apple unveiled ResearchKit during its March event in 2015 and announced it as open-source in April. One year later, CareKit came to light. They are both BSD-licensed frameworks dedicated to developers and researchers who create software focused on medical care. Both of them are implemented in Objective C, and can be seamlessly integrated with HealthKit. While they cannot be considered highly specialized, rocket-science frameworks, they surely offer some convenient tools and solutions that could speed up and add some UI sugar to your quick, research projects.
ResearchKit — a nod to amateur researchers all over the world
ResearchKit offers a platform that literally transforms an iPhone into a tool for medical research. Researchers can use it to create apps that frequently gather data from volunteers wishing to participate in medical studies on whatever subject — for instance breast cancer, asthma, or diabetes. This framework enables the medical community to distribute actual health research through ResearchKit-enabled apps.
This is a tool tailored by Apple, which means that it’s an over-simplified, yet easy and painless solution. ResearchKit comes with several out-of-the-box modules that address the most common elements found in research studies, i.e. participant consent, surveys and active tasks.
Obtaining the participant consent is a starting point of every research. ResearchKit provides an e-consent template that covers creating the consent document
ORKConsentDocument, presenting a visual, animated sequence to help the user understand it
ORKVisualConsentStep as well as reviewing the consent
ORKConsentReviewStep. All the above steps are contained inside a task
ORKTask, which is an object presentable by the specially designed
ORKTaskViewController. Obtaining a participant’s signature crowns the whole process (note: ResearchKit does not include digital signature support). It’s as simple as that! And looks well with zero design effort:
Surveys are another example of
ORKTask composed of a series of steps, each one handling a specific question or instruction. The appearance of every step can be customized by implementing task view controller delegate methods. It might feel quite restrictive, but again, the biggest advantage of this framework is its ease of use.
Active tasks are partially controlled tests inviting users to perform activities and giving them a step-by-step instruction, while iPhone sensors are used to collect data. For example, an active task might ask the user to walk a short distance with their phone in their pocket, while the accelerometer and gyroscope data is being collected on the device to analyze gait and balance. Initial ResearchKit modules include Active Tasks to measure motor activities, fitness, cognition and voice. The research community is encouraged to contribute custom active tasks to the framework.
ResearchKit comes with one more super handy feature, which is charts. Now, this is definitely not a very comprehensive tool for tweaking complex data representation. However, if all you care about is fast graphing of some simple data, here you go: implement a couple of data source protocol methods, add a few lines of appearance adjustment and you get a neat, readable chart in the blink of an eye.
What is more, there is a whole lot of boilerplate work covered by ResearchKit related to registration and validation of users. The framework offers a module with ready to use structures that cover login and passcode verification, granting required access and permissions etc.
It’s important to note that currently ResearchKit does not define any specific data format for how the structured data is serialized (however, all the framework objects conform to the
NSSecureCoding protocol). Also, it is always up to the developer to comply with applicable law for each territory in which the app is made available.
Monitoring medical conditions with CareKit
CareKit enables users to monitor ongoing medical conditions, track medicine intake, treatment tasks and exercise, and share this data with the caregivers, family or friends. It also provides a seamless integration with HealthKit. The idea of this tool is to empower users to take an active role in their care, whether it be post-surgical recovery or meditation. CareKit-based apps are able to introduce the user’s entire treatment plan in an interactive way, providing a sense of progress.
CareKit contents can be divided into two groups of modules: the user interface part and the data management part. UI modules include the following:
- Care Card, which tracks user’s individual care plan and manages tasks that they need to perform as a part of the treatment, such as taking medicine or doing physical exercise.
- Symptom and Measurement Tracker, which evaluates the effectiveness of a treatment plan by recording symptoms, temperature or blood pressure measurements etc.
- Insights Dashboard, which combines the data from the first two modules so that a user can see the relationship between its treatment and progress.
- Connect, helping the user to communicate their health status to doctors and family members.
Two data management modules include:
- Care Plan Store, which is a database that stores the information displayed by the Care Card and Progress Card modules; it also triggers the UI updates automatically.
- Document Exporter, which enables easy sharing of data displayed by the Insights module, such as graphs and other information.
The Care Plan Store consists of activities and events. Activities have their schedule and can be one of many types, e.g. taking a medication can show as Intervention. Events are created automatically by the Care Plan Store based on the given schedule. The Care Plan Store will stop generating events once an activity reaches its previously specified deadline.
Document Exporter allows to take the data from the Care Plan Store in order to create a rich PDF. The
OCKDocumentElement protocol supports creating a document with headers and footers, texts and paragraphs, images, charts and tables. A document created this way is a user friendly summary of their progress, comprising all the data that can be seen in the Insights Dashboard module, e.g. a weekly data of the pain scores or trends and gaps in their care. Creating a document is really straightforward: all it takes is collecting an array of elements that are to be included, initialize the
OCKDocument object and give it a title. Then use the
createPDFData method, which in its completion block returns the
NSData object that you can write to file or URL and share — voila!
Of course there is a somewhat troubling matter: the security of health data, which may be exceptionally sensitive. Agreeing to share personal data is a worry in itself. Apple addressed this issue in its Best Practices document, where it highly recommends to:
- use the highest possible level of file protection, so that the files stored by your app are encrypted when the device is locked — this usually means
- use an end-to-end protection (e.g. a CMS envelope) whenever transmitting data via network.
This is a glimpse of what CareKit and ResearchKit can offer both to the user and to the developer. Is it possible to integrate them both within one project? Absolutely yes — CareKit and ResearchKit teams actually invite you to do so. How about contributing to the codebase? You are more than welcome to share your ideas and solutions built upon these open-source frameworks.
PositiveTech for the win again! No wonder that giants like Apple appreciate its value. And so do we! Check out our work section for the ultimate proof;) If you have an agenda or a project outline asking to come to life—we’re your guys! Let’s make it happen.
- MonikaSoftware Engineer