Workflow Integration

Implementation of a certain integration use case might require Oracle Insurance Gateway to send a 'message' to a workflow system when business errors or technical errors get identified.

Oracle Insurance Gateway supports an out of the box feature to send out a 'message' when an exchange fails or times out. An exchange may fail due to a technical error. For example, run time error in a dynamic logic or when an external system is not reachable. It can also fail when a business error is encountered. For example, Invoking an activity step without supplying mandatory parameters or by identifying a problem with the data within the dynamic logic and flagging it to call a delivery step that delivers a 'message' to a workflow system. An exchange may time out due to time guard defined at the integration or the integration step configuration.

In this chapter two such use cases are described.

Use case #1

Sending out a message to an external system when exchange fails

This use case requires the following two settings on the integration to be present:

  • Error Destination - REST Destination to reach out to in case of a technical or business error.

  • Error Payload - Dynamic logic function that returns a payload.

Whenever an exchange gets marked as Failed, Oracle Insurance Gateway fires a request to an endpoint given by the error destination with the JSON payload returned by the Error Payload function

To clarify, if the error destination is configured as follows

Fields Configuration

code

workflowDestination

credentialKey

workflow_user

addressKey

ohi.workflow.baseurl e.g.

http://workflowapps:8080/events

destinationType

REST

typeConfig

path: /gatewayevents

httpMethod: POST

The dynamic logic 'workflowMessage' is configured as:

import groovy.json.JsonBuilder

  def jsonBuilder = new JsonBuilder()
  def errorsJsonBuilder= new JsonBuilder()
  def errorArrayList= new ArrayList()
  def errors = {
                error(
                  errorCode: "WRK_001",
                  errorText: exception.message
                )
              }
              errorArrayList.add(errors)

  errorsJsonBuilder {
               type : exchangeStep.exchange.integration.code
               errorList(jsonBuilder.call(errorArrayList))

            }

 return errorsJsonBuilder.toString()

Suppose an integration 'providerUpload' is set up with the error destination set to 'workflowDestination', then following message is sent to endpoint as (POST) request, whenever the invocation of this integration fails.

http://workflowapps:8080/events/gatewayevents
{ "type":"providerUpload",
   "errors":[{
     "errorCode":"WRK_001",
     "errorText":"<error message>"
  }]
}

Use case #2

Orchestrating the integration steps to send out a message to a workflow system.

At times integrations must perform business validation checks on data and take actions based on these checks. For example, send out a workflow message or event when the file header controls do not match with the actual data in the file or request to update a record that does not exist in Oracle Health Insurance applications.

In the next example, the system sends a workflow event if the file contains at least one provider that is unknown to Oracle Health Insurance applications. This logic to determine whether an event should be sent or not is part of the Oracle Health Insurance File Delivery Step data transformation logic.

To achieve this, configure the integration as follows:

  • Sequence 1 - Oracle Health Insurance File Deliver Step

  • Sequence 2 - Oracle Health Insurance Prover Import Activity Step

  • Sequence 3 - Workflow Deliver Step

The Oracle Health Insurance File Delivery step (transformation dynamic logic) validates the file data and sets the exchange property 'invokeWorkflow' as true if a data problem gets identified. The next steps are similar to the steps described in the 'Provider Import' example given in the chapter 'File Upload'.

The 'Step Invocation Check' dynamic logic on the Workflow Deliver Step returns true when the exchange property 'invokeWorkflow' is true, otherwise, it returns false. When the Step Invocation Check dynamic logic returns true, the system triggers the transformation logic associated with the Workflow Deliver Step and delivers the message produced by it to the workflow system.

Sample outline for the Oracle Health Insurance File Delivery Step data transformation logic:

^Note that here, the logic is much simplified. Here, each provider record gets verified, and if there is at least one faulty provider record then, an exchange property ('invokeWorkflow') gets added to indicate the presence of wrong provider data. ^

import org.apache.commons.csv.*
import javax.ws.rs.core.Response
import groovy.json.JsonSlurper
import groovy.xml.StreamingMarkupBuilder

def invokeWorkflow= false

// Note: this assumes a single datafile in a set
trigger.dataFiles.each { df ->

    // define the CSV structure that is capable of parsing the csv input
    char delimiter = ';'
    def csvParser = fileReader.csvParser(df, CSVFormat.DEFAULT
                              .withFirstRecordAsHeader()
                              .withIgnoreHeaderCase()
                              .withTrim()
                              .withDelimiter(delimiter))

    // this closure defines the XML payload
    def individualProvidersXML = { xml ->

        individualProviders {

            csvParser.each { csvRecord ->

                def validationResult = validate(csvRecord)
                if (!validationResult) {
                    invokeWorkflow= true
                    return
                }
                // ++logic to transform delimited file to OHI specific provider XML file
         }
     }
   }
}
// validate an individual csvRecord, as some elements are required
boolean validate(csvRecord) {
   def validationResult = true

   if( "some condition when true") {
       validationResult = false
   }
   return validationResult
}