DPHRS (Decentralised Patient Health Records System) is a secure, blockchain-based web application designed to give patients complete ownership and control over their medical data.
By leveraging Ethereum smart contracts, medical records are immutably stored on the blockchain. Instead of relying on a centralized hospital database that can be breached or compromised, DPHRS guarantees that patient data is decentralized, tamper-proof, and solely accessible via cryptographic keys. Healthcare institutions can securely write and read from a verifiable ledger while patients retain oversight via transparent access logs.
- Decentralized Storage: Patient basic information and medical records are stored directly on the blockchain, eliminating single points of failure.
- Role-Based Access Control: Distinct, secure dashboard interfaces for Patients and Hospitals.
- Cryptographic Ownership: Patients manage their identity using MetaMask wallet public/private key pairs.
- Medical History Interoperability: Any registered hospital can fetch a patient's historical medical records seamlessly via their public wallet address.
- Transparent Audit Trails: Every time a hospital queries a patient's data or adds a record, an immutable access log is generated on the blockchain that the patient can review.
- Zero Third-Party Tracking: Records are tied strictly to wallet addresses without intermediaries.
- Frontend: Next.js 16 (App Router), React 19, TypeScript
- Styling: CSS-in-JS (Tailwind support included)
- Blockchain Framework: Hardhat 3 (with Hardhat Ignition for deployments)
- Web3 Interface:
viem(Type-safe Ethereum interactions) - Smart Contracts: Solidity
^0.8.31 - Wallet Integration: MetaMask
Before running the application locally, ensure you have the following installed:
git clone https://github.com/iamkazbrekker/dphrs.git
cd dphrsNavigate to the blockchain directory to install dependencies and deploy the local network.
cd blockchain
npm installStart the local Hardhat node in a separate terminal:
npx hardhat nodeOpen a new terminal, navigate back to the blockchain directory, and deploy the smart contract:
npm run deploy (This deployment script will automatically compile the contract, deploy it via Hardhat Ignition, and export the generated ABI configuration directly to the frontend directory!)
- Open your MetaMask extension.
- Go to Settings > Networks > Add Network > Add a network manually.
- Enter the following details:
- Network Name: Hardhat Localhost
- New RPC URL:
http://127.0.0.1:8545/ - Chain ID:
31337 - Currency Symbol:
ETH
- Import one of the private test keys generated by your
npx hardhat nodeterminal into MetaMask so you have test ETH.
Navigate to the frontend directory:
cd ../frontend
npm install
npm run devOpen http://localhost:3000 in your browser. (Hint: You can use the "Dev: Change Active Account" button on the home screen to quickly request permission updates via MetaMask to switch between patient/hospital accounts!)
While the current version of DPHRS provides a robust proof-of-concept for decentralized healthcare, future iterations plan to implement:
- Providing data for researchers: Providing abstract data for research purposes.
- IPFS Integration: Currently, simple strings are stored on-chain. Future versions will use IPFS (InterPlanetary File System) to securely store heavy files like X-Rays, MRI scans, and full PDFs off-chain while anchoring only the content hashes on-chain.
- Granular Data Permissions: Allowing patients to selectively decrypt/approve access to specific files rather than granting blanket access to an institution.
- ZK-Rollups for Privacy: Integrating Zero-Knowledge Proofs to allow hospitals to verify certain patient conditions (e.g., "Is patient vaccinated?") without actually revealing the underlying private data.
- Multi-signature Security: For sensitive operations and account recovery mechanisms.
This project is licensed under the MIT License.