Download as pdf or txt
Download as pdf or txt
You are on page 1of 79

MEDVAULT: PERSONAL HEALTH

RECORDS USING BLOCKCHAIN

A MINI PROJECT REPORT

Submitted by

ABISHAKE D AC20UCS003
AJITHKUMAR P AC20UCS009
BHUANESH KUMAR T AC20UCS018

in partial fulfilment for the award of the degree of

BACHELOR OF ENGINEERING

IN

COMPUTER SCIENCE AND ENGINEERING

ADHIYAMAAN COLLEGE OF ENGINEERING (AUTONOMOUS)

DR. M.G.R NAGAR, HOSUR-635130

ANNA UNIVERSITY: CHENNAI 600 025


NOVEMBER 2023
MEDVAULT: PERSONAL HEALTH

RECORDS USING BLOCKCHAIN

A MINI PROJECT REPORT

Submitted by

ABISHAKE D AC20UCS003
AJITHKUMAR P AC20UCS009
BHUANESH KUMAR T AC20UCS018

in partial fulfilment for the award of the degree of

BACHELOR OF ENGINEERING

IN

COMPUTER SCIENCE AND ENGINEERING

ADHIYAMAAN COLLEGE OF ENGINEERING (AUTONOMOUS)

DR. M.G.R NAGAR, HOSUR-635130

ANNA UNIVERSITY: CHENNAI 600 025


NOVEMBER 2023
ANNA UNIVERSITY:CHENNAI 600 025

BONAFIDE CERTIFICATE

Certified that this mini project report “MEDVAULT: PERSONAL HEALTH RECORDS

USING BLOCKCHAIN” is the Bonafide work of “ABISHAKE D (AC20UCS003),

AJITHKUMAR P (AC20UCS009), BHUANESH KUMAR T (AC20UCS018)” who

carried out the project under my supervision.

SIGNATURE SIGNATURE

Dr. G. FATHIMA, M.E., Ph.D., Mrs. M.MALATHI, M.E.,


HEAD OF THE DEPARTMENT SUPERVISOR
PROFESSOR, ASSISTANT PROFESSOR,
Department of CSE, Department of CSE,
Adhiyamaan College of Engineering, Adhiyamaan College of Engineering,
(Autonomous), (Autonomous)
Dr. M.G.R. Nagar, Dr. M.G.R. Nagar,
Hosur – 635 130. Hosur – 635 130.

Submitted for the Mini project VIVA-VOCE Examination held on at

Adhiyamaan College of Engineering (Autonomous), Hosur-635 130.

INTERNAL EXAMINER EXTERNAL EXAMINER


ACKNOWLEDGEMENT

It is one of the most efficient tasks in life to choose the appropriate words to express one’s
gratitude to the beneficiaries. We are very much grateful to God who helped us all the way
through the project and how molded us into what we are today.

We are grateful to our beloved Principal Dr. G. RANGANATH, M.E., Ph.D.,


Adhiyamaan College of Engineering (Autonomous), Hosur for providing the opportunity
to do this work in premises.

We acknowledge our heartful gratitude to Dr. G. FATHIMA, M.E., Ph.D., Professor and
Head of the Department, Department of Computer Science and Engineering, Adhiyamaan
College of Engineering (Autonomous), Hosur, for her guidance and valuable suggestions
and encouragement throughout this project and made us to complete this project
successfully.

We acknowledge our heartful gratitude to Mrs. M.MALATHI, M.E., Assistant Professor,


Department of Computer Science and Engineering, Adhiyamaan College of Engineering
(Autonomous), Hosur, for her supervision, guidance and valuable suggestions and
encouragement throughout this project and made us to complete this project successfully.

We also extend our thanks to the project Coordinator and all Staff Members for their
support in completing this project successfully.

Finally, we would like to thank our parents, without their motivation and support would not
have been possible for us to complete this project successfully.
ABSTRACT

MedVault is a pioneering system for managing personal health records (PHRs) using
blockchain technology. In an era where healthcare data security and accessibility are
paramount, MedVault provides a reliable and efficient solution. The platform leverages the
decentralized nature of blockchain to ensure the privacy and integrity of health records
while enabling seamless access for authorized users.

MedVault allows individuals to securely store and manage their medical history, test
results, prescriptions, and other health-related information in a distributed ledger. With
end-to-end encryption and user-controlled access permissions, patients have complete
control over who can view and modify their records. Healthcare providers, on the other
hand, can access patients' PHRs with consent, facilitating more accurate diagnoses and
timely treatment.

The utilization of blockchain technology in MedVault eliminates the risk of data tampering
and unauthorized access, enhancing trust among patients and healthcare providers.
Furthermore, the system streamlines data exchange, reducing administrative burdens and
improving overall healthcare efficiency. MedVault represents a significant step forward in
the digitization of personal health records, ensuring data security, privacy, and accessibility
for all.

Keywords: MedVault, Personal Health Records, Blockchain, Data Security,


Interoperability, Smart Contracts, Patient-Centric, Healthcare, Data Management, Privacy.

i
TABLE OF CONTENTS

PAGE
CHAPTER TITLE
NO.
NO.

ABSTRACT i
LIST OF ABBREVIATION iv
LIST OF FIGURES v
1 INTRODUCTION
1.1 OVERVIEW 1
1.2 OBJECTIVES 3
2 LITERATURE SURVEY 4
3 SYSTEM ANALYSIS
3.1 EXISTING SYSTEM 6
3.2 PROPOSED SYSTEM 7
3.3 PROPOSED SOLUTION 8
3.4 IDEATION & BRAINSTORMING 9
3.5 ARCHITECTURE DESIGN 10
3.6 DESCRIPTION OF MODULES 13
3.6.1 USER REGISTER 13
3.6.2 USER LOGIN 14
3.6.3 USER VERIFICATION 16
3.6.4 USER PERSONAL DETAILS 17
3.6.5 HOME SCREEN 19
4 SYSTEM REQUIREMENT
4.1 HARDWARE REQUIREMENT 22
4.2 SOFTWARE REQUIREMENT 22

ii
5 IMPLEMENTATION
5.1 FRONTEND DEVELOPMENT 23
5.1.1 USER REGISTRATION 23
5.1.2 USER LOGIN 24
5.1.3 USER VERIFICATION 26
5.1.4 USER PERSONAL DETAILS 27
5.1.5 HOME SCREEN 28
5.2 CODE IMPLEMENTATION 30
5.2.1 USER REGISTRATION IMPLEMENTATION 30
5.2.2 USER LOGIN IMPLEMENTATION 31
5.2.3 USER VERIFICATION IMPLEMENTATION 32
5.2.4 USER PERSONAL DETAILS
34
IMPLEMENTATION
5.2.5 HOME SCREEN IMPLEMENTATION 36
5.3 BACKEND DEVELOPMENT 38
5.4 RESULT 40
6 CONCLUSION 41
APPENDICES 42
SOURCE CODE 42
OUTPUT 67
REFERENCES 69

iii
LIST OF ABBREVIATIONS

ACRONYM ABBREVIATIONS

BC - BlockChain

PHR - Personal Health Records

HVB - HealthVault Blockchain

MVHR MedVault Health Records


-

MVPR - MedVault Personal Records

BCT - Blockchain Technology

MH - Medical History

DS - Data Security

UCAP - User-Controlled Access Permissions

DN - Decentralized Network

DT - Data Tampering

DL - Distributed Ledger

EC - EnCryption

iv
LIST OF FIGURES

FIGURE PAGE
TITLE
NO. NO.

3.1 MODEL ARCHITECTURE 10

5.1 USER REGISTRATION CODE IMPLEMENTATION 31

5.2 USER LOGIN CODE IMPLEMENTATION 32

5.3 USER VERIFICATION CODE IMPLEMENTATION 34

USER PERSONAL DETAILS CODE


5.4 35
IMPLEMENTATION

5.5 HOME SCREEN CODE IMPLEMENTATION 37

6.1 USER REGISTER AND USER LOGIN 68


USER PERSONAL DETAILS AND VERIFICATION
6.2 68
OF USER DOCUMENTS
6.3 UPLOAD PAGE AND USER ACCOUNT DETAILS 69

v
CHAPTER 1
INTRODUCTION

1.1 OVERVIEW

In an era where data plays a pivotal role in shaping our lives and making
informed decisions, the healthcare industry is no exception. The need for efficient,
secure, and accessible personal health records has never been more crucial. Amidst
this evolving landscape, MedVault emerges as a groundbreaking solution that
leverages Blockchain technology to revolutionize the way we manage and access our
personal health records.

MedVault represents a paradigm shift in the realm of personal health records,


addressing the long-standing challenges that have hindered the healthcare industry
for decades. At its core, MedVault is a Blockchain-based platform that empowers
individuals to take control of their health data like never before. It seamlessly
integrates the principles of decentralization, security, and accessibility to create a
comprehensive ecosystem that puts the patient at the center of their healthcare
journey.

The traditional approach to personal health records has been fraught with
inefficiencies. Paper records are easily lost or damaged, and electronic health records
are often siloed in different healthcare providers' systems, making it cumbersome for
patients to access their complete medical history. Moreover, concerns about data
security and privacy breaches have loomed large over these centralized systems.
MedVault resolves these issues by harnessing the power of Blockchain technology.

1
Blockchain, the underlying technology of cryptocurrencies like Bitcoin, has
gained immense popularity for its ability to provide a transparent, secure, and
immutable ledger of transactions. MedVault employs this technology to create an
unalterable record of an individual's health history. Each piece of medical data, from
lab results to treatment plans, is securely stored in a decentralized network of nodes.
This ensures that patients can trust the authenticity and integrity of their health
records, eliminating concerns about tampering or unauthorized access.

One of MedVault's most compelling features is its accessibility. By using


Blockchain technology, it eliminates the need for patients to rely on a single
healthcare provider or institution to store their records. Instead, individuals have
control over their health data and can grant access to authorized healthcare
professionals when needed. This not only empowers patients to actively manage their
health but also streamlines the communication between patients and healthcare
providers, enhancing the overall quality of care.

The security measures integrated into MedVault are unparalleled. Blockchain's


cryptographic techniques safeguard sensitive information, making it virtually
impervious to hacking and unauthorized access. Patients can trust that their personal
health data remains confidential and secure, giving them peace of mind while
engaging with the healthcare system.

Furthermore, the use of Blockchain technology eliminates the need for


intermediaries in managing personal health records. This significantly reduces
administrative costs and enhances the efficiency of healthcare services. Patients can
easily update their records, request prescriptions, or schedule appointments, all within
the MedVault platform. This streamlined process not only saves time and resources
but also promotes a patient-centric approach to healthcare.

2
1.2 OBJECTIVES

The main Objective of the project is

• Data Security and Privacy: Ensure the highest level of data security and
privacy for personal health records. Utilize Blockchain's cryptographic
techniques to protect sensitive medical information from unauthorized
access.

• Immutable Record Keeping: Leverage Blockchain's immutability to


maintain an indisputable and unalterable history of medical data, providing
a trustworthy source for healthcare providers and patients.

• Smart Contracts: Utilize smart contracts to automate and enforce consent,


access, and data sharing rules, reducing administrative overhead and
ensuring compliance.

• User-Friendly Interface: Develop an intuitive and user-friendly interface


for both patients and healthcare providers, making it easy to upload, access,
and manage health records.

• Decentralization: Implement a decentralized architecture to eliminate the


need for a central authority, making it resistant to single points of failure and
reducing the risk of data breaches.

3
CHAPTER 2

LITERATURE SURVEY

Electronic Health Records(EHR) are gaining a lot of popularity all over the
world. The current EHR systems however have their fair share of problems related to
privacy and security. We have proposed a mechanism which provides a solution to
most of these problems. Using a permissioned Ethereum blockchain allows the
hospitals and patients across the world to be connected to each other. Our mechanism
uses a combination of symmetric and asymmetric key cryptography to ensure the
secure storage and selective access of records. It gives patients full control over their
health records and also allows them to grant or revoke a hospital's access to his/her
records. We have used IPFS(interplanetary file system) to store records which has
the advantage of being distributed and ensures immutability of records. The proposed
model also maintains the statistics of diseases without violating the privacy of any
patient.

Blockchain technology has been emerged in the last decade and has gained a
lot of interests from several sectors such as finance, government, energy, health, etc.
This paper gives a broad ranging survey of the application of blockchain in healthcare
domain. In fact, the ongoing research in this area is evolving rapidly. Therefore, we
have identified several use cases in the state of art applying the blockchain
technology, for instance for sharing electronic medical records, for remote patient
monitoring, for drug supply chain, etc. We have focused also on identifying
limitations of studied approaches and finally we have discussed some open research
issues and the areas of future researchMohd Ilyas and Ajit Chauhan[3] proposed a
system called Some Plant Disease Identification and Prevention using Machine
Learning, The proposed methodology in the proposed plant disease detection system

4
focuses on generating an advanced and efficient system which makes the process of
creating high yields of crops are much easier for farmers. The farmers will be able to
accurately detect the type of disease a particular plant is having using the image of
the plant.

The world is moving towards progress, to achieve the desired progress, the
world should have a healthy population and health records are the projections of an
individual's health over time. The centralised approach of maintaining the health
records lead to data breaches. According to 2017 Ponemon Cost of Data Breach
Study, the cost of the data breach for healthcare organizations estimated to be $380
per record. According to 2016 Breach Barometer Report, 27,314,647 patient records
were affected. So we moved towards institution-driven approach of record
maintenance, which didn't make much difference with the previously existing one.
Since the patient have no control over the data, the chances of data being misused is
high. This paper highlights on the patient-driven model of record maintenance using
Blockchain technology where smart contracts can be incorporated in future days
making it more potential in data exchange. Finding its huge scope, hoping that more
researches will be carried out and practically implemented.

5
CHAPTER 3

SYSTEM ANALYSIS

3.1 EXISTING SYSTEM:

Existing Personal Health Record (PHR) systems face several challenges that
hinder efficient healthcare record management. One of the primary issues is
centralized storage. Many PHRs are stored on centralized servers or databases,
controlled by healthcare providers or third-party companies. This setup limits
individuals' control over their own health data. Patients may struggle to access, update,
or share their records without going through complex administrative processes,
potentially delaying critical healthcare decisions.

Security risks are another significant concern. Centralized storage makes PHRs
vulnerable to data breaches, hacking, and unauthorized access. A breach can expose
sensitive medical information, leading to identity theft, fraud, and other privacy
violations. It erodes trust in the system, deterring individuals from fully engaging with
their PHRs.

Data integrity reliance is a fundamental issue. Patients often rely on healthcare


providers to input and maintain their records accurately. Errors or omissions can have
serious consequences, impacting treatment decisions and patient safety.

Interoperability challenges are widespread in the healthcare industry, and PHRs


are no exception. Different providers and institutions use various systems that may
not communicate effectively. This can hinder the seamless sharing of health
information, impeding continuity of care and leading to duplicated tests and
procedures.
6
3.2 PROPOSED SYSTEM:

Blockchain technology offers a decentralized and secure solution for managing


PHRs, granting users unprecedented control over their health information. Unlike
traditional systems, where data is stored in centralized servers, Blockchain distributes
data across a network of nodes, ensuring that users have the keys to access and manage
their records. This decentralization enhances user privacy, as patients can choose what
information to share and with whom, reducing the risk of unauthorized access and
breaches.

Security is a paramount feature of Blockchain-powered PHRs. Data on the


Blockchain is encrypted and protected through cryptographic techniques, making it
extremely difficult for malicious actors to compromise the information. Immutable
records on the Blockchain ensure data integrity, making it practically impossible to
alter or delete records without a transparent and traceable history.

By securely managing and sharing health records through Blockchain,


individuals and healthcare providers can seamlessly collaborate. Patients can grant
access to their medical history and health data to doctors, specialists, and caregivers
as needed, promoting trust and facilitating more informed medical decisions.
Furthermore, the transparency of Blockchain technology enhances trust in the
healthcare system, as patients can verify who accessed their data and when, reducing
concerns about unauthorized usage.

7
3.3 PROPOSED SOLUTION

Blockchain technology has indeed revolutionized healthcare by empowering


users with control, privacy, and security over their Personal Health Records (PHR).
This innovation ensures that sensitive medical information remains tamper-proof and
easily accessible, all while promoting trust, data integrity, and patient engagement.

One of the key components of this solution is the implementation of a


Blockchain-based PHR platform. Each patient's medical records are stored in a
decentralized and immutable ledger, accessible only to authorized individuals, such
as healthcare providers and the patients themselves. Users are given a private key,
ensuring that they have complete control over who can access their data. This fosters
trust and confidence among patients, as they know their data is safe and only shared
when they permit it.

Security is further enhanced by using advanced encryption techniques, making


it virtually impossible for malicious actors to compromise the data. In addition,
patients can easily manage and share their records with healthcare providers,
improving the efficiency and accuracy of treatment.

Blockchain also ensures data integrity. Records are time-stamped and linked in
a chain, making it easy to trace any changes or access. This not only helps in
preventing data breaches but also in maintaining an accurate and unaltered medical
history, crucial for informed healthcare decisions.

Moreover, the transparency and security of Blockchain-powered PHRs promote


patient engagement. When individuals have faith in the safety of their data, they are
more likely to actively participate in their healthcare. This solution is a game-changer
in the healthcare industry.

8
3.4 IDEATION & BRAINSTORMING

1.) Security and Privacy: Start with the core concept of ensuring patients' control
over their health data. The blockchain should provide robust security and privacy
features. Consider implementing advanced encryption, biometric authentication, and
two-factor authentication for users to access their records.

2.) Integration of Smart Contracts: Utilize smart contracts for automated


