Skip to content

BillProcedureValidator

Validates a BillProcedure entry: it requires a procedure code (up to 8 characters), requires a primary-procedure designation restricted to a fixed allow-list (P or O), and — only when a procedure date is supplied — constrains that date to a rolling window between nine years ago and today. It has no constructor dependencies, computing the nine-year cutoff (nineYearsAgo) once at construction time from DateTime.Today, so the validator instance's date bound is fixed to whenever it was instantiated rather than re-evaluated per validation call.*

Purpose

  • Requires ProcedureCode to be non-null/non-empty and no more than 8 characters long.
  • Requires PrimaryProcedure to be non-null and, when present, restricts it to the allow-list P or O.
  • When ProcedureDate is set and greater than DateTime.MinValue, requires it to fall between nine years ago and today (rejecting future dates and dates too far in the past).

Context

  • Namespace: SAIF.Services.Claims.Bills.Validators
  • Assembly/package: SAIF.Services (packaged inside the SAIF.SAIFCode.Core NuGet package)

Public members

Member Signature Purpose
BillProcedureValidator BillProcedureValidator() Wires length/required rules for ProcedureCode, an allow-list Must check for PrimaryProcedure, and conditional date-range rules for ProcedureDate bounded by a nine-year lookback computed at construction time.*

Behavioral notes

  • Validation is enforced via FluentValidation's AbstractValidator<T> base.*
  • The date-range rules for ProcedureDate only run inside a When(x => x.ProcedureDate != null && x.ProcedureDate > DateTime.MinValue, ...) guard, so an unset or default date skips the range check entirely.*
  • The nine-year lookback boundary (nineYearsAgo) is computed once in the constructor from DateTime.Today, not recomputed per validated instance.*
  • A source comment on the primary-procedure allow-list notes it may later be validated against the database instead of the hard-coded list.*

Constraints and usage notes

  • Takes no constructor dependencies; all validation is self-contained and does not query external data.

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/BillProcedureValidator.cs