Research on drug traceability system based on blockchain technology

. Because of the frequent occurrence of drug safety incidents in recent years, drug safety cannot be effectively guaranteed. The purpose of this study is to establish a blockchain-based drug traceability system and strengthen the construction of a drug information technology traceability system. Because the traditional drug traceability system depends on a certain center, there are many traceability participants, and the information is difficult to integrate, resulting in incomplete and unreliable traceability information. The use of blockchain technology can achieve data tamper-proof and decentralization so that each drug can be tracked through the unique identifier on the blockchain to ensure the integrity and authenticity of the data. Finally, "one thing, one code, one traceability code" will be realized, to strengthen the sharing of traceability information, realize the traceability of the whole variety and process, and improve drug safety. The drug traceability system consists of the data collection system, product traceability identification system, data statistical analysis system, and other subsystems. The platform uses distributed ledgers, blockchain, data technology, smart contracts, data mining and analysis, and other technologies to achieve multiple functional requirements such as anti-counterfeiting traceability of enterprise products, process tracking, data statistics, and so on.


Introduction
Drug safety is a significant livelihood and public safety issue related to people's health, social harmony, and stability. However, there have been frequent medical accidents in recent years, including data forgery in production and research and opaque information in transportation. In recent years, the global world has continuously established a drug safety supervision system and improved the drug safety supervision laws and regulations system and the safety supervision technical support system. Drug supervision needs a more accurate and reliable drug traceability system.
Setting up a drug traceability platform helps foster the ethical management of the pharmaceutical industry and contributes to assuring the quality and safety of drugs.
The anti-counterfeiting and traceability system of "one thing, one code" technology has natural application value in the pharmaceutical manufacturing industry [1]. All nodes can be recorded and tracked throughout the process, from raw material procurement to product sales. One thing one code has the characteristics of convenience and timeliness and cannot be forged or tampered with. Drug production, transportation, and sales are regarded as a node in the chain. Each batch of drugs has detailed production, transportation, and sales information. In drug circulation, every participant can supervise the process, ensuring the reliability of drug sources. In addition to ensuring the rights and interests of consumers, pharmaceutical enterprises and pharmacies can also timely write off, and upload information, ensure the integrity and accuracy of data, and assign responsibilities to individuals. To fundamentally eliminate consumer doubts, a drug quality traceability system must be established to realize the traceability of drug information in the whole supply chain, from raw material supply to drug sales.
However, because traditional drug traceability relies on a centralized organization, there are many traceability participants, and it isn't easy to integrate information, which leads to the result that traceability information is not complete and reliable [2]. This study uses the decentralized characteristics of blockchain and combines it with distributed ledgers to encrypt data to make drug information more authentic and transparent.
The medical supply chain is a critical foundation for crucial services in everyday life. The system's intrinsic complexity may bring some impurities, such as erroneous information, a lack of transparency, and restricted data sources. Counterfeit medications are one of the outcomes of the present supply chain limitation, which causes major economic losses to the healthcare business and has serious negative repercussions on human health [3]. The advent of internet pharmacies, in particular, has resulted in recurrent safety issues in medicine delivery.
As a result, current research highlights the importance of a strong, end-to-end medication supply chain tracking and tracking system. The drug supply chain's end-to-end product tracking system is critical for ensuring product safety and eliminating counterfeit drugs. The majority of present tracking and tracking systems are centralized, which causes concerns with data privacy, transparency, and authenticity in the healthcare supply chain.
The Hyperledger Fabric blockchain platform is used in a new and original Medledger system for tracking and tracking blockchain. The Medledger system facilitates the efficient and secure execution of medication supply chain transactions in the pharmaceutical stakeholders' private licensed distributed network [4]. The traceability system described in this study eliminates the need for trusted intermediates, offers transaction records, enhances efficiency, assures security through high integrity, dependability, and safety, and lowers the risk of intervention on Medledger data [5]. To manage and control the interactions among stakeholders in the drug supply chain ecosystem, use sequence diagrams to design, code, and apply chain codes. To preserve and give maximum transparency and traceability, the system permanently keeps and records all activities, events, and transactions on the blockchain's immutable Medledger and integrates with point-to-point decentralized file systems like IPFS, Swarm, and file currencies.
There is also a way to apply blockchain technology to the drug information storage platform and RFID technology to the drug production and logistics information collection link. According to the findings of the study, employing a drug traceability system based on blockchain technology and RFID technology may make drug traceability information more full, safe, and trustworthy, and the query process is simple and quick [6].
The primary goal of this paper is to use blockchain to solve medication traceability issues in the medical profession. To ensure drug information cannot be tampered with, data is written into the blockchain using various technologies such as distributed ledgers, smart contracts, and consensus mechanisms to ensure that drug information cannot be tampered with for consumers, quality inspection institutions and regulators to complete drug traceability. The weak centrality of the blockchain is used to maintain the information traceability system of drugs from production jointly, and circulation to consumption is established based on the characteristics of non-tampering. The design of a drug traceability system based on blockchain is completed, ensuring the safety of drugs and greatly attacking the counterfeiting and trafficking of drugs in the drug industry.

