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 unpaidLegalBillwith 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 viaIProviderInformationService. - 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 theSAIF.SAIFCode.CoreNuGet 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. GetInboxItemsandGetPendingBillsboth useIClaimDataApiClient.GetClaims(bulk lookup, awaited synchronously) rather than per-bill single-claim calls, favoring performance for list views.GetPendingBillssetsIsPaidAmountOverAuthorityonly when the paid amount exceeds both the user's initiate and approve authority limits.BillUpdateEmployeesListswallows and logs (rather than propagates) exceptions thrown byIUserProfileService.GetApplicationUser/IsAuthorizedfor individual employees, so one bad lookup does not fail the whole list.- The class is
sealedand carries aCA1506:AvoidExcessiveClassCouplingsuppression, reflecting its dependency on user-profile, provider-information, environment, bill-service-helper, legal-service, log, and claim-data-API collaborators.* LegalSupportEmployeeListincludes 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, andbillServiceHelperare null-checked in the constructor viaEnforce.ArgumentNotNull;logServiceandclaimDataApiClientare not validated for null.* - This type is read/query-oriented — it does not itself open
IUnitOfWorktransactions for the mutation lifecycle (approve, disallow, pend, etc.); that responsibility belongs to theBillServiceinSAIF.Services.Claims.Billsand toBillSaveService/BillPaymentServicein 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