Aidbox & FHIR formats
Difference between Aidbox and FHIR formats
Aidbox stores FHIR resources almost as is with 3 types of isomorphic transformations:
    References
    Union (Choice Types)
    First-Class Extensions

References:

In FHIR, references are represented as URI string. In most cases, you are interested in discrete parts of references like resource id and type. For performance and accuracy reasons Aidbox parses reference and stores its parts in discrete fields. There are three types of references - absolute, relative, and local. Aidbox parses them into different attributes.
Relative (interpreted as a reference to a resource on the same server; trigger referential consistency check) :
1
# FHIR
2
subject:
3
reference: "Patient/pt-1"
4
​
5
# Aidbox
6
subject:
7
resourceType: "Patient"
8
id: "pt-1"
Copied!
reference is parsed into a pair of {id,resourceType} attributes
Absolute (interpreted as a reference to an external resource; no ref validation)
1
# FHIR
2
subject:
3
reference: "http://external/fhir/Patient/pt-1"
4
​
5
# Aidbox
6
subject:
7
uri: "http://external/fhir/Patient/pt-1"
Copied!
reference is parsed into the uri attribute
Local (interpreted as a local ref to contained resources )
1
# FHIR
2
subject:
3
reference: "#pt"
4
​
5
# Aidbox
6
subject:
7
localRef: "pt"
Copied!
reference is parsed into a ref attribute

Union (Choice) Types:

Some elements can have multiple types. Such elements in FHIR spec prefixed with [x] like Observation.value[x] and represented in JSON in a wrong (postfixed) way likeObservation.valueString . The simple logical check "why it's wrong" is "you could not have a collection of union elements in FHIR JSON!". Aidbox fixes this moving type as a key inside a nested object - valueString:... => value: {string: ...}
1
#FHIR
2
resourceType: Observation
3
valueQuantity:
4
unit: ...
5
value: ...
6
​
7
# becomes Aidbox
8
resourceType: Observation
9
value:
10
Quantity:
11
unit: ...
12
value: ...
Copied!

First-Class Extensions

While FHIR uses two different ways to define core elements and extensions, Aidbox provides unified framework to describe both. Aidbox supports user-defined attributes or "first-class extensions". In Aidbox, you can define new attributes (elements) for existing (FHIR) resources. Let's illustrate this on race complex attribute for Patient from US-Core FHIR Profile.
This is how a patient with race looks in FHIR format:
1
resourceType: Patient
2
id: sample-pt
3
extension:
4
- url: http://hl7.org/fhir/us/core/StructureDefinition/us-core-race
5
extension:
6
- url: text
7
valueString: Asian Indian
8
- url: ombCategory
9
valueCoding:
10
system: urn:oid:2.16.840.1.113883.6.238
11
code: 2028-9
12
display: Asian
13
- url: detailed
14
valueCoding:
15
system:
16
code: 2029-7
17
display: Asian Indian
Copied!
If you try to save this resource in "default", Aidbox will keep these extensions as is. But if you define attributes for these extensions, Aidbox will store them in a more friendly format.
1
PUT /
2
​
3
- resourceType: Attribute
4
id: Patient.race
5
path: ['race']
6
resource: {id: 'Patient', resourceType: 'Entity'}
7
extensionUrl: 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-race'
8
- resourceType: Attribute
9
id: Patient.race.text
10
path: ['race', 'text']
11
resource: {id: 'Patient', resourceType: 'Entity'}
12
type: {id: 'string', resourceType: 'Entity'}
13
extensionUrl: text
14
- resourceType: Attribute
15
id: Patient.race.category
16
path: ['race', 'category']
17
resource: {id: 'Patient', resourceType: 'Entity'}
18
type: {id: 'Coding', resourceType: 'Entity'}
19
extensionUrl: ombCategory
20
- resourceType: Attribute
21
id: Patient.race.detailed
22
path: ['race', 'detailed']
23
resource: {id: 'Patient', resourceType: 'Entity'}
24
type: {id: 'Coding', resourceType: 'Entity'}
25
extensionUrl: detailed
Copied!
Now you can test how a resource will be stored in Aidbox with:
1
POST /to-format/aidbox
2
​
3
resourceType: Patient
4
id: sample-pt
5
extension:
6
- url: http://hl7.org/fhir/us/core/StructureDefinition/us-core-race
7
extension:
8
- url: text
9
valueString: Asian Indian
10
- url: ombCategory
11
valueCoding:
12
system: urn:oid:2.16.840.1.113883.6.238
13
code: 2028-9
14
display: Asian
15
- url: detailed
16
valueCoding:
17
system:
18
code: 2029-7
19
display: Asian Indian
Copied!
Read more about /$to-format Operation.
The response should be:
1
resourceType: Patient
2
id: sample-pt
3
race:
4
text: Asian Indian
5
category: {system: 'urn:oid:2.16.840.1.113883.6.238', code: 2028-9, display: Asian}
6
detailed: {system: 'urn:oid:2.16.840.1.113883.6.238', code: 2029-7, display: Asian Indian}
Copied!
Last modified 9mo ago