Functional requirements
It includes the recording of drug production information, such as manufacturer, production time, batch number, etc., to facilitate the traceability of the production process; at the same time, it also records the drug circulation information, including sales, inventory, transportation, etc., to facilitate the traceability of the circulation process. Therefore, users can query the production, distribution, sales, and other information about drugs by scanning the QR code or entering the drug code. To actualize the supervision and management of medications over their full life cycle, multi-party organizations such as manufacturers, distribution businesses, and drug regulatory agencies must collaborate and supervise the drug traceability system. To prevent data from being tampered with or leaked, the drug traceability system must also offer data security and privacy protection, as well as use encryption technology and access control methods.

Data requirements
In this era of big data, almost all functions are based on data processing, and data is divided into three types: 1. It comes from the data of enterprise management, production, and sales. These data are generally based on CRM, ERP, and other systems, and are generated by the business activities of the enterprise.
2. Data from machines and sensors, such data includes device log information, call records, transaction data, etc.
3. Data from social networks. This type of data is generated by social activities between people, including individual identity information, behavior information, and interaction information.
Massive and diverse data are gathered together, making data storage, reading, verification, screening, cleaning, etc. face huge challenges. Therefore, data analysis becomes more important. Data analytics can be used to identify patterns, trends, and anomalies in data collected throughout the pharmaceutical supply chain. For example, data analytics can help identify common sources of contamination or quality issues during production, enabling manufacturers to improve their processes and reduce the risk of unsafe drugs entering the market. In addition, data analysis can also be used to monitor drug circulation and sales patterns to identify potential problems with counterfeit or substandard drugs entering the market. Suspicious behavior can be recognized and action is taken to prevent the sale of dangerous drugs by evaluating sales data and tracing the flow of medicines across the supply chain. In addition to identifying potential security issues, data analysis can also be used to gain insight into market trends and needs. By analyzing sales data and identifying patterns in consumer behavior, manufacturers can make informed decisions about the type and amount of medicines to produce, reducing waste and ensuring medicines are available where they are most needed.
The blockchain's immutable and trustworthy openness and transparency enable more data to move safely. One common example is how blockchain enables big data gene sequencing. Blockchain big data sequencing employs private keys to control access rights, decreases the constraints of utilizing laws to prevent persons from getting genetic data, and effectively completes sequencing activities using distributed computing resources. The blockchain's security overcomes the industrialization challenge of DNA sequencing and encourages the secure flow of data. When the data is continually published, data changes and trends may be collected, and reports are made, through the gathering and analysis of data. Through the system, you can not only view the detailed content of the report but also customize and selectively view and export the report. At present, the mainstream BaaS platform alarm system implementation scheme is often based on Prometheus+Grafana+AlertManager. Because it is an external third-party platform, there is a lack of business event alarms, non-blockchain native alarms, and business alarms that cannot be flexibly connected to heterogeneous chains. And the low quality of warnings. The new alarm system adopted supports users to dynamically configure alarm rules according to business demands, based on the organic combination of the blockchain's built-in audit contract, KVSQL on the chain, and collectors, and checks the monitoring objects through periodic triggering activities (chain or node) whether there is an abnormality, once the abnormality is detected, the alarm activity will be reported to the alarm management module, and the alarm module will decide how to deal with the corresponding alarm (such as grouping, filtering, suppression, etc.) according to the relevant configuration and the current alarm status, and notification methods (such as SMS, email, DingTalk, etc.). Users can know the abnormal events on the blockchain the first time, such as "node attack", "double spend problem", "abnormal account", "fork", etc., to reduce business losses.

