Share via


HAPI FHIR in Azure (PaaS)

Fast Healthcare Interoperability Resources (FHIR) is a draft standard describing data formats and elements (known as "resources") and an application programming interface (API) for exchanging electronic health records. In a previous blog post, I discussed running FHIR Servers in Azure PaaS Services. In this blog post I will be expanding on the list of FHIR Servers you can run in Azure PaaS. Specifically, I will be sharing templates and instructions for running the HAPI FHIR JPA Example Server in an Azure Web App with Azure SQL backend.

In my fhir-azure GitHub repo, I have added a template for configuring the resources for HAPI-FHIR. It will deploy an Azure Web App, Azure SQL Server, and configure JAVA and connection string settings. This will be your environment ready for deploying HAPI-FHIR.

Next you need a *.war file for deployment. I have forked the HAPI-FHIR code repository and made the required changed to use Azure SQL server. The changes are pretty modest. In order to build the project, you need JAVA and Maven installed. Please consult the README file for details. You can build the required *.war file with:

[ps]
git clone https://github.com/hansenms/hapi-fhir.git
cd hapi-fhir
git checkout azuresql
cd hapi-fhir-jpaserver-example
mvn install
[/ps]

Then copy the hapi-fhir-jpaserver-example.war (from the target folder) to the D:\home\site\wwwroot\webapps folder on your web app. You can use the Kudu console for this (drag and drop).

After copying the war file, it will be expanded and that will take a while. The initial database will also be created and so on, so it may take some time (several minutes) before. Once deployed, open it up and you should see something like the screenshot below:

If you would like to load some data into the HAPI FHIR server, I recommend using the Synthea project. To download and build that tool (you need Java 1.8 or above):

[ps]
git clone https://github.com/synthetichealth/synthea.git
cd synthea
.\gradlew build check test
[/ps]

Then to generate a population of say 10 patients:

[ps]
.\run_synthea -p 10
[/ps]

The 10 patient dataset will be in output\fhir. It's a bit of a technical detail, but Synthea produces FHIR bundles of type collection and typically you need a type transaction to upload to the server. You could create a script to make the required changes yourself, but I use the "tag-uploader" from the SMART on FHIR project. You can find the source code for the tag-uploader on GitHub. It is written in NodeJS (sorry about the language mixture in this post). To install and use it, first:

[ps]
git clone https://github.com/smart-on-fhir/tag-uploader.git
cd tag-uploader
npm install
[/ps]

Then use the uploader:

[ps]
node . -d PATH-TO-SYNTHEA\output\fhir\ -S https://HAPI-WEBSITE-NAME.azurewebsites.us/hapi-fhir-jpaserver-example/baseDstu3
[/ps]

And that's it. You now have a HAPI FHIR example server with some synthetic datasets. Let me know if you have questions/comments/suggestions.

Comments

  • Anonymous
    May 08, 2018
    very useful, thanks for sharing!
  • Anonymous
    November 21, 2018
    Great article. Here is a tip. When you FTP the WAR it will unpack into a subfolder rather than the ROOT folder that already exists inside "webapps". If you want to just use the ROOT instead you can drop the following into Terminal and it will use Wardeploy to put it there. The username/password are the same as the ones for FTP:# *** BEGIN *** Customizationssitename='site1' # if you site is site1.azurewebsites.netusername='$site1' # Example: username='$site1' (NOT 'site1$site1', NOT 'site1\site1'. Also, note the single quotes.)password='pwd'warFilePath='./hapi-fhir-jpaserver-example.war'# *** END *** Customizationscurl -X POST -u $username:$password https://$sitename.scm.azurewebsites.net/api/wardeploy --data-binary @$warFilePath
    • Anonymous
      November 21, 2018
      Yes, another option is to just name the war file ROOT.war before dropping it in. That solves it as well.