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

# SQL-041: BillQueryProvider.GetCbpServiceZCode

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

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-041 |
| **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** | `GetCbpServiceZCode` |

## Parameters

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

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [CBP_SERVICE_CODE](../database-tables.md#cbp_service_code) | SELECT | CODE, BILL_SERVICE_TYPE_CODE, UPDATE_NUM, EFF_DATE, EXP_DATE, RP_1099_REQ_FLAG, UPDATE_USER, UPDATE_DATE, NURSE_REVIEW_REQUIRED_FLAG, DCBS_REPORT_SERVICE_CODE |

## LINQ statement

Source: `Data/SAIF.Data/Queries/Claims/BillQueryProvider.cs:172`.

```csharp
return Factory.GetRepository<CbpServiceCode>().Query().SingleOrDefault(x => x.Code == serviceCode && x.ServiceType == GetBillServiceTypeCode("Z"));
```

## 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
  CSC.CODE,
  CSC.BILL_SERVICE_TYPE_CODE,
  CSC.UPDATE_NUM,
  CSC.EFF_DATE,
  CSC.EXP_DATE,
  CSC.RP_1099_REQ_FLAG,
  CSC.UPDATE_USER,
  CSC.UPDATE_DATE,
  CSC.NURSE_REVIEW_REQUIRED_FLAG,
  CSC.DCBS_REPORT_SERVICE_CODE
FROM CBP_SERVICE_CODE CSC
WHERE CSC.CODE = :serviceCode
  AND CSC.BILL_SERVICE_TYPE_CODE = :ServiceType
-- NHibernate expects at most one row
```

Translation notes:
- `x.ServiceType == GetBillServiceTypeCode("Z")` compares by the `CbpServiceTypeCode` entity's identifier, so it resolves to the owner column `CSC.BILL_SERVICE_TYPE_CODE` with no join; `CBP_SERVICE_TYPE_CODE` is not accessed as a separate table.
- `GetBillServiceTypeCode("Z")` does not reference the lambda parameter, so NHibernate's partial evaluator invokes it client-side before this statement runs, issuing a separate query of the SQL-044 shape with `CODE = 'Z'`. If that pre-query finds nothing, `:ServiceType` becomes `NULL` and no rows match.

## 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:172`