Other requirements
The system is designed and developed in such a way that a lot of hardware and software is included in the usage process. All this must comply with the main international, national, and industrial standards. For example, the operating system, network system, and development tools used in development must conform to common standards. Developing this system on its own requires good design work to develop a proven technical specification to ensure that the code is easily readable, usable, and portable.
The accuracy and timeliness of system processing are also essential functions of the system. In the process of designing and developing the system, the current and potential future workload of the system should be fully considered so that the processing capacity and response time of the system can meet the user's demand for information processing. System accuracy requirements mainly include the following.
1. the ability to provide the correct registration and login mechanism 2. the ability to accurately record drug information, including transport personnel information, etc.

Users can get the correct information of drug information by scanning the QR code
The query function of the drug traceability system is crucial for the functional and performance completion of the entire system. As a source of system data, its accuracy largely determines the success or failure of the drug traceability system. In the process of developing the system, it is necessary to apply certain methods to ensure accuracy of the system.
By the way, the drug traceability system is directly user-oriented, and users may not be very familiar with the application function interface of this system, which requires the system to provide a good user interface and an easy-to-use human-computer interaction interface. To achieve this, the system should use terms familiar to users as much as possible and provide sufficient online help for possible user usage issues to shorten the process of familiarity with the system for users.
Correctness of data entry is a prerequisite for data processing; Incorrect input can lead to incorrect and inaccessible system output, which will make the system work meaningless. Data entry sources are barcode scanning and manual input. Manual input requires the system to be fault-tolerant, so the system must have some computing power to ensure fast data processing.
Data consistency and integrity remain important. Since the system's data is shared, the problem of how to ensure the consistency of this data must be solved. To resolve this issue, some people are required to maintain data consistency, control where the data goes when data is entered, and impose strict restrictions on the data integrity of the database. Constraints should be defined for the input, and if integrity constraints cannot be met, the system should reject the data.

Systematic crowd-side analysis
The end users of this project are roughly divided into the following categories: manufacturers, administrators, distributors, and general users.
Manufacturers: The role of drug distribution data entry in the system, responsible for the processing of raw materials into drugs.
Administrators: Verification of registration information through manufacturers, management of transporters' information and manufacturers' information, drug traceability data query, etc. Distributors: The link between manufacturers and hospitals and other places in the distribution of drugs, responsible for the transit of goods.
Users: Users of drugs, this system is responsible for traceability inquiries and commodity authenticity inquiries.

Process
To protect the public safety of drugs, strengthen the implementation of the main responsibility of enterprises, accelerate the construction of drug information technology traceability system, through blockchain technology to achieve "one thing, one code, the same traceability code", strengthen the sharing of traceability information to achieve the whole variety of the whole process of traceability, enhance the level of drug quality and safety assurance. As shown in figure 1, demonstrated how the drug traceability system works.

Main modules
The drug traceability system consists of several subsystems such as a data collection system, product traceability marking system, and data statistical analysis system. It realizes various functional requirements such as anti-counterfeit traceability, process tracing, and data statistics of enterprise products. As shown in figure 2, Shows how people at different stages participate in the system.  Management System Management rights, notification alarms Table 1 shows the details of the Subsystem List.  Notification alerts Notification alerts Table 2 shows the details of the Function List.

Use of technology
Distributed architecture. The drug traceability system adopts distributed architecture, distributing each subsystem on different physical nodes and connecting each subsystem through the network to realize real-time data transmission and sharing. The distributed architecture can improve the reliability, scalability, and performance of the system.
Blockchain Technology. The drug traceability system can adopt blockchain technology to achieve data tamper-proof and decentralization. To assure the accuracy and integrity of the data, each medicine may be traced using a unique identity on the blockchain. Smart Contracts. Drug traceability systems can adopt smart contract technology to achieve automated management and rule enforcement. For example, in pharmaceutical transactions, smart contracts can automatically enforce the rules in the contract to avoid interference and misuse by human operations.
Data mining and analysis. Drug traceability systems need to adopt certain data mining and analysis techniques to extract valuable information and make corresponding decisions. Data mining and analysis techniques can be applied to many fields, including anomaly detection, trend analysis, risk assessment.
Data technology. Because the medication traceability system must manage a huge volume of data, big data technologies must be used for storage, processing, and analysis. Big data technology has the potential to increase the system's processing capacity and data processing efficiency.

Detailed design
The system design pattern, as illustrated in Figure 3, adheres to the following principles: single responsibility principle, open and closed principle, Richter replacement principle, dependency inversion principle, and so on.

