Introduction

HAPI FHIR is an open source implementation of the HL7 FHIR standard for healthcare interoperability.

Getting Started

The easiest way to get started with HAPI FHIR is to use the HAPI FHIR JPA Server Starter Project.

I created a fork of the repository and then cloned the fork:

git clone git@github.com:Robinyo/hapi-fhir-jpaserver-starter.git
cd ~/hapi-fhir-jpaserver-starter

And I configured Git to sync the fork with the upstream repository:

git remote add upstream git@github.com:hapifhir/hapi-fhir-jpaserver-starter.git

To verify the new upstream repository you have specified for your fork:

git remote -v
origin   git@github.com:Robinyo/hapi-fhir-jpaserver-starter.git (fetch)
origin	 git@github.com:Robinyo/hapi-fhir-jpaserver-starter.git (push)
upstream git@github.com:hapifhir/hapi-fhir-jpaserver-starter.git (fetch)
upstream git@github.com:hapifhir/hapi-fhir-jpaserver-starter.git (push)

You should see the URL for your fork as origin, and the URL for the upstream repository as upstream.

Docker Compose

I created a Docker Compose configuration file, as follows:

services:

  postgres:
    image: postgres:latest
    container_name: postgres
    restart: always
    environment:
      POSTGRES_DB: "hapi"
      POSTGRES_USER: "admin"
      POSTGRES_PASSWORD: "admin"
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data

  hapi-fhir:
    build: .
    container_name: hapi-fhir
    restart: on-failure
    environment:
      SPRING_DATASOURCE_URL: "jdbc:postgresql://postgres:5432/hapi"
      SPRING_DATASOURCE_USERNAME: "admin"
      SPRING_DATASOURCE_PASSWORD: "admin"
      SPRING_DATASOURCE_DRIVERCLASSNAME: "org.postgresql.Driver"
      SPRING_JPA_PROPERTIES_HIBERNATE_DIALECT: "ca.uhn.fhir.jpa.model.dialect.HapiFhirPostgresDialect"
    ports:
      - "8080:8080"
    configs:
      - source: hapi
        target: /app/config/application.yaml

volumes:
  postgres_data:
    driver: local

configs:
  hapi:
    file: ./hapi.application.yaml

See: docker-compose-fhir-au.yml

I updated the project's application.yml, as follows:

spring:
  datasource:
    url: ${SPRING_DATASOURCE_URL}
    username: ${SPRING_DATASOURCE_USERNAME}
    password: ${SPRING_DATASOURCE_PASSWORD}
    driverClassName: ${SPRING_DATASOURCE_DRIVERCLASSNAME}
    max-active: 15
    
  jpa:
    properties:
      hibernate.dialect: ${SPRING_JPA_PROPERTIES_HIBERNATE_DIALECT}

To build the project:

docker compose -f docker-compose-fhir-au.yml build

To create and start all the services in the configuration file:

docker compose -f docker-compose-fhir-au.yml up

Navigate to the Welcome page:

http://localhost:8080

You should see something like:

To stop the services:

docker compose -f docker-compose-fhir-au.yml stop

To remove the services:

docker compose -f docker-compose-fhir-au.yml down

To remove the data volume:

docker volume rm hapi-fhir-jpaserver-starter_postgres_data

To restart the services:

docker compose -f docker-compose-fhir-au.yml up

Web Testpage Overlay

You can customise the Web Testpage Overlay by modifying the templates in the src/main/webapp/WEB-INF/templates directory:

What's Next

In the next post, we'll we'll configure HAPI FHIR to install a FHIR Implementation Guide.

Source Code:
Resources: