Skip to content

appdevgbb/pbm-agent-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PBM Status CLI

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.

Features

  • πŸ“Š 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

Installation

  1. Clone or download this project
  2. Install dependencies:
    npm install
  3. Build the project:
    npm run build

Configuration

  1. Copy the example environment file:

    cp .env.example .env
  2. Edit .env with 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

Usage

Basic Analysis

Analyze a CSV file of PBM records:

npm run dev -- analyze -f examples/sample-pbm-data.csv

Advanced Options

# 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.json

Setup Command

Generate example files and templates:

npm run dev -- setup

CSV File Format

Your CSV file should contain PBM record data with the following common columns:

Required Fields

  • patient_id: Unique patient identifier
  • medication_name: Name of the medication
  • claim_status: Current status of the claim

Optional Fields

  • patient_name: Patient full name
  • ndc_number: National Drug Code
  • prescription_date: Date prescription was written
  • prescriber_name: Prescribing physician name
  • prescriber_npi: National Provider Identifier
  • pharmacy_name: Dispensing pharmacy name
  • pharmacy_ncpdp: Pharmacy NCPDP number
  • insurance_plan: Insurance plan name
  • prior_authorization_status: PA status
  • formulary_tier: Drug tier level
  • copay_amount: Patient copayment
  • rejection_reason: Reason for denial
  • days_supply: Days supply dispensed
  • quantity_dispensed: Quantity dispensed
  • refills_remaining: Remaining refills

Example CSV Structure

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

Output Formats

Console Output

Real-time analysis results with colored status indicators and detailed breakdowns.

CSV Output

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 explanation
  • recommendations: Action items (semicolon-separated)
  • risk_factors: Identified risks (semicolon-separated)
  • processed_at: Timestamp of analysis

JSON Output

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": [...]
}

Analysis Status Types

  • 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

Command Reference

analyze Command

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)

setup Command

Generate example configuration and template files.

Development

Build

npm run build

Development Mode

npm run dev -- <command> [options]

Using Built Version

npm start -- <command> [options]

Troubleshooting

Authentication Issues

  • Verify your Azure OpenAI credentials in .env
  • Ensure your API key has proper permissions
  • Check that your endpoint URL is correct

CSV Format Issues

  • 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

Rate Limiting

  • Increase the --delay parameter if you encounter rate limits
  • Reduce --batch-size for more conservative processing
  • Monitor your Azure OpenAI usage quotas

Example Workflow

  1. Prepare Data: Export PBM records to CSV format
  2. Configure: Set up Azure OpenAI credentials in .env
  3. Test: Run analysis on sample data
  4. Analyze: Process your full dataset
  5. Review: Examine results and recommendations
  6. Act: Address identified issues and reprocess as needed

Support

For issues or questions:

  1. Check this README for common solutions
  2. Verify your Azure OpenAI setup and permissions
  3. Ensure CSV data format matches requirements
  4. Review console output for specific error messages

License

MIT License - see LICENSE file for details.

About

Agent/LLM based PBM analysis and categorization

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published