注意
本仓库是 StanfordBDHG 对 Apple 公司的 ResearchKit 项目 的一个分支,并增加了以下支持:
ORKOrderedTaskView
轻松与 ORKTaskViewController
交互。ResearchKit™ 框架是一个开源软件框架,可轻松创建用于医学研究或其他研究项目的应用程序。
ResearchKit 框架代码库支持 iOS,并且需要 Xcode 12.0 或更高版本。ResearchKit 框架的 Base SDK 版本为 13.0。
通过将 ResearchKit 设置为 Xcode 中的目标,然后在 Product 菜单下拉列表中选择“Build Documentation”,来查看 ResearchKit 框架文档。
按照关于 向您的应用添加软件包依赖项 的文章,使用以下存储库 URL:https://github.com/StanfordBDHG/ResearchKit
。
随附的 catalog 应用演示了 ResearchKit 中可用的不同模块。在 ResearchKit 的 samples
目录中找到该项目。
![]() |
![]() |
ResearchKit 框架为调查问卷提供了一个预构建的用户界面,可以在 iPhone 或 iPad 上以模态形式呈现。下面的示例展示了为参与者呈现一个身高问题以供回答的过程。
import ResearchKit
import ResearchKitUI
let sectionHeaderFormItem = ORKFormItem(sectionTitle: "Your question here.")
let heightQuestionFormItem = ORKFormItem(identifier: "heightQuestionFormItem1", text: nil, answerFormat: ORKAnswerFormat.heightAnswerFormat())
heightQuestionFormItem.placeholder = "Tap here"
let formStep = ORKFormStep(identifier: "HeightQuestionIdentifier", title: "Height", text: "Local system")
formStep.formItems = [sectionHeaderFormItem, heightQuestionFormItem]
return formStep
身高问题如下图所示。
![]() |
![]() |
ResearchKit 框架提供了您可以自定义的类,以解释您的研究的细节,并在需要时获得签名。使用 ResearchKit 提供的类来快速欢迎并告知参与者研究的内容。
import ResearchKit
import ResearchKitUI
// Welcome page.
let welcomeStep = ORKInstructionStep(identifier: String(describing: Identifier.consentWelcomeInstructionStep))
welcomeStep.iconImage = UIImage(systemName: "hand.wave")
welcomeStep.title = "Welcome!"
welcomeStep.detailText = "Thank you for joining our study. Tap Next to learn more before signing up."
// Before You Join page.
let beforeYouJoinStep = ORKInstructionStep(identifier: String(describing: Identifier.informedConsentInstructionStep))
beforeYouJoinStep.iconImage = UIImage(systemName: "doc.text.magnifyingglass")
beforeYouJoinStep.title = "Before You Join"
let sharingHealthDataBodyItem = ORKBodyItem(text: "The study will ask you to share some of your Health data.",
detailText: nil,
image: UIImage(systemName: "heart.fill"),
learnMoreItem: nil,
bodyItemStyle: .image)
let completingTasksBodyItem = ORKBodyItem(text: "You will be asked to complete various tasks over the duration of the study.",
detailText: nil,
image: UIImage(systemName: "checkmark.circle.fill"),
learnMoreItem: nil,
bodyItemStyle: .image)
let signatureBodyItem = ORKBodyItem(text: "Before joining, we will ask you to sign an informed consent document.",
detailText: nil,
image: UIImage(systemName: "signature"),
learnMoreItem: nil,
bodyItemStyle: .image)
let secureDataBodyItem = ORKBodyItem(text: "Your data is kept private and secure.",
detailText: nil,
image: UIImage(systemName: "lock.fill"),
learnMoreItem: nil,
bodyItemStyle: .image)
beforeYouJoinStep.bodyItems = [
sharingHealthDataBodyItem,
completingTasksBodyItem,
signatureBodyItem,
secureDataBodyItem
]
知情同意书步骤如下图所示。
![]() |
![]() |
请访问 ResearchKit 文档中的 Obtaining Consent
文章,了解更多示例,包括签名收集和 PDF 文件存储。
如果您正在为 iOS 编程,某些研究可能需要超出调查问卷或通过使用 HealthKit 和 CoreMotion API 获得的被动数据收集功能之外的数据。ResearchKit 的主动任务邀请用户在半控制条件下执行活动,而 iPhone 传感器主动收集数据。ResearchKit 主动任务不是任何类型的诊断工具或医疗设备,并且来自这些主动任务的输出不得用于诊断。开发人员和研究人员有责任遵守所有适用法律和法规,以进一步开发和使用主动任务。
使用 ResearchKit 提供的预定义任务来指导您的参与者完成特定的操作。
import ResearchKit
import ResearchKitUI
import ResearchKitActiveTask
let orderedTask = ORKOrderedTask.dBHLToneAudiometryTask(withIdentifier: "dBHLToneAudiometryTaskIdentifier",
intendedUseDescription: nil, options: [])
let taskViewController = ORKTaskViewController(task: orderedTask, taskRun: nil)
taskViewController.delegate = self
present(taskViewController, animated: true)
dBHL 音调测听任务如下图所示。
![]() |
![]() |
GitHub 是我们 ResearchKit 的主要论坛。欢迎提出关于问题、问题或想法的 issue。
本项目根据 BSD 许可的条款提供。请参阅 LICENSE 文件。