Skip to content

LegalTaskService

Owns the full lifecycle of legal/claim activity tasks — filtered task-list queries flattened for performance and merged with bulk claim data (IClaimDataApiClient), task creation/update/completion/deletion/reassignment inside IUnitOfWork transactions, worker-name masking for restricted/secured claims, imaging-document metadata enrichment via IImagingClient, and task-to-note conversion (legal note or claim note) on completion or deletion. It extends ValidatingServiceBase and implements ILegalTaskService.

Purpose

  • Retrieves a single task by ID and the reference lists (task groups, note categories, manual-entry categories) used by task-entry UI.
  • Filters and returns the task list for a claim, mail ID/group, or activity view, enriching each row with claim/worker/policy data, masked worker names for restricted/secured claims the current user cannot access, and imaging-document metadata (type/subtype/date/link) fetched in batches from IImagingClient.
  • Creates, updates, completes, deletes, and bulk-reassigns tasks, converting a completed or deleted task into a LegalNote (for Legal-category tasks) or ClaimNote (otherwise) when the task was flagged to be saved to the notepad.
  • Adjusts a requested task date to the next/previous working day using IWorkCalendarService.
  • Reports whether a claim number is valid, whether a user can edit tasks, and whether a claim has associated imaging media.
  • Produces a printable PDF of the filtered task list and an "additional info" task lookup per claim/case.

Context

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

Public members

Member Signature Purpose
ValidGroups public IEnumerable<string> ValidGroups { get; } The set of recognized group mail IDs (from the LegalActivities.ValidGroups config setting) that bypass per-user edit-authorization checks.
LegalActivityCategory public const string LegalActivityCategory = "LGLT" Task-category code identifying a legal-source activity tied to a legal case.
ClaimActivityCategory public const string ClaimActivityCategory = "CLMM" Task-category code identifying a claim-source activity tied to a claim rather than a legal case.
ImageLegalActivityCategory public const string ImageLegalActivityCategory = "LEGAL" Task-category code identifying an imaging-sourced legal document activity.
ImageClaimActivityCategory public const string ImageClaimActivityCategory = "CLAIM" Task-category code identifying an imaging-sourced claim document activity.
AdditionalInfoTask public const string AdditionalInfoTask = "INFO" Reserved task-user value identifying the special "additional info" placeholder task, which is exempt from normal date/authorization rules.
AccessResourseForSecuredClaims public const string AccessResourseForSecuredClaims = "LNSecured" Authorization key checked to grant access to conflict- and security-restricted claims.
LegalTaskService (constructor) public LegalTaskService(IUnitOfWork unitOfWork, IUserProfileService userProfileService, IDocumentService documentService, IValidationService validationService, IClaimInformationService claimInformationService, IEnvironmentService environmentService, IPolicyInformationService policyInformationService, IImagingClient imagingClient, ILogService logService, IWorkCalendarService workCalendarService, IClaimQueryProvider claimQueryProvider, IWorkerQueryProvider workerQueryProvider, ICCClaimApiService claimApiService, IClaimDataApiClient gwClaimDataApiClient) Wires the full set of collaborators used across task queries, mutations, imaging lookups, and claim/policy data; captures the current user's note preferences and conflict/secure-access flags, and parses ValidGroups from configuration.
GetTaskById public LegalTask GetTaskById(long id) Returns the task mapped to LegalTask, with its claim data resolved via ICCClaimApiService.GetClaim.
GetTaskGroups public IEnumerable<TaskGroup> GetTaskGroups() Returns all configured task groups.
GetNoteCategories public IEnumerable<Core.Contracts.Legal.Notes.NoteCategory> GetNoteCategories() Returns all legal note categories ordered by description, with a blank placeholder entry prepended.
GetManualEntryCategories public IEnumerable<TaskCategory> GetManualEntryCategories() Returns the task categories eligible for manual entry (Legal or Image-Legal category codes).
GetTasks public IEnumerable<LegalTask> GetTasks(LegalTaskFilter filter) Returns up to 300 filtered, flattened tasks (Legal/Image sources, excluding "additional info" tasks) matching the claim/case/user/policy/date/activity-view filters, each enriched with claim, worker-name masking, policy, and imaging-document metadata; returns an empty list for unrecognized assigned-group filters or when neither a user nor a resolvable claim number is supplied.
GetAdditionalInfoTask public LegalTask GetAdditionalInfoTask(string claimNumber, long caseId) Returns the most recent non-deleted "additional info" task for the given claim/case context, or an empty LegalTask if none exists.
GetClaimDocumentURL public string GetClaimDocumentURL(string claimNumber) Returns the OnBase URL for viewing a claim's documents, or null (logging the exception) if the URL cannot be constructed.
GetCaseDocumentURL public string GetCaseDocumentURL(long caseId) Returns the OnBase URL for viewing a legal case's documents, or null (logging the exception) if the URL cannot be constructed.
CanUserEdit public bool CanUserEdit(string userId) Returns whether the given (non-blank) user ID holds LNUpdate authorization.
IsValidClaim public bool IsValidClaim(string claimNum) Returns whether the claim number resolves to a claim with a positive ID.
IsValidWorkDate public bool IsValidWorkDate(DateTime workDate) Returns whether the date is between today and two years in the future.
GetClaimWorkerName public string GetClaimWorkerName(string claimNum) Returns the claim's worker name formatted to standard last-name-first order, or the masked placeholder ("Confidential") if the claim is restricted/secured and the current user lacks the corresponding access.
CreateTaskStateless public long CreateTaskStateless(LegalTaskEdit task, IMessageContainer messages) Builds and validates a new task, persists it (in its own transaction) if valid, and returns the new task ID, or 0 if validation fails.
CreateTask public LegalTask CreateTask(LegalTaskEdit task, IMessageContainer messages) Builds and validates a new task inside a transaction, persists it if valid, and returns the freshly reloaded LegalTask (via GetTaskById); returns the unpersisted mapped task if validation fails.
UpdateTask public bool UpdateTask(long id, ref LegalTaskEdit task, IMessageContainer messages) Updates the existing task's fields (context key, date, text with unicode replacement unless the claim is restricted, priority, category, note category) inside a transaction with an optimistic-concurrency check on UpdateNumber; completes the task (converting it to a note) if task.IsComplete is set, and commits only if validation and completion both succeed. Sets task.IsRefreshRequired when key display fields changed.
DeleteTask public bool DeleteTask(long id, IMessageContainer messages) Marks the task deleted inside a transaction, converting it to a note first if it was flagged to be saved to the notepad; adds an authorization error and returns false if the current user lacks conflict/secure access to a restricted/secured claim.
CompleteTasks public void CompleteTasks(long[] ids, IMessageContainer messages) Completes each listed task (converting completed tasks to notes) inside a single shared transaction.
DeleteTasks public void DeleteTasks(long[] ids) Soft-deletes each listed task (converting notepad-flagged tasks to notes) inside a single shared transaction.
ReassignTasks public void ReassignTasks(long[] ids, string newTaskUser, DateTime newTaskDate, Boolean? newPriority, string newText) Bulk-updates assigned user, work-calendar-adjusted date, priority, and (for image-linked, non-masked-worker tasks only) text across the listed tasks inside a single transaction.
PrintTasks public byte[] PrintTasks(LegalTaskFilter filter) Generates a PDF of the filtered task list via IDocumentService.GeneratePdf, using an XML representation of the filtered/sorted tasks.
AdjustTaskDate public DateTime AdjustTaskDate(DateTime dueDate) Returns dueDate unchanged if it is DateTime.MinValue; otherwise returns it unchanged if it is a working day, or rolls it back to the previous working day via IWorkCalendarService.
HasMedia public bool HasMedia(long claimId) Returns whether the claim has associated imaging media of the CLAIM document-type group.

Behavioral notes

  • A static constructor calls AutoMapperBootStrapper.Configure(), registering the AutoMapper mappings this service relies on once per process.
  • GetTasks flattens task data into ClaimTaskData before mapping, explicitly noting in an inline comment that this improves performance versus mapping the full EF entity graph, then performs a single bulk claim lookup (IClaimDataApiClient.GetClaims) for all distinct claim IDs in the result set rather than one call per task.
  • Worker names are masked to "Confidential" when a claim/task is restricted (conflict worker) or secured and the current user lacks the corresponding LNSecured-derived access, unless IClaimInformationService.HasSecurityOverride grants an override for that user.
  • Imaging-document lookups (GetAlertDocuments/GetImagesInBatchesAsync) are batched in chunks of 1000 image IDs per IImagingClient.GetImages call, grouped by document-type group (EAIP, LEGAL, CLAIM), with per-batch exceptions logged rather than propagated.
  • CompleteTask refuses to complete an LEGAL-category task that has no LegalNoteCategory set, adding a validation error instead.
  • CreateTaskNote/task completion routes the resulting note to a LegalNote (attached to the task's legal case) for Legal-category tasks, or a ClaimNote (category LEGAL, type UPDT) otherwise; for inmate or secured claims (via a locally constructed Claim domain object), the note's create-user is overridden to the claim's responsible adjuster's mail ID. Throws ApplicationException if the current user's note preferences have no CategoryCode configured.
  • TaskTextCanBeBulkUpdated (used by ReassignTasks) only allows bulk text updates for image-linked tasks whose claim worker name is not currently masked.

Constraints and usage notes

  • All constructor parameters except imagingClient's name-typo-free validation are null-checked via Enforce.ArgumentNotNull (all twelve listed dependencies plus imagingClient/workCalendarService/etc. are checked); documentService is checked but not stored under a null-checked alias mismatch.*
  • The class carries a CA1506:AvoidExcessiveClassCoupling suppression, reflecting its dependency on a very large number of query providers, API clients, and services.*
  • GetTasks hard-caps results at 300 rows (.Take(300)) after applying filters, regardless of how many tasks match.

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/Tasks/LegalTaskService.cs