Skip to content

StanfordSpezi/SpeziQuestionnaire

Repository files navigation

Spezi Questionnaire

Build and Test codecov DOI

Enables apps to display and collect responses from HL7® FHIR® questionnaires.

Overview

The Spezi Questionnaire package enables HL7® FHIR® Questionnaires to be displayed in your Spezi application.

Questionnaires are displayed using ResearchKit and the ResearchKitOnFHIR package.

Screenshot showing a Questionnaire rendered using the Spezi Questionnaire module. Screenshot showing a Questionnaire rendered using the Spezi Questionnaire module.
An HL7® FHIR® Questionnaire is rendered using the QuestionnaireView

Setup

You need to add the Spezi Questionnaire Swift package to your app in Xcode or Swift package.

Important

If your application is not yet configured to use Spezi, follow the Spezi setup article and set up the core Spezi infrastructure.

Example

In the following example, we create a SwiftUI view with a button that displays a sample questionnaire from the FHIRQuestionnaires package using QuestionnaireView.

import FHIRQuestionnaires
import SpeziQuestionnaire
import SwiftUI


struct ExampleQuestionnaireView: View {
    @State var displayQuestionnaire = false


    var body: some View {
        Button("Display Questionnaire") {
            displayQuestionnaire.toggle()
        }
            .sheet(isPresented: $displayQuestionnaire) {
                QuestionnaireView(
                    questionnaire: Questionnaire.gcs
                ) { result in
                    guard case let .completed(response) = result else {
                        return // user cancelled
                    }

                    // ... save the FHIR response to your data store
                }
            }
    }
}

For more information, please refer to the API documentation.

The Spezi Template Application

The Spezi Template Application provides a great starting point and example using the Spezi Questionnaire module.

Contributing

Contributions to this project are welcome. Please make sure to read the contribution guidelines and the contributor covenant code of conduct first.

Notices

FHIR is a registered trademark of Health Level Seven International.

License

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

Spezi Footer Spezi Footer