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

August 14, 2019 - HAPI FHIR 4.0.0 (Igloo) Released - The next release of HAPI has now been uploaded to the Maven repos and GitHub's releases section.

This release features a number of significant performance improvements, and has some notable changes:

  • A new consent framework called ConsentInterceptor that can be used to apply local consent directives and policies, and potentially filter or mask data has been added.
  • Initial support for draft FHIR R5 resources has been added.
  • Support for GraphQL and the _filter search parameter has been added.
  • The ability to perform cascading deletes has been added.

As always, see the changelog for a full list of changes. You can also watch the release webinar!

Thanks to everyone who contributed to this release!

- James Agnew



May 30, 2019 - HAPI FHIR 3.8.0 (Hippo) Released - The next release of HAPI has now been uploaded to the Maven repos and GitHub's releases section.

This release features a number of significant performance improvements, and has some notable changes:

  • A new interceptor framework has been added. Existing interceptors will continue to work, and no code changes are needed in order to use this new version, but existing interceptors can be modified to use the new framework and can then take advantage of even more functionality. Updated migration documentation will be produced in the coming weeks.
  • A security issue in the hapi-fhir-testpage-overlay (the web-based testing UI that powers hapi.fhir.org and can be embedded into other applications) has been corrected. Users of this module are recommended to upgrade right away.
  • The hapi-fhir-jpaserver-starter project now uses a properties file for much easier configuration. Please use this project as the basis for any new JPA Server projects, as we are deprecating the existing duplicate hapi-fhir-jpaserver-example project.
  • A number of improvements have been made to the validator.

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

Thanks to everyone who contributed to this release!

- James Agnew



Feb 6, 2019 - HAPI FHIR 3.7.0 (Gale) Released - The next release of HAPI has now been uploaded to the Maven repos and GitHub's releases section.

This release includes support for the now-completed FHIR R4 release (FHIR 4.0.0). It also brings support for Java 11, along with a big number of bugfixes and new features.

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

Thanks to everyone who contributed to this release!

- James Agnew



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



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);