FHIR SDC API

This article outlines operations from the FHIR SDC Implementation Guide.

Implementation corresponds to SDC FHIR IG - 3.0.version 0

FHIR SDC API

Aidbox Forms module supports FHIR SDC operations:

  • $populate - filling out a form with existing data (FHIR)

  • $populatelink - filling out a form with existing data, and return signed link to it (FHIR)

  • $extract - extract data from QuestionnaireResponse to other FHIR resources (FHIR)

  • $expand - create a simple collection of codes suitable for use for data entry or validation. (FHIR)

We have created an Aidbox notebook demonstrating different population and extraction methods

We have created an Aidbox notebook demonstrating different population and extraction methods:

Aidbox forms: populate & extract

Populate Questionnaire - $populate

The populate operation generates a QuestionnaireResponse based on a specific Questionnaire, filling in answers to questions where possible based on information provided as part of the operation or already known by the server about the subject of the Questionnaire.

This implementation supports the Observation based and Expression based population methods.

URLs

POST [base]/Questionnaire/$populate
POST [base]/Questionnaire/[id]/$populate

Parameters

Parameters are specified via FHIR Parameters type.

Example

resourceType: Parameters
parameter:
- name: subject
  value:
    Reference:
      id: pt-1
      resourceType: Patient

identifier

A logical questionnaire identifier (i.e. Questionnaire.identifier). The server must know the questionnaire or be able to retrieve it from other known repositories.

name: identifier
value:
  Identifier:
    system: 'forms.aidbox'
    value: 'vitals'

canonical

The canonical identifier for the questionnaire (optionally version-specific).

name: canonical
value:
  Canonical: http://forms.aidbox.io/Questionnaire/vitals

questionnaire

The Questionnaire is provided directly as part of the request. Servers may choose not to accept questionnaires in this fashion

name: questionnaire
resource:
  resourceType: Questionnaire
  id: new-form
  title: "Vitals"
  ...

questionnaireRef

The Questionnaire is provided as a resource reference. Servers may choose not to accept questionnaires in this fashion or may fail if they cannot resolve or access the referenced questionnaire.

name: questionnaireRef
value:
  Reference:
    resourceType: Questionnaire
    id: new-form

subject

The resource that is to be the QuestionnaireResponse.subject. The QuestionnaireResponse instance will reference the provided subject. In addition, if the local parameter is set to true, server information about the specified subject will be used to populate the instance.

name: subject
value:
  Reference:
    id: pt-1
    resourceType: Patient

local

If specified and set to true (and the server is capable), the server should use what resources and other knowledge it has about the referenced subject when pre-populating answers to questions.

name: local
value:
  Boolean: true

context

Resources containing information to be used to help populate the QuestionnaireResponse. These will typically be FHIR resources.

Context paramertes are presented as pairs of name and content parameters that are placed under the part key.

They should correspond launchContext parameter definitions.

name: context
part:
- name: name
  value:
    String: encounter
- name: content
  value:
    Reference:
      resourceType: Encounter
      id: enc1

FHIR SDC launchContext extension enumerates possible context variables, they are:

Additionnaly Aidbox expands this list with parameters that mirrors QuestionnaireResponse root properties.

WARN: This is non FHIR SDC compliant behavior!

Paramerters passed directly to QuestionnaireResponse root properties and should not be used in populate expressions.

Example:

name: name
value:
  Reference: 
    id: sr1
    resourceType: ServiceRequest

context.name

The name of the launchContext or root Questionnaire variable the passed content should be used as for population purposes. The name SHALL correspond to a launchContext or variable delared at the root of the Questionnaire.

name: name
value:
  String: encounter

context.content

The actual resource (or resources) to use as the value of the launchContext or variable.

name: content
value:
  Reference:
    resourceType: Encounter
    id: enc1

Or

name: content
resource:
  ...
  resourceType: Encounter
  id: enc1
  subject: 
    id: pt-1
    resourceType: Patient
  ...

launchContext

Resources that provide context for form processing logic (pre-population) when creating/displaying/editing a QuestionnaireResponse.

Response

Success response shape

Usage Example

