Interface FHIRClient

  • All Known Implementing Classes:
    FHIRClientImpl

    public interface FHIRClient
    This interface provides a client API for invoking the FHIR Server's REST API.
    • Field Detail

      • PROPNAME_BASE_URL

        static final String PROPNAME_BASE_URL
        FHIR REST API endpoint base URL (e.g. https://localhost:9443/fhir-server/api/v4).
        See Also:
        Constant Field Values
      • PROPNAME_DEFAULT_MIMETYPE

        static final String PROPNAME_DEFAULT_MIMETYPE
        Specifies the default mimetype to be used by the FHIRClient instance when invoking FHIR REST APIs. If not specified a value of "application/fhir+json" will be used.
        See Also:
        Constant Field Values
      • PROPNAME_OAUTH2_ENABLED

        static final String PROPNAME_OAUTH2_ENABLED
        Indicates whether OAuth 2.0 should be used when invoking REST API requests. Valid values are "true" and "false" (the default). If enabled, then the authorizeURL, tokenURL and grantType properties are required as well.
        See Also:
        Constant Field Values
      • PROPNAME_OAUTH2_TOKEN

        static final String PROPNAME_OAUTH2_TOKEN
        The accessToken to use with OAuth 2.0 Authorization.
        See Also:
        Constant Field Values
      • PROPNAME_BASIC_AUTH_ENABLED

        static final String PROPNAME_BASIC_AUTH_ENABLED
        Indicates whether Basic Authentication should be used when invoking REST API requests. Valid values are "true" and "false" (the default). If enabled, then the username and password properties are required as well.
        See Also:
        Constant Field Values
      • PROPNAME_CLIENT_USERNAME

        static final String PROPNAME_CLIENT_USERNAME
        The username to use with Basic Authentication.
        See Also:
        Constant Field Values
      • PROPNAME_CLIENT_PASSWORD

        static final String PROPNAME_CLIENT_PASSWORD
        The password to use with Basic Authentication.
        See Also:
        Constant Field Values
      • PROPNAME_CLIENT_AUTH_ENABLED

        static final String PROPNAME_CLIENT_AUTH_ENABLED
        Indicates whether Client Certificate-based Authentication should be used when invoking REST API requests. Valid values are "true" and "false" (the default). If enabled, then the rest of the "clientauth"-related properties are required as well.
        See Also:
        Constant Field Values
      • PROPNAME_TRUSTSTORE_LOCATION

        static final String PROPNAME_TRUSTSTORE_LOCATION
        The client truststore's filename. The client truststore is used to store the server's public key certificates and is used to verify the server's identity.
        See Also:
        Constant Field Values
      • PROPNAME_TRUSTSTORE_PASSWORD

        static final String PROPNAME_TRUSTSTORE_PASSWORD
        The client truststore's password.
        See Also:
        Constant Field Values
      • PROPNAME_KEYSTORE_LOCATION

        static final String PROPNAME_KEYSTORE_LOCATION
        The client keystore's filename. The client keystore is used to store the client's private/public key pair certificates. When using client certificate-based authentication, this is now the client supplies its identity to the server.
        See Also:
        Constant Field Values
      • PROPNAME_KEYSTORE_PASSWORD

        static final String PROPNAME_KEYSTORE_PASSWORD
        The client keystore's password.
        See Also:
        Constant Field Values
      • PROPNAME_KEYSTORE_KEY_PASSWORD

        static final String PROPNAME_KEYSTORE_KEY_PASSWORD
        The password associated with the client's certificate within the keystore file.
        See Also:
        Constant Field Values
      • PROPNAME_LOGGING_ENABLED

        static final String PROPNAME_LOGGING_ENABLED
        Indicates whether or not to enable to CXF Logging feature which will log all request and response messages at a level of INFO
        See Also:
        Constant Field Values
      • PROPNAME_HOSTNAME_VERIFICATION_ENABLED

        static final String PROPNAME_HOSTNAME_VERIFICATION_ENABLED
        Indicates whether or not to enable hostname verification when connecting over TLS
        See Also:
        Constant Field Values
      • PROPNAME_HTTP_TIMEOUT

        static final String PROPNAME_HTTP_TIMEOUT
        The amount of time, in milliseconds, that the consumer will wait for a response before it times out. 0 is infinite. Defaults to 60,000ms (60s)
        See Also:
        Constant Field Values
      • PROPNAME_HTTP_RETURN_PREF

        static final String PROPNAME_HTTP_RETURN_PREF
        The client preference for whether the server response for modification requests like POST or PUT should include an empty body, the updated resources, or a resource describing the outcome of the interaction.

        "minimal", "representation", or "OperationOutcome"

        See Also:
        Constant Field Values
      • PROPNAME_TENANT_ID

        static final String PROPNAME_TENANT_ID
        The tenant identifier to use for requests (using the header X-FHIR-TENANT-ID)
        See Also:
        Constant Field Values
    • Method Detail

      • getWebTarget

        javax.ws.rs.client.WebTarget getWebTarget()
                                           throws Exception
        Returns a JAX-RS 2.0 WebTarget object associated with the REST API endpoint.
        Returns:
        a WebTarget instance that can be used to invoke REST APIs.
        Throws:
        Exception
      • getWebTarget

        javax.ws.rs.client.WebTarget getWebTarget​(String baseURL)
                                           throws Exception
        Returns a JAX-RS 2.0 WebTarget object associated with a given REST API endpoint.
        Returns:
        a WebTarget instance that can be used to invoke REST APIs.
        Throws:
        Exception
      • getWebTargetUsingBasicAuth

        javax.ws.rs.client.WebTarget getWebTargetUsingBasicAuth​(String baseURL,
                                                                String username,
                                                                String pwd)
                                                         throws Exception
        Returns a JAX-RS 2.0 WebTarget object associated with a given REST API endpoint.
        Returns:
        a WebTarget instance that can be used to invoke REST APIs.
        Throws:
        Exception
      • setDefaultMimeType

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

        String getDefaultMimeType()
                           throws Exception
        Returns a string that represents the default mime-type associated with the FHIRClient interface.
        Throws:
        Exception
      • setOAuth2AccessToken

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

        String getOAuth2AccessToken()
                             throws Exception
        Returns a string that represents the OAuth 2.0 access token to be used by the FHIRClient interface for authorization requests.
        Throws:
        Exception
      • metadata

        FHIRResponse metadata​(FHIRRequestHeader... headers)
                       throws Exception
        Invokes the 'metadata' FHIR REST API operation.
        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:
        Exception
      • create

        FHIRResponse create​(Resource resource,
                            FHIRRequestHeader... headers)
                     throws Exception
        Invokes the 'create' FHIR REST API operation.
        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:
        Exception
      • conditionalCreate

        FHIRResponse conditionalCreate​(Resource resource,
                                       FHIRParameters parameters,
                                       FHIRRequestHeader... headers)
                                throws Exception
        Invokes the 'conditional create' FHIR REST API operation.
        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:
        Exception
      • create

        FHIRResponse create​(javax.json.JsonObject resource,
                            FHIRRequestHeader... headers)
                     throws Exception
        Invokes the 'create' FHIR REST API operation.
        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:
        Exception
      • conditionalCreate

        FHIRResponse conditionalCreate​(javax.json.JsonObject resource,
                                       FHIRParameters parameters,
                                       FHIRRequestHeader... headers)
                                throws Exception
        Invokes the 'conditional create' FHIR REST API operation.
        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:
        Exception
      • update

        FHIRResponse update​(Resource resource,
                            FHIRRequestHeader... headers)
                     throws Exception
        Invokes the 'update' FHIR REST API operation.
        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:
        Exception
      • conditionalUpdate

        FHIRResponse conditionalUpdate​(Resource resource,
                                       FHIRParameters parameters,
                                       FHIRRequestHeader... headers)
                                throws Exception
        Invokes the 'conditional update' FHIR REST API operation.
        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:
        Exception
      • update

        FHIRResponse update​(javax.json.JsonObject resource,
                            FHIRRequestHeader... headers)
                     throws Exception
        Invokes the 'update' FHIR REST API operation.
        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:
        Exception
      • conditionalUpdate

        FHIRResponse conditionalUpdate​(javax.json.JsonObject resource,
                                       FHIRParameters parameters,
                                       FHIRRequestHeader... headers)
                                throws Exception
        Invokes the 'conditional update' FHIR REST API operation.
        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:
        Exception
      • delete

        FHIRResponse delete​(String resourceType,
                            String resourceId,
                            FHIRRequestHeader... headers)
                     throws Exception
        Invokes the 'delete' FHIR REST API operation.
        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:
        Exception
      • conditionalDelete

        FHIRResponse conditionalDelete​(String resourceType,
                                       FHIRParameters parameters,
                                       FHIRRequestHeader... headers)
                                throws Exception
        Invokes the 'conditional delete' FHIR REST API operation.
        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:
        Exception
      • read

        FHIRResponse read​(String resourceType,
                          String resourceId,
                          FHIRRequestHeader... headers)
                   throws Exception
        Invokes the 'read' FHIR REST API operation.
        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:
        Exception
      • vread

        FHIRResponse vread​(String resourceType,
                           String resourceId,
                           String versionId,
                           FHIRRequestHeader... headers)
                    throws Exception
        Invokes the 'vread' FHIR REST API operation.
        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:
        Exception
      • history

        FHIRResponse history​(String resourceType,
                             String resourceId,
                             FHIRParameters parameters,
                             FHIRRequestHeader... headers)
                      throws Exception
        Invokes the 'history' FHIR REST API operation.
        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:
        Exception
      • history

        FHIRResponse history​(FHIRParameters parameters,
                             FHIRRequestHeader... headers)
                      throws Exception
        Invokes system level history FHIR REST API operation
        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:
        Exception
      • search

        FHIRResponse search​(String resourceType,
                            FHIRParameters parameters,
                            FHIRRequestHeader... headers)
                     throws Exception
        Invokes the 'search' FHIR REST API operation.
        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:
        Exception
      • _search

        FHIRResponse _search​(String resourceType,
                             FHIRParameters parameters,
                             FHIRRequestHeader... headers)
                      throws Exception
        Invokes the '_search' FHIR REST API operation.
        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:
        Exception
      • searchAll

        FHIRResponse searchAll​(FHIRParameters parameters,
                               boolean isPost,
                               FHIRRequestHeader... headers)
                        throws Exception
        Invokes the 'search-all' FHIR REST API operation with HTTP POST.
        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:
        Exception
      • validate

        FHIRResponse validate​(Resource resource,
                              FHIRRequestHeader... headers)
                       throws Exception
        Invokes the 'validate' FHIR REST API operation.
        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:
        Exception
      • validate

        FHIRResponse validate​(javax.json.JsonObject resource,
                              FHIRRequestHeader... headers)
                       throws Exception
        Invokes the 'validate' FHIR REST API operation.
        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:
        Exception
      • batch

        FHIRResponse batch​(Bundle bundle,
                           FHIRRequestHeader... headers)
                    throws Exception
        Invokes the 'batch/transaction' FHIR REST API operation for a request bundle of type 'batch'.
        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:
        Exception
      • transaction

        FHIRResponse transaction​(Bundle bundle,
                                 FHIRRequestHeader... headers)
                          throws Exception
        Invokes the 'batch/transaction' FHIR REST API operation for a request bundle of type 'transaction'.
        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:
        Exception
      • invoke

        FHIRResponse invoke​(String operationName,
                            FHIRParameters parameters,
                            FHIRRequestHeader... headers)
                     throws Exception
        Invokes the 'invoke' FHIR REST API operation.
        Parameters:
        operationName - name of the operation to be performed
        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:
        Exception
      • invoke

        FHIRResponse invoke​(String operationName,
                            Resource resource,
                            FHIRRequestHeader... headers)
                     throws Exception
        Invokes the 'invoke' FHIR REST API operation.
        Parameters:
        operationName - name of the operation to be performed
        resource - the FHIR resource used in context 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:
        Exception
      • invoke

        FHIRResponse invoke​(String resourceType,
                            String operationName,
                            FHIRParameters parameters,
                            FHIRRequestHeader... headers)
                     throws Exception
        Invokes the 'invoke' FHIR REST API operation.
        Parameters:
        resourceType - the FHIR resource type used in context for the operation
        operationName - name of the operation to be performed
        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:
        Exception
      • invoke

        FHIRResponse invoke​(String resourceType,
                            String operationName,
                            Resource resource,
                            FHIRRequestHeader... headers)
                     throws Exception
        Invokes the 'invoke' FHIR REST API operation.
        Parameters:
        resourceType - the FHIR resource type used in context for the operation
        operationName - name of the operation to be performed
        resource - the FHIR resource used in context 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:
        Exception
      • invoke

        FHIRResponse invoke​(String resourceType,
                            String operationName,
                            String resourceId,
                            FHIRParameters parameters,
                            FHIRRequestHeader... headers)
                     throws Exception
        Invokes the 'invoke' FHIR REST API operation.
        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
        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:
        Exception
      • invoke

        FHIRResponse invoke​(String resourceType,
                            String operationName,
                            String resourceId,
                            Resource resource,
                            FHIRRequestHeader... headers)
                     throws Exception
        Invokes the 'invoke' FHIR REST API operation.
        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 used in context 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:
        Exception
      • invoke

        FHIRResponse invoke​(String resourceType,
                            String operationName,
                            String resourceId,
                            String versionId,
                            FHIRParameters parameters,
                            FHIRRequestHeader... headers)
                     throws Exception
        Invokes the 'invoke' FHIR REST API operation.
        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
        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:
        Exception
      • invoke

        FHIRResponse invoke​(String resourceType,
                            String operationName,
                            String resourceId,
                            String versionId,
                            Resource resource,
                            FHIRRequestHeader... headers)
                     throws Exception
        Invokes the 'invoke' FHIR REST API operation.
        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 used in context 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:
        Exception
      • getTrustStore

        KeyStore getTrustStore()
        Allow the client consumer to be able to get and reuse the same TrustStore if necessary.