Skip to content

BillService

Read-focused orchestrator for the legal-bill inbox and detail views — assembles inbox items and pending-approval bill review lists (merging local LegalBill records with bulk claim data fetched through IClaimDataApiClient), retrieves a single legal bill enriched with provider address details via IProviderInformationService, exposes the legal-support/bill-update employee lists filtered by IUserProfileService authorization, and supplies the code-table lists (special handling, rate types, adjustment reasons, bill statuses, bill service codes) used to populate bill-entry UI. It masks claimant names for conflict-restricted workers unless the current user holds LNConflict access.

Purpose

  • Builds the legal-bill inbox (GetInboxItems), merging each unpaid LegalBill with its bulk claim data and masking claimant names for conflict workers when the current user lacks conflict access.
  • Builds the pending-approval bill review list (GetPendingBills), filtered by approver, enriched with the assigned attorney, formatted quantities/adjustment text, case notes summary, and whether the paid amount exceeds the approver's payment authority.
  • Retrieves a single legal bill by ID (GetLegalBill), including billing/payment provider addresses formatted via IProviderInformationService.
  • Reports the current user's view-only/bill-update authorization and payment/approval authority limits.
  • Exposes bill service fee schedules (IME and MCO), the legal-support employee list, the filtered bill-update-authorized employee list, and the special-handling, bill-service-rate-type, adjustment-reason, bill-status, and bill-service code lists used by bill-entry screens.

Context

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

Public members

Member Signature Purpose
BillService (constructor) public BillService(IUnitOfWork unitOfWork, IUserProfileService userProfileService, ProviderContract.IProviderInformationService providerInformationService, IEnvironmentService environmentService, IBillServiceHelper billServiceHelper, ILegalService legalService, ILogService logService, IClaimDataApiClient claimDataApiClient) Wires the unit of work, user-profile, provider-information, environment, bill-service-helper, legal-service, log, and claim-data-API collaborators; captures the current user ID and conflict-access flag at construction time.
GetInboxItems public IEnumerable<InboxItem> GetInboxItems(string employeeIdOrMailId, List<LegalEmployee> legalAttorneys) Returns all non-paid legal bills as InboxItems merged with bulk claim data, masking claimant names for conflict workers (unless the user has conflict access) and resolving each item's assigned-attorney user ID from the supplied attorney/legal-support-employee lists, ordered by bill status date.
GetPendingBills public IList<LegalBillReview> GetPendingBills(string userId) Returns bills pending approval for the given user ID (or all pending bills when userId is null/"ALL"), each enriched with assigned attorney, formatted adjustment/quantity text, case notes and notes summary, and an over-authority flag when both the user's initiate and approve limits are exceeded; masks claimant names for conflict workers unless the user has conflict access.
GetLegalBill public LegalBill GetLegalBill(long billId, IMessageContainer messageContainer) Returns the bill mapped with merged bulk claim data and formatted billing/payment provider addresses, ordering its service lines by ID; adds a "Bill not found" error and returns an empty LegalBill if the ID does not resolve.
IsViewOnlyUser public bool IsViewOnlyUser() Returns whether the current user holds the LNBillView authorization.
CanEnterBills public bool CanEnterBills() Returns whether the current user holds the LNBillUpdate authorization.
CurrentUserPaymentLimit public decimal CurrentUserPaymentLimit() Returns the current user's initiate-level payment authority for legal bills.
CurrentUserApprovalLimit public decimal CurrentUserApprovalLimit() Returns the current user's approve-level payment authority for legal bills.
GetImeBillServiceFees public IList<BillServiceFee> GetImeBillServiceFees(long imeId) Returns the bill service fee schedule configured for the given IME provider.
GetMcoBillServiceFees public IList<BillServiceFee> GetMcoBillServiceFees(string mcoPlanId) Returns the bill service fee schedule configured for the given MCO plan.
BillUpdateEmployeesList public List<LegalEmployee> BillUpdateEmployeesList { get; } Returns the legal-support employees who currently hold LNBillUpdate authorization, logging and skipping any employee whose authorization check throws.
SpecialHandlingCodeList public List<SpecialHandling> SpecialHandlingCodeList { get; } Returns all configured special-handling codes.
ListOfBillRateTypeCodes public List<BillServiceRateType> ListOfBillRateTypeCodes { get; } Returns all configured bill service rate type codes.
ListOfAdjustmentReasons public List<AdjustmentReason> ListOfAdjustmentReasons { get; } Returns all configured adjustment reason codes.
ListOfBillStatusCodes public List<BillStatus> ListOfBillStatusCodes { get; } Returns all configured bill status codes.
ListOfBillServiceCodes public List<BillServiceCode> ListOfBillServiceCodes { get; } Returns all configured bill service codes.

Behavioral notes

  • A static constructor calls BillMappingHelper.MapBillService(), registering the AutoMapper mappings this service relies on once per process.
  • GetInboxItems and GetPendingBills both use IClaimDataApiClient.GetClaims (bulk lookup, awaited synchronously) rather than per-bill single-claim calls, favoring performance for list views.
  • GetPendingBills sets IsPaidAmountOverAuthority only when the paid amount exceeds both the user's initiate and approve authority limits.
  • BillUpdateEmployeesList swallows and logs (rather than propagates) exceptions thrown by IUserProfileService.GetApplicationUser/IsAuthorized for individual employees, so one bad lookup does not fail the whole list.
  • The class is sealed and carries a CA1506:AvoidExcessiveClassCoupling suppression, reflecting its dependency on user-profile, provider-information, environment, bill-service-helper, legal-service, log, and claim-data-API collaborators.*
  • LegalSupportEmployeeList includes a hardcoded set of development-team user IDs (GREMIL, MELHIL, CHACAT, BRISLY, AARCHA) in non-production environments, in addition to active Legal-department employees.

Constraints and usage notes

  • Only unitOfWork, userProfileService, providerInformationService, environmentService, and billServiceHelper are null-checked in the constructor via Enforce.ArgumentNotNull; logService and claimDataApiClient are not validated for null.*
  • This type is read/query-oriented — it does not itself open IUnitOfWork transactions for the mutation lifecycle (approve, disallow, pend, etc.); that responsibility belongs to the BillService in SAIF.Services.Claims.Bills and to BillSaveService/BillPaymentService in this namespace.*

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