Aidbox forms supports Observation-based extraction and Definition-based extraction
Observation-based extraction
Observation-based extraction are widely used extraction method and the simpliest one.
To extract data from item to Observation, you just need to add code to item and enable Observation extraction.
Form setup:
Fill item code (this code will go into Observation code)
Enable Observation-extraction by clicking "Data extraction" -> "Observation"
Minimal Questionnaire that uses that approach:
title: New form
status: draft
url: http://forms.aidbox.io/questionnaire/new-form
resourceType: Questionnaire
item:
- type: quantity
text: Weight
extension:
- url: http://hl7.org/fhir/StructureDefinition/questionnaire-unitOption
valueCoding:
display: F
- url: http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationExtract
valueBoolean: true
linkId: weight
code:
- code: 8302-2
system: http://loinc.org
display: Body height
Usage
To get some data from you need to call $extract operation. Also, you can use Debug panel in builder, choose Extraction and you will see result of calling this operation:
POST /fhir/QuestionnaireResponse/$extract
content-type: application/json
resourceType: Parameters
parameter:
- name: questionnaire-response
resource:
resourceType: QuestionnaireResponse
subject:
id: morgan
resourceType: Patient
author:
id: morgan
resourceType: Patient
status: in-progress
item:
- linkId: weight
text: Weight
answer:
- valueQuantity:
value: 123123
unit: F
questionnaire: http://forms.aidbox.io/questionnaire/new-form
In response you will get resource Bundle with needed Observation:
resourceType: Observation
status: final
code:
coding:
- code: 8302-2
system: http://loinc.org
display: Body height
subject:
reference: Patient/morgan
valueQuantity:
value: 123123
unit: F
effectiveDateTime: '2024-08-13T10:56:51.101406969Z'
id: c83afc80-b274-4a75-8034-c54ee3110e67
Definition-based extraction
Definiton-based extraction can be used to extract any type of resources. In this guide we will create form that updates Patient info.
Form setup
Let's create a form that updates Patient resource. Any item in Questionnaire that you want to extract using this approach must be placed inside a group with itemExtractionContext
Create in builder group called Patient and three items, so your form in item tree should look like this:
Patient [group]
- family name [string]
- given name [string]
- birth date [date]
1. Setting group extraction context
Select group in outline
Expand Data extraction section
Check Extract
Select Definition
Fill Group extraction context with Patient/{{%resource.subject.id}}
When aidbox mets this group during the extraction process, it will fetch Patient resource with id = subject.id of QuestionnaireResponse.
2. Setting item definitions
Once we have item extraction context (in our case it is a Patient resource), we can set where answers from items in this group should go.
For each item in "Patient" group enable data-extraction in builder and choose "Definition" and fill it with these values:
Patient.name.family for family name item
Patient.name.given for given name item
Patient.birthDate for birth date item
In the end your Questionnaire should look like this: