All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.hcxprotocol.interfaces.IncomingRequest Maven / Gradle / Ivy

Go to download

The SDK for HCX Participant System to help in integrating with HCX Gateway easily.

There is a newer version: 1.0.8
Show newest version
package io.hcxprotocol.interfaces;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.typesafe.config.Config;
import io.hcxprotocol.utils.Operations;

import java.util.Map;

/**
 * The Incoming Request Interface provide the methods to help in processing the JWE Payload and extract FHIR Object.
 */
public 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. *
  3. Decryption of the payload and extracting FHIR object
  4. *
  5. Validating the FHIR object using HCX FHIR IG.
  6. *
* @param jwePayload The JWE payload from the incoming API request body. * @param operation The HCX operation name. * @param output A wrapper map to collect the outcome (errors or response) of the JWE Payload processing. * @param config The config instance to get config variables. *
    *
  1. output - *
         *    {@code {
         *       "headers":{}, - protocol headers
         *       "fhirPayload":{}, - fhir object
         *       "responseObj":{} - success/error response object
         *    }}
    *
  2. *
  3. success response object - *
         *    {@code {
         *       "timestamp": , - unix timestamp
         *       "correlation_id": "", - fetched from incoming request
         *       "api_call_id": "" - fetched from incoming request
         *    }}
    *
  4. *
  5. error response object - *
         *    {@code {
         *       "timestamp": , - unix timestamp
         *       "error": {
         *           "code" : "", - error code
         *           "message": "", - error message
         *           "trace":"" - error trace
         *        }
         *    }}
    *
  6. *
* * @return It is a boolean value to understand the incoming request processing is successful or not. *
    *
  1. true - It is successful.
  2. *
  3. false - It is failure.
  4. *
* * @throws com.fasterxml.jackson.core.JsonProcessingException */ boolean process(String jwePayload, Operations operation, Map output, Config config) throws Exception; /** * Validates the HCX Protocol Headers from the JWE Payload. * This method is used by {@index IncomingInterface.processFunction} for validate the headers. * @param jwePayload The JWE payload from the incoming API request body. * @param operation The HCX operation or action defined by specs to understand the functional behaviour. * @param error A wrapper map to collect the errors from the JWE Payload. *
     *    {@code {
     *       "error_code": "error_message"
     *    }}
* @return It is a boolean value to understand the validation status of JWE Payload. *
    *
  1. true - Validation is successful.
  2. *
  3. false - Validation is failure.
  4. *
* */ boolean validateRequest(String jwePayload, Operations operation, Map error); /** * Decrypt the JWE Payload using the Participant System Private Key (which is available from the configuration). * The JWE Payload follows RFC7516. * * @param jwePayload The JWE payload from the incoming API request body. * @param output A wrapper map to collect the outcome (errors or response) of the JWE Payload after decryption. *
    *
  1. success output - *
         *    {@code {
         *       "headers":{}, - protocol headers
         *       "fhirPayload":{} - fhir object
         *    }}
    *
  2. *
  3. error output - *
         *    {@code {
         *       "error_code": "error_message"
         *    }}
    *
  4. *
* @return It is a boolean value to understand the decryption status of JWE Payload. *
    *
  1. true - Decryption is successful.
  2. *
  3. false - Decryption is failure.
  4. *
*/ boolean decryptPayload(String jwePayload, String privateKey, Map output) throws Exception; /** * Validates the FHIR Object structure and required attributes using HCX FHIR IG. * * @param fhirPayload The FHIR object extracted from the incoming JWE Payload. * @param operation The HCX operation or action defined by specs to understand the functional behaviour. * @param error A wrapper map to collect the errors from the FHIR Payload validation. * @param config The config instance to get config variables. *
     *    {@code {
     *       "error_code": "error_message"
     *    }}
* @return It is a boolean value to understand the validation status of FHIR Payload. *
    *
  1. true - Validation is successful.
  2. *
  3. false - Validation is failure.
  4. *
*/ boolean validatePayload(String fhirPayload, Operations operation, Map error, Config config); /** * Generates the HCX Protocol API response using validation errors and the output object. * * @param error A wrapper map to collect the errors from the JWE or FHIR Payload validations. * @param output A wrapper map to collect the response of the JWE Payload processing. *
    *
  1. output - *
         *    {@code {
         *       "headers":{}, - protocol headers
         *       "fhirPayload":{}, - fhir object
         *       "responseObj":{} - success/error response object
         *    }}
    *
  2. *
  3. success response object - *
         *    {@code {
         *       "timestamp": , - unix timestamp
         *       "correlation_id": "", - fetched from incoming request
         *       "api_call_id": "" - fetched from incoming request
         *    }}
    *
  4. *
  5. error response object - *
         *    {@code {
         *       "timestamp": , - unix timestamp
         *       "error": {
         *           "code" : "", - error code
         *           "message": "", - error message
         *           "trace":"" - error trace
         *        }
         *    }}
    *
  6. *
* * @return It is a boolean value to understand the final status is successful or failure. */ boolean sendResponse(Map error, Map output) throws JsonProcessingException; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy