Today we are going to be setting up a HAPI FHIR JPA Server. If you don’t know what FHIR or HAPI FHIR is please see my previous post.
In HAPI FHIR there are two versions of the server that are available to use. The Plain server and the JPA server.
The plain server is simply a REST endpoint facade that exposes all of the CRUD endpoints for FHIR resources. HAPI FHIR takes care of the high level parts like HTTP processing, serialization and the semantics of the FHIR standard. You would use this version if you have your own dataset. For instance, if you are a provider that runs on an EHR and want to be able to expose your data to consumers through the FHIR standard, you would likely use this version of HAPI FHIR. You would write your own mapping interface that would take the FHIR requests from the HAPI FHIR facade and hook that into your EHR system. This is just one example though, this mapping can happen against any type of dataset.
The JPA server is a more full flavored version. This version has the same FHIR facade from the Plain server along with the mappings required to store FHIR resources in a relational database. JPA server uses Hibernate ORM to take resources that are written as Java objects and store them into databases that are supported by Hibernate. This means that you can store your data in a number of different databases out of the box. The database for this server is created upon instantiation of the server. By default, HAPI FHIR JPA uses an embedded Derby database. How HAPI FHIR stores resources in the database will be the subject of a future article, so stay tuned 😉
Alright, now lets define the AWS resources we are going to use.
EC2: Elastic Compute Cloud is an AWS product that is a virtual server that lives in the AWS cloud. It is very easy to setup and there is plenty of configuration that AWS provides to choose the operating system, security and networking preferences. We will use this to host our HAPI FHIR JPA Server.
We are now ready to start setting up our AWS environment!
Lets begin by starting an EC2 instance. Go to the EC2 section of the AWS console and launch an instance. For the AMI, choose the Amazon Linux version. Also, choose to create an SSH key-pair so that you can login. Check the “Allow SSH traffic from” box and choose “My IP”. Choose the default values for everything else. Launch the instance. When the instance is running, go to the EC2 instance list and choose Connect in the top right corner. Follow the directions to login to your EC2 instance.
We need to prepare our EC2 instance to be able to run the HAPI FHIR JPA Server on it:
sudo yum update -y
sudo yum install -y docker
sudo service docker start
sudo usermod -a -G docker ec2-user
Now log out out the ec2 instance and back in to allow docker to update permissions.
docker pull hapiproject/hapi:latest
docker run -p 8080:8080 hapiproject/hapi:latest
Follow this AWS documentation to add your computers IP address to the inbound rules for the EC2 instance you just created. You will need this to go to the HAPI FHIR server in your browser.
You should now be able to go to http://<your-ec2-instance-public-ip>.compute-1.amazonaws.com:8080/ and see the Home screen for your FHIR server.
Click around and see what the HAPI FHIR server is all about!




Leave a Reply