Name: fhirbase-plv8
Owner: Fhirbase
Description: Fhirbase 2.0 is an FHIR relational storage
Created: 2015-07-22 20:18:26.0
Updated: 2017-12-12 22:53:16.0
Pushed: 2017-05-31 14:54:37.0
Homepage: http://fhirbase.github.io
Size: 21706
Language: CoffeeScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
This is new version of fhirbase, with support of DSTU-2 and planned support many advanced features:
While crafting Health IT systems we understand an importance of a properly chosen domain model. FHIR is an open source new generation lightweight standard for health data interoperability, which (we hope) could be used as a foundation for Health IT systems. FHIR is based on a concept of resource.
FHIRŽ is a next generation standards framework created by HL7. FHIR combines the best features of HL7 Version 2, Version 3 and CDAŽ product lines while leveraging the latest web standards and applying a tight focus on implementability.
We also learned that data is a heart of any information system, and should be reliably managed. PostgreSQL is a battle proven open source database which supports structured documents (jsonb) while preserving ACID guaranties and richness of SQL query language.
PostgreSQL is a powerful, open source object-relational database system. It has more than 15 years of active development and a proven architecture that has earned it a strong reputation for reliability, data integrity, and correctness.
Here is the list of PostgreSQL features that we use:
To install fhirbase you need postgresql-9.4 and plv8 extension.
apt-get install postgresql-contrib-9.4 postgresql-9.4-plv8 -qq -y
-c "CREATE USER \"user\" WITH PASSWORD 'password'"
-c 'CREATE DATABASE fhirbase;' -U user
-c '\dt' -U postgres
rt DATABASE_URL=postgres://user:password@localhost:5432/fhirbase
https://github.com/fhirbase/fhirbase-plv8/releases/download/v<version of the fhirbase>/fhirbase-<version of the fhirbase>.sql.zip
p fhirbase-<version of the fhirbase>.sql.zip
fhirbase-<version of the fhirbase>.sql | psql fhirbase
rt DATABASE_URL=postgres://user:password@localhost:5432/fhirbase
https://github.com/fhirbase/fhirbase-plv8/releases/download/v<version of the fhirbase>/fhirbase-<version of the fhirbase>-patch.sql.zip
p fhirbase-<version of the fhirbase>-patch.sql.zip
fhirbase-<version of the fhirbase>-patch.sql | psql fhirbase
Development installation requires node v6.2.0 or newer and npm 3.0.0 or newer, which could be installed by nvm:
stall node < 0.12 by nvm for example
apt-get install postgresql-contrib-9.4 postgresql-9.4-plv8 -qq -y
clone https://github.com/fhirbase/fhirbase-plv8
hirbase-plv8
submodule init && git submodule update
install && cd plpl && npm install
install -g mocha && npm install -g coffee-script
-c "CREATE USER fb WITH PASSWORD 'fb'"
-c 'ALTER ROLE fb WITH SUPERUSER'
-c 'CREATE DATABASE fhirbase;' -U postgres
-c '\dt' -U postgres
rt DATABASE_URL=postgres://fb:fb@localhost:5432/fhirbase
ild migrations
ee utils/generate_schema.coffee -n | psql fhirbase
utils/patch_3.sql | psql fhirbase
ange something
load schema
/bin/plpl reload
run test
to: change something
clone https://github.com/fhirbase/fhirbase-plv8 fhirbase
hirbase
er build .
If you have permissions to edit PostgreSQL config, add directive for auto setting plv8 parameter for every connection. It will make your debugging and development much easier:
"plv8.start_proc='plv8_init'" >> /etc/postgresql/9.4/main/postgresql.conf
To make fhirbase-plv8 work, just after opening connection to postgresql, you have to issue the following command (read more here):
plv8.start_proc = 'plv8_init';
plv8.start_proc = 'plv8_init';
ork with storage
CT fhir_create_storage('{"resourceType": "Patient"}');
CT fhir_drop_storage('{"resourceType": "Patient"}');
CT fhir_truncate_storage('{"resourceType": "Patient"}');
elete all resources of specified type
he above commands should look like this:
ql fhirbase
(9.4.6)
"help" for help.
base=# SET plv8.start_proc = 'plv8_init';
base=# SELECT fhir_create_storage('{"resourceType": "Patient"}');
fhir_create_storage
---------------------------------------------------
tatus":"ok","message":"Table patient was created"}
ow)
base=#
RUD
CT fhir_create_resource('{"resource": {"resourceType": "Patient", "name": [{"given": ["Smith"]}]}}');
reate will fail if id provided, to create with predefined id pass [allowId] option or use fhir_update_resource
CT fhir_create_resource('{"allowId": true, "resource": {"resourceType": "Patient", "id": "smith"}}');
onditional create
CT fhir_create_resource('{"ifNoneExist": "identifier=007", "resource": {"resourceType": "Patient", "id": "smith", "name": [{"given": ["Smith"]}]}}');
CT fhir_read_resource('{"resourceType": "Patient", "id": "smith"}');
CT fhir_vread_resource('{"resourceType": "Patient", "id": "????", "versionId": "????"}');
CT fhir_resource_history('{"resourceType": "Patient", "id": "smith"}');
CT fhir_resource_type_history('{"resourceType": "Patient", "queryString": "_count=2&_since=2015-11"}');
CT fhir_update_resource('{"resource": {"resourceType": "Patient", "id": "smith", "name": [{"given": ["John"], "family": ["Smith"]}]}}');
onditional update
CT fhir_update_resource('{"ifNoneExist": "identifier=007", "resource": {"resourceType": "Patient", "id": "smith", "name": [{"given": ["Smith"]}]}}');
pdate with contention guard
CT fhir_update_resource('{"ifMatch": "..versionid..", "resource": {"resourceType": "Patient", "id": "smith", "name": [{"given": ["Smith"]}]}}');
CT fhir_search('{"resourceType": "Patient", "queryString": "name=smith"}');
CT fhir_index_parameter('{"resourceType": "Patient", "name": "name"}');
CT fhir_unindex_parameter('{"resourceType": "Patient", "name": "name"}');
CT fhir_search_sql('{"resourceType": "Patient", "queryString": "name=smith"}');
ee generated SQL
CT fhir_explain_search('{"resourceType": "Patient", "queryString": "name=smith"}');
ee execution plan
ark resource as deleted (i.e. keep history)
CT fhir_delete_resource('{"resourceType": "Patient", "id": "smith"}');
ompletely delete resource and it history
CT fhir_terminate_resource('{"resourceType": "Patient", "id": "smith"}');
xpand valueset
CT fhir_valueset_expand('{"id": "issue-types", "filter": "err"}');
CT fhir_conformance('{"default": "values"}');
eturn simple Conformance resource, based on created stores
se different methods to calculate total elements to improve performance: no _totalMethod or _totalMethod=exact uses standard approach
CT fhir_search('{"resourceType": "Patient", "queryString": "name=smith"}');
CT fhir_search('{"resourceType": "Patient", "queryString": "name=smith&_totalMethod=exact"}');
totalMethod=extimated - faster but 'total' is estimated.
CT fhir_search('{"resourceType": "Patient", "queryString": "name=smith&_totalMethod=estimated"}');
totalMethod=no - fastest but no 'total' is returned.
CT fhir_search('{"resourceType": "Patient", "queryString": "name=smith&_totalMethod=no"}');
See the CONTRIBUTING.md.
Copyright Š 2016 health samurai.
fhirbase is released under the terms of the MIT License.