Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create Assessments and Symptoms like things with CareKit 2.0 #471

Open
umair-shams opened this issue Jul 7, 2020 · 1 comment
Open

Comments

@umair-shams
Copy link

umair-shams commented Jul 7, 2020

Hello Developers
I have questions about Carekit 2.0
I need to use Assessments and Symptoms in my app, Carekit 1.2 already have these features but later these removed in CareKit.
So I want to achieve these features with CareKit 2.0. Please tell me the solution os suggest me the way with code sample how I can achieve these goals

@umair-shams umair-shams changed the title How to create Assessments and Symptoms and insights like things with CareKit 2.0 How to create Assessments and Symptoms like things with CareKit 2.0 Jul 7, 2020
@erik-apple
Copy link
Collaborator

Hi Umair, have you taken a look at the OCKSample app we provide as part of this repo? It contains a fairly thorough example on how to create insights. If you still have any questions after going over the provided example, let us know and we'll be happy to help.

// Create a card for the nausea task if there are events for it on this day.
// Its OCKSchedule was defined to have daily events, so this task should be
// found in `tasks` every day after the task start date.
if let nauseaTask = tasks.first(where: { $0.id == "nausea" }) {
// dynamic gradient colors
let nauseaGradientStart = UIColor { traitCollection -> UIColor in
return traitCollection.userInterfaceStyle == .light ? #colorLiteral(red: 0.9960784314, green: 0.3725490196, blue: 0.368627451, alpha: 1) : #colorLiteral(red: 0.8627432641, green: 0.2630574384, blue: 0.2592858295, alpha: 1)
}
let nauseaGradientEnd = UIColor { traitCollection -> UIColor in
return traitCollection.userInterfaceStyle == .light ? #colorLiteral(red: 0.9960784314, green: 0.4732026144, blue: 0.368627451, alpha: 1) : #colorLiteral(red: 0.8627432641, green: 0.3598620686, blue: 0.2592858295, alpha: 1)
}
// Create a plot comparing nausea to medication adherence.
let nauseaDataSeries = OCKDataSeriesConfiguration(
taskID: "nausea",
legendTitle: "Nausea",
gradientStartColor: nauseaGradientStart,
gradientEndColor: nauseaGradientEnd,
markerSize: 10,
eventAggregator: OCKEventAggregator.countOutcomeValues)
let doxylamineDataSeries = OCKDataSeriesConfiguration(
taskID: "doxylamine",
legendTitle: "Doxylamine",
gradientStartColor: .systemGray2,
gradientEndColor: .systemGray,
markerSize: 10,
eventAggregator: OCKEventAggregator.countOutcomeValues)
let insightsCard = OCKCartesianChartViewController(
plotType: .bar,
selectedDate: date,
configurations: [nauseaDataSeries, doxylamineDataSeries],
storeManager: self.storeManager)
insightsCard.chartView.headerView.titleLabel.text = "Nausea & Doxylamine Intake"
insightsCard.chartView.headerView.detailLabel.text = "This Week"
insightsCard.chartView.headerView.accessibilityLabel = "Nausea & Doxylamine Intake, This Week"
listViewController.appendViewController(insightsCard, animated: false)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants