[ Music ]
[ Applause ]
Good afternoon everyone.
Welcome to the session Getting Started with CareKit.
I'm Umer. I'm an engineer on the CareKit Team.
Our agenda will consist of exploring the story of CareKit and how it came about.
Taking a look at an app that utilizes CareKit to enhance the patient-provider experience.
Working through the CareKit architecture in order to create an app here.
Then a demo of an app that uses a customization in CareKit.
And then lastly what's next, how Apple and the developer community can work together to take it to the next level.
So before I talk about what CareKit is, let's see where it came from.
Many of you might be familiar with ResearchKit.
It's a framework that we released last year that enables providers and medical researchers to create a study that they can conduct on a large-scale using iPhones.
So if you're interested, I would recommend taking a look at the session from earlier today.
What's New in ResearchKit, hosted by Bunny Laden and Yuen Xiou [phonetic].
And the ResearchKit session from last year, hosted by John Roll [phonetic], Building Apps with ResearchKit.
In the past year with ResearchKit, we received a lot of requests on study participants, to be able to see the data that they were providing for medical research.
This led us to brainstorm patient-centric modules.
While brainstorming these modules, these are the use case for care, expanding beyond the boundaries of medical research.
And therefore from ResearchKit evolved our new framework, CareKit.
So CareKit is an open source framework that enables providers to build apps that can empower patients to take an active role in their care.
Now CareKit is great for chronic and acute use cases.
So a great example for a chronic use case is mental health.
Where medication tracking is critical.
Also doing assessments like depression and anxiety surveys to see your progress and performing activities that actually improve your mental health.
Just stuff that you need to do outside of a group a support group or therapy session.
And then another good example is surgery where one of the most critical parts is the recovery phase, post-surgery.
So let's focus on this use case, and walk through the current scenario of the patient and provider experience.
So currently, if you leave the hospital or a doctor's office, you're given a sheet of paper that looks like this.
This has everything you need to do for a healthy recovery.
This sheet of paper has some very specific instructions, with many that change over time.
The compliance to these types of plans is horrible.
And they typically lead to user confusion.
These plans are not dynamic, and therefore they don't change based on the user's improvement.
And ultimately the patient returns to the hospital to be retreated.
Our goal with CareKit was to solve this problem and take something like this sheet of paper, and turn it into what we call a Care Card.
Now this is a Care Card that allows the patient to see their entire treatment plan.
One that is interactive, updated dynamically, and it provides a great sense of progress for the patient.
So in the development of this module we discovered that there's so much more we can do because now we're on an iPhone.
And that let us create three other modules to help with the patient care experience.
The Symptom and Measurement Tracker, which records subjective and objective measurements.
The insides dashboard, that displays the data in the app in a way that enables a patient to see trends and gaps in their care.
And the connect module that enables communicating and sharing the data with a family member or your care team.
So let's see how these come together to enhance the patient-provider experience.
Texas Medical Center was one of our initial partners of CareKit.
They've taken these modules to create a unique patient-provider experience.
So let's take a look at these modules in action.
At first, you are greeted with a walk-in screen that allows you to create an account or log in.
Our patient, John Appleseed, has already registered and is set up to use the app.
So John wakes up and receives a notification that he needs to weigh himself.
He enters the app with a secure passcode and then he weighs himself on a smart scale and the value is transferred into HealthKit.
And the CareKit app will autopopulate the data using HealthKit.
This is very easy to do with CareKit, because CareKit provides seamless integration with HealthKit.
After recording his weight, John goes to his Care Card to see what he needs to do on his what's on his to-do list today.
So the Care Card and the Symptom and Measurement Tracker we're looking at, is populating its content directly from the ERM Health System at Texas Medical Center.
So John doesn't recall the specifics for one of his activities, the short walk.
So he can tap into that cell, and he can read the instructions for this activity.
And then John completes his activity, and takes his first dose of medication.
He now taps into the Assessments Tab to see what assessments he needs to complete today.
In his Symptom and Measurement Tracker, he wants to indicate that he has some surgical side pain, and some signs of what could be an infection.
So first he records his pain score, using the scale assessment.
And then he decides to take a photo of the infected area, and upload it to the app.
And he can do that directly from the Symptom and Measurement Tracker, and this data is transmitted to his provider.
Lastly, he performs a get-up-and-go activity.
As he is walking around to complete this activity, the sensors on the iPhone are being used to record his steps.
And once he has completed the entire activity, the data is transmitted directly to his provider.
So John decides to take a look at the Insights Dashboard now to see his data for the last couple weeks.
He can see the tips and charts for the current week.
This provides a way for him to understand his data in a visual and user-friendly way.
And then he also navigates to the previous week, to be able to compare his current week's performance.
Meanwhile, he is still worried about the possible infection that he reported earlier in the assessments.
So he decides to send a message to his care team member.
He taps to compose a message, and he decides to email his provider, Dr. Paul Cashman.
In his message, he does not need to upload the infection photo anymore because it's already been transmitted to Dr. Cashman through the infection assessment.
So then later in the day, he receives a reply message from his care team member, Dr. Paul Cashman.
And he can go back into his app and see the message that the provider has provided to him.
And that's how Texas Medical Center has taken the CareKit module, and created an app that can completely close the loop with the patient-provider experience.
[ Applause ]
Thanks. Let's take a look at the process of creating an app just like them.
Here are the four front-end modules that we've already looked at.
Accompanied by two back-end modules: The Care Plan Store and the Document Exporter.
Now we'll go into each one of these, but let's first focus on the Care Plan Store.
The Care Plan Store consists of activities and events.
So let's begin by defining what activities and events are, then creating an activity and adding it to the store, exploring the relationship between activities and events, and then bringing these up to the UI.
So if you look at this Care Card here, we can visualize what an activity and an event is.
Let's focus on the ibuprofen.
Where Ibuprofen 200 mg is the activity.
And the circles underneath are the events.
And then activities and events come together to create the Care Plan Store.
So here's an activity.
Let's go ahead and create an ibuprofen one.
You'll first give an identifier, which we've used ibuprofen medication here.
This helps uniquely identify this activity in the Care Plan Store.
Then a group identifier to be able to create groups of certain activities that you can query the backend store later on.
The title is Ibuprofen.
The text is 200 mg.
Now these properties surface to the user.
So be sure they properly define what the activity is.
The tint color, which can be any UI color, so we chose blue.
Apart from the tint color on each activity, there are many other customization properties that are available in CareKit and we'll discuss them in a little bit.
Now the two properties I really want to focus on are type and schedule.
So the type determines which front-end module this activity belongs to.
So for example, we have an intervention, which belong on the Care Card.
And we have assessments, which are shown in the Symptom and Measurement Tracker.
So because we're creating a medication activity, it belongs in the Care Card.
Therefore, the activity type is intervention.
Next, I want to focus on schedule.
The schedule determines how many times, and when this activity should happen.
So there are three different ways to specify the days for the schedule.
You can use a daily schedule, a weekly schedule, or you can create your own custom schedule.
And then you can specify the frequency, to indicate how many times per day this activity should occur.
Now this sounds a little bit complicated, but it's really not.
So let's simplify it.
Let's go ahead and define a schedule for our activity.
Well here's a weekly schedule.
And we'll say we want the patient to take this medication on Monday, Wednesday, and Friday.
And then we can use a frequency to specify four times on Monday, twice on Wednesday, and four times on Friday.
And then combined together it creates a schedule object for this activity.
And now we have a complete activity ready to be added to the Care Plan Store.
So before we look at the code on how to create the Care Plan Store and add this activity in there, let's just discuss what an event is really quickly.
So an event is an object that a developer never directly initializes.
In fact, it's created automatically by the Care Plan Store.
So to understand how these are created, let's go back to the schedule object we just had.
A schedule object generates events based on the frequency you specify.
So for example, here, we have four events on Monday.
Therefore, we've got four events for June 20th.
And then we have two events on Wednesday, so you've got two for June 22nd.
And then it'll keep on generating them.
So the way you can stop the generation of these events, is by specifying an end date.
Once you specify an end date for an activity, the Care Plan Store will stop generating these events.
So even though a developer doesn't create an event, it provides a lot of useful information.
From an event object you can retrieve the date of the event.
You can see what state it is in, such as an initial state, which means the user hasn't invoked it.
It could be completed or not completed.
The results object contains the completion status of it.
As things such as when it was completed, and any other information you want to store along with that.
And then there's also a pointer back to the activity that this event came out of.
So activities generate events in the Care Plan Store and combined together they create what we call here, a Care Plan Store.
So let's take a look at the code for this.
So now to create a Care Plan Store, it's very straight forward.
You just define a variable, which I have here myCarePlanStore of type OCKCarePlanStore.
Then you have to define a persistent directory URL.
Which in this case I've used application to documents directory.
And then you just initialize the [inaudible] URL, and you have a Care Plan Store ready to use.
So now, let's go ahead and add the ibuprofen activity that we just created.
First you will create a schedule object.
So you have a start date just specified as the beginning of this year.
And then using a weekly schedule, I can use the array for occurrences on each day to specify how many times per day.
So for example, our array starts on Sunday.
So zero on Sunday, four on Monday, and zero on Tuesday.
And then so on and so forth.
So once you have that object, you go ahead and initialize the care plan activity.
You give it the identifier, the group identifier.
All the other parameters will be defined.
There's two here that we have not discussed yet, which is instructions and image URL.
So these are shown on the detailed [inaudible] for that activities.
For example, when John Appleseed clicked on short walk, he could see additional instructions for it.
So we'll have additional instructions for ibuprofen along with an image, and we'll take a look at how this looks when we look at the Care Card.
And then to add this activity to the Care Plan Store, we just call the add method passing the activity you've created, and then use a completion handler for any error checking you would like to do.
That's how you create a Care Plan Store and that's how you add an activity to it.
Let's see how we can use the data in here to show it onto the Care Card now.
Creating the Care Plan Store and adding an activity is the tougher part.
Showing it on the Care Card is actually very simple and straightforward.
I'm going to show you the activity we just added.
Emphasize the type property here, that it's intervention.
So because you set intervention, the Care PlanS tore already knows to show it on the Care Card.
And then to actually create the Care Card, you just initialize the CareCardViewController with a carePlanStore object.
You embed it inside a NavigationController.
The reason this is necessary is because we provide some bar button items to assist with calendar navigation as well as details that we push onto the navigation stack.
And then you just present it, or we can embed it into a tab bar controller.
And with these three lines of code, you get what we have here is a Care Card.
[ Applause ]
So as you can see here, we have the ibuprofen activity along with some other ones that I've added.
And then let's look at the different components of this UI to understand what we're looking at.
So the header view shows you a glance of the current week.
You can slide left and right to navigate between weeks.
You can select a specific date to see the details for that day.
The heart completion here is automatically calculated and updated based on the information in the Care Plan Store.
So the heart and the fill color here are customizable.
You can specify a different image that might suit your use case better.
And then the fill color can be changed to match the custom image.
And we'll see an example of a Care Card that has this customization later on.
Now below the header is the treatment plan.
This shows all the interventions that the user needs to complete for that day.
So any time you add or remove an activity from the Care Plan Store, this UI gets updated automatically, with no additional work necessary from the developer.
So here's ibuprofen intervention we just added.
And if you tap on the cell, it will take you into the detail view which has the detail instructions, as well as an image of the medication so that the user does not confuse them with other pills that they might be taking.
Now let's take a look at a different intervention.
So this one here asks the user to stand and move a little.
So while this is something the user can self-report by just tapping into the cell, it can also be updated automatically using sensors on the Apple Watch.
So that brings me to the next point, is how can we update these events?
Well there's different ways.
One of which, like we said, is self-reported such as medication tracking where they can report they've taken their medication.
They can be marked completed after the user has completed a task.
Such as an active task from ResearchKit.
Or it can be updated passively using the data from device sensors such as the Apple Watch and the iPhone using HealthKit.
So that's the Care Card.
It's an interactive treatment plan that uses the Care Plan Store to schedule activities and events, and provide the user with a focused experience on their day-to-day health.
So just like the Care Card, the Symptom and Measurement Tracker also uses the Care Plan Store to record a subjective and objective measurements.
So the process of adding an assessment is very similar to how we did in the ibuprofen intervention.
So let's say that we have a pain survey that you want to create for your lower back.
The code here is nearly identical to create this, so we'll assume that it's already been added to the Care Plan Store.
Now let's take a look at how you can create a Symptom Tracker to actually show this assessment.
Just like the Care Card, you initialize the Symptom Tracker with your controller with a Care Plan Store object.
There's a delegate that you can implement, but I'll get to that shortly.
And then embed it into a navigation controller.
And then again, just present it to see something like this here.
So if we dissect this UI, the header view contains the similar navigation model as the Care Card where we can slide left and right to change weeks.
We select specific days to see details for that day.
As you're working on the assessment for that day, the ring there will be a ring that shows you your progress.
And once you've completed them, it'll turn into a checkmark to know that you have no more assessments for that day.
The color for the ring and the checkmark can be customized to suit your app.
Underneath here, you will have a list of assessments that need to be completed for the day.
Now there can be a variety of assessments so let's take a look at some of them.
Here we have a pain survey.
For this you can use the survey module in a ResearchKit to present a beautifully designed survey.
They can be an active task.
So you could launch like a tapping test, or create a custom active task using ResearchKit, such as the range of motion one.
It can be self-reported.
So you can present a view controller, just like we did in the Texas Medical Center app, where you can ask the user to take a photo of the infection and report it back.
And then it could be any data from a HealthKit or Bluetooth device.
So in the Texas Medical Center app, John jumped onto his smart scale, and it automatically updated the data and CareKit app.
So that's where the delegate comes in.
In order to present the appropriate assessment, you have to implement the Symptom Tracker delegate which provides a callback for the developer whenever the user taps on an assessment cell.
In this call back, you're given the assessment event that they want to launch.
And then you can determine which view controller to present appropriately at that point.
Once you've presented the view controller, let's say a pain survey, you have to go ahead and use the data from that and calculate a pain score, then you create a result object, which takes in a value strength, an optional unit strength, and then a user info dictionary for all the any additional information you would need.
And then you just update the Care Plan Store with this event, the result object, the state that it's entering into, and then use the completion block for any error handling.
And all that combined gives you what you see here, the Symptom and Measurement Tracker.
[ Applause ]
The Insights Dashboard can use data from the Care Plan Store to generate messages and charts.
And this allows the user to better understand the data that they're actually looking at.
So for us to make this easy for developers to create, we've created what we call insight items.
You can plug and play those into the Insight's Dashboard.
And these also can include messages such as tips or alerts.
And they can also be charts such as the grouped bar chart that we introduced in CareKit, as well as any custom charts.
So for example the charts from ResearchKit can easily be subclassed into our chart object.
So let's take a look at the insight items in this dashboard.
This is a medication adherence message item.
Message items help motivate users to complete their care by surfacing valuable information about their health.
This message item is using data from the Care Plan Store to calculate the adherence for ibuprofen for the past week.
These messages can also be generated from a remote server, and then passed into the Insights Dashboard.
So let's look at the code on how you can query the backend store.
Here you can specify start date and an end date.
So I've used the beginning of last week, Sunday, and the end of last week, Saturday, as a start and end date.
Then we can call the enumerateEvents method on the Care Plan Store, provide the activity we want to enumerate on, the dates that we want to enumerate from and to, and then in the handler we're given back all the events in the store for that activity.
And then we can enumerate through these events to check their state to determine if they've been completed or not, to calculate adherence.
So let's say we calculated the adherence now, and we want to go ahead and create a message item.
Here you will want to take the adherence you've calculated, and turn it into a user friendly message.
So that it's easier for the user to read, and actually gain insights from it.
And then you just create initialize a message item with a title, he message you would like to show, a color, nd then the message type.
For example, this one's a tip.
Next we have a group bar chart that allows you to present multi-series data in a single chart.
For example, in this chart we have pain and ibuprofen mapped together so the user can see their data in a way that allows them to visualize trends and gaps in their care.
So here I've defined a variable called barChartItem.
It's of type OCK insight ttem.
A barChartItem consists of series.
In the one we just saw there was a pain series and an ibuprofen series.
So in order to create this chart, we will define a pain series by initializing a bar series with a title.
And an array of numeric values, and then an array of string values, and the tint colors.
Now the number of items in the array are not limited by any means.
So your chart can show weekly data, monthly data, or any number of data points.
The array of numeric values is what determines a bar length on the chart.
And the array of string values shows up right next to each bar.
Oftentimes these are not the same.
For example, in the ibuprofen series, the numeric values determine the length of the bar, but they don't represent the data itself.
For example, the 1-5-4 and so on and so forth can easily be misunderstood to mean one tablet, five tablets, or four tablets.
Therefore, the value labels help the user know that their medication is adherence; 10 percent, 50 percent, and 40 percent.
So now that we have the series that we need to show, we're going to go ahead and initialize a bar chart item.
Give it a title, a text, a tint color.
And we've got two arrays for axis titles and axis subtitles that show up to the left of each bar group.
And then you can specify all the data skews you would like to show.
This could be one, two, or ten.
Now there are two optional parameters here which is the scale.
The minimum scale range and the maximum scale range.
If you don't specify these, we automatically generate it based on the data you've given us.
But if you do, then be mindful of what you specify here so that the data doesn't seem skewed.
For example, if you have data points that are going from one to ten, and you specify a scale that's from five to ten, then all the points that are below five will now be visible to the user.
And it will make the data seem out of context.
So we have a message item we've created.
And we have a chart item.
Let's go ahead and create the Insights Dashboard.
You initialize the InsightsViewController with an array of these two items.
Give it an optional header and a subtitle.
A title and a subtitle.
And then you just present it, and you get something like this.
[ Applause ]
And that's how you create an Insights Module.
So the next one is Connect.
Connect allows you to communicate and share your data with your care team and your friends and family.
So to make this easy as well, we've created what we call CareKit contacts.
And there are two types here.
We've got a care team contact, which is a physician or a nurse, or any other care team member.
And then we have a personal contact, which could be a close friend or a family member.
So if we look at the Connect Module, these show up grouped by their type.
Here we have the care team members up top.
And then down below we have the friends and family.
So let's look at the code on how we can create this.
To create a physician contact, you define a variable.
PhysicianContact of type, OCKContact.
And then you just initialize the contact object with the type, which is careTeam, the name, the relation of the patient to this contact, the tint color, and then we have phone number and message number, which are CNPhoneNumber objects for formatting purposes.
The email address is just a string, and then a monogram to be shown if there's no image, or the image to specify what the physician or the care team contact looks like.
Once you've created all your contacts, you just initialize the connect view controller with an array of all the contacts, and then you just present it.
But there's also a delegate here that you need to implement, which we'll get to in a little bit.
And before we can present this, you have to embed it in a navigation controller, because we have master and detail views for the Connect Module.
So you will get a Connect Module that looks like this with the Connect View Controller.
Now if we focus in on the contact we just created, Dr. Paul Cashman.
If we tap into the cell, it will take you into the detail view where you get a contact card for him.
In this contact card, you see all his contact information up top here, which shows you how you call him, text him.
Text message him, or send him an email.
And then down below is the ability to share and send your reports with him.
Now this is where the delegate comes into play.
The connect delegate enables sharing the data with this contact.
So for example, when the user taps the share button, this method is called.
And then you are given the contact object from which you can determine what kind of a report to generate and then you can go ahead and share that report.
Now this part is actually quite tedious.
To create the report and to share it.
So let's see what we can do to make this easier.
So to make the connect module work hand to make it easy to share data with the connect module, we've created the document exporter, which works hand-in-hand with it.
The document exporter allows you to take the data from the Care Plan Store.
And even other sources to create a rich PDF that can be shared.
And just like everything else we've done in CareKit to make this easy, we've created CareKit Document Elements.
You've got headers and footers.
We've got texts and paragraphs, images, charts, and tables.
And then combining all of these together, you can create a rich PDF that looks like this.
[ Applause ]
So as we can see in this PDF we've got an image of the patient, a user friendly summary of their progress, and now the same chart that they were looking at in their Insights Dashboard can be seen here by their provider, so that they can all see the trends and gaps in their care.
I know there's a table that neatly lays out all the subjective and objective measurements for these patients on the previous week.
So let's take a look at the code to create this.
We have a DocumentElementPparagraph, which is just text content.
This text content can also come from the Care Plan Store or a remote source.
Then we have a document element chart which basically accepts the same chart object that you created in the Insights Dashboard.
So there's no need to do any new code, or new chart generation here.
Then we have a table here which gives you an array of headers.
And an array of arrays, in which each array is a row of the data you want to show.
For example, a weekly data of the pain scores, or a weekly data of tapping tests results.
Then once you have all the different elements you want to use in the document, you initialize a document object.
Give it a title.
And then give it an array of all the elements.
And then turning this document element into a PDF is really straightforward.
You just call the createPDFData method.
Use the NSData that's returned to you in the completion block, and write it to a file URL.
So now when the user taps the share button, we can go ahead and generate the PDF using the document exporter we just created, present it to the user to preview so they know what they're about to share, and then they can tap on the share button and then bring up the share sheet to share this PDF with others in the way they want to.
And that's how the Document Exporter works hand-in-hand with the Connect Module to allow for data sharing.
[ Applause ]
So all these modules come together and form the CareKit framework.
So Patient PAL recently transformed their entire patient care experience using CareKit.
And I want to show you how they've used customization to match their user experience and they've created interventions and assessments to help their patients improve their health.
So their Care Card replaces a heart with a custom image of an exercise buddy.
Their app is focused on getting their patients to perform certain exercises throughout the day.
For example, if you focus on the hip extension exercise, the pink one down below, we will tap on the remaining circle to complete it.
But before it can be marked as completed, we have to perform this exercise.
In this exercise task, there's a nice description of the exercise along with a video that the patient can watch to make sure they're performing the exercise correctly.
What's even nicer is that they provide a way to record yourself while you're performing the exercise so that the care provider can see it as well.
When you tap the Watch Video button, it shows it embedded within the task.
And once you feel like you've understood the exercise, you can tap Get Started to start performing it.
And then there's an active task that walks you through each set and each rep.
Once you've completed the exercise, you can see under Care Completion Progress updated to reflect the change.
And now you've got a completion for that little circle down there.
So by default, we don't provide we provide detailed views for each activity on the Care Card but you can implement the delegate to provide your own as well.
So one other thing that they've customized here is that when the user taps on one of the detail views here, for example the hamstring stretch, it will go ahead and bring up a view controller that lets you send reminders for these exercises.
So there's the two that I've already done.
And then the third one, I want to say that go ahead and let's do it at 8:00 pm.
And now the app will go ahead and me a push notification to come back in and perform this exercise to complete my care.
So CareKit provides a lot of flexibility with this module, so that you can tailor them to suite your needs.
And these are some of the ones.
So that brings me to the last section, or slides What's next for CareKit?
Currently, CareKit allows you to build patient centric apps.
Next, we want to focus on building the hooks between these apps and the provider clouds and then also transmitting that information from the cloud to the care team app or portal.
This sort of infrastructure can be seen in the Texas Medical Center app as well as the Patient PAL app.
What we would like is, as you're building your CareKit apps and linking them to your cloud, you build these hooks in a way that you can contribute it back to the community.
And other people who are using similar cloud solutions can also benefit from it.
CareKit is open source.
It will become what you make of it.
[ Applause ]
So please contribute.
You can find the project on GitHub.
It's on github.com/carekit-apple/ carekit.
So here's how you can help us make CareKit even better.
Your role involves checking out the issues section on GitHub page.
You can create a new issue or you can choose an existing one, then develop the feature.
Feel free to reach out to us or the community with any questions you have during the development.
And then work with us through the code review process.
And this usually involves you, the community, and the Apple engineers.
And that's kind of where our role also begins.
Once you have facilitated with the development and review of the feature, we'll take it over and enhance the feature even more by providing accessibility.
We'll localize it for all the languages we support in CareKit.
And then we'll do QA testing for all the supported platforms.
We might ask for your help during this process as well.
And then once the feature's ready, we'll go ahead and merge it into the framework.
With CareKit we are excited to see how all of us can work together to create this new patient-provider experience.
You can find more information behind this URL.
It includes links to our website and the GitHub repository, as well as information on how to get in touch with us if you have any technical questions, or if you have a great CareKit app idea that you would like to share.
Be sure to check out these related sessions that can help you build your CareKit app.
And thanks for coming to this talk.
[ Applause ]