Skip to content

DocumentManagementService

Implements IDocumentManagementService as the data-access and status-transition layer behind the document-imaging workflow: it assembles the list of documents a bill still needs imaged, updates bill/document/batch status after imaging, and formats the new-claim notification email. It delegates the actual image upload to IDocumentImager and persists changes through IUnitOfWork, with claim data resolved through ICCClaimApiService and e-billing data through IEbillingQueryProvider.

Purpose

  • Builds a BillImageRequest listing a bill's not-yet-imaged documents, flagging the request as a new claim when the bill's patient has no matching claim resolved via the claim API (GetBillImageRequest).
  • Records a patient-error note ("Claim not found - 827 sent to Fast Track.") when a new-claim document is detected (CreateNewDocumentNote).
  • Transitions a bill to the document-load status and stamps the current user/date (UpdateBillStatus), and transitions a batch to document-load status (UpdateBatchStatusToDocumentLoad).
  • Records the resulting image ID against an e-bill document after upload (UpdateDocumentImageId).
  • Formats the new-claim notification email body/attachment/subject sent when an 827 document arrives for an unmatched claim (FormatNewClaimEmail).
  • Lists the bill IDs in a batch that have not yet been imaged (GetNotYetImagedBills).
  • Delegates single- and multi-document imaging requests to IDocumentImager (ImageDocument, ImageDocuments).

Context

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

Public members

Member Signature Purpose
DocumentManagementService public DocumentManagementService(IUnitOfWork unitOfWork, IUserProfileService profileService, IEbillingQueryProvider queryProvider, IDocumentImager imager, ICCClaimApiService claimApiService) Wires the unit-of-work, current-user resolver, e-billing query provider, document imager, and claim API client, capturing the current user ID for later status stamps.
GetBillImageRequest public BillImageRequest GetBillImageRequest(long billId) Assembles the not-yet-imaged documents for a bill into a BillImageRequest, marking it as a new claim when the bill's patient exists but no matching claim is found.
CreateNewDocumentNote public void CreateNewDocumentNote(long billId) Adds a patient error note indicating the claim could not be found and the 827 was routed to Fast Track.
UpdateBillStatus public void UpdateBillStatus(long billId) Sets the bill's status to document-load and stamps the update user/date to the current user and now.
UpdateBatchStatusToDocumentLoad public void UpdateBatchStatusToDocumentLoad(long batchId) Transitions the given batch to the document-load status.
UpdateDocumentImageId public void UpdateDocumentImageId(long documentId, long imageId) Stamps a document's image ID and update user/date after it has been imaged.
FormatNewClaimEmail public void FormatNewClaimEmail(MailMessage message, long documentId, string fileName, string newClaimEmailAddress) Populates the from/to/subject/attachment/body of a new-claim notification email referencing the associated bill ID.
GetNotYetImagedBills public IEnumerable<long> GetNotYetImagedBills(long batchId) Returns the IDs of bills in a batch that still have documents pending imaging.
ImageDocument public long ImageDocument(long documentId, string sourcePath, string destinationPath, ILogWriter controlReport) Delegates to IDocumentImager.ImageDocument for a single document, supplying the captured current-user ID.
ImageDocuments public long ImageDocuments(IList<BillImageRequest.Document> documents, string sourcePath, string destinationPath, ILogWriter controlReport) Delegates to IDocumentImager.ImageDocuments for a batch of documents, supplying the captured current-user ID.

Behavioral notes

  • GetBillImageRequest calls ICCClaimApiService.GetClaim synchronously via GetAwaiter().GetResult(), blocking on the underlying async claim lookup.
  • The constructor resolves and caches the current user's ID once (_currentUser) rather than re-querying IUserProfileService on every call.
  • FormatNewClaimEmail hard-codes the sender address NoReplySystemNotification@saif.com and a fixed subject/body template.
  • CreateNewDocumentNote constructs an ErrorConditionHandler directly rather than through dependency injection.*

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/Claims/EBilling/Imaging/DocumentManagementService.cs