Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions medical-records/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tests/** linguist-vendored
vitest.config.js linguist-vendored
* text=lf
13 changes: 13 additions & 0 deletions medical-records/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

**/settings/Mainnet.toml
**/settings/Testnet.toml
.cache/**
history.txt

logs
*.log
npm-debug.log*
coverage
*.info
costs-reports.json
node_modules
4 changes: 4 additions & 0 deletions medical-records/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

{
"files.eol": "\n"
}
19 changes: 19 additions & 0 deletions medical-records/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

{
"version": "2.0.0",
"tasks": [
{
"label": "check contracts",
"group": "test",
"type": "shell",
"command": "clarinet check"
},
{
"type": "npm",
"script": "test",
"group": "test",
"problemMatcher": [],
"label": "npm test"
}
]
}
19 changes: 19 additions & 0 deletions medical-records/Clarinet.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[project]
name = 'medical-records'
description = ''
authors = []
telemetry = true
cache_dir = '.\.cache'
requirements = []
[contracts.health-records]
path = 'contracts/health-records.clar'
clarity_version = 2
epoch = 2.5
[repl.analysis]
passes = ['check_checker']

[repl.analysis.check_checker]
strict = false
trusted_sender = false
trusted_caller = false
callee_filter = false
138 changes: 138 additions & 0 deletions medical-records/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Personalized Medicine Smart Contract

## Overview
The Personalized Medicine Smart Contract is a blockchain-based solution built on Clarity for managing medical records, prescriptions, and healthcare provider authorizations. This system enables secure, transparent, and efficient management of personalized medical data while maintaining patient privacy and regulatory compliance.

## Features
- **Patient Record Management**
- Comprehensive medical history storage
- Genetic profile data management
- Current prescription tracking
- Healthcare provider authorization control

- **Healthcare Provider Management**
- Provider registration and verification
- Specialization and licensing documentation
- Active status tracking
- Authorization-based access control

- **Prescription System**
- Secure prescription creation and management
- Dosage and medication tracking
- Time-bound prescription validity
- Active/inactive status management

## Technical Architecture

### Data Structures

#### 1. Patient Medical Records
```clarity
{
comprehensive-medical-history: (string-ascii 256),
genetic-profile-data: (string-ascii 256),
current-prescriptions: (list 10 uint),
approved-healthcare-providers: (list 5 principal)
}
```

#### 2. Healthcare Provider Registry
```clarity
{
medical-specialization: (string-ascii 64),
medical-license-identifier: (string-ascii 32),
provider-active-status: bool
}
```

#### 3. Prescription Records
```clarity
{
patient-wallet-address: principal,
prescribing-provider: principal,
prescribed-medication: (string-ascii 64),
medication-dosage-instructions: (string-ascii 32),
prescription-start-timestamp: uint,
prescription-end-timestamp: uint,
prescription-active-status: bool
}
```

## Functions

### Patient Management

#### `register-new-patient`
- **Description**: Registers a new patient in the system
- **Parameters**:
- comprehensive-medical-history: (string-ascii 256)
- genetic-profile-data: (string-ascii 256)
- **Returns**: Success/Error response
- **Access**: Public

#### `authorize-healthcare-provider`
- **Description**: Authorizes a healthcare provider to access patient records
- **Parameters**:
- provider-wallet-address: principal
- **Returns**: Success/Error response
- **Access**: Public (patient only)

### Healthcare Provider Management

#### `register-healthcare-provider`
- **Description**: Registers a new healthcare provider
- **Parameters**:
- medical-specialization: (string-ascii 64)
- medical-license-identifier: (string-ascii 32)
- **Returns**: Success/Error response
- **Access**: Public

#### `verify-provider-credentials`
- **Description**: Verifies the active status of a healthcare provider
- **Parameters**:
- provider-wallet-address: principal
- **Returns**: Boolean
- **Access**: Read-only

### Prescription Management

#### `create-new-prescription`
- **Description**: Creates a new prescription for a patient
- **Parameters**:
- patient-wallet-address: principal
- prescribed-medication: (string-ascii 64)
- medication-dosage-instructions: (string-ascii 32)
- prescription-start-timestamp: uint
- prescription-end-timestamp: uint
- **Returns**: Success/Error response
- **Access**: Public (authorized providers only)

## Error Codes
- `ERR-UNAUTHORIZED-ACCESS (u1)`: Unauthorized access attempt
- `ERR-DUPLICATE-PATIENT-RECORD (u2)`: Patient already registered
- `ERR-PATIENT-RECORD-NOT-FOUND (u3)`: Patient record doesn't exist
- `ERR-INVALID-PRESCRIPTION-DATA (u4)`: Invalid prescription parameters
- `ERR-DUPLICATE-HEALTHCARE-PROVIDER (u5)`: Provider already registered
- `ERR-HEALTHCARE-PROVIDER-NOT-FOUND (u6)`: Provider not found in registry

## Security Considerations
1. **Access Control**
- Only authorized healthcare providers can access patient records
- Patients control provider authorization
- Prescription management restricted to authorized providers

2. **Data Privacy**
- Sensitive data stored with appropriate access controls
- Limited list sizes to prevent overflow attacks
- Status tracking for all entities

3. **Input Validation**
- Comprehensive error checking
- Date validation for prescriptions
- Authorization verification

## Contributing
1. Fork the repository
2. Create feature branch
3. Commit changes
4. Create pull request
7 changes: 7 additions & 0 deletions medical-records/Testnet.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[network]
name = "testnet"
stacks_node_rpc_address = "https://api.testnet.hiro.so"
deployment_fee_rate = 10

[accounts.deployer]
mnemonic = "<YOUR PRIVATE TESTNET MNEMONIC HERE>"
Loading