---
title: Bill queries
summary: Query bill records, entry-source classification, allowed amounts, and non-expired service codes.
status: draft
owner: SAIF.Core documentation team
last_reviewed: 2026-09-24
library: SAIF.Data
reference_type: package
operation_id: OP-SD-12
trigger: Bill-related read operations.
---

# Bill queries

Query bill records, entry-source classification, allowed amounts, and non-expired service codes.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-SD-12 |
| **Trigger** | Bill-related read operations. |
| **Inputs** | Bill id, service code |
| **Outputs** | Bill/service data |
| **Primary components** | `BillQueryProvider` |
| **Entry point** | `Data/SAIF.Data/Queries/Claims/BillQueryProvider.cs` |

## Steps

1. Entry source "R" means regenerated and "E" means e-bill ([SD-BR-034](../business-rules.md#sd-br-034-bill-entry-source-classification)).
2. `GetBillAmounts` sums `AllowedAmount`, treating null as 0 ([SD-BR-035](../business-rules.md#sd-br-035-bill-allowed-total-treats-null-as-zero), [SQL-024](../sql/SQL-024-bill-query-provider-bill-exists.md), [SQL-025](../sql/SQL-025-bill-query-provider-get-bill.md), [SQL-026](../sql/SQL-026-bill-query-provider-get-bills-for-claim.md), [SQL-027](../sql/SQL-027-bill-query-provider-get-bill-ids-for-claim.md), [SQL-028](../sql/SQL-028-bill-query-provider-get-bill-types.md), [SQL-029](../sql/SQL-029-bill-query-provider-get-bill-status-code.md)).
3. `GetCbpServiceCodeNotExpired` requires `ExpirationDate == null` ([SD-BR-036](../business-rules.md#sd-br-036-service-code-current-only-when-expiration-date-is-null)). Data: `CbpBill` (`CBP_BILL`), `CbpServiceCode`.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([Bill-related read operations.]) --> S1["`BillQueryProvider`"]
	S1 --> S2{"Rules satisfied?"}
	S2 -->|Yes| EndOk([Result returned])
	S2 -->|No| EndErr([Exception / empty result])
```

## Failure and edge-case behavior
- Null `AllowedAmount`: treated as 0 in the sum.

## 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/BillQueryProvider.cs`
- `Data/SAIF.Data/Queries/Claims/BillQueryProvider.cs:35`
- `Data/SAIF.Data/Queries/Claims/BillQueryProvider.cs:40`
- `Data/SAIF.Data/Queries/Claims/BillQueryProvider.cs:45`
