---
title: "SQL-031: Ebill status update during 835 build (Ebill)"
summary: Sets the ebill status to the resolved 835 status code while rendering the 835 EDI file.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Domain
reference_type: package
---

# SQL-031: Ebill status update during 835 build (Ebill)

`File835Builder.CreateFile` sets the ebill's `Status` to the resolved 835 status code while rendering the 835 EDI file. NHibernate persists the change via dirty-check detection at flush*.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-031 |
| **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** | `File835Builder` |
| **Criteria property** | N/A — ORM |
| **Lifecycle method** | `CreateFile` |

## 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/File835Builder.cs:107`

```csharp
// Domain/SAIF.Domain/Claims/Ebilling/File835Builder.cs:100-107
var ebills = eob.Ebills;
//Int16 counter = 0;
foreach (var ebill in ebills)
{
    var bill = ebill.Bill; //CbpBill
    var audits = bill.Audits;

    ebill.Status = ebillStatus;
```

## 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`.
- `ebillStatus` comes from `GetBillStatuseEobDistributed()` (line 43, separate read).
- `eob.Ebills`, `ebill.Bill`, `bill.Audits` (lines 100-105) are lazy collection/proxy loads — separate SELECTs not part of this SQL ID.
- Bind variables for `References` carry the referenced entity's identifier; values not changed by this call site are re-sent unchanged.

## Operations and processes
- OP-DOM-12 EobBuilder.GenerateEobs — File835Builder renders the EDI output for generated EOBs (see [Operations and processes](../operations-processes.md))

## Business rules
No business rule directly enforced by this statement.

> **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/File835Builder.cs
