---
title: "SQL-032: Ebill status update to CbpSetup (Ebill)"
summary: Links the ebill to the newly inserted CbpBill and sets its status to CbpSetup.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Domain
reference_type: package
---

# SQL-032: Ebill status update to CbpSetup (Ebill)

After inserting the new `CbpBill` (SQL-016), `GenerateCbpBills.Generate` links it to the ebill bill and sets the ebill's `Status` to CbpSetup. NHibernate persists the change via dirty-check detection at flush*.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-032 |
| **Operation type** | Update* |
| **Execution method** | ORM (dirty-check flush*) |
| **Database** | Oracle* |
| **Schema** | [unqualified]** |
| **Command type** | N/A — ORM (NHibernate generates SQL at runtime from the ClassMaps in `Data/SAIF.Data.NHibernate/Mappings/**`) |
| **Business object** | `GenerateCbpBills` |
| **Criteria property** | N/A — ORM |
| **Lifecycle method** | `Generate` |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [EBILL](../database-tables.md#ebill) | UPDATE | `UPDATE_NUM`, `CLEARINGHOUSE_CONTROL_NUM`, `STATEMENT_FROM_DATE`, `STATEMENT_THRU_DATE`, `INJURY_DATE`, `ADMISSION_DATE`, `DISCHARGE_DATE`, `ORIGINAL_BILL_ID`, `BILL_TOTAL_AMOUNT`, `UB_BILL_TYPE_CODE`, `SERVICE_LOCATION_CODE`, `FACILITY_NPI`, `SUBMITTER_CONTROL_NUM`, `TRANSACTION_SET_CONTROL_NUM`, `UPDATE_USER`, `UPDATE_DATE`, `CLEARINGHOUSE_RECEIVED_DATE`, `CBP_ADMISSION_TYPE_CODE`, `BILL_ID`, `EBILL_RECEIPT_BATCH_SEQ_NUM`, `EBILL_PATIENT_SEQ_NUM`, `EBILL_STATUS_CODE`, `FACILITY_ADDRESS_SEQ_NUM`, `EBILL_SET_TYPE_CODE`, `EBILL_FIRST_RESPONSE_SEQ_NUM`, `EBILL_LAST_RESPONSE_SEQ_NUM`, `EBILL_RESPONSE_SET_SEQ_NUM`, `EBILL_EOB_SEQ_NUM`, `EBILL_SEQ_NUM` |

## LINQ statement

Source: `Domain/SAIF.Domain/Claims/Ebilling/GenerateCBPBills.cs:36`

```csharp
// Domain/SAIF.Domain/Claims/Ebilling/GenerateCBPBills.cs:36-39
bill.Bill = newCbpBill;
bill.Status = ebillingQueryProvider.BillQueries.GetBillStatusCbpSetup();
bill.UpdateDate = DateTime.Now;
bill.UpdateUser = currentUser;
```

## 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
UPDATE EBILL
SET
  UPDATE_NUM = :newVersion,
  CLEARINGHOUSE_CONTROL_NUM = :ClearinghouseControlNumber,
  STATEMENT_FROM_DATE = :StatementFromDate,
  STATEMENT_THRU_DATE = :StatementThruDate,
  INJURY_DATE = :InjuryDate,
  ADMISSION_DATE = :AdmissionDate,
  DISCHARGE_DATE = :DischargeDate,
  ORIGINAL_BILL_ID = :OriginalBillId,
  BILL_TOTAL_AMOUNT = :TotalAmount,
  UB_BILL_TYPE_CODE = :UbBillTypeCode,
  SERVICE_LOCATION_CODE = :ServiceLocationCode,
  FACILITY_NPI = :FacilityNpi,
  SUBMITTER_CONTROL_NUM = :SubmitterControlNumber,
  TRANSACTION_SET_CONTROL_NUM = :TransactionSetControlNumber,
  UPDATE_USER = :UpdateUser,
  UPDATE_DATE = :UpdateDate,
  CLEARINGHOUSE_RECEIVED_DATE = :ClearinghouseReceivedDate,
  CBP_ADMISSION_TYPE_CODE = :CbpAdmissionTypeCode,
  BILL_ID = :Bill,
  EBILL_RECEIPT_BATCH_SEQ_NUM = :ReceiptBatch,
  EBILL_PATIENT_SEQ_NUM = :Patient,
  EBILL_STATUS_CODE = :Status,
  FACILITY_ADDRESS_SEQ_NUM = :FacilityAddress,
  EBILL_SET_TYPE_CODE = :SetType,
  EBILL_FIRST_RESPONSE_SEQ_NUM = :FirstResponseBatch,
  EBILL_LAST_RESPONSE_SEQ_NUM = :LastResponseBatch,
  EBILL_RESPONSE_SET_SEQ_NUM = :ResponseSet,
  EBILL_EOB_SEQ_NUM = :Eob
WHERE EBILL_SEQ_NUM = :Id
  AND UPDATE_NUM = :oldVersion
```

Translation notes:
- No explicit `Update()` call: under the stateful strategy `RepositoryBase.Update` is a no-op and the UPDATE is emitted by NHibernate dirty-checking at `Commit()` flush (Legends: SAIF.Framework.Data.NHibernate RepositoryBase / business-rules). The mapping declares no `DynamicUpdate()`, so NHibernate sends every updatable mapped column, not only the ones changed here.
- Version `UPDATE_NUM`.
- `:Bill` = identifier of the new `CbpBill` (from `CBP_BILL_SEQ`, SQL-016) — `EbillMap.cs:14`. Prior page used column name `BILL`; mapped column is `BILL_ID`.
- `GetBillStatusCbpSetup()` is a separate read.
- Bind variables for `References` carry the referenced entity's identifier; values not changed by this call site are re-sent unchanged.
- The C# code assigns `DateTime.Now` client-side before flush; the value is bound as an ordinary parameter (no server date function).

## Operations and processes
- OP-DOM-06 GenerateCbpBills.Generate — sets the ebill status to CbpSetup after CBP generation (see [Operations and processes](../operations-processes.md))

## Business rules
- [DOM-BR-050](../business-rules.md#dom-br-050-cbp-generation)
- [DOM-BR-051](../business-rules.md#dom-br-051-cbp-generation)
- [DOM-BR-052](../business-rules.md#dom-br-052-cbp-generation)
- [DOM-BR-053](../business-rules.md#dom-br-053-cbp-generation)
- [DOM-BR-054](../business-rules.md#dom-br-054-cbp-generation)
- [DOM-BR-055](../business-rules.md#dom-br-055-cbp-generation)
- [DOM-BR-056](../business-rules.md#dom-br-056-cbp-generation)
- [DOM-BR-057](../business-rules.md#dom-br-057-cbp-generation)
- [DOM-BR-058](../business-rules.md#dom-br-058-cbp-generation)
- [DOM-BR-059](../business-rules.md#dom-br-059-cbp-generation)
- [DOM-BR-060](../business-rules.md#dom-br-060-cbp-generation)
- [DOM-BR-061](../business-rules.md#dom-br-061-cbp-generation)
- [DOM-BR-062](../business-rules.md#dom-br-062-cbp-generation)
- [DOM-BR-063](../business-rules.md#dom-br-063-complete)
- [DOM-BR-064](../business-rules.md#dom-br-064-cbp-generation)

> **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
- Domain/SAIF.Domain/Claims/Ebilling/GenerateCBPBills.cs
