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

io.hcxprotocol.init.HCXIntegrator 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.init;

import io.hcxprotocol.utils.Operations;

import java.util.Map;

/**
 * This class contains the methods to initialize configuration variables, process incoming and outgoing requests.
 */
public class HCXIntegrator extends BaseIntegrator {

    /**
     * This method is to initialize config factory by passing the configuration as Map.
     *
     * @param config A Map that contains configuration variables and its values.
     */
    public static HCXIntegrator getInstance(Map config) throws Exception {
        HCXIntegrator hcxIntegrator = new HCXIntegrator();
        hcxIntegrator.setConfig(config);
        return hcxIntegrator;
    }

    /**
     * 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. *
    *
  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. *
* */ public boolean processIncoming(String jwePayload, Operations operation, Map output) throws Exception { return getIncomingRequest().process(jwePayload, operation, output, getConfig()); } /** * 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.
  • *
* @param fhirPayload The FHIR object created by the participant system. * @param operation The HCX operation or action defined by specs to understand the functional behaviour. * @param recipientCode The recipient code from HCX Participant registry. * @param apiCallId The unique id for each request, to use the custom identifier, pass the same or else * pass an empty string("") and method will generate a UUID and uses it. * @param correlationId The unique id for all the messages (requests and responses) that are involved in processing of one cycle, * to use the custom identifier, pass the same or else pass empty string("") and method will generate a UUID and uses it. * @param domainHeaders The domain headers to use while creating the JWE Payload. * @param output A wrapper map to collect the outcome (errors or response) of the JWE Payload generation process using FHIR object. *
    *
  1. output - *
         *    {@code {
         *       "payload":{}, -  jwe payload
         *       "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 outgoing request generation is successful or not. * *
    *
  1. true - It is successful.
  2. *
  3. false - It is failure.
  4. *
*/ public boolean processOutgoingRequest(String fhirPayload, Operations operation, String recipientCode, String apiCallId, String correlationId, Map domainHeaders, Map output) throws InstantiationException, IllegalAccessException { return getOutgoingRequest().process(fhirPayload, operation, recipientCode, apiCallId, correlationId, "", "", domainHeaders, output, getConfig()); } /** * 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.
  • *
* @param fhirPayload The FHIR object created by the participant system. * @param operation The HCX operation or action defined by specs to understand the functional behaviour. * @param apiCallId The unique id for each request, to use the custom identifier, pass the same or else * pass empty string("") and method will generate a UUID and uses it. * @param actionJwe The JWE Payload from the incoming request for which the response JWE Payload created here. * @param onActionStatus The HCX Protocol header status (x-hcx-status) value to use while creating the JEW Payload. * @param domainHeaders The domain headers to use while creating the JWE Payload. * @param output A wrapper map to collect the outcome (errors or response) of the JWE Payload generation process using FHIR object. *
    *
  1. output - *
         *    {@code {
         *       "payload":{}, -  jwe payload
         *       "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 outgoing request generation is successful or not. * *
    *
  1. true - It is successful.
  2. *
  3. false - It is failure.
  4. *
*/ public boolean processOutgoingCallback(String fhirPayload, Operations operation, String apiCallId, String actionJwe, String onActionStatus, Map domainHeaders, Map output) throws InstantiationException, IllegalAccessException { return getOutgoingRequest().process(fhirPayload, operation, "", apiCallId, "", actionJwe, onActionStatus, domainHeaders, output, getConfig()); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy