share

ENGINEERING

6min read

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.

Discover the story
of the revolutionary telecomms app

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.

image.png

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.

image.png

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:

  • have an explicit privacy policy for every CareKit app (this is also required by the App Store);
  • 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 NSFileProtectionComplete or NSFileProtectionCompleteUnlessOpen;
  • use an end-to-end protection (e.g. a CMS envelope) whenever transmitting data via network.

image.png

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.

share


MonikaSoftware Engineer

LEARN MORE

Contact us if you have any questions regarding the article or just want to chat about technology, our services, job offers and more!

POLIDEA NEWSLETTER

Sign in and expect sharp insights, recommendations, ebooks and fascinating project stories delivered to your inbox

The controller of the personal data that you are about to provide in the above form will be Polidea sp. z o.o. with its registered office in Warsaw at ul. Przeskok 2, 00-032 Warsaw, KRS number: 0000330954, tel.: 0048 795 536 436, email: hello@polidea.com (“Polidea”). We will process your personal data based on our legitimate interest and/or your consent. Providing your personal data is not obligatory, but necessary for Polidea to respond to you in relation to your question and/or request. If you gave us consent to call you on the telephone, you may revoke the consent at any time by contacting Polidea via telephone or email. You can find detailed information about the processing of your personal data in relation to the above contact form, including your rights relating to the processing, HERE.

Data controller:

The controller of your personal data is Polidea sp. z o.o. with its registered office in Warsaw at ul. Przeskok 2, 00-032 Warsaw, KRS number: 0000330954, tel.: [0048795536436], email: [hello@polidea.com] (“Polidea”)

Purpose and legal bases for processing:

 

Used abbreviations:

GDPR – Regulation (EU) 2016/679 of the European Parliament and of the Council of 27 April 2016
on the protection of natural persons with regard to the processing of personal data and on the free movement
of such data, and repealing Directive 95/46/EC (General Data Protection Regulation)

ARES – Polish Act on Rendering Electronic Services dated 18 July 2002

TL – Polish Telecommunications Law dated 16 July 2004

1)        sending to the given email address a newsletter including information on Polidea’s new projects, products, services, organised events and/or general insights from the mobile app business world |art. 6.1 a) GDPR, art. 10.2 ARES and art. 172.1 TL (upon your consent)

Personal data:name, email address

2)       statistical, analytical and reporting purposes |art. 6. 1 f) GDPR (based on legitimate interests pursued by Polidea, consisting in analysing the way our services are used and adjusting them to our clients’ needs, as well as developing new services)

Personal data:name, email address

Withdrawal of consent:

You may withdraw your consent to process your personal data at any time.

Withdrawal of the consent is possible solely in the scope of processing performed based on the consent. Polidea is authorised to process your personal data after you withdraw your consent if it has another legal basis for the processing, for the purposes covered by that legal basis.

Categories of recipients:

Your personal data may be shared with:

1)       authorised employees and/or contractors of Polidea

2)       persons or entities providing particular services to Polidea (accounting, legal, IT, marketing and advertising services) – in the scope required for those persons or entities to provide those services to Polidea

 

Retention period:

1)       For the purpose of sending newsletter to the given email address – for as long as the relevant consent is not withdrawn

2)       For statistical, analytical and reporting purposes – for as long as the relevant consent is not withdrawn

Your rights:

 

Used abbreviation:

GDPR – Regulation (EU) 2016/679 of the European Parliament and of the Council of 27 April 2016
on the protection of natural persons with regard to the processing of personal data and on the free movement
of such data, and repealing Directive 95/46/EC (General Data Protection Regulation)

According to GDPR, you have the following rights relating to the processing of your personal data, exercised by contacting Polidea via [e-mail, phone].

1)       to access to your personal data (art. 15 GDPR) by requesting sharing and/or sending a copy of all your personal data processed by Polidea

2)       to request rectification of inaccurate personal data
(art. 16 GDPR) by indicating the data requiring rectification

3)       to request erasure of your persona data (art. 17 GDPR); Polidea has the rights to refuse erasing the personal data in specific circumstances provided by law

4)       to request restriction of processing of your personal data (art. 18 GDPR) by indicating the data which should be restricted

5)       to move your personal data (art. 20 GDPR) by requesting preparation and transfer by Polidea of the personal data that you provided to Polidea to you or another controller in a structured, commonly used machine-readable format

6)       to object to processing your personal data conducted based on art. 6.1 e) or f) GDPR, on grounds relating to your particular situation (art. 21 GDPR)

7)       to lodge a complaint with a supervisory authority,
in particular in the EU member state of your habitual residence, place of work or place of the alleged infringement if you consider that the processing
of personal data relating to you infringes the GDPR
(art. 77.1 GDPR)

No obligation to provide data:

Providing your personal data is not obligatory, but necessary for Polidea to provide you the newsletter service

Refusal to provide the above data will result in inability to receive the newsletter service.

Profiling

In the process of providing the newsletter service, we make decisions in an automated way, including profiling, based on the data you provide.

 

“Profiling” means automated processing of personal data consisting of the use of your personal data to evaluate certain personal aspects relating to you, in particular to analyze or predict aspects concerning your personal preferences and interests.

 

The automated decisions are taken based on the analysis of clicked and viewed content. They affect the targeting of specific newsletter content to selected users registered to receive the newsletter service, based on the anticipated interests of the recipient.