5.11.1Customizing 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:

@Interceptor
public class CapabilityStatementCustomizer {

   @Hook(Pointcut.SERVER_CAPABILITY_STATEMENT_GENERATED)
   public void customize(IBaseConformance theCapabilityStatement) {

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

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

   }

}