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:
...