A unified full-stack application for validating medical study coverage against insurance provider lists using AI/LLM technology. The system helps medical professionals determine if specific medical studies are covered by insurance and provides detailed reasoning for coverage decisions.
- Unified Architecture: Single server serves both API and frontend
- AI-Powered Coverage Validation: Uses LLM to determine medical study coverage
- Multiple Model Support: OpenAI and Ollama integration
- Structured Output: Zod schema validation for consistent responses
- Web Interface: Modern HTML/CSS/JS frontend
- REST API: Programmatic access to coverage validation
- Command Line Tool: Testing and development utilities
- Docker Support: Containerized deployment ready
This project uses a unified architecture where a single Express server handles both the API and serves the frontend files. This simplifies deployment and eliminates CORS issues.
insurance_coverage/
βββ src/ # Server source code
β βββ index.ts # Main server (API + static file serving)
β βββ ic.ts # Command-line testing script
β βββ insurance-coverage.ts # Core coverage logic
β βββ config.ts # Environment configuration
β βββ enums/ # Type definitions
β βββ schemas/ # Zod validation schemas
βββ frontend/ # Static frontend files
β βββ index.html # Main web interface
β βββ main.js # Frontend JavaScript
β βββ style.css # Styling
βββ package.json # Dependencies and scripts
βββ tsconfig.json # TypeScript configuration
βββ Dockerfile # Container configuration
βββ env.example # Environment variables template
βββ LICENSE # ISC License
βββ README.md
- Node.js: Version 18.0.0 or higher
- npm: Version 8.0.0 or higher
- OpenAI API Key (for production) or Ollama (for local development)
-
Clone the repository
git clone <repository-url> cd insurance_coverage
-
Install dependencies
npm install
-
Set up environment variables
cp env.example .env # Edit .env with your configuration -
Start the unified server
npm run dev
-
Access the application
- Open
http://localhost:3000in your browser - The server automatically serves both API and frontend
- Open
Create a .env file in the root directory with the following variables:
# OpenAI Configuration (for production)
OPENAI_API_KEY=your_openai_api_key_here
OPENAI_MODEL=gpt-4o-mini
# Ollama Configuration (for local development)
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL=mistralThe system supports two AI models:
- OpenAI: Production-ready, requires API key
- Ollama: Local development, free to use
- Open
http://localhost:3000in your browser - Enter a medical study description (e.g., "urotac", "resonancia de cabeza")
- Click "Check" to get coverage information
- View the coverage result and reasoning
GET /health- Health checkGET /ping- Simple ping endpointGET /homologate-study/:study- Get coverage for a medical study
Use the ic.ts script for command-line testing:
npm run icThis will test the coverage validation with a predefined study.
npm run dev # Start unified development server with hot reload
npm run build # Build TypeScript to JavaScript
npm start # Start production server
npm run ic # Run command-line testing scriptThe project uses a unified architecture where:
- Single Server: One Express server handles both API and frontend
- No CORS Issues: Frontend and API are on the same origin
- Simplified Deployment: One process to manage
- Static File Serving: Express serves frontend files automatically
The frontend is automatically served by the Express server at http://localhost:3000. No separate frontend server needed.
The project includes a Dockerfile for containerized deployment:
docker build -t insurance-coverage .
docker run -p 3000:3000 insurance-coverage- Unified Architecture: Single server for API and frontend
- AI-Powered Coverage Validation: Uses LLM to determine medical study coverage
- Multiple Model Support: OpenAI and Ollama integration
- Structured Output: Zod schema validation for consistent responses
- Modern Web Interface: Clean HTML/CSS/JS frontend
- REST API: Programmatic access to coverage validation
- Command Line Tool: Testing and development utilities
- TypeScript: Full type safety throughout the project
- Docker Ready: Containerized deployment support
The system currently validates coverage for:
- TomografΓas (CT Scans): Various body parts and types
- Resonancias MagnΓ©ticas (MRI): Different anatomical regions
- Other Medical Studies: As defined in the coverage list
- Frontend Documentation - Frontend usage and customization guide
- Environment Configuration - Environment variables template
- LICENSE - ISC License file
This project uses a unified architecture where a single Express server handles both the API endpoints and serves the frontend files. This approach provides several benefits:
- Simplified Deployment: Only one server process to manage
- No CORS Issues: Frontend and API share the same origin
- Easier Development: Single command to start everything
- Better Performance: No network overhead between frontend and API
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the ISC License. See the LICENSE file for details.
For questions or issues, please check the individual component documentation or create an issue in the repository.