5.11Customizing the CapabilityStatement


Per the FHIR specification, any compliant FHIR REST server must support the FHIR Capabilities operation. This operation is typically invoked by clients by requesting [baseUrl]/metadata from the server.

The Capabilities operation requires the server to return a valid CapabilityStatement resource describing the supported resources, operations, search parameters, and other capabilities of the server.

The HAPI FHIR RestfulServer will automatically generate a CapabilityStatement which describes its abilities.

You can customize the generated CapabiliityStatement by creating a server interceptor and registering it against the server. This interceptor should implement a hook method for the SERVER_CAPABILITY_STATEMENT_GENERATED pointcut.

An example is shown below:

public class CapabilityStatementCustomizer {

   public void customize(IBaseConformance theCapabilityStatement) {

      // Cast to the appropriate version
      CapabilityStatement cs = (CapabilityStatement) theCapabilityStatement;

      // Customize the CapabilityStatement as desired
         .setName("Acme FHIR Server")
         .setReleaseDateElement(new DateTimeType("2021-02-06"));