A Novel Medical Blockchain Model for Drug Supply Chain Integrity Management in a Smart Hospital

.


Introduction
In the current era, every human being has the right to good health facilities. The emergence of an increasing number of diseases on a daily basis has also introduced new drugs into the market with different new labels. These drugs help the patient to get instant relief from pain, but despite the advantages, these drugs also have disadvantages. These drugs are manufactured by different pharmaceutical companies, and the authenticity of these organizations is unknown. According to the World Health Organization (WHO), tens of thousands of deaths occur in developing countries due to fake drugs, and many of the victims are children [1,2]. According to statistics, the annual business loss of US pharmaceutical industries is approximately $200 billion due to drug counterfeiting [3,4]. Counterfeiting is not the main reason itself; rather, as compared to traditional drugs, these counterfeit drugs produce different side effects to human health. These drugs may not help patients at all: Instead of curing the patient, they affect their health, and the side effects are even more dangerous to a person's system that uses conventional programming languages for smart contracts [12]. This opens up vast possibilities for using product-centric enterprise systems. In this paper, the main focus is the design and implementation of a secure drug delivery system based on blockchain using Hyperledger Fabric in a smart hospital. The system will show how blockchain using Hyperledger Fabric technology can be used to securely share and control drug delivery record information among different departments of the hospital. The following are the overview of the contributions being made: Initially, we developed a novel drug delivery blockchain platform in which electronic prescription along with drug dose, doctor, and patient information is stored and shared in a secured permissioned chain of network in an efficient way across different departments of the hospital. This blockchain platform is moving towards a new web-based model for a user-friendly interface using front-end programming languages such as JavaScript and HTML5 to enhance the usability of the management of assets and participants within the organization. Moreover, we used the Composer REST APIs to visualize the product-specific services. We also used smart contracts in order to provide the data consistency of the drug and other heath-related information. The access control policy was also defined to authenticate and authorize the request for the transactions in the proposed system. For cases of a large number of transactions and medical information, we present a new approach to incorporate and deploy Couch DB for each node to avoid data redundancy across the blockchain file system. Finally, we checked the hands-on experience of the system by applying a factual case study in a smart hospital based on Hyperledger Fabric. The remaining paper is categorized into seven sections which are as follows: Section 2 explains the related work on drug delivery blockchain-based solutions and also gives a critical analysis on existing healthcare systems based on blockchain. Section 3 gives the detailed system methodology, design architecture, smart contract design, and overall transaction process of the proposed system. Section 4 elaborates on the implementations, smart contract modeling, and distributed ledger storage design of the proposed system. Section 5 presents the results of the proposed system. Section 6 enlightens the implications of the proposed work through benchmarking with current healthcare solutions, and Section 7 concludes the paper.

