This demo shows how to use FHIR SDC Api in Aidbox via Aidbox Forms module.
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:
$populatelink
APITo fill the form, you can use Aidbox Forms UI or use FHIR SDC API from Aidbox Rest Console
localhost:8080/ui/sdc
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
localhost:8080/ui/console#/rest
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.
localhost:8080/ui/console#/rest
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 >>>
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.