Python SDK for Privacy-Preserving Healthcare Agents API
Project description
Oneliac Python SDK
A Python client library for the Privacy-Preserving Healthcare Agents API. Enables secure medical data analysis with zero-knowledge proofs and federated learning.
🚀 Features
- 🔐 Zero-Knowledge Proofs: Patient privacy guaranteed mathematically
- 🏥 Eligibility Verification: Check insurance coverage without exposing data
- 💊 Prescription Validation: Verify drug safety with encrypted medical history
- 🤖 Federated Learning: Participate in collaborative AI training
- ⛓️ Blockchain Integration: Solana-based proof verification
- 🔒 HIPAA Compliant: Meets healthcare privacy standards
📦 Installation
pip install oneliac
🔧 Quick Start
Async Usage (Recommended)
import asyncio
from oneliac import HealthcareAgentsClient, PatientData, EligibilityRequest
async def main():
# Initialize client
async with HealthcareAgentsClient("https://healthcare-agents-api.onrender.com") as client:
# Check API health
health = await client.health_check()
print(f"API Status: {health['status']}")
# Create patient data
patient_data = PatientData.create(
patient_id="PATIENT_001",
raw_data={
"age": 45,
"insurance_id": "INS123456",
"medical_conditions": ["diabetes", "hypertension"]
}
)
# Check eligibility
eligibility_request = EligibilityRequest(
patient_data=patient_data,
procedure_code="PROC001"
)
result = await client.verify_eligibility(eligibility_request)
print(f"Eligible: {result['eligible']}")
print(f"Coverage: {result['coverage_percentage']}%")
# Run async function
asyncio.run(main())
Synchronous Usage
from oneliac import HealthcareAgentsClientSync, PatientData, EligibilityRequest
# Initialize sync client
client = HealthcareAgentsClientSync("https://healthcare-agents-api.onrender.com")
# Check API health
health = client.health_check()
print(f"API Status: {health['status']}")
# Create patient data
patient_data = PatientData.create(
patient_id="PATIENT_001",
raw_data={
"age": 45,
"insurance_id": "INS123456",
"medical_conditions": ["diabetes", "hypertension"]
}
)
# Check eligibility
eligibility_request = EligibilityRequest(
patient_data=patient_data,
procedure_code="PROC001"
)
result = client.verify_eligibility(eligibility_request)
print(f"Eligible: {result['eligible']}")
📚 API Reference
Client Initialization
# Async client
client = HealthcareAgentsClient(
base_url="https://healthcare-agents-api.onrender.com",
api_key="your-api-key", # Optional
timeout=30 # Request timeout in seconds
)
# Sync client
client = HealthcareAgentsClientSync(
base_url="https://healthcare-agents-api.onrender.com",
api_key="your-api-key", # Optional
timeout=30
)
Eligibility Verification
from healthcare_agents import EligibilityRequest, PatientData
# Create request
request = EligibilityRequest(
patient_data=patient_data,
procedure_code="PROC001" # Medical procedure code
)
# Verify eligibility
result = await client.verify_eligibility(request)
# Returns: {"eligible": bool, "coverage_percentage": float, "zk_proof_hash": str}
Prescription Validation
from healthcare_agents import PrescriptionRequest
# Create request
request = PrescriptionRequest(
patient_data=patient_data,
drug_code="DRUG001" # Drug identifier
)
# Validate prescription
result = await client.validate_prescription(request)
# Returns: {"safe": bool, "interactions": list, "confidence": float}
Federated Learning
from healthcare_agents import FederatedLearningRequest
# Create request with multiple patient datasets
request = FederatedLearningRequest(
patient_datasets=[patient_data1, patient_data2, patient_data3]
)
# Participate in training
result = await client.federated_learning_train(request)
# Returns: {"model_updated": bool, "training_round": int, "model_accuracy": float}
# Check FL status
status = await client.federated_learning_status()
# Returns: {"active_agents": int, "training_rounds": int, "model_accuracy": float}
🔐 Privacy & Security
Data Encryption
# Patient data is automatically encrypted
patient_data = PatientData.create(
patient_id="PATIENT_001",
raw_data={
"ssn": "123-45-6789", # Sensitive data
"medical_history": ["surgery_2020", "allergy_penicillin"]
}
)
# Raw data is encrypted before API calls
print(patient_data.encrypted_data) # Base64 encoded encrypted data
print(patient_data.data_hash) # SHA256 hash for verification
Zero-Knowledge Proofs
All eligibility and prescription validations use zero-knowledge proofs:
result = await client.verify_eligibility(request)
# ZK proof hash verifies the computation without revealing data
zk_proof = result['zk_proof_hash']
print(f"ZK Proof: {zk_proof}") # Cryptographic proof of eligibility
🏥 Healthcare Use Cases
Hospital Integration
class HospitalSystem:
def __init__(self):
self.client = HealthcareAgentsClientSync("https://your-api.onrender.com")
def check_patient_eligibility(self, patient_id: str, procedure: str):
"""Check if patient is eligible for procedure"""
patient_data = self.get_patient_data(patient_id)
request = EligibilityRequest(patient_data, procedure)
return self.client.verify_eligibility(request)
def validate_prescription(self, patient_id: str, drug_code: str):
"""Validate prescription safety"""
patient_data = self.get_patient_data(patient_id)
request = PrescriptionRequest(patient_data, drug_code)
return self.client.validate_prescription(request)
Pharmacy Integration
class PharmacySystem:
def __init__(self):
self.client = HealthcareAgentsClientSync("https://your-api.onrender.com")
def dispense_medication(self, patient_id: str, drug_code: str):
"""Check safety before dispensing"""
patient_data = self.get_patient_data(patient_id)
request = PrescriptionRequest(patient_data, drug_code)
result = self.client.validate_prescription(request)
if result['safe']:
return self.dispense_drug(drug_code)
else:
return {"error": "Prescription validation failed", "warnings": result['warnings']}
🔧 Error Handling
from healthcare_agents.exceptions import APIError, ValidationError
try:
result = await client.verify_eligibility(request)
except APIError as e:
print(f"API Error: {e}")
print(f"Status Code: {e.status_code}")
except ValidationError as e:
print(f"Validation Error: {e}")
except Exception as e:
print(f"Unexpected Error: {e}")
🧪 Testing
# Install development dependencies
pip install healthcare-agents[dev]
# Run tests
pytest
# Run with coverage
pytest --cov=healthcare_agents
📖 Documentation
- API Documentation: https://healthcare-agents-api.onrender.com/docs
- SDK Documentation: https://healthcare-agents-sdk.readthedocs.io/
- GitHub Repository: https://github.com/razaahmad9222/healthcare-agents-sdk-python
🤝 Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make changes and add tests
- Run tests:
pytest - Submit a pull request
📄 License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
🆘 Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: raza@healthcare-agents.com
Built with ❤️ for privacy-preserving healthcare
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file oneliac-0.1.0.tar.gz.
File metadata
- Download URL: oneliac-0.1.0.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7b99c90d31ec2b929ac8040b7f06489fb3a1634bffe075fd77893676ac8e2a6
|
|
| MD5 |
b2bc71b887a58d9de6704908aa39d58b
|
|
| BLAKE2b-256 |
81887f38c47e73bec6dec2eecc69148538131c76e577f99305fefc8bc137bf8b
|
File details
Details for the file oneliac-0.1.0-py3-none-any.whl.
File metadata
- Download URL: oneliac-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3be3122081b0aca6a34816fc84e7e60299b0cea82e07ce4537e9bf6a44cd91e
|
|
| MD5 |
f416bbcd3e0c7543d47505cbfa34a9d3
|
|
| BLAKE2b-256 |
9166afca31dee03c77bd18621f908e09612470d91620de931fbeabccaff4ef6b
|