Related Work
Blockchain is the one of the most revolutionized technologies of the future. It uses distributed ledger technology to record and transmit transparent, secure, controllable, and fault-tolerant data. Blockchain has the capability to make organizations decentralized, transparent, efficient, democratic, and secure. Over the years, many blockchain platforms have been proposed in the literature. These blockchain applications could be segregated into three categories, i.e., Public Blockchain, Private Blockchain, and Consortium Blockchain [11]. In this study, our main focus is to cover heath-related blockchain and medicine supply chain in blockchain. The following are few of the industries that have disrupted blockchain (e.g., supply chain management, networking and internet of things, forecasting, banking and payments, insurance, forecasting, private transportation, carpooling, online data storage, voting, real estate, government, charity, health, energy management, forecasting, online music, and retail).
In [13], the author introduced MedRec, which is a blockchain-based decentralized distributed ledger technology for sharing and maintaining patients health records. The MedRec is a bitcoin-based solution that aims to resolve issues like system interoperability, slow access to medical data, patient, agency, fragmentation, etc. The novel blockchain-based solution provides patients with complete access to medical information and immutable logs across providers. The MEdRec platform manages to keep patients' medical records secure and provides confidentiality, accountability, and real-time sharing of heath record. The MedRec block data signify viewership and ownership shared by the users of a private, peer-to-peer network. The MedRec is a smart contract-enabled platform that uses proof-of-work as a consensus algorithm in its working mechanism [14]. The smart contract uses a cryptographic hash function to secure the integrity and privacy of patients' heath records. The smart contract structure of MedRec is categorized into two parts, i.e., register contract (RC), patient-provider relationship contract (PPR), and a summary contract (SC). The RC is responsible of identity registration, PPR provides ownership, access info, EMR queries and hashes, permissions and mining bounties, and SC is responsible for maintaining the patient medical history and also gives details about the patient's current status in the system.
At present, one the main problems in healthcare is that organizations hold multiple and fragmented health records of patients. In [15], MedicalChain solved these problems by putting medical record transactions on the blockchain to create a smart healthcare ecosystem. In MedicalChain, a smart contract is launched to give time-limited access to a patient's electronic health record. Doctors write notes and scan lab results, which are all recorded as transactions. The pharmacy dispenses medication and also records the transaction on the blockchain. The patient gives time-limited access to their insurer for verification of treatment and payment settlement. The patient gives time-limited access to their insurer for verification of treatment and payment settlement. With smart contracts, patients allow doctors to remotely review medical cases and provide advice or a second opinion. Patients give access to their health record to insurers to monitor fitness progress and be rewarded with tokens or reduced insurance premiums. Patients are also rewarded for giving research institutions time-limited access to their health record for medical trial purposes. MedicalChain issues Med Tokens, which patients use for storing electronic health records on the blockchain, data from wearable fitness devices, and transfer value and payments. MedicalChain will also be a platform that enables developers to build smart applications that analyze all of these data and provide recommendations, such as nutrition and fitness routines.
MeFy is a subscription-based model, in which the user of the MeMe Care signs up for a yearly subscription, allowing them any number of tests throughout the years for the cost of just consumables. Through its eConsult feature, MeFy connects worldwide doctors to worldwide patients, thereby solving accessibility issues, and with its MeMe Edge device, it provides authenticity to the test conducted. MeMe Edge powered by AI will possess capabilities to generate autoprescription for off-the-shelf medicine by processing individuals' past health data, treatments, and environmental factors impacting the health of individuals of the area. Due to its eConsult function, Mefy connects worldwide doctors with worldwide patients, thereby solving the accessibility problems, and using the MeMe Edge device, it ensures the authenticity of the test conducted [16].
MedicoHealth is a blockchain-based project designed to improve the fragmented healthcare system. The MedicoHealth platform allows for fully anonymous and safe client communication with world's leading physicians. Physician credentials, together with license validity information, are updated in an immutable decentralized database. Patient data are anonymously stored and accessed only by selected physicians for a limited amount of time. Payments are fully tokenized and anonymous. Tokens run the system and compensate the service provider, platform, underlying protocol, and blockchain layer use [17].
MediBloc's healthcare information platform is a personal data ecosystem for patients, providers, and researchers, built on blockchain technology [18]. Our mission is to streamline medicine for patients, providers, and researchers by redistributing value behind personal healthcare data ownership. Through MediBloc, you can effectively own your medical data, providers can remove redundancies to provide better care, and your valuable data can help researchers to push the advancement of medicine faster than ever.
In [19], the author enlightened the challenges in current healthcare blockchains. According to the study, the pharmaceutical supply chain is one of the most prominent industries which needs attention. The WHO says that around $200 billion worth of fake, counterfeit, and substandard medicine is supplied in the global market every year [5]. Therefore, many blockchain healthcare platforms have been introduced, e.g., block verify [19], chronicled [20], farmatrust [21], and many others to secure the pharmaceutical supply chain.
The author in [22] presented a method to share medication history in a secure and efficient way among different healthcare institutions. In this study, a decentralized medication management system (DMMS) was introduced, in which a physician examines the patient and writes a prescription. The prescription is encrypted with the patient's public key, and no one can access the patient's record without his or her private key. The patient can view his or her record with different perspectives, and at the same time, the doctor can also view the patient's record after approval of the patient. The proposed system assures the integrity, authenticity, security, and privacy of medication history across different healthcare institutions.
HDG (Healthcare Data Gateway) [23], a smart application that allows a patient to control and manage the sharing of healthcare data, is a blockchain-based application that consists of a gateway and a traditional database. The smart application manages patient medical data in a blockchain ledger or a storage system. The HDG-centric healthcare ecosystem is divided into three layers, i.e., the storage layer, data management layer, and data usage layer. The storage layer provides independent storage, which is highly secure and available for healthcare data. The medical data are stored in the private blockchain, which is encrypted with different cryptographic techniques. The data management layer works as a gateway which evaluates all the incoming and outgoing data access. The layer also manages patient data and also authorizes other application data. The data usage layer contains the list of entities that use or access the medical data of the patient.
Healthbank [24] is a blockchain-based startup known for controlling, managing, and sharing data related to patient healthcare among different healthcare organizations. Healthbank is a Swiss digital startup which shares the patient's personal medical history and records with the permission of the patient in a secure way. The decentralized application is secure, robust, and efficient.
The "counterfeit medicine project" was recently launched by the Hyperledger. The Hyperledger project aims to target drug counterfeiting and its current use cases. Notable research companies like IBM, Cisco, Accenture, Intel, Bloomberg, and block stream are currently involved in this research network of drug counterfeiting. According to this project, every drug which is manufactured is issued with a timestamp on it. Therefore, in a blockchain technology, every drug which is produced is traceable with its origin and manufacturer details. This project decreases drug counterfeiting [25,26].
Healthcare is based on many existing systems and is another area that is well suited for disease. One of the main problems in hospitals is that there is no secure platform for storing and analyzing data. The lack of adequate infrastructure might often make it a victim of hackers. However, in block chain technology, hospitals can safely store data such as medical records and share them with certified authorized experts, doctors, and patients [27]. The enriched features of blockchain technology improve data security and help to enhance the correctness and timeliness of diagnosis. Gem [26] and Tierion [28] are two emerging companies focusing on the current medical data center based on blockchain technology.
In the supply chain, block chain technology transactions are recorded permanently and are monitored safely and transparently. This greatly reduces the time required, which minimizes the chances of human errors. Blockchain technology can also be used to monitor cost, labor, as well as waste and emissions at every step of the supply chain [29]. The distributed ledger technology enables the state of a fair-trade product by providing ethnicity and tracking its origin. Many of the blockchain startup working in the industry (i.e., Provenance, Fluent, Skuchain and Blockverify) are using blockchain to improve supply chain networks [30,31] .
In the present era, due to a lack of resources and infrastructure crowdfunding, it has become a common technique of fund raising for new startups and projects. There exists a crowdfunding platform which developed a conviction between supporters and project creators, and they charge high fees. Instead of creating trust through traditional approaches, blockchain smart contracts are used, and online reputation systems are used for crowdfunding. This blockchain crowdfunding removes the need for a middle-man [32]. New projects can raise capital by issuing tokens and be exchanged for products, services, or cash. Several blockchain-based startups like Starbase [33] raised millions of dollars through such token sales.
Today, due to lack of transparency and mistakes in public records, buying and selling real estate is difficult. In the real-estate industry, blockchain technology is also used to keep records secure, transparent, and to speed up the buying and selling process. The decentralized distributed ledger ensures the accuracy of a document, tracking, verifying ownership, and transferring property deeds [34]. Ubitquity [35] is a secure platform based on blockchain technology for real-estate records-keeping that is a substitute of a legacy-based system.
Energy management has been a very concentrated industry for a long time. Energy consumers and producers cannot purchase energy directly from each other and have to go through a trusted private intermediary or public grid. TransactiveGrid [36] is an Ethereum-based startup that permits its customers to buy and vend energy from each other in a peer-to-peer way.
UK-based GovCoin uses blockchain technology and is serving the government in allocating public benefits [37]. Contenders like blockchain are very efficient for implementing basic income. Startups like circles use blockchain technology to develop and implement a universal basic income [38].
Corruption, poor management, and dishonesty are the main causes that affect the growth and progress of every institution. Applying blockchain technology in every process of government operation can reduce the involvement of bureaucracy and also makes the operation secure, transparent, and efficient. Dubai is transforming all of its government operations by aiming to use systems based on blockchain technology by the end of 2020 [39].
Voting is one of the main areas of society that blockchain will disrupt. Blockchain technology ensures that only the registered voter can vote, and only authentic votes are counted. The distributed ledger and smart contracts can verify the voter's identity and keep track of every electronic polled vote. The public-viewable ledger is the main step toward a free and fair election [11]. Two startup companies like Democracy Earth [40] and Follow My Vote [41] are planning to disrupt democracy by developing a voting system for government based on blocking technology.
Corruption and inefficient management corrode every single organization. In the case of a charity, it is important that only those in need get money, i.e., those who are really meant to have it. The BitGive Foundation is a blockchain-based charity firm that uses a distributed ledger which is secure and transparent. Thus, using blockchain technology, donors can easily track and make sure their money is going to end up in the right hands and received by the intended party [42].
At present, everything is accessible through the cloud. Therefore, people use online storage like google drive, one drive, and many other service providers which give free space to their user. However, in cases of a centralized server, the data are managed and controlled in a central location, so they can be easily become victims of hackers. In centralized servers, there is also the chance of data loss and human error because everything relies on a central computer. Storj is an example of a decentralized cloud storage platform using blockchain technology.
Blockchain revolutionized the local transport industry by introducing e-wallet and its decentralized behavior. The decentralized concept of blockchain allows its users and owners of a ridesharing app to agree on terms and conditions without the involvement of a third-party provider. Arcade City [43] and La'Zooz are the two startups that use blockchain technologies. The built-in e-wallets make it easier for car owners to pay expenses like highway tolls, parking tickets, electricity top-ups, and car maintenance automatically for their vehicle. Currently, Innogy, UBS, and ZF are a few of the companies that use e-wallet, which was developed using blockchain technology [44].
Trust management plays a pivotal role in the insurance Industry. Blockchain technology is an innovative way of dealing trust and can be used to authenticate and track numerous types of data in insurance contracts like the identity of insured persons. Previously, these insurance companies relied on oracle and other software companies for data management, but in the future, not even just insurance companies but also oracle and other software companies will collaborate with blockchain to integrate real-world data with smart contracts. Aeternity [45] is a powerful tool that provides real-world data for the insurance industry.
IBM and Samsung jointly introduced a new idea called ADEPT (Autonomous Decentralized Peer-to-Peer Telemetry) using blockchain technology. The ADEPT concept is to create the decentralized network of Iot devices and aims to eradicate the centralized mode to handle communication. The main purpose of ADEPT is to create an environment in which devices will able to communicate with each other directly, update and monitor the system performance like software updates and bug management [46], etc.
Blockchain technology has transformed the entire approach to consulting, forecasting, research, and analysis. Blockchain-based platforms like Augur are a decentralized market for predications. This Ethereum-based solution is used to monitor and place bets on everything like stocks, election, sports, weather, and even cryptocurrencies in a decentralized manner [47].
Due to the emergence of blockchain technology, the data are secured as they never were before. Although the ledger in blockchain is shared, nevertheless, the data are encrypted and verified using enhanced cryptography algorithms. This cryptography algorithm protects data from theft and also maintains the integrity of data [48].
Blockchain removes the barrier of current banking and payment systems by giving access to financial services. People who do not have access to traditional banking systems use bitcoin, which allows them to send money anywhere across the world instantly, securely and with comparatively lower fees. Several banks around the globe like Barclays espouse blockchain technology to increase business and make their transactions efficient, fast, and secure. According to IBM, 65% of the total recognized banks around the world will start using blockchain by the end of 2019 [49].
As stated above, theses blockchain platforms are either not open-source or they are permissionless; therefore, the general user cannot modify them for their own purpose. Furthermore, most of the systems presented in literature reviews are either related to managing electronic medical records or sharing the health records of patients and doctors. Nevertheless, none of these systems will address secure drug delivery combined with doctor and patient management using Hyperledger Fabric platforms. Moreover, many of the systems discussed above use the inherent cryptocurrency which increases the computational power during the transaction. To the best knowledge of the author, there has been no functional, medical blockchain model for drug supply chain management based on Hyperledger technology built so far.

