Batch 5
Batch 5
PHARMACEUTICAL PRODUCTS
TRACEABILITY USING EPCIS
A PROJECT REPORT
Submitted by
AISHWARYA.C (821316104002)
MAHALAKSHMI.G (821316104025)
SOUNDARIYA.V (821316104042)
SWETHA.K (821316104046)
BACHELOR OF ENGINEERING
in
i
ANNA UNIVERSITY: CHENNAI 600 025
BONAFIDE CERTIFICATE
Certified that this project report title “BLOCKCHAIN DRIVEN IOT FOR
PHARMACEUTICAL PRODUCTS TRACEABILITY USING EPCIS” is
the bona fide work of “AISHWARYA.C (821316104002),
MAHALAKSHMI.G (821316104025), SOUNDARIYA.V(821316104042),
SWETHA.K (821316104046)” who carried out the project work under my
supervision.
SIGNATURE SIGNATURE
Mrs. R.Kavitha, B.E., M.Tech.,(Ph.D.,) Dr. T.Kavitha, B.E., M.Tech.,Ph.D.,
HEAD OF THE DEPARTMENT SUPERVISOR
ASSOCIATE PROFESSOR ASSISTANT PROFESSOR
Department of Computer Science Department of Computer Science
and Engineering, and Engineering,
Parisutham Institute of Technology Parisutham Institute of Technology
and Science, Thanjavur. and Science, Thanjavur.
ii
ACKNOWLEDGEMENT
At the outset, we present our humble prayer to The Almighty for giving
us strength, courage, determination not only in pursuance of this task but also in
every walk of life.
We are much obliged and grateful to our Head of the Department and
Project Coordinator, Mrs.R.Kavitha, B.E., M.Tech., (Ph.D.,) Associate Professor,
Department of Computer Science and Engineering, for her continuous support not
only in this task but also in all our academic activities.
Last but not the least, we thank our beloved parents, faculty members and
friends for their timely help and valuable suggestions.
iii
ABSTRACT
The drug supply chain is the most complex and fragmented of all supply
chains. A lot of the producers and intermediaries are difficult to identify and track.
Examples of problems that have been difficult or impossible to solve with current
traceability system (BIDTS) is proposed in this study, to achieve the following: (i)
To integrate Blockchain and IoT technology for effective and efficient traceability.
(ii) To support shelf life adjustment and quality decay evaluation for improving
quality assurance. (iii) In the drug Electronic Product Code Information Services
(EPCIS) is used and the information is updated to view the status of the product by
RFID reader. (iv) Smart contract is used to coordinate the suppliers inside the
Blockchain. For the sake of better computational load, the Blockchain is modified
monitoring. It can be vaporized after the entire life cycle of traceability to release
computational resources of the system. By using such reliable data source, the
adjustment of shelf life, rate and order of quality decay. According to different
situations for each batch of perishable drug stuffs at drug processing sites.
iv
CONTENTS
ABSTRACT iv
LIST OF FIGURES vii
LIST OF ABBREVIATIONS ix
1 INTRODUCTION 1
1.1 Overview 1
1.1.1 Proof of work 3
1.1.2 Proof of stake 3
1.2 Objectives 5
2 LITERATURE SURVEY 6
2.1 Managing drug safety with pricing, contracts and 6
coordination in supply chain
3 SYSTEM ANALYSIS 16
3.1 Problem statement 16
3.2 Existing system 16
3.3 Proposed system 17
4 SYSTEM SPECIFICATION 18
4.1 Hardware requirements 18
4.2 Software requirements 18
v
5 SYSTEM DESIGN 19
5.1 Architectural diagram 19
5.2 Data flow diagram 20
5.3 UML diagrams 22
5.3.1 Use case diagram 22
5.3.2 Class diagram 23
5.3.3 Sequence diagram 24
5.3.4 State diagram 25
5.3.5 Activity diagram 25
5.3.6 Collaboration diagram 26
6 IMPLEMENTATION 27
6.1 Types of Modules 27
6.1.1 Enterprises module 27
6.1.2 Customer client module 28
6.1.3 Government regulator module 29
6.1.4 Enterprise user server module 30
6.1.5 Consumer traceability module 31
7 SYSTEM TESTING 32
32
7.1 Input design
7.2 Output design 32
7.3 Types of testing 33
7.3.1 Functional testing 33
7.3.2 Integration testing 33
7.3.3 Security testing 33
7.3.4 Performance testing 33
7.3.5 Specialized testing 34
7.3.5.1 Smart contract testing 34
7.3.5.2 Peer/node testing 34
8 CONCLUSION 35
9 FUTURE ENHANCEMENT 36
10 APPENTICS 37
10.1 Code 37
10.2 snapshot 50
11 REFERENCE 61
vi
LIST OF FIGURES
vii
10.2.13 ADMINISTRATOR LOGIN PAGE 58
10.2.14 BLOCKCHAIN VIEWING PAGE 58
10.2.15 USERS DETAIL PAGE 59
10.2.16 SEARCHING PAGE 59
10.2.17 FINAL PRODUCT DETAILS PAGE 60
viii
LIST OF ABREVATION
ABREVATION EXPANSION
BIDTS Blockchain IOT Based Drug Traceability System
DB Data Base
ix
CHAPTER 1
INTRODUCTION
1.1 OVERVIEW
1
There are many key issues under the drug traceability and tracking. One of
the key issues of pharmaceutical manufacturing supply chains is the incredible
number of incompatible computer systems providing virtually no visibility into
end-consumer sales for manufacturers. Some of the problems that arise from this
complex situation could be avoided easily with Blockchain by providing real-time
access to data and visibility across the entire pharmaceutical supply chain, from the
ingredient supplier’s product codes to the pharmacies dispensing prescriptions to
patients. Suppliers are currently working without a decentralised ledger, creating a
large hole in the infrastructure, and little-to-no security for its participants.
Pharmaceutical companies and pharmacy retailers are also involved in marketing
alliances involving rebates and coupons that deflate the value of the product in order
to boost exposure and that provide an unclear picture of how many drugs are on the
market. There are some difficulties while tracing a product and counterfeiting may
arises while transferring product between the distributors. So, this work is helpful
for eradicate this violation.
2
These characteristics ensure that the Blockchain technology is considered
to be the digital disrupter to exchange anything of value (e.g. transactions where
we have double spent problems) just as the internet is considered to be the digital
disrupter to exchange information. This has big implications for private
businesses, corporations and the public sector.
1.1.1 PROOF OF WORK
3
Proof of Stake have the same purpose of validating transactions and
achieving consensus. However, the process is quite different than in Proof of
Work systems. With Proof of Stake, there is no mathematical puzzle instead, the
creator of new block is chosen in a deterministic way based on their Stake. Proof
of Stake concept states that a person can mine or validate block transactions
according to how many products they have. This means that the more product
owned by a miner.
The huge financial burden in the manufacturing supply chain is the
thousands of third party companies that are paid handsomely to provide research
on the movement of pharmaceuticals. This enormous expense could be
drastically lowered with a Blockchain based tracking system. The main issues
with drug safety in the pharmaceutical supply chain are to do with how the drugs
are initially manufactured. The traceability of active pharmaceutical ingredients
during actual manufacture is a difficult process, so detecting drugs that do not
contain the intended active ingredients can ultimately lead to end consumer
patient harm or even death. According to the survey the number of deaths related
to these issues has been increasing in recent years. Blockchain’s advanced
features make it capable of providing a basis for complete traceability of drugs,
from manufacturer to end consumer, and the ability to identify exactly where the
supply chain breaks down during an issue. Despite the efforts of supply chain
managers, preparing inventories based on demand for pharmaceuticals can be a
difficult task without proper visibility into the supply chain. A Blockchain-based
system would enable manufacturers to efficiently manage inventory levels to
prepare for spikes in demand.
4
1.2 OBJECTIVES
There are many public safety issues where Blockchain can improve the
efficiency of delivering a safe and effective medicine to end consumer patients.
With Blockchain making real-time data available at the push of a button,
pharmacies and other retailers can improve their internal and external inventories
by tracking product movement from in store and in transit information.
Blockchain can fill in the gaps in pharmaceutical supply chains globally,
mitigating their direct impact on the overall population. It’s important to provide
a strong foundation of trustworthiness and safe practices for all patients and the
community as a whole. Blockchain integrates these values by generating
informative, real time responses to events potentially impacting patient health,
such as lifesaving prescription medication debuts and product recalls. Recall
management is another issue that Blockchain can solve by better managing the
process of informing the public of these types of important announcement.
According to national health interview survey up to one million people are killed
each year worldwide as a result of these types of errors, and better tracking
through the supply chain would have a significant effect on the current
pharmaceutical supply chain model.
This project proposes Blockchain technology applied to the
pharmaceutical sector. In this project Blockchain is used to track the information.
EPCIS having a unique number is used to identify the information of the product
and the quality of the product. Smart contract is implemented to coordinate the
suppliers in the supply chain. On the whole, the drug supply chain will be safer
and more secure.
5
CHAPTER 2
LITERATURE SURVEY
2.1 Paper Title : Managing Drug Safety with Pricing, Contracts and
Coordination in Supply Chains
Authors : Dung-Ying Lin ; Chieh-Ju Juan ; Ching-Chih Chang.
Publication : IEEE, December 2019,Volume: 17, Issue: 1
The objective was to design a safe and sustainable drug supply chain with Drug
safety mechanisms so that confidence-dependent demand can be positively
affected by centralized, decentralized and combined supply chain contracts. They
used java and PHP in this project. Here in this project the information and
communication technologies, including (i) Radio Frequency Identification
(RFID) and Near field Communication (NFC) (ii) chemical and biological
analysis, including isotope analysis is used to check the expiry state of the
product. These were applicable tools for tracing, tracking, identifying, and
monitoring the drug to maintain its quality and safety through the supply chain.
However, the growth of e-commerce business in perishable drug also facilitates
the international trading of perishable drug, and changes customer behaviour in
the supply chain, adaptability, efficiency, and reliability of such existing
traceability methods are insufficient to share information among the complicated
supply chain network. Incorporates consumer drug safety confidence into a
conventional supply chain contract model and then presents a mathematical
model for supply chain planning. It cannot analyse competition and cooperation
with respect to drug products in the market to better understand the effects of
drug safety concerns on the drug industry over various time periods.
6
Issues of seasonality Traditional systems do not prove the product ownership.
They still use a traditional method to maintain the supply chain process.
Counterfeiting products, such as branded goods, is one of the most important and
difficult issues to deal with in national or international markets. The collected
data about the product is stored in the cloud. The drug traceability system
contains the information of the product. When the product is shipped, the details
about the product is updated in the cloud. At the customer end, the consumer
knows the detail of the product but the details provided by the system (RFID) can
be changed easily, Sometimes the chip presented inside the sensor is changed
because of the humidity and temperature. The third party offense will arise when
the information is transferred in the cloud. Blockchain will maintain the blocks
by its own consensus algorithm but in the cloud the data can be easily altered. So
that the duplication of the product is not focused on this project. The workflow
between the supplier a manufacturer is not clearly mentioned in this project. Still
with the help of the RFID and the environmental sensor the workflow is not up
to the level. RFID cannot be implemented in all the drugs since it costs high. In
this project contract is implemented between the supplier and retailers can be
changed through various ways. Coordinating the supply chain is not an easy task.
But this supply chain easily coordinates the manufacturer, wholesaler and the
retailer with the help of the smart contract in this project. The main view of the
project is to create coordination in the supply chain. But it is not focusing on
duplication and quality of the product.
7
2.2 Paper Title : Blockchain-Driven IoT for Drug Traceability with an
Integrated Consensus Mechanism
Authors : Yung Po Tsang ; Chun Ho Wu ; George To Sum Ho ; Hoi
Yan Lam
Integrates the novel deployment of Blockchain, IoT technology and fuzzy logic
into a total traceability shelf life management system for managing perishable
drug. The objective is to integrate Blockchain and IoT technology for effective
and efficient traceability, to support shelf life adjustment and quality decay
evaluation for improving quality assurance with the improvement of living
standard, people begin to pay more attention to food safety and product quality.
Therefore, for consumers, it is necessary to establish a reliable system that can
trace the source of products. However, most existing traceability systems tend to
lack transparency, data is primarily stored within the enterprise, and the cost of
tampering with data is very low. Besides, the supply chain nodes are easy to
evade responsibility when product safety or quality issues arise under the
traditional centralized management model, and it is difficult to trace the root of
issues. The development of Blockchain technology provides us with new ideas
for realizing the traceability of products in supply chain scenarios. Due to its
characteristics of decentralization, transparency, and immutability, Blockchain
can be effectively used to alleviate the above problems. They proposed a product
traceability system based on Blockchain technology, in which all product
transferring histories are perpetually recorded in a distributed ledger by using
smart contracts and a chain is formed that can trace back to the source of the
products. In particular, an event response mechanism to verify the identities of
both parties of the transaction was designed, so that the validity of the transaction
can be guaranteed. All events are permanently stored in the form of logs as a
basis for handling disputes and tracking responsible entities. Furthermore, a
system prototype is constructed based on the testing framework.
8
Once a smart contract is deployed on the Blockchain, it will be executed
according to predefined rules, and no one can change it. The smart contract in
Ethereum is written as a stack based low level bytecode language, which is
performed by Ethereum Virtual Machine (EVM) and is called EVM code. These
codes are stored in the Blockchain in a binary form unique to Ethereum. Smart
contracts can also be written in high level languages, such as solidity, and then
compiled into EVM code. The core of Ethereum is the Ethereum Virtual
Machine, which can execute code with arbitrary algorithmic complexity. In
computer terminology: Ethereum is Turing complete. Developers can create
contracts and a wide variety of Daps on Ethereum Virtual Machine based on
existing programming languages (such as Java, Python). Since Bitcoin is
designed only for virtual currency scenarios, and it is not turing complete, the
universality is not high. Hence, many other Blockchain based systems have
emerged. Smart contract based product traceability system in the supply chain
scenario and different types of applications have been allowed to be represented
on the Blockchain in the form of ‘‘smart contracts’’. Ethereum first realized the
complete fit of Blockchain and smart contracts Smart contracts can handle a
variety of operation logics, making full use of the Ethereum Blockchain
capabilities, enabling the Blockchain more scalable and prompting Ethereum to
develop into the most extensive Blockchain development. The contract code is
deployed on a test network that runs in local memory, and a decentralized web
page interface is implemented based on the prototype. Finally, the system
security analysis and experimental results proved that their solution was feasible.
The limitations of their work were that the proposed consensus mechanism is
based on the scenario of drug traceability, instead of other supply chain
applications, and the consideration of drug authentication is not included in the
study.
9
2.3 Paper Title : Internet of Perishable Logistics: Building Smart Fresh Drug
Supply Chain Networks
Authors : Amitangshupal and Krishna Kant
The ultimate purpose of the paper is to inspire and engage researchers from both
communities to holistically examine the numerous difficult problems involved in
turning logistics systems into highly agile and efficient cyber physical systems.
Layered unified model called Internet of Perishable Logistics (IOPL) modelled
after the cyber Internet layered models (or models) were formulated in the
following aspects: Information and communication technologies, including
Radio Frequency Identification (RFID) and Near field Communication (NFC)
and chemical and biological analysis, including isotope analysis and DNA
barcoding .These were applicable tools for tracing, tracking, identifying, and
monitoring the food to maintain its quality and safety through the supply chain.
However, the growth of e-commerce business in perishable foodstuffs also
facilitates the international trading of perishable food, and changes customer
behaviour in the supply chain, adaptability, efficiency, and reliability of such
existing traceability methods are insufficient to share information among the
complicated supply chain network. The recent generic perishable drug supply
chain (PDSC) with six major supply chain parties along two challenges for food
traceability. First, to trace and track objects in the PDSC, the adequate definition
of traceable resource units (TRUs), which is used to identify and mutually
understand traceable objects covering trade units, production units, and logistics
units for supply chain activities, are required from raw suppliers to end.
Blockchain driven IoT for food traceability with an integrated consensus
mechanism. TRUs are an essential component of food traceability for considering
the mix and different packaging of food products by providing unique identities
in specific food supply chains.
10
Actual material flows in the PDSC involve a complex mixture of shippers,
consignees, TRUs, such that a traceability tree is created to visualise the whole
traceability process. In addition to deploying IoT technologies for food quality
assurance and operational concerns of e-commerce logistics, the entire
traceability tree becomes much more complicated for locating a single piece of
food and for retrieving its relevant traceability information. Thus, the entire
traceability process becomes time consuming, while the system reliability and
adaptability should be further improved. Second, in modern supply chains
(particularly in e-commerce businesses), customers cannot touch the items when
purchasing. Hence, they heavily rely on information provided by eshops and
logistics companies. However, accurate traceability information is difficult to
ensure, and the decision support for food quality assurance (including shelf life
and quality decay evaluations) is also lacking. Worse still, certain health
problems may be caused if end customers consume poor quality food. Blockchain
is deemed feasible in the area of food traceability, because the validated data
cannot be manipulated and low cost implementation creates trust in the supply
chain network. Accordingly, Blockchain enables the functions of tracking food
items and reliable monitoring of the volume of handling conditions throughout
supply chain activities. Automation doesn’t cover the aspects of logistics
including loading, unloading, sorting, packing, unpacking, quality monitoring,
movement inside the facility and out (e.g., robotic conveyers and autonomous
trucks), inventory control, etc.
11
2.4 Paper Title : Robust Authentication of Consumables With Extrinsic
Tags and Chemical Fingerprinting
12
When This solution makes the substrate more rigid in some points, but still
flexible to be used in food quality control applications. Moreover, in vision of a
possible mass production, the use of kapton enables reel-to-reel production with
evident benefits in term of costs. The patterning of copper interconnections was
performed by standard photolithography and wet etching. For the proposed case
study on tonic bottles a low cost custom packaging was developed consisting of
an annular polycarbonate housing which can be easily wrapped around the
bottleneck. To avoid tampering with or corrupting the FTD or the data stored
therein, an adhesive tape sealing can be applied around the open part of the
annular case, which has to be broken to access the data logger. Despite the tag is
used externally provide the mispatch and the information inside the tag will
destroy once the drug gets broken, and the damaged drug cannot be identified by
the manufacturer because the system never gets any update regarding this issue.
So, the safe of the drug is not available. This photolithography and wet etching
cells are high cost. And it does not give the information of the product and gives
only the lifetime of the product and the trackability is also not given by this
project. Their main aim in this project is to give the authentication to their
product. But this project never focuses on the traceability and supply chain. There
is still a need to reduce the amount of tag by using compounds with higher
resonance frequencies. In this project the components are attached to the wrapper
of the drugs so once the wrapper is damaged at the time of transporting it is not
known by the supplier or retailer. So, by this counterfeiting will arise. and in the
wrapper, there are large amount of chips are attached. So, the pack will cost high
and it is not user friendly. Hardware based solution in this project is more
expensive. Hence to avoid this kind of issues we proposed the system based on
EPCIS tag and through this the information is accurate.
13
2.5 PaperTitle : Wireless EAS Sensor Tags for Volatile Profiling in Drug Packages
Author :Saranraj Karuppuswami ; Mohd Ifwat Mohd Ghazali ; Saikat
Mondal; Premjeet Chahal
Publication : IEEE, October 2018, Volume: 10, Issue: 3
Real-time volatile profiling of packaged drug is necessary to estimate shelf life,
quality, and freshness of the drug products along the supply chain Volatile
profiling is demonstrated using thin film coated electronic article surveillance
(EAS) compatible sensor tags fabricated on a porous substrate. The thin film
coated tag along with a reference tag without any coatings are placed inside an
enclosed chamber and different volumes of volatiles vapors are introduced. The
frequency shift between the sensor and the reference tags are monitored for
identifying different concertation of volatiles. The tags are fabricated on a porous
flexible substrate that enables surface absorption due to capillary condensation
used in packaging technology. Hardware based solution is expensive in supply
chain management systems to provide information sharing and analysis to
companies and support their planning activities. They are not based on the real
data because there is asymmetric information between companies, then leading
to disturbance of the planning algorithms. On the other hand, sharing data
between manufacturers, suppliers and customers becomes very important to
ensure reactivity towards markets variability. Especially, double marginalization
is a widespread and serious problem in supply chain management. Decentralized
systems under wholesale price contracts are investigated with double
marginalization effects shown to lead to supply insufficiencies, in the cases of
both deterministic and random demands. This paper proposed a Blockchain based
solution to address the problems of supply chain such as double marginalization
and information asymmetry etc. In the past, most manufacturers produced almost
everything in house.
14
But now, high pressure on the prices and the global competition forced them to
focus on their core competences like engineering and final assembly as original
equipment manufacturers thus outsourcing almost the whole manufacturing
operations. These higher levels of complexity are the result of dramatic changes
in manufacturing and distribution including globalization and outsourcing. As a
result, independent firms manage different parts of global supply chains. Each
firm in the supply chain sets strategic and operational goals to maximize its own
profit using local information such as cost structures, profit margins and
forecasts. Even though advances in information technology enable firms to
collect, process, and share information, firms may be reluctant to do so because
of conflicting incentives. Aligning incentives improves firms’ profits and
sustains the use of information technology. In this situation, it is important to
build competitive supply chain. To build it, information in supply chains is one
of the most valuable resources for manufacturers. Due to the huge amount of
produced and exchanged data needed for the production activities, it is essential
to identify the most useful ones and to focus only on the "strategic transaction"
leading to potential improvements at the supply chain level. The coordination of
information, as well as operations and logistics optimization, has become
increasingly more difficult with recent increases in supply chain complexity.
They discussed incentive problems to a major risk imbalance such as capacity
risk. Because of the imbalance, the impact of capacity risk is more severe for a
decentralized supply chain than for a vertically integrated supply chain. To solve
this problem, we propose a Blockchain based solution to address the double
marginalization problem. It is fully based on hardware components, hence it is
expensive. This project motivated us to utilize the wireless concept in our project.
15
CHAPTER 3
SYSTEM ANALYSIS
The Drug supply chain is the most complex and fragmented of all
supply chains. A lot of the producers and intermediaries are difficult to identify
and track. Examples of problems that have been difficult or impossible to solve
with current technologies include establishing reliable provenance and
preventing fraud and counterfeiting.
Disadvantages
Lack in digitalization and weak supporting systems
Lack of connectivity, particularly with upstream suppliers.
Onerous and costly data reconciliation processes.
Ineffective solutions for handling large amounts of disparate and potentially
inconsistent data.
16
3.3 PROPOSED SYSTEM
17
CHAPTER 4
SYSTEM SPECIFICATION
RAM : 2 GB
EPCIS
EPC Reader
ESP8266
18
CHAPTER 5
SYSTEM DESIGN
Enterprise Server
Enterprise Admin
Consumer
Blockchain
Government Regulator
19
5.2 DATA FLOW DIAGRAM
LEVEL 0
Medical
ADMIN Database
Chain
Fig:5.2.1 Level 0
LEVEL 1
register
Marketing
Database
Agent
Login
Fig:5.2.2 Level 1
20
LEVEL 2
Login
Agent
ID
ADMIN Database
Agent
Details
Verifying
Intimate
Feedback
Fig:5.2.3 Level 2
LEVEL 3
Register
Details
Database
Suppliers Request
s
Verify
Intimate
Feedback
Fig:5.2.4 Level 3
21
5.3 UML DIAGRAM
22
5.3.2 CLASS DIAGRAM
23
5.3.3 SEQUENCE DIAGRAM
24
5.3.4 STATE CHART DIAGRAM
expire
check
y
Rigister
Rigister
Login
Login
Product
Details
Product
Request Product
Details
Product ID
Verification
Product
Request
Purchase
Product
Product ID
Feedback Verification
Purchase
Product
Feedback
Fig: 5.3.5 Activity Diagram
25
5.3.6 COLLABORATION DIAGRAM
26
CHAPTER 6
IMPLEMENTATION
6.1 MODULES
6.1.1 Enterprises Module
6.1.2 Consumer client Module
6.1.3 Government regulator Module
6.1.4 Enterprise-user server Module
6.1.5 Consumer traceability client Module
TYPES OF MODULES
The main needs of enterprises in the drug data shared supply chain are: 1) the
specific accessibility of them on the Blockchain must be assured to prevent the
leakage of sensitive information and to provide confidentiality. 2) The
maintenance cost of Blockchain system should be appropriately controlled. Only
by satisfying the above needs will this system truly benefits enterprises. This
module mainly includes enterprise entities, manufacturers, and regulators in the
supply chain, which are connected through a decentralized network. Each node
in the network corresponds to a Blockchain account, which represents its identity
in the system and can be used to deploy smart contracts. The enterprise entities
in the supply chain can be summarized as suppliers, manufacturers, distributors,
and retailers. By using SHA-256 algorithm the blocks in the Blockchain will be
created. In this enterprise module the main flow of work is created with different
methods. In order to add blocks to a Blockchain, some proof of work has to be
communicated. The purpose of a consensus mechanism is to bring all the nodes
in agreement, that is, trust one another, in an environment where the nodes don’t
trust each other.
27
All the transactions in the new block are then validated and the new block is then
added to the Blockchain. Note that, the block will get added to the chain which
has the longest block height (see Blockchain forks to understand how multiple
chains can exist at a point of time). Miners (special computers on the network)
perform computation work in solving a complex mathematical problem to add
the block to the network. By this proof of work and proof of stake this enterprise
module will be achieved.
28
6.1.3 GOVERNMENT REGULATOR
As for the demand of government regulators, we should provide highest
accessibility to them to monitor all data on the traceability system in order that
they can pinpoint the culpable sector as soon as possible once the Drug safety
event occurs. Also, they should have capability to ensure that all data uploaded
by the enterprise is legal and verified. This module is fully based on the consensus
mechanism. The chain code has a non-deterministic approach where upon
execution of different replicas, the results may be different over a distributed
network. In order to deal with nondeterminism, SIEVE consensus model is
designed, which speculatively executes all transactions and then results produced
by various replicas are analysed. If the divergence between the output is small
over small number of replicas, then the diverging values are sieved. If the
observed divergence is across a large number of processes, then the operation is
sieved itself. A high-level comparison of various Blockchain consensus
mechanisms is provided based on specific characteristics of Blockchain. These
characteristics are confined to type of Blockchain, performance in terms of
transaction rate, the trust component, cost of participation i.e. cost to join the
network or use specific services, scalability of the network i.e. addition of new
nodes, security, and power consumption. The factors are not exhausted, rather
these are representative enough to compare usage of various consensus
mechanisms. By this government regulator the overall process gets control. And
this module has the authentication to verify the blocks and changes. The
workflow will be maintained and the control over the Blockchain is fully given
to this module.
29
6.1.4 ENTERPRISE-USER SERVER
30
6.1.4.4 BLOCKCHAIN MODULE
Blockchain module has two functions. One is the data interaction including the
upload of key traceability information on Blockchain, the request of on chain
information and the verification of event information. The other is to provide
options for users to be the full Blockchain node or the light weight Blockchain
node i.e. to decide whether or not to participate in the maintenance of the
Blockchain.
6.1.4.5 INTERACTION AUTHORITY MANAGEMENT MODULE
This module is in charge of the verification of enterprise identity when there is
any event information interaction i.e. to determine whether the requester who
initiates the request for event information is in this supply chain.
31
CHAPTER 7
SYSTEM TESTING
The input design achieved by creating user-friendly screens for the data
entry to handle large volume of data. The goal of designing input is to make data
entry easier and to be free from errors. The data entry screen is designed in such
a way that all the data manipulates can be performed. It also provides record
viewing facilities. The input design is the link between the information system
and the user. It comprises the developing specification and procedures for data
preparation and those steps are necessary to put transaction data in to a usable
form for processing can be achieved by inspecting the computer to read data from
a written or printed document or it can occur by having people keying the data
directly into the system. This design is important to avoid errors in the data
input process and show the correct direction to the management for getting
correct information from the computerized system.
A quality output is one, which meets the requirements of the end user and
presents the information clearly. In any system results of processing are
communicated to the users and to other system through outputs. In output design
it is determined how the information is to be displaced for immediate need and
also the hard copy output. It is the most important and direct source information
to the user. Efficient and intelligent output design improves the system’s
relationship to help user decision-making. The output testing is achieved by this
following objective. The system has to Convey information about past activities,
current status or projections of the future.
32
7.3 TYPES OF TESTING
Functional testing of the basic components, the system, and its workings is
essential. Testing here is conducted to assess the effectiveness of use-case
scenarios and the specific business processes involved.
Blockchain applications are built for speed. This makes performance testing even
more important. The performance of an application and the latency vary with
networks as well as transaction size. Performance testing in Blockchain includes
identifying performance bottlenecks, defining the metrics for tuning the system,
and assessing if the application is ready for production.
33 33
7.3.5 SPECIALIZED TESTING
Smart Contract testing is a specialized testing. Smart contracts lie at the core of
the Blockchain validation process. Testing of smart contracts calls for simulating
all possible expected and unexpected conditions for all possible contract. Testing
looks at business logic combinations and appropriate execution of all the
transactions in the context of a dynamically changing and expanding the network.
The power of the Blockchain lies in the shared ledger being exactly the same at
each and every node with the same set of and sequence of transactions. This
makes it essential to achieve a consensus across all nodes on the order in which
the transactions are added to the network. Peer/Node testing for the consistency
of transactions is needed. This calls for the testing of the consensus protocol to
determine that all the transactions get stored in the proper sequence. This would
have to be the case under normal conditions and also under conditions when
nodes fail simultaneously or when they do not participate in the network for some
time. These tests help ensure that the nodes in the network sync with other
validating peers and the integrity of the network and shared ledger are maintained
throughout.
34
CHAPTER 8
CONCLUSION
Drug traceability has always been an important and critical function in PDSC,
which provides information covering the entire drug life cycle. Further,
customers and supply chain stakeholders rely heavily on this information to make
their decisions. Due to the rapid development of e-commerce businesses, the
perishable drug e-commerce sector is one of the branches that promotes and sells
perishable drug in the online e-commerce platforms. Unlike shopping in wet
markets and supermarkets, customers in perishable drug e-commerce need to pay
for drug items without having any drug quality information (until parcels are
received). Further, perishable drug is highly sensitive to ambient environmental
conditions. Hence, drug discrepancy and deterioration always occur. Therefore,
using typical traceability systems that merely track and trace the information of
the last mile of delivery and product master data is inefficient and unreliable.
In this project, the above problems are addressed by formulating the following:
(i) an IoT technology deployment framework (ii) a Blockchain IoT mechanism
and (iii) fuzzy drug quality evaluation for drug traceability throughout the entire
supply chain. The IoT technologies are deployed under various TRUs to achieve
cost-effectiveness and user convenience in system implementation. And
subsequently, all the collected data are managed in a cloud database, while the
traceability associated IDs with timestamp are forged in the Blockchain for
traceability purposes. To achieve consensus in the supply chain network, an index
is proposed to evaluate the share of supply chain stakeholders by considering
responsible transit time, stakeholder analysis, and active shipment volume.
Moreover, lightweight and vaporised characteristics of Blockchain are proposed
to improve the block forging efficiency and application storage capacity.
35
CHAPTER 9
FUTURE ENCHANCEMENT
To achieve consensus in the supply chain network, an index of EPCIS is proposed
to evaluate the share of supply chain stakeholders by considering responsible
transit time, stakeholder analysis, and active shipment volume. Moreover,
lightweight and vaporised characteristics of Blockchain are proposed to improve
the block forging efficiency and application storage capacity. The collected data
are then analysed to measure the food quality in the aspects of shelf life and
quality decay, so that end customers can not only track and trace the purchased
medical items, but also obtain the status of medicine quality. Therefore, proactive
strategies to prevent quality discrepancy and serious deterioration can be
established to build better management of perishable medical e-commerce.
Extension of EPCIS (Enterprise level): The use of EPCIS should not only be
limited to medical traceability, but also to other functionalities of supply chain
management, such as quality management, risk management and e-commerce
transactions. Because the proposed EPCIS defines the stakes or shares of supply
chain stakeholders, the new Blockchain applications can be simply developed.
Integration of flows: In addition to information flow, material flow, capital flow,
value flow, and risk flow should also be covered by the Blockchain driven IoT to
create a reliable and secure supply chain in both virtual and physical worlds.
Consequently, a scalable and adaptive cyber physical system in supply chain
management can ultimately be achieved.
36
CHAPTER 10
APPENDICES
10.1 CODE
37
@app.route('/')
def index():
return render_template('index.html')
@app.route('/login', methods=['GET', 'POST'])
def login():
msg=""
act = request.args.get('act')
if request.method=='POST':
uname=request.form['uname']
pwd=request.form['pass']
cursor = mydb.cursor()
cursor.execute('SELECT * FROM sc_company WHERE uname = %s
AND pass = %s', (uname, pwd))
account = cursor.fetchone()
if account:
session['username'] = uname
return redirect(url_for('man_home'))
else:
# Account doesnt exist or username/password incorrect
msg = 'Incorrect username/password!'
return render_template('login.html',msg=msg,act=act)
@app.route('/view_user', methods=['GET', 'POST'])
def view_user():
msg=""
act=""
if 'username' in session:
uname = session['username']
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM sc_user")
data = mycursor.fetchall(
if request.method=='GET':
act = request.args.get('act')
id1 = request.args.get('id')
if act=="yes":
cursor1 = mydb.cursor()
38
cursor1.execute('SELECT * FROM sc_user WHERE id = %s', (id1, ))
account1 = cursor1.fetchone()
email=account1[5]
prk=account1[8]
pbk=account1[7]
usid=account1[6]
message="User:"+usid+", Public Key:"+pbk+", Private Key:"+prk
print(message)
##send mail
print(email)
with app.app_context():
msg = Message(subject="Smart Contract",
sender=app.config.get("MAIL_USERNAME"),recipients=[email],
body=message)
mail.send(msg)
##BC########################
cursor = mydb.cursor()
cursor.execute('update sc_user set status=1 WHERE id = %s', (id1,))
mydb.commit()
act='no'
return redirect(url_for('view_user'))
else:
cursor = mydb.cursor()
cursor.execute('update sc_user set status=0 WHERE id = %s', (id1,))
mydb.commit()
#return redirect(url_for('view_user'))
39
cursor.execute('SELECT * FROM sc_customer WHERE uname = %s
AND pass = %s', (uname, pwd))
account = cursor.fetchone()
if account:
session['username'] = uname
return redirect(url_for('cus_home'))
else:
Account doesnt exist or username/password incorrect
msg = 'Incorrect username/password!'
return render_template('login_cus.html',msg=msg,act=act)
40
result="sucess"
if cursor.rowcount==1:
return redirect(url_for('login',act='1'))
else:
return redirect(url_for('login',act='2'))
#msg='Already Exist'
return render_template('register.html',msg=msg)
mycursor = mydb.cursor()
mycursor.execute("SELECT max(id)+1 FROM sc_category")
maxid = mycursor.fetchone()[0]
if maxid is None:
maxid=1
cursor = mydb.cursor()
sql = "INSERT INTO sc_category(id,category) VALUES (%s, %s)"
val = (maxid,category)
cursor.execute(sql, val)
mydb.commit()
msg="Added Success"
return redirect(url_for('man_cat',msg=msg))
return render_template('man_cat.html',msg=msg)
41
pid = request.form['pid']
ttype=request.form['ttype']
transport=request.form['transport']
location=request.form['location']
tdate=request.form['tdate']
rd=str(tdate).split("-")
rdd=rd[2]+"-"+rd[1]+"-"+rd[0]
cursor = mydb.cursor()
cursor.execute('update sc_product set
ttype=%s,transport=%s,tlocation=%s,tdate=%s,status=1 where
id=%s',(ttype,transport,location,rdd,pid))
mydb.commit()
##BC##
sdata="PID:"+pid+",Company:"+uname+",Transport:"+transport+",Location:"+
location+",Date:"+tdate
result = hashlib.md5(sdata.encode())
key=result.hexdigest()
mycursor1 = mydb.cursor()
mycursor1.execute("SELECT max(id)+1 FROM sc_Blockchain")
maxid1 = mycursor1.fetchone()[0]
if maxid1 is None:
maxid1=1
pkey="00000000000000000000000000000000"
else:
mid=int(pid)-1
cursor.execute('SELECT * FROM sc_Blockchain where id=%s',(mid, ))
pp = cursor.fetchone()
pkey=pp[3]
sql2 = "INSERT INTO
sc_Blockchain(id,block_id,pre_hash,hash_value,sdata) VALUES (%s, %s, %s,
%s, %s)"
val2 = (maxid1,pid,pkey,key,sdata)
cursor.execute(sql2, val2)
mydb.commit()
####
msg="Added Success"
return redirect(url_for('man_transview',msg=msg)
return render_template('man_transfer.html',pid=pid,msg=msg)
@app.route('/man_transview', methods=['GET', 'POST'])
42
def man_transview():
if 'username' in session:
uname = session['username']
cursor = mydb.cursor()
cursor.execute('SELECT * FROM sc_product where status=1 and
company=%s',(uname, ))
data = cursor.fetchall()
return render_template('man_transview.html',data=data)
43
cursor.execute('update sc_product set
retailer=%s,ttype=%s,transport=%s,tlocation=%s,sdate=%s,status=3 where
id=%s',(shop,ttype,transport,location,rdd,pid))
mydb.commit()
##BC##
sdata="PID:"+pid+",Supplier:"+uname+",Retailer:"+shop+",Transport:"+transp
ort+",Location:"+location+",Date:"+tdate
result = hashlib.md5(sdata.encode())
key=result.hexdigest()
mycursor1 = mydb.cursor()
mycursor1.execute("SELECT max(id)+1 FROM sc_Blockchain")
maxid1 = mycursor1.fetchone()[0]
if maxid1 is None:
maxid1=1
pkey="00000000000000000000000000000000"
else:
mid=int(pid)-1
cursor.execute('SELECT * FROM sc_Blockchain where id=%s',(mid, ))
pp = cursor.fetchone()
pkey=pp[3]
sql2 = "INSERT INTO
sc_Blockchain(id,block_id,pre_hash,hash_value,sdata) VALUES (%s, %s, %s,
%s, %s)"
val2 = (maxid1,pid,pkey,key,sdata)
cursor.execute(sql2, val2)
mydb.commit()
####
msg="Added Success"
return redirect(url_for('sup_shopview',msg=msg))
return render_template('sup_trans.html',data=data,pid=pid)
@app.route('/sup_shopview', methods=['GET', 'POST'])
def sup_shopview():
msg=""
if 'username' in session:
uname = session['username']
cursor = mydb.cursor()
cursor.execute('SELECT * FROM sc_product where supplier=%s && status
= 3',(uname, ))
44
data = cursor.fetchall()
return render_template('sup_shopview.html',data=data)
if request.method=='GET':
msg = request.args.get('msg')
cursor = mydb.cursor()
cursor.execute('SELECT * FROM sc_category')
catt = cursor.fetchall()
if request.method=='POST':
cat=request.form['category']
prd=request.form['product']
price=request.form['price']
psize=request.form['psize']
kg=request.form['kg']
description=request.form['description']
location=request.form['location']
mdate=request.form['mdate']
edate=request.form['edate']
mycursor = mydb.cursor()
mycursor.execute("SELECT max(id)+1 FROM sc_product")
maxid = mycursor.fetchone()[0]
if maxid is None:
maxid=1
numStr = str(maxid)
numStr = numStr.zfill(4)
45
now = datetime.datetime.now()
rdate=now.strftime("%d-%m-%Y")
my=now.strftime("%y%m")
pcode=my+numStr
sdata="PID:"+str(maxid)+",Product:"+prd+",Company:"+uname+",Manufactur
e:"+mdate+",Expire:"+edate+",RegDate:"+rdate
result = hashlib.md5(sdata.encode())
key=result.hexdigest()
mycursor1 = mydb.cursor()
mycursor1.execute("SELECT max(id)+1 FROM sc_Blockchain")
maxid1 = mycursor1.fetchone()[0]
if maxid1 is None:
maxid1=1
pkey="00000000000000000000000000000000"
else:
mid=maxid-1
cursor.execute('SELECT * FROM sc_Blockchain where id=%s',(mid, ))
pp = cursor.fetchone()
pkey=pp[3]
sql2 = "INSERT INTO
sc_Blockchain(id,block_id,pre_hash,hash_value,sdata) VALUES (%s, %s, %s,
%s, %s)"
val2 = (maxid1,maxid,pkey,key,sdata)
cursor.execute(sql2, val2)
mydb.commit()
####
46
if cursor.rowcount==1:
msg="success"
return redirect(url_for('man_home',msg=msg))
else:
msg="fail"
return redirect(url_for('man_home',msg=msg))
#msg='Already Exist'
'''if request.method=='POST':
product=request.form['product']
price=request.form['price']
store.addprod(product,price)'''
return render_template('man_home.html',catt=catt, msg=msg)
47
data = cursor.fetchall()
if request.method=='GET':
pid = request.args.get('pid')
if request.method=='POST':
pid = request.form['pid']
supplier = request.form['supplier']
ttype=request.form['ttype']
transport=request.form['transport']
location=request.form['location']
sdate=request.form['sdate']
rd=str(sdate).split("-")
rdd=rd[2]+"-"+rd[1]+"-"+rd[0]
cursor = mydb.cursor()
cursor.execute('update sc_product set
supplier=%s,ttype=%s,transport=%s,tlocation=%s,sdate=%s,status=2 where
id=%s',(supplier,ttype,transport,location,rdd,pid))
mydb.commit()
##BC##
sdata="PID:"+str(pid)+",Company:"+uname+",Supplier:"+supplier+",Transport
:"+transport+",Location:"+location+",Date:"+sdate
result = hashlib.md5(sdata.encode())
key=result.hexdigest()
mycursor1 = mydb.cursor()
mycursor1.execute("SELECT max(id)+1 FROM sc_Blockchain")
maxid1 = mycursor1.fetchone()[0]
if maxid1 is None:
maxid1=1
pkey="00000000000000000000000000000000"
else:
mid=int(pid)-1
cursor.execute('SELECT * FROM sc_Blockchain where id=%s',(mid, ))
pp = cursor.fetchone()
pkey=pp[3]
sql2 = "INSERT INTO
sc_Blockchain(id,block_id,pre_hash,hash_value,sdata) VALUES (%s, %s, %s,
%s, %s)"
val2 = (maxid1,pid,pkey,key,sdata)
cursor.execute(sql2, val2)
mydb.commit()
48
msg="Added Success"
return redirect(url_for('man_supply',msg=msg))
return render_template('man_sup.html',pid=pid,msg=msg,data=data
if request.method=='GET':
msg = request.args.get('msg')
cursor = mydb.cursor()
cursor.execute('SELECT * FROM sc_product where company=%s &&
status = 2',(uname, ))
data = cursor.fetchall()
@app.route('/logout')
def logout():
# remove the username from the session if it is there
session.pop('username', None)
return redirect(url_for('index'))
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True)
49
10.2 SNAPSHOT
50
10.2.2MANUFACURE LOGIN PAGE
51
10.2.4 PRODUCT CATEGORY SELECTION PAGE
52
10.2.6 TRANSFERRED PRODUCTS DETAILS PAGE
53
10.2.7 SUPPLIER LOGIN PAGE
54
10.2.8 SUPPLIER DETAILS PAGE
55
10.2.10 CUSTOMER LOGIN PAGE
56
10.2.12 PRODUCT VERIFICATION PAGE
57
10.2.13 ADMINISTRATOR LOGIN PAGE
58
10.2.15 USERS DETAIL PAGE
59
10.2.17 FINAL PRODUCT DETAILS PAGE
60
REFERENCES
[1] G. O. Young, ``Synthetic structure of industrial plastics,'' in Plastics, vol. 3, 2nd ed., J.
Peters, Ed. New York, NY, USA: McGraw-Hill, 1964,pp. 15_64.
[2] R. Wang, S. Prives, R. Fischer, M. Salfer, and W. A. Gunthner, ``Data analysis and
simulation of auto-ID enabled food supply chains based on EPCIS standard'' in Proc. IEEE
Int. Conf. Autom. Logistics (ICAL), Aug. 2011, pp. 58_63.
[3] J.Wu, S. Luo, S.Wang, and H.Wang, ``NLES: A novel lifetime extension scheme for
safety-critical cyber-physical systems using SDN and NFV,'' IEEE Internet Things J., to be
published. doi: 10.1109/JIOT.2018.2870294.
[4] J. Wu, M. Dong, K. Ota, J. Li, and Z. Guan, ``Big data analysis-based secure cluster
management for optimized control plane in software-de_ned networks,'' IEEE Trans. Netw.
Service Manag., vol. 15, no. 1, pp. 27_38, Mar. 2018.
[5] Z. Guan, Y. Zhang, L.Wu, J.Wu, Y. Ma, and J. Hu, ``APPA: An anonymous and privacy
preserving data aggregation scheme for fog-enhanced IoT,'' J. Netw. Comput. Appl., vol. 125,
pp. 82_92, Jan. 2019.
[6] J. Wu, M. Dong, K. Ota, J. Li, and Z. Guan, ``FCSS: Fog computing based content-aware
_ltering for security services in information centric social networks,'' IEEE Trans. Emerg.
Topics Comput., to be published. doi: 10.1109/TETC.2017.2747158.
[7] M. Swan, Blockchain: Blueprint for a New Economy. Newton, MA, USA: O'Reilly Media,
2015.
[8] S. Nakamoto. (2008). Bitcoin: A Peer-to-Peer Electronic Cash System. [Online].
Available: https://bitcoin.org/bitcoin.pdf
[9] M. Iansiti and K. R. Lakhani, ``The truth about Blockchain,'' Harvard Bus. Rev., vol. 95,
no. 1, pp. 118_127, 2017.
[10] H. Watanabe, S. Fujimura, A. Nakadaira, T. Yamada, A. Akutsu, and J. J. Kishigami,
``BRIGHT: A concept for a decentralized rights manage-
ment system based on Blockchain,'' in Proc. IEEE 5th Int. Conf. Consum. Electron. (ICCE),
Berlin, Germany, Sep. 2015, pp. 345_346.
[11] F. Tian, ``An agri-food supply chain traceability system for China based on RFID
&Blockchain technology,'' in Proc. 13th Int. Conf. Service Syst.Service, 2016, pp. 1_6.
[12] K. Toyoda, P. T. Mathiopoulos, I. Sasase, and T. Ohtsuki, ``A novel Blockchain-based
product ownership management system (POMS) for anti-counterfeits in the post supply chain,''
IEEE Access, vol. 5, pp. 17465_17477, 2017.
[13] R. Aitken. (2017). IBM & Walmart Launching Blockchain Food Safety Alliance in China
with Fortune 500's JD.Com. [Online].
Available:https://www.forbes.com/sites/rogeraitken/2017/12/14/ibm-walmart- launching-
Blockchain-food-safety-alliance-in-china-with-fortune-500s-jd-com/#556eb5fe7d9c
[14] D. Tse, B. Zhang, Y. Yang, C. Cheng, and H. Mu, ``Blockchain application in food supply
information security,'' in Proc. IEEE IEEM, Dec. 2017, pp. 1357_1361.
[15] M. P. Caro, M. S. Ali, M. Vecchio, and R. Giaffreda, ``Blockchain-based traceability in
agri-food supply chain management: A practical implemen- tation,'' in Proc. IoT Vertical
Topical Summit Agriculture Tuscany (IOT Tuscany), May 2018, pp. 1_4.
[16] B. Sohn, S. Woo, J. Han, H. Cho, J. Byun, and D. Kim, ``GS1 Connected car using EPCIS-
ONS system,'' in Proc. IEEE Int. Congr. Big Data,Jun./Jul. 2016, pp. 426_42
61