Package io.hcxprotocol.impl
Class HCXOutgoingRequest
- java.lang.Object
-
- io.hcxprotocol.helper.FhirPayload
-
- io.hcxprotocol.impl.HCXOutgoingRequest
-
- All Implemented Interfaces:
OutgoingRequest
public class HCXOutgoingRequest extends io.hcxprotocol.helper.FhirPayload implements OutgoingRequest
The HCX Outgoing Request class provide the methods to help in creating the JWE Payload and send the request to the sender system from HCX Gateway.- generate is the main method to use by the integrator(s) to generate JWE Payload.
- This method handles two types of requests. There are two implementations of generate method to handle action, on_action API calls.
- Sending an initial request of HCX workflow action.
- Sending a response to the incoming HCX workflow action.
- The input request JWE should be used as actionJwe.
- This method handles two types of requests. There are two implementations of generate method to handle action, on_action API calls.
- validatePayload, createHeader, encryptPayload, initializeHCXCall methods are used by generate method to compose the JWE payload generation functionality. These methods are available for the integrator(s) to use them based on different scenario(s) or use cases.
-
-
Constructor Summary
Constructors Constructor Description HCXOutgoingRequest()
-
Method Summary
All Methods Instance Methods Concrete 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.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.hcxprotocol.interfaces.OutgoingRequest
validatePayload
-
-
-
-
Method Detail
-
generate
public boolean generate(String fhirPayload, io.hcxprotocol.utils.Operations operation, String recipientCode, Map<String,Object> output)
Description copied from interface:OutgoingRequestGenerates 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.
- Specified by:
generatein interfaceOutgoingRequest- 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
public boolean generate(String fhirPayload, io.hcxprotocol.utils.Operations operation, String actionJwe, String onActionStatus, Map<String,Object> output)
Description copied from interface:OutgoingRequestGenerates 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.
- Specified by:
generatein interfaceOutgoingRequest- 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.
-
createHeader
public boolean createHeader(String recipientCode, String actionJwe, String onActionStatus, Map<String,Object> headers)
Description copied from interface:OutgoingRequestCreates the HCX Protocol Headers using the input parameters.- Specified by:
createHeaderin interfaceOutgoingRequest- 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
public boolean encryptPayload(Map<String,Object> headers, String fhirPayload, Map<String,Object> output)
Description copied from interface:OutgoingRequestIt generates JWE Payload using the HCX Protocol Headers and FHIR object. The JWE Payload follows RFC7516.- Specified by:
encryptPayloadin interfaceOutgoingRequest- 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
public boolean initializeHCXCall(String jwePayload, io.hcxprotocol.utils.Operations operation, Map<String,Object> response) throws Exception
Description copied from interface:OutgoingRequestUses the input parameters and the SDK configuration to call HCX Gateway REST API based on the operation.- Specified by:
initializeHCXCallin interfaceOutgoingRequest- 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
-
-