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

# SQL-026: BillQueryProvider.GetBillsForClaim

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

## Classification

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

## Parameters

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

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [CBP_BILL](../database-tables.md#cbp_bill)** | SELECT | full CbpBill column list (same as SQL-025); predicate column unresolved (`Claim`) |

## LINQ statement

Source: `Data/SAIF.Data/Queries/Claims/BillQueryProvider.cs:45`. The repository is a class field initialised from `Factory.GetRepository<CbpBill>().Query()` at `Data/SAIF.Data/Queries/Claims/BillQueryProvider.cs:26`.

```csharp
return repository.Where(x => x.Claim.Id == claimId).ToList();
```

## 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
  CB.BILL_ID,
  CB.UPDATE_NUM,
  CB.PATIENT_REFERENCE_NUM,
  CB.MAIL_ROOM_RECEIVED_DATE,
  CB.SAIF_CLAIM_NUM,
  CB.SAIF_CLAIM_CHK_VALUE,
  CB.WORKER_FIRST_NAME,
  CB.WORKER_MIDDLE_INITIAL,
  CB.WORKER_LAST_NAME,
  CB.WORKER_PHONE_NUM,
  CB.WORKER_BIRTH_DATE,
  CB.WORKER_ADDRESS_LINE1,
  CB.WORKER_ADDRESS_LINE2,
  CB.WORKER_ADDRESS_LINE3,
  CB.WORKER_ADDRESS_LINE4,
  CB.GENDER_CODE,
  CB.PATIENT_ACCOUNT_NUM,
  CB.PROVIDER_TAX_ID,
  CB.PROVIDER_ADDRESS_LINE1,
  CB.PROVIDER_ADDRESS_LINE2,
  CB.PROVIDER_CITY_NAME,
  CB.PROVIDER_STATE_CODE,
  CB.PROVIDER_ZIP_CODE,
  CB.PROVIDER_LICENSE_NUM,
  CB.ADMISSION_DATE,
  CB.DISCHARGE_DATE,
  CB.STATEMENT_FROM_DATE,
  CB.STATEMENT_THRU_DATE,
  CB.WORKER_TAX_ID,
  CB.TOWID,
  CB.REBILL_FLAG,
  CB.CURRENT_BILL_STATUS_ID,
  CB.PRIORITY_NUM,
  CB.UPDATE_USER,
  CB.UPDATE_DATE,
  CB.REFERRING_PROVIDER_NAME,
  CB.BILL_TOTAL_AMT,
  CB.DRG_CODE,
  CB.BILL_PACKAGE_QUANTITY,
  CB.WORKFLOW_BYPASS_CODE,
  CB.CURRENT_RESPONSIBLE_PARTY_ID,
  CB.CURRENT_STATUS_EFF_DATE,
  CB.CURRENT_UPDATE_USER,
  CB.CURRENT_NEXT_REVIEW_DATE,
  CB.UB_BILL_TYPE_CODE,
  CB.CBP_ADMISSION_TYPE_CODE,
  CB.IMAGE_SEQ_NUM,
  CB.CLAIM_ID,
  CB.BILL_TYPE_CODE,
  CB.PROVIDER_LOCATION_SEQ_NUM,
  CB.CURRENT_BILL_STATUS_CODE,
  CB.CBP_BILL_ENTRY_SOURCE_CODE
FROM CBP_BILL CB
WHERE CB.Claim.Id = :claimId -- unresolved mapping: CbpBill.Claim
```

Translation notes:
- **Unresolved mapping `CbpBill.Claim`:** the model declares `public virtual InjuryClaim Claim { get; set; }`, but `CbpBillMap` has no `References(x => x.Claim)` — only `Map(x => x.ClaimId).Column("CLAIM_ID")`. The property is rendered with its C# path because no mapping resolves it; this query is expected to fail at runtime with an NHibernate `QueryException`.
- **Likely intent:** if the mapping is fixed to `References(x => x.Claim).Column("CLAIM_ID")`, this becomes `CB.CLAIM_ID = :claimId` with no join, because `.Id` is the identifier.
- `CL_INJURY_CLAIM` is not included, because no mapping links `CbpBill` to `InjuryClaim`.

## Operations and processes

- [Bill queries](../operations/bill-queries.md)

## Business rules

- [SD-BR-034 Bill entry source classification](../business-rules.md#sd-br-034-bill-entry-source-classification)
- [SD-BR-035 Bill allowed total treats null as zero](../business-rules.md#sd-br-035-bill-allowed-total-treats-null-as-zero)
- [SD-BR-036 Service code current only when expiration date is null](../business-rules.md#sd-br-036-service-code-current-only-when-expiration-date-is-null)

## Sources
- `Data/SAIF.Data/Queries/Claims/BillQueryProvider.cs:45`
