A powerful command-line tool for analyzing Pharmacy Benefit Management (PBM) records using Azure OpenAI. This tool processes CSV files containing prescription and claim data to determine the status and identify potential issues with PBM records.
- π CSV Processing: Reads and validates PBM record data from CSV files
- π€ AI Analysis: Uses Azure OpenAI to analyze records and determine status
- π Multiple Output Formats: Console, CSV, and JSON output options
- π Detailed Insights: Provides confidence scores, recommendations, and risk factors
- π Batch Processing: Handles large datasets efficiently with configurable batch sizes
- β‘ Rate Limiting: Built-in delays to respect API rate limits
- Clone or download this project
- Install dependencies:
npm install
- Build the project:
npm run build
-
Copy the example environment file:
cp .env.example .env
-
Edit
.envwith your Azure OpenAI credentials:AZURE_OPENAI_API_KEY=your_actual_api_key AZURE_OPENAI_ENDPOINT=https://your-resource-name.openai.azure.com AZURE_OPENAI_DEPLOYMENT_NAME=your_deployment_name
Analyze a CSV file of PBM records:
npm run dev -- analyze -f examples/sample-pbm-data.csv# Specify output format and file
npm run dev -- analyze -f data.csv --format csv --output results.csv
# Process in smaller batches with longer delays
npm run dev -- analyze -f data.csv --batch-size 5 --delay 2000
# Output as JSON
npm run dev -- analyze -f data.csv --format json --output analysis.jsonGenerate example files and templates:
npm run dev -- setupYour CSV file should contain PBM record data with the following common columns:
patient_id: Unique patient identifiermedication_name: Name of the medicationclaim_status: Current status of the claim
patient_name: Patient full namendc_number: National Drug Codeprescription_date: Date prescription was writtenprescriber_name: Prescribing physician nameprescriber_npi: National Provider Identifierpharmacy_name: Dispensing pharmacy namepharmacy_ncpdp: Pharmacy NCPDP numberinsurance_plan: Insurance plan nameprior_authorization_status: PA statusformulary_tier: Drug tier levelcopay_amount: Patient copaymentrejection_reason: Reason for denialdays_supply: Days supply dispensedquantity_dispensed: Quantity dispensedrefills_remaining: Remaining refills
patient_id,medication_name,claim_status,prior_authorization_status,formulary_tier
P001,Lipitor,APPROVED,APPROVED,Tier 2
P002,Metformin,APPROVED,NOT_REQUIRED,Tier 1
P003,OxyContin,PENDING,PENDING,Tier 3
Real-time analysis results with colored status indicators and detailed breakdowns.
Spreadsheet-compatible format with all original fields plus analysis results:
status: Analysis result (APPROVED/DENIED/PENDING/REQUIRES_REVIEW/ERROR)confidence: Confidence score (0-1)reason: Detailed explanationrecommendations: Action items (semicolon-separated)risk_factors: Identified risks (semicolon-separated)processed_at: Timestamp of analysis
Structured format ideal for further processing:
{
"metadata": {
"generated_at": "2024-09-25T12:00:00Z",
"total_records": 10,
"analysis_summary": {
"status_breakdown": {
"APPROVED": 5,
"DENIED": 2,
"PENDING": 3
},
"average_confidence": 0.85
}
},
"results": [...]
}- APPROVED: Claim processed successfully, no issues
- DENIED: Claim rejected with clear reasons
- PENDING: Awaiting additional information or processing
- REQUIRES_REVIEW: Potential issues identified, needs human review
- ERROR: Analysis failed or insufficient data
Analyze PBM records from a CSV file.
Options:
-f, --file <path>: Path to CSV file (required)-o, --output <path>: Output file path (optional)--format <format>: Output format: console, csv, json (default: console)--batch-size <size>: Records per batch (default: 10)--delay <ms>: Delay between API calls in milliseconds (default: 1000)
Generate example configuration and template files.
npm run buildnpm run dev -- <command> [options]npm start -- <command> [options]- Verify your Azure OpenAI credentials in
.env - Ensure your API key has proper permissions
- Check that your endpoint URL is correct
- Ensure your CSV has headers in the first row
- Check that required fields (patient_id, medication_name, claim_status) are present
- Verify data encoding is UTF-8
- Increase the
--delayparameter if you encounter rate limits - Reduce
--batch-sizefor more conservative processing - Monitor your Azure OpenAI usage quotas
- Prepare Data: Export PBM records to CSV format
- Configure: Set up Azure OpenAI credentials in
.env - Test: Run analysis on sample data
- Analyze: Process your full dataset
- Review: Examine results and recommendations
- Act: Address identified issues and reprocess as needed
For issues or questions:
- Check this README for common solutions
- Verify your Azure OpenAI setup and permissions
- Ensure CSV data format matches requirements
- Review console output for specific error messages
MIT License - see LICENSE file for details.