---
title: "SQL-014: Ebill error condition insert (EbillErrorCondition)"
summary: Inserts an error-condition row whose pended/provider-error flags depend on the kind of error being recorded.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Domain
reference_type: package
---

# SQL-014: Ebill error condition insert (EbillErrorCondition)

`ErrorConditionHandler.NewError` inserts an `EbillErrorCondition` row recording an indexing or generation error; the pended and provider-error flags are set according to the kind of error being recorded.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-014 |
| **Operation type** | Create |
| **Execution method** | ORM (IRepository.Add) |
| **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** | `ErrorConditionHandler` |
| **Criteria property** | N/A — ORM |
| **Lifecycle method** | `NewError` |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [EBILL_ERROR_CONDITION](../database-tables.md#ebill_error_condition) | INSERT | `EBILL_ERROR_CONDITION_SEQ_NUM`, `UPDATE_NUM`, `ERROR_TEXT`, `PENDED_BILL_FLAG`, `PROVIDER_ERROR_FLAG`, `EBILL_SERVICE_SUB_NUM`, `UPDATE_USER`, `UPDATE_DATE`, `EBILL_SEQ_NUM`, `EBILL_PROVIDER_SEQ_NUM`, `EBILL_PATIENT_SEQ_NUM` |

## LINQ statement

Source: `Domain/SAIF.Domain/Model/Claims/Ebilling/ErrorConditionHandler.cs:28`

```csharp
// Domain/SAIF.Domain/Model/Claims/Ebilling/ErrorConditionHandler.cs:21-28
var error = new EbillErrorCondition
{
    ErrorText = text,
    UpdateDate = DateTime.Now,
    UpdateUser = userProfileService.GetCurrentUser().UserId
};

Factory.GetRepository<EbillErrorCondition>().Add(error);
```

## 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 EBILL_ERROR_CONDITION_SEQ.NEXTVAL
FROM DUAL

INSERT INTO EBILL_ERROR_CONDITION (
  EBILL_ERROR_CONDITION_SEQ_NUM,
  UPDATE_NUM,
  ERROR_TEXT,
  PENDED_BILL_FLAG,
  PROVIDER_ERROR_FLAG,
  EBILL_SERVICE_SUB_NUM,
  UPDATE_USER,
  UPDATE_DATE,
  EBILL_SEQ_NUM,
  EBILL_PROVIDER_SEQ_NUM,
  EBILL_PATIENT_SEQ_NUM)
VALUES (
  :Id,
  :UpdateNumber,
  :ErrorText,
  :IsPendedBill,
  :IsProviderError,
  :ServiceSubNumber,
  :UpdateUser,
  :UpdateDate,
  :Bill,
  :Provider,
  :Patient)
```

Translation notes:
- `:Id` is the value fetched from `EBILL_ERROR_CONDITION_SEQ` (`GeneratedBy.Native("EBILL_ERROR_CONDITION_SEQ")` on Oracle).
- `:UpdateNumber` is the initial version value NHibernate seeds on insert (version column mapped with `Version(...)`).
- `:IsPendedBill`, `:IsProviderError` are bound as `'Y'`/`'N'` (`YesNoType`).
- Reference bind variables (`:<Property>`) carry the referenced entity's identifier value.
- The C# code assigns `DateTime.Now` client-side before flush; the value is bound as an ordinary parameter (no server date function).
- At `Add` time only `ErrorText`, `UpdateDate`, `UpdateUser` are set; callers later assign `Bill` (lines 57, 68) — if that happens before flush, the values travel in this INSERT; otherwise a dirty-check UPDATE follows (not fabricated).

## Operations and processes
- OP-DOM-07 ErrorConditionHandler — inserts an error-condition row whose flags depend on the error kind (see [Operations and processes](../operations-processes.md))

## Business rules
- [DOM-BR-070](../business-rules.md#dom-br-070-error-recording)

> **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/Model/Claims/Ebilling/ErrorConditionHandler.cs