Scenario of Drug Supply Chain Management
Blockchain has revolutionized the healthcare industry by its unique decentralized distributed technology. The scenario of proposed drug supply chain management based on blockchain is shown in Figure 2. The graphical description represents the medical blockchain which manages and updates the complete supply chain, storing data related to drug, pharmacy, pharmacist, medical prescription, doctor, patient, nurse, and drug dose. The drug delivery data lakes act as a separate repository also called a stored-off blockchain. The data lake is a useful tool used for tasks such as analytics, visualization, and reporting of medical data. It would be beneficial not only for a hospital but also for other healthcare-related organizations that require medical data for their daily transactions. Furthermore, doctors can also view patient data with the patient's permission and the patient can also share their data with any doctor within the network. These permissions can be set by defining the access control policy in the smart contract in order to maintain the privacy and integrity of patients' data. The developed system contains reliable nodes which are responsible for executing a consensus protocol for the purpose of distributed ledger consistency. Initially, the doctor examines the patient and defines a therapy, drug dose, and other advice in the form of a computerized prescription. Then, the computerized prescription is sent to pharmacy personnel who analyze the authenticity of the prescription and request the pharmacist to prepare the drug cart. The pharmacist then sends the drug cart to the pharmacy personnel for cross-verification with the computerized prescription. The prepared drug cart along with the computerized prescription is sent to the head nurse, who verifies and updates the drug inventory of the ward and requests the nurse to start the patient therapy procedure. Finally, the nurse administers the therapy to the patient in accordance with the doctor prescription. The complete structure of the proposed drug supply chain management is shown in Figure 3.

Proposed System Architecture of Drug Supply Chain Management
The primary concern for a blockchain network is to record information in a distributed manner. Each block comprises a number of transactions that are hashed and encrypted. The proposed blockchain-based structure of drug supply chain management is shown in Figure 4. The developed application is based on a user service framework that uses a smart contract and distributed ledger as middleware. In the proposed system, the transaction proposal is sent by the end user (i.e., doctor, nurse, pharmacist, and patient) through the application to call backend services like medical prescription, profile management, appointment, EDR (electronic drug record), data sharing, pharmacy management, etc., provided by the proposed blockchain network. The blockchain transaction has complete CRUD (create, read, update, and delete) operations that transform the ongoing data between the connected nodes. However, in cases of private and secure transactions, we introduce the subnetwork concept to distinguish the entire network into a separate private network. The main purpose of this private network is to share confidential data directly with the concerned department without exposing them to other departments. The proposed drug delivery system allows each department to create their own subnetworks for the purpose of secure data sharing.
The unique feature of the proposed system is that it is built on a permissioned network which differentiates it from other blockchain-based systems. This feature allows only the valid participant to participate and enroll in the blockchain network through a user identity manager. The user identity manager provides certificates for user enrollment and user authentication. Moreover, these services are related to user identity validations, verification, and signature generation for individual users who participate in the blockchain network. The consent manager represents the consensus that is responsible for connecting a department with a subnetwork through a provided interface and also controlling the transaction order. Each department in a drug delivery blockchain contains nodes and a distributed ledger. The node is capable of storing data and also contains a smart contract that is responsible for endorsing the transaction proposal or write transaction block to the ledger. The goal of the consensus algorithm is to ensure that only a single history of transactions exists, and the history does not contain invalid or contradictory transactions. The distributed ledger technology records the immutable and transparent transactions, logs, and histories of all the events and actions into the network. In order to keep the consistency of every ledger, a copy different cryptographic and consensus protocols have been employed, e.g., digital signatures and hashing. The responsibility of a node in a network is to sustain the replica of a blockchain, and it is also responsible for processing the transaction. Figure 5 gives the inside view of a blockchain node. The node in blockchain comprises a smart contract, blocks, state database, and policies. The state database is used to represent and store the state of the ledger at a given point and time. The sample white box representation of a node indicates the relation between the state database and block.  Each ledger entry represents the states corresponding to the drug data. A drug has attributes like name, quantity, expiry-date, etc. that are stored with their values. The blockchain ledger contains a block where the first block is called a genesis block and others represent the transactions corresponding to drugs like (Tx 1 , drug 1 ), (Tx 2 , drug 2 ), (Tx 3 , drug 3 ), and (Tx n , drug n ) in the ledger state. The last part is the endorsement policy that decides which transaction is to be added to the ledger based on node agreement, i.e., AND ('Dept1.member', 'Dept2.member'); both departments are required to accept the transaction, and OR ('Dept1.member', 'Dept2.member'); one is required to accept the transaction.

Smart Contract of Drug Supply Chain Management
A smart contract adds functionality to blockchain, as it is a computer program that can execute transactions and access blockchain blocks and the history.
It is a computer program that is stored in the distributed database. A smart contract allows the addition of constraints, validations, and business logic to transactions. They could be considered similar to database triggers. A smart contract is not just a computer program, it is an agreement between parties. It contains parts for entering the contract, executing operations, and exiting. There are main challenges faced by blockchain developers while writing smart contracts. For instance, smart contracts are primarily implemented by relatively newer programming languages like Solidity, and therefore, the learning curve is very steep, and maintenance is hard. Furthermore, the performance of transaction execution is very limited because transactions are executed by all nodes in a sequence. In order to resolve these issues, we installed smart contracts only to define subsets of a node instead of all nodes, due to which, transactions are only executed on a specified set of nodes. This technique can improve the performance and execution scale of the proposed system and will also achieve higher parallelism and concurrency for the network. Moreover, we used different known programming languages like Java and Node.js to program the smart contract in order to provide ease to developers. The proposed system contains several functions that make it possible for the user to interact with the ledger. For example, the doctor can check the complete information related to drugs, such as the stock in inventory, and the patient can check his or her prescription; in other words, the user has complete access of CRUD operations and can query only those information which the user is authorized to access. Users can retrieve their information by acquiescing a transaction to the smart contract. The smart contract-based application takes the transaction and executes several kinds of queries and updates the ledger state by appending the transaction in blocks and returning the updated result to the application as a response. Figure 6 illustrates the ledger queries and updates using a smart contract in the proposed drug supply chain system. Update Ledger Figure 6. Querying and updating a ledger using a smart contract.

Transaction Process of Drug Supply Chain Management
Transaction management is split between peers and orderers. This allows higher parallelism and concurrency for the network. Every transaction is executed in the peer using the world state. If the transaction succeeds, it is signed with a Peers certificate. Executing transactions prior to ordering allows each node to process multiple transactions at the same time. The orderer will not re-execute the transaction: They will just order them and will not maintain the ledger. This also enables the peers to trust all orderers and vice versa, so they can run independently. Figure 7 shows the overall transaction process and role of every individual component of the network inside the proposed blockchain-based drug supply chain management. The user manager issued the credentials to client application in order to authorize for sending transaction proposals. The transaction process starts when the client application sends a transaction proposal to nodes, due to which the communication starts over the client SDK. The nodes which participates in the network can be either committers or endorsers. The responsibility of an endorser node is to sign and authorize the proposal for transactions, while the committer node validates the results in responses to the transaction and writes a transaction block to the ledger. The endorser node also acts as a committing node and is used for receiving and executing a proposal for the transaction by invoking a smart contract without updating the ledger. The endorser node collects and reads the RW (read-write) sets from the present world state during the transaction. The endorser node then signs these RW sets and returns the response to the client application for further processing. The client application then compiles the signed transaction in the form of a package and submits it to the consensus manager along with the RW sets.The consensus occurs in parallel throughout the transaction process with the RW sets and signed transaction and then is sent to committer nodes in the form of blocks. After that, each transaction is validated by comparing its RW set with the present world state. The validated transaction is then written into the ledger, and the endorser will also update the current world state from the RW sets. Finally, the committing node generates an asynchronous alert for the submitted transaction on whether it is successful or not. The committer node also gets notified for every event by registering events through the client application.

Development Environment
The development environment of the proposed case study is categorized into two parts, as illustrated in Figure 4. The front-end and back-end were developed in separate environments. The back-end implementation for drug supply chain management in a docker environment is described in Table 1. All the implementation and experimental work of this study was carried out on Ubuntu Linux 18.04 LTS with an Intel Core i5-8500 @ 3.00GHz processor and 8 GB memory. Moreover, for the docker running environment, we used a Docker engine (version 18.06.1-ce), and for the configuration of the container and the docker image and in the virtual machine, we used docker-compose (version 1.13.0). We used an open-source framework Hyperledger Fabric (v1.2) project hosted by Linux Foundation. Python (v2.7.15) and Node (v8.11.4) are a prerequisite of a Fabric network to develop client SDK. We used a Composer web-playground to design and develop the business network definition, and for deployment, we used a Composer CLI tool for the proposed blockchain platform. We used a Composer REST server to create the REST-API for the participant, assets, queries, and transactions to visualize the back-end business logic to the graphical user interface (GUI). The tool and technologies for GUI implementation for the drug supply chain management are mentioned in Table 2. The web application for the front-end was developed using HTML5, CSS3, and for dynamic programming, we used Java-script. In order to make the web application more efficient and user-friendly, we used third-party toolkits like jQuery and Bootstrap. The back-end and front-end interact with each other using a REST API server. The client performs some action on the web application that will trigger the HTTP method like POST, GET, PUT, and DELETE, which in response perform according to the client HTTP request.

Network Topology for Drug Supply Chain Management in a Medical Blockchain Platform
The network topology for the drug supply chain management in a medical blockchain platform is presented in Figure 8. The key design features woven in Hyperledger Fabric were used to design and develop the proposed system architecture as illustrated in Figure 4. The fundamental element of the blockchain network is the peer that is responsible for hosting a ledger and smart contract to perform basic operations on the ledger (e.g., READ, WRITE). Hyperledger Fabric also supports creating multiple blockchains called channels. A channel is a secure blockchain which is used to provide confidentiality and data isolation. The ordering service is the nodes which are responsible for ordering the transaction into a block. In this section, we explained the network topology of the proposed system in reference to channels, peers, and ordering services. The network topology for the proposed system is categorized into three departments, i.e., Cardiology as D 1 , Neurosurgery as D 2 , and Medicine as D 3 . These three departments are grouped into one channel, which is represented as C 1 . Moreover, these three departments together are involved in an agreement to make a network policy for setting up and initializing a blockchain network. The private communication between departments D 1 , D 2 , and D 3 is carried out in a C 1 . The C 1 is administrated according to the rules described in the channel policy (CP 1 ) created by D 1 , D 1 , and D 3 . The smart contract (SC 1 ) and Ledger(L 1 ) are hosted on Peers (i.e., P 1 , P 2 , and P 3 ). The role of the ordering service is to create channels and allow other nodes to participate in a specific channel. Client applications (A 1 , A 2 , and A 3 ) connect with other network entities with the help of C 1 . Each department is linked with a certificate authority (CA), e.g., A 1 belongs to D 1 issued by CA 1 , A 2 belongs to D 2 issued by CA 2 , A 3 belongs to D 3 issued by CA 3 , etc. Every department member and user is issued with a public key infrastructure (PKI)-based certificate by CA.

