Interface Repository


@Beta public interface Repository

This API is under-going active development, so it should be considered beta-level.

This interface is a Java rendition of the FHIR REST API. All FHIR operations are defined at the HTTP level, which is convenient from the specification point-of-view since FHIR is built on top of web standards. This does mean that a few HTTP specific considerations, such as transmitting side-band information through the HTTP headers, bleeds into this API.

One particularly odd case are FHIR Bundle links. The specification describes these as opaque to the end-user, so a given FHIR repository implementation must be able to resolve those directly. See link(Class, String)

This interface also chooses to ignore return headers for most cases, preferring to return the Java objects directly. In cases where this is not possible, or the additional headers are crucial information, HAPI's MethodOutcome is used.

Implementations of this interface should prefer to throw the exceptions derived from BaseServerResponseException All operations may throw AuthenticationException, ForbiddenOperationException, or InternalErrorException in addition to operation-specific exceptions.

If a given operation is not supported, implementations should throw an NotImplementedOperationException. The capabilities operation, if supported, should return the set of supported interactions. If capabilities is not supported, the components in this repository will try to invoke operations with "sensible" defaults. For example, by using the standard FHIR search parameters. Discussion is on-going to determine what a "sensible" minimal level of support for interactions should be.

See Also:
  • Method Details

    • read

      default <T extends IBaseResource, I extends IIdType> T read(Class<T> resourceType, I id)
      Reads a resource from the repository
      Type Parameters:
      T - a Resource type
      I - an Id type
      Parameters:
      resourceType - the class of the Resource type to read
      id - the id of the Resource to read
      Returns:
      the Resource
      See Also:
    • read

      <T extends IBaseResource, I extends IIdType> T read(Class<T> resourceType, I id, Map<String,String> headers)
      Reads a Resource from the repository
      Type Parameters:
      T - a Resource type
      I - an Id type
      Parameters:
      resourceType - the class of the Resource type to read
      id - the id of the Resource to read
      headers - headers for this request, typically key-value pairs of HTTP headers
      Returns:
      the Resource
      See Also:
    • create

      default <T extends IBaseResource> MethodOutcome create(T resource)
      Creates a Resource in the repository
      Type Parameters:
      T - a Resource type
      Parameters:
      resource - the Resource to create
      Returns:
      a MethodOutcome with the id of the created Resource
      See Also:
    • create

      <T extends IBaseResource> MethodOutcome create(T resource, Map<String,String> headers)
      Creates a Resource in the repository
      Type Parameters:
      T - a Resource type
      Parameters:
      resource - the Resource to create
      headers - headers for this request, typically key-value pairs of HTTP headers
      Returns:
      a MethodOutcome with the id of the created Resource
      See Also:
    • patch

      default <I extends IIdType, P extends IBaseParameters> MethodOutcome patch(I id, P patchParameters)
      Patches a Resource in the repository
      Type Parameters:
      I - an Id type
      P - a Parameters type
      Parameters:
      id - the id of the Resource to patch
      patchParameters - parameters describing the patches to apply
      Returns:
      a MethodOutcome with the id of the patched resource
      See Also:
    • patch

      default <I extends IIdType, P extends IBaseParameters> MethodOutcome patch(I id, P patchParameters, Map<String,String> headers)
      Patches a Resource in the repository
      Type Parameters:
      I - an Id type
      P - a Parameters type
      Parameters:
      id - the id of the Resource to patch
      patchParameters - parameters describing the patches to apply
      headers - headers for this request, typically key-value pairs of HTTP headers
      Returns:
      a MethodOutcome with the id of the patched resource
      See Also:
    • update

      default <T extends IBaseResource> MethodOutcome update(T resource)
      Updates a Resource in the repository
      Type Parameters:
      T - a Resource type
      Parameters:
      resource - the Resource to update
      Returns:
      a MethodOutcome with the id of the updated Resource
      See Also:
    • update

      <T extends IBaseResource> MethodOutcome update(T resource, Map<String,String> headers)
      Updates a Resource in the repository
      Type Parameters:
      T - a Resource type
      Parameters:
      resource - the Resource to update
      headers - headers for this request, typically key-value pairs of HTTP headers
      Returns:
      a MethodOutcome with the id of the updated Resource
      See Also:
    • delete

      default <T extends IBaseResource, I extends IIdType> MethodOutcome delete(Class<T> resourceType, I id)
      Deletes a Resource in the repository
      Type Parameters:
      T - a Resource type
      I - an Id type
      Parameters:
      resourceType - the class of the Resource type to delete
      id - the id of the Resource to delete
      Returns:
      a MethodOutcome with the id of the deleted resource
      See Also:
    • delete

      <T extends IBaseResource, I extends IIdType> MethodOutcome delete(Class<T> resourceType, I id, Map<String,String> headers)
      Deletes a Resource in the repository
      Type Parameters:
      T - a Resource type
      I - an Id type
      Parameters:
      resourceType - the class of the Resource type to delete
      id - the id of the Resource to delete
      headers - headers for this request, typically key-value pairs of HTTP headers
      Returns:
      a MethodOutcome with the id of the deleted resource
      See Also:
    • search

      default <B extends IBaseBundle, T extends IBaseResource> B search(Class<B> bundleType, Class<T> resourceType, Map<String,List<IQueryParameterType>> searchParameters)
      Searches this repository
      Type Parameters:
      B - a Bundle type
      T - a Resource type
      Parameters:
      bundleType - the class of the Bundle type to return
      resourceType - the class of the Resource type to search
      searchParameters - the searchParameters for this search
      Returns:
      a Bundle with the results of the search
      See Also:
    • search

      <B extends IBaseBundle, T extends IBaseResource> B search(Class<B> bundleType, Class<T> resourceType, Map<String,List<IQueryParameterType>> searchParameters, Map<String,String> headers)
      Searches this repository
      Type Parameters:
      B - a Bundle type
      T - a Resource type
      Parameters:
      bundleType - the class of the Bundle type to return
      resourceType - the class of the Resource type to search
      searchParameters - the searchParameters for this search
      headers - headers for this request, typically key-value pairs of HTTP headers
      Returns:
      a Bundle with the results of the search
      See Also:
    • link

      default <B extends IBaseBundle> B link(Class<B> bundleType, String url)
      Reads a Bundle from a link on this repository This is typically used for paging during searches
      Type Parameters:
      B - a Bundle type
      Parameters:
      url - the url of the Bundle to load
      Returns:
      a Bundle
      See Also:
    • link

      default <B extends IBaseBundle> B link(Class<B> bundleType, String url, Map<String,String> headers)
      Reads a Bundle from a link on this repository This is typically used for paging during searches
      Type Parameters:
      B - a Bundle type
      Parameters:
      url - the url of the Bundle to load
      headers - headers for this request, typically key-value pairs of HTTP headers
      Returns:
      a Bundle
      See Also:
    • capabilities

      default <C extends IBaseConformance> C capabilities(Class<C> resourceType)
      Returns the CapabilityStatement/Conformance metadata for this repository
      Type Parameters:
      C - a CapabilityStatement/Conformance type
      Parameters:
      resourceType - the class of the CapabilityStatement/Conformance to return
      Returns:
      a CapabilityStatement/Conformance with the repository's metadata
      See Also:
    • capabilities

      default <C extends IBaseConformance> C capabilities(Class<C> resourceType, Map<String,String> headers)
      Returns the CapabilityStatement/Conformance metadata for this repository
      Type Parameters:
      C - a CapabilityStatement/Conformance type
      Parameters:
      resourceType - the class of the CapabilityStatement/Conformance to return
      headers - headers for this request, typically key-value pairs of HTTP headers
      Returns:
      a CapabilityStatement/Conformance with the repository's metadata
      See Also:
    • transaction

      default <B extends IBaseBundle> B transaction(B transaction)
      Performs a transaction or batch on this repository
      Type Parameters:
      B - a Bundle type
      Parameters:
      transaction - a Bundle with the transaction/batch
      Returns:
      a Bundle with the results of the transaction/batch
      See Also:
    • transaction

      default <B extends IBaseBundle> B transaction(B transaction, Map<String,String> headers)
      Performs a transaction or batch on this repository
      Type Parameters:
      B - a Bundle type
      Parameters:
      transaction - a Bundle with the transaction/batch
      headers - headers for this request, typically key-value pairs of HTTP headers
      Returns:
      a Bundle with the results of the transaction/batch
      See Also:
    • invoke

      default <R extends IBaseResource, P extends IBaseParameters> R invoke(String name, P parameters, Class<R> returnType)
      Invokes a server-level operation on this repository that returns a Resource
      Type Parameters:
      R - a Resource type to return
      P - a Parameters type for operation parameters
      Parameters:
      name - the name of the operation to invoke
      parameters - the operation parameters
      returnType - the class of the Resource the operation returns
      Returns:
      the results of the operation
      See Also:
    • invoke

      default <R extends IBaseResource, P extends IBaseParameters> R invoke(String name, P parameters, Class<R> returnType, Map<String,String> headers)
      Invokes a server-level operation on this repository that returns a Resource
      Type Parameters:
      R - a Resource type to return
      P - a Parameters type for operation parameters
      Parameters:
      name - the name of the operation to invoke
      parameters - the operation parameters
      returnType - the class of the Resource the operation returns
      headers - headers for this request, typically key-value pairs of HTTP headers
      Returns:
      the results of the operation
      See Also:
    • invoke

      default <P extends IBaseParameters> MethodOutcome invoke(String name, P parameters)
      Invokes a server-level operation on this repository
      Type Parameters:
      P - a Parameters type for operation parameters
      Parameters:
      name - the name of the operation to invoke
      parameters - the operation parameters
      Returns:
      a MethodOutcome with a status code
      See Also:
    • invoke

      default <P extends IBaseParameters> MethodOutcome invoke(String name, P parameters, Map<String,String> headers)
      Invokes a server-level operation on this repository
      Type Parameters:
      P - a Parameters type for operation parameters
      Parameters:
      name - the name of the operation to invoke
      parameters - the operation parameters
      headers - headers for this request, typically key-value pairs of HTTP headers
      Returns:
      a MethodOutcome with a status code
      See Also:
    • invoke

      default <R extends IBaseResource, P extends IBaseParameters, T extends IBaseResource> R invoke(Class<T> resourceType, String name, P parameters, Class<R> returnType)
      Invokes a type-level operation on this repository that returns a Resource
      Type Parameters:
      R - a Resource type to return
      P - a Parameters type for operation parameters
      T - a Resource type to do the invocation for
      Parameters:
      resourceType - the class of the Resource to do the invocation for
      name - the name of the operation to invoke
      parameters - the operation parameters
      returnType - the class of the Resource the operation returns
      Returns:
      the results of the operation
      See Also:
    • invoke

      <R extends IBaseResource, P extends IBaseParameters, T extends IBaseResource> R invoke(Class<T> resourceType, String name, P parameters, Class<R> returnType, Map<String,String> headers)
      Invokes a type-level operation on this repository that returns a Resource
      Type Parameters:
      R - a Resource type to return
      P - a Parameters type for operation parameters
      T - a Resource type to do the invocation for
      Parameters:
      resourceType - the class of the Resource to do the invocation for
      name - the name of the operation to invoke
      parameters - the operation parameters
      returnType - the class of the Resource the operation returns
      headers - headers for this request, typically key-value pairs of HTTP headers
      Returns:
      the results of the operation
      See Also:
    • invoke

      default <P extends IBaseParameters, T extends IBaseResource> MethodOutcome invoke(Class<T> resourceType, String name, P parameters)
      Invokes a type-level operation on this repository
      Type Parameters:
      P - a Parameters type for operation parameters
      T - a Resource type to do the invocation for
      Parameters:
      resourceType - the class of the Resource to do the invocation for
      name - the name of the operation to invoke
      parameters - the operation parameters
      Returns:
      a MethodOutcome with a status code
      See Also:
    • invoke

      default <P extends IBaseParameters, T extends IBaseResource> MethodOutcome invoke(Class<T> resourceType, String name, P parameters, Map<String,String> headers)
      Invokes a type-level operation on this repository
      Type Parameters:
      P - a Parameters type for operation parameters
      T - a Resource type to do the invocation for
      Parameters:
      resourceType - the class of the Resource to do the invocation for
      name - the name of the operation to invoke
      parameters - the operation parameters
      headers - headers for this request, typically key-value pairs of HTTP headers
      Returns:
      a MethodOutcome with a status code
      See Also:
    • invoke

      default <R extends IBaseResource, P extends IBaseParameters, I extends IIdType> R invoke(I id, String name, P parameters, Class<R> returnType)
      Invokes an instance-level operation on this repository that returns a Resource
      Type Parameters:
      R - a Resource type to return
      P - a Parameters type for operation parameters
      I - an Id type
      Parameters:
      id - the id of the Resource to do the invocation on
      name - the name of the operation to invoke
      parameters - the operation parameters
      returnType - the class of the Resource the operation returns
      Returns:
      the results of the operation
      See Also:
    • invoke

      <R extends IBaseResource, P extends IBaseParameters, I extends IIdType> R invoke(I id, String name, P parameters, Class<R> returnType, Map<String,String> headers)
      Invokes an instance-level operation on this repository that returns a Resource
      Type Parameters:
      R - a Resource type to return
      P - a Parameters type for operation parameters
      I - an Id type
      Parameters:
      id - the id of the Resource to do the invocation on
      name - the name of the operation to invoke
      parameters - the operation parameters
      returnType - the class of the Resource the operation returns
      headers - headers for this request, typically key-value pairs of HTTP headers
      Returns:
      the results of the operation
      See Also:
    • invoke

      default <P extends IBaseParameters, I extends IIdType> MethodOutcome invoke(I id, String name, P parameters)
      Invokes an instance-level operation on this repository
      Type Parameters:
      P - a Parameters type for operation parameters
      I - an Id type
      Parameters:
      id - the id of the Resource to do the invocation on
      name - the name of the operation to invoke
      parameters - the operation parameters
      Returns:
      a MethodOutcome with a status code
      See Also:
    • invoke

      default <P extends IBaseParameters, I extends IIdType> MethodOutcome invoke(I id, String name, P parameters, Map<String,String> headers)
      Invokes an instance-level operation on this repository
      Type Parameters:
      P - a Parameters type for operation parameters
      I - an Id type
      Parameters:
      id - the id of the Resource to do the invocation on
      name - the name of the operation to invoke
      parameters - the operation parameters
      headers - headers for this request, typically key-value pairs of HTTP headers
      Returns:
      a MethodOutcome with a status code
      See Also:
    • history

      default <B extends IBaseBundle, P extends IBaseParameters> B history(P parameters, Class<B> returnType)
      Returns a Bundle with server-level history for this repository
      Type Parameters:
      B - a Bundle type to return
      P - a Parameters type for input parameters
      Parameters:
      parameters - the parameters for this history interaction
      returnType - the class of the Bundle type to return
      Returns:
      a Bundle with the server history
      See Also:
    • history

      default <B extends IBaseBundle, P extends IBaseParameters> B history(P parameters, Class<B> returnType, Map<String,String> headers)
      Returns a Bundle with server-level history for this repository
      Type Parameters:
      B - a Bundle type to return
      P - a Parameters type for input parameters
      Parameters:
      parameters - the parameters for this history interaction
      returnType - the class of the Bundle type to return
      headers - headers for this request, typically key-value pairs of HTTP headers
      Returns:
      a Bundle with the server history
      See Also:
    • history

      default <B extends IBaseBundle, P extends IBaseParameters, T extends IBaseResource> B history(Class<T> resourceType, P parameters, Class<B> returnType)
      Returns a Bundle with type-level history for this repository
      Type Parameters:
      B - a Bundle type to return
      P - a Parameters type for input parameters
      T - a Resource type to produce history for
      Parameters:
      resourceType - the class of the Resource type to produce history for
      parameters - the parameters for this history interaction
      returnType - the class of the Bundle type to return
      Returns:
      a Bundle with the type history
      See Also:
    • history

      default <B extends IBaseBundle, P extends IBaseParameters, T extends IBaseResource> B history(Class<T> resourceType, P parameters, Class<B> returnType, Map<String,String> headers)
      Returns a Bundle with type-level history for this repository
      Type Parameters:
      B - a Bundle type to return
      P - a Parameters type for input parameters
      T - a Resource type to produce history for
      Parameters:
      resourceType - the class of the Resource type to produce history for
      parameters - the parameters for this history interaction
      returnType - the class of the Bundle type to return
      headers - headers for this request, typically key-value pairs of HTTP headers
      Returns:
      a Bundle with the type history
      See Also:
    • history

      default <B extends IBaseBundle, P extends IBaseParameters, I extends IIdType> B history(I id, P parameters, Class<B> returnType)
      Returns a Bundle with instance-level history
      Type Parameters:
      B - a Bundle type to return
      P - a Parameters type for input parameters
      I - an Id type for the Resource to produce history for
      Parameters:
      id - the id of the Resource type to produce history for
      parameters - the parameters for this history interaction
      returnType - the class of the Bundle type to return
      Returns:
      a Bundle with the instance history
      See Also:
    • history

      default <B extends IBaseBundle, P extends IBaseParameters, I extends IIdType> B history(I id, P parameters, Class<B> returnType, Map<String,String> headers)
      Returns a Bundle with instance-level history
      Type Parameters:
      B - a Bundle type to return
      P - a Parameters type for input parameters
      I - an Id type for the Resource to produce history for
      Parameters:
      id - the id of the Resource type to produce history for
      parameters - the parameters for this history interaction
      returnType - the class of the Bundle type to return
      headers - headers for this request, typically key-value pairs of HTTP headers
      Returns:
      a Bundle with the instance history
      See Also:
    • fhirContext

      Returns the FhirContext used by the repository Practically, implementing FHIR functionality with the HAPI toolset requires a FhirContext. In particular for things like version independent code. Ideally, a user could which FHIR version a repository was configured for using things like the CapabilityStatement. In practice, that's not widely implemented (yet) and it's expensive to create a new context with every call. We will probably revisit this in the future.
      Returns:
      a FhirContext