Wednesday 3 April 2013

Activiti Business Process


Activiti is a light-weight workflow and Business Process Management (BPM) Platform targeted at business people, developers and system admin. Its core is a super-fast and rock-solid BPMN 2 process engine for Java.
Activiti Architecture

The Process Virtual Machine is the architectural base layer of the Activiti Engine. It allows for easy pluggability of activity types, features and complete process languages.

Illustration of Activiti Business Example with an example 'Health Insurance Claim Process'.

Health Insurance Claim Process

Steps involved simulating the Health Insurance Claim Process using Activiti Business Process:-

Firstly customer approaches the Network Hospital for Cashless Treatment. This event is recorded as a startEvent for our Activiti BP.
<startEvent id="startEvent" activiti:initiator="employeeName" name="Customer approaches Network Hospital for Cashless Treatment"></startEvent>

Step 1:
Then, Hospital verifies customer details and sends pre-auth by fax. This event could involve some business process to be invoked. This is defined as a userTask.
<userTask id="handleRequest" name="Hospital verifies customer details and send pre-auth by fax” activiti: class="com.esoft.numonitor.activitiresource.ClaimProcess"></userTask>
This piece of XML code invokes the external Java class i.e. ClaimProcess to carry out the verification of customer details.

Step 2:
Now, the Health Insurance Company verifies the pre-auth details with policy benefits and sends response to the hospital. In this case, response could be Approved or Denied so Activiti provides you the exclusiveGateway to model a decision in the process.
<exclusiveGateway id="documentVerification" name="Health Insurance Company verifies pre-auth details with policy benefits and sends response to the Hospital" />

Step 3:
If the Health Insurance Company approves the cashless claim then hospital admits the patient for cashless treatment.

// This verifies the response of claim request, in this case it is approved.
<sequenceFlow id="flow3" sourceRef="documentVerification" targetRef="approvedCashlessClaim"><conditionExpression xsi:type="tFormalExpression">${claimApproved == 'true'}</conditionExpression> </sequenceFlow>

// Then, hospital admits the patient
<task id="approvedCashlessClaim" name="Hospital admits the patient without any deposit and provides cashless treatment" />

Step 4:
Then, it follows the endEvent for this claim process.
<endEvent id="stopEvent" name="Pay Non Medical Expenses and co-payment before discharge from the hospital"/>

Similarly, if the claimApproved is false, then the process would lead through steps-5 & 6.Following XML snippets carry out those above mentioned steps.

<sequenceFlow id="flow5" sourceRef="documentVerification" targetRef="deniedCashlessClaim">      <conditionExpression xsi:type="tFormalExpression">${claimApproved == 'false'}</conditionExpression>    </sequenceFlow>
<userTask id="deniedCashlessClaim" name="Admits the patient as Cash patient and patient has to pay the bill"></userTask>