Skip to content

CaseCostService

Builds the combined cost-history view for a legal case by merging three sources — legal-case cost adjustments (via ILegalQueryProvider.GetCaseCost), subpoena recipient payments (via ILegalQueryProvider.GetSubpoenas and financial-transaction lookups), and legal-bill service-line payments (via ILegalQueryProvider.GetLegalBills and ICCClaimApiService.GetClaim) — into a single chronologically ordered CaseCost list, and reorganizes amended/adjusted entries into nested adjustment histories.

Purpose

  • Populates each CaseInfo's combined cost history (and optionally case notes) for display in the legal case list/detail UI.
  • Merges legal-case cost adjustments, subpoena recipient payments, and legal-bill service payments into one CaseCost timeline, ordered by service-from date descending.
  • Attributes each cost entry with authorized-by/requested-by employee names resolved from ADP employee data, and financial transaction payment ID/issue date where available.
  • Reorganizes amended cost entries so each amendment nests its prior (parent) versions under AdjustmentHistory, removing the parent entries from the flat list.

Context

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

Public members

Member Signature Purpose
CaseCostService (constructor) public CaseCostService(IUserProfileService userProfileService, ILegalQueryProvider legalQueryProvider, IBillServiceHelper billServiceHelper, ICCClaimApiService ccclaimApiService) Wires the user-profile, legal-query, bill-service-helper, and claim-API collaborators, and registers the CaseCost AutoMapper mapping once via MapCaseCost.
PopulateAdditionalCaseListProperties public void PopulateAdditionalCaseListProperties(IEnumerable<CaseInfo> caseList, bool includeSubpoenas, bool includeNotes) For each case in the list, sets CaseCost to the combined cost history (optionally including subpoenas) and, when requested, sets CaseNotes from IBillServiceHelper.GetBillNotes; does nothing if caseList is null.

Behavioral notes

  • GetCombinedCaseCostHistory always includes legal-case cost adjustments and legal-bill payments, and includes subpoena payments only when includeSubpoenas is true.
  • MapRecipientsToCaseCost marks a subpoena payment IsPaidSubpoena only when its status code is Paid and the current user is authorized for LNBillUpdate (CanEnterBills).
  • CreateHistoryRow converts billed units to hours (rounded to 2 decimals, away-from-zero) for conference/deposition (and cancellation) service codes, and resolves the MCO plan description from the claim's MCO data (fetched per service line via ICCClaimApiService.GetClaim) when the rate type is MCO.
  • MoveAmendedCaseCostsToAdjustedLists walks each amended entry's ParentCostId chain, moving every ancestor entry into the amended entry's AdjustmentHistory list and removing it from the flat costHistory collection.
  • A static MapCaseCost method registers the CaseCost → ContractData.CaseCost mapping, including provider names, authorized-by fields, service description, formatted quantity-paid text, and prepayment yes/no text; this is invoked once per instance construction rather than from a static constructor.*

Constraints and usage notes

  • userProfileService, legalQueryProvider, and billServiceHelper are null-checked in the constructor via Enforce.ArgumentNotNull; ccclaimApiService is not validated for null.*
  • CreateHistoryRow calls ICCClaimApiService.GetClaim synchronously (via GetAwaiter().GetResult()) once per bill service line, which may be a per-row network/API cost for cases with many bill services.*

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