DIR Fee Tracking & Forecasting System – Technical Overview
The Problem We’re Solving
We’re not solving DIR fees. We’re exposing them so pharmacies can fight back with data instead of hope.
PBMs have weaponized DIR fees to systematically extract profit from independent pharmacies while creating an illusion of fair reimbursement at point of sale. When a pharmacy processes a prescription, the initial adjudication shows a seemingly acceptable reimbursement. The pharmacist counsels the patient, dispenses the medication, and the claim status reads “paid.” But 90 to 180 days later, the PBM sends a retroactive clawback notice, reclaiming 8% to 30% of that original payment through obscure “performance metrics” that were never disclosed upfront.
This creates a financial time bomb. Pharmacies cannot predict their true profitability at the moment of service. They’re forced to accept claims blind, not knowing if a seemingly profitable prescription will become underwater months later. The result is pharmacies either stop serving certain payers entirely, limiting patient access, or absorb losses that push them toward closure. Patients lose access to care, and pharmacists are forced into impossible decisions about which prescriptions they can afford to fill.
We built this system because pharmacies deserve visibility into the actual economics of their business before PBMs retroactively rewrite the deal.
Technical Architecture
The DIR Fee Tracking system operates across two core components: historical data tracking and predictive forecasting, both secured with organization-level data isolation.
Historical DIR Fee Tracking (DIRFee Entity)
Every DIR fee notification from a PBM is captured with complete metadata: the fee amount, fee type classification, payer identity, notification date, the service period being clawed back, and linkage to the specific pharmacy location and original claim. This creates a full audit trail of PBM behavior over time. The system tracks gross sales versus actual net reimbursement after DIR adjustments, exposing the true margin erosion. Fee types are categorized (performance-based, network fees, administrative) to identify which PBM tactics are most aggressive.
The data model links DIR fees to PharmacyLocation records, which are associated with Organization entities. This ensures pharmacies only see their own DIR fee history, not competitors’ data. Organization-level isolation is enforced at the data access layer through OrganizationUser relationships, preventing cross-tenant data leakage.
Predictive DIR Fee Forecasting (forecastDIRFees Function)
The forecasting engine analyzes historical DIR patterns to predict future clawback exposure on currently paid claims. When invoked with a payer name, drug NDC, claim amount, and location ID, the system retrieves all historical DIR fees for that specific payer at that location. It calculates the average DIR fee percentage across all historical claims, then weights recent data more heavily by comparing the last 30 days of DIR activity against the full historical average.
The prediction algorithm uses recent trend data if at least three data points exist within the last month, otherwise it defaults to the long-term average. This adaptive approach accounts for PBMs changing their clawback aggressiveness over time. The predicted DIR fee is calculated as a percentage of the current claim amount, giving pharmacies a real-time estimate of what will actually be clawed back later.
Risk Classification
The system assigns risk levels based on predicted DIR exposure:
- Critical: 25%+ DIR fees (claim will likely be net-negative after clawback)
- High: 15-24% DIR fees (significant margin erosion)
- Medium: 8-14% DIR fees (moderate clawback exposure)
- Low: <8% DIR fees (minimal impact)
Confidence scoring accounts for data volume. High confidence requires at least 10 historical DIR events and 3 recent data points. Medium confidence requires 5 historical events. Low confidence is assigned when historical data is sparse. This prevents false precision when predicting from limited information.
Payer-Specific Pattern Analysis
The system identifies common fee types by frequency and average amount, exposing which PBM tactics are most prevalent for each payer. It calculates the average delay between service date and DIR notification date, showing pharmacies the typical clawback timeline. Trend analysis compares recent DIR percentages against historical averages to flag when PBMs are increasing clawback aggression.
Security & Data Isolation
Access control operates at three levels. First, vertical-level guards restrict DIR tracking to pharmacy-licensed users only. Second, organization-level access is enforced by validating that the requesting user has OrganizationUser relationships or is listed as the primary contact for the organization that owns the target PharmacyLocation. Third, location-level filtering ensures users only retrieve DIR fee data for locations they have explicit access to. The forecasting function verifies that the provided location_id belongs to an organization the user can access before returning any predictions.
All entity queries default to empty arrays if null, preventing null reference errors. The organization access check is wrapped in try-catch to gracefully handle missing OrganizationUser records without exposing system errors to the client.
Clinical & Financial Impact
This system gives pharmacies the one thing PBMs don’t want them to have: foresight. By exposing DIR clawback patterns before they happen, pharmacies can make informed decisions about which prescriptions are actually profitable, which payers are predatory, and when to negotiate better contracts or drop networks entirely. It shifts power back to the dispensing pharmacist, who can now see through the PBM’s accounting manipulation in real-time instead of discovering losses months later when it’s too late to act.