Getting Started (Docker version)
Getting started with Fhirbase using Docker image.
Last updated
Getting started with Fhirbase using Docker image.
Last updated
This tutorial explains how to run Fhirbase using Docker Container Platform.
If for some reason you want to install PostgreSQL and Fhirbase natively (without containerisation), consider switching to another version of this tutorial.
Please follow Official Docker installation guide. There are handy installers for all major operating systems.
Fhirbase Docker image comes with PostgreSQL instance and already prepared database with Synthea data loaded in it.
For some Docker installations (mostly Linux) you may have to prepend all docker
commands with sudo
prefix, i.e. sudo docker pull
When image is downloaded, type following command to start web demo:
When you'll see an message that web server was started on port 3000, point your browser to the http://localhost:3000, and you'll see the Fhirbase demo page.
To stop webserver, press Ctrl+C
.
To be able to invoke Fhirbase commands, start container in demonised (-d
) mode:
Docker will respond with ID of newly created container, a long hash string like 34b55aae4b2538b3a51b87a125bba93f667dc5ddf67aec95d0cb6da6b953993e
. Copy this ID to the clipboard. Now we're ready to get Bash shell inside running container. Do following command and paste ID from the clipboard instead of ID placeholder:
If you see an postgres@xxxxxxxxx:/$
bash prompt, you can use psql
command to create a new database. After invoking psql
command your terminal should look like this:
Type CREATE DABATASE fb;
statement into the prompt and press Enter. Do not forget to put semicolon at the end of the statement. fb
here is the name of new database, you can change it to anything you want, but don't forget to change it in all command examples in this tutorial as well.
If PostgreSQL responded with CREATE DATABASE
, your new database is created and now you can quit psql
with typing \q
and pressing Enter.
Proceed to PostgreSQL documentation to get more information about psql
, an standard command-line PostgreSQL client.
Now we need to initialize newly created database with FHIR schema to store data in. We will use fhirbase init
command for that:
In this command -d fb
specifies name of the database (don't forget to change it if you named database differently in previous step). --fhir=3.0.1
sets a FHIR version you're going to use.
If Fhirbase did not return any error, your database was properly initialized with FHIR schema.
To import data into newly created database, use fhirbase load
command. Fhirbade Docker image comes with sample NDJSON file containing 127454 Synthea-generated FHIR resources. This bundle is located at /bundle.ndjson.gzip
. Invoke following command to load it:
Usually it takes about 30 seconds to load this bundle.
There are two different load modes: insert and copy. Using copy mode in some cases can drastically decrease load time. Also you can load data from Bulk Data API endpoints, FHIR bundles and plain JSON files. To get more information on this, take a look at load command reference.
Now we're ready to query our FHIR database with SQL. Let's start psql
providing database name:
You should get fb=#
prompt. Copy-and-paste examples below to see some trivial SQL magic.