Skip to main content

HACS Persistence

PostgreSQL + pgvector persistence for healthcare data storage

Database and vector storage adapters optimized for healthcare AI applications.

🗄️ Database Support

PostgreSQL with pgvector

Primary storage solution for healthcare data:

  • Relational Data - Patient records, observations, clinical data
  • Vector Storage - Clinical embeddings via pgvector extension
  • Schema Management - Automated migrations and versioning
  • Healthcare Compliance - HIPAA-aware design patterns

🏥 Healthcare Schema

Optimized database tables for clinical workflows:

-- Core healthcare tables
patients              -- Patient demographics and clinical context
observations         -- Clinical measurements and findings
actors              -- Healthcare providers with role-based permissions
memory_blocks       -- AI agent episodic/procedural memory
evidence_items     -- Clinical guidelines and research
knowledge_base     -- Structured clinical knowledge

-- Vector storage for AI operations
patient_vectors     -- Patient data embeddings
clinical_vectors    -- Clinical note embeddings
memory_vectors      -- Memory content embeddings

📦 Installation

pip install hacs-persistence

🚀 Quick Start

Setup via HACS

# Automatic setup with migrations
python setup.py --mode local

# Database runs on localhost:5432
# Automatic pgvector extension installation

Direct Usage

from hacs_persistence import Adapter
from hacs_core import Patient

# Connect to healthcare database
adapter = Adapter(
    database_url="postgresql://hacs:password@localhost:5432/hacs"
)

# Store patient record
patient = Patient(
    full_name="Maria Rodriguez",
    birth_date="1985-03-15",
    gender="female"
)

# Save with automatic validation
saved_patient = adapter.save_resource(patient)
print(f"Saved patient: {saved_patient.id}")

🔧 Configuration

Environment Variables

# Primary database connection
DATABASE_URL=postgresql://hacs:password@localhost:5432/hacs

# Vector store configuration (uses pgvector by default)
VECTOR_STORE=pgvector

# Optional: External PostgreSQL for production
DATABASE_URL=postgresql://hacs:secure_password@prod-db:5432/hacs_production

Migration Management

# Run database migrations
python -m hacs_persistence.migrations $DATABASE_URL

# Check migration status
python -c "from hacs_persistence import get_migration_status; print(get_migration_status())"

📊 Performance

  • Resource Operations: <50ms for standard CRUD
  • Vector Queries: <100ms for similarity search
  • Batch Operations: 1000+ records per second
  • Memory Footprint: Minimal overhead

🔐 Security Features

  • Connection Encryption - SSL/TLS support
  • Role-based Access - Healthcare provider permissions
  • Audit Trails - Complete operation logging
  • Data Isolation - Organization-specific schemas

🛠️ Advanced Usage

Vector Operations

# Store clinical embedding
adapter.store_vector(
    resource_id="patient_123",
    embedding=[0.1, 0.2, ...],  # Clinical text embedding
    metadata={"type": "patient", "department": "cardiology"}
)

# Similarity search
similar_patients = adapter.vector_search(
    query_embedding=[0.1, 0.2, ...],
    resource_type="patient",
    top_k=5
)

Batch Operations

# Bulk insert for large datasets
patients = [Patient(...) for _ in range(1000)]
results = adapter.bulk_save(patients)

📄 License

Apache-2.0 License - see LICENSE for details.

Metadata

Release files for hacs-persistence 0.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hacs-persistence 0.4.3
File Size Uploaded Provenance
hacs_persistence-0.4.3.tar.gz 30.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for hacs-persistence 0.4.3
File Interpreter ABI Platform
hacs_persistence-0.4.3-py3-none-any.whl Python 3 none any Details

Total release size: 66.7 kB

Release files / hacs_persistence-0.4.3.tar.gz

Download URL hacs_persistence-0.4.3.tar.gz
Size 30.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ff31cee332a1a85662728de73fbbcffd8967038fb58a1fa49f69b274e8b199f8
BLAKE2b-256 checksum
How to use checksums
f60c68f4d0c37475b595253ebcf2fa72186ae19cfc682705f5ae9cfffd000c81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.6

Release files / hacs_persistence-0.4.3-py3-none-any.whl

Download URL hacs_persistence-0.4.3-py3-none-any.whl
Size 35.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
616f05db6c3fdf4c3c1d23f09a4835ce7fde4ec80fc2c2637af4bbc904fc4671
BLAKE2b-256 checksum
How to use checksums
13f9f4e51a7c6c7b55da6a1c4fa9fee55eb096300a6448e13b97be0e475de6d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.6

Security for hacs-persistence 0.4.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page