In our previous article we presented the general concepts as well as the problem that we wanted to solve by using the task engine integrated in InterSystems IRIS, in today's article we will see how we configure an interoperability production to provide a solution.
Workflow Engine Configuration
First we are going to define the roles of the tasks that we are going to manage, in our example we are going to define two types:
- AutomaticBloodPressureRole: to create automatic tasks that will have no intervention from the user.
- ManualBloodPressureRole: to create those tasks that the user must manually validate.
It will not be necessary to assign users to these roles since we will do it later as we go along as we receive HL7 messages from different patients.
We also do not need to add IRIS users to the Workflow since we will do it by code from production.
Production setup
For our example we are going to create a production within a NAMESPACE created ad-hoc and which we have called WORKFLOW. It will be in this production where we will include the business components that we need.
Let's start by explaining the simplest components:
Business Services
- HL7_File_IN: responsible for collecting HL7 files from a specific server path that will simulate receiving messaging from a medical device.
Business Operations
- AutomaticBloodPressureRole:component of the class EnsLib.Workflow.Operation, with the name of one of the defined roles that we will use to generate in our Workflow the tasks that will not involve direct interaction with the user.
- ManualBloodPressureRole: similar to the previous Business Operation, but in this case the tasks we generate will require the user to intervene directly to close them.
Let's now see in detail the Business Process that will manage the flow of information and the creation and management of the tasks involved in our cycle.
Workflow.BP.BloodPressurePlan
This Business Process is of the BPL type and will be responsible for creating the tasks involved in patient care and capturing the response, both from the patient and from the medical device that will send the information related to blood pressure levels.
Start of the process:
In this part the flow does the following:
-
Checking user: checks the user received in the received ADT^A08 message and if it exists, continues moving through the flow, otherwise it creates the user in IRIS and assigns it to the roles defined in the workflow. To assign users to the role, it runs the following command:
/// Workflow user creation set sc = ##class(EnsLib.Workflow.UserDefinition).CreateUser(username) /// Assigning Workflow user to the role set sc = ##class(EnsLib.Workflow.RoleDefinition).AddUserToRole(role, username)
-
Get automatic task: Since in this flow we are going to manage both automatic and manual tasks, we must check if there are pending automatic tasks for the user for the patient received. This is relevant since if there are pending automatic tasks it means that we have had a previous reading whose values exceed normal levels. We will do the checking directly on the TaskResponse table where all the created tasks are saved, the query will be as follows:
&sql(SELECT ID INTO :taskId FROM EnsLib_Workflow.TaskResponse WHERE TaskStatus_AssignedTo = :username AND TaskStatus_IsComplete = 0 AND %RoleName = :role)
- Getting count of OBX: we retrieve the number of OBX segments from our HL7 message.
- Check OBX values: we go through the OBX segments and extract only the data related to blood pressure.
- Pending tasks?: As we said in point 2, we check if we have a pending automatic task or not.
First blood pressure reading:
In this part of the flow we will deal with those messages that are not generated by a first reading that exceeds the defined maximum blood pressure levels.
- Check pressure: We check if blood pressure levels exceed pre-established limits; if they do not, the process will conclude without the need to do anything else. Otherwise it will be necessary to create the necessary tasks.
- Create manual task: The blood pressure has exceeded the defined safety levels, so it will be necessary to create a manual task in which we will inform the patient of the situation, indicating that they must take a second reading. Let's see the configuration of this activity.
Second blood pressure reading
This part of the flow will only be accessed when there is a previously created automatic task that has not been completed.
- Check pressure: We again validate for the message received whether the blood pressure values exceed the limit or not.
- Close normal task: If the levels do not exceed the maximum values, we will close the pending task with the CompleteTask method provided by the EnsLib.Workflow.TaskResponse class that our task instantiates. The parameter used will indicate the action taken, in this case we will indicate that it is a false alarm by passing the value FalseAlarm, we could define any other one we want.
- Close warning task:Same as in the previous case, with the difference that in this case the action that we pass to the Workflow engine will be Warning and that it will be the value that the "Check if warning" activity that we have seen previously will check.
As you can see in the following diagram (it is not literal but you can get an idea of how it will work), our task flow will work with 2 "threads" or "processes":
The first thread/process will remain open in case it is necessary to wait for a second reading and it will be the second thread/process that will cause the reactivation of the first open thread upon receiving said second reading, thus concluding the defined task flow.
Conclusion
As you can see, configuring a task flow in a BPL is quite simple, and you can simulate automatic and manual tasks without much complication. In the next and last article we will see how users can interact with their tasks from an external application.
Thank you all for your attention!
Top comments (0)