Interface IncomingRequest

  • All Known Implementing Classes:
    HCXIncomingRequest

    public interface IncomingRequest
    The Incoming Request Interface provide the methods to help in processing the JWE Payload and extract FHIR Object.
    • Method Detail

      • process

        boolean process​(String jwePayload,
                        io.hcxprotocol.utils.Operations operation,
                        Map<String,​Object> output)
        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.
        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

        boolean validateRequest​(String jwePayload,
                                io.hcxprotocol.utils.Operations operation,
                                Map<String,​Object> error)
        Validates the HCX Protocol Headers from the JWE Payload. This method is used by IncomingInterface.processFunction for validate the headers.
        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

        boolean decryptPayload​(String jwePayload,
                               Map<String,​Object> output)
        Decrypt the JWE Payload using the Participant System Private Key (which is available from the configuration). The JWE Payload follows RFC7516.
        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.
      • validatePayload

        boolean validatePayload​(String fhirPayload,
                                io.hcxprotocol.utils.Operations operation,
                                Map<String,​Object> error)
        Validates the FHIR Object structure and required attributes using HCX FHIR IG.
        Parameters:
        fhirPayload - The FHIR object extracted from the incoming JWE Payload.
        operation - The HCX operation or action defined by specs to understand the functional behaviour.
        error - A wrapper map to collect the errors from the FHIR Payload validation.
            {
               "error_code": "error_message"
            }
        Returns:
        It is a boolean value to understand the validation status of FHIR Payload.
        1. true - Validation is successful.
        2. false - Validation is failure.
      • sendResponse

        boolean sendResponse​(Map<String,​Object> error,
                             Map<String,​Object> output)
        Generates the HCX Protocol API response using validation errors and the output object.
        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.