How to extract data from forms
Aidbox forms supports Observation-based extraction, Definition-based extraction and Template-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:
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:
In response you will get resource Bundle with needed Observation:
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
Create in builder group called Patient and three items, so your form in item tree should look like this:
1. Setting group extraction context
Select group in outline
Expand
Data extraction
sectionCheck
Extract
Select
Definition
Fill
Group extraction context
withPatient/{{%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 itemPatient.name.given
for given name itemPatient.birthDate
for birth date item
In the end your Questionnaire should look like this:
Usage
Now let's call $extract
operation again or click "Extract" in Debug panel in Extraction tab:
In response you will find two entries in Bundle resource: one updating Patient resource and one for creating Provenance resource.
Extraction complicated resource types
In our example ContactPoint has constraints which means:
A system field is required if a value is provided.
We need setup another item which will be extract's need system
field.
Form setup
Let's create a form that updates Patient phone resource. Create in builder group called Patient and two items into it , so your form in item tree should look like this:
1. Setting group extraction context
Select group in outline
Expand
Data extraction
sectionCheck
Extract
Select
Definition
Fill
Group extraction context
withPatient/{{%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.telecom.value
for phone name itemPatient.telecom.system
for system name item
3. Setting widgets
Select
system
widget in outlineSelect
Hidden
andReadonly
propertiesExpand
Rules
sectionFill
Calculated Expression
with'phone'
Now system
item will extract 'system' = 'phone'
into Patient telecom resource.
In the end your Questionnaire should look like this:
Testing
Call $extract
operation again or click "Extract" in Debug panel in Extraction tab:
In response you will find entry which updates Patient id2
with filled telecom
. In our example it is phone
type with +1222333444
numbers.
Template-based extraction
Template-based extraction is a new way to extract data with user-friendly UI and simple setup. To extract data from form just create template with visual or code editor.
In this guide we will create form with template that updates Patient information.
Form setup
Let's create a form that updates Patient resource.
Create in builder group called Patient and four items, so your form in item tree should look like this:
1. Setting group extraction template
Select group in outline
Expand
Data extraction
sectionCheck
Extract
Select
Template
Click
Add template
and selectNew resource
After this steps will opens Resource Template Editor for your template. Now let's create extraction context.
Fill your
Template name
Select
Patient
into Resource TypeSelect
Existing
into New or existing resourceSelect local items answers
patient-id
into pick resource id
When aidbox mets this group during the extraction process, it will fetch Patient resource with id = patient-id
of QuestionnaireResponse.
Now assemble template what data need to extract
Find
Name
and clickadd value
Into created bundle
0
findfamily
and again pressadd value
Pick a value into local items answers
family name
Repeat this steps for other items
given name
andbirth date
Your template is ready for extraction.
2. Setting widgets
This steps needs only for updating Patient resource. If you want create new resource skip this section.
Select
patient-id
widget in outlineSelect
Hidden
propertyExpand
Population
sectionSelect
Expression
and fill it with%subject.id
Now patient-id
item will populate id from Patient resource and will store it for our extraction which one we need to update.
Usage
Now let's call $extract
operation again or click "Extract" in Debug panel in Extraction tab:
In response you will find entry which updates Patient id1
with filled family name
, given name
and birthdate
.
Last updated
Was this helpful?