Building Component of the Business Network
In Hyperledger Fabric, there are three main components for building a business network, i.e., participants, assets, and transaction. The proposed business network is shown in Figure 9.
The participants in the proposed network are the doctor, patient, nurse, and pharmacist. The assets include the drug, prescription, order, and repository. Lastly, the transaction contains updatePrescriptionTime, updateDrugDose, updateDoctorComment, shareDrugRecordWithDoctor, updateDrugDetails, UpdateDrugorderStatus, and ShareRepositoryRecordwithNurse. Initially, the doctor examines the patient and defines a therapy, drug dose, and other advice in the form of a computerized prescription. Then, the computerized prescription is sent to the pharmacy personnel, who analyze the authenticity of the prescription and request the pharmacist to prepare the drug cart. The pharmacist then sends the drug cart to the pharmacy personnel for cross-verification with the computerized prescription. The prepared drug cart along with the computerized prescription are sent to the head nurse, who verifies and updates the drug inventory of the ward and requests the nurse to start the patient therapy procedure. Finally, therapy is administered to the patient in accordance with the doctor's prescription.

Smart Contract Modeling of Drug Supply Chain Management in a Medical Blockchain Platform
Hyperledger Composer [50] is an open-source framework and toolkit for developing blockchain applications. It is used to design and implement a smart contract in blockchain application. The smart contract in Hyperledger comprises four components, i.e., model, query definition, script, and access control rules. In blockchain technology, the business network is run by the participants, and every participant owns a number of assets and can submit transactions. However, in the proposed blockchain platform, the participants are doctors, pharmacists, nurses, and patients. Every participant is modeled as an identifier and has some properties. Similarly, assets are also represented like participants, and assets can be anything, like services, goods, property etc. The summarized drug supply chain management definition in a medical blockchain is mentioned in Table 3, containing information related to drug, medical history, and personal information.
Transactions are also defined during smart contract modeling, which aims to interact with assets, similarly to transactions, participants, and events, which are also defined and can also interact with the entities involved in multiple blockchain networks. Once the events are defined, they also become a part of transaction processor functions and process in a similar way as transactions will be processed. Table 4 presents the definition of transactions and events used in the proposed blockchain.
In Figure 10, the script file contains a transaction process function which is triggered. It contains functions like CREATE, DELETE, UPDATE, etc. to modify the values of assets and participants in the blockchain network. Transaction processor functions are written in JavaScript and confined in an isolated file as a portion of a smart contract definition. The ShareRecord function updates the drug record asset in the registry and then triggers an event.  The access control language (ACL) provides declarative access control over the elements of the domain model. By defining ACL rules, we can determine which users/roles are permitted to create, read, update or delete elements in a business network's domain model. Figure 11 illustrates the ACL rules in which all participants access all operations and commands in the business network, including network access and business access. In Hyperledger Composer, queries are also defined in a separate file and written in a bespoke query language. Queries are used to retrieve data from a world state. The query is divided into two parts, i.e., statement and a description. In the description, we describe the function of the query, which is composed of a string, and in the statement, we use statement operators like, e.g., SELECT, FROM, WHERE, AND, OR, CONTAINS, and ORDER BY for defining specific rules in a query. Figure 12 describes the queries used in drug supply chain management in a medical blockchain.  Figure 13 represents the REST APIs generated by the Composer REST server for interaction between the client end and back-end. The Composer REST server API comprises three parts i.e., resource, verb, and action. The resource contains the request path, and the verb signifies the action performed on a particular resource, e.g., POST, GET, PUT, and DELETE. The list of resources that are used in the proposed solution is presented in Figure 13.

