Skip to content

Open-source FHIR Server to support patient- and clinician-facing apps

License

Notifications You must be signed in to change notification settings

Venvictor/api-server

 
 

Repository files navigation

SMART on FHIR

Open-source FHIR Server to support patient- and clinician-facing apps.

Still highly experimental, but has limited support for:

  • GET, POST, and PUT resources
  • transaction (POST a bundle of resources)
  • Search resources based on FHIR's defined search params

Live demo: API | Apps

Installing

Prerequisites

  • Install Postgres 9.1+ (locally or use a remote service)
  • Oracle Java 7 JDK (not JRE -- and not Java 8)

Get it

$ git clone https://github.com/smart-on-fhir/api-server
$ cd api-server

Initialize the DB (see config below as needed)

Ensure that /etc/postgresql/9.1/main/pg_hba.conf contains a line like:

local   all         all                               md5

(If you have local all all peer, for example, peer with md5.)

$ sudo -u postgres -i
postgres@$ createuser -R  -P -S  -D fhir
           [at password prompt: fhir]
postgres@$ createdb -O fhir fhir
postgres@$ logout

Run it

$ ./grailsw run-app

Configuring

Key settings files are:

grails-app/conf/Config.groovy

  • Turn authentication or off with fhir.oauth.enabled: true | false
  • Configure authentication with fhir.oauth

grails-app/conf/DataSource.groovy

  • Configure your Postgres dataSource

Using

Add new data to the server via HTTP PUT or POST. For example, with default authentication settings and a server running at http:https://localhost:8080, you can add a new Diagnostic Order via:

curl 'http:https://localhost:8080/DiagnosticOrder/example' \
     -X PUT \
     -H 'Authorization: Basic Y2xpZW50OnNlY3JldA=='\
     -H 'Content-Type: text/xml' \
     --data @grails-app/conf/examples/diagnosticorder.xml

And then you can retrieve a feed of diagnostic orders via:

curl 'http:https://localhost:8080/DiagnosticOrder' \
     -H 'Authorization: Basic Y2xpZW50OnNlY3JldA=='

or fetch a single resource as JSON via:

curl 'http:https://localhost:8080/DiagnosticOrder/example' \
     -H 'Authorization: Basic Y2xpZW50OnNlY3JldA==' \
     -H 'Accept: application/json'

Getting more sample data

You can load sample data from SMART's Sample Patients:

$ sudo apt-get install python-jinja2
$ git clone --recursive https://github.com/smart-on-fhir/sample-patients
$ cd sample-patients/bin
$ git checkout fhir
$ python generate.py --write-fhir ../generated-data
$ ls ../generated-data # a bunch of XML files

Loading these files into your system

cd ../generated-data
for i in *.xml; do 
   curl 'http:https://localhost:8080/?' \
        -H 'Content-Type: text/xml' \
        --data-binary @$i; 
done

Storing Documents + DocumentReferences

There's very rudimentary support for adding C-CDA documents to the server, with a client-side loader script. The loader will:

  • Store the raw content of your C-CDA
  • Create a FHIR DocumentReference for your C-CDA, with a location pointing to the raw content.
  • Create an empty patient if needed

Here's how to invoke it (note the awkward use of environment variables to pass arguments):

BASE_URL="http:https://localhost:8080" \
CLIENT_ID=client \
CLIENT_SECRET=secret \
PATIENT_ID="1234" \
CCDA="grails-app/conf/examples/ccda.xml"\
./grailsw run-script scripts/LoadCCDA.groovy

Loading EMERGE Test Patients

To load a collection of >600 C-CDA documents (and a FHIR DocumentReference for each), you can do:

cd load-emerge-patients
git clone https://github.com/chb/sample_ccdas
./gradlew -PemergeDir=sample_ccdas/EMERGE/ -PfhirBase="http:https://localhost:8080" loadPatients

And load a single patient with id of example:

./gradlew -PemergeDir=../grails-app/conf/examples -PfhirBase="http:https://localhost:8080" loadPatients

About

Open-source FHIR Server to support patient- and clinician-facing apps

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Groovy 83.4%
  • CSS 10.1%
  • Batchfile 6.4%
  • JavaScript 0.1%