- Description
- Features
- Architecture
- Prerequisites
- Installation
- Usage
- Testing
- Deployment
- Security Considerations
- Real-World Integration
- Compliance
Web3EMR is a decentralized Electronic Medical Record (EMR) with embedded AI/ML system built on a Substrate-based blockchain, transforming EMR into a Web3-native application. It empowers patients to control their medical records, ensures secure access for verified healthcare providers, and validates credentials (e.g., medical licenses, hospital accreditations) through real-world organizations using Polkadot's native Identity system and the People Chain for Decentralized Identifiers (DIDs).
Leveraging a custom Substrate chain (which can be deployed as either a public blockchain or a private/consortium blockchain) or a Substrate-based parachain in the Substrate ecosystem, Web3EMR uses CESS (Cumulus Encrypted Storage System) for decentralized off-chain storage. This flexible architecture allows for different deployment models to meet various regulatory and organizational requirements while maintaining Web3 principles of decentralization, transparency, and interoperability. The system is designed to comply with healthcare regulations (e.g., HIPAA, GDPR) in both public and private deployment scenarios.
- Patient-Centric Control: Patients manage EMR access using cryptographic wallets (e.g., Polkadot.js) and Polkadot Identity.
- Secure Data Storage: EMRs and credentials are encrypted and stored on CESS (Cumulus Encrypted Storage System), with content-addressable hashes recorded on-chain for integrity and verification.
- Identity Management: Leverages Polkadot's native Identity pallet and People Chain for secure, verifiable identities with hierarchical sub-identities.
- Credential Validation: Links medical licenses, nursing certifications, and hospital accreditations to Polkadot DIDs, validated by real-world organizations (e.g., medical boards, accreditation bodies).
- Access Control: Fine-grained permissions allow patients to grant/revoke provider access, with checks for valid credentials.
- Revocation Support: Handles credential revocation (e.g., expired or suspended licenses) with on-chain updates.
- Interoperability: Integrates with Polkadot's XCM for cross-chain data sharing, enabling multi-institutional ecosystems.
- Regulatory Compliance: Ensures HIPAA/GDPR compliance through AES-256 encryption, zero-knowledge proofs (ZKPs), and immutable audit trails.
- Immutable Audit Trail: Logs all EMR and attestation interactions on-chain for transparency and compliance.
- Data Analytics: Privacy-preserving analytics on medical data with patient consent, enabling population health insights while maintaining individual privacy.
- AI/ML Integration: Machine learning models for predictive diagnostics, treatment recommendations, and clinical decision support based on anonymized or consented patient data.
- Enterprise Integration: Connects with Enterprise Risk Management (ERM) systems and other enterprise platforms (e.g., SAP) through a secure API Gateway, enabling integration with supply chain, insurance, financial, and marketing systems.
graph TD
subgraph "Web3EMR Core System"
BL[Blockchain Layer] --- OS[Off-Chain Storage]
BL --- IS[Identity System]
BL --- AA[Analytics & AI Layer]
end
subgraph "Integration & Access"
FE[Frontend] --- BL
EI[Enterprise Integration Layer] --- BL
EI --- AA
end
subgraph "External Systems"
EI --- SC[Supply Chain Systems]
EI --- IN[Insurance Systems]
EI --- FM[Financial Management]
EI --- MK[Marketing/CRM]
end
RWI[Real-World Integration] --- IS
- Blockchain Layer: Custom Substrate pallets (
emr_pallet,attestation_pallet) for EMR management, access control, attestation, and credential validation, running on a Substrate-based blockchain. - Off-Chain Storage: Encrypted EMRs and credential documents (e.g., license PDFs) stored on StorageHub, with hashes on-chain.
- Identity System: Integrates with KILT Protocol for secure, verified DIDs, supporting credential attestation.
- Analytics & AI Layer: Privacy-preserving data analytics and machine learning models for medical insights, predictive diagnostics, and clinical decision support.
- Frontend: React-based UI with Polkadot.js for wallet integration and blockchain interaction.
- Enterprise Integration Layer: API Gateway and connector modules enabling secure integration with enterprise systems including ERM platforms, supply chain management, insurance systems, and financial management tools.
- Real-World Integration: Oracles (e.g., Chainlink on Polkadot) or a healthcare DAO validate credentials from trusted organizations (e.g., AMA, Joint Commission).
- Rust: Latest stable toolchain (
rustup update stable). - Polkadot SDK: For blockchain development.
- StorageHub: For off-chain storage.
- Node.js: For the React frontend (>=16.0.0).
- Polkadot.js: Browser extension for wallet management.
- KILT SDK: For DID management.
- Docker (optional): For running StorageHub or blockchain nodes.
- Chainlink (optional): For oracle-based credential validation.
git clone https://github.com/meddsai/Web3EMR.git
cd Web3EMR# Clone the Polkadot SDK
git clone https://github.com/paritytech/polkadot-sdk
cd polkadot-sdk
# Build the node template
cargo build --release -p node-template
./target/release/node-template --devAlternatively, connect to an existing Polkadot-based parachain in the Polkadot ecosystem (e.g., a testnet or mainnet).
Clone and run StorageHub:
git clone https://github.com/Moonsong-Labs/storage-hub
cd storage-hub
cargo build --release
./target/release/storage-hub-node --devFollow StorageHub's documentation for configuration and network connection.
Install the KILT SDK for DID management:
cd backend
npm install @kiltprotocol/sdk-jsInstall Rust dependencies and build the pallets:
cd backend
cargo build --releaseAdd emr_pallet.rs and attestation_pallet.rs to the Substrate node's pallets directory. Update the runtime configuration (runtime/src/lib.rs):
impl emr_pallet::Config for Runtime {
type Event = Event;
}
impl attestation_pallet::Config for Runtime {
type Event = Event;
type AttestationExpiry = AttestationExpiry;
type MaxAttestationsPerEntity = MaxAttestationsPerEntity;
}Install Node.js dependencies and start the React app:
cd frontend
npm install
npm startInstall the Polkadot.js browser extension and create/import accounts for testing.
Create KILT DIDs for testing entities, patients, and personnel using the KILT SDK. (see https://docs.kilt.io).
Start the Substrate node:
./target/release/node-template --devConnect to the node via WebSocket (e.g., ws://127.0.0.1:9944).
Healthcare entities (e.g., hospitals, clinics) register on-chain:
- Create a KILT DID for the entity
- Submit the entity's DID, name, and accreditation hash (e.g., Joint Commission certification) via
register_entity - Accreditation is validated off-chain by real-world organizations or oracles
Healthcare entities attest patients and personnel:
- Patients: Link patient KILT DID to entity DID using
attest_patient - Personnel: Submit personnel KILT DID, entity DID, credential hash (e.g., medical license), and expiry timestamp via
attest_personnel
Credentials are validated off-chain by real-world organizations (e.g., medical boards) and stored on StorageHub.
Patients upload EMRs:
- Log in with a Polkadot.js wallet and KILT DID
- Upload an EMR (JSON format), which is encrypted and stored on StorageHub
- Submit the EMR hash to the blockchain using
store_emr
Patients control provider access:
- Grant access with
grant_access, specifying the provider's KILT DID and EMR hash - The system verifies the provider's attestation status before allowing access
- Revoke access with
revoke_access
Providers retrieve EMRs from StorageHub using the on-chain hash, decrypting with authorized keys.
Authorities revoke credentials (e.g., expired licenses) using revoke_credential, updating on-chain status.
Check the blockchain's event log (via Polkadot.js Apps) for EMR and attestation events (e.g., EMRStored, PersonnelAttested, CredentialRevoked).
- A medical board creates a KILT DID for a hospital
- The board registers the hospital with an accreditation hash on-chain
- The hospital's identity is now verifiable on the blockchain
- The hospital attests a doctor's medical license
- This links the doctor's KILT DID to their credential hash and expiry date
- The credential can be verified by any authorized party
- The hospital attests a patient's registration
- This links the patient's KILT DID to the hospital
- The patient's identity is now verifiable within the system
- The patient uploads an EMR
- The EMR is encrypted and stored on StorageHub
- Only the hash of the EMR is recorded on-chain
- The patient grants access to the doctor
- The doctor retrieves the EMR after credential validation
- All actions are logged on-chain
- This ensures transparency and regulatory compliance
- Audit trails are immutable and verifiable
- EMR Pallet: Manages EMR storage and access control (
backend/pallets/emr_pallet.rs) - Attestation Pallet: Handles entity, patient, and personnel attestation with credential validation (
backend/pallets/attestation_pallet.rs) - StorageHub Integration: Encrypts and stores EMRs/credentials off-chain (
backend/storagehub.rs) - Analytics Engine: Privacy-preserving data analytics with differential privacy guarantees (
backend/analytics/) - AI/ML Models: Machine learning pipeline for medical data analysis and predictive healthcare (
backend/ml/) - Frontend: React app with Polkadot.js and KILT SDK for blockchain and DID interaction (
frontend/src) - Enterprise Integration Layer: API Gateway and connector modules enabling secure integration with enterprise systems including ERM platforms, supply chain management, insurance systems, and financial management tools (
backend/enterprise_integration/)
- Extend pallets for clinical trial data or insurance integration
- Implement ZKPs for private credential verification using KILT's capabilities
- Add multi-language support to the frontend
- Integrate a healthcare DAO for governance using Substrate's democracy pallet
- Develop specialized AI models for disease prediction and early diagnosis
- Implement federated learning for collaborative model training across healthcare entities
- Create privacy-preserving analytics dashboards for population health monitoring
- Build secure APIs for third-party research integration with anonymized data
- Run a local Substrate node with
--devflag - Use Polkadot.js Apps to interact with pallets
- Test StorageHub storage/retrieval with sample EMRs and credentials
- Test KILT DID creation and attestation using the KILT SDK
- Deploy to a Substrate-based testnet (e.g., a custom chain or Polkadot parachain)
- Connect to KILT's Peregrine testnet (https://docs.kilt.io)
- Simulate attestation workflows with multiple KILT DIDs
- Deploy to a custom Substrate-based mainnet or a Polkadot parachain slot
- Configure production-grade StorageHub nodes
- Host the frontend on a decentralized platform (e.g., Fleek)
- Use AES-256 encryption for EMRs and credentials
- Implement ZKPs for private transactions (supported by KILT)
- Maintain audit logs for HIPAA/GDPR compliance
- Partner with medical boards (e.g., AMA) or accreditation bodies (e.g., Joint Commission) for credential validation
- Use oracles (e.g., Chainlink) or a healthcare DAO for off-chain verification
- Encryption: AES-256 for off-chain data on CESS
- Key Management: Secure patient/provider keys via Polkadot.js wallets and KILT DIDs
- Credential Validation: Ensure real-world organizations attest credentials to prevent fraud
- Auditability: Immutable on-chain logs for all interactions
- Privacy: Use selective disclosure and verification levels for sensitive data (e.g., license details)
- Fork the repository
- Create a feature branch (
git checkout -b feature/xyz) - Commit changes (
git commit -m "Add XYZ feature") - Push to the branch (
git push origin feature/xyz) - Open a pull request
Please follow the Code of Conduct and report issues via GitHub.
This project is licensed under the MIT License - see the LICENSE file for details.
- Product Requirements Document (PRD)
- Substrate Developer Hub
- KILT Protocol
- StorageHub
- Polkadot.js
- Chainlink on Polkadot
For questions or support, open an issue or contact Kresna Sucandra at X @ks_sha888.
Empowering decentralized healthcare with trust and transparency.