This demo shows how to use FHIR SDC Api in Aidbox via Aidbox Forms module.
- Docker
- Cloned repository: Github: Aidbox/examples
- Working directory:
fhir-sdc-api
git clone git@github.com:Aidbox/examples.git && cd examples/fhir-sdc-api
docker compose up
Docker Compose file initializes aidbox with following configuration:
- Imports sample Questionnaire
- Creates two patients
To fill the form, you can use Aidbox Forms UI or use FHIR SDC API from Aidbox Rest Console
- Open Aidbox Forms UI:
localhost:8080/ui/sdc
- Click share on the CVD Reference Form (this is the form that was imported)
- Choose a patient
- Click Attach button to get the link
Now you can open the link you obtained on the last step and start filling the form.
Now, we’ll do the same but using $populatelink
call using Aidbox REST Console
- Open Aidbox Rest Console
localhost:8080/ui/console#/rest
- Send this request:
POST /Questionnaire/cvd-reference-form/$populatelink
resourceType: Parameters
parameter:
- name: subject
valueReference:
reference: Patient/john
- name: local
valueBoolean: true
FHIR SDC defines an operation $extract
to retrieve resources from QuestionnaireResponse
. However, since it’s a stateless operation, it returns a Bundle
that you need to save by yourself.
The Aidbox Forms UI has auto-save feature. That means it will save QuestionnaireResponse
each time you
changed answers in the form.
But after clicking Submit
button it will extract resources from this QuestionnaireResponse and save it into database. So you don’t need to save extracted resources manually.
You need to fill the QuestionnaireResponse and obtain it ID.
- Open Aidbox Rest Console
localhost:8080/ui/console#/rest
- Extract resources
POST /QuestionnaireResponse/<your-qr-id>/$extract
In response you will get something like this:
resourceType: Parameters
parameter:
- name: return
resource:
resourceType: Bundle
entry:
— resource:
resourceType: Observation
<<< list of resources >>>
- Save extracted resources
Now we need to save this Bundle
that we get in return
parameter using POST /
POST /
resourceType: Bundle
entry:
- resource:
resourceType: Observation
<<< list of extracted resources >>>
GET /Observation
Since our form extracts only observation you should see two or three new Observations depending on your answers.