POST [base]/Questionnaire/vitals/$populate
content-type: text/yaml

resourceType: Parameters
parameter:
- name: subject
  value:
    Reference:
      id: pt-1
      resourceType: Patient
- name: context
  part:
  - name: name
    value:
      String: encounter
  - name: content
    value:
      Reference:
        resourceType: Encounter
        id: enc1

The populatelink operation generates a link to a web page to be used to answer a specified Questionnaire. The form at the specified location will be pre-filled with answers to questions where possible based on information provided as part of the operation or already known by the server about the subject of the Questionnaire.

URLs

POST [base]/Questionnaire/$populatelink
POST [base]/Questionnaire/[id]/$populatelink

Parameters

The base set of parameters is the same as for $populate. On top of that, a few extra parameters are supported by Aidbox Forms.

WARN: The following parameters are not FHIR SDC compliant. This is an extension of the specification.

NOTE: Don't forget to wrap parameters in Parameters object

resourceType: Parameters
parameter:
- name:  [var-name]
  value: [varType: var-value]

allow-amend

Whether the generated link will allow amending and re-submitting the form.

name: allow-amend
value:
  Boolean: true

allow-repopulate

Whether the generated link will allow re-populating the form.

NOTE: Repopulate will be working only with forms that contain populate behavior

name: allow-repopulate
value:
  Boolean: true

redirect-on-submit

A URL where the user will be redirected to after successfully submitting the form.

name: redirect-on-submit
value:
  String: https://example.com/submit-hook?questionnaire=123

redirect-on-save

A URL where the user will be redirected to after hitting Save button.

By default Save button is not visible - form autosaved after every keystroke. But sometimes it's usefull to close form in a partially-filled state

name: redirect-on-save
value:
  String: https://example.com/submit-hook?questionnaire=123

Link expiration period (days)

name: expiration
value:
  Integer: 30

By default thir parameter = 7 days

theme

Form theme.

name: theme
value:
  String: hs-theme

read-only

Open form in read-only mode.

name: read-only
value:
  Boolean: true

app-name

Application name that will be used in Audit logging when returned link was used.

Audit logging should be enabled via configuartion

- name: app-name
  value
    String: my-app

Response

  • in failure case - response is specified as OperationOutcome object containing a link.

  • in success case - response is specified as Parameters object containing a list of issues.

Usage Example

POST [base]/Questionnaire/vitals/$populatelink
content-type: text/yaml

resourceType: Parameters
parameter:
- name: subject
  value:
    Reference:
      id: pt-1
      resourceType: Patient
- name: context
  part:
  - name: name
    value:
      String: encounter
  - name: content
    resource:
      resourceType: Encounter
      id: enc-1
      subject:
        id: pt-1
        resourceType: Patient

Questionnaire response extract to resources - $extract

The extract operation takes a completed QuestionnaireResponse and extracts it's data to Bundle of resources by using metadata embedded in the Questionnaire the QuestionnaireResponse is based on. The extracted resources might include Observations, MedicationStatements and other standard FHIR resources which can then be shared and manipulated.

Aidbox supports only the Observation based and Definition based extraction methods.

URLs

URL: [base]/QuestionnaireResponse/$extract
URL: [base]/QuestionnaireResponse/[id]/$extract

Parameters

Parameters are specified via FHIR Parameters type.

Example

resourceType: Parameters
parameter:
- name: questionnaire-response
  resource:
    id: qr-1
    resourceType: QuestionnaireResponse
    ...

Response

Usage Example

POST [base]/QuestionnaireResponse/$extract
content-type: text/yaml

resourceType: Parameters
parameter:
- name: questionnaire-response
  resource:
    id: pt-1
    resourceType: QuestionnaireResponse
    questionnaire: https://forms.aidbox.io/vitals
    item:
      - linkId: temperature
        value:
          Decimal: 36.6
    ...

ValueSet Expansion - $expand

Value Sets are used to define possible coded answer choices in a questionnaire.

The use of standardized codes is useful when data needs to be populated into the questionnaire or extracted from the questionnaire for other uses.

The expand operation expand given ValueSet in to set of concepts.

This operation is described in detail here.

Last updated