---
title: E-bill processing queries
summary: Support e-bill lifecycle queries: status/assignment classification, clearinghouse response-file selection, compound-drug flagging, batch classification, zero-pay EOB candidates, DRG lookup, and active clearinghouse resolution.
status: draft
owner: SAIF.Core documentation team
last_reviewed: 2026-09-24
library: SAIF.Data
reference_type: package
operation_id: OP-SD-17
trigger: E-bill processing workflow steps.
---

# E-bill processing queries

Support e-bill lifecycle queries: status/assignment classification, clearinghouse response-file selection, compound-drug flagging, batch classification, zero-pay EOB candidates, DRG lookup, and active clearinghouse resolution.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-SD-17 |
| **Trigger** | E-bill processing workflow steps. |
| **Inputs** | Bill/EOB/batch identifiers |
| **Outputs** | Bill/EOB/batch data, flags set |
| **Primary components** | `EbillQueryProvider`, `EbillBatchQueryProvider`, `EbillEobQueryProvider`, `EbillHealthInformationQueryProvider`, `EbillingQueryProvider` |
| **Entry point** | `Data/SAIF.Data/Queries/Claims/Ebilling/EbillQueryProvider.cs` |

## Steps

1. E-bill status codes (ACCPT, ASSGN, COMPL, DLOAD, EOBDS, EOBRJ, IMAGE, INDEX, NEW, PEND, REJCT, SETUP, EXTR) and assignment rules (CONF, PROV, CLAIM, CLEAN) are applied as constants ([SD-BR-050](../business-rules.md#sd-br-050-e-bill-status-and-assignment-rule-code-sets)). Data: `Ebill` (`EBILL`), `EbillAssignmentRule` (`EBILL_ASSIGNMENT_RULE`).
2. `GetBillsForResponseFileForClearinghouse` selects bills where there is no `FirstResponseBatch`, or no `LastResponseBatch` and the bill status is not "PEN" ([SD-BR-051](../business-rules.md#sd-br-051-bill-included-in-clearinghouse-response-file-by-response-batch-state), [SQL-074](../sql/SQL-074-ebill-address-query-provider-get-address.md), [SQL-075](../sql/SQL-075-ebill-address-query-provider-get-address-type-by-code.md), [SQL-076](../sql/SQL-076-ebill-address-query-provider-get-address-by-batch-id.md), [SQL-077](../sql/SQL-077-ebill-address-query-provider-get-addresses-to-override.md), [SQL-078](../sql/SQL-078-ebill-batch-query-provider-get-batch.md), [SQL-079](../sql/SQL-079-ebill-batch-query-provider-get-batch.md)).
3. `SetCompoundDrugForAllServiceLinesForTheBill`: if there is more than one distinct prescription number among the NDC lines, set `IsCompoundDrug` on all of them ([SD-BR-052](../business-rules.md#sd-br-052-multiple-prescription-numbers-mark-all-ndc-lines-as-compound-drug)). Data: `EbillService` (`EBILL_SERVICE`). This **writes** entity flags; persistence happens via the caller's unit of work.
4. `EbillBatchQueryProvider`: batch type 837 is e-bill and 835 is payment advice ([SD-BR-053](../business-rules.md#sd-br-053-e-bill-batch-type-classification)). Data: `EBILL_BATCH`.
5. `EbillEobQueryProvider.GetCompletedZeroPaymentBillsForEob`: bill status COM, audits exist, the allowed-amount sum is 0, and no EOB exists ([SD-BR-054](../business-rules.md#sd-br-054-zero-pay-eob-candidate-criteria)). Data: `EBILL_EOB`, `CBP_BILL`, `CBP_AUDIT`.
6. `EbillHealthInformationQueryProvider.GetDrgCode`: health information type "DR" ([SD-BR-055](../business-rules.md#sd-br-055-drg-code-identified-by-health-information-type)).
7. `EbillingQueryProvider.GetClearinghouse`: the active clearinghouse is the one where `EndDate == null` ([SD-BR-056](../business-rules.md#sd-br-056-active-clearinghouse-has-a-null-end-date)). Data: `EBILL_CLEARINGHOUSE`.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([E-bill processing workflow steps.]) --> S1["`EbillQueryProvider`"]
	S1 --> S2{"Rules satisfied?"}
	S2 -->|Yes| EndOk([Result returned])
	S2 -->|No| EndErr([Exception / empty result])
```

## Failure and edge-case behavior
- No matching prescription numbers: `IsCompoundDrug` left unset.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [SQL catalog](../sql/index.md)
- [Database tables](../database-tables.md)


## Sources
- `Data/SAIF.Data/Queries/Claims/Ebilling/EbillQueryProvider.cs`
- `Data/SAIF.Data/Queries/Claims/Ebilling/EbillAddressQueryProvider.cs:24`
- `Data/SAIF.Data/Queries/Claims/Ebilling/EbillAddressQueryProvider.cs:29`
- `Data/SAIF.Data/Queries/Claims/Ebilling/EbillAddressQueryProvider.cs:34`
