Skip to content

BillService

Orchestrates bill-level lifecycle operations — approval, disallowance, pending, sending to audit, regeneration, and payment-option updates — by loading a domain Bill (via the internal domainBill/Domain.Model.Claims.Bills.Bill type built from IBillQueryProvider, IClaimQueryProvider, IAuditNoteQueryProvider, IWorkerQueryProvider, ICCClaimApiService, and IClaimDataApiClient) and invoking its state-changing behavior inside IUnitOfWork transactions. It also determines whether a bill can be treated as non-chargeable based on claim denial/WCD-closure history obtained through IWorkCalendarService-independent domain claim data, and assembles the composite BillHeader view by merging bill, claim, and MCO detail data.

Purpose

  • Determines whether an IME-provider bill can be marked non-chargeable, based on the claim's denial decisions or WCD closure date relative to the bill's statement date.
  • Computes the reviewed/allowed bill amount total for a claim, payment category, and set of bill types.
  • Approves a bill, disallows or allows all its services, sends bills to pend, sends bills to audit, and regenerates duplicate/erroneous bills — all as validated, transactional request operations.
  • Updates a bill's payment options.
  • Supplies read views used by the bill UI: status history, status codes, bill type codes, a composite bill header (with claim, MCO, and adjuster details), disallow reason codes, diagnoses, procedures, medical conditions, claim request decisions, WCD status history, audited services, and other (non-audited) services.

Context

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

Public members

Member Signature Purpose
BillService (constructor) public BillService(IUnitOfWork uow, IUserProfileService uprof, IValidationService val, IWorkCalendarService workCalendarService, IBillQueryProvider billQueryProvider, IServiceCodeQueryProvider serviceCodeQueryProvider, IProviderQueryProvider providerQueryProvider, IAuditNoteQueryProvider auditNoteQueryProvider, IClaimQueryProvider claimQueryProvider, IAuditQueryProvider auditQueryProvider, IWorkerQueryProvider workerQueryProvider, ICCClaimApiService claimApiService, IClaimDataApiClient gwClaimDataApiClient) Wires the unit of work, user-profile, validation, work-calendar, and the full set of query-provider/API-client collaborators used to build the domain bill and claim objects underlying every operation.
CanBillBeNonChargeable public bool CanBillBeNonChargeable(long billId) Returns true only for a reviewed IME-provider bill with chargeable audit cost whose claim was closed (WCD status) on or before the bill's statement-from date, or whose claim has a "Denied" decision dated on or before that date.
GetBillAmounts public decimal GetBillAmounts(long claimId, string paymentCategory, IList<string> billTypes) Sums the allowed amount of audited services for the claim, restricted to the given bill statuses and payment category, returning 0 when there are no matching services.
ApproveBill public IValidationResult ApproveBill(ApproveBillRequest request) Validates the request, then approves the bill and sets its payment issue date, committing the change transactionally; returns the validation result either way.
DisallowAllServices public bool DisallowAllServices(long billId, string reasonId) Marks every service on the bill's audit as disallowed for the given reason, attributed to the current user, and commits the change; always returns true.
AllowAllServices public bool AllowAllServices(long billId) Marks every service on the bill's audit as allowed, attributed to the current user, and commits the change; always returns true.
SendPendBill public IValidationResult SendPendBill(SendPendRequest request) Validates the request, then sends each listed bill to pend status with the given pend date and mail ID, committing the change; returns the validation result either way.
SendToAudit public IValidationResult SendToAudit(SendToAuditRequest request) Validates the request, then sends each listed bill to audit with the supplied note text, committing the change; returns the validation result either way.
RegenerateBill public IValidationResult RegenerateBill(RegenerateRequest request) Validates the request, then regenerates each listed bill via BillRegenerator.Regenerate unless it is a full duplicate (in which case a message identifying the original bill is added instead), committing the change and appending a success or partial-exception summary message.
UpdatePaymentOptions public IValidationResult UpdatePaymentOptions(PaymentOptionsRequest request) Validates the request, then applies the requested payment-option changes to the bill and commits them; returns the validation result either way.
GetBillStatusHistory public IEnumerable<BillStatusItem> GetBillStatusHistory(long billId) Returns the bill's status-change history, most recent first, retrieved through a locally constructed BillQueryProvider.
GetBillStatusCodes public IEnumerable<BillStatusCode> GetBillStatusCodes() Returns the selectable bill status codes, excluding the internal "PEN" and "DIS" codes.
GetBillTypes public IEnumerable<BillTypeCode> GetBillTypes() Returns all configured bill type codes.
GetBillHeader public BillHeader GetBillHeader(long billId) Assembles the composite header view for a bill: base bill data plus attending physician, claim status/type, injury date, adjuster display/navigation info, MCO plan/enrollment status, and physical-medicine service count; throws if the bill has no associated claim in Claim Center.
GetDisallowReasonCodes public IEnumerable<DisallowReasonCode> GetDisallowReasonCodes() Returns the fixed, alphabetically ordered list of reasons a service can be disallowed (e.g. claim denied, condition not related, no pre-certification).
GetBillDiagnosis public IEnumerable<BillDiagnosis> GetBillDiagnosis(long billId) Returns the bill's diagnoses, each enriched with its description looked up from the CBP diagnosis reference table.
GetBillProcedure public IEnumerable<BillProcedure> GetBillProcedure(long billId) Returns the bill's procedure line items.
GetConditions public IEnumerable<Condition> GetConditions(long claimId) Returns the claim's medical conditions, sourced from a locally constructed domain Claim.
GetClaimRequestDecisions public IEnumerable<ClaimRequestDecision> GetClaimRequestDecisions(long claimId) Returns the claim's request decisions, sourced from a locally constructed domain Claim.
GetClaimWcdStatusHistory public IEnumerable<ClaimStatusDetail> GetClaimWcdStatusHistory(long claimId) Returns the claim's WCD (workers' comp division) status history via IClaimQueryProvider.
GetAuditedService public IEnumerable<AuditedService> GetAuditedService(long billId) Returns the bill audit's reviewed/audited service lines.
GetOtherServices public IEnumerable<AuditedService> GetOtherServices(long billId, DateTime fromDate, DateTime thruDate) Returns the bill's services outside the audit within the given date range (i.e., services not part of the formal audit set).