Distributed Ledger Storage Structure of Drug Supply Chain Management in a Medical Blockchain Platform
The ledger technology in Hyperledger Fabric comprises two distinct parts, i.e., a world state and a blockchain. The world state database is capable of storing cache of the current value of the set of the ledger state. The world state by default stores the current value of ledger state; because of this, developers can easily access the current state without traversing the entire transaction log. The data in the world state are stored in a key-value pair. The world state is so flexible that each time a state is changed, it automatically updates the state value, e.g., ownership of some assets or transfer of record to others. There are two appropriate choices of state database that are selected based on the format of the data. The default state database used is LevelDB, which is used to store smart contract data in a key-value pair. The default database is located within the node of a network and embedded within the same process of the operating system. The second one is CouchDB, which is used to format smart contract data in a JSON document. CouchDB is an optional alternate state database that supports rich queries when chaincode data values are modeled as JSON. Rich queries are more flexible and efficient against large indexed data stores, when you want to query the actual data value content rather than the keys. CouchDB is a JSON document datastore rather than a pure key-value store therefore enabling indexing of the contents of the documents in the database. In CouchDB, content-based JSON data can be retrieved from queries. CouchDB supports all types of requests through which data can be accessed through REST APIs. Figure 14 represents the record of the drug assets as a ledger state. Drug1 is stored in CouchDB and has a key-value pair. CouchDB stores both single key-value pairs and multiple key-value pairs as a simple and complex state. If you have a mix of JSON and binary data values, you can still use CouchDB; however, the binary values can only be queried based on key, key range, and composite key queries. { "DrugID": "7385", "drugname": "Panadol", "makers": "GlaxoSmithKline", "ExpireyDate": "2020-02-15T14:59: 46.382Z", "patient": "resource: composers.participant.Patient#Anum", "doctor": "resource:composers.participant.Doctor#Faisal"

State Database
... Similarly, in the case of blockchain, the records are always stored as a file. As the blockchain is only capable of storing small sets of operations, blockchain records all the changes occurring in the world state as a transaction log. These transactions are then composed as an encrypted block that is cryptographically linked to form a chain-like structure. This chain structure is used to store transactions on the ledger in a sequence, ordered by time. The main advantage of blockchain is data immutability: Once written, the stored data cannot be changed or deleted even by administrator.

Execution Results
This section illustrates the execution of the proposed system and provides some snapshots illustrating the process of execution. Tables 1 and 2 show the implementation environment of both the front-end and the back-end of the proposed system, which were investigated and discussed in an earlier section. Similarly, Figure 13 shows the detailed API request and response of different modules of the proposed system with the Hyperledger Composer REST server. Firstly, the network authorizes the user by validating the user ID, then the request will be initiated by the client to the REST server in order to submit the transaction to the proposed blockchain platform. In order to perform the transactions, the smart contract functions are triggered by the blockchain platform, which returns a response to the client after successful execution of a transaction. Figure 15 shows the doctor dashboard showing a web form to allow the doctor to add their profile. The entered data have been validated, and if the form field is not filled out or contains an invalid value, an exception is thrown, and as a result, the form does not proceed further. Data validation is crucial in any system design, since if the parameters are given wrong values, this will have a drastic effect on the overall results of the system, and there will be endless anomalies in the overall flow of the system. The proposed doctor dashboard user interface allows the users to perform CRUD on a selected doctor. Similarly, in Figure 16, the user can update the existing doctor information by sending a request to the blockchain platform, and on successful response, the doctor information will be repopulated on the user interface. Doctor attributes like username, specialization, firstname, lastname, and department will be updated on successful response from the Hyperledger Composer REST server.
In Figure 17, the doctor record can also be verified by providing DoctorId as a parameter to doctor API in the Hyperledger Composer REST server. The query request is sent to rhe blockchain platform and on successful response, it will generate responsecode as 200, responsebody which contain the meta-data (i.e., department, specialization, firstname, lastname, username, and email address) of the specific doctor against the requested id, and requestedURL on which the request was sent. The response of request can be viewed as a json format on the Hyperledger Composer REST server. The request URL contains the address of the API along with the port on which it is running.   Figure 18 illustrates the details of an individual drug along with the patient and doctor. The drug management dashboard allows the user to add information of a specific drug. The entered drug data have been validated, and if the form field is not filled out or contains an invalid value, an exception is thrown, and as a result, the form does not proceed further. The proposed drug management interface allows the user to perform CRUD on a selected drug by specifying DrugId. Moreover, drug management also keeps the record of individuals' prescribed medicine by the corresponding doctor. Additionally, drug description, expiry date, manufacture date, and manufacturer are also stored to describe the overall behavior of the drug. Similarly, in Figure 19, the user can update the existing drug information by sending a request to the blockchain platform, and on successful response, the drug information will be repopulated on the user interface. Drug attributes like drugname, price, description, makers, expiryDate, manufacturerDate, and unitofMeasure will be updated on successful response from the Hyperledger Composer REST server. The authenticity of a record can also be verified by querying directly on the Hyperledger Composer REST server. In Figure 20, the query request "/api/queries/selectDrugRecordByName?drugname = Tramadol" is initiated by the client to the REST server in order to submit the transaction. The Hyperledger Composer REST server responds to the query request in the form of a ResponseBody, which contains the meta-data related to the drug. The response of the request can be viewed in a json format on the Hyperledger Composer REST server. The request URL contains address of the API along with the port on which it is running.  Figure 21 demonstrates the prescription dashboard in which details of an individual prescription are recorded. The prescription holds the record of a patient with the assigned doctor and the number of drugs prescribed by the doctor along with doctor notes, all stored in prescription management. The prescription management dashboard allows the doctor to add the information of a specific patient during patient examination.The entered data have been validated, and if the form field is not filled out or contains an invalid value, an exception is thrown, and as a result, the form does not proceed further. The proposed prescription management interface allows the doctor to perform CRUD on a selected prescription by specifying PrescriptionID. Moreover, the doctor can also update the drug dose and doctor notes of a specific patient. Additionally, prescription management also keeps track of individual drugs which are prescribed by the doctor in prescription. Similarly, in Figure 22, the user can update the existing prescription information by sending a request to the blockchain platform, and on successful response, the prescription information will be repopulated on the user interface. Prescription attributes like prescriptionID, PrescriptionTime, doctor, drugdose, and DoctorComment will be updated on successful response from the Hyperledger Composer REST server. The record authenticity of a prescription can also be verified by querying directly on the Hyperledger Composer REST server. In Figure 23, the query request "/api/Prescription/Prescription3" is initiated by the client to the REST server in order to submit the transaction. The Hyperledger Composer REST server responds to the query request in the form of a ResponseBody, which contains the meta-data related to the prescription. The response of the request can be viewed in a json format on the Hyperledger Composer REST server. The request URL contains the address of the API along with the port on which it is running.  Figure 24 shows the snapshot related to transaction history. The transaction history represents the complete log of activities performed through the web to blockchain platform. The log contains attributes like timestamp, which represents the time of transaction and is unalterable, type, which represents the type of transaction performed, and participant, which is the user of the system who performed that specific transaction.  Figure 25 represents the details of a specific transaction in which transactionID, TransactionType, TransactionInvoked, ParticipantInvoking, IdentityUsed, and transactionTimeStamp are mentioned. Every single activity performed in the system can be verified from the history dashboard.

Performance Evaluation
We used Hyperledger Caliper as an open-source performance benchmark framework for a blockchain-based solution [51]. The Hyperledger Caliper project is an initiative of Linux Foundation and is used for benchmarking blockchain solutions. Hyperledger Caliper currently supports many blockchain solutions like Fabric v1.0, Sawtooth 1.0, Iroha 1.0, Burrow 1.0, and also Hyperledger Composer. The Hyperledger Caliper benchmarking tool supports many performance indicators like success rate, transaction throughput, and transaction latency (minimum, average, maximum, and percentile). It also indicates the resource allocation of the proposed system (e.g., CPU, Memory, IO). The performance benchmark tool environmental setup is represented in Table 5. We calculated the results against the following metric. A brief description of each metric is given below.

•
Transaction Response Time: It is the time in which a success is measured by the amount of time a transaction takes to request and get response from a blockchain platform. Resource Utilization: It is a process to utilize resources while processing transaction request and response. Resource utilization can be measured by checking the utilized resources by CPU, Memory, Network, and IO by the blockchain SUT in a defined time period.

Simulation Results
Figure 26 provides a comparison between three different user groups in order to investigate the response time of the proposed system. We ran the simulation for a time period of 100 ms. In general, the response time increases as the number of users increase querying the system at a same time. The three categories of user groups are 100 users at first round, 300 users at second round, and in the end, we evaluated the performance by increasing users to 500. Figure 26 illustrates the response of the system for the first two groups that are almost the same but when we increase the number of users to 500; the response time increases only 15 ms for the first 500 transactions. Although the number of user increases, the response time of the system remains stable. Figure 27 investigates the transaction per second (TPS). Similarly to Figure 26, we also used the same number of user groups in order to evaluate the TPS of the proposed system. In general, if we have one user sending a request to the server, it responds after 100 ms, and the TPS is calculated as Number of user = 1000 ms/100 ms, which is 1 × 1000 ms/100 ms = 10 TPS . As illustrated in Figure 27, the user-group with 100 users has an average of 40 tps for an elapsed time of 100 s. However, if we increase the number of users, the tps also increases. In the case of a group with 300 users, the average tps is 70, and with 500 users. the average tps is 115 with an elapsed time of 100 s.  Figures 28 and 29 describe the average, min, max, and percentile latency to execute the invoke process and query function of the proposed system. We calculated the latency of the proposed blockchain system by querying the transaction with three different user-groups. As illustrated in Figure, the user-group with 100 users has an average latency of 154 ms. Similarly, in the case of a group with 300 users, the average latency is 172, and with 500 users, the average latency is 436. In general, if the number of users increases, the latency of the system also increases. In the case of 90% percentile latency, it can be clearly seen that if we increased the user number from 90% to 95%, the latency of the system also increased by 5 ms, and the same applies for the 95% and 99% line. The minimum latency of a group with 100 users is 108 ms, for 300 users, it is 107 ms, and for 500 users, it is 127 ms. Likewise, for a group with 100, 300, and 500 users, the maximum latency is 228 ms, 443 ms, and 1147 ms, respectively.  Figure 29 demonstrates the case of invoking transaction latency is higher than querying transactions because invoking transaction requires peers to perform endorsement, which requires additional time. The user-group with 100 users has an average latency of 1519 ms. Similarly, in the case of a group with 300 users, the average latency is 1472, and with 500 users, the average latency is 1393. In the case of 90% percentile latency, we clearly see that if we increase the user number from 90% to 95%, the latency of the system is also increased by 199 ms, and the same is also the case with the 95% and 99% line. The minimum latency of a group with 100 users is 243 ms, for 300 users, it is 293 ms, and for 500 users, it is 344 ms. Likewise, for a group with 100, 300, and 500 users, the maximum latency is 2540 ms, 2964 ms, and 2471 ms, respectively. The resource utilization of the proposed system is present in Table 6 in terms of CPU (max), CPU (avg), Memory (max), Memory (min), Traffic In, and Traffic Out, carried out in 10 iterations by the proposed system. As we see in the table, the local client consumes an average CPU of 8.76% and maximum of 14.64%, which is the normal usage of CPU by any process. If we investigate memory allocation of the proposed system for local-client maximum memory, the utilization is 105.2 MB, and average memory utilization is around 90.5 MB. Moreover, if we see the average resource utilization of all peer nodes in terms of CPU and memory, then the average CPU consumption of all peer nodes is approximately 6.68%, and the average maximum CUP consumption is 11.83%. In terms of memory allocation, the average maximum memory allocation of peer nodes is 107.69 MB, and the average is 99.91 MB. If we analyze the orderer node, then the maximum CPU utilization is 14.95%, and average CPU utilization is 6.75%. In terms of memory, the maximum memory allocation of the orderer node is 93.6 MB, and the average memory allocation is 88.7 MB. In the case of the ca_node, the average and average maximum CPU utilization is 0%; however, average memory and average maximum memory allocation is 3.66%. The resource utilization of CPU and memory is neither too high nor too low in the designed platform; therefore, if user requests exceed, this will not effect the SUT, although if the CPU utilization is more than 30%, then we consider system performance as low or poor.

Conclusions
Blockchain has shown its capability to transform the traditional supply chain industry into a secure, automated, anonymous, persistent, audible, and decentralized supply chain. In this paper, we described the design, implementation, and performance evaluation of the proposed drug supply chain integrity management in a smart hospital based on Hyperledger Fabric. The proposed system is a proof-of-concept application that keeps track of individual drug records using blockchain technology in a decentralized way. It enables doctors, nurses, patients, and pharmacists to manage, access, and share personal medical records and also a complete individual drug life cycle in a secure and accountable way through comprehensive logs. In order to achieve the transparency, security, and privacy of the proposed system, we used a smart contract developed in the solidity programming language in combination with permissioned blockchain architecture (i.e., Hyperledger Fabric). Furthermore, we also designed a web application which interacts with the blockchain platform to expose the services to the front-end. A number of experiments were carried out in order to test the performance analysis of the proposed system in terms of transaction response time, throughput, latency, and recourse utilization. Our results indicated that using blockchain technology increases the performance in terms of throughput and also minimizes latency of the proposed system with less utilization of resources. The potential future direction could be to increase the network size and then to check the performance and feasibility by deploying the system in a real environment.