Package io.hcxprotocol.interfaces
Interface OutgoingRequest
-
- All Known Implementing Classes:
HCXOutgoingRequest
public interface OutgoingRequestThe Outgoing Request Interface provide the methods to help in creating the JWE Payload and send the request to the sender system from HCX Gateway.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleancreateHeader(String recipientCode, String actionJwe, String onActionStatus, Map<String,Object> headers)Creates the HCX Protocol Headers using the input parameters.booleanencryptPayload(Map<String,Object> headers, String fhirPayload, Map<String,Object> output)It generates JWE Payload using the HCX Protocol Headers and FHIR object.booleangenerate(String fhirPayload, io.hcxprotocol.utils.Operations operation, String actionJwe, String onActionStatus, Map<String,Object> output)Generates the JWE Payload using FHIR Object, Operation and other parameters part of input.booleangenerate(String fhirPayload, io.hcxprotocol.utils.Operations operation, String recipientCode, Map<String,Object> output)Generates the JWE Payload using FHIR Object, Operation and other parameters part of input.booleaninitializeHCXCall(String jwePayload, io.hcxprotocol.utils.Operations operation, Map<String,Object> response)Uses the input parameters and the SDK configuration to call HCX Gateway REST API based on the operation.booleanvalidatePayload(String fhirPayload, io.hcxprotocol.utils.Operations operation, Map<String,Object> error)Validates the FHIR Object structure and required attributes using HCX FHIR IG.
-
-
-
Method Detail
-
generate
boolean generate(String fhirPayload, io.hcxprotocol.utils.Operations operation, String recipientCode, Map<String,Object> output)
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.
- 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.- output -
{ "payload":{}, - jwe payload "responseObj":{} - success/error response object } - success response object -
{ "timestamp": , - unix timestamp "correlation_id": "", - fetched from incoming request "api_call_id": "" - fetched from incoming request } - error response object -
{ "timestamp": , - unix timestamp "error": { "code" : "", - error code "message": "", - error message "trace":"" - error trace } }
- output -
- Returns:
- It is a boolean value to understand the outgoing request generation is successful or not.
- true - It is successful.
- false - It is failure.
-
generate
boolean generate(String fhirPayload, io.hcxprotocol.utils.Operations operation, String actionJwe, String onActionStatus, Map<String,Object> output)
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.
- 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.- output -
{ "payload":{}, - jwe payload "responseObj":{} - success/error response object } - success response object -
{ "timestamp": , - unix timestamp "correlation_id": "", - fetched from incoming request "api_call_id": "" - fetched from incoming request } - error response object -
{ "timestamp": , - unix timestamp "error": { "code" : "", - error code "message": "", - error message "trace":"" - error trace } }
- output -
- Returns:
- It is a boolean value to understand the outgoing request generation is successful or not.
- true - It is successful.
- false - It 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 created by the participant system.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.
- true - Validation is successful.
- false - Validation is failure.
-
createHeader
boolean createHeader(String recipientCode, String actionJwe, String onActionStatus, Map<String,Object> headers)
Creates the HCX Protocol Headers using the input parameters.- 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.
- true - It is successful.
- false - It is failure.
-
encryptPayload
boolean encryptPayload(Map<String,Object> headers, String fhirPayload, Map<String,Object> output)
It generates JWE Payload using the HCX Protocol Headers and FHIR object. The JWE Payload follows RFC7516.- 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.- success output -
{ "payload": "" - jwe payload } - error output -
{ "error_code": "error_message" }
- success output -
- Returns:
- It is a boolean value to understand the encryption of FHIR object is successful or not.
- true - It is successful.
- false - It is failure.
-
initializeHCXCall
boolean initializeHCXCall(String jwePayload, io.hcxprotocol.utils.Operations operation, Map<String,Object> response) throws Exception
Uses the input parameters and the SDK configuration to call HCX Gateway REST API based on the operation.- 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.- success response -
{ "responseObj": { "timestamp": , - unix timestamp "correlation_id": "", - fetched from incoming request "api_call_id": "" - fetched from incoming request } } - error response -
{ "responseObj":{ "timestamp": , - unix timestamp "error": { "code" : "", - error code "message": "", - error message "trace":"" - error trace } } }
- success response -
- 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
-
-