Skip to content

LegalService

Resolves legal cases for a claim into CaseInfo view models (merging local LegalCase data, InjuryClaim data from ICCClaimApiService, and MCO plan data), determines the assigned attorney or outside-counsel/manager fallback for a case, and reports whether the current user holds conflict-claim access (LNConflict). It is a key collaborator for BillService, BillSaveService, and CaseCostService when they need attorney assignment or case list data.

Purpose

  • Resolves a claim ID from a claim number or case number, adding a message-container error when neither resolves.
  • Builds the list of legal cases for a claim (GetCaseList), merging legal-case, injury-claim, and MCO data into CaseInfo, masking conflict-worker cases from users without LNConflict access, and marking the currently selected/primary case.
  • Determines and sets the assigned attorney for a case (DetermineAssignedAttorney), preferring an appeal-specific assignment, then the case's most recent hearing schedule's assigned attorney or outside firm, falling back to "Outside Counsel" when neither resolves.
  • Builds opposing-counsel display information (firm name, address, attorney name) for a case.
  • Reports the current user's conflict-access flag and whether a claim has any image-alert-flagged legal cases.
  • Exposes the active legal-attorney list for use in attorney-selection UI.

Context

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

Public members

Member Signature Purpose
LegalService (constructor) public LegalService(IUnitOfWork unitOfWork, IUserProfileService userProfileService, ILegalQueryProvider legalQueryProvider, ICCClaimApiService claimApiService) Wires the unit of work, legal-query provider, and claim-API service, and captures the current user's LNConflict authorization at construction time.
GetClaimIdByClaimNumberOrCaseNumber public long GetClaimIdByClaimNumberOrCaseNumber(string claimNumberOrCaseNumber, IMessageContainer messageContainer) Returns the claim ID resolved from the given claim/case number via ILegalQueryProvider.GetClaimIdForCase, adding a "Case or claim not found" error when it resolves to 0.
GetClaimNumber public string GetClaimNumber(long legalCaseId) Returns the claim number for the legal case's associated claim; throws ArgumentException if the legal case cannot be found.
GetCaseList public IEnumerable<CaseInfo> GetCaseList(long claimId, string claimNumberOrCaseId, IMessageContainer messageContainer) Returns all legal cases for the claim as CaseInfo, merging injury-claim and MCO data, hiding conflict-worker cases (with an authorization error) from users without conflict access, populating assigned attorney/opposing counsel/primary-case flags, and marking the selected case; adds a "No cases for this claim" error when none exist.
LegalAttorneyList public List<LegalEmployee> LegalAttorneyList { get; } Returns active (non-expired within the last year) attorney profiles, ordered by last name, mapped to LegalEmployee.
DetermineAssignedAttorney public void DetermineAssignedAttorney(CaseInfo caseInfo) Sets caseInfo.AssignedAttorneyEmployeeId/AssignedAttorneyName from the appeal-specific assignment if present, otherwise from the case's most recent hearing schedule's assigned attorney or assigned outside firm (marked "Outside Counsel"), or clears both if no assignment can be determined.
UserHasLNConflictAccess public bool UserHasLNConflictAccess() Returns whether the current user holds LNConflict authorization, as captured at construction time.
LegalCaseExistsAndHasImageAlertsFlag public bool LegalCaseExistsAndHasImageAlertsFlag(long claimId) Returns whether the claim has at least one legal case flagged IsImageAlert.

Behavioral notes

  • A static constructor calls LegalMappingHelper.MapLegalService(), registering the AutoMapper mappings this service relies on once per process.
  • GetCaseList checks conflict access only against the first case in the resolved list (caseList.First().IsConflictWorker); if that first case is a conflict case and the user lacks access, the entire non-conflict subset is returned instead, along with an authorization error.*
  • GetOpposingCounselInfo prefers a correspondence-type address for the worker's attorney firm, falling back to a physical-type address if no correspondence address is found, and reports "N/A" for firm/attorney name when no firm/attorney is associated with the case.

Constraints and usage notes

  • Only unitOfWork, userProfileService, and legalQueryProvider are null-checked in the constructor via Enforce.ArgumentNotNull; claimApiService is not validated for null.*
  • DetermineAssignedAttorney requires a non-null caseInfo, enforced via Enforce.ArgumentNotNull.

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