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

# BillServiceValidator

Validates a `BillService` line item's coding, dates, quantities, and identifiers against the constraints of a professional/institutional claim service line: provider service codes, up to four diagnosis pointer codes (each restricted to `A`–`L` or `1`–`8` and cross-checked for uniqueness across all four fields), service and prescription dates bounded relative to today, up to four two-character service modifiers, a two-digit service location code, quantity/tooth-number ranges, and conditional length checks on pharmacy dispense-as-written and prescribing-provider identifiers. It depends on `IBillServiceService` via constructor injection, though that dependency is not referenced within the visible rule bodies.*

## Purpose
- Requires `ProviderServiceCode` to be non-null and no more than 11 characters; limits `SecondaryProvServiceCode` to at most 11 characters.
- Restricts each of `DiagnosisPointerCode1`–`4` to at most 1 character matching `[A-L1-8]`, and requires the four pointer codes (where entered) to be mutually distinct via a custom `Must` predicate.
- When set, bounds `BillServiceDate` to no more than 30 days in the future and requires `BillServiceEndDate` (when set) to be on or after `BillServiceDate`; requires `PrescriptionWrittenDate` (when set) to be a valid, non-default date.
- Limits `ServiceModifierCode1`–`4` to at most 2 characters each, and requires `ServiceLocationCode` to be exactly 2 digits.
- Requires `ServiceQuantity` to be non-negative, `ToothNumber` to fall between 0 and 32 inclusive, and `DaysSupplyQuantity` to fall between 0 and 99999 inclusive.
- When present, requires `PharmacyDispenseAsWrittenCode` to be exactly 1 character and `PrescribingProviderId` to be at most 10 characters.

## Context
- Namespace: `SAIF.Services.Claims.Bills.Validators`
- Assembly/package: `SAIF.Services` (packaged inside the `SAIF.SAIFCode.Core` NuGet package)

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| BillServiceValidator | `BillServiceValidator(IBillServiceService billServiceService)` | Wires the full set of length, regex, range, date-window, and cross-field uniqueness rules described above for a `BillService` line item.* |

## Behavioral notes
- Validation is enforced via FluentValidation's `AbstractValidator<T>` base.*
- The diagnosis-pointer uniqueness rule uses a custom `Must((service, x) => ...)` predicate that inspects all four `DiagnosisPointerCode1`–`4` fields together, comparing entered (non-null) values for duplicates — a genuine cross-field rule rather than a per-property check.*
- Several rules (`BillServiceDate`, `BillServiceEndDate`, `PrescriptionWrittenDate`, `PharmacyDispenseAsWrittenCode`, `PrescribingProviderId`) are gated by `.When(...)` so they only apply when the corresponding value is present/non-default.*
- The injected `IBillServiceService` is accepted via the constructor but is not visibly used inside any rule body shown in source; its role could not be confirmed.**

## Constraints and usage notes
- Requires an `IBillServiceService` implementation to be supplied via constructor injection.

> **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
- Services/SAIF.Services/Claims/Bills/Validators/BillServiceValidator.cs
