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

# BillRegenerator

`BillRegenerator` implements [OP-DOM-16](../../operations-processes.md#op-dom-16), the bill-regeneration workflow that clones a rejected or corrected `CbpBill` into a brand-new bill so it can re-enter the CBP processing pipeline without losing its original service, procedure, and diagnosis detail. It copies every scalar field from the source `CbpBill` (worker, provider, dates, addresses, totals) onto a new entity tagged with a regenerated entry-source code, re-adds the services, procedures, and diagnoses, persists the clone through `IRepositoryFactory`, and then drives the new `Bill` domain wrapper through `ModifyStatus` so the clone starts life at status Entered with responsible party SYSTEM ([DOM-BR-160](../../business-rules.md#dom-br-160-regenerate)). Callers in SAIF.Services invoke it when a bill needs to be resubmitted.

## Purpose
- Clones a bill's core data plus its services, procedures, and diagnoses into a fresh `CbpBill` row so the original audit/status history is not disturbed.
- Sets the regenerated bill's initial state to Entered with responsible party SYSTEM, per [DOM-BR-160](../../business-rules.md#dom-br-160-regenerate).
- Provides the SAIF.Services layer with a single entry point for bill regeneration, isolating the field-by-field copy logic from the caller.

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

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| Regenerate | `public static bool Regenerate(IRepositoryFactory factory, Bill bill, IUserProfileService profileService, string noteText, IBillQueryProvider billQueryProvider, IClaimQueryProvider claimQueryProvider, IAuditNoteQueryProvider auditNoteQueryProvider, IWorkerQueryProvider workerQueryProvider, ICCClaimApiService claimApiService, IClaimDataApiClient gwClaimDataApiClient)` | Clones `bill`'s data, services, procedures, and diagnoses into a new `CbpBill` tagged with the regenerated entry-source code, persists it, and moves the new bill to status Entered with responsible party SYSTEM via `Bill.ModifyStatus` ([DOM-BR-160](../../business-rules.md#dom-br-160-regenerate)); always returns `true` on completion*. |

## Behavioral notes
- The clone's `BillEntrySource` is obtained from `IBillQueryProvider.GetRegeneratedBillEntrySourceCode()`, distinguishing regenerated bills from originally entered ones.
- `noteText`, when supplied, is passed through to `Bill.ModifyStatus` and becomes an audit note attached to the regenerated bill's status change.
- The method has no failure return path in the current implementation; any error surfaces as an unhandled exception rather than a `false` result*.

## Constraints and usage notes
- Callers must supply query providers for bills, claims, audit notes, and workers because the cloned `Bill` wrapper is constructed with the same dependency set as any other `Bill`.
- `factory` must support `GetRepository<CbpBill>().Add`, since the clone is persisted before status modification.

> **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/Claims/Bills/BillRegenerator.cs`