processes like insurance claims, appointment scheduling, or prescription refills. This
can streamline administrative tasks and reduce errors.

3.) Immutable Records: Emphasize the immutability of records. Any changes or


updates to the records should be timestamped and recorded securely on the blockchain.
This ensures data integrity.

4.) Blockchain Consortium: Consider forming a consortium with healthcare


providers, insurers, and technology companies to ensure widespread adoption and
standardization in the industry.

5.) Patient Education: Develop educational resources and tools for patients to
understand the benefits and usage of Blockchain-based PHRs. Increased patient
awareness can drive adoption.

9
3.5 ARCHITECTURE DESIGN

Figure 3.1: Model Architecture

Designing a Personal Health Records (PHR) system using Blockchain


technology involves creating a secure, decentralized, and efficient platform for
managing and sharing health data. Above is an architecture design for a Blockchain-
based PHR system along with an explanation of each component below:

1.) User Interface:

The user interacts with the system through a user-friendly interface, which can
be a web application or a mobile app. Users can access and manage their health
records, control access, and view transaction history.

2.) Blockchain Network:

The core of the system is a Blockchain network, which can be permissioned


(private) or permissionless (public). A permissioned blockchain is typically used in
healthcare to maintain privacy security.

10
3.) Smart Contracts:

Smart contracts are self-executing contracts with predefined rules and


conditions. In a PHR system, smart contracts control access to health records,
ensuring that only authorized individuals or entities can view or modify the data.

4.) Identity Management:

Identity management is crucial for user authentication and authorization. A


component is needed to manage user identities, keys, and permissions securely. This
may involve integration with existing identity systems or the use of decentralized
identity solutions.

5.) Data Storage:

Encrypted health data is stored on the blockchain or off-chain (external storage)


for efficiency. Storing large files directly on the blockchain can be costly and slow.
Data is linked to the smart contract governing its access.

6.) Consensus Mechanism:

The consensus mechanism (e.g., Proof of Work, Proof of Stake) ensures that
transactions are verified and added to the blockchain securely. In healthcare,
consensus mechanisms should be energy-efficient and scalable.

7.) Access Control and Encryption:

Access control is managed through smart contracts, and encryption ensures


data privacy. Only authorized users or devices with the correct keys can decrypt and
access the data.

8.) Interoperability:

11
Standards for data interoperability, like HL7 FHIR, should be considered to
enable easy data exchange between healthcare providers and systems.

9.) Audit Trail:

An audit trail logs all transactions related to health records. This allows for
transparency and accountability, important in healthcare for compliance and security.

10.) External APIs and Data Sources:

Integration with external systems and data sources, such as hospitals, labs, and
wearable devices, is essential to provide a comprehensive view of a patient's health.

11.) Notifications and Alerts:

The system can send notifications and alerts to users for actions like record
access, updates, or appointment reminders.

In this architecture, blockchain ensures the security, privacy, and immutability


of personal health records, while smart contracts automate access control. User-
friendly interfaces and interoperability support patient engagement and seamless data
exchange between healthcare providers. It's essential to continually update and secure
the system to adapt to evolving healthcare regulations and technology advancements.

12
3.6 DESCRIPTION OF MODULES

3.6.1 USER REGISTER:

The user registration module in a blockchain-based Personal Health Records


(PHR) system plays a pivotal role in ensuring secure, verified, and controlled access to
the platform. Here's a breakdown of how this module functions:
1.) User Initiation:
Registration begins with the user providing essential information, such as
their full name, email address, and a secure password. This data serves as the
foundation of their digital identity within the PHR system.
2.) Identity Verification:
To bolster security and prevent fraudulent registrations, the system employs
various identity verification methods. These may include email confirmation, two-
factor authentication, or even advanced biometric verification. By confirming the user's
identity, the system ensures that only legitimate individuals gain access to the platform.
3.) Creation of Blockchain Identity:
After successful identity verification, the system establishes a unique
blockchain identity for the user. This identity is linked to a cryptographic key pair,
which comprises a public key (known to others on the network) and a private key
(known exclusively to the user). Safeguarding the private key is paramount, as it grants
access and control over the user's health records on the blockchain.
4.) User Consent and Data Privacy:
During the registration process, users are prompted to provide consent
regarding the management and sharing of their health data within the blockchain
network. This step empowers users to specify who can access their data, for what
purposes, and under what conditions. It is a fundamental component of ensuring that
users have full control over their personal health information and privacy.
5.) User Wallet Setup:
In some blockchain PHR systems, the registration process also encompasses

13
the establishment of a digital wallet. This wallet is designed for managing tokens or
cryptocurrency that may be utilized within the system, such as for paying for services
or incentivizing data sharing.

Overall, the user registration module is pivotal in guaranteeing that only


authorized and verified individuals can access the blockchain-based PHR system. It
lays the groundwork for trust, security, and user-controlled data management, which
are essential principles in the realm of personal health records on the blockchain.

3.6.2 USER LOGIN:


A user login module within a blockchain-based Personal Health Records
(PHR) system plays a crucial role in ensuring the security and accessibility of a patient's
health information. Here's an explanation of how the user login module typically works
in such a system:
1.) User Registration:
To begin using the blockchain-based PHR system, a user must first register.
During registration, the user provides their personal information, creates a unique
username and password, and associates their public blockchain address with their
account.
2.) Authentication:
When the user attempts to access their PHR, they are prompted to enter
their username and password. This information is securely stored in the system's
database, but the password is typically hashed and salted to enhance security.
3.) Two-Factor Authentication (2FA):
Many blockchain-based PHR systems may implement an additional layer
of security by offering two-factor authentication. This could involve sending a one-time
code to the user's registered mobile device or email, which they must enter to complete
the login process.

14
4.) Private Key Management:
In blockchain technology, a user's private key is crucial for accessing and
controlling their PHR data. The user login module may include a secure way for users
to manage their private keys, such as providing options for password recovery or
securely storing and retrieving their private keys.
5.) Access Control:
After successful authentication, the system verifies the user's blockchain
address to ensure they have the appropriate permissions to access the stored health
records. Permissions may vary, allowing different levels of access to view, edit, or share
records.
6.) Audit Trails:
The system may also track and record all login and access activities in an
audit trail. This helps in monitoring any unauthorized access attempts and provides a
history of who accessed the PHR and when.
7.) Password Management:
Users should have the ability to change their passwords periodically for
security reasons. The system should facilitate this process, with password policies in
place to ensure strong and secure passwords.
8.) Logout Functionality:
Users must be able to log out of their accounts securely to prevent
unauthorized access, especially on shared or public devices.
9.) Account Recovery:
In case a user forgets their login credentials or loses access to their private
key, a secure account recovery process should be in place. This could involve identity
verification and multifactor authentication to ensure that only the rightful owner regains
access.

15
10.) Continuous Monitoring and Security Updates:
The user login module should be regularly monitored for potential
vulnerabilities and security updates to protect user accounts and their health data.

The user login module is a fundamental aspect of a blockchain-based PHR


system, providing the necessary security and access control mechanisms to ensure that
patients have control over their health records and that these records remain private and
secure.

3.6.3 USER VERIFICATION:


The user verification module in a blockchain-based Personal Health Records
(PHR) system is a crucial component designed to ensure the authenticity and security of
individuals accessing their health data. This module plays a pivotal role in safeguarding
the sensitive medical information stored on the blockchain, promoting trust and data
integrity. Here's an explanation of the user verification module in this context:
1.) Identity Verification:
The user verification module starts by verifying the identity of the individual
seeking access to their PHR. This process typically involves collecting various forms of
identification, such as government-issued IDs, biometric data (e.g., fingerprints or facial
recognition), or other personally identifiable information.
2.) Authentication:
Once the identity is verified, the system utilizes strong authentication
mechanisms to confirm that the person is who they claim to be. This can include multi-
factor authentication (MFA) methods, such as SMS codes, email verification, or
hardware tokens. By requiring multiple forms of authentication, the system adds an extra
layer of security.
3.) User Consent:
After identity and authentication checks, the user is asked to provide explicit
16
consent to access their PHR. This consent is critical, as it ensures that the individual is
aware of who is accessing their data and for what purpose. It also aligns with privacy
regulations and ethical considerations.
4.) Private Key Management:
In a blockchain system, each user has a private key that grants them access
to their encrypted health records. The user verification module oversees the secure
management of these private keys. It ensures that keys are generated and stored securely,
minimizing the risk of unauthorized access.
5.) Access Control:
The user verification module enforces access control policies defined by the
user. This means that users have the flexibility to grant or revoke access to their data to
healthcare providers, family members, or other authorized parties. The module manages
and enforces these permissions on the blockchain.
6.) Logging and Auditing:
All user verification activities, including successful logins, access requests,
and consent changes, are logged and audited. This audit trail enhances transparency,
accountability, and the ability to track any unauthorized access or data breaches.
7.) User Support:
The module also provides support to users who may encounter issues during
the verification process or have questions about their access rights. This support may
include a helpdesk or user-friendly interfaces to simplify the verification process.
Overall, the user verification module is integral to maintaining the security
and privacy of personal health records on a blockchain. It ensures that only authorized
users can access their data, and their interactions with the system are well-documented,
helping to establish trust and confidence in the PHR platform.

17
3.6.4 USER PERSONAL DETAILS:

In a blockchain-based Personal Health Records (PHR) system, the


"Personal Details" module is a crucial component that stores and manages an
individual's personal information. This module ensures the secure and efficient
handling of the user's identifying and contact details within the context of their health
records. Here's an explanation of the "Personal Details" module in such a system:

1.) User Identification:

The "Personal Details" module contains unique identifying information about


the user. This typically includes their full name, date of birth, gender, and a unique
identifier, such as a blockchain wallet address or a patient ID. These details are securely
stored and associated with the user's health records to maintain a clear link between the
individual and their medical information.

2.) Contact Information:

Users' contact details, including phone numbers, email addresses, and physical
addresses, are stored in this module. This information is essential for healthcare
providers to communicate with the user, send appointment reminders, or share critical
health updates.

3.) Emergency Contacts:

In case of emergencies, the "Personal Details" module may include information


about emergency contacts. This information helps healthcare providers quickly reach
out to designated individuals in case of an urgent medical situation.

4.) Consent and Preferences:

Users can specify their consent preferences regarding the sharing of their health
data. These preferences can include who can access their records, for what purposes,
and for how long. The "Personal Details" module serves as a repository for these consent
18
settings, ensuring that user privacy and data-sharing preferences are respected.

5.) Authentication and Security:

The module also manages user authentication and security measures. This
includes storing cryptographic keys or other authentication methods that users need to
access their PHR. By keeping these details secure, the blockchain-based system ensures
that only authorized users can view and modify their records.

6.) Change Tracking:

Any updates or changes to the personal details are recorded in the blockchain,
providing an immutable history of modifications. This transparency and data integrity
are key features of blockchain technology, enhancing trust and security.

The "Personal Details" module in a blockchain-based PHR system plays a pivotal


role in providing users with control, security, and privacy over their personal
information while maintaining a clear and immutable connection to their health records.
It's a fundamental element in ensuring the proper functioning and user-friendliness of
the system, which ultimately empowers individuals to actively manage and engage in
their healthcare.

3.6.5 HOME SCREEN:

The "Home Screen" module in a blockchain-based Personal Health Records


(PHR) system is a crucial component that serves as the user's entry point into their health
record management platform. This module is designed to provide a user-friendly and
intuitive interface that allows individuals to access, view, and manage their health
records seamlessly. Here's an explanation of the key features and functions typically
found in the Home Screen module of a PHR system using blockchain:

19
1.) User Authentication:

The Home Screen begins with a secure user authentication process. Users log
in using their unique credentials, such as a username and password, or more advanced
authentication methods like biometrics, to ensure that only authorized individuals can
access the system.

2.) User Profile:

Once logged in, users can view and edit their profile information, including
contact details, emergency contacts, insurance information, and any other relevant
personal data. This provides a holistic view of their health-related information.

3.) Summary of Health Records:

The Home Screen displays a summarized version of the user's health records.
This might include an overview of recent medical encounters, upcoming appointments,
or important health metrics like blood pressure, weight, and allergies. It gives users a
quick snapshot of their health status.

4.) Navigation Menu:

A user-friendly navigation menu or dashboard provides quick access to


various sections of the PHR platform, such as medical history, medications, test results,
and shared records. This makes it easy for users to find the specific information

5.) Record Access and Management:

Users can access and manage their full health records through the Home
Screen. They can view details of past medical visits, laboratory results, prescriptions,
and any other health-related information. Users can also upload new records, making it
a centralized repository for all their health data.

20
6.) Sharing and Permissions:

The Home Screen may include a section where users can manage the sharing
of their records with healthcare providers, family members, or other authorized
individuals. They can set permissions and access levels to control who can view or edit
their records.

7.) Notifications and Reminders:

The module can also feature a notification system that alerts users about
upcoming appointments, medication schedules, or any updates to their shared records.

8.) Security Information:

Information about the security measures in place, such as blockchain


encryption and data protection, is often provided on the Home Screen to reassure users
about the safety of their records.

Users can typically access help resources, FAQs, or customer support options
directly from the Home Screen in case they encounter any issues or have questions.

The Home Screen module is designed to make managing and interacting


with personal health records on a blockchain-based platform convenient, user-centric,
and secure. It empowers individuals to take control of their healthcare information,
ultimately promoting better health outcomes and fostering trust in the system.

21
CHAPTER 4

SYSTEM REQUIREMENTS

4.1 HARDWARE REQUIREMENT

Component Minimum Requirement

Processor 64-bit, four-core, 2.5 GHz minimum per core

RAM 8 GB for developer or evaluation use 16 GB for production use

Hard disk 20 GB

4.2 SOFTWARE REQUIREMENTS

• Flutter(UI Software Development Toolkit)

• Alchemy(Ethereum node provider)

• Pinata(IPFS Gateway)

• Dart and Solidity(Programming Languages)

• VS Code Editor

22
CHAPTER 5

IMPLEMENTATION

5.1 FRONTEND DEVELOPMENT:

5.1.1 USER REGISTRATION

(i) User Interface Design:


Begin by designing the user registration page with a user-friendly interface.
Include fields for personal information such as name, email, password, and any other
required details. Make sure the design is intuitive and responsive.

(ii) Data Validation:


Implement data validation checks on the frontend to ensure that users enter
valid information. This includes checking for valid email addresses, strong passwords,
and appropriate input formats.

(iii) Privacy Policy and Terms:


Include links to your platform's privacy policy and terms of service, and
make it clear that users must agree to these terms before registering.

(iv) Blockchain Wallet Integration:


To link the user to the blockchain, you need to integrate a wallet creation
feature. This includes generating a unique blockchain address for each user and linking
it to their account. Users should be educated on the importance of securely storing their
wallet details.

(v) Captcha or Anti-Spam Measures:


To prevent automated registration, implement captcha or other anti-spam
measures.
23
(vi) User Consent:
Before proceeding with registration, users should be asked for their
explicit consent to store their health data on the blockchain. Ensure transparency in
explaining how their data will be used.

(vii) Error Handling:


Develop a system for handling errors and providing user-friendly error
messages. This can include notifying users if an email is already in use or if there are
issues with their registration.

(viii) Confirmation Email:


After successful registration, send a confirmation email to the user's
provided email address to verify their account. Include a link for email verification.

(ix) User Dashboard Access:


Upon successful registration and email verification, grant users access to
their personalized dashboard, where they can start managing their PHR.

(x) Security:
Ensure that all data transmitted between the frontend and backend is
encrypted and secure. Additionally, implement mechanisms to prevent SQL injection
and other common security vulnerabilities.

5.1.2 USER LOGIN

(i) User Registration and KYC (Know Your Customer):


Start by creating a user registration form where users can input their
personal details. Implement a KYC process to verify the user's identity, which can
include document uploads for verification.

24
(ii) User Authentication:
Develop an authentication system that allows users to log in using their
registered credentials. Ensure secure password hashing and encryption for data
protection.

(iii) Blockchain Wallet Integration:


Integrate a blockchain wallet for each user, allowing them to securely
manage their PHR data. Provide clear instructions on how to create or link an existing
blockchain wallet.

(iv) Access Control and Permissions:


Implement role-based access control to define who can view or modify
specific PHR data. Allow users to manage access permissions for their data, granting or
revoking access to healthcare providers or trusted individuals.

(v) User Dashboard:


Design a user-friendly dashboard where users can easily navigate their
PHR data. Display a summary of their medical records, recent activity, and access
history.

(vi) PHR Upload and Management:


Enable users to upload and manage their health records securely. Data
should be encrypted before storage on the blockchain. Include features for adding,
updating, or deleting records as needed.

(vii) Data Sharing:


Implement a user-controlled data sharing feature, allowing users to
grant temporary or permanent access to specific healthcare providers or family
25
members. Notify users about access requests and changes in data access.

(viii) Security Measures:


Employ strong encryption and authentication mechanisms to protect
user data. Implement multi-factor authentication (MFA) for added security.

5.1.3 USER VERIFICATION

(i) User Registration:


Users start by signing up for the PHR platform. They provide essential
information such as their name, email, and a password.

(ii)Two-Factor Authentication (2FA):


After registration, users set up a 2FA method, such as receiving a one-
time code via SMS or email. This extra layer of security helps ensure that only the
authorized user can access their account.

(iii) User Profile:


Users create a profile, including personal information, emergency
contact details, and any relevant medical history. This profile is the basis for their PHR.

(iv) Blockchain Wallet Setup:


As part of the registration process, a blockchain wallet is created for
the user. This wallet is linked to their PHR and is used for secure, private key-based
access to their data.

(v) Identity Verification:


To ensure the identity of the user, they may be required to provide
additional information, such as a government-issued ID or proof of address. This step
can be automated using document verification services.

