-
Notifications
You must be signed in to change notification settings - Fork 3
4) Queries on processes
After loading a process model, different queries can be made. One of the probably most interesting ones is: Which process can be started? It is important to know, that ESProNa differs between different actions (start, finish, abort, suspend, ...). The possible actions on a process are defined when the process definition is written (see chapter ...).
Which processes are startable?
In order to query the previously loaded process model set_up_surgery_plan_extended for executable processes, just enter:
process_planning::initial_state(set_up_surgery_plan_extended, InitialState),
extends_object(Process, process),
Process::validate_action(start, InitialState, Instance-AgentList-RequiredDataList-ToolsList).
The first line of the leading code generates the initial state of the process model set_up_surgery_plan_extended. It is defined by the following lines:
InitialState = model_state([
process_state('set_up_surgery_plan_extended#pid_0', []),
process_state('set_up_surgery_plan_extended#pid_1', []),
process_state('set_up_surgery_plan_extended#pid_2', []),
process_state('set_up_surgery_plan_extended#pid_3', [])],
0
).
Every state object (represented as model_state) contains process_state objects. A state always has as many process_state objects as processes modeled in your process model. The 0 in the last but one line indicates that the process model has not been completed yet. A completion of the process model would be encoded by 1.
The second line retrieves all process-objects and binds them to the variable Process. In the third line the predicate validate_action/3 is called. As we wanted to retrieve the processes that can be started, the first parameter of validate_action/3 is start. The generated state of line one is used as a second parameter. validate_action/3 retrieves in the third parameter a compound list of different variables representing the concepts of the different POPM perspectives. Instances of a process that can be started are always bound on the variable Instance. AgentList is giving you a list of persons who must execute the process together. If there is just one name in the list, then only one person is needed to execute the process step (this is the normal case). RequiredDataList and ToolsList tell you which Data and Tools you need for this process step.
The answer in your terminal will look like this:
InitialState = model_state([process_state('set_up_surgery_plan_extended#pid_0', []), ...,
Process = 'set_up_surgery_plan_extended#pid_0'(_G83),
Instance = 1,
AgentList = ['http://ai4.inf.uni-bayreuth.de/ontology/individuals#Jack'],
RequiredDataList = [],
ToolsList = ['HIS']
If you press ; after the first result, then you get further results until you get a false by ESProNa which means that there are no more results.
InitialState = model_state([process_state('set_up_surgery_plan_extended#pid_0', []), ...,
Process = 'set_up_surgery_plan_extended#pid_0'(_G83),
Instance = 1,
AgentList = ['http://ai4.inf.uni-bayreuth.de/ontology/individuals#John'],
RequiredDataList = [],
ToolsList = ['HIS']
The difference between the two results is, that in the first one Jack is bound to the variable AgentList and in the second solution John is the person who can execute the process instance.
Executing a process:
With the information retrieved in the previous query, you can now start a certain process instance through the predicate perform_action/4. If you want that John starts process step set_up_surgery_plan_extended#pid_0 then bind him to the AgentList.
process_planning::initial_state(set_up_surgery_plan_extended, InitialState),
'set_up_surgery_plan_extended#pid_0'(_)::perform_action(start, InitialState,
1-['http://ai4.inf.uni-bayreuth.de/ontology/individuals#John']-[]-['HIS'],
NextModelState
).
As every action which is performed (also aborting a process) changes the state, it is important to know, that a predicate always requires the state you are currently in. Base on the input-state, the resulting NextModelState is calculated. The answer by ESProNa is the resulting NextModelState:
...
NextModelState = model_state([
process_state('set_up_surgery_plan_extended#pid_0', [1-start-['http://ai4.inf.uni-bayreuth.de/ontology/individuals#John']-[]-['HIS']]),
process_state('set_up_surgery_plan_extended#pid_1', []),
process_state('set_up_surgery_plan_extended#pid_2', []),
process_state('set_up_surgery_plan_extended#pid_3', [])],
0
).
The process state of 'set_up_surgery_plan_extended#pid_0' has as second term the history of the process. In the upper code you can see that an entry 1-start-['http://ai4.inf.uni-bayreuth.de/ontology/individuals#John']-[]-['HIS'] has been added to the list (compare it to the initial state). With this state you can ask ESProNa which processes now became executable. In order to query that, just copy & paste the following code into the ESProNa session:
ModelState = model_state([
process_state('set_up_surgery_plan_extended#pid_0', [1-start-['http://ai4.inf.uni-bayreuth.de/ontology/individuals#John']-[]-['HIS']]),
process_state('set_up_surgery_plan_extended#pid_1', []),
process_state('set_up_surgery_plan_extended#pid_2', []),
process_state('set_up_surgery_plan_extended#pid_3', [])],
0),
extends_object(Process, process),
Process::validate_action(Action, ModelState, Instance-AgentList-RequiredDataList-ToolsList).
Please note that the first parameter of validate_action/3 is in this query an unbound variable: Action. The effect of this variable is, that you now get all actions that are possible on the different processes in the submitted state. The outcome in your ESProNa session will look like this:
...
Process = 'set_up_surgery_plan_extended#pid_0'(_G111),
Action = finish,
Instance = 1,
AgentList = ['http://ai4.inf.uni-bayreuth.de/ontology/individuals#Jack'],
RequiredDataList = [],
ToolsList = ['HIS'] ;
...
Process = 'set_up_surgery_plan_extended#pid_0'(_G111),
Action = finish,
Instance = 1,
AgentList = ['http://ai4.inf.uni-bayreuth.de/ontology/individuals#John'],
RequiredDataList = [],
ToolsList = ['HIS'] ;
...
Process = 'set_up_surgery_plan_extended#pid_0'(_G111),
Action = abort,
Instance = 1,
AgentList = ['http://ai4.inf.uni-bayreuth.de/ontology/individuals#Jack'],
RequiredDataList = [],
ToolsList = ['HIS'] ;
...
Process = 'set_up_surgery_plan_extended#pid_0'(_G111),
Action = abort,
Instance = 1,
AgentList = ['http://ai4.inf.uni-bayreuth.de/ontology/individuals#John'],
RequiredDataList = [],
ToolsList = ['HIS'] ;
false.
When you take a look to the different answers (you get them by entering ; after each answer) you can see that Instance 1 of process step 'set_up_surgery_plan_extended#pid_0' again can be executed by Jack and John. The possible actions are finish and abort. Based on these possible steps in the submitted state, you can now perform a certain action using the predicate perform_action/4 again. Let's say process step 'set_up_surgery_plan_extended#pid_0' should be finished this time by Jack, then copy & paste:
ModelState = model_state([
process_state('set_up_surgery_plan_extended#pid_0', [1-start-['http://ai4.inf.uni-bayreuth.de/ontology/individuals#Jack']-[]-['HIS']]),
process_state('set_up_surgery_plan_extended#pid_1', []),
process_state('set_up_surgery_plan_extended#pid_2', []),
process_state('set_up_surgery_plan_extended#pid_3', [])],
0),
'set_up_surgery_plan_extended#pid_0'(_)::perform_action(finish, ModelState,
1-['http://ai4.inf.uni-bayreuth.de/ontology/individuals#John']-[]-['HIS'],
NextModelState).