Build Status
Coverage Status
Maven Central
VersionEye
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://fhirtest.uhn.ca. 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.

Announcements

November 11, 2016 - HAPI FHIR 2.1 Released - The next release of HAPI has now been uploaded to the Maven repos and GitHub's releases section.

This release brings several primary changes:

  • STU3 definitions have been updated to the latest definitions (FHIR 1.7.0 - SVN 10129)
  • Add support for FHIR Patch operation (thanks to Peter Girard of McKesson for his help on this!)
  • Android library has been streamlined to use the OkHttp client by default (no more fighting with out-of-date Apache HttpClient. Thanks to Matt Clarke of Orion Health for his help on this!)
  • The STU3 client now supports both the Conformance resource (which is going away) and the new CapabilityStatement (which replaces it). This should allow for a bridge while servers are migrated to the new resource type being returned by the <code>/metadata</code> endpoint.

This release also brings a number of bugfixes and also quite a few enhancements. As always, the changelog has the full list of changes in this version. Among the enhancements in this release are:

As always, we welcome new contributions and contributors! Please feel free to get in touch if you are interested in getting involved with HAPI but don't know where to start.

- James Agnew



August 30, 2016 - HAPI FHIR 2.0 Released - The next release of HAPI has now been uploaded to the Maven repos and GitHub's releases section.

This release brings several primary changes:

  • The JSON parser used by HAPI's parser module has been switched from JSR353/JSONP to Google GSON. This should be an invisible change for most users (the only thing that broke for us was that a few extra spaces are inserted in pretty-printed encoding and this broke some overly sensitive unit tests). Gson is a much more active project than JSONP and should be better supported in the future.
  • STU3 definitions have been updated to the FHIR 1.6.0 2016 September Ballot Candidate definitions (aka the 2016 Baltimore Connectathon version).
  • Content-Types emitted by the library have been updated to use the new content type strings proposed for use as of STU3 (when using HAPI in STU3 mode). E.g. application/fhir+xml insead of the previous application/xml+fhir

This release also brings a number of bugfixes and also quite a few enhancements. As always, the changelog has the full list of changes in this version. Among the enhancements in this release are:

As always, we welcome new contributions and contributors! Please feel free to get in touch if you are interested in getting involved with HAPI but don't know where to start.

- 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.