io.hcxprotocol.interfaces.IncomingRequest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hcx-integrator-sdk Show documentation
Show all versions of hcx-integrator-sdk Show documentation
The SDK for HCX Participant System to help in integrating with HCX Gateway easily.
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.
*
* - Validating HCX Protocol headers
* - Decryption of the payload and extracting FHIR object
* - Validating the FHIR object using HCX FHIR IG.
*
* @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.
*
* - output -
*
* {@code {
* "headers":{}, - protocol headers
* "fhirPayload":{}, - fhir object
* "responseObj":{} - success/error response object
* }}
*
* - success response object -
*
* {@code {
* "timestamp": , - unix timestamp
* "correlation_id": "", - fetched from incoming request
* "api_call_id": "" - fetched from incoming request
* }}
*
* - error response object -
*
* {@code {
* "timestamp": , - unix timestamp
* "error": {
* "code" : "", - error code
* "message": "", - error message
* "trace":"" - error trace
* }
* }}
*
*
*
* @return It is a boolean value to understand the incoming request processing is successful or not.
*
* - true - It is successful.
* - false - It is failure.
*
*
* @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.
*
* - true - Validation is successful.
* - false - Validation is failure.
*
*
*/
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.
*
* - success output -
*
* {@code {
* "headers":{}, - protocol headers
* "fhirPayload":{} - fhir object
* }}
*
* - error output -
*
* {@code {
* "error_code": "error_message"
* }}
*
*
* @return It is a boolean value to understand the decryption status of JWE Payload.
*
* - true - Decryption is successful.
* - false - Decryption is failure.
*
*/
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.
*
* - true - Validation is successful.
* - false - Validation is failure.
*
*/
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.
*
* - output -
*
* {@code {
* "headers":{}, - protocol headers
* "fhirPayload":{}, - fhir object
* "responseObj":{} - success/error response object
* }}
*
* - success response object -
*
* {@code {
* "timestamp": , - unix timestamp
* "correlation_id": "", - fetched from incoming request
* "api_call_id": "" - fetched from incoming request
* }}
*
* - error response object -
*
* {@code {
* "timestamp": , - unix timestamp
* "error": {
* "code" : "", - error code
* "message": "", - error message
* "trace":"" - error trace
* }
* }}
*
*
*
* @return It is a boolean value to understand the final status is successful or failure.
*/
boolean sendResponse(Map error, Map output) throws JsonProcessingException;
}