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 java.lang.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 java.lang.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; fhirVersion=4.3" will be used.
        See Also:
        Constant Field Values
      • PROPNAME_OAUTH2_ENABLED

        static final java.lang.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 fhirclient.oAuth2.accessToken is required as well.
        See Also:
        Constant Field Values
      • PROPNAME_OAUTH2_TOKEN

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

        static final java.lang.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 java.lang.String PROPNAME_CLIENT_USERNAME
        The username to use with Basic Authentication.
        See Also:
        Constant Field Values
      • PROPNAME_CLIENT_PASSWORD

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

        static final java.lang.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 keystore properties are required.
        See Also:
        Constant Field Values
      • PROPNAME_TRUSTSTORE_LOCATION

        static final java.lang.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 java.lang.String PROPNAME_TRUSTSTORE_PASSWORD
        The client truststore's password.
        See Also:
        Constant Field Values
      • PROPNAME_KEYSTORE_LOCATION

        static final java.lang.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 java.lang.String PROPNAME_KEYSTORE_PASSWORD
        The client keystore's password.
        See Also:
        Constant Field Values
      • PROPNAME_KEYSTORE_KEY_PASSWORD

        static final java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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

      • getDefaultBaseUrl

        java.lang.String getDefaultBaseUrl()
        Returns the default FHIR base URL that is configured for this client instance
        Returns:
        the FHIR base URL with scheme, host, and path
      • getWebTarget

        javax.ws.rs.client.WebTarget getWebTarget()
                                           throws java.lang.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:
        java.lang.Exception
      • getWebTarget

        javax.ws.rs.client.WebTarget getWebTarget​(java.lang.String baseURL)
                                           throws java.lang.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:
        java.lang.Exception
      • setDefaultMimeType

        void setDefaultMimeType​(java.lang.String mimeType)
                         throws java.lang.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:
        java.lang.Exception
      • getDefaultMimeType

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

        void setOAuth2AccessToken​(java.lang.String accessToken)
                           throws java.lang.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:
        java.lang.Exception
      • getOAuth2AccessToken

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

        FHIRResponse capabilities​(FHIRRequestHeader... headers)
                           throws java.lang.Exception
        Invokes the 'capabilities' FHIR REST API operation to get a capability statement for the target server.
        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

        FHIRResponse create​(Resource resource,
                            FHIRRequestHeader... headers)
                     throws java.lang.Exception
        Invokes the 'create' FHIR REST API operation to create a new resource with a server assigned id.
        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
      • conditionalCreate

        FHIRResponse conditionalCreate​(Resource resource,
                                       FHIRParameters parameters,
                                       FHIRRequestHeader... headers)
                                throws java.lang.Exception
        Invokes the 'conditional create' FHIR REST API operation to conditionally create a new resource with a server assigned id.
        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
      • create

        FHIRResponse create​(jakarta.json.JsonObject resource,
                            FHIRRequestHeader... headers)
                     throws java.lang.Exception
        Invokes the 'create' FHIR REST API operation to create a new resource with a server assigned id.
        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

        FHIRResponse conditionalCreate​(jakarta.json.JsonObject resource,
                                       FHIRParameters parameters,
                                       FHIRRequestHeader... headers)
                                throws java.lang.Exception
        Invokes the 'conditional create' FHIR REST API operation to conditionally create a new resource with a server assigned id.
        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

        FHIRResponse update​(Resource resource,
                            FHIRRequestHeader... headers)
                     throws java.lang.Exception
        Invokes the 'update' FHIR REST API operation to update an existing resource by its id (or create it if it is new).
        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
      • conditionalUpdate

        FHIRResponse conditionalUpdate​(Resource resource,
                                       FHIRParameters parameters,
                                       FHIRRequestHeader... headers)
                                throws java.lang.Exception
        Invokes the 'conditional update' FHIR REST API operation to conditionally update an existing resource by its id (or create it if it is new).
        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
      • update

        FHIRResponse update​(jakarta.json.JsonObject resource,
                            FHIRRequestHeader... headers)
                     throws java.lang.Exception
        Invokes the 'update' FHIR REST API operation to update an existing resource by its id (or create it if it is new).
        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

        FHIRResponse conditionalUpdate​(jakarta.json.JsonObject resource,
                                       FHIRParameters parameters,
                                       FHIRRequestHeader... headers)
                                throws java.lang.Exception
        Invokes the 'conditional update' FHIR REST API operation to conditionally update an existing resource by its id (or create it if it is new).
        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

        FHIRResponse delete​(java.lang.String resourceType,
                            java.lang.String resourceId,
                            FHIRRequestHeader... headers)
                     throws java.lang.Exception
        Invokes the 'delete' FHIR REST API operation to delete a resource.
        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

        FHIRResponse conditionalDelete​(java.lang.String resourceType,
                                       FHIRParameters parameters,
                                       FHIRRequestHeader... headers)
                                throws java.lang.Exception
        Invokes the 'conditional delete' FHIR REST API operation to conditionally delete a resource.
        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

        FHIRResponse read​(java.lang.String resourceType,
                          java.lang.String resourceId,
                          FHIRRequestHeader... headers)
                   throws java.lang.Exception
        Invokes the 'read' FHIR REST API operation to read the current state of a resource.
        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

        FHIRResponse vread​(java.lang.String resourceType,
                           java.lang.String resourceId,
                           java.lang.String versionId,
                           FHIRRequestHeader... headers)
                    throws java.lang.Exception
        Invokes the 'vread' FHIR REST API operation to read the state of a specific version of a resource.
        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

        FHIRResponse history​(java.lang.String resourceType,
                             java.lang.String resourceId,
                             FHIRParameters parameters,
                             FHIRRequestHeader... headers)
                      throws java.lang.Exception
        Invokes the type-level 'history' FHIR REST API operation to retrieve the change history for a particular resource type.
        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

        FHIRResponse history​(FHIRParameters parameters,
                             FHIRRequestHeader... headers)
                      throws java.lang.Exception
        Invokes the system-level 'history' FHIR REST API operation to retrieve the change history for all resources.
        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

        FHIRResponse search​(java.lang.String resourceType,
                            FHIRParameters parameters,
                            FHIRRequestHeader... headers)
                     throws java.lang.Exception
        Invokes the type-level 'search' FHIR REST API operation to search the resource type based on some filter criteria.
        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

        FHIRResponse _search​(java.lang.String resourceType,
                             FHIRParameters parameters,
                             FHIRRequestHeader... headers)
                      throws java.lang.Exception
        Invokes the type-level 'search' FHIR REST API operation via HTTP POST.
        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

        FHIRResponse searchAll​(FHIRParameters parameters,
                               boolean isPost,
                               FHIRRequestHeader... headers)
                        throws java.lang.Exception
        Invokes the system-level 'search' FHIR REST API operation to search across all resource types based on some filter criteria.
        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

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

        FHIRResponse validate​(jakarta.json.JsonObject resource,
                              FHIRRequestHeader... headers)
                       throws java.lang.Exception
        Invokes the 'validate' FHIR extended 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:
        java.lang.Exception
      • batch

        FHIRResponse batch​(Bundle bundle,
                           FHIRRequestHeader... headers)
                    throws java.lang.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:
        java.lang.Exception
      • transaction

        FHIRResponse transaction​(Bundle bundle,
                                 FHIRRequestHeader... headers)
                          throws java.lang.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:
        java.lang.Exception
      • invoke

        FHIRResponse invoke​(java.lang.String operationName,
                            FHIRParameters parameters,
                            FHIRRequestHeader... headers)
                     throws java.lang.Exception
        Invokes a FHIR extended operation at the system level via HTTP GET.
        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

        FHIRResponse invoke​(java.lang.String operationName,
                            Resource resource,
                            FHIRRequestHeader... headers)
                     throws java.lang.Exception
        Invokes a FHIR extended operation at the system level via HTTP POST.
        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

        FHIRResponse invoke​(java.lang.String resourceType,
                            java.lang.String operationName,
                            FHIRParameters parameters,
                            FHIRRequestHeader... headers)
                     throws java.lang.Exception
        Invokes a FHIR extended operation at the type level via HTTP GET.
        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

        FHIRResponse invoke​(java.lang.String resourceType,
                            java.lang.String operationName,
                            Resource resource,
                            FHIRRequestHeader... headers)
                     throws java.lang.Exception
        Invokes a FHIR extended operation at the type level via HTTP POST.
        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

        FHIRResponse invoke​(java.lang.String resourceType,
                            java.lang.String operationName,
                            java.lang.String resourceId,
                            FHIRParameters parameters,
                            FHIRRequestHeader... headers)
                     throws java.lang.Exception
        Invokes a FHIR extended operation at the instance level via HTTP GET.
        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

        FHIRResponse invoke​(java.lang.String resourceType,
                            java.lang.String operationName,
                            java.lang.String resourceId,
                            Resource resource,
                            FHIRRequestHeader... headers)
                     throws java.lang.Exception
        Invokes a FHIR extended operation at the instance level via HTTP POST.
        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

        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
        Invokes a FHIR extended operation at the instance version level via HTTP GET.
        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

        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
        Invokes a FHIR extended operation at the instance version level via HTTP POST.
        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
      • getTrustStore

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

        java.lang.String getTenantId()
        Get the value of the tenant name the client is currently configured to use
        Returns: