Skip to content

PolicyOutputDocumentRepository

PolicyOutputDocumentRepository is the RepositoryBase<PolicyOutputDocument> implementation behind agency document delivery: it eager-fetches OutputDocument/DocumentType, Policy/SubmissionPolicies, and Policy/RelationshipPolicy for every read, and composes the query-scoping extension methods on PolicyOutputDocumentExtensions (documented separately) to answer agency-inbox, released/held/pending, and parent/child document queries. Agency-visibility scoping (AgencyViewable, AgencyInboxViewable, category/producer/agency filters) restricts results by caller-supplied ids that are not independently validated against the current user at this layer (DLA-SDN-03, Security and authorization).

Purpose

  • Retrieve policy output documents by id, source key text, or image id, and enumerate unreleased documents prior to a release date.
  • Serve agency document-inbox queries with an Unread/All/Deleted filter, per SDN-BR-060.
  • Restrict agency-facing queries to released, agency-viewable documents (or held/pending variants for specific views), per SDN-BR-061.
  • Detect duplicate documents before creation (CheckDocumentExist) and return a released parent document's agency-viewable children, enforcing that the parent is released (SDN-BR-063).

Context

  • Namespace: SAIF.Data.NHibernate.Repositories.OutputDocuments
  • Assembly/package: SAIF.Data.NHibernate (ships inside the SAIF.SAIFCode.Core NuGet package)
  • Base class: RepositoryBase<PolicyOutputDocument> from SAIF.Framework.Data.NHibernate (external, resolved via Legends CLI — see Inherited public members below).
  • Implements: IPolicyOutputDocumentRepository, defined in SAIF.Data.Interfaces.Repositories.OutputDocuments.
  • Collaborator: this type composes filter methods from PolicyOutputDocumentExtensions, declared in the same source file.

Public members

Member Signature Purpose
PolicyOutputDocumentRepository(NHibernateUnitOfWork) public PolicyOutputDocumentRepository(NHibernateUnitOfWork uow) Constructor; passes uow to the RepositoryBase<PolicyOutputDocument> base and retains it (as _uow) to obtain the Policy repository in GetAccountNumber.
GetUnReleasedDocumentsPriorToDate public IEnumerable<PolicyOutputDocument> GetUnReleasedDocumentsPriorToDate(DateTime releaseDate) Returns eager-loaded documents in Pending status whose OutputDocument.DocumentDate is before releaseDate, ordered by policy number then id (SQL-036).
GetPolicyOutputDocument public PolicyOutputDocument GetPolicyOutputDocument(long documentId) Returns the PolicyOutputDocument for documentId via the inherited Get(object id), or null if not found (SQL-037).
GetPolicyOutputDocumentsBySourceKeyText public IEnumerable<PolicyOutputDocument> GetPolicyOutputDocumentsBySourceKeyText(string sourceKeyText) Returns eager-loaded documents whose OutputDocument.PolicyOutputDocument.SourceKeyText equals sourceKeyText (SQL-038).
GetPolicyOutputDocumentsByImageId public IEnumerable<PolicyOutputDocument> GetPolicyOutputDocumentsByImageId(long imageId) Returns eager-loaded documents whose OutputDocument.ImageId equals imageId (SQL-039).
GetHeldDocumentsForNotification public IEnumerable<PolicyOutputDocument> GetHeldDocumentsForNotification() Returns documents in Held status where HoldTaskId is null and TaskUser is not null — i.e. held documents awaiting a notification task to be created (SQL-040).
GetReleasedAgencyViewablePolicyOutputDocuments (long) public IEnumerable<PolicyOutputDocument> GetReleasedAgencyViewablePolicyOutputDocuments(long policyNumber) Returns eager-loaded, released, agency-viewable documents for the policy number or its account (SDN-BR-061, SQL-041).
GetReleasedAgencyViewablePolicyOutputDocuments (long, string) public IEnumerable<PolicyOutputDocument> GetReleasedAgencyViewablePolicyOutputDocuments(long policyNumber, string documentCategory) Same as the single-parameter overload, additionally filtered to documentCategory via ForCategory (blank/"ALL" means no filter, SDN-BR-062) (SQL-041).
GetHeldAndPendingAgencyViewablePolicyOutputDocuments public IEnumerable<PolicyOutputDocument> GetHeldAndPendingAgencyViewablePolicyOutputDocuments(long policyNumber) Resolves the policy's account number, then returns eager-loaded, agency-viewable documents in Held or Pending status for the policy or account (SQL-042).
GetPolicyOutputDocumentsForInbox (4-arg) public IEnumerable<PolicyOutputDocument> GetPolicyOutputDocumentsForInbox(ShowOnlyDocuments showOnlyDocuments, DateTime releaseDate, long agencyId) Returns agency-inbox-viewable, released-on-or-after, agency-scoped documents, with showOnlyDocuments selecting NonViewed+NotAgencyDeleted (Unread, and the default case), NotAgencyDeleted only (All), or AgencyDeleted (Deleted) (SDN-BR-060, SQL-043).
GetPolicyOutputDocumentsForInbox (5-arg) public IEnumerable<PolicyOutputDocument> GetPolicyOutputDocumentsForInbox(ShowOnlyDocuments showOnlyDocuments, DateTime releaseDate, long agencyId, long producerId) Same as the 4-argument overload, additionally filtered to producerId via ForProducer (SQL-043).
GetPolicyOutputDocuments public IEnumerable<PolicyOutputDocument> GetPolicyOutputDocuments(long policyNumber, DateTime documentDate, DateTime releaseDate) Returns released, agency-viewable documents for the policy/account matching both documentDate and releaseDate exactly (SQL-044).
CheckDocumentExist public bool CheckDocumentExist(PolicyOutputDocument document, string documentTypeCode) Returns true if a released document already exists for the same relationship-policy number, PolicyPeriodEffectiveDate, documentTypeCode, ReleaseDate, and OutputDocument.DocumentDate as document — used to prevent duplicate document creation (SQL-045).
GetReleasedAgencyViewableChildOutputDocuments public IEnumerable<PolicyOutputDocument> GetReleasedAgencyViewableChildOutputDocuments(PolicyOutputDocument doc) Returns agency-viewable, released child documents of doc's relationship-policy, matching doc's release date and document date; throws Exception("Document does not is released!") if doc.ReleaseDate is null (SDN-BR-063, SQL-046).

Inherited public members

Members in this section are inherited from RepositoryBase<PolicyOutputDocument> in SAIF.Framework.Data.NHibernate. They are available on this type through inheritance.

Member Signature Purpose Origin
Add public void Add(PolicyOutputDocument entity) Registers a new PolicyOutputDocument entity for insertion on the next unit-of-work commit.† SAIF.Framework.Data.NHibernate — RepositoryBase<PolicyOutputDocument>
Update public void Update(PolicyOutputDocument entity) Marks an existing PolicyOutputDocument entity as modified for the next unit-of-work commit.† SAIF.Framework.Data.NHibernate — RepositoryBase<PolicyOutputDocument>
Delete public void Delete(PolicyOutputDocument entity) Registers a PolicyOutputDocument entity for deletion on the next unit-of-work commit.† SAIF.Framework.Data.NHibernate — RepositoryBase<PolicyOutputDocument>
Query public IQueryable<PolicyOutputDocument> Query() Returns a LINQ-queryable session projection over PolicyOutputDocument, used as the basis for EagerLoadQuery() and every filtered query above.† SAIF.Framework.Data.NHibernate — RepositoryBase<PolicyOutputDocument>
Get public PolicyOutputDocument Get(object id) Loads a PolicyOutputDocument by primary key, returning null if not found; used directly by GetPolicyOutputDocument.† SAIF.Framework.Data.NHibernate — RepositoryBase<PolicyOutputDocument>
Load public PolicyOutputDocument Load(object id) Loads a PolicyOutputDocument by primary key as a (possibly proxied) reference, throwing if not found.† SAIF.Framework.Data.NHibernate — RepositoryBase<PolicyOutputDocument>
SystemDate public DateTime SystemDate { get; } Current system date/time as tracked by the underlying session/unit of work.† SAIF.Framework.Data.NHibernate — RepositoryBase<PolicyOutputDocument>

Behavioral notes

  • All read methods share a common eager-fetch shape (OutputDocument→DocumentType, Policy→SubmissionPolicies, Policy→RelationshipPolicy) via the private EagerLoadQuery() helper, so N+1 query patterns are avoided for these navigation paths*.
  • Several methods resolve an "account number" for the policy (GetAccountNumber, a private helper over the injected NHibernateUnitOfWork's Policy repository) so that documents scoped to either the specific policy or its account are both returned (SQL-047).
  • agencyId/producerId/policyNumber parameters are accepted from the caller and used directly to scope the query; there is no check here that the current user is actually authorized for that agency/producer/policy (DLA-SDN-03, Security and authorization).
  • GetReleasedAgencyViewableChildOutputDocuments throws a bare Exception (not a more specific type) when the parent document is not released, which callers must catch by type Exception rather than a narrower exception type*.

Constraints and usage notes

  • GetReleasedAgencyViewableChildOutputDocuments requires doc.ReleaseDate.HasValue; pass only already-released parent documents.
  • The agency/producer/category filters composed here duplicate filter logic also present in SAIF.Data's own PolicyOutputDocumentExtensions (SD-BR-070/072) — see SDN-BR-061 for the duplication note.

Note: Statements marked with † are derived from dependency library documentation via the Legends CLI. Statements marked with * were inferred from code structure or contextual evidence. Statements marked with ** could not be confirmed; treat as unknown until verified.

Sources

  • Data/SAIF.Data.NHibernate/Repositories/OutputDocuments/PolicyOutputDocumentRepository.cs