Schema
Fhirbase schema is regular and uniform. Each resource is saved in a table with the lower case name of the resourceType. For example, the Patient resource is saved in the patient table. All resource tables has similar structure:
id
is an resource IDtxid
is the versionId for the resource and at the same time the sequential id of logical transaction, which can be used for implementing integrations, ETags, reactive APIs, etc.ts
stores a timestamp of last resource updatestatus
is enumeration with possible values:create
,updated
,deleted
,recreated
resource
stores JSON representation of a resource in slightly altered format.
Previous versions of resources are saved in the history table:
History tables are postfixed with "_history" and have same structure as primary tables. On resource update Fhirbase moves the current version of the resource from the primary table to the history table.
Sometimes you change many resources in one transaction and/or want to store meta-information about transactions. Fhirbase has a special transaction table to store transaction info and the id
sequence for transaction is used as versionId (txid
) in resources, which were touched in this transaction.
The schematic transaction workflow usually looks like this:
Create a new record in the transaction table or get next transaction ID from transaction ID sequence -
txid
For all resources which will be changed in the transaction, set
txid
to the value obtained in previous stepSave changed resources
txid and record in transaction table can be used to track back changes. txid can also be used as the globally increasing version id for resources - a logical clock which may be helpful for caches and reactive engines implementation.
Last updated