{"id":18762071,"url":"https://github.com/stanfordbdhg/researchkitonfhir","last_synced_at":"2026-02-26T05:39:16.973Z","repository":{"id":59465923,"uuid":"530673273","full_name":"StanfordBDHG/ResearchKitOnFHIR","owner":"StanfordBDHG","description":"HL7 FHIR Structured Data Capture with ResearchKit on iOS","archived":false,"fork":false,"pushed_at":"2025-08-06T00:12:30.000Z","size":285,"stargazers_count":17,"open_issues_count":5,"forks_count":2,"subscribers_count":17,"default_branch":"main","last_synced_at":"2025-08-06T02:25:44.650Z","etag":null,"topics":["fhir","questionnaire","researchkit","stanford","swift","swiftui"],"latest_commit_sha":null,"homepage":"https://swiftpackageindex.com/StanfordBDHG/ResearchKitOnFHIR/documentation","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StanfordBDHG.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"custom":["Stanford Biodesign Digital Health Group.stanford.edu"]}},"created_at":"2022-08-30T13:37:30.000Z","updated_at":"2025-08-06T00:12:32.000Z","dependencies_parsed_at":"2024-02-05T15:46:45.425Z","dependency_job_id":"2d3f7f7e-7709-457a-b8cc-91136aee3c9f","html_url":"https://github.com/StanfordBDHG/ResearchKitOnFHIR","commit_stats":{"total_commits":58,"total_committers":2,"mean_commits":29.0,"dds":0.3620689655172413,"last_synced_commit":"1bc7a15760916ade4c5058fa798a871e80c2955c"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"purl":"pkg:github/StanfordBDHG/ResearchKitOnFHIR","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StanfordBDHG%2FResearchKitOnFHIR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StanfordBDHG%2FResearchKitOnFHIR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StanfordBDHG%2FResearchKitOnFHIR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StanfordBDHG%2FResearchKitOnFHIR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StanfordBDHG","download_url":"https://codeload.github.com/StanfordBDHG/ResearchKitOnFHIR/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StanfordBDHG%2FResearchKitOnFHIR/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269987131,"owners_count":24508177,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fhir","questionnaire","researchkit","stanford","swift","swiftui"],"created_at":"2024-11-07T18:19:07.201Z","updated_at":"2026-02-21T13:03:06.866Z","avatar_url":"https://github.com/StanfordBDHG.png","language":"Swift","funding_links":["Stanford Biodesign Digital Health Group.stanford.edu"],"categories":[],"sub_categories":[],"readme":"\u003c!--\n                  \nThis source file is part of the ResearchKitOnFHIR open source project\n\nSPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md)\n\nSPDX-License-Identifier: MIT\n             \n--\u003e\n\n# ResearchKitOnFHIR\n\n[![Build and Test](https://github.com/StanfordBDHG/ResearchKitOnFHIR/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/StanfordBDHG/ResearchKitOnFHIR/actions/workflows/build-and-test.yml)\n[![codecov](https://codecov.io/gh/StanfordBDHG/ResearchKitOnFHIR/branch/main/graph/badge.svg?token=A9IUX2PFCL)](https://codecov.io/gh/StanfordBDHG/ResearchKitOnFHIR)\n[![DOI](https://zenodo.org/badge/530673273.svg)](https://zenodo.org/badge/latestdoi/530673273)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FStanfordBDHG%2FResearchKitOnFHIR%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/StanfordBDHG/ResearchKitOnFHIR)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FStanfordBDHG%2FResearchKitOnFHIR%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/StanfordBDHG/ResearchKitOnFHIR)\n\nResearchKitOnFHIR is a framework that allows you to use [FHIR Questionnaires](https://www.hl7.org/fhir/questionnaire.html) with ResearchKit to create healthcare surveys on iOS based on the [HL7 Structured Data Capture Implementation Guide](http://build.fhir.org/ig/HL7/sdc/)\n\nFor more information, please refer to the [API documentation](https://swiftpackageindex.com/StanfordBDHG/ResearchKitOnFHIR/documentation).\n\n\n## Features\n\n- Converts [FHIR Questionnaires](https://www.hl7.org/fhir/questionnaire.html) into ResearchKit tasks\n- Serializes results into [FHIR QuestionnaireResponses](https://www.hl7.org/FHIR/questionnaireresponse.html)\n- Supports survey skip-logic by converting FHIR `enableWhen` conditions into ResearchKit navigation rules\n- Supports answer validation during entry\n- Supports contained [FHIR ValueSets](https://www.hl7.org/fhir/valueset.html) as answer options\n\n\n### FHIR \u003c-\u003e ResearchKit Conversion\n\n| FHIR R4 [QuestionnaireItemType](https://www.hl7.org/fhir/valueset-item-type.html) | ResearchKit Type | FHIR Response Type\n|------------------------------|-----------------------------|--------------------------|\n| [attachment](https://www.hl7.org/fhir/codesystem-item-type.html#item-type-attachment) | [ORKImageCaptureStep](http://researchkit.org/docs/Classes/ORKImageCaptureStep.html) | valueAttachment\n| [boolean](https://www.hl7.org/fhir/codesystem-item-type.html#item-type-boolean) | [ORKBooleanAnswerFormat](http://researchkit.org/docs/Classes/ORKBooleanAnswerFormat.html) | valueBoolean\n| [choice](https://www.hl7.org/fhir/codesystem-item-type.html#item-type-choice) | [ORKTextChoice](http://researchkit.org/docs/Classes/ORKTextChoice.html) | valueCoding\n| [date](https://www.hl7.org/fhir/codesystem-item-type.html#item-type-date) | [ORKDateAnswerFormat](http://researchkit.org/docs/Classes/ORKDateAnswerFormat.html)(style: [ORKDateAnswerStyle.date](http://researchkit.org/docs/Constants/ORKDateAnswerStyle.html)) | valueDate \n| [dateTime](https://www.hl7.org/fhir/codesystem-item-type.html#item-type-dateTime) | [ORKDateAnswerFormat](http://researchkit.org/docs/Classes/ORKDateAnswerFormat.html)(style: [ORKDateAnswerStyle.dateAndTime](http://researchkit.org/docs/Constants/ORKDateAnswerStyle.html)) | valueDateTime\n| [decimal](https://www.hl7.org/fhir/codesystem-item-type.html#item-type-decimal) | [ORKNumericAnswerFormat](http://researchkit.org/docs/Classes/ORKNumericAnswerFormat.html).decimalAnswerFormat | valueDecimal \n| [display](https://www.hl7.org/fhir/codesystem-item-type.html#item-type-display) | [ORKInstructionStep](http://researchkit.org/docs/Classes/ORKInstructionStep.html) | *none*\n| [group](https://www.hl7.org/fhir/codesystem-item-type.html#item-type-group) | [ORKFormStep](http://researchkit.org/docs/Classes/ORKFormStep.html) | *none*\n| [integer](https://www.hl7.org/fhir/codesystem-item-type.html#item-type-integer) | [ORKNumericAnswerFormat](http://researchkit.org/docs/Classes/ORKNumericAnswerFormat.html).integerAnswerFormat | valueInteger \n| [quantity](https://www.hl7.org/fhir/codesystem-item-type.html#item-type-quantity) | [ORKNumericAnswerFormat](http://researchkit.org/docs/Classes/ORKNumericAnswerFormat.html).decimalAnswerFormat(withUnit: quantityUnit) | valueQuantity\n| [string](https://www.hl7.org/fhir/codesystem-item-type.html#item-type-string) | [ORKTextAnswerFormat](http://researchkit.org/docs/Classes/ORKTextAnswerFormat.html) | valueString  \n| [text](https://www.hl7.org/fhir/codesystem-item-type.html#item-type-text) | [ORKTextAnswerFormat](http://researchkit.org/docs/Classes/ORKTextAnswerFormat.html) | valueString \n| [time](https://www.hl7.org/fhir/codesystem-item-type.html#item-type-time) | [ORKTimeOfDayAnswerFormat](http://researchkit.org/docs/Classes/ORKTimeOfDayAnswerFormat.html) | valueTime \n\n\n### Navigation Rules\n\nThe following table describes how the FHIR [enableWhen](https://www.hl7.org/fhir/questionnaire-definitions.html#Questionnaire.item.enableWhen) is converted to a ResearchKit [ORKSkipStepNavigationRule](http://researchkit.org/docs/Classes/ORKSkipStepNavigationRule.html) for each supported type and operator. (The conversion is performed by constructing an ORKResultPredicate from the enableWhen expression and negating it.) \n\nMultiple enableWhen expressions are supported, using the [enableBehavior](https://www.hl7.org/fhir/questionnaire-definitions.html#Questionnaire.item.enableBehavior) element to determine if any or all of the expressions should be applied. If enableBehavior is not defined, all expressions will be applied.\n\n| FHIR R4 [QuestionnaireItemType](https://www.hl7.org/fhir/valueset-item-type.html) | Supported [QuestionnaireItemOperators](https://www.hl7.org/fhir/valueset-questionnaire-enable-operator.html) | ResearchKit [ORKResultPredicate](http://researchkit.org/docs/Classes/ORKResultPredicate.html) |\n| ---------------------------- | ------------------- | ------------------------------ |\n| boolean | =, != | .predicateForBooleanQuestionResult\n| integer | =, !=, \u003c=, \u003e= | .predicateForNumericQuestionResult\n| decimal | =, !=, \u003c=, \u003e= | .predicateForNumericQuestionResult\n| date | \u003e, \u003c | .predicateForDateQuestionResult\n| coding | =, != | .predicateForChoiceQuestionResult\n\n\n## Installation\n\nResearchKitOnFHIR can be installed into your Xcode project using [Swift Package Manager](https://github.com/apple/swift-package-manager).\n\n1. In Xcode 14 and newer (requires Swift 5.7), go to “File” » “Add Packages...”\n2. Enter the URL to this GitHub repository, then select the `ResearchKitOnFhir` package to install.\n\n\n## Usage\n\nThe `Example` directory contains an Xcode project that demonstrates how to create a ResearchKit task from an FHIR Questionnaire and extract the results in the form of an FHIR QuestionnaireResponse.\n\n### Converting from FHIR to ResearchKit\n\n#### 1. Instantiate an FHIR Questionnaire from JSON\n\n```swift\nlet data = \u003cFHIR JSON data\u003e\nvar questionnaire: Questionnaire?\ndo {\n    questionnaire = try JSONDecoder().decode(Questionnaire.self, from: data)\n} catch {\n    print(\"Could not decode the FHIR questionnaire\": \\(error)\")\n}\n```\n\n#### 2. Create a ResearchKit Navigable Task from the FHIR Questionnaire\n\n```swift\nvar task: ORKNavigableOrderedTask?\ndo {\n    task = try ORKNavigableOrderedTask(questionnaire: questionnaire)\n} catch {\n    print(\"Error creating task: \\(error)\")\n}\n```\n\nNow you can present the task as described in the [ResearchKit documentation](https://github.com/StanfordBDHG/researchkit#4-present-the-task).\n\n### Converting ResearchKit Task Results to FHIR QuestionnaireResponse\n\nIn your class that implements the `ORKTaskViewControllerDelegateProtocol`, you can extract an FHIR [QuestionnaireResponse](https://www.hl7.org/FHIR/questionnaireresponse.html) from the task's results as shown below.\n\n```swift\nfunc taskViewController(\n    _ taskViewController: ORKTaskViewController, \n    didFinishWith reason: ORKTaskViewControllerFinishReason, \n    error: Error?\n) {\n    switch reason {\n    case .completed:\n        let fhirResponse = taskViewController.result.fhirResponse\n        // ...\n    }\n}\n```\n\n\n## License\n\nThis project is licensed under the MIT License. See [Licenses](https://github.com/StanfordBDHG/ResearchKitOnFHIR/tree/main/LICENSES) for more information.\n\n\n## Contributors\n\nThis project is developed as part of the Stanford University projects at Stanford.\nSee [CONTRIBUTORS.md](https://github.com/StanfordBDHG/ResearchKitOnFHIR/tree/main/CONTRIBUTORS.md) for a full list of all ResearchKitOnFHIR contributors.\n\n\n## Notices\n\nResearchKit is a registered trademark of Apple, Inc.\nFHIR is a registered trademark of Health Level Seven International.\n\n![Stanford Byers Center for Biodesign Logo](https://raw.githubusercontent.com/StanfordBDHG/.github/main/assets/biodesign-footer-light.png#gh-light-mode-only)\n![Stanford Byers Center for Biodesign Logo](https://raw.githubusercontent.com/StanfordBDHG/.github/main/assets/biodesign-footer-dark.png#gh-dark-mode-only)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstanfordbdhg%2Fresearchkitonfhir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstanfordbdhg%2Fresearchkitonfhir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstanfordbdhg%2Fresearchkitonfhir/lists"}