Mappings
Mapper module provides a way to convert data with arbitrary schema to FHIR resource(s) and store results in Aidbox.
Most of real-world healthcare applications are integrated with 3rd-party systems to ingest data from them. Using the Mapping resource, you can describe how 3rd-party data is being converted to the FHIR format. Mappings are written using the JUTE language.
The Mapping is an Aidbox resource, so all CRUD operations are applicable to it. The Mapping's schema is pretty straightforward:
If the scopeSchema
attribute is provided, incoming mapping data (also called a scope) will be validated against it first. Then, a JUTE template from the body
will be executed. Mapping should return a valid Transaction Bundle, so when applied, it will be able to operate with multiple resources not just single one.
Example
Let's do a simple mapping which will create a Patient resource from the following data structure:
The following request will create a mapping resource:
If you're not familiar with JUTE, please check out JUTE Tutorial to understand basic concepts.
When a template is created, you can invoke the $apply operation on it to generate a Patient resource and save it into the database:
$apply Endpoint
To execute Mapping and store its result to the Aidbox database, do a POST request to the $apply endpoint. Request's body will be passed to a JUTE as an incoming data (scope):
Make sure that your Mapping returns a Transaction Bundle, otherwise its result won't be persisted to a database.
$debug Endpoint
To check Mapping's result without actual persisting, you can do a POST request to the $debug endpoint:
Response will contain a mapping result or an error if evaluation failed for some reason.
Global $debug Endpoint
There is a way to check a mapping result without persisting it as a resource:
You pass both Mapping and incoming data (scope) in a request body. Request response will contain the mapping result or an error information.
Including Mapping inside other Mapping
In Aidbox, there is the $include
directive which allows you to include a Mapping within another one:
This template will pass execution to either /Mapping/patient
or /Mapping/practitioner
depending on the value of the type
key. Current evaluation scope will be passed to the included Mapping.
Because potentially there is a way to create an infinite recursion using the$include
directive, there is an inclusion depth limit which equals to 5 for now.
Mapping Parameters
omit-drop-blanks
parameter
Let's say we want to specify request depending on the gender field:
JUTE will remove all empty values (nulls and empty arrays) and Aidbox will answer with "Please provide body for patch" response.
Passing omit-drop-blanks
parameter will solve the issue.
Mapping Editor in the Aidbox UI
There is a Mapping Editor in the Aidbox UI with a built-in syntax checker and Debug capabilities. Search for the "Mappings" item in the left navigation menu.
Last updated