Class FHIRClientImpl

  • All Implemented Interfaces:
    FHIRClient

    public class FHIRClientImpl
    extends java.lang.Object
    implements FHIRClient
    Provides an implementation of the FHIRClient interface, which can be used as a high-level API for invoking FHIR REST APIs.
    • Constructor Detail

      • FHIRClientImpl

        public FHIRClientImpl​(java.util.Properties props)
                       throws java.lang.Exception
        Throws:
        java.lang.Exception
    • Method Detail

      • capabilities

        public FHIRResponse capabilities​(FHIRRequestHeader... headers)
                                  throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes the 'capabilities' FHIR REST API operation to get a capability statement for the target server.
        Specified by:
        capabilities in interface FHIRClient
        Parameters:
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains a Conformance object which describes the FHIR Server's capabilities
        Throws:
        java.lang.Exception
      • create

        public FHIRResponse create​(Resource resource,
                                   FHIRRequestHeader... headers)
                            throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes the 'create' FHIR REST API operation to create a new resource with a server assigned id.
        Specified by:
        create in interface FHIRClient
        Parameters:
        resource - the FHIR resource to be created
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'create' operation
        Throws:
        java.lang.Exception
      • create

        public FHIRResponse create​(jakarta.json.JsonObject resource,
                                   FHIRRequestHeader... headers)
                            throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes the 'create' FHIR REST API operation to create a new resource with a server assigned id.
        Specified by:
        create in interface FHIRClient
        Parameters:
        resource - the resource (in the form of a JsonObject) to be created
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'create' operation
        Throws:
        java.lang.Exception
      • conditionalCreate

        public FHIRResponse conditionalCreate​(Resource resource,
                                              FHIRParameters parameters,
                                              FHIRRequestHeader... headers)
                                       throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes the 'conditional create' FHIR REST API operation to conditionally create a new resource with a server assigned id.
        Specified by:
        conditionalCreate in interface FHIRClient
        Parameters:
        resource - the FHIR resource to be created
        parameters - search-related query parameters to be included in the request
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'conditional create' operation
        Throws:
        java.lang.Exception
      • conditionalCreate

        public FHIRResponse conditionalCreate​(jakarta.json.JsonObject resource,
                                              FHIRParameters parameters,
                                              FHIRRequestHeader... headers)
                                       throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes the 'conditional create' FHIR REST API operation to conditionally create a new resource with a server assigned id.
        Specified by:
        conditionalCreate in interface FHIRClient
        Parameters:
        resource - the resource (in the form of a JsonObject) to be created
        parameters - search-related query parameters to be included in the request
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'conditional create' operation
        Throws:
        java.lang.Exception
      • update

        public FHIRResponse update​(Resource resource,
                                   FHIRRequestHeader... headers)
                            throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes the 'update' FHIR REST API operation to update an existing resource by its id (or create it if it is new).
        Specified by:
        update in interface FHIRClient
        Parameters:
        resource - the FHIR resource to be updated
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'update' operation
        Throws:
        java.lang.Exception
      • update

        public FHIRResponse update​(jakarta.json.JsonObject resource,
                                   FHIRRequestHeader... headers)
                            throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes the 'update' FHIR REST API operation to update an existing resource by its id (or create it if it is new).
        Specified by:
        update in interface FHIRClient
        Parameters:
        resource - the resource (in the form of a JsonObject) to be updated
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'update' operation
        Throws:
        java.lang.Exception
      • conditionalUpdate

        public FHIRResponse conditionalUpdate​(Resource resource,
                                              FHIRParameters parameters,
                                              FHIRRequestHeader... headers)
                                       throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes the 'conditional update' FHIR REST API operation to conditionally update an existing resource by its id (or create it if it is new).
        Specified by:
        conditionalUpdate in interface FHIRClient
        Parameters:
        resource - the FHIR resource to be created
        parameters - search-related query parameters to be included in the request
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'conditional update' operation
        Throws:
        java.lang.Exception
      • conditionalUpdate

        public FHIRResponse conditionalUpdate​(jakarta.json.JsonObject resource,
                                              FHIRParameters parameters,
                                              FHIRRequestHeader... headers)
                                       throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes the 'conditional update' FHIR REST API operation to conditionally update an existing resource by its id (or create it if it is new).
        Specified by:
        conditionalUpdate in interface FHIRClient
        Parameters:
        resource - the resource (in the form of a JsonObject) to be updated
        parameters - search-related query parameters to be included in the request
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'conditional update' operation
        Throws:
        java.lang.Exception
      • delete

        public FHIRResponse delete​(java.lang.String resourceType,
                                   java.lang.String resourceId,
                                   FHIRRequestHeader... headers)
                            throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes the 'delete' FHIR REST API operation to delete a resource.
        Specified by:
        delete in interface FHIRClient
        Parameters:
        resourceType - a string representing the name of the resource type to be deleted (e.g. "Patient")
        resourceId - the id of the resource to be deleted
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'delete' operation
        Throws:
        java.lang.Exception
      • conditionalDelete

        public FHIRResponse conditionalDelete​(java.lang.String resourceType,
                                              FHIRParameters parameters,
                                              FHIRRequestHeader... headers)
                                       throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes the 'conditional delete' FHIR REST API operation to conditionally delete a resource.
        Specified by:
        conditionalDelete in interface FHIRClient
        Parameters:
        resourceType - a string representing the name of the resource type to be deleted (e.g. "Patient")
        parameters - search-related query parameters to be included in the request
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'delete' operation
        Throws:
        java.lang.Exception
      • read

        public FHIRResponse read​(java.lang.String resourceType,
                                 java.lang.String resourceId,
                                 FHIRRequestHeader... headers)
                          throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes the 'read' FHIR REST API operation to read the current state of a resource.
        Specified by:
        read in interface FHIRClient
        Parameters:
        resourceType - a string representing the name of the resource type to be retrieved (e.g. "Patient")
        resourceId - the id of the resource to be retrieved
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'read' operation
        Throws:
        java.lang.Exception
      • vread

        public FHIRResponse vread​(java.lang.String resourceType,
                                  java.lang.String resourceId,
                                  java.lang.String versionId,
                                  FHIRRequestHeader... headers)
                           throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes the 'vread' FHIR REST API operation to read the state of a specific version of a resource.
        Specified by:
        vread in interface FHIRClient
        Parameters:
        resourceType - a string representing the name of the resource type to be retrieved (e.g. "Patient")
        resourceId - the id of the resource to be retrieved
        versionId - the version id of the resource to be retrieved
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'read' operation
        Throws:
        java.lang.Exception
      • history

        public FHIRResponse history​(java.lang.String resourceType,
                                    java.lang.String resourceId,
                                    FHIRParameters parameters,
                                    FHIRRequestHeader... headers)
                             throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes the type-level 'history' FHIR REST API operation to retrieve the change history for a particular resource type.
        Specified by:
        history in interface FHIRClient
        Parameters:
        resourceType - a string representing the name of the resource type to be retrieved (e.g. "Patient")
        resourceId - the id of the resource to be retrieved
        parameters - an optional collection of request parameters for the 'history' operation; may be specified as null if no parameters need to be passed to the 'history' operation
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'history' operation
        Throws:
        java.lang.Exception
      • history

        public FHIRResponse history​(FHIRParameters parameters,
                                    FHIRRequestHeader... headers)
                             throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes the system-level 'history' FHIR REST API operation to retrieve the change history for all resources.
        Specified by:
        history in interface FHIRClient
        Parameters:
        parameters - an optional collection of request parameters for the 'history' operation; may be specified as null if no parameters need to be passed to the 'history' operation
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'history' operation
        Throws:
        java.lang.Exception
      • search

        public FHIRResponse search​(java.lang.String resourceType,
                                   FHIRParameters parameters,
                                   FHIRRequestHeader... headers)
                            throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes the type-level 'search' FHIR REST API operation to search the resource type based on some filter criteria.
        Specified by:
        search in interface FHIRClient
        Parameters:
        resourceType - a string representing the name of the resource type to search for (e.g. "Patient")
        parameters - an optional collection of request parameters for the 'search' operation; may be specified as null if no parameters need to be passed to the 'search' operation
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'search' operation
        Throws:
        java.lang.Exception
      • _search

        public FHIRResponse _search​(java.lang.String resourceType,
                                    FHIRParameters parameters,
                                    FHIRRequestHeader... headers)
                             throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes the type-level 'search' FHIR REST API operation via HTTP POST.
        Specified by:
        _search in interface FHIRClient
        Parameters:
        resourceType - a string representing the name of the resource type to search for (e.g. "Patient")
        parameters - an optional collection of request parameters for the '_search' operation; may be specified as null if no parameters need to be passed to the '_search' operation; search parameters for this operation will go in the request body
        Returns:
        a FHIRResponse that contains the results of the '_search' operation
        Throws:
        java.lang.Exception
      • searchAll

        public FHIRResponse searchAll​(FHIRParameters parameters,
                                      boolean isPost,
                                      FHIRRequestHeader... headers)
                               throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes the system-level 'search' FHIR REST API operation to search across all resource types based on some filter criteria.
        Specified by:
        searchAll in interface FHIRClient
        Parameters:
        parameters - an optional collection of request parameters for the 'search-all' operation; may be specified as null if no parameters need to be passed to the 'search' operation; for Post, search parameters for this operation will go in the request body as FORM parameters for Get, search parameters for this operation will go in the request url as parameters
        Returns:
        a FHIRResponse that contains the results of the 'search-all' operation
        Throws:
        java.lang.Exception
      • validate

        public FHIRResponse validate​(Resource resource,
                                     FHIRRequestHeader... headers)
                              throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes the 'validate' FHIR extended operation.
        Specified by:
        validate in interface FHIRClient
        Parameters:
        resource - the resource to be validated
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'validate' operation
        Throws:
        java.lang.Exception
      • validate

        public FHIRResponse validate​(jakarta.json.JsonObject resource,
                                     FHIRRequestHeader... headers)
                              throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes the 'validate' FHIR extended operation.
        Specified by:
        validate in interface FHIRClient
        Parameters:
        resource - the resource (in the form of a JsonObject) to be validated
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'validate' operation
        Throws:
        java.lang.Exception
      • batch

        public FHIRResponse batch​(Bundle bundle,
                                  FHIRRequestHeader... headers)
                           throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes the 'batch/transaction' FHIR REST API operation for a request bundle of type 'batch'.
        Specified by:
        batch in interface FHIRClient
        Parameters:
        bundle - the Bundle containing the individual requests
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'batch/transaction' operation
        Throws:
        java.lang.Exception
      • transaction

        public FHIRResponse transaction​(Bundle bundle,
                                        FHIRRequestHeader... headers)
                                 throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes the 'batch/transaction' FHIR REST API operation for a request bundle of type 'transaction'.
        Specified by:
        transaction in interface FHIRClient
        Parameters:
        bundle - the Bundle containing the individual requests
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'batch/transaction' operation
        Throws:
        java.lang.Exception
      • invoke

        public FHIRResponse invoke​(java.lang.String operationName,
                                   FHIRParameters parameters,
                                   FHIRRequestHeader... headers)
                            throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes a FHIR extended operation at the system level via HTTP GET.
        Specified by:
        invoke in interface FHIRClient
        Parameters:
        operationName - name of the operation to be performed
        parameters - query parameters to use for the request
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'invoke' operation
        Throws:
        java.lang.Exception
      • invoke

        public FHIRResponse invoke​(java.lang.String operationName,
                                   Resource resource,
                                   FHIRRequestHeader... headers)
                            throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes a FHIR extended operation at the system level via HTTP POST.
        Specified by:
        invoke in interface FHIRClient
        Parameters:
        operationName - name of the operation to be performed
        resource - the FHIR resource to use as the input for the operation
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'invoke' operation
        Throws:
        java.lang.Exception
      • invoke

        public FHIRResponse invoke​(java.lang.String resourceType,
                                   java.lang.String operationName,
                                   FHIRParameters parameters,
                                   FHIRRequestHeader... headers)
                            throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes a FHIR extended operation at the type level via HTTP GET.
        Specified by:
        invoke in interface FHIRClient
        Parameters:
        resourceType - the FHIR resource type used in context for the operation
        operationName - name of the operation to be performed
        parameters - query parameters to use for the request
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'invoke' operation
        Throws:
        java.lang.Exception
      • invoke

        public FHIRResponse invoke​(java.lang.String resourceType,
                                   java.lang.String operationName,
                                   Resource resource,
                                   FHIRRequestHeader... headers)
                            throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes a FHIR extended operation at the type level via HTTP POST.
        Specified by:
        invoke in interface FHIRClient
        Parameters:
        resourceType - the FHIR resource type used in context for the operation
        operationName - name of the operation to be performed
        resource - the FHIR resource to use as the input for the operation
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'invoke' operation
        Throws:
        java.lang.Exception
      • invoke

        public FHIRResponse invoke​(java.lang.String resourceType,
                                   java.lang.String operationName,
                                   java.lang.String resourceId,
                                   FHIRParameters parameters,
                                   FHIRRequestHeader... headers)
                            throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes a FHIR extended operation at the instance level via HTTP GET.
        Specified by:
        invoke in interface FHIRClient
        Parameters:
        resourceType - the FHIR resource type used in context for the operation
        operationName - name of the operation to be performed
        resourceId - the FHIR resource instance used in context for the operation
        parameters - query parameters to use for the request
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'invoke' operation
        Throws:
        java.lang.Exception
      • invoke

        public FHIRResponse invoke​(java.lang.String resourceType,
                                   java.lang.String operationName,
                                   java.lang.String resourceId,
                                   Resource resource,
                                   FHIRRequestHeader... headers)
                            throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes a FHIR extended operation at the instance level via HTTP POST.
        Specified by:
        invoke in interface FHIRClient
        Parameters:
        resourceType - the FHIR resource type used in context for the operation
        operationName - name of the operation to be performed
        resourceId - the FHIR resource instance used in context for the operation
        resource - the FHIR resource to use as the input for the operation
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'invoke' operation
        Throws:
        java.lang.Exception
      • invoke

        public FHIRResponse invoke​(java.lang.String resourceType,
                                   java.lang.String operationName,
                                   java.lang.String resourceId,
                                   java.lang.String versionId,
                                   FHIRParameters parameters,
                                   FHIRRequestHeader... headers)
                            throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes a FHIR extended operation at the instance version level via HTTP GET.
        Specified by:
        invoke in interface FHIRClient
        Parameters:
        resourceType - the FHIR resource type used in context for the operation
        operationName - name of the operation to be performed
        resourceId - the FHIR resource instance used in context for the operation
        versionId - version of the FHIR resource instance used in context for the operation
        parameters - query parameters to use for the request
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'invoke' operation
        Throws:
        java.lang.Exception
      • invoke

        public FHIRResponse invoke​(java.lang.String resourceType,
                                   java.lang.String operationName,
                                   java.lang.String resourceId,
                                   java.lang.String versionId,
                                   Resource resource,
                                   FHIRRequestHeader... headers)
                            throws java.lang.Exception
        Description copied from interface: FHIRClient
        Invokes a FHIR extended operation at the instance version level via HTTP POST.
        Specified by:
        invoke in interface FHIRClient
        Parameters:
        resourceType - the FHIR resource type used in context for the operation
        operationName - name of the operation to be performed
        resourceId - the FHIR resource instance used in context for the operation
        versionId - version of the FHIR resource instance used in context for the operation
        resource - the FHIR resource to use as the input for the operation
        headers - an optional list of request headers to be added to the request
        Returns:
        a FHIRResponse that contains the results of the 'invoke' operation
        Throws:
        java.lang.Exception
      • getDefaultBaseUrl

        public java.lang.String getDefaultBaseUrl()
        Description copied from interface: FHIRClient
        Returns the default FHIR base URL that is configured for this client instance
        Specified by:
        getDefaultBaseUrl in interface FHIRClient
        Returns:
        the FHIR base URL with scheme, host, and path
      • getWebTarget

        public javax.ws.rs.client.WebTarget getWebTarget()
                                                  throws java.lang.Exception
        Description copied from interface: FHIRClient
        Returns a JAX-RS 2.0 WebTarget object associated with the REST API endpoint.
        Specified by:
        getWebTarget in interface FHIRClient
        Returns:
        a WebTarget instance that can be used to invoke REST APIs.
        Throws:
        java.lang.Exception
      • getWebTarget

        public javax.ws.rs.client.WebTarget getWebTarget​(java.lang.String baseURL)
                                                  throws java.lang.Exception
        Description copied from interface: FHIRClient
        Returns a JAX-RS 2.0 WebTarget object associated with a given REST API endpoint.
        Specified by:
        getWebTarget in interface FHIRClient
        Returns:
        a WebTarget instance that can be used to invoke REST APIs.
        Throws:
        java.lang.Exception
      • getBaseEndpointURL

        public java.lang.String getBaseEndpointURL()
      • setDefaultMimeType

        public void setDefaultMimeType​(java.lang.String mimeType)
                                throws java.lang.Exception
        Description copied from interface: FHIRClient
        Sets the default mime-type to be used by the FHIRClient interface when invoking REST API operations.
        Specified by:
        setDefaultMimeType in interface FHIRClient
        Parameters:
        mimeType - a string containing the mime-type (e.g. "application/fhir+json")
        Throws:
        java.lang.Exception
      • getDefaultMimeType

        public java.lang.String getDefaultMimeType()
                                            throws java.lang.Exception
        Description copied from interface: FHIRClient
        Returns a string that represents the default mime-type associated with the FHIRClient interface.
        Specified by:
        getDefaultMimeType in interface FHIRClient
        Throws:
        java.lang.Exception
      • setOAuth2AccessToken

        public void setOAuth2AccessToken​(java.lang.String accessToken)
                                  throws java.lang.Exception
        Description copied from interface: FHIRClient
        Sets the OAuth 2.0 access token to be used by the FHIRClient interface for authorization when invoking REST API operations.
        Specified by:
        setOAuth2AccessToken in interface FHIRClient
        Parameters:
        accessToken - a string containing the OAuth 2.0 access token
        Throws:
        java.lang.Exception
      • getOAuth2AccessToken

        public java.lang.String getOAuth2AccessToken()
                                              throws java.lang.Exception
        Description copied from interface: FHIRClient
        Returns a string that represents the OAuth 2.0 access token to be used by the FHIRClient interface for authorization requests.
        Specified by:
        getOAuth2AccessToken in interface FHIRClient
        Throws:
        java.lang.Exception
      • getTrustStore

        public java.security.KeyStore getTrustStore()
        Description copied from interface: FHIRClient
        Allow the client consumer to be able to get and reuse the same TrustStore if necessary.
        Specified by:
        getTrustStore in interface FHIRClient
      • getKeyStoreLocation

        public java.lang.String getKeyStoreLocation()
      • setKeyStoreLocation

        public void setKeyStoreLocation​(java.lang.String keyStoreLocation)
      • getKeyStorePassword

        public java.lang.String getKeyStorePassword()
      • setKeyStorePassword

        public void setKeyStorePassword​(java.lang.String keyStorePassword)
      • getKeyStoreKeyPassword

        public java.lang.String getKeyStoreKeyPassword()
      • setKeyStoreKeyPassword

        public void setKeyStoreKeyPassword​(java.lang.String keyStoreKeyPassword)
      • isLoggingEnabled

        public boolean isLoggingEnabled()
      • setLoggingEnabled

        public void setLoggingEnabled​(boolean loggingEnabled)
      • isHostnameVerificationEnabled

        public boolean isHostnameVerificationEnabled()
      • setHostnameVerificationEnabled

        public void setHostnameVerificationEnabled​(boolean hostnameVerficationEnabled)
      • getHttpTimeout

        public int getHttpTimeout()
      • setHttpTimeout

        public void setHttpTimeout​(int httpTimeout)
      • getTenantId

        public java.lang.String getTenantId()
        Description copied from interface: FHIRClient
        Get the value of the tenant name the client is currently configured to use
        Specified by:
        getTenantId in interface FHIRClient
        Returns: