Skip to content

Add Patient, Appointment, Medical Record, and Access Control Modules to Smart Contract #78

@shamil-t

Description

@shamil-t

Add Appointment, Medical Record, and Access Control Modules to Smart Contract

Summary

Enhance the EHR smart contract to support:

  • Appointment management
  • Medical record management
  • Doctor-patient access control
  • Improved user management
  • Event-driven architecture for frontend integration

Features to Implement

1. User Management

Add support for:

  • Admin
  • Doctor
  • Patient

Smart Contract Changes

  • Add UserType enum
  • Store user profile IPFS CID
  • Prevent duplicate registrations
  • Add getters for doctors/patients

2. Appointment Module

Add Appointment Struct

Fields:

  • appointmentId
  • patient wallet
  • doctor wallet
  • metadata CID (IPFS)
  • appointment time
  • status
  • created timestamp

Add Appointment Status Enum

Statuses:

  • PENDING
  • APPROVED
  • REJECTED
  • COMPLETED
  • CANCELLED

Functions

  • bookAppointment
  • updateAppointmentStatus
  • getAppointmentsByUser
  • getAllAppointments

Storage Design

  • Main appointment mapping by ID
  • Doctor appointment indexes
  • Patient appointment indexes

3. Medical Records Module

Add MedicalRecord Struct

Fields:

  • recordId
  • patient wallet
  • doctor wallet
  • metadata CID
  • file hash
  • created timestamp

Functions

  • uploadMedicalRecord
  • getMedicalRecordsByUser
  • getAllMedicalRecords

Storage Design

  • Main medical record mapping by ID
  • Patient record indexes
  • Doctor record indexes

4. Doctor Access Control

Features

Patients can:

  • grant doctor access
  • revoke doctor access

Doctors can:

  • access patient records only when authorized

Storage

  • mapping(patient => doctor => bool)

Functions

  • grantDoctorAccess
  • revokeDoctorAccess
  • hasAccess

IPFS Architecture

Blockchain Stores

  • wallet addresses
  • user role
  • appointment references
  • medical record references
  • IPFS CIDs
  • permissions

IPFS Stores

  • patient profile JSON
  • doctor profile JSON
  • appointment metadata JSON
  • medical record metadata
  • medical files/PDFs

Frontend Integration

Stack

  • Angular
  • ethers.js
  • MetaMask
  • Local Anvil node
  • Local IPFS node

Future Improvements

  • encrypted IPFS payloads
  • pagination
  • hospital module
  • audit logging
  • prescription module
  • role-based permissions
  • The Graph indexing
  • multisig admin
  • signature verification

Acceptance Criteria

  • Admin can add doctors/patients
  • Patients can book appointments
  • Doctors can update appointment status
  • Authorized doctors can upload records
  • Patients can revoke access
  • All entities retrievable by role
  • IPFS CIDs stored properly

Metadata

Metadata

Assignees

Projects

Status
In Progress

Relationships

None yet

Development

No branches or pull requests

Issue actions