fhir_questionnaire 1.0.1 copy "fhir_questionnaire: ^1.0.1" to clipboard
fhir_questionnaire: ^1.0.1 copied to clipboard

A library to render FHIR Questionnaires and generate a QuestionnaireResponse

FHIR Questionnaire #

A Flutter package for working with FHIR® Questionnaires. FHIR® is the registered trademark of HL7 and is used with the permission of HL7. Use of the FHIR trademark does not constitute endorsement of this product by HL7.

This package takes care building the UI of a FHIR R4 Questionnaire, handle behavior and validations and finally generates the QuestionnaireResponse from the user answers.

Supported Questionnaire Items #

So far this package only supports FHIR R4 Item Types

Item Supported
Group ☑️
Display
Question ☑️
Boolean
Decimal
Integer
Date
DateTime
Time
String
Text
Url
Choice
OpenChoice
Attachment
Reference ☑️
Quantity

How to use #

Just add a QuestionnaireView widget to your widget tree and you will have your Questionnaire UI.

QuestionnaireView(
    questionnaire: questionnaire, // A FHIR R4 Questionnaire instance
    onAttachmentLoaded: onAttachmentLoaded, // A callback to handle attachment loading (explained below) 
    locale: locale, // The specific locale for the Button and validation texts
    localizations: localizations, // To add support for extra localization 
    isLoading: loading, // Wether is some ongoing operation before loading the UI 
    onSubmit: onSubmit, // Callback to get the QuestionnaireResponse
)

QuestionnaireView #

  1. Questionnaire questionnaire: QuestionnaireView requires an object of type Questionnaire this is the definition of the Questionnaire and will be used to build the Form UI and generate the Questions and Answers.
  2. String? locale: Optionally you can specify the language like "es" or "en" or "fr", etc. you want to use for validation messages and Submit button, by default the system language will be used.
  3. List: this is a list allows you to add extra language translations to the Questionnaire, currently the package supports only English and Spanish, so you can add other Languages, you just need to create a class for each new Language you want to support and extend QuestionnaireBaseLocalization.
  4. QuestionnaireBaseLocalization? defaultLocalization: Indicates what should be the fallback localization if the specified language or the system language is not supported, by default English is the fallback.
  5. bool isLoading: use this to indicate there is an ongoing operation, for instance if you need to make an API request to load your Questionnaire you can set isLoading = true so the QuestionnaireView will show a Shimmer loading effect view.
  6. Future<Attachment?> Function()? onAttachmentLoaded: To make this package simpler and compatible with all Flutter supported platforms, the feature to load an attachment is delegated to the App, so you have to handle this logic by implementing this function and returning an Attachment instance according to FHIR.
  7. ValueChanged: This is the callback that will be triggered once the user taps on the Submit button, and you will get a QuestionnaireResponse instance ready, you just have to set the subject or whatever extra data you consider necessary but the answers will covered.

Some extra notes #

  1. This widget will use the app Theme to build, so if you want to change colors, InputDecorations, etc, you just have to change it in your app Theme. Also all the package widgets are public and exposed so you could override it if necessary.
  2. The QuestionnaireView implementation takes care of validations depending on each QuestionnaireItem definition.
  3. enableWhen and enableBehavior supported.
  4. Check the example project which shows all the features in action.

Demo #

2
likes
130
pub points
39%
popularity

Publisher

unverified uploader

A library to render FHIR Questionnaires and generate a QuestionnaireResponse

Repository (GitHub)
View/report issues

Topics

#fhir #questionnaire #hl7 #r4

Documentation

API reference

License

BSD-2-Clause (LICENSE)

Dependencies

collection, fhir, flutter, intl, shimmer, validators

More

Packages that depend on fhir_questionnaire