# Model to Program and Blockchain Approaches for Business Processes and Workflows in Finance
## 4 Overview of the Insurance Claim Processing
### Transforming the Extended UML with Blockchain to Petri Nets
#### 4.4.2 Transformation Algorithm  
For our Algorithm 1, we define first the set of components from both the extended UML-AD and Petri nets.  
**Definition 2**.: _The input model of Extended UML-AD_  
* _Node is for initial, Final or decision node._
* _Action is for action._
* _Edge is for edge._
* _Work flow is for join or fork._
* _Block is for added block._
* _Data is for added data._  
**Definition 3**.: _The output model Petri nets_  
* _Place is for Place._
* _Transition is for Transition._
* _Arc is for Arc._
* _Token is for Token._  
We initialize the unprocessed elements to all the elements in the input model and then process them one by one through specifying the type of the workflow, whether it is a join or a fork; and even the type of the activity node is defined, whether it is an initial, final, or decision node, and then we pursue the created transformation rules (Table 3) until we complete all elements in the set.  
\begin{table}
\begin{tabular}{c p{142.3 pt}} \hline \hline \multicolumn{2}{c}{**Transformation Rules from UML AD to Petri Nets**} \\ \hline Rule 1 & The initial node from UML AD is transformed into a place in Petri nets and the name of the place is the same as the initial node. \\ \hline Rule 2 & The final node from UML AD is transformed into a place in Petri nets and the name of the place is the same as the final node. \\ \hline Rule 3 & Every action node from the UML activity diagram is transformed to a new place in Petri nets. \\ \hline Rule 4 & Every decision node from the UML activity diagram is transformed to a new place in Petri nets, and the name of the place has the same name as the decision. \\ \hline Rule 5 & Edges in the UML activity diagram are transformed into new transitions in Petri nets. \\ \hline Rule 6 & Join (And Join workflow) in UML activity diagram is transformed to a non-real transition with incoming arcs from the joined places in Petri nets. \\ \hline Rule 7 & Fork(And Fork workflow) in the UML activity diagram is transformed to a non-real transition with outgoing arcs from the places split. \\ \hline Rule 8 & Every block added by the UML profile is transformed into a place in Petri nets. \\ \hline Rule 9 & Data contained in blocks added by the UML profile is transformed into tokens/resources in Petri nets. \\ \hline \hline \end{tabular}
\end{table}
Table 3: Transformations rules from UML AD to Petri nets.  
```
Input: an extended UML model \((Node,Action,Workflow,Edge,Block,Data)\) Output: a Petri net \((Place,Transition,Arc,Token)\) Initialization: \(proc\_elements:=\varnothing,non\_proc\_elements=\{i\mid i\in Input\}\); \(node\_type\in\{Initial,Final,Decision\}\) \(workflow\_type\in\{Join,Fork\}\) while\(|\)\(non\_proc\_elements\mid\
eq 0\)do if\(i=Node\)then if\(node\_type=Initial\)or\(node\_type=Final\)or\(node\_type=Decision\)then  add\(Place\to Output\);  add\(i\to proc\_elements\); endif endif if\(i=Action\)then  add\(Place\to Output\);  add\(i\to proc\_elements\) endif if\(i=Edge\)then  add\(Transition\to Output\);  add\(i\to proc\_elements\) endif if\(i=Workflow\)then if\(workflow\_type=Join\)then  add\(Non\_Realtransition\to Output\);  add\(Incoming\_Arcs\_from\_joined\_Places\to Output\);  add\(i\to proc\_elements\) else if\(workflow\_type=Fork\)then  add\(Non\_Realtransition\to Output\);  add\(Outgoing\_Arcs\_from\_forked\_Places\to Output\);  add\(i\to proc\_elements\) endif endif if\(i=Edge\)then  add\(transition\to Output\);  add\(i\to proc\_elements\) endif if\(i=Block\)then  add\(Place\to Output\);  add\(i\to proc\_elements\) endif if\(i=Data\)then  add\(token\to Output\);  add\(i\to proc\_elements\) endif endwhile
```  
**Algorithm 1** Extended UML AD to Petri net Transformation algorithm