Swiftpack.co - StanfordBDHG/ResearchKitOnFHIR as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by StanfordBDHG.
StanfordBDHG/ResearchKitOnFHIR 1.1.2
HL7 FHIR Structured Data Capture with ResearchKit on iOS
⭐️ 11
🕓 3 weeks ago
iOS macOS watchOS
.package(url: "https://github.com/StanfordBDHG/ResearchKitOnFHIR.git", from: "1.1.2")

ResearchKitOnFHIR

Build and Test codecov DOI

ResearchKitOnFHIR is a framework that allows you to use FHIR Questionnaires with ResearchKit to create healthcare surveys on iOS based on the HL7 Structured Data Capture Implementation Guide

For more information, please refer to the API documentation.

Features

FHIR <-> ResearchKit Conversion

FHIR R4 QuestionnaireItemType ResearchKit Type FHIR Response Type
attachment ORKImageCaptureStep valueAttachment
boolean ORKBooleanAnswerFormat valueBoolean
choice ORKTextChoice valueCoding
date ORKDateAnswerFormat(style: ORKDateAnswerStyle.date) valueDate
dateTime ORKDateAnswerFormat(style: ORKDateAnswerStyle.dateAndTime) valueDateTime
decimal ORKNumericAnswerFormat.decimalAnswerFormat valueDecimal
display ORKInstructionStep none
group ORKFormStep none
integer ORKNumericAnswerFormat.integerAnswerFormat valueInteger
quantity ORKNumericAnswerFormat.decimalAnswerFormat(withUnit: quantityUnit) valueQuantity
string ORKTextAnswerFormat valueString
text ORKTextAnswerFormat valueString
time ORKTimeOfDayAnswerFormat valueTime

Navigation Rules

The following table describes how the FHIR enableWhen is converted to a ResearchKit ORKSkipStepNavigationRule for each supported type and operator. (The conversion is performed by constructing an ORKResultPredicate from the enableWhen expression and negating it.)

Multiple enableWhen expressions are supported, using the enableBehavior element to determine if any or all of the expressions should be applied. If enableBehavior is not defined, all expressions will be applied.

FHIR R4 QuestionnaireItemType Supported QuestionnaireItemOperators ResearchKit ORKResultPredicate
boolean =, != .predicateForBooleanQuestionResult
integer =, !=, <=, >= .predicateForNumericQuestionResult
decimal =, !=, <=, >= .predicateForNumericQuestionResult
date >, < .predicateForDateQuestionResult
coding =, != .predicateForChoiceQuestionResult

Installation

ResearchKitOnFHIR can be installed into your Xcode project using Swift Package Manager.

  1. In Xcode 14 and newer (requires Swift 5.7), go to “File” » “Add Packages...”
  2. Enter the URL to this GitHub repository, then select the ResearchKitOnFhir package to install.

Usage

The 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.

Converting from FHIR to ResearchKit

1. Instantiate an FHIR Questionnaire from JSON

let data = <FHIR JSON data>
var questionnaire: Questionnaire?
do {
    questionnaire = try JSONDecoder().decode(Questionnaire.self, from: data)
} catch {
    print("Could not decode the FHIR questionnaire": \(error)")
}

2. Create a ResearchKit Navigable Task from the FHIR Questionnaire

var task: ORKNavigableOrderedTask?
do {
    task = try ORKNavigableOrderedTask(questionnaire: questionnaire)
} catch {
    print("Error creating task: \(error)")
}

Now you can present the task as described in the ResearchKit documentation.

Converting ResearchKit Task Results to FHIR QuestionnaireResponse

In your class that implements the ORKTaskViewControllerDelegateProtocol, you can extract an FHIR QuestionnaireResponse from the task's results as shown below.

func taskViewController(
    _ taskViewController: ORKTaskViewController, 
    didFinishWith reason: ORKTaskViewControllerFinishReason, 
    error: Error?
) {
    switch reason {
    case .completed:
        let fhirResponse = taskViewController.result.fhirResponse
        // ...
    }
}

License

This project is licensed under the MIT License. See Licenses for more information.

Contributors

This project is developed as part of the Stanford University projects at Stanford. See CONTRIBUTORS.md for a full list of all ResearchKitOnFHIR contributors.

Notices

ResearchKit is a registered trademark of Apple, Inc. FHIR is a registered trademark of Health Level Seven International.

Stanford Byers Center for Biodesign Logo Stanford Byers Center for Biodesign Logo

GitHub

link
Stars: 11
Last commit: 3 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Dependencies

Release Notes

1.1.2
3 weeks ago

What's Changed

New Contributors

Full Changelog: https://github.com/StanfordBDHG/ResearchKitOnFHIR/compare/1.1.1...1.1.2

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics