# Efficient and Secure Management of Medical Data Sharing Based on Blockchain Technology
## 4 Medical Data Provenance Methods
### Naive Provenance Method  
In data provenance, based on the data structure of medical data and operational behaviors data, medical data and operational behaviors data can be represented as shown in Figure 4. \begin{table}
\begin{tabular}{|l|} \hline \{ \\ TxnType: String[data], // String [data] Types of content that can be put on \\ the blockchain, such as medical data or operational behaviors data. \\ PartyId: String, // Participant ID information that occurs on the chain, \\ usually a serial number of a hospital. \\ OpSign: String, // The signature information of the operational data itself on \\ the blockchain, calculated by the business (the unique identifier of \\ operational behavior). \\...... \\ \hline \end{tabular}
\end{table} 
Table 1: Data structure of medical data. \begin{table}
\begin{tabular}{|l|} \hline \{ \\ TxnType: String[data], // String [data] Types of content that can be put on \\ the blockchain, such as medical data or events \\ PartyId: String, // Participant ID information that occurs on the chain, \\ usually a serial number of a hospital. \\ DataSign: String, // The signature of the data. \\ DataStage: String, Business-level data stage information. Generally refers \\ to raw data or data in the \\ intermediate processing stage. \\ DataType: String, // The data type at the business level, generally refers to \\ the data storage format (file / *db / from API, etc.). \\ OpSign: String, // The signature information of the operation data itself on \\ the blockchain, calculated by the business (the unique identifier of \\ operational behavior). \\...... \\ \hline \end{tabular}
\end{table} 
Table 2: Data structure of operational behaviors data. In Figure 4, we divide medical data into raw medical data and processed medical data. According to the designed data structure, the BehaviorSign field in the raw medical data is NULL, while the BehaviorSign field in the processed medical data points to a specific operational behavior record, indicating that the processed medical data must have been obtained through an operation. When given a piece of processed medical data, the values of the EventInputs and EventOutputs fields can be obtained through the operational behaviors data pointed to by the BehaviorSign field, allowing us to know which data and how they were processed to obtain these data. Based on the designed data structure, the forward tracking and backward tracing methods are shown in Algorithms 1 and 2, respectively. ```
Input: ID of medical data \(d_{id}\), time interval or block number interval: \([f,t]\) Output: The results of backward tracing results
1 dataList = [\(d_{id}\)], results = []; hData = getMedicalData(\(d_{id}\));
2 opSign = getOpSignOfData(hData) //Get the Sign of hData;
3 ifopSign == NULLthen
4 return (\(d_{id}\))
5 else
6 forlength(dataList) > 0 do
7 opSign = getOpSignOfData(dataList[0]);
8 eventInputs, eventOutputs = getEvents(opSign);
9 dataList += eventInputs;
10 foritem in eventInputsdo
11 results.append((item, dataList[0], opSign));
12
13 end for
14 delete dataList[0];
15
16 end for
17
18 end for
19
20 end for
21
22 results = naiveInterval(results, [f,t]); // Obtain the results that meet the constraints [f, t];
23 return results;
24
25 end for
```  
**Algorithm 1**Naive provenance--backward tracing  
Figure 4: Linkage between medical data and operational behaviors data. From the algorithm description, we can see that the time complexity in the backward tracing phase is \(O(m)\), while the time complexity in the forward tracking phase is \(O(t*p)\), where \(m\) and \(t\) are the path lengths of forward tracking and backward tracing, respectively, and \(p\) represents the number of al behaviors data stored in the interval \([l,r]\). We can see that when the value of the interval range \(|r-l|\) increases, the value of \(p\) also increases rapidly, which will cause the efficiency of forward tracking to decrease rapidly, while having almost no effect on the efficiency of backward tracing.