# Efficient and Secure Management of Medical Data Sharing Based on Blockchain Technology
## 4 Medical Data Provenance Methods  
### Definition and Examples of Medical Data Provenance  
When performing medical data provenance on the platform, we mainly focus on two types of transactional data: medical data and operational behaviors. Operational behaviors can link the original medical data, intermediate data, and final data, ultimately allowing the provenance-related transactional data on the chain to be represented in a graph. In Figure 3, we provide a schematic diagram of the topological structure between medical data and operational behaviors. Each vertex in the graph represents a unique record of medical data, and the edges represent operational behaviors. Edges with the same number belong to the  
Figure 2: Blockchain network structure diagram.  
same operational behaviors. Vertices with zero in-degree represent the original data, and vertices with zero out-degree represent the final data. In this paper, the processing process of medical data represented by a graph is a directed acyclic graph.  
In this paper, we study two types of data provenance methods: forward tracking and backward tracing. Forward tracking refers to the process of finding out what processing operations have been performed on a given data record and what new data have been generated. Backward tracing refers to the process of finding out which original data were used to generate a given data record, what operational behaviors were performed on it, and what intermediate data were generated. Below, we provide a formal description of data provenance in this paper.  
Let \(S\) represent a complete blockchain with \(n\) blocks, i.e., \(S=\{B_{1},B_{2},\cdots,B_{n}\}\). Each block \(B_{i}\) is represented as a tuple \(B_{i}=\langle H_{i},K_{i}\rangle\), where \(H_{i}\) represents the block header information of block \(B_{i}\); \(K_{i}\) represents the transaction data in block \(B_{i}\), which is a set composed of \(m\) transactions, i.e., \(K_{i}=\{TX_{1},TX_{2},\cdots,TX_{m}\}\). The provenance query can be expressed as \(Q=\langle P,S,[f,t]\rangle\), where \(P\) represents the query conditions, and \([f,t]\) represents the time or block interval for query or provenance. After executing the query based on the query conditions \(P\), all transaction data that exist directly or indirectly dependent on the transaction \(TX_{i}\) within the interval \([f,t]\) are returned to form \(Q\). In this paper, if \([f,t]\) represents a time interval, then \(index=time(TX)\) indicates the time when \(TX_{i}\) was generated. If \([f,t]\) represents a block number interval, then \(index=block(TX)\) indicates the block number where \(TX_{i}\) is stored. If \(index<f\), forward tracking will be performed to obtain all related transactions within the interval \([f,t]\) with transaction \(TX_{i}\). If \(index\in[f,t]\), both forward tracking and backward tracing will be performed. If \(index\geq t\), backward tracing will be performed.  
Let us take Figure 3 as an example to illustrate the medical data provenance described in this paper. For the vertex \(L\), the out-degree is 0, so we can only perform backward tracing. The results of backward tracing for \(L\) can be represented as \(((J,K),g,L)\), \(((G,H),e,\)\(J)\), \(((G),f,K)\), \(((C,D),b,G)\), \(((D,E),c,H)\). For the vertex \(G\), both the in-degree and out-degree are not 0, so we can perform both forward tracking and backward tracing. The results of forward tracking for \(G\) are \(((F,G),d,(I))\), \(((G,H),e,(I))\), \(((G),f,(K))\), \(((J,K),g,(L))\), and the results of backward tracing for \(G\) are \(((C,D),b,(G))\). For the vertex \(A\), the in-degree is 0, so we can only perform forward tracking. The results of forward tracking for \(A\) are \(((A,B,C),a,(F)),((F,G),d,(I))\).