Data storage solution
The data storage solution of a blockchain-based drug traceability system should be a multi-level and multi-type system. Blockchain is the primary data storage technology, and other data may be saved using other storage technologies to maintain data integrity, security, and efficiency [7]. In the meanwhile, proper encryption technology and access control strategies should be utilized to ensure data security and privacy. Blockchain Data Storage: To provide data security, immutability, and traceability, the primary data of the drug traceability system should be maintained on the blockchain. Blockchain technology stores data on multiple nodes in the network, and each node has a complete copy of the data. This decentralized data storage method can prevent single-point failures and data loss. In the drug traceability system, each block should contain important data such as drug batch numbers, production information, inspection reports, transaction records, and logistics information for full-process traceability.
Data Hashing: Each block should contain the hash value of the data to ensure the integrity and immutability of the data stored in the blockchain [8]. The hash value is a fixed-length string generated by hashing the data that may be used to validate the data's integrity and validity. If the data on the blockchain changes, the hash value changes as well, preventing data tampering.
Database storage: In addition to blockchain data, the drug traceability system also needs to store other types of data, such as drug information, user information, permission management data, and metadata. These data can be stored using a relational database or a document database. Relational databases can use SQL query language for data query and management, while document databases are more suitable for storing semi-structured data. These data should have basic database functions such as access control, backup, and recovery to ensure data reliability and security.
Document storage: The files in the drug traceability system include drug inspection reports, production records, and distribution records. These files can be stored using distributed file systems, object storage, and other technologies. Distributed file systems store files scattered across multiple nodes in the network, improving file reliability and availability. Object storage is more suitable for storing large-scale unstructured data and can achieve automatic backup, fault tolerance, and scaling. When storing files, the hash value of the file should be associated with the file name to ensure file integrity and security.

Algorithm
The SBFT consensus method can be utilized to tackle the problem of low performance of blockchain applications in a multi-node traceability scenario [9].
SBFT can be said to be an extension of PBFT, which solves the problem of scalability, can support the normal operation of 209 copies around the world, and can have twice the throughput and lower latency than PBFT [10].
SBFT adds four design improvements to PBFT to achieve these performance enhancements:  From PBFT to Linear PBFT  Add fast path  Use cryptography to allow single-message acknowledgment  Add redundant servers to improve resiliency and performance Service attribute. SBFT implements a fault-tolerant scalable universal replication service (i.e., a state machine replication service) on top of which a certifiable key-value store is built using Merkle trees. A smart contract layer that can execute EVM bytecode is added on top of it.
General service. Implements a deterministic replication service with stateful operations, deterministic operations, and a read-only query interface. 1) = ( , ): Modify the state according to the operation and return 2) = ( , ): query in return state without modification 3) The state of the service is changed in discrete chunks, each chunk containing some number of requests The implementation process is as follows: 1) Traceability data is gathered by smart devices during the medicine distribution process and transferred to the blockchain network after conversion via the gateway protocol.
2) The process of reaching a consensus on drug traceability data through the blockchain network. This is achieved using SBFT during the consensus determination phase. After this consensus process, the traceback data is added to the chain and the response address is returned.
3) The traceability data on the chain is shared among drug traceability companies, and transportation data, temperature data, drug quantities, etc. can be viewed by all companies and regulatory agencies. If there is a "broken chain" situation such as the number of drugs, the traceability system can quickly carry out early warning and processing.

Conclusion
This study has built a blockchain-based drug traceability system. Consider all possible problems involved in the development process. Designing and implementing this system involves much use of computer hardware and software throughout the process, all in line with the mainstream international, national, and industrial standards. In the independent development of this system, the code is easy to read, operable, and portable. During the implementation of this system, the possible workload is fully considered so that the system can have high accuracy, strengthen processing ability and reduce response time to meet the user's needs for information processing. There are also high requirements for accuracy and real-time data input and processing. Manual input requires the system to have fault tolerance. Therefore, the system must have the first-class processing capability to ensure faster data processing. Moreover, the drug traceability system is directly user-oriented, so it needs to provide a good user interface. Finally, the drug traceability system consists of the data collection system, product traceability identification system, data statistical analysis system, and other subsystems. The company has realized multiple functional requirements such as product anti-counterfeiting traceability, process tracking, data statistics using distributed ledgers, blockchain, data technology, smart contracts, data mining and analysis, and other technologies.