Skip to content

VantaScript/clinivox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Clinic AI Assistant Platform

A production-ready AI-powered telephony platform for healthcare clinics that automates patient communication through intelligent voice conversations. Built with FastAPI, ElevenLabs Conversational AI, and Twilio, this platform handles appointment scheduling, patient inquiries, and administrative tasks while maintaining HIPAA-compliant standards.

πŸš€ Features

Core Functionality

  • AI-Powered Voice Conversations: Natural language processing for handling inbound and outbound calls
  • Appointment Management: Schedule, reschedule, cancel, and confirm appointments with real-time availability
  • Multi-Clinic Support: Isolated tenant architecture supporting multiple clinics with custom configurations
  • Knowledge Base Integration: Clinic-specific Q&A knowledge base with automatic context injection
  • Call Analytics: Comprehensive call metrics, sentiment analysis, and performance tracking

Integrations

  • EHR Systems: AthenaHealth and Epic FHIR integration for patient data and appointment sync
  • Calendly: Bidirectional calendar synchronization
  • Telephony: Twilio integration for phone number management and call routing
  • Conversational AI: ElevenLabs agents with customizable voice and personality

Advanced Features

  • Outbound Call Automation: Appointment reminders, confirmations, and follow-ups
  • Patient Record Management: Secure patient data handling with verification protocols
  • Staff Management: Role-based access control (Admin, Doctor, Receptionist, Nurse, Manager)
  • Insurance Verification: Real-time eligibility checks and coverage validation
  • Call Transcripts: Automatic conversation transcription and summarization

πŸ“‹ Prerequisites

  • Python 3.10 or higher
  • PostgreSQL 14 or higher
  • Twilio account with API credentials
  • ElevenLabs account with API key
  • (Optional) AthenaHealth API credentials
  • (Optional) Epic FHIR API credentials

πŸ› οΈ Installation

1. Clone the Repository

git clone <repository-url>
cd clini

2. Create Virtual Environment

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

4. Environment Configuration

Create a .env file in the root directory:

# Database
DATABASE_URL=postgresql://user:password@localhost:5432/clinic_ai

# Twilio Configuration
TWILIO_ACCOUNT_SID=your_twilio_account_sid
TWILIO_AUTH_TOKEN=your_twilio_auth_token
WEBHOOK_BASE_URL=https://your-domain.com

# ElevenLabs Configuration
ELEVENLABS_API_KEY=your_elevenlabs_api_key

# EHR Integrations (Optional)
ATHENA_CLIENT_ID=your_athena_client_id
ATHENA_CLIENT_SECRET=your_athena_client_secret
ATHENA_API_BASE_URL=https://api.athenahealth.com
ATHENA_PRACTICE_ID=your_practice_id

EPIC_CLIENT_ID=your_epic_client_id
EPIC_CLIENT_SECRET=your_epic_client_secret
EPIC_FHIR_BASE_URL=https://fhir.epic.com/interconnect-fhir-oauth
EPIC_REDIRECT_URI=http://localhost:8000/callback

# Application Settings
SECRET_KEY=your_secret_key_here
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30

5. Database Setup

# Run Alembic migrations
alembic upgrade head

# Or create tables directly (development only)
python -c "from database import create_tables; create_tables()"

6. Run the Application

# Development mode with auto-reload
uvicorn main:app --reload --host 0.0.0.0 --port 8000

# Or using the main entrypoint
python main.py

The API will be available at http://localhost:8000
Interactive API documentation: http://localhost:8000/docs
Alternative docs: http://localhost:8000/redoc

πŸ“ Project Structure

clini/
β”œβ”€β”€ alembic/                 # Database migrations
β”œβ”€β”€ config/                  # Configuration files
β”œβ”€β”€ integration/             # External service integrations
β”‚   β”œβ”€β”€ athena_health_client.py
β”‚   β”œβ”€β”€ epic_fhir_client.py
β”‚   └── webhook_tools.py
β”œβ”€β”€ routes/                  # API route handlers
β”‚   β”œβ”€β”€ admin_routes.py
β”‚   β”œβ”€β”€ agent_setup_routes.py
β”‚   β”œβ”€β”€ auth.py
β”‚   β”œβ”€β”€ conversation_routes.py
β”‚   └── ...
β”œβ”€β”€ services/                # Business logic services
β”‚   β”œβ”€β”€ agent_setup_service.py
β”‚   β”œβ”€β”€ conversation_service.py
β”‚   β”œβ”€β”€ twilio_service.py
β”‚   └── ...
β”œβ”€β”€ system_prompts/          # AI system prompts
β”œβ”€β”€ database.py              # Database configuration
β”œβ”€β”€ models.py                # SQLAlchemy models
β”œβ”€β”€ schemas.py               # Pydantic schemas
β”œβ”€β”€ main.py                  # FastAPI application entry point
└── requirements.txt         # Python dependencies

πŸ”§ Technology Stack

  • Framework: FastAPI 0.115+
  • Database: PostgreSQL with SQLAlchemy ORM
  • Migrations: Alembic
  • Authentication: JWT (JSON Web Tokens)
  • Telephony: Twilio
  • Conversational AI: ElevenLabs
  • EHR Integration: AthenaHealth API, Epic FHIR R4
  • Validation: Pydantic
  • Async HTTP: httpx

πŸ“– API Documentation

Main Endpoints

  • POST /clinic/register - Register a new clinic
  • POST /clinic/login - Clinic authentication
  • POST /api/setup/agent - Create and configure AI agent
  • POST /api/setup/phone-number - Purchase Twilio phone number
  • GET /api/conversations - Retrieve conversation history
  • GET /api/conversations/{conversation_id} - Get conversation details
  • GET /admin/* - Administrative endpoints

Full interactive API documentation is available at /docs when the server is running.

πŸ” Authentication

The API uses JWT-based authentication. Include the token in the Authorization header:

Authorization: Bearer <your_jwt_token>

πŸ—„οΈ Database Models

Core Entities

  • Clinic: Clinic information and AI configuration
  • Patient: Patient records and insurance information
  • Staff: Clinic staff with role-based permissions
  • Appointment: Appointment scheduling and management
  • Call: Call records with transcripts and analytics
  • KnowledgeBase: Clinic-specific Q&A knowledge
  • InsurancePlan: Accepted insurance plans and coverage

See models.py for complete schema definitions.

πŸ”„ Workflow Example

Clinic Onboarding Flow

  1. Register Clinic: POST /clinic/register
  2. Create AI Agent: POST /api/setup/agent
  3. Purchase Phone Number: POST /api/setup/phone-number
  4. Upload Knowledge Base: POST /api/setup/knowledge-base
  5. Configure Agent Settings: Update clinic configuration

Call Handling Flow

  1. Inbound call received via Twilio
  2. Twilio forwards to ElevenLabs webhook
  3. ElevenLabs agent processes conversation
  4. Our platform receives webhook events
  5. Conversation state synced to database
  6. Transcripts and analytics generated

πŸ§ͺ Testing

# Test database connection
python test_db_connection.py

# Test ElevenLabs API connectivity
python test_elevenlabs_api.py

# Test environment configuration
python test_env_config.py

🚒 Deployment

Production Considerations

  • Use managed PostgreSQL (AWS RDS, Google Cloud SQL)
  • Set up reverse proxy (Nginx) for SSL termination
  • Configure environment variables securely
  • Enable database connection pooling
  • Set up automated backups
  • Use process manager (systemd, supervisord)
  • Configure CORS for production domains
  • Set up monitoring and logging

Recommended Setup

# Using Gunicorn with Uvicorn workers
gunicorn main:app -w 4 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000

πŸ“ Environment Variables Reference

Variable Description Required
DATABASE_URL PostgreSQL connection string Yes
TWILIO_ACCOUNT_SID Twilio account identifier Yes
TWILIO_AUTH_TOKEN Twilio authentication token Yes
ELEVENLABS_API_KEY ElevenLabs API key Yes
WEBHOOK_BASE_URL Base URL for webhook callbacks Yes
SECRET_KEY JWT secret key Yes
ATHENA_CLIENT_ID AthenaHealth client ID No
EPIC_CLIENT_ID Epic FHIR client ID No

🀝 Contributing

  1. Follow existing code style and patterns
  2. Add type hints to new functions
  3. Write docstrings for public methods
  4. Use Alembic for database schema changes
  5. Test your changes before submitting

πŸ“„ License

Proprietary - Internal use only

πŸ†˜ Support

For issues, questions, or contributions, please contact the development team.

πŸ”— Related Resources


Version: 1.0.0
Last Updated: 2025

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages