# A Hyperledger Fabric-Based System Framework for Healthcare Data Management
## 5 Discussion
\begin{table}
\begin{tabular}{p{142.3 pt} p{142.3 pt}} \hline \hline
**Functions** & **Details** \\ \hline \multicolumn{3}{c}{The parameter can be 3 or 4. When the first parameter is “patient”, the current time will be automatically obtained in the web (the following time is the same) and passed in together with the patient’s ID or username entered on the front-end. When the first parameter is “doctor”, the current time will be passed in together with the doctor’s ID, patient’s ID entered on the front-end. This function first verifies the number of parameters, then determines whether the first parameter is patient or doctor, and goes to different execution contents. The former (patient) obtains the world state value of the patient’s username directly from the ledger, records the “read” operation, and finally returns the patient information. The latter (doctor) first obtains the world state value of the patient’s username from the ledger, determines whether the doctor’s username is in the patient’s authorized doctors’ array (that is, whether it is authorized), and if so, records the “read” operation and returns patient’s personal and medical information. Otherwise, it prompts “unauthorized” \\ \hline \multicolumn{3}{c}{The number of parameters is 2. This function verifies the number of parameters, then obtains the world state value of patient’s username from the ledger, adds the doctor’s username to the patient’s authorized doctor array, and then rewrites the modification into the ledger.} \\ \hline \multicolumn{3}{c}{This function is used for doctors entering the patient’s data into the system. We simplify the entry of each case into the following 6 parameters: the username of doctor, the username of patient, the test results, the doctor’s diagnosis, the treatment plan, and current time. This function verifies the number of parameters, and then obtains the world state value of the patient’s username from the ledger to determine whether the doctor’s username is in the patient’s authorized doctor array. If it is, the medical data (test result, diagnosis, treatment) will be written into patient’s account by the doctor. Then, the modified patient information and medical case will be rewritten into the ledger. The above “append” operation will also be recorded. If there is no permission, it will prompt “unauthorized”.} \\ \hline \multicolumn{3}{c}{This function is used to query medical data for research or supervision purposes. It has 4 parameters, which are user category (researcher/regulator), the user’s username, query keywords, and the current time. The function first verifies the number of parameters, and then uses rich query to query all cases in the ledger that contain the keyword in the diagnosis category. It returns the content that meets the conditions, and then records the read operation as well as role, username, time. Otherwise, it prompts that there is no information that meets the conditions.} \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Functions in the smart contract. illegal acts such as theft of patient privacy information. Based on the above reasons, at present, the proposed solution is more suitable to be implemented through the Hyperledger Fabric framework. As the core of blockchain technology, the consensus mechanism is an important factor that affects the deployment of the system, the design of business logic, and system performance. Hyperledger Fabric gave up the previously adopted Solo and Kafka consensus because Solo has few applicable scenarios and Kafka needs to deploy Zookeeper externally. At present, Hyperledger Fabric adopts the Raft consensus, which is a Leader-follower model. The leader node is determined by dynamic election and each follower node is the replication of the leader node. The configuration of the Raft consensus is simpler and can better reflect the characteristics of decentralization in the blockchain. It is also suitable for multiple organizations and channels.