Panel |
---|
Panel |
In this tutorial, you will use a BPMN process defined in the Business Process profile of WSO2 EI to manage the process of canceling a doctor's appointment. The appointment cancellation process should be designed according to the following requirement:
|
...
Tip | ||||||
---|---|---|---|---|---|---|
Before you begin,
|
...
- Open WSO2 Integration Studio.
- Go to BP Project → BPMN.
- Create a new project named AppointmentCancellation.
- Click Finish.
- Right click the project in the navigator and go to New → Other and select BPMN diagram.
- Select the
AppointmentCancellation/src/main/resources/diagrams
directory as the parent folder, and enterAppointmentCancellation.bpmn
for the File name.
- Click Next, select the option to create an empty diagram as shown below, and click Finish.
- Let's start drawing the BPMN process diagram for the appointment cancellation process. The AppointmentCancellation canvas. The Palette on the right side of the AppointmentCancellation canvas contains all the activity symbols that will be used for drawing the process as shown below.
Let's get started. You can easily drag and drop the activities from the Palette the canvas, and then update the properties and configurations of each activity as explained below.- Add a StartEvent from the Start Event palette.
Select the Properties tab, click Form, click New, update the following and click OK.
Id patientName Name Name of the Patient Type string Required True Repeat clicking New and adding the following to add the other form properties one by one.
Id Name Type Required appointmentNo
Appointment Number long True doctor
Name of the Doctor string True reason
Reason for cancellation string True email
Email Address string True Add a REST Task from the WSO2 Tasks palette.
Select the Properties tab, click General and give the Name asGet Appointment
, then click Main config and update the following:Service URL http ://localhost:9090/healthcare/appointments/validity/${appointmentNo}
HTTP method GET Output Variable Mappings noOfDays:$.status
- Add an Exclusive Gateway from the Gateway palette.
- Add a User Task from the Task palette and name it
Appointment Control Task
.
- Click Properties, click Main config and give
admin
as the Assignee.
In the Properties tab click Form, click New and add the following.
Id Name Type Readable Writable Required approveCancellation
Do You Approve the
Appointment Cancellation Request?enum True True True Click New next to Form values and add the following:
Id Name approve Approve reject Reject Repeat clicking New and adding the following to add the other form properties one by one.
Id Name Type Variable Readable Writable Required AppNo
Appointment Number long appointmentNo True False True cancellationReason
Reason For The Cancellation string reason True False True doctorName
Name of the Doctor string doctor True False True - Add another Exclusive Gateway from the Gateway palette.
- Add a REST Task from the WSO2 Tasks palette.
Select the Properties tab and click Main config and update the following:
Service URL http://localhost:9090/healthcare/appointments/validity/${appointmentNo}
HTTP method DELETE Output Variable name status Add a MailTask from the Task palette below the second Parallel Gateway and name it
Reject cancellation Task
.
Select the Properties tab and click Main config and update the following:To ${email}
From Enter a valid SMTP email address. Subject Appointment cancellation rejected Html Appointment cancellation request with Appointment Number ${appointmentNo} has been rejected. Thank you.
Administration DepartmentAdd another MailTask above the second Parallel Gateway and name it
Approve Cancellation Task
.
Select the Properties tab and click Main config and update the following:To ${email}
From Enter a valid SMTP email address. Subject Appointment cancellation successful Html Appointment cancellation request with Appointment Number ${appointmentNo} has been approved. Thank you.
Administration Department- Link each activity by hovering over the element, selecting the arrow sign and dragging it to the connecting element as shown below.
- Add a StartEvent from the Start Event palette.
- Click on the arrow leading from the first Exclusive Gateway to the
Approve Cancellation Task
, and in the Main config section of the Properties tab add the${noOfDays >2}
condition.
Click on the arrow leading from the first Exclusive Gateway to theAnchor reject reject Reject Cancellation Task
, and in the Main config section of the Properties tab add the${noOfDays<2}
condition.
- Click on the arrow leading from the second Exclusive Gateway to the
Rest Task
, and in the Main config section of the Properties tab add the${approveCancellation == 'approve'}
condition.
- Click on the arrow leading from the second Exclusive Gateway to the
Reject Cancellation Task
, and in the Main config section of the Properties tab add the${approveCancellation == 'reject'}
condition.
- Click the arrow leading to the Appointment Control Task, open the General tab that is under properties and note the Id.
Example:
- Click the first exclusive gateway, open the General tab that is under properties, and select the ID you noted in the above steps as the value for Default flow.
- Save all the changes you have made.
- Click Window -> Show View -> Other in the top menu of WSO2 Integration Studio.
- Type
Package Explorer
in the search bar, select it and click Open.
- In the Package Explorer, right-click the
AppointmentCancellation
project and select Create deployment artifacts.
This will create aAppointmentCancellation.bar
file in thedeployment
folder:
...
You can now deploy the .bar file of the BPMN process using the management console of the business process profile in WSO2 EI.
Open a terminal and navigate to the
<EI_HOME>/wso2/business-proces/bin
directory.Start the Business Process profile in WSO2 EI by executing one of the following commands:
Panel borderColor #542989 bgColor #ffffff borderWidth 1 Localtabgroup Localtab title On MacOS/Linux/CentOS Open a terminal and execute the following command:
Code Block sudosh wso2ei-6.5.0-business-processwso2server.sh
Localtab Go to Start Menu -> Programs -> WSO2 -> Enterprise Integrator 6.5.0 Business Process. This will open a terminal and start the business process profile.title On Windows Code Block wso2server.bat
- Open the management console from
https://localhost:9445/carbon/
. - Log in using admin as the username and password.
- Go to Main -> Manage -> Add ->BPMN and upload the
AppointmentCancellation.bar
file by browsing in the workspace directory of your WSO2 Integration Studio instance as shown below.
Anchor | ||||
---|---|---|---|---|
|
Let's start the Message Broker profilestart the Message Broker profile:
Open a terminal and navigate to the
<EI_HOME>/wso2/broker/bin
directory.Start the Business Process profile in WSO2 EI by executing one of the following commands:
Panel borderColor #542989 bgColor #ffffff borderWidth 1 Localtabgroup Localtab title On MacOS/Linux/CentOS
...
Open a terminal and execute the following command:
Code Block |
---|
sudo wso2ei-6.5.0-broker |
...
title | On Windows |
---|
...
Code Block sh wso2server.sh
Localtab title On Windows Code Block wso2server.bat
Anchor | ||||
---|---|---|---|---|
|
...
To be able to send requests to the back-end service (which is an MSF4J service deployed in the MSF4J profile of WSO2 EI), you need to first start the MSF4J runtime:MSF4J runtime:
- Open a terminal and navigate to the
<EI_HOME>/wso2/msf4j/bin
directory. Start the runtime by executing the MSF4J startup script as shown below.
Panel borderColor #542989 bgColor #ffffff borderWidth 1 Localtabgroup Localtab title On MacOS/Linux/CentOS
...
Code Block
...
sh
...
carbon.sh
Localtab title On Windows
...
Code Block carbon.bat
The system is now ready to receive appointment reservation requests.
...