Skip to content

nihalmaddala/Relay_Heidi_Hackathon

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

HEIDI 2025 - AI-Powered Medical Referral Automation

Streamlining healthcare workflows with intelligent automation

HEIDI 2025 is an AI-powered automation layer built on top of Heidi Health (an AI medical scribe) and OpenEMR. It transforms medical consultation transcripts into complete, actionable specialist referrals in seconds, reducing physician administrative burden by 96% (from 25 minutes to 60 seconds per referral).

🎯 Problem Statement

Primary care physicians spend 25+ minutes manually processing each specialist referral:

  • Reviewing patient history and consultation notes
  • Determining appropriate specialty and specialist
  • Writing clinical justification
  • Checking insurance requirements and prior authorizations
  • Generating referral documentation
  • Coordinating specialist communication

This administrative burden leads to physician burnout, delayed patient care, and reduced time for actual medical practice.

πŸ’‘ Solution

HEIDI 2025 automates the entire referral workflow using Claude AI (Anthropic) to:

  1. Analyze medical consultation transcripts from Heidi sessions
  2. Generate clinical reasoning and specialty recommendations
  3. Match patients with appropriate in-network specialists
  4. Check prior authorization requirements automatically
  5. Create professional referral PDFs with medical codes
  6. Send referrals to specialists via automated email workflow

Result: Complete referral process in 60 seconds with human-in-the-loop approval.

✨ Key Features

πŸ€– AI-Powered Clinical Reasoning

  • Claude AI (Haiku) analyzes patient history, symptoms, and consultation transcripts
  • Generates clinical justification, risk assessment, and urgency levels
  • No templates - real AI reasoning for each case

🎯 Intelligent Specialty Detection

  • Automatic specialty detection from 15+ medical specialties
  • Keyword-based scoring system (cardiology, neurology, gastroenterology, etc.)
  • Context-aware specialty matching

πŸ’³ Insurance & Prior Authorization

  • Automatic insurance network verification (in-network vs. out-of-network)
  • 3-stage prior authorization decision tree
  • Copay calculation and coverage details

πŸ₯ Specialist Matching

  • Automated matching with top-rated specialists
  • Geographic proximity consideration
  • Insurance compatibility checks

πŸ“„ Professional PDF Generation

  • Medical letterhead with facility branding
  • Complete patient demographics and insurance details
  • AI-generated clinical notes and assessment
  • CPT and ICD-10 medical codes
  • Specialist contact information

πŸ“§ Automated Email Delivery

  • Integration with n8n workflow automation
  • PDF attachments sent to specialist offices
  • Email confirmation to referring physician

πŸ‘¨β€βš•οΈ Human-in-the-Loop Approval

  • Two-stage workflow: Analyze β†’ Review β†’ Approve β†’ Send
  • Physicians review AI recommendations before sending
  • Maintain clinical oversight and compliance

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   OpenEMR EHR   β”‚ ← Patient records & Heidi sessions
β”‚  (PHP/MySQL)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         ↓ AJAX/JSON
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Flask Backend  β”‚ ← AI processing & orchestration
β”‚    (Python)     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β”œβ”€β”€β†’ Claude AI (Anthropic) ← Clinical reasoning
         β”œβ”€β”€β†’ MySQL Database ← Patient data
         β”œβ”€β”€β†’ FPDF ← PDF generation
         └──→ n8n Webhook ← Email automation

Tech Stack

Frontend:

  • OpenEMR (PHP-based EHR system)
  • JavaScript/AJAX for API communication
  • Bootstrap CSS for UI styling

Backend:

  • Flask (Python REST API)
  • Claude AI API (Anthropic)
  • MySQL database
  • FPDF library for PDF generation

External Services:

  • n8n workflow automation (email delivery)
  • Cloud-based webhook infrastructure

πŸš€ Getting Started

Prerequisites

  • PHP 7.4+
  • Python 3.8+
  • MySQL 5.7+
  • Node.js 22.* (for OpenEMR builds)
  • Anthropic API key

Installation

  1. Clone the repository:
git clone https://github.com/saketh-bandi/heidi_2025.git
cd heidi_2025
  1. Set up OpenEMR:
composer install --no-dev
npm install
npm run build
composer dump-autoload -o
  1. Configure Python environment:
cd python_agent
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install -r requirements.txt
  1. Set up environment variables:
# Create .env file in python_agent/
ANTHROPIC_API_KEY=your_api_key_here
N8N_WEBHOOK_URL=your_n8n_webhook_url
  1. Start the backend:
cd python_agent
python app.py
# Backend runs on http://localhost:5001
  1. Start OpenEMR:
php -S localhost:8000
# OpenEMR runs on http://localhost:8000

Usage

  1. Navigate to a patient's demographics page in OpenEMR
  2. View Heidi medical consultation sessions
  3. Click "Analyze for Referral" to process a session
  4. Review AI-generated recommendation with PDF preview
  5. Click "Approve & Send" to send referral to specialist
  6. Specialist receives email with complete referral PDF

πŸ“Š Impact Metrics

  • 96% time reduction: 25 minutes β†’ 60 seconds per referral
  • 100% accuracy: All required medical codes included
  • Zero template fatigue: AI generates unique clinical reasoning
  • Instant specialist matching: Automatic insurance-compatible selection
  • Real-time prior auth checks: No manual insurance portal searches

πŸ—‚οΈ Project Structure

heidi_2025/
β”œβ”€β”€ python_agent/          # Flask backend & AI processing
β”‚   β”œβ”€β”€ app.py            # Main Flask API
β”‚   β”œβ”€β”€ router.py         # Claude AI integration & workflow
β”‚   β”œβ”€β”€ pdf_generator.py  # Medical PDF generation
β”‚   └── openemr_connector.py  # Database queries
β”œβ”€β”€ interface/            # OpenEMR frontend modifications
β”‚   └── patient_file/
β”‚       └── summary/
β”‚           β”œβ”€β”€ demographics.php  # Referral UI
β”‚           └── heidi_sessions_fragment.php  # Sessions display
β”œβ”€β”€ HACKATHON_DEMO_SCRIPT.md      # Presentation guide
β”œβ”€β”€ FLOWCHART_DESCRIPTION.md      # System workflow documentation
└── README.md            # This file

πŸŽ₯ Demo

For a complete demo script and presentation materials, see HACKATHON_DEMO_SCRIPT.md.

For detailed system workflow and flowchart description, see FLOWCHART_DESCRIPTION.md.

πŸ” Security & Compliance

  • All patient data encrypted in transit
  • HIPAA-compliant data handling
  • Human approval required before sending referrals
  • Audit trail for all referral actions
  • Secure API key management

🀝 Contributing

This is a hackathon project built on top of OpenEMR. For contributing to the base OpenEMR system, see the OpenEMR Contributing Guide.

πŸ“„ License

GNU GPL - Inherited from OpenEMR base project

πŸ™ Acknowledgments

πŸ“ž Contact

For questions or support, please open an issue on the GitHub repository.


HEIDI 2025 - Reducing physician burnout, one referral at a time πŸ₯✨

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • PHP 84.0%
  • JavaScript 5.1%
  • XSLT 3.7%
  • HTML 2.6%
  • Twig 1.9%
  • CSS 1.1%
  • Other 1.6%