26
(vi) Biometric Verification:
Some PHR systems may include biometric verification, such as
fingerprint or facial recognition, for added security.

(vii) Email Confirmation:


Users receive a confirmation email to verify their email address. They
need to click a link in the email to confirm their registration.

5.1.4 USER PERSONAL DETAILS

(i) User Registration:


Create a user registration page where individuals can sign up for
the PHR platform. Collect essential information such as name, contact details, and
create a unique username and password for each user.

(ii) User Login:


Develop a secure login page for users to access their accounts.
Implement proper authentication and session management to ensure user privacy
and security.

(iii) User Dashboard:


Design a user-friendly dashboard where users can manage their
personal details. This should include sections for basic information like name, date
of birth, address, contact details, and emergency contacts.

(iv) Data Entry Forms:


Create structured data entry forms for each personal detail category.
For instance, have separate forms for entering contact details, medical history, allergies,
and medications. These forms should be intuitive and easy to fill out.

27
(v) Data Validation:
Implement validation checks to ensure data accuracy. Validate inputs
such as email addresses, phone numbers, and date of birth to maintain data integrity.

(vi) Data Encryption:


Apply strong encryption protocols to protect personal details while
they are being transmitted to and stored on the blockchain. This step is crucial for
maintaining privacy and security.

(vii) Blockchain Integration:


Connect the frontend with the blockchain network. When users submit
their personal details, this data should be securely stored on the blockchain, ensuring its
immutability and accessibility only through user-specific private keys.

(viii) Private Key Management:


Provide users with a secure way to manage their private keys. This
could involve implementing two-factor authentication or biometric verification for
added security.

5.1.5 HOME SCREEN

(i) User Registration and Login:


Begin with a user-friendly registration page, asking for essential
information. Implement a secure login system, requiring username and password.

(ii) Dashboard:
After login, the user lands on a personalized dashboard. Display a
user's profile information, including name and a profile picture. Include options to

28
navigate to different sections, such as "My Health Records," "Sharing," and "Settings."

(iii) My Health Records:


Create a section where users can view and manage their health records.
Show a summary of their medical history, including recent diagnoses, medications, and
allergies. Provide filters and sorting options for easy access to specific records.

(iv) Uploading Records:


Enable users to upload their medical records, including test results,
prescriptions, and doctor's notes. Allow document uploads in various formats like PDF,
images, or text.

(v) Blockchain Integration:


Ensure that the backend is seamlessly integrated with a blockchain
network for secure storage of health records. Users should not have to interact directly
with the blockchain, but the system should manage the blockchain interactions for them.

29
5.2. CODE IMPLEMENTATION:

5.2.1 USER REGISTRATION IMPLEMENTATION:

The user registration module in a blockchain-based Personal Health Records


(PHR) system plays a pivotal role in ensuring secure, verified, and controlled access to
the platform. Here's a breakdown of how this module functions:
1.) User Initiation:
Registration begins with the user providing essential information, such as
their full name, email address, and a secure password. This data serves as the
foundation of their digital identity within the PHR system.
2.) Identity Verification:
To bolster security and prevent fraudulent registrations, the system employs
various identity verification methods. These may include email confirmation, two-
factor authentication, or even advanced biometric verification. By confirming the user's
identity, the system ensures that only legitimate individuals gain access to the platform.
3.) Creation of Blockchain Identity:
After successful identity verification, the system establishes a unique
blockchain identity for the user. This identity is linked to a cryptographic key pair,
which comprises a public key (known to others on the network) and a private key
(known exclusively to the user). Safeguarding the private key is paramount, as it grants
access and control over the user's health records on the blockchain.
4.) User Consent and Data Privacy:
During the registration process, users are prompted to provide consent
regarding the management and sharing of their health data within the blockchain
network. This step empowers users to specify who can access their data, for what
purposes, and under what conditions. It is a fundamental component of ensuring that
users have full control over their personal health information and privacy.

30
FIGURE 5.1 User Registration Code Implementation

5.2.2 USER LOGIN IMPLEMENTATION:


A user login module within a blockchain-based Personal Health Records
(PHR) system plays a crucial role in ensuring the security and accessibility of a patient's
health information. Here's an explanation of how the user login module typically works
in such a system:
1.) User Registration:
To begin using the blockchain-based PHR system, a user must first register.
During registration, the user provides their personal information, creates a unique
username and password, and associates their public blockchain address with their
account.
2.) Authentication:
When the user attempts to access their PHR, they are prompted to enter
their username and password. This information is securely stored in the system's
database, but the password is typically hashed and salted to enhance security.
3.) Two-Factor Authentication (2FA):
Many blockchain-based PHR systems may implement an additional layer
31
of security by offering two-factor authentication. This could involve sending a one-time
code to the user's registered mobile device or email, which they must enter to complete
the login process.

4.) Private Key Management:


In blockchain technology, a user's private key is crucial for accessing and
controlling their PHR data. The user login module may include a secure way for users
to manage their private keys, such as providing options for password recovery or
securely storing and retrieving their private keys

FIGURE 5.2 User Login Code Implementation

5.2.3 USER VERIFICATION IMPLEMENTATION:


The user verification module in a blockchain-based Personal
Health Records (PHR) system is a crucial component designed to ensure the authenticity
and security of individuals accessing their health data. This module plays a pivotal role
in safeguarding the sensitive medical information stored on the blockchain, promoting
trust and data integrity. Here's an explanation of the user verification module in this
context:

32
1.) Identity Verification:
The user verification module starts by verifying the identity of the individual
seeking access to their PHR. This process typically involves collecting various forms of
identification, such as government-issued IDs, biometric data (e.g., fingerprints or facial
recognition), or other personally identifiable information.
2.) Authentication:
Once the identity is verified, the system utilizes strong authentication
mechanisms to confirm that the person is who they claim to be. This can include multi-
factor authentication (MFA) methods, such as SMS codes, email verification, or
hardware tokens. By requiring multiple forms of authentication, the system adds an extra
layer of security.
3.) User Consent:
After identity and authentication checks, the user is asked to provide explicit
consent to access their PHR. This consent is critical, as it ensures that the individual is
aware of who is accessing their data and for what purpose. It also aligns with privacy
regulations and ethical considerations.
4.) Private Key Management:
In a blockchain system, each user has a private key that grants them access
to their encrypted health records. The user verification module oversees the secure
management of these private keys. It ensures that keys are generated and stored securely,
minimizing the risk of unauthorized access.

33
FIGURE 5.3 User Verification Code Implementation

5.2.4 USER PERSONAL DETAILS IMPLEMENTATION :

In a blockchain-based Personal Health Records (PHR) system,


the "Personal Details" module is a crucial component that stores and manages an
individual's personal information. This module ensures the secure and efficient
handling of the user's identifying and contact details within the context of their health
records. Here's an explanation of the "Personal Details" module in such a system:

1.) User Identification:

The "Personal Details" module contains unique identifying information about


the user. This typically includes their full name, date of birth, gender, and a unique
identifier, such as a blockchain wallet address or a patient ID. These details are securely
stored and associated with the user's health records to maintain a clear link.

34
2.) Contact Information:

Users' contact details, including phone numbers, email addresses, and physical
addresses, are stored in this module. This information is essential for healthcare
providers to communicate with the user, send appointment reminders, or share critical
health updates.

3.) Emergency Contacts:

In case of emergencies, the "Personal Details" module may include information


about emergency contacts. This information helps healthcare providers quickly reach
out to designated individuals in case of an urgent medical situation.

4.) Consent and Preferences:

Users can specify their consent preferences regarding the sharing of their
health data. These preferences can include who can access their records, for what
purposes, and for how long. The "Personal Details" module serves as a repository for
these consent settings, ensuring that user privacy and data-sharing preferences are
respected.

FIGURE 5.4 User Personal Details Code Implementation


35
5.2.5 HOME SCREEN IMPLEMENTATION:

The "Home Screen" module in a blockchain-based Personal Health Records


(PHR) system is a crucial component that serves as the user's entry point into their health
record management platform. This module is designed to provide a user-friendly and
intuitive interface that allows individuals to access, view, and manage their health
records seamlessly. Here's an explanation of the key features and functions typically
found in the Home Screen module of a PHR system using blockchain:

1.) User Authentication:

The Home Screen begins with a secure user authentication process. Users log
in using their unique credentials, such as a username and password, or more advanced
authentication methods like biometrics, to ensure that only authorized individuals can
access the system.

2.) User Profile:

Once logged in, users can view and edit their profile information, including
contact details, emergency contacts, insurance information, and any other relevant
personal data. This provides a holistic view of their health-related information.

3.) Summary of Health Records:

The Home Screen displays a summarized version of the user's health records.
This might include an overview of recent medical encounters, upcoming appointments,
or important health metrics like blood pressure, weight, and allergies. It gives users a
quick snapshot of their health status.

4.) Navigation Menu:

A user-friendly navigation menu or dashboard provides quick access to


