---
title: ErrorConditionHandler
summary: API reference for ErrorConditionHandler.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Domain
reference_type: package
---

# ErrorConditionHandler

`ErrorConditionHandler` implements `IErrorConditionHandler` and is the single recording point for [OP-DOM-07](../../operations-processes.md#op-dom-07): every indexing and generation step in this library (`PatientIndexer`, `ProviderIndexer`/`ProviderIndexerV2`, `BillServiceIndexer`, `GenerateCbpBills`) that hits a data problem records it here as an `EbillErrorCondition` row, with the pended and provider-error flags set according to which error-kind method was called ([DOM-BR-070](../../business-rules.md#dom-br-070-error-recording)).

## Purpose
- Creates a new `EbillErrorCondition` row for every recorded error, stamping the update date/user and adding it to the repository before any error-kind-specific fields are set.
- Sets the pended-bill and provider-error flags differently depending on which error-kind method is called — provider errors and bill-service-provider errors are always pended and flagged as provider errors, patient errors are pended but not provider errors, and bill-service errors take an explicit `isPending` flag — implementing [DOM-BR-070](../../business-rules.md#dom-br-070-error-recording).

## Context
- Namespace: `SAIF.Domain.Model.Claims.Ebilling`
- Assembly/package: `SAIF.Domain` (packaged in `SAIF.SAIFCode.Core`)

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| ErrorConditionHandler (constructor) | `public ErrorConditionHandler(IRepositoryFactory factory, IUserProfileService prof)` | Initializes the handler with the repository factory and user-profile service used to stamp new error rows; requires `prof` to be non-null. |
| AddProviderError | `public void AddProviderError(EbillProvider provider, string errorText)` | Records a pended, provider-flagged error against `provider` ([DOM-BR-070](../../business-rules.md#dom-br-070-error-recording)). |
| AddPatientError | `public void AddPatientError(EbillPatient patient, string errorText)` | Records a pended, non-provider-flagged error against `patient` and its provider ([DOM-BR-070](../../business-rules.md#dom-br-070-error-recording)). |
| AddBillServiceError | `public void AddBillServiceError(Ebill bill, string errorText, bool isPending = true)` | Records an error against `bill`, with the pended flag controlled by the `isPending` parameter rather than a fixed value ([DOM-BR-070](../../business-rules.md#dom-br-070-error-recording)). |
| AddBillServiceProviderError | `public void AddBillServiceProviderError(EbillService service, string errorText)` | Records a pended, provider-flagged error against `service`'s bill, patient, and provider, and its sub-service number ([DOM-BR-070](../../business-rules.md#dom-br-070-error-recording)). |

## Inherited public members

Members in this section are inherited from `DomainBase<TItem>` in `SAIF.Domain`. They are available on this type through inheritance (via the intermediate `DomainRepositoryBase<TItem>` base).

| Member | Signature | Purpose | Origin |
| --- | --- | --- | --- |
| HasData | `public virtual bool HasData { get; }` | Reports whether the wrapped `EbillErrorCondition` entity is present, evaluated as `!DataItem.IsNull()`. | `SAIF.Domain` — `DomainBase<TItem>` |

## Behavioral notes
- Each `Add*Error` method creates and adds a brand-new `EbillErrorCondition` row per call via the private `NewError` helper; the type's own `DataItem`/`HasData` state (inherited from its base classes) is not used to track the error it just created*.
- `AddBillServiceError`'s `isPending` parameter defaults to `true`, so callers that omit it get the same pended behaviour as the provider/patient error methods.

## Constraints and usage notes
- Each public method issues its own `Factory.GetRepository<EbillErrorCondition>().Add` call, so callers do not need to persist the error row themselves after calling one of these methods.

> **Note:** Statements marked with `*` were inferred from code structure, naming
> conventions, or contextual evidence where direct confirmation was not available
> in source artifacts.

## Sources
- `Domain/SAIF.Domain/Model/Claims/Ebilling/ErrorConditionHandler.cs`
- `Domain/SAIF.Domain/Model/Claims/Ebilling/IErrorConditionHandler.cs`
- `Domain/SAIF.Domain/DomainBase.cs`
- `Domain/SAIF.Domain/DomainRepositoryBase.cs`
