This project enables storing Electronic Health Records (EHR) on the Ethereum blockchain using the ERC-721 protocol for NFTs. Prescriptions created by doctors are stored as NFTs on IPFS. The tokenURI generated is stored on-chain and mapped to a unique tokenId. The project also features Web3-powered signup and login functionality, allowing users to authenticate using wallets like MetaMask or Phantom.
- Decentralized EHR Storage: Prescriptions stored securely as
NFTsonIPFS. - Web3 Authentication: Signup and login using wallet addresses and cryptographic nonce verification.
- Role-based System: Separate user roles for doctors and patients.
- Fee Payment: Seamless fee payment mechanism for doctors using blockchain transactions.
- Node.js (v20+)
- MetaMask or Phantom wallet
- Ethereum network (e.g., Rinkeby/Testnet or Mainnet)
- IPFS setup (or Infura for IPFS storage)
- Clone the repository:
git clone https://github.com/anasM0hammad/dMed_frontend.git cd your-repo - Install dependencies:
npm install
- Configure environment variables in a
.envfile:REACT_APP_CONTRACT_ADDRESS=<address of deployed contract> REACT_APP_INFURA_PROJECT_ID=<your-infura-project-id> REACT_APP_INFURA_PROJECT_SECRET=<your-infura-project-secret>
- Start the application:
npm start
- Clone the repository:
git clone https://github.com/anasM0hammad/dMed_backend.git cd your-repo - Install dependencies:
npm install
- Configure environment variables in a
.envfile:MONGODB_URI=mongodb:://URI PORT=port number to run on SALT=for JWT
- Start the application:
npm start
- Clone the repository:
git clone https://github.com/anasM0hammad/dMed_contracts.git cd your-repo - Install dependencies:
npm install
- use truffle to compile and deploy:
truffle comiple truffle migrate
-
Signup:
- Users sign up as a doctor or patient using their wallet address as a unique identifier.
- All the details will be stored in mongodb database
- Wallet address will be used as userId.
- A Nonce will be stored for each user entry
-
Login:
- A nonce is generated and stored on the backend.
- Frontend will do a
getNonce()call to fetch the user nonce. - The user signs the nonce using their wallet (MetaMask/Phantom).
- The signature then will be sent to backend.
- The backend verifies the signed nonce and issues a JWT token upon successful verification.
- Doctors will start the consultation with a valid patient address
- Once done, doctor will add values like symptoms, diagnosis, medicine and findings with prescriptions notes.
- Once consultation is completed doctor will
generate prescriptionwhich will create an entry in db with prescription metadata - A PDF preview of prescription will be open and other data like consultation cost (in wei) and notes will be entered by doctor
- Doctor digitally signs the PDF and signature will be marked as QR Code on PDF.
- Doctor then end the consultation with PDF gets stored on IPFS returning the tokenURI
- A contract call on ethereum network will be made to
generate NFTwith giventokenURI,cost,patientAddressand doctor as owner - An ERC-721 token is minted with the
tokenURIstored on-chain and mapped to a uniquetokenId. - Prescription metadata on DB will be updated with
cost,tokenIdandtokenURI
- Patients pay consultation fees to doctors through blockchain transactions.
- Smart contracts handle the payment and ensure transparency and immutability.
- On payment the contract will transfer the ownership of the NFT to the patient from the doctor
- This provides authenticity of
EHRmade by doctor and payment confirmation from patient.
- Blockchain:
Ethereum,ERC-721,Solidity,Web3,Remix,Truffle - Storage:
IPFS,MongoDB - Frontend:
React.js,HTML,CSS - Backend:
Node.js,Express,Mongoose - Authentication:
JWT,Cryptography
- Set up a
MetaMaskorPhantomwallet. - Deploy the smart contracts using the provided scripts:
npm run deploy
- Access the application in your browser:
http://localhost:3000
- SnomedCT can be integrated for retrieving medical data during consultation
- On Confirmation of payment backend can update the status of prescription using events
- Allow login/signup through other methods like email/passsword and social auth
- An extended feature can be implemeted for pharmacies for prescription verification
- so on...
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature/bugfix.
- Submit a pull request with detailed description.
For any queries, feel free to reach out:
- Email: anas.1633.m@gmail.com
- GitHub: anasM0hammad


