Class HCXIncomingRequest

  • All Implemented Interfaces:
    IncomingRequest

    public class HCXIncomingRequest
    extends io.hcxprotocol.helper.FhirPayload
    implements IncomingRequest
    The HCX Incoming Request class provide the methods to help in processing the JWE Payload and extract FHIR Object.
    • process is the main method to use by the integrator(s) to validate the JWE Payload and fetch FHIR Object.
      • This method takes the JWE Payload and Operation as input parameters to validate and extract the respective FHIR Object.
    • validateRequest, validatePayload, decryptPayload, sendResponse methods are used by process method to compose functionality of validating JWE Payload and extracting FHIR Object. These methods are available for the integrator(s) to use them based on different scenario(s) or use cases.
    • Constructor Detail

    • Method Detail

      • process

        public boolean process​(String jwePayload,
                               io.hcxprotocol.utils.Operations operation,
                               Map<String,​Object> output)
        Description copied from interface: IncomingRequest
        Process the JWE Payload based on the Operation to validate and extract the FHIR Object. It has the implementation of below steps.
        1. Validating HCX Protocol headers
        2. Decryption of the payload and extracting FHIR object
        3. Validating the FHIR object using HCX FHIR IG.
        Specified by:
        process in interface IncomingRequest
        Parameters:
        jwePayload - The JWE payload from the incoming API request body.
        operation - The HCX operation name.
        output - A wrapper map to collect the outcome (errors or response) of the JWE Payload processing.
        1. output -
              {
                 "headers":{}, - protocol headers
                 "fhirPayload":{}, - fhir object
                 "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 incoming request processing is successful or not.
        1. true - It is successful.
        2. false - It is failure.
      • validateRequest

        public boolean validateRequest​(String jwePayload,
                                       io.hcxprotocol.utils.Operations operation,
                                       Map<String,​Object> error)
        Description copied from interface: IncomingRequest
        Validates the HCX Protocol Headers from the JWE Payload. This method is used by IncomingInterface.processFunction for validate the headers.
        Specified by:
        validateRequest in interface IncomingRequest
        Parameters:
        jwePayload - The JWE payload from the incoming API request body.
        operation - The HCX operation or action defined by specs to understand the functional behaviour.
        error - A wrapper map to collect the errors from the JWE Payload.
            {
               "error_code": "error_message"
            }
        Returns:
        It is a boolean value to understand the validation status of JWE Payload.
        1. true - Validation is successful.
        2. false - Validation is failure.
      • decryptPayload

        public boolean decryptPayload​(String jwePayload,
                                      Map<String,​Object> output)
        Description copied from interface: IncomingRequest
        Decrypt the JWE Payload using the Participant System Private Key (which is available from the configuration). The JWE Payload follows RFC7516.
        Specified by:
        decryptPayload in interface IncomingRequest
        Parameters:
        jwePayload - The JWE payload from the incoming API request body.
        output - A wrapper map to collect the outcome (errors or response) of the JWE Payload after decryption.
        1. success output -
              {
                 "headers":{}, - protocol headers
                 "fhirPayload":{} - fhir object
              }
        2. error output -
              {
                 "error_code": "error_message"
              }
        Returns:
        It is a boolean value to understand the decryption status of JWE Payload.
        1. true - Decryption is successful.
        2. false - Decryption is failure.
      • sendResponse

        public boolean sendResponse​(Map<String,​Object> error,
                                    Map<String,​Object> output)
        Description copied from interface: IncomingRequest
        Generates the HCX Protocol API response using validation errors and the output object.
        Specified by:
        sendResponse in interface IncomingRequest
        Parameters:
        error - A wrapper map to collect the errors from the JWE or FHIR Payload validations.
        output - A wrapper map to collect the response of the JWE Payload processing.
        1. output -
              {
                 "headers":{}, - protocol headers
                 "fhirPayload":{}, - fhir object
                 "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 final status is successful or failure.