Class HCXOutgoingRequest

  • All Implemented Interfaces:
    OutgoingRequest

    public class HCXOutgoingRequest
    extends io.hcxprotocol.helper.FhirPayload
    implements OutgoingRequest
    The HCX Outgoing Request class provide the methods to help in creating the JWE Payload and send the request to the sender system from HCX Gateway.
    • generate is the main method to use by the integrator(s) to generate JWE Payload.
      • This method handles two types of requests. There are two implementations of generate method to handle action, on_action API calls.
        1. Sending an initial request of HCX workflow action.
        2. Sending a response to the incoming HCX workflow action.
          • The input request JWE should be used as actionJwe.
    • validatePayload, createHeader, encryptPayload, initializeHCXCall methods are used by generate method to compose the JWE payload generation functionality. These methods are available for the integrator(s) to use them based on different scenario(s) or use cases.
    • Constructor Detail

    • Method Detail

      • generate

        public boolean generate​(String fhirPayload,
                                io.hcxprotocol.utils.Operations operation,
                                String recipientCode,
                                Map<String,​Object> output)
        Description copied from interface: OutgoingRequest
        Generates the JWE Payload using FHIR Object, Operation and other parameters part of input. This method is used to handle the action API request. It has the implementation of the below steps to create JWE Payload and send the request.
        • Validating the FHIR object using HCX FHIR IG.
        • Crate HCX Protocol headers based on the request.
        • Fetch the sender encryption public key from the HCX participant registry.
        • Encrypt the FHIR object along with HCX Protocol headers using RFC7516 to create JWE Payload.
        • Generate or fetch the authorization token of HCX Gateway.
        • Trigger HCX Gateway REST API based on operation.
        Specified by:
        generate in interface OutgoingRequest
        Parameters:
        fhirPayload - The FHIR object created by the participant system.
        operation - The HCX operation or action defined by specs to understand the functional behaviour.
        output - A wrapper map to collect the outcome (errors or response) of the JWE Payload generation process using FHIR object.
        1. output -
              {
                 "payload":{}, -  jwe payload
                 "responseObj":{} - success/error response object
              }
        2. success response object -
              {
                 "timestamp": , - unix timestamp
                 "correlation_id": "", - fetched from incoming request
                 "api_call_id": "" - fetched from incoming request
              }
        3. error response object -
              {
                 "timestamp": , - unix timestamp
                 "error": {
                     "code" : "", - error code
                     "message": "", - error message
                     "trace":"" - error trace
                  }
              }
        Returns:
        It is a boolean value to understand the outgoing request generation is successful or not.
        1. true - It is successful.
        2. false - It is failure.
      • generate

        public boolean generate​(String fhirPayload,
                                io.hcxprotocol.utils.Operations operation,
                                String actionJwe,
                                String onActionStatus,
                                Map<String,​Object> output)
        Description copied from interface: OutgoingRequest
        Generates the JWE Payload using FHIR Object, Operation and other parameters part of input. This method is used to handle the on_action API request. It has the implementation of the below steps to create JWE Payload and send the request.
        • Validating the FHIR object using HCX FHIR IG.
        • Crate HCX Protocol headers based on the request and actionJWE payload.
        • Fetch the sender encryption public key from the HCX participant registry.
        • Encrypt the FHIR object along with HCX Protocol headers using RFC7516 to create JWE Payload.
        • Generate or fetch the authorization token of HCX Gateway.
        • Trigger HCX Gateway REST API based on operation.
        Specified by:
        generate in interface OutgoingRequest
        Parameters:
        fhirPayload - The FHIR object created by the participant system.
        operation - The HCX operation or action defined by specs to understand the functional behaviour.
        actionJwe - The JWE Payload from the incoming request for which the response JWE Payload created here.
        onActionStatus - The HCX Protocol header status (x-hcx-status) value to use while creating the JEW Payload.
        output - A wrapper map to collect the outcome (errors or response) of the JWE Payload generation process using FHIR object.
        1. output -
              {
                 "payload":{}, -  jwe payload
                 "responseObj":{} - success/error response object
              }
        2. success response object -
              {
                 "timestamp": , - unix timestamp
                 "correlation_id": "", - fetched from incoming request
                 "api_call_id": "" - fetched from incoming request
              }
        3. error response object -
              {
                 "timestamp": , - unix timestamp
                 "error": {
                     "code" : "", - error code
                     "message": "", - error message
                     "trace":"" - error trace
                  }
              }
        Returns:
        It is a boolean value to understand the outgoing request generation is successful or not.
        1. true - It is successful.
        2. false - It is failure.
      • createHeader

        public boolean createHeader​(String recipientCode,
                                    String actionJwe,
                                    String onActionStatus,
                                    Map<String,​Object> headers)
        Description copied from interface: OutgoingRequest
        Creates the HCX Protocol Headers using the input parameters.
        Specified by:
        createHeader in interface OutgoingRequest
        Parameters:
        recipientCode - The recipient code from HCX Participant registry.
        actionJwe - The JWE Payload from the incoming request for which the response JWE Payload created here.
        onActionStatus - The HCX Protocol header status (x-hcx-status) value to use while creating the JEW Payload.
        headers - The HCX Protocol headers to create the JWE Payload.
        Returns:
        It is a boolean value to understand the HCX Protocol Headers generation is successful or not.
        1. true - It is successful.
        2. false - It is failure.
      • encryptPayload

        public boolean encryptPayload​(Map<String,​Object> headers,
                                      String fhirPayload,
                                      Map<String,​Object> output)
        Description copied from interface: OutgoingRequest
        It generates JWE Payload using the HCX Protocol Headers and FHIR object. The JWE Payload follows RFC7516.
        Specified by:
        encryptPayload in interface OutgoingRequest
        Parameters:
        headers - The HCX Protocol headers to create the JWE Payload.
        fhirPayload - The FHIR object created by the participant system.
        output - A wrapper map to collect the JWE Payload or the error details in case of failure.
        1. success output -
               {
                 "payload": "" - jwe payload
               }
        2. error output -
              {
                 "error_code": "error_message"
              }
        Returns:
        It is a boolean value to understand the encryption of FHIR object is successful or not.
        1. true - It is successful.
        2. false - It is failure.
      • initializeHCXCall

        public boolean initializeHCXCall​(String jwePayload,
                                         io.hcxprotocol.utils.Operations operation,
                                         Map<String,​Object> response)
                                  throws Exception
        Description copied from interface: OutgoingRequest
        Uses the input parameters and the SDK configuration to call HCX Gateway REST API based on the operation.
        Specified by:
        initializeHCXCall in interface OutgoingRequest
        Parameters:
        jwePayload - The JWE Payload created using HCX Protocol Headers and FHIR object.
        operation - The HCX operation or action defined by specs to understand the functional behaviour.
        response - A wrapper map to collect response of the REST API call.
        1. success response -
              {
                 "responseObj": {
                 "timestamp": , - unix timestamp
                 "correlation_id": "", - fetched from incoming request
                 "api_call_id": "" - fetched from incoming request
                }
              }
        2. error response -
              {
                "responseObj":{
                 "timestamp": , - unix timestamp
                 "error": {
                     "code" : "", - error code
                     "message": "", - error message
                     "trace":"" - error trace
                  }
                }
              }
        Returns:
        It is a boolean value to understand the REST API call execution is successful or not.
        Throws:
        com.fasterxml.jackson.core.JsonProcessingException - The exception throws when it is having issues in parsing the JSON object.
        Exception