Build Status
Coverage Status
Maven Central
Apache 2.0 Licensed

This is the homepage for the HAPI-FHIR library. We are developing an open-source implementation of the FHIR specification in Java. FHIR (Fast Healthcare Interoperability Resources) is a specification for exchanging healthcare data in a modern and developer friendly way.

Note that this is the home for the FHIR version of HAPI. If you are looking for HL7 v2 support, click here.

Demonstration/Test Page

A public test server is now operating at http://hapi.fhir.org. This server is built entirely using components of HAPI-FHIR and demonstrates all of its capabilities. This server is also entirely open source. You can host your own copy by following instructions on our JPA Server documentation.

Commercial Support

Commercial support for HAPI FHIR is available through Smile CDR.

Announcements

Nov 12, 2018 - HAPI FHIR 3.6.0 (Food) Released - The next release of HAPI has now been uploaded to the Maven repos and GitHub's releases section.

This release brings us back to our regular 3 month release cycle (although we're only two months after the last release, which was delayed more than we were hoping). This also marks the beginning of codenamed major releases. Our first codename is Food, and we will be following the popular (and admittedly unoriginal) strategy of using the next letter in the alphabet for each release.

As always, see the changelog for a full list of changes. Notable changes include:

  • The FHIR R4 structures have been upgraded to the latest (3.6.0) version of the structures. This marks an exciting (but pointless) milestone that HAPI FHIR and FHIR itself have the same version number!
  • The JPA Server migrator tool has been enhanced so that it is now possible to run a rolling migration from 3.4.0 to 3.6.0 instead of needing to incur a long downtime while the indexes are rebuilt. See this link for details. In addition, the migrator can now migrate HAPI FHIR 3.3.0 as well. This tool now also operates in a multithreaded way, meaning that it can run migrations much faster in systems with a lot of data.
  • A new custom FHIR operation has been added, allowing subscriptions to be manually triggered/retriggered. This means that it is possible to cause a subscription to process a resource in the database as though that resource had been updated, without actually updating it.
  • The JPA SearchCoordinator now pre-fetches only the first few pages of a search by default instead of pre-fetching all possible results. This makes searches dramatically more efficient in servers where users commonly perform searches that could potentially return many pages but only actually load the first few.
  • A new JPA sample project has been added. This sample has existed for a while, but this is now the offical "reference" project for anyone looking to get started with HAPI FHIR JPA.

Thanks to everyone who contributed to this release!

- James Agnew



Sep 17, 2018 - HAPI FHIR 3.5.0 Released - The next release of HAPI has now been uploaded to the Maven repos and GitHub's releases section.

This release is happening a little bit later than we had hoped. This release features a complete reworking of the way that search indexes in the JPA server work, as well as a new database migration tool that can be used to migrate to a new version of HAPI FHIR. Testing these features ended up taking longer than we had hoped, but we think it will be worth the wait.

As always, see the changelog for a full list of changes. Notable changes include:

  • HAPI FHIR now works correctly and is tested on Java 9 and 10, and continues to support Java 8. Java 9 introduces a new module system that meant a lot of additional testing and build tweaks were required in order to get HAPI FHIR working on that platform. Future migrations do not look like they will be as difficult, and we anticipate supporting current release versions of Java as they come out.
  • A new database migration tool has been added to the HAPI FHIR CLI. This tool allows administrators to automatically upgrade an existing database schema from a previous version of HAPI FHIR (currently only HAPI FHIR 3.4.0 is supported) to the latest version. See the command documentation for more information.
  • The JPA server mechanism for indexing resources has been completely reworked to index based on complex hashes of data. This change should have no user-visible effects, but it does reduce the total size of the database and improve search performance in many cases. It also lays the groundwork for some other features we have planned, including native JPA server multitenancy and column-level encryption.
  • Performance in the JPA server has been significantly improved when fetching large pages of data (e.g. search results or history operations containing 100+ resources in one page). This work comes thanks to a collaboration between HAPI FHIR and the US National Institutes for Health (NIH).
  • Support for LOINC has been further improved, thanks to an ongoing collaboration between HAPI FHIR and the Regenstrief Institute.

Note that this version does not include an updated set of FHIR R4 resources. The previous versions are still included. This is because the latest resources have a number of changes that break the HAPI FHIR build in fairly fundamental ways (e.g. compartment definitions have changes to using a FHIRPath expression that requires a resource resolution, a new validation rule has been added to require narratives across the board, etc.). Work is ongoing on addressing these changes, but as a result we decided to not delay the release any further. A point release should be available soon with updated definitions.

Thanks to everyone who contributed to this release!

- James Agnew



What is HAPI FHIR?

HAPI FHIR is a simple-but-powerful library for adding FHIR messaging to your application. It is pure Java (1.6+ compatible), and licensed under the business-friendly Apache Software License, version 2.0.

Some Ways You Can Use HAPI FHIR

HAPI is designed with one main intent: providing a flexible way of adding FHIR capability to applications. We at University Health Network developed HAPI-FHIR to allow us to build up our own unified FHIR RESTful server which exposes data backed by a number of systems and repositories, so it is designed to be flexible above all else.

The library is designed to support several main usage patterns:

Fluent Interface

The HAPI API is designed to allow interaction with FHIR model objects using a convenient Fluent Interface.

Patient patient = new Patient();
patient.addIdentifier().setUse(OFFICIAL).setSystem("urn:fake:mrns").setValue("7000135");
patient.addIdentifier().setUse(SECONDARY).setSystem("urn:fake:otherids").setValue("3287486");

patient.addName().addFamily("Smith").addGiven("John").addGiven("Q").addSuffix("Junior");

patient.setGender(AdministrativeGenderEnum.MALE);

Encoding Support

Both XML and JSON encoding are suported natively using a simple API to pick between them. XML support is built on top of the lightning-fast STaX/JSR 173 API, and JSON support is provided using Google Gson.

FhirContext ctx = FhirContext.forDstu2();
String xmlEncoded = ctx.newXmlParser().encodeResourceToString(patient);
String jsonEncoded = ctx.newJsonParser().encodeResourceToString(patient);

Easy RESTful Client and Servers

Creating clients is simple and uses an annotation based format that will be familiar to users of JAX-WS.

public interface MyClientInterface extends IRestfulClient
{
  /** A FHIR search */
  @Search
  public List<Patient> findPatientsByIdentifier(@RequiredParam(name="identifier") IdentifierDt theIdentifier);

  /** A FHIR create */
  @Create
  public MethodOutcome createPatient(@ResourceParam Patient thePatient);
}

Using this client is as simple as:

MyClientInterface client = ctx.newRestfulClient(MyClientInterface.class, "http://foo/fhir");
IdentifierDt searchParam = new IdentifierDt("urn:someidentifiers", "7000135");
List<Patient> clients = client.findPatientsByIdentifier(searchParam);

Back to top

Reflow Maven skin by Andrius Velykis.