Package io.hcxprotocol.impl
Class HCXIncomingRequest
- java.lang.Object
-
- io.hcxprotocol.helper.FhirPayload
-
- io.hcxprotocol.impl.HCXIncomingRequest
-
- All Implemented Interfaces:
IncomingRequest
public class HCXIncomingRequest extends io.hcxprotocol.helper.FhirPayload implements IncomingRequest
The HCX Incoming Request class provide the methods to help in processing the JWE Payload and extract FHIR Object.- process is the main method to use by the integrator(s) to validate the JWE Payload and fetch FHIR Object.
- This method takes the JWE Payload and Operation as input parameters to validate and extract the respective FHIR Object.
- validateRequest, validatePayload, decryptPayload, sendResponse methods are used by process method to compose functionality of validating JWE Payload and extracting FHIR Object. These methods are available for the integrator(s) to use them based on different scenario(s) or use cases.
-
-
Constructor Summary
Constructors Constructor Description HCXIncomingRequest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandecryptPayload(String jwePayload, Map<String,Object> output)Decrypt the JWE Payload using the Participant System Private Key (which is available from the configuration).booleanprocess(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.booleansendResponse(Map<String,Object> error, Map<String,Object> output)Generates the HCX Protocol API response using validation errors and the output object.booleanvalidateRequest(String jwePayload, io.hcxprotocol.utils.Operations operation, Map<String,Object> error)Validates the HCX Protocol Headers from the JWE Payload.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.hcxprotocol.interfaces.IncomingRequest
validatePayload
-
-
-
-
Method Detail
-
process
public boolean process(String jwePayload, io.hcxprotocol.utils.Operations operation, Map<String,Object> output)
Description copied from interface:IncomingRequestProcess 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.
- Specified by:
processin interfaceIncomingRequest- 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.- output -
{ "headers":{}, - protocol headers "fhirPayload":{}, - fhir object "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 incoming request processing is successful or not.
- true - It is successful.
- false - It is failure.
-
validateRequest
public boolean validateRequest(String jwePayload, io.hcxprotocol.utils.Operations operation, Map<String,Object> error)
Description copied from interface:IncomingRequestValidates the HCX Protocol Headers from the JWE Payload. This method is used by IncomingInterface.processFunction for validate the headers.- Specified by:
validateRequestin interfaceIncomingRequest- 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.
- true - Validation is successful.
- false - Validation is failure.
-
decryptPayload
public boolean decryptPayload(String jwePayload, Map<String,Object> output)
Description copied from interface:IncomingRequestDecrypt the JWE Payload using the Participant System Private Key (which is available from the configuration). The JWE Payload follows RFC7516.- Specified by:
decryptPayloadin interfaceIncomingRequest- 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.- success output -
{ "headers":{}, - protocol headers "fhirPayload":{} - fhir object } - error output -
{ "error_code": "error_message" }
- success output -
- Returns:
- It is a boolean value to understand the decryption status of JWE Payload.
- true - Decryption is successful.
- false - Decryption is failure.
-
sendResponse
public boolean sendResponse(Map<String,Object> error, Map<String,Object> output)
Description copied from interface:IncomingRequestGenerates the HCX Protocol API response using validation errors and the output object.- Specified by:
sendResponsein interfaceIncomingRequest- 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.- output -
{ "headers":{}, - protocol headers "fhirPayload":{}, - fhir object "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 final status is successful or failure.
-
-