According to the FHIR specification, any conformant server must be able to export a Conformance statement, which indicates all of the resource types and potential operations that the server supports.

HAPI provides a Maven plugin called "Tinder" which is able to automatically generate a client based on that conformance statement.

Client Generation

The following example shows a simple Maven plugin which builds a client for the Health Intersections reference server.

Note that as of HAPI 0.8, you need to add a dependency to the plugin containing the version of FHIR you are building custom structures against.


This example will create a class called ca.uhn.hitest.HiTest which has methods to invoke the various server operations.

It is then possible to use this client as simply as:

// Instantiate the client
FhirContext ctx = new FhirContext(Patient.class);
IRestfulClientFactory clientFactory = ctx.newRestfulClientFactory();
ClientClass client = clientFactory.newClient(ClientClass.class, "");

// Invoke the client
Bundle bundle = client.searchPatientByGender(new StringDt("M"));

// Prints: 50

Patient patientOne = (Patient) bundle.getEntries().get(0).getResource();
// Prints: Chalmers