Skip to main content

Python SDK for Privacy-Preserving Healthcare Agents API

Project description

Oneliac Python SDK

PyPI version Python Support License

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

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make changes and add tests
  4. Run tests: pytest
  5. Submit a pull request

📄 License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

🆘 Support


Built with ❤️ for privacy-preserving healthcare

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oneliac-0.1.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oneliac-0.1.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

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

Hashes for oneliac-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b7b99c90d31ec2b929ac8040b7f06489fb3a1634bffe075fd77893676ac8e2a6
MD5 b2bc71b887a58d9de6704908aa39d58b
BLAKE2b-256 81887f38c47e73bec6dec2eecc69148538131c76e577f99305fefc8bc137bf8b

See more details on using hashes here.

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

Hashes for oneliac-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b3be3122081b0aca6a34816fc84e7e60299b0cea82e07ce4537e9bf6a44cd91e
MD5 f416bbcd3e0c7543d47505cbfa34a9d3
BLAKE2b-256 9166afca31dee03c77bd18621f908e09612470d91620de931fbeabccaff4ef6b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page