various sections of the PHR platform, such as medical history, medications, test results,

36
and shared records. This makes it easy for users to find the specific information

FIGURE 5.5 Home Screen Code Implementation

37
5.3 BACKEND DEVELOPMENT:

Define Objectives and Regulations:


Clearly outline your project's goals, understand relevant healthcare regulations (e.g.,
HIPAA in the United States), and identify data privacy and security requirements.
Select Blockchain Platform:
Choose the appropriate blockchain platform, such as Ethereum, Hyperledger Fabric,
or a private blockchain, considering factors like scalability, consensus mechanism, and
developer community support.
Data Schema Design:
Design a data schema to represent PHR data. Include fields for patient demographics,
medical history, prescriptions, and any other relevant information. Ensure data
normalization to optimize storage and retrieval.
User Identity Management:
Implement a secure user identity management system. Users should have a unique
identifier, possibly linked to a cryptographic key pair, to access their records.
Smart Contract Development:
Develop smart contracts for managing PHR transactions. These contracts should
include functions for record creation, modification, and access control. Security and privacy
must be top priorities during this phase.
Consensus Mechanism:
Choose a consensus mechanism that ensures data integrity and prevents unauthorized
modifications. Consider options like Proof of Authority (PoA) or Practical Byzantine Fault
Tolerance (PBFT) for a private blockchain.

38
Data Encryption:
Implement robust encryption protocols to secure data both at rest and during
transmission. Encryption keys should be stored securely and only accessible to authorized
users.
Access Control:
Develop access control mechanisms to determine who can view, modify, or share a
patient's records. This should align with patient consent and privacy preferences.
Data Storage Integration:
Connect the blockchain with a secure and scalable data storage solution (e.g., IPFS
or a cloud-based storage service) to store large files like medical images or reports.
API Development:
Create APIs to allow external applications, such as electronic health records (EHR)
systems or mobile apps, to interact with the blockchain. Ensure proper authentication and
authorization.
Testing and Quality Assurance:
Thoroughly test the backend to identify and rectify any vulnerabilities, bugs, or
performance issues. Security testing is of utmost importance to protect patient data.
Compliance Check:
Verify that the backend complies with relevant healthcare regulations and data
protection laws. Conduct third-party audits if necessary.
Scalability and Performance Optimization:
Ensure that the system can handle a growing volume of PHR transactions and maintain
optimal performance.
Monitoring and Maintenance:
Implement continuous monitoring and regular maintenance to address security
updates, blockchain protocol upgrades, and emerging threats.

39
User Training and Support:
Educate users, including healthcare providers and patients, on how to use the system
effectively. Offer robust customer support for issue resolution and guidance.

A Blockchain-based PHR backend system requires meticulous planning and execution,


emphasizing data security, privacy, and compliance. This approach ensures that the system
provides a trustworthy and efficient platform for managing personal health records.

5.4 RESULT
Personal health records (PHRs) using blockchain technology offer a promising
solution for securely storing and managing individuals' medical information. Unlike
traditional paper-based or centralized electronic health records (EHRs), blockchain-based
PHRs provide a decentralized and tamper-resistant platform for patients to maintain control
over their health data. Blockchain's key advantage lies in its ability to ensure data integrity
and security. Patient records are stored in a distributed ledger, with each block containing a
time-stamped and encrypted set of transactions. This design makes it extremely difficult for
unauthorized access, fraud, or data breaches, as any alteration would require consensus from
the entire network, ensuring the utmost privacy and trust.
Patients can grant access to their PHRs to healthcare providers, improving care
coordination and reducing duplication of tests and procedures. Furthermore, blockchain-
based PHRs empower individuals to selectively disclose their health data to researchers,
insurers, or any relevant party, promoting data ownership and consent-driven sharing.
Moreover, the interoperability of blockchain allows for seamless integration of PHRs across
different healthcare systems and providers, overcoming the fragmentation and data silos
prevalent in the current healthcare landscape.

40
CHAPTER 6

CONCLUSION

The integration of blockchain technology into Personal Health Records (PHR)


marks a significant leap forward in the healthcare industry. It empowers individuals with
unprecedented control, privacy, and security over their medical information, ultimately
fostering trust, data integrity, and patient engagement. Blockchain's decentralized ledger
and encryption techniques ensure that sensitive health data remains secure and accessible
only to authorized parties. Patients are given a private key, giving them the ultimate
authority over who can access their records. This instills confidence in patients, knowing
their data is protected and shared only when they grant permission.
The blockchain's ability to maintain data integrity through time-stamping and
immutability is a critical feature in preserving the accuracy of medical histories and
preventing unauthorized changes or breaches. This, in turn, enhances the quality of
healthcare decision-making. Furthermore, the transparency and security of blockchain-
powered PHRs encourage active patient engagement. When individuals have faith in the
safety of their data, they are more likely to take an active role in managing their health,
leading to better healthcare outcomes.
Overall, the blockchain-powered PHR system is a revolutionary step forward,
putting patients at the center of their healthcare journey. It not only ensures the privacy
and security of personal health data but also promotes trust, data integrity, and
engagement, making it a vital tool for the future of healthcare. This project sets the stage
for a more patient-centric and efficient healthcare ecosystem that benefits individuals and
the industry as a whole.

41
APPENDICES
SOURCE CODE:
“””MEDVAULT: PERSONAL HEALTH RECORDS USING BLOCKCHAIN @author:
ABISHAKE – AJITHKUMAR – BHUANESH KUMAR “””

import 'package:bhuanesh_s_application6/core/app_export.dart';
import 'package:bhuanesh_s_application6/widgets/custom_outlined_button.dart';
import 'package:flutter/material.dart';

class LoginAndRegisterScreen extends StatelessWidget {


const LoginAndRegisterScreen({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
body: SingleChildScrollView(
child: Container(

width: mediaQueryData.size.width,
height: mediaQueryData.size.height,
decoration: BoxDecoration(
border: Border.all(
color:
theme.colorScheme.onPrimaryContainer.withOpacity(1),

42
width: 1.h,
strokeAlign: strokeAlignOutside),
gradient: LinearGradient(
begin: Alignment(0.5, 1),
end: Alignment(0.5, 0),
colors: [
theme.colorScheme.secondaryContainer,
theme.colorScheme.secondaryContainer.withOpacity(0)
])),
child: Container(
width: double.maxFinite,
padding: EdgeInsets.symmetric(vertical: 25.v),
child: Column(mainAxisSize: MainAxisSize.min, children: [
Container(
width: double.maxFinite,
padding: EdgeInsets.symmetric(
horizontal: 26.h, vertical: 11.v),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(ImageConstant.imgGroup59),
fit: BoxFit.cover)),
child: Column(children: [
SizedBox(
height: 236.v,
width: 332.h,
child: Stack(

43
alignment: Alignment.center,
children: [
Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding:
EdgeInsets.only(bottom: 6.v),
child: SizedBox(
width: 332.h,
child: Divider()))),
Align(
alignment: Alignment.center,
child: SizedBox(
height: 236.v,
width: 124.h,
child: Stack(
alignment: Alignment.center,
children: [
CustomImageView(
imagePath: ImageConstant
.imgElectronicmedi,
height: 212.v,
width: 98.h,
radius: BorderRadius
.circular(10.h),
alignment:

44
Alignment.center),
CustomImageView(
imagePath: ImageConstant
.imgKisspngapplei,
height: 236.v,
width: 124.h,
radius: BorderRadius
.circular(37.h),
alignment:
Alignment.center)
])))
])),
Container(
width: 243.h,
margin:
EdgeInsets.fromLTRB(48.h, 31.v, 49.h, 25.v),
child: RichText(
text: TextSpan(children: [
TextSpan(
text: "Hello\n",
style: CustomTextStyles
.displayMediumInknutAntiquaOnPrimaryContainer_1),
TextSpan(
text: "Welcome to MedVault.",
style: theme.textTheme.bodyLarge)
]),

45
textAlign: TextAlign.center))
])),
SizedBox(height: 36.v),
CustomOutlinedButton(
width: 100.h,
text: "Login",
buttonStyle:
CustomButtonStyles.outlineOnPrimaryContainer,
onTap: () {
onTapLogin(context);
}),
SizedBox(height: 38.v),
CustomOutlinedButton(
width: 100.h,
text: "Register",
rightIcon: Container(
margin: EdgeInsets.only(),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.h)),
),
onTap: () {
onTapRegister(context);
}),
SizedBox(height: 5.v)
]))))));
}

46
/// Navigates to the loginScreen when the action is triggered.
///
/// The [BuildContext] parameter is used to build the navigation stack.
/// When the action is triggered, this function uses the [Navigator] widget
/// to push the named route for the loginScreen.
onTapLogin(BuildContext context) {
Navigator.pushNamed(context, '/login_screen');
}

/// Navigates to the registerScreen when the action is triggered.


