Skip to main content
โšก Calmops

Healthcare Blockchain: Medical Records, Drug Traceability

Introduction

Blockchain offers healthcare solutions for interoperability, patient consent, and drug traceability. While not a universal solution, it excels in specific healthcare use cases.

Key Statistics:

  • Blockchain in healthcare market: $1.7B by 2025
  • 55% of pharma companies use blockchain for traceability
  • Patient data breaches cost 65% more than other breaches
  • Blockchain can reduce drug counterfeiting by 90%

Healthcare Blockchain Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Healthcare Blockchain                              โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                  โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚  โ”‚              Permissioned Network                          โ”‚   โ”‚
โ”‚  โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚   โ”‚
โ”‚  โ”‚  โ”‚ Hospital โ”‚  โ”‚  Labs   โ”‚  โ”‚ Pharmacyโ”‚  โ”‚  payer  โ”‚  โ”‚   โ”‚
โ”‚  โ”‚  โ”‚  Node    โ”‚  โ”‚  Node   โ”‚  โ”‚  Node   โ”‚  โ”‚  Node   โ”‚  โ”‚   โ”‚
โ”‚  โ”‚  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜  โ”‚   โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”‚          โ”‚             โ”‚             โ”‚             โ”‚             โ”‚
โ”‚          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜          โ”‚
โ”‚                              โ”‚                                   โ”‚
โ”‚                              โ–ผ                                   โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚  โ”‚              Smart Contracts                              โ”‚   โ”‚
โ”‚  โ”‚  โ”œโ”€โ”€ Patient Consent Management                         โ”‚   โ”‚
โ”‚  โ”‚  โ”œโ”€โ”€ Medical Record Access                              โ”‚   โ”‚
โ”‚  โ”‚  โ”œโ”€โ”€ Drug Supply Chain                                 โ”‚   โ”‚
โ”‚  โ”‚  โ””โ”€โ”€ Insurance Claims                                   โ”‚   โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”‚                                                                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Smart Contract

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract PatientConsent {
    
    struct Consent {
        bytes32 patientId;
        address grantedBy;
        address grantedTo;
        string purpose;
        uint256 grantedAt;
        uint256 expiresAt;
        bool revoked;
    }
    
    mapping(bytes32 => Consent[]) public patientConsents;
    
    event ConsentGranted(bytes32 indexed patientId, address indexed provider, string purpose);
    event ConsentRevoked(bytes32 indexed patientId, address indexed provider);
    
    function grantConsent(
        bytes32 _patientId,
        address _provider,
        string memory _purpose,
        uint256 _duration
    ) public {
        Consent memory consent = Consent({
            patientId: _patientId,
            grantedBy: msg.sender,
            grantedTo: _provider,
            purpose: _purpose,
            grantedAt: block.timestamp,
            expiresAt: block.timestamp + _duration,
            revoked: false
        });
        
        patientConsents[_patientId].push(consent);
        
        emit ConsentGranted(_patientId, _provider, _purpose);
    }
    
    function checkConsent(bytes32 _patientId, address _provider) public view returns (bool) {
        Consent[] storage consents = patientConsents[_patientId];
        
        for (uint i = 0; i < consents.length; i++) {
            Consent storage consent = consents[i];
            
            if (consent.grantedTo == _provider && 
                !consent.revoked && 
                consent.expiresAt > block.timestamp) {
                return true;
            }
        }
        
        return false;
    }
    
    function revokeConsent(bytes32 _patientId, address _provider) public {
        Consent[] storage consents = patientConsents[_patientId];
        
        for (uint i = 0; i < consents.length; i++) {
            if (consents[i].grantedTo == _provider) {
                consents[i].revoked = true;
                emit ConsentRevoked(_patientId, _provider);
            }
        }
    }
}

Medical Records

FHIR + Blockchain

#!/usr/bin/env python3
"""Medical records on blockchain."""

import hashlib
import json
from datetime import datetime

class MedicalRecordBlockchain:
    """Medical record management with blockchain."""
    
    def __init__(self, web3_provider):
        self.web3 = web3_provider
        self.record_contract = None
    
    def create_record_hash(self, patient_id, data):
        """Create hash of medical record."""
        
        record_data = {
            'patient_id': patient_id,
            'data': data,
            'timestamp': datetime.utcnow().isoformat()
        }
        
        record_json = json.dumps(record_data, sort_keys=True)
        record_hash = hashlib.sha256(record_json.encode()).hexdigest()
        
        return record_hash, record_data
    
    def store_record_pointer(self, patient_id, record_hash, ipfs_cid):
        """Store pointer to IPFS on blockchain."""
        
        tx = self.record_contract.functions.storeRecord(
            patient_id,
            record_hash,
            ipfs_cid,
            datetime.utcnow().timestamp()
        ).transact()
        
        return tx
    
    def verify_record_integrity(self, patient_id, data):
        """Verify record hasn't been tampered."""
        
        record_hash, _ = self.create_record_hash(patient_id, data)
        
        # Get stored hash from blockchain
        stored_hash = self.record_contract.functions.getRecordHash(patient_id).call()
        
        return record_hash == stored_hash
    
    def grant_record_access(self, patient_id, provider_address, expiration):
        """Grant provider access to patient records."""
        
        tx = self.record_contract.functions.grantAccess(
            patient_id,
            provider_address,
            expiration
        ).transact()
        
        return tx

Drug Traceability

Supply Chain Tracking

#!/usr/bin/env python3
"""Drug supply chain on blockchain."""

class DrugTraceability:
    """Track pharmaceutical supply chain."""
    
    def __init__(self, web3, contract_address):
        self.web3 = web3
        self.contract_address = contract_address
    
    def manufacture_drug(self, drug_id, manufacturer, details):
        """Record drug manufacture."""
        
        tx = self.contract.functions.manufacture(
            drug_id,
            manufacturer,
            json.dumps(details)
        ).transact()
        
        return tx
    
    def ship_to_distributor(self, drug_id, from_address, to_address, details):
        """Record shipment to distributor."""
        
        tx = self.contract.functions.ship(
            drug_id,
            from_address,
            to_address,
            json.dumps(details)
        ).transact()
        
        return tx
    
    def dispense_to_patient(self, drug_id, pharmacy, patient_id, prescription_id):
        """Record dispensing to patient."""
        
        tx = self.contract.functions.dispense(
            drug_id,
            pharmacy,
            patient_id,
            prescription_id
        ).transact()
        
        return tx
    
    def get_drug_history(self, drug_id):
        """Get complete drug history."""
        
        events = self.contract.getPastEvents(
            'DrugEvent',
            filter={'drugId': drug_id},
            fromBlock=0,
            toBlock='latest'
        )
        
        history = []
        for event in events:
            history.append({
                'event_type': event.args.eventType,
                'from': event.args.fromAddress,
                'to': event.args.toAddress,
                'timestamp': event.args.timestamp,
                'details': json.loads(event.args.details)
            })
        
        return history
    
    def verify_drug_authenticity(self, drug_id):
        """Verify drug is authentic."""
        
        # Check manufacturer exists
        manufacturer = self.contract.functions.getDrugManufacturer(drug_id).call()
        if manufacturer == "0x0000000000000000000000000000000000000000":
            return False, "Drug not found in system"
        
        # Verify all supply chain events
        history = self.get_drug_history(drug_id)
        
        expected_events = ['manufactured', 'shipped', 'received', 'dispensed']
        event_types = [h['event_type'] for h in history]
        
        for event_type in expected_events:
            if event_type not in event_types:
                return False, f"Missing event: {event_type}"
        
        return True, "Drug is authentic"

Interoperability

Cross-Network Records

# Healthcare interoperability with blockchain
interoperability:
  standards:
    - FHIR R4
    - HL7 v2
    - DICOM
  
  blockchain_networks:
    - network: "Hospital Consortium"
      type: "Private (Hyperledger Fabric)"
      participants:
        - "Hospital A"
        - "Hospital B"
        - "Lab Network"
    
    - network: "Pharma Supply Chain"
      type: "Permissioned (Ethereum)"
      participants:
        - "Manufacturer"
        - "Distributors"
        - "Pharmacies"
  
  cross_chain:
    enabled: true
    protocol: "Hash Time Locked Contracts"
    bridge_contracts:
      - "Ethereum Mainnet"
      - "Hyperledger Besu"

Use Cases

Use Case Blockchain Benefit Implementation
Patient Consent Immutable audit trail, patient control Smart contracts
Medical Records Interoperability, integrity IPFS + blockchain pointers
Drug Traceability Supply chain transparency Track & trace smart contracts
Insurance Claims Automated processing, fraud reduction Claims processing smart contracts
Clinical Trials Data integrity, audit Immutable trial records
Organ Transplants Chain of custody Provenance tracking

External Resources


Comments