Behavioral notes

  • Wraps every state-changing operation (ApproveBill, DisallowAllServices, AllowAllServices, SendPendBill, SendToAudit, RegenerateBill, UpdatePaymentOptions) in unitOfWork.Begin()/unitOfWork.Commit(), only entering the transaction after IValidationService.Validate reports the request valid.
  • Validates all mutation request DTOs (ApproveBillRequest, SendPendRequest, SendToAuditRequest, RegenerateRequest, PaymentOptionsRequest) via IValidationService before performing any work, returning the IValidationResult unchanged when invalid.
  • RegenerateBill skips regeneration for bills flagged as full duplicates and instead records a message referencing the original bill ID(s); it aggregates success/exception messages after the transaction commits.
  • GetBillHeader throws a plain Exception when the bill has no associated Claim Center claim, rather than returning a partial/null result.
  • A static constructor calls BillMappingHelper.MapBillService() and BillMappingHelper.MapForBillHeader(), registering AutoMapper mappings once per process.
  • GetBillStatusHistory constructs its own local BillQueryProvider instance rather than using an injected query-provider abstraction, coupling this method directly to that concrete type.*
  • GetConditions and GetClaimRequestDecisions construct a Domain.Model.Claims.Claim object directly per call rather than retrieving it through a cached or injected service.*
  • The class carries a CA1506:AvoidExcessiveClassCoupling suppression, reflecting its dependency on a large number of query providers and API clients.*

Constraints and usage notes

  • Only uow is null-checked in the constructor via Enforce.ArgumentNotNull; the remaining collaborator parameters are not validated for null.*
  • Multi-bill operations (SendPendBill, SendToAudit, RegenerateBill) process each listed bill within a single shared transaction; a failure partway through affects the whole batch's commit.*

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