KeFHIR can handle different storages per every FHIR resource type.
There are various KeFHIR storage implementations that can be used in parallel in the same installation.
You should implement ResourceStorage to provide resource save capabilities to KeFHIR.
There can be several implementations for different resource types, as well as default global implementation.
PostgreSQL is the default storage implementation in the KeFHIR.
KeFHIR provides default ResourceStorage implementation using PostgreSQL.
implementation "com.kodality.kefhir:pg-core:${kefhirVersion}"
implementation "com.kodality.kefhir:pg-store:${kefhirVersion}"
datasources:
default:
url: jdbc:postgresql://localhost:5151/kefhirdb
username: kefhir_app
password: test
maximum.pool.size: 10
driver.class.name: org.postgresql.Driver
admin:
url: jdbc:postgresql://localhost:5151/kefhirdb
username: kefhir_admin
password: test
maximum.pool.size: 1
driver.class.name: org.postgresql.Driver
liquibase:
datasources:
admin:
enabled: true
change-log: 'classpath:changelog.xml'
default-schema: 'public'
parameters:
app-username: ${datasources.default.username}
default
datasource is used for data insert/load.admin
datasource is used for liquibase database migrations and for adding/removing resource types, as they require permissions for altering the database.uid
- generated primary keytype
and id
- resource type and resource id, as in url (Patient/123)version
- resource version number. Generated sequentiallyupdated
and author
- When and who created this version.content
- full json content of a versionprofiles
- contains references to the profiling StructureDefinition resource by uidsecurity_labels
- list of resource security labelssystem status
of a version:
A
- active. There can be only one active version (last)T
- terminated. Version has been updated by a newer versionC
- cancelled or deleted. Resource is deleted.TODO. @Igor add more details
As mentioned above, you can provide your own storage solution by implementing ResourceStorage
interface.
Methods desctioption:
default
implementation.AuditEvent
for example.delete
interaction. Should mark last version as deleted
.history
interactiontransaction
interaction is called to pregenerate ids and replace references.For examples you may reference to Postgresql implementation here .
Since multiple data providers are allowed, KeFHIR cannot automatically handle theirs transactions.
When implmenting your own storage, you need to think of transactionality as well.
Given two classes to think of:
interface TransactionManager {
TransactionRef requireTransaction();
}
interface TransactionRef {
void rollback(Throwable e);
void commit();
void cleanupTransaction();
}
You need to implement TransactionManager
, which is being called for all data provides every time a save
is performed.
Please refer to Postgresql implementation example