Class FhirConsumer<AuditDatasetType extends FhirAuditDataset>

java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.DefaultConsumer
org.openehealth.ipf.platform.camel.ihe.fhir.core.FhirConsumer<AuditDatasetType>
All Implemented Interfaces:
AutoCloseable, Predicate<RequestDetails>, Consumer, EndpointAware, HealthCheckAware, RouteAware, Service, ShutdownableService, HostedService, RouteIdAware, StatefulService, SuspendableService, RequestConsumer

public class FhirConsumer<AuditDatasetType extends FhirAuditDataset> extends org.apache.camel.support.DefaultConsumer implements SuspendableService, RequestConsumer
FHIR consumer, which is an implementation of a RequestConsumer that handles requests by sending the request data and parameters into a Camel route and returning the result of the route processing.
Since:
3.1
Author:
Christian Ohr
  • Constructor Details

  • Method Details

    • test

      public boolean test(RequestDetails requestDetails)
      Description copied from interface: RequestConsumer
      Returns true if this RequestConsumer can handle the provided FHIR payload
      Specified by:
      test in interface Predicate<AuditDatasetType extends FhirAuditDataset>
      Specified by:
      test in interface RequestConsumer
      Parameters:
      requestDetails - FHIR requestDetails
      Returns:
      true if this RequestConsumer can handle the provided FHIR request, false otherwise
    • getName

      public String getName()
      Specified by:
      getName in interface RequestConsumer
    • getFhirContext

      public FhirContext getFhirContext()
      Specified by:
      getFhirContext in interface RequestConsumer
      Returns:
      the FhirContext used by this consumer
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class org.apache.camel.support.DefaultConsumer
      Throws:
      Exception
    • doStop

      protected void doStop() throws Exception
      Overrides:
      doStop in class org.apache.camel.support.DefaultConsumer
      Throws:
      Exception
    • getEndpoint

      Specified by:
      getEndpoint in interface EndpointAware
      Overrides:
      getEndpoint in class org.apache.camel.support.DefaultConsumer
    • handleResourceRequest

      public final <R extends IBaseResource> R handleResourceRequest(Object payload, Map<String,Object> inHeaders, Map<String,Object> outHeaders, Class<R> resultClass)
      This method can be called by IResourceProvider objects to send the received (and potentially handled) request further down a Camel route.
      Specified by:
      handleResourceRequest in interface RequestConsumer
      Type Parameters:
      R - Resource type being returned
      Parameters:
      payload - FHIR request content
      inHeaders - request parameters, e.g. search parameters
      outHeaders - map where Camel response headers will be copied into
      resultClass - class of the result resource
      Returns:
      result of processing the FHIR request in Camel
    • handleBundleRequest

      public <R extends IBaseResource> List<R> handleBundleRequest(Object payload, Map<String,Object> inHeaders, Map<String,Object> outHeaders)
      Description copied from interface: RequestConsumer
      Handles the (search) request for a bundle, effectively being a list of resources.

      If RequestConsumer.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.

      Specified by:
      handleBundleRequest in interface RequestConsumer
      Type Parameters:
      R - resource type
      Parameters:
      payload - request payload
      inHeaders - request parameters, e.g. search parameters
      outHeaders - map where Camel response headers will be copied into
      Returns:
      list of resources to be packaged into a bundle
    • handleBundleProviderRequest

      public IBundleProvider handleBundleProviderRequest(Object payload, Map<String,Object> headers, jakarta.servlet.http.HttpServletResponse httpServletResponse)
      Description copied from interface: RequestConsumer
      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 RequestConsumer.handleBundleRequest(Object, Map, Map) as required.
      Specified by:
      handleBundleProviderRequest in interface RequestConsumer
      Parameters:
      payload - request payload
      headers - request parameters, e.g. search parameters
      httpServletResponse - HTTP servlet response
      Returns:
      a bundle provider
    • handleTransactionRequest

      public <T extends IBaseBundle> T handleTransactionRequest(Object payload, Map<String,Object> inHeaders, Map<String,Object> outHeaders, Class<T> bundleClass)
      Description copied from interface: RequestConsumer
      Handles transaction requests
      Specified by:
      handleTransactionRequest in interface RequestConsumer
      Parameters:
      payload - request payload
      inHeaders - request parameters
      outHeaders - map where response headers will be copied into
      Returns:
      transaction response bundle
    • handleAction

      public MethodOutcome handleAction(Object payload, Map<String,Object> inHeaders, Map<String,Object> outHeaders)
      Description copied from interface: RequestConsumer
      Handles a Create / Update / Validate / Delete action request.
      Specified by:
      handleAction in interface RequestConsumer
      Parameters:
      payload - request payload
      inHeaders - request parameters, e.g. search parameters
      outHeaders - map where response headers will be copied into
      Returns:
      result of the action execution
    • handleSizeRequest

      public int handleSizeRequest(Object payload, Map<String,Object> headers)
      Description copied from interface: RequestConsumer
      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 RequestConsumer.supportsLazyLoading() returns true.
      Specified by:
      handleSizeRequest in interface RequestConsumer
      Parameters:
      payload - request payload
      headers - request parameters
      Returns:
      transaction response bundle
    • supportsLazyLoading

      public boolean supportsLazyLoading()
      Specified by:
      supportsLazyLoading in interface RequestConsumer
      Returns:
      returns true indicating that lazy loading of search results is supported, false otherwise.
    • handleInRoute

      protected <T> T handleInRoute(Object payload, Map<String,Object> inHeaders, Map<String,Object> outHeaders, Class<T> resultClass)
      Forwards the request to be handled into a Camel route
      Parameters:
      payload - request payload, will become the Camel message body
      inHeaders - request parameters, will be added to the Camel headers
      outHeaders - map where Camel response headers will be copied into
      resultClass - expected body type to be returned
      Returns:
      request result, type-converted into the required result class
    • runRoute

      protected Exchange runRoute(Object payload, Map<String,Object> headers)
    • getBundleProvider

      protected IBundleProvider getBundleProvider(Object payload, Map<String,Object> headers, jakarta.servlet.http.HttpServletResponse httpServletResponse)
      Returns the IBundleProvider, providing the matching bundles. Depending on FhirEndpointConfiguration.isLazyLoadBundles(), the bundle provider either eagerly fetches all matching bundles or fetches the requested subset on request.
      Parameters:
      payload - request payload
      headers - request headers
      Returns:
      resulting bundle provider