Bug Report & Fix: Fee Sheet Review Button Applies Historical Fees Instead of Current Fee Schedule

Summary
When a practice updates their fee schedule (e.g., raising 99214 from $140.00 to $160.00), the Fee Sheet Review button continues to import the old historical fee from the billing table rather than the current fee schedule price. This causes incorrect charges to be applied to new encounters without the provider being aware.
Environment
• OpenEMR Version: 7.0.4
• PHP Version: 8.2
• Database: MySQL 8.0
• Operating System: Ubuntu 24.04 LTS

Steps to Reproduce
• Set up a fee schedule with 99214 at price X (e.g., $140.00).
• Create and bill at least one encounter using that fee.
• Update the fee schedule, raising 99214 to a new price Y (e.g., $160.00).
• Open a new encounter for the same patient.
• Click the Review button on the Fee Sheet.
• Select the previous encounter and click to apply charges.
• Observe: the 99214 imports at the OLD price X ($140.00) instead of the current price Y ($160.00).

Expected vs. Actual Behavior
Expected
The Review button should import CPT codes from the previous encounter but apply the CURRENT fee schedule price for each code, ensuring charges are always billed at the practice’s current rates.
Actual
The Review button imports both the CPT code AND the historical fee amount stored in the billing table at the time of the original encounter. If fees have been updated since that encounter, the new encounter will be created with outdated charges.

Root Cause
The bug is in the fee_sheet_items() function located at:
/interface/forms/fee_sheet/review/fee_sheet_queries.php

The original query pulls the fee directly from the billing table:
function fee_sheet_items($pid, $encounter, &$diagnoses, &$procedures): void
{
$param = [$encounter];
$sql = “SELECT code, code_type, code_text, fee, modifier, justify, units, ct_diag, ct_fee, ct_mod”
. " FROM billing, code_types as ct"
. " WHERE encounter=? AND billing.activity>0 AND ct.ct_key=billing.code_type"
. " ORDER BY id";
}

The fee field in the billing table stores the fee at the time of the original encounter. It is never updated when the fee schedule changes. The query makes no attempt to look up the current price from the prices table.

Fix
Modify the fee_sheet_items() query to JOIN against the prices table and use COALESCE() to prefer the current fee schedule price, falling back to the historical fee only if no current price exists:
function fee_sheet_items($pid, $encounter, &$diagnoses, &$procedures): void
{
$sql = “SELECT billing.code, billing.code_type, billing.code_text,”
. " COALESCE(prices.pr_price, billing.fee) as fee,"
. " billing.modifier, billing.justify, billing.units, ct_diag, ct_fee, ct_mod"
. " FROM billing"
. " JOIN code_types as ct ON ct.ct_key=billing.code_type"
. " LEFT JOIN codes ON codes.code=billing.code AND codes.code_type=ct.ct_id"
. " LEFT JOIN prices ON prices.pr_id=codes.id AND prices.pr_level=?"
. " WHERE billing.encounter=? AND billing.activity>0"
. " ORDER BY billing.id";
$param = [‘standard’, $encounter];
}

How the Fix Works
• LEFT JOIN codes — matches the CPT code in billing to the codes table to get the code’s internal ID (codes.id).
• LEFT JOIN prices — uses the code ID to look up the current price at the ‘standard’ price level from the prices table.
• COALESCE(prices.pr_price, billing.fee) — uses the current fee schedule price if found; falls back to the historical fee if the code is not in the fee schedule (e.g., a rarely used code with no price entry).
• The fix is backward compatible — practices that have not updated their fee schedule will see no change in behavior.

File to Modify
• File: /interface/forms/fee_sheet/review/fee_sheet_queries.php
• Function: fee_sheet_items()
• Lines: approximately 195-204 (may vary by version)

Impact
Any practice that has updated their fee schedule since going live on OpenEMR is affected. Charges applied via the Review button will be silently incorrect — billed at old rates — without any warning to the provider or billing staff. This can result in systematic underbilling that may go unnoticed for extended periods.
Verification
After applying the fix:
• Open a patient with a previous encounter billed under the old fee schedule.
• Create a new encounter and click the Review button.
• Select the old encounter and apply charges.
• Confirm that 99214 (or any updated CPT code) now shows the current fee schedule price, not the historical price.

1 Like