Aidbox stores FHIR resources almost as is with 3 types of isomorphic transformations:
References
Union (Choice Types)
First-Class Extensions
In FHIR references are represented as URI string. In most of cases you interested in discrete parts of references like resource id and type. For performance and accuracy reason Aidbox parses reference and store its parts in discrete fields. There are three types of references - absolute, relative and local. Aidbox parse them into different attributes.
Relative ( interpreted as reference to resource on same server; trigger referential consistency check) :
# FHIRsubject:reference: "Patient/pt-1"​# Aidboxsubject:resourceType: "Patient"id: "pt-1"
reference is parsed into pair of {id,resourceType}
attributes
Absolute (interpreted as reference to external resource; no ref validation)
# FHIRsubject:reference: "http://external/fhir/Patient/pt-1"​# Aidboxsubject:uri: "http://external/fhir/Patient/pt-1"
reference is parsed into uri attribute
Local (interpreted as local ref to contained resources )
# FHIRsubject:reference: "#pt"​# Aidboxsubject:localRef: "pt"
reference is parsed into ref attribute
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 key inside nested object - valueString:... => value: {string: ...}
#FHIRresourceType: ObservationvalueQuantity:unit: ...value: ...​# becomes AidboxresourceType: Observationvalue:Quantity:unit: ...value: ...
While FHIR uses two different ways to define core elements and extensions, Aidbox provide 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 how patient with race looks in FHIR format:
resourceType: Patientid: sample-ptextension:- url: http://hl7.org/fhir/us/core/StructureDefinition/us-core-raceextension:- url: textvalueString: Asian Indian- url: ombCategoryvalueCoding:system: urn:oid:2.16.840.1.113883.6.238code: 2028-9display: Asian- url: detailedvalueCoding:system:code: 2029-7display: Asian Indian
If you will try save this resource in "default" Aidbox it will keep this extensions "as is". But if you define attributes for this extensions - Aidbox will store it in more friendly format.
PUT /​- resourceType: Attributeid: Patient.racepath: ['race']resource: {id: 'Patient', resourceType: 'Entity'}extensionUrl: 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-race'- resourceType: Attributeid: Patient.race.textpath: ['race', 'text']resource: {id: 'Patient', resourceType: 'Entity'}type: {id: 'string', resourceType: 'Entity'}extensionUrl: text- resourceType: Attributeid: Patient.race.categorypath: ['race', 'category']resource: {id: 'Patient', resourceType: 'Entity'}type: {id: 'Coding', resourceType: 'Entity'}extensionUrl: ombCategory- resourceType: Attributeid: Patient.race.detailedpath: ['race', 'detailed']resource: {id: 'Patient', resourceType: 'Entity'}type: {id: 'Coding', resourceType: 'Entity'}extensionUrl: detailed
Now you can test how resource will be stored in Aidbox with:
POST /to-format/aidbox​resourceType: Patientid: sample-ptextension:- url: http://hl7.org/fhir/us/core/StructureDefinition/us-core-raceextension:- url: textvalueString: Asian Indian- url: ombCategoryvalueCoding:system: urn:oid:2.16.840.1.113883.6.238code: 2028-9display: Asian- url: detailedvalueCoding:system:code: 2029-7display: Asian Indian
Read more about /$to-format Operation.
The response should be:
resourceType: Patientid: sample-ptrace:text: Asian Indiancategory: {system: 'urn:oid:2.16.840.1.113883.6.238', code: 2028-9, display: Asian}detailed: {system: 'urn:oid:2.16.840.1.113883.6.238', code: 2029-7, display: Asian Indian}