///
/// The [BuildContext] parameter is used to build the navigation stack.
/// When the action is triggered, this function uses the [Navigator] widget
/// to push the named route for the registerScreen.
onTapRegister(BuildContext context) {
Navigator.pushNamed(context, '/register_screen');
}
}

import 'package:bhuanesh_s_application6/core/app_export.dart';
import 'package:bhuanesh_s_application6/widgets/custom_outlined_button.dart';
import 'package:flutter/material.dart';

class RegisterScreen extends StatelessWidget {


const RegisterScreen({Key? key}) : super(key: key);

47
@override
Widget build(BuildContext context) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
extendBody: true,
extendBodyBehindAppBar: true,
body: Container(
width: mediaQueryData.size.width,
height: mediaQueryData.size.height,
decoration: BoxDecoration(
color: appTheme.whiteA700,
border: Border.all(
color:
theme.colorScheme.onPrimaryContainer.withOpacity(1),
width: 1.h),
image: DecorationImage(
image: AssetImage(ImageConstant.imgRegister),
fit: BoxFit.cover)),
child: Container(
width: 394.h,
padding: EdgeInsets.symmetric(vertical: 4.v),
child: Column(mainAxisSize: MainAxisSize.min, children: [
SizedBox(height: 5.v),
SizedBox(

48
height: 659.v,
width: 387.h,
child: Stack(
alignment: Alignment.bottomCenter,
children: [
Align(
alignment: Alignment.topCenter,
child: Container(
padding: EdgeInsets.symmetric(
horizontal: 95.h, vertical: 96.v),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
ImageConstant.imgGroup12),
fit: BoxFit.cover)),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment:
MainAxisAlignment.center,
children: [
SizedBox(height: 28.v),
Text("REGISTER",
style: theme
.textTheme.displayMedium)
]))),
Align(

49
alignment: Alignment.bottomCenter,
child: Container(
margin: EdgeInsets.symmetric(
horizontal: 35.h),
padding: EdgeInsets.symmetric(
horizontal: 16.h, vertical: 20.v),
decoration: AppDecoration
.outlineOnPrimaryContainer1
.copyWith(
borderRadius: BorderRadiusStyle
.roundedBorder20),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
"Please store the account phrase safely:",
style: theme
.textTheme.titleSmall),
Padding(
padding: EdgeInsets.only(
left: 12.h, top: 18.v),
child: Text("1.strike",
style: theme.textTheme
.bodySmall)),

50
Padding(
padding: EdgeInsets.only(
left: 12.h, top: 13.v),
child: Text("2.basket",
style: theme.textTheme
.bodySmall)),
Padding(
padding: EdgeInsets.only(
left: 13.h, top: 10.v),
child: Text("3.scheme",
style: theme.textTheme
.bodySmall)),
Padding(
padding: EdgeInsets.only(
left: 13.h, top: 9.v),
child: Text("4.fall",
style: theme.textTheme
.bodySmall)),
Padding(
padding: EdgeInsets.only(
left: 13.h, top: 10.v),
child: Text("5.enroll",
style: theme.textTheme
.bodySmall)),
Padding(
padding: EdgeInsets.only(

51
left: 12.h, top: 12.v),
child: Text("6.expire",
style: theme.textTheme
.bodySmall)),
Padding(
padding: EdgeInsets.only(
left: 13.h, top: 11.v),
child: Text("7.april",
style: theme.textTheme
.bodySmall)),
Padding(
padding: EdgeInsets.only(
left: 13.h, top: 10.v),
child: Text("8.humor",
style: theme.textTheme
.bodySmall)),
Padding(
padding: EdgeInsets.only(
left: 12.h, top: 14.v),
child: Text("9.pudding",
style: theme.textTheme
.bodySmall)),
Padding(
padding: EdgeInsets.only(
left: 13.h, top: 10.v),
child: Text("10.lucky",

52
style: theme.textTheme
.bodySmall)),
Padding(
padding: EdgeInsets.only(
left: 13.h, top: 12.v),
child: Text("11.expect",
style: theme.textTheme
.bodySmall)),
Padding(
padding: EdgeInsets.only(
left: 12.h, top: 12.v),
child: Text("12.expose",
style: theme.textTheme
.bodySmall)),
SizedBox(height: 24.v),
CustomOutlinedButton(
width: 192.h,
text: "copy to clipboard",
leftIcon: Container(
margin: EdgeInsets.only(
right: 6.h),
child: CustomImageView(
height: 30.v,
width: 30.h)),
buttonStyle:
CustomButtonStyles.none,

53
onTap: () {
onTapCopyto(context);
},
alignment: Alignment.center),
SizedBox(height: 40.v)
])))
]))
])))));
}

/// Navigates to the verifyScreen when the action is triggered.


///
/// The [BuildContext] parameter is used to build the navigation stack.
/// When the action is triggered, this function uses the [Navigator] widget
/// to push the named route for the verifyScreen.
onTapCopyto(BuildContext context) {
Navigator.pushNamed(context, '/verify_screen');
}

import 'package:bhuanesh_s_application6/core/app_export.dart';
import 'package:bhuanesh_s_application6/widgets/custom_outlined_button.dart';
import 'package:bhuanesh_s_application6/widgets/custom_text_form_field.dart';
import 'package:flutter/material.dart';

54
// ignore_for_file: must_be_immutable
class PersonalDetailsScreen extends StatelessWidget {
PersonalDetailsScreen({Key? key}) : super(key: key);

TextEditingController firstNameController = TextEditingController();

TextEditingController lastNameController = TextEditingController();

TextEditingController emailController = TextEditingController();

TextEditingController dateOfBirthController = TextEditingController();

TextEditingController phoneNumberController = TextEditingController();

@override
Widget build(BuildContext context) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
resizeToAvoidBottomInset: false,
body: SizedBox(
width: double.maxFinite,
child: Column(mainAxisSize: MainAxisSize.min, children: [
SizedBox(height: 3.v),
SizedBox(

55
height: 849.v,
width: 391.h,
child: Stack(alignment: Alignment.topCenter, children: [
CustomImageView(
imagePath: ImageConstant.imgDesktopwallpap849x3911,
height: 849.v,
width: 391.h,
radius: BorderRadius.circular(10.h),
alignment: Alignment.center),
Align(
alignment: Alignment.topCenter,
child: Padding(
padding: EdgeInsets.only(
left: 3.h, top: 45.v, right: 6.h),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text("PERSONAL DETAILS",
textAlign: TextAlign.center,
style: theme.textTheme.displayMedium),
Container(
margin: EdgeInsets.only(
left: 32.h,
top: 29.v,
right: 32.h),
padding: EdgeInsets.symmetric(

56
horizontal: 16.h, vertical: 27.v),
decoration: AppDecoration
.outlineOnPrimaryContainer2
.copyWith(
borderRadius:
BorderRadiusStyle
.roundedBorder20),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(
left: 12.h),
child: Text("FIRST NAME",
style: theme.textTheme
.bodySmall)),
CustomTextFormField(
controller:
firstNameController,
margin: EdgeInsets.only(
left: 8.h, top: 4.v)),
Padding(
padding: EdgeInsets.only(
left: 12.h, top: 31.v),

57
child: Text("LAST NAME",
style: theme.textTheme
.bodySmall)),
CustomTextFormField(
controller:
lastNameController,
margin: EdgeInsets.only(
left: 8.h, top: 5.v)),
Padding(
padding: EdgeInsets.only(
left: 12.h, top: 32.v),
child: Text("EMAIL",
style: theme.textTheme
.bodySmall)),
CustomTextFormField(
controller: emailController,
margin: EdgeInsets.only(
left: 8.h, top: 4.v)),
Padding(
padding: EdgeInsets.only(
left: 12.h, top: 27.v),
child: Text("DATE OF BIRTH",
style: theme.textTheme
.bodySmall)),
CustomTextFormField(
controller:

58
dateOfBirthController,
margin: EdgeInsets.only(
left: 8.h, top: 4.v)),
Padding(
padding: EdgeInsets.only(
left: 12.h, top: 30.v),
child: Text("PHONE NUMBER",
style: theme.textTheme
.bodySmall)),
CustomTextFormField(
controller:
phoneNumberController,
margin: EdgeInsets.only(
left: 8.h, top: 6.v),
textInputAction:
TextInputAction.done),
CustomOutlinedButton(
width: 80.h,
text: "Next",
margin: EdgeInsets.only(
left: 82.h,
top: 46.v,
bottom: 35.v),
rightIcon: Container(
margin: EdgeInsets
.only(),

59
decoration: BoxDecoration(
borderRadius:
BorderRadius
.circular(10
.h)),
child: CustomImageView(
svgPath: ImageConstant
.imgRectangle)),
buttonStyle: CustomButtonStyles
.outlineOnPrimaryContainerTL10,
onTap: () {
onTapNext(context);
})
]))
])))
]))
]))));
}

/// Navigates to the loginScreen when the action is triggered.


