---
title: "SQL-014: AuditQueryProvider.GetAuditForBill"
summary: Read operation for `AuditQueryProvider.GetAuditForBill`
status: draft
owner: SAIF.Core documentation team
last_reviewed: 2026-09-24
library: SAIF.Data
reference_type: package
---

# SQL-014: AuditQueryProvider.GetAuditForBill

This statement is a read operation invoked through ORM (NHibernate LINQ). Executed by `AuditQueryProvider.GetAuditForBill`.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-014 |
| **Operation type** | Read |
| **Execution method** | ORM (NHibernate LINQ) |
| **Database** | Oracle* |
| **Schema** | [unqualified]** |
| **Command type** | N/A (ORM-generated) |
| **Business object** | `AuditQueryProvider` |
| **Criteria property** | N/A — ORM |
| **Lifecycle method** | `GetAuditForBill` |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `billId` | Input | long | N/A | Method argument of `AuditQueryProvider.GetAuditForBill` bound into the ORM expression; NHibernate generates the bind variable at runtime |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [CBP_AUDIT](../database-tables.md#cbp_audit) | SELECT | BILL_ID, UPDATE_NUM, TOTAL_CHARGED_AMT, TOTAL_ALLOWED_AMT, TOTAL_MCO_ADMIN_FEE_AMT, UPDATE_DATE, UPDATE_USER, AUDIT_RECEIPT_DATE, CHARGEABLE_COST_FLAG, PRINT_EOB_FLAG, SPECIAL_HANDLING_CODE |

## LINQ statement

Source: `Data/SAIF.Data/Queries/AuditQueryProvider.cs:39`. The repository is a class field initialised from `Factory.GetRepository<CbpAudit>().Query()` at `Data/SAIF.Data/Queries/AuditQueryProvider.cs:23`.

```csharp
return repository.SingleOrDefault(x => x.Bill.Id == billId);
```

## Sample SQL

> **Inferred SQL:** This SQL was inferred from the LINQ statement above and the NHibernate mappings. It is not concrete SQL from source code; NHibernate generates the executed statement at runtime, so aliases, column order, join syntax, and bind-parameter names may differ.

```sql
-- Inferred from LINQ (NHibernate mapping translation); not concrete SQL
SELECT
  CA.BILL_ID,
  CA.UPDATE_NUM,
  CA.TOTAL_CHARGED_AMT,
  CA.TOTAL_ALLOWED_AMT,
  CA.TOTAL_MCO_ADMIN_FEE_AMT,
  CA.UPDATE_DATE,
  CA.UPDATE_USER,
  CA.AUDIT_RECEIPT_DATE,
  CA.CHARGEABLE_COST_FLAG,
  CA.PRINT_EOB_FLAG,
  CA.SPECIAL_HANDLING_CODE
FROM CBP_AUDIT CA
WHERE CA.BILL_ID = :billId
-- NHibernate expects at most one row
```

Translation notes:
- `x.Bill.Id` is the identifier of `References(Bill).Column("BILL_ID")`, so it resolves to `CA.BILL_ID` with no join; `CBP_BILL` is not accessed as a separate table.

## Operations and processes

- [Bill audit evaluation](../operations/bill-audit-evaluation.md)

## Business rules

- [SD-BR-030 Nurse review required if any audited service code flags it](../business-rules.md#sd-br-030-nurse-review-required-if-any-audited-service-code-flags-it)
- [SD-BR-031 Duplicate services excluded from count](../business-rules.md#sd-br-031-duplicate-services-excluded-from-count)
- [SD-BR-032 Unset thru-date treated as open-ended](../business-rules.md#sd-br-032-unset-thru-date-treated-as-open-ended)

## Sources
- `Data/SAIF.Data/Queries/AuditQueryProvider.cs:39`
