Interface RequestConsumer

All Superinterfaces:
Predicate<RequestDetails>
All Known Implementing Classes:
FhirConsumer

public interface RequestConsumer extends Predicate<RequestDetails>
Consumer interface of FHIR requests. Plain providers or resource providers forward the request data received to an instance of this interface to be processed. This decouples request reception from request handling, so you can e.g. use the IHE resource providers outside of Apache Camel.

The request parameters may contain the following parameters entries indicating a "lazy-loading" mode on searches.

  • Constants.FHIR_REQUEST_SIZE_ONLY: if this entry is present, the requester expects only the result size to be returned in an parameter entry with the same name and calls handleSizeRequest(Object, Map) to do so. If possible, implementations should only request the result size from the backend rather than a complete result set.
  • Constants.FHIR_FROM_INDEX and Constants.FHIR_TO_INDEX: if these entries are present, the requester expects only the specified subset of the result. If possible, implementations should only request this result set from the backend rather than a complete result set.

Since:
3.1
Author:
Christian Ohr
  • Method Details

    • getFhirContext

      FhirContext getFhirContext()
      Returns:
      the FhirContext used by this consumer
    • test

      default boolean test(RequestDetails requestDetails)
      Returns true if this RequestConsumer can handle the provided FHIR payload
      Specified by:
      test in interface Predicate<RequestDetails>
      Parameters:
      requestDetails - FHIR requestDetails
      Returns:
      true if this RequestConsumer can handle the provided FHIR request, false otherwise
    • handleAction

      MethodOutcome handleAction(Object payload, Map<String,Object> headers)
      Handles a Create / Update / Validate / Delete action request.
      Parameters:
      payload - request payload
      headers - request parameters, e.g. search parameters
      Returns:
      result of the action execution
    • handleResourceRequest

      <R extends IBaseResource> R handleResourceRequest(Object payload, Map<String,Object> headers, Class<R> resultType)
      Handles the request for a resource
      Type Parameters:
      R - type of the returned resource
      Parameters:
      payload - request payload
      headers - request parameters, e.g. search parameters
      resultType - type of the returned resource
      Returns:
      resource to be returned
    • handleBundleRequest

      <R extends IBaseResource> List<R> handleBundleRequest(Object payload, Map<String,Object> headers)
      Handles the (search) request for a bundle, effectively being a list of resources.

      If supportsLazyLoading() returns true, the headers may contain Constants.FHIR_FROM_INDEX and Constants.FHIR_TO_INDEX entries, indicating that only a part of the result is requested. Implementations must return only the requested entries.

      Type Parameters:
      R - type of the returned resources contained in the bundle
      Parameters:
      payload - request payload
      headers - request parameters, e.g. search parameters or
      Returns:
      list of resources to be returned
    • handleBundleProviderRequest

      IBundleProvider handleBundleProviderRequest(Object payload, Map<String,Object> headers)
      Handles the request for a bundle provider, effectively constructing a list of resources. The returned IBundleProvider takes over the responsibility to fetch the required subset of the result, usually by indirectly calling handleBundleRequest(Object, Map) as required.
      Parameters:
      payload - request payload
      headers - request parameters, e.g. search parameters
      Returns:
      a bundle provider
    • handleTransactionRequest

      <T extends IBaseBundle> T handleTransactionRequest(Object payload, Map<String,Object> headers, Class<T> bundleClass)
      Handles transaction requests
      Parameters:
      payload - request payload
      headers - request parameters
      Returns:
      transaction response bundle
    • handleSizeRequest

      int handleSizeRequest(Object payload, Map<String,Object> headers)
      Optional method that request the result size of a bundle request. Only used for lazy bundle providers. The headers contain a Constants.FHIR_REQUEST_SIZE_ONLY entry flag. This method only needs to be implemented is supportsLazyLoading() returns true.
      Parameters:
      payload - request payload
      headers - request parameters
      Returns:
      transaction response bundle
    • supportsLazyLoading

      boolean supportsLazyLoading()
      Returns:
      returns true indicating that lazy loading of search results is supported, false otherwise.
    • getName

      default String getName()