///
/// The [BuildContext] parameter is used to build the navigation stack.
/// When the action is triggered, this function uses the [Navigator] widget
/// to push the named route for the loginScreen.
onTapNext(BuildContext context) {
Navigator.pushNamed(context, AppRoutes.loginScreen);

60
}
}
#___________________BACKEND IMPLEMENTATION_____________________
pragma solidity >=0.7.0 <0.9.0;
contract Upload {

struct Access{
address user;
bool access; //true or false
}
mapping(address=>string[]) value;
mapping(address=>mapping(address=>bool)) ownership;
mapping(address=>Access[]) accessList;
mapping(address=>mapping(address=>bool)) previousData;

function add(address _user,string memory url) external {


value[_user].push(url);
}
function allow(address user) external {//def
ownership[msg.sender][user]=true;
if(previousData[msg.sender][user]){
for(uint i=0;i<accessList[msg.sender].length;i++){
if(accessList[msg.sender][i].user==user){
accessList[msg.sender][i].access=true;
}
}

61
}else{
accessList[msg.sender].push(Access(user,true));
previousData[msg.sender][user]=true;
}

}
function disallow(address user) public{
ownership[msg.sender][user]=false;
for(uint i=0;i<accessList[msg.sender].length;i++){
if(accessList[msg.sender][i].user==user){
accessList[msg.sender][i].access=false;
}
}
}

function display(address _user) external view returns(string[] memory){


require(_user==msg.sender || ownership[_user][msg.sender],"You don't have access");
return value[_user];
}

function shareAccess() public view returns(Access[] memory){


return accessList[msg.sender];
}
}

import 'dart:convert';

62
import 'package:flutter/material.dart';
import 'package:http_parser/http_parser.dart';
import 'package:http/http.dart' as http;
import 'package:file_picker/file_picker.dart';

class HomeScreen extends StatefulWidget {


const HomeScreen({Key? key}) : super(key: key);

@override
_HomeScreenState createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {


String uploadStatus = '';
List<String> ipfsUrls = [];

void uploadToIPFS(List<PlatformFile> files) async {


try {
// Create a Pinata account and obtain API keys at https://pinata.cloud/
String apiKey = 'c21bfae6f04632d14c78';
String apiSecret =
'427c876e1da8247d56ec9802c8af6c2f5039b4c73b8b9f528d4f2c30fa375f8c';

String endpoint = 'https://api.pinata.cloud/pinning/pinFileToIPFS';

63
for (var file in files) {
var request = http.MultipartRequest('POST', Uri.parse(endpoint));
request.headers.addAll({
'pinata_api_key': apiKey,
'pinata_secret_api_key': apiSecret,
});

if (file.bytes != null) {
var multipartFile = http.MultipartFile.fromBytes(
'file',
file.bytes!,
filename: file.name,
);
request.files.add(multipartFile);
// Now you can proceed with using 'multipartFile' in the request.
} else {
// Handle the case where 'file.bytes' is null, for example, by showing an error message.
}

var response = await request.send();


if (response.statusCode == 200) {
var responseBody = await response.stream.bytesToString();
Map<String, dynamic> responseJson = json.decode(responseBody);
String ipfsUrl = responseJson['IpfsHash'];
ipfsUrls.add(ipfsUrl);
}

64
}

setState(() {
uploadStatus = 'Upload complete!';
});
} catch (e) {
setState(() {
uploadStatus = 'Error: $e';
});
}
}

void retrieveFromIPFS() async {


// Replace 'YOUR_IPFS_HASH' with the actual hash you want to retrieve
String ipfsHash = 'YOUR_IPFS_HASH';
String ipfsUrl = 'https://gateway.pinata.cloud/ipfs/$ipfsHash';

// You can now use 'ipfsUrl' to display or download the file


// For example, you can use the 'http' package to fetch the file and display it.
}
#____________________________API___________________________________
void pickFiles() async {
FilePickerResult? result = await FilePicker.platform.pickFiles(
type: FileType.custom,
allowedExtensions: ['jpg', 'pdf', 'doc'],
allowMultiple: true);

65
if (result != null) {
uploadToIPFS(result.files);
}
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('IPFS File Upload'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextButton(
onPressed: pickFiles,
child: Text('Pick Files'),
),
Text(uploadStatus),
TextButton(
onPressed: retrieveFromIPFS,
child: Text('Retrieve from IPFS'),
),
}
}

66
OUTPUT

FIGURE 6.1 User Register and User Login

FIGURE 6.2 User Personal Details and Verification of User Documents

67
FIGURE 6.3 Upload page and User Account Details

68
REFERENCES

[1] Rifi, Nabil, Elie Rachkidi, Nazim Agoulmine, and Nada Chendeb Taher.
”Towards using blockchain technology for eHealth data access man- agement.” In 2017
Fourth International Conference on Advances in Biomedical Engineering (ICABME),
pp. 1-4. IEEE, 2017.
[2] Pramod P, Pratyush Kumar Tripathy, Harshit Bajpai, Manjunath R Kounte, ”Role
of Natural Language Processing and Deep Learning in Intelligent Machines”, IEEE
International Conference on Electrical, Communication, Electronics, Instrumentation
and Computing (ICECEIC), Kanchipuram,
India, 30-31 Jan 2019
[3] Kotsiuba, Igor, Artem Velvkzhanin, Yury Yanovich, Iuna Skarga Ban- durova,
Yuriy Dyachenko, and Viacheslav Zhygulin. ”Decentralized e- Health Architecture for
Boosting Healthcare Analytics.” In 2018 Second World Conference on Smart Trends in
Systems, Security and Sustainabil- ity (WorldS4), pp. 113-118. IEEE, 2018.
[4] Mikula, Tomas, and Rune Hylsberg Jacobsen. ”Identity and Access
Management with Blockchain in Electronic Healthcare Records.” In 2018 21st
Euromicro Conference on Digital System Design (DSD), pp. 699- 706. IEEE, 2018.
[5] Soumyalatha Naveen, Manjunath R Kounte, Machine Learning based Fog
Computing as an Enabler of IoT, International Conference on New Trends in
Engineering and Technology (ICNTET), Tiruvalur, Tamil Nadu, India, 7-8 Sep 2018
[6] Kamau, Gabriel, Caroline Boore, Elizaphan Maina, and Stephen Njenga.
”Blockchain Technology: Is this the Solution to EMR Interoperability and Security
Issues in Developing Countries?.” In 2018 IST-Africa Week Conference (IST-Africa),
pp. Page-1. IEEE, 2018.
[7] Alhadhrami, Zainab, Salma Alghfeli, Mariam Alghfeli, Juhar Ahmed Abedlla,
and Khaled Shuaib. ”Introducing blockchains for healthcare.” In 2017 International
Conference on Electrical and Computing Technologies and Applications (ICECTA),
pp. 1-4. IEEE, 2017
69
[8] Zhang, Xiaoshuai, and Stefan Poslad. ”Blockchain Support for Flexible Queries
with Granular Access Control to Electronic Medical Records (EMR).” In 2018 IEEE
International Conference on Communications (ICC), pp. 1-6. IEEE, 2018.
[9] Chintarlapallireddy Yaswanth Simha, Harshini V M, L V S Raghuvamsi,
Manjunath R Kounte, ”Enabling Technologies for Internet of Things Its Security
issues”, Second International Conference on Intelligent Com- puting and Control
Systems (ICICCS 2018), Madurai, India, 14-15 June 2018, pp 1849-1852
[10] Wehbe, Youssef, Mohamed Al Zaabi, and Davor Svetinovic. ”Blockchain AI
Framework for Healthcare Records Management: Constrained Goal Model.” In 2018
26th Telecommunications Forum (TELFOR), pp. 420-425. IEEE, 2018.
[11] Novikov, Sergey P., Oleg D. Kazakov, Natalya A. Kulagina, and Natalya Yu
Azarenko. ”Blockchain and Smart Contracts in a Decentralized Health Infrastructure.”
In 2018 IEEE International Conference” Quality Management, Transport and
Information Security, Information Technolo- gies”(ITQMIS), pp. 697-703. IEEE,
2018.
[12] Jiang, Shan, Jiannong Cao, Hanqing Wu, Yanni Yang, Mingyu Ma, and
Jianfei He. ”Blochie: a blockchain-based platform for healthcare information
exchange.” In 2018 IEEE International Conference on Smart Computing
(SMARTCOMP), pp. 49-56. IEEE, 2018.
[13] Azaria, Asaph, Ariel Ekblaw, Thiago Vieira, and Andrew Lippman. ”Medrec:
Using blockchain for medical data access and permission management.” In 2016 2nd
International Conference on Open and Big Data (OBD), pp. 25-30. IEEE, 2016.
[14] Kaushik, Akanksha, Archana Choudhary, Chinmay Ektare, Deepti Thomas,
and Syed Akram. ”BlockchainLiterature survey.” In 2017 2nd IEEE International
Conference on Recent Trends in Electronics, Infor- mation Communication
Technology (RTEICT), pp. 2145-2148. IEEE, 2017.

70

You might also like