---
title: BillRateService
summary: API reference for BillRateService.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Services
reference_type: package
---

# BillRateService

Calculates the allowed (paid) amount for a legal-bill service line by applying, in order, copy-fee rates, unknown-service zeroing, IME contract rates, and MCO contract rates found through `IUnitOfWork` and `IProviderQueryProvider`/`IClaimQueryProvider` lookups, falling back to full billed-amount reimbursement when no applicable fee schedule is found. It also flags a service line as a possible or exact duplicate of an existing service line on another bill for the same case/provider/service date.

## Purpose
- Determines the paid amount for a bill service line based on its service type (electronic/paper copy, unknown service, IME rate, MCO rate, or standard/full reimbursement) and records the corresponding adjustment reason.
- Detects duplicate or possible-duplicate service lines by comparing billed amount, service date, and provider/case across other bills, marking exact duplicates for zero payment and near-matches as possible duplicates.
- Applies the worker's active MCO plan (if the provider participates) or the IME provider fee schedule to cap the paid amount at a configured maximum.

## Context
- Namespace: `SAIF.Services.Legal.Bills`
- Assembly/package: `SAIF.Services` (packaged inside the `SAIF.SAIFCode.Core` NuGet package).

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| BillRateService (constructor) | `public BillRateService(IUnitOfWork unitOfWork, IProviderQueryProvider providerQueryProvider, IClaimQueryProvider claimQueryProvider, IValidationService validationService)` | Wires the unit of work, provider/claim query providers, and validation service used to compute rates and check for duplicates. |
| CalculateAllowedAmount | `public bool CalculateAllowedAmount(long claimId, long providerLocationId, LegalBillService serviceLine)` | Caps the paid amount at the billed amount, validates the service line, then applies copy/unknown-service handling, IME rate, or MCO rate in order; if none apply, sets the paid amount to the full billed amount with a standard rate type and clears the adjustment reason. Returns `false` only when validation fails. |
| CheckForDuplicateService | `public void CheckForDuplicateService(long caseId, long providerLocationId, long billId, LegalBillService serviceLine)` | Sets `PaidAmount` to `0` and the adjustment reason to `DuplicateBill` when an existing service line on a different bill for the same case/provider matches exactly on service code, service date, and billed amount; otherwise flags `IsPossibleDuplicate` when only the provider/case/service date match. |

## Behavioral notes
- `CalculateAllowedAmount` short-circuits to `false` without modifying the paid amount further (beyond the initial billed-amount cap) when `Validate` reports the service line invalid.
- IME and MCO rate application (`ApplyImeRate`/`ApplyMcoRate`) look up a `BillServiceFee` scoped to the service code, effective/expiration date range, and MCO plan or IME provider location; when a fee's `MaximumAmount` is exceeded, the paid amount is capped and the adjustment reason is set to `ImeContract` or `McoContract` respectively.
- `ApplyMcoRate` only applies when the claim has an active MCO location for the service date (via `IClaimQueryProvider.GetAllMcoLocations`) and the provider participates in that MCO plan (via `IProviderQueryProvider.IsProviderInMco`).
- `SetAdjustmentReason` clears the adjustment reason only when it was previously one of `ImeContract`, `McoContract`, or `NegotiatedRate`, preserving other reasons (e.g. manually entered ones) when no new reason applies.

## Constraints and usage notes
- Only `unitOfWork` is null-checked in the constructor via `Enforce.ArgumentNotNull`; the remaining collaborator parameters are not validated for null.*
- `CalculateAllowedAmount` and `CheckForDuplicateService` both require a non-null `serviceLine`, enforced via `Enforce.ArgumentNotNull`.

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts. Statements
> marked with ** could not be confirmed; treat as unknown until verified.

## Sources
- `Services/SAIF.Services/Legal/Bills/BillRateService.cs`
