Audit condition maintenance¶
An audit condition records a data-quality edit finding (rate, source, ARD, exposure, or loss discrepancy) raised against a policy unit during Unit Stat processing. This operation covers clsAuditCondition's create/insert/retrieve lifecycle, clsAuditConditionCollection's multi-shape retrieval and error-flag evaluation, and the collection's shared bulk-delete functions used to clear conditions before a re-audit.
| Field | Value |
|---|---|
| Operation ID | OP-US-04 |
| Trigger | clsAuditCondition.NewAuditCondition / GetAuditCondition, clsAuditConditionCollection.GetAuditConditions / GetPolicyPeriodAudits / GetPolicyUnitAudits / GetUpdateUserAudits, or any of the shared Delete* functions |
| Inputs | Policy unit sequence number, exposure summary sequence number, claim ID, audit condition description, edit type code, error flag, policy number, policy period effective date, update user |
| Outputs | Persisted US_AUDIT_CONDITION row(s); populated clsAuditCondition or clsAuditConditionCollection; HasPolicyUnitErrors/HasExposureErrors/HasLossErrors booleans; rows-deleted count from bulk deletes |
| Primary components | clsAuditCondition.Create, clsAuditCondition.BeforeInsert/AfterInsert, clsAuditCondition.BeforeRetrieve/AfterRetrieve, clsAuditConditionCollection.BeforeRetrieve/AfterRetrieve, clsAuditConditionCollection.Delete* shared functions |
| Entry point | Business\SAIF.Business.UnitStat\clsAuditCondition.vb, Business\SAIF.Business.UnitStat\clsAuditConditionCollection.vb |
Steps¶
- Create.
NewAuditCondition(dataPortal)invokesCreate(), which allocatesAuditConditionSeqNumfrom theUS_AUDIT_CONDITION_SEQsequence. - Validate.
Save()runsValidAuditDescription, requiringAuditConditionDescription.Length <> 0. - On failure: the broken-rule collection blocks the save.
- Insert.
BeforeInsertstampsUpdateUser/UpdateDateand binds every column (SQL-001, US_AUDIT_CONDITION).AfterInsertchecks rows affected: - If
RowsAffected <> 1: addsInsertErrorwith the literal "Insert Failed" message. - Otherwise:
MarkOld(). - No update or delete path exists on the individual
clsAuditConditionobject; corrections are made by deleting and re-inserting via the collection's shared delete functions (step 7) followed by a fresh audit run. - Retrieve single audit condition.
GetAuditCondition(dataPortal, auditConditionSeqNum)selects by sequence number (SQL-005).AfterRetrievefills the object when a row is found and always callsMarkOld(). - Retrieve audit-condition collection.
Criteria.RetrieveSQLdispatches onRetrieveType: GetAuditConditions(dataPortal, policyNumber, policyPeriodEffectiveDate)— despite accepting a policy number and period, this factory constructsNew Criteria(dataPortal)(the all-rows constructor), so the two arguments are silently ignored and every audit condition in the table is returned (SQL-006).*GetPolicyPeriodAudits(dataPortal, policyNumber, policyPeriodEffectiveDate)— the correct policy-period-scoped retrieval, filtering to policy units belonging to the given policy and period (SQL-007).GetPolicyUnitAudits(dataPortal, policyUnitSeqNum)— filters to a single policy unit (SQL-008); this is the retrieval used to lazily load a policy unit'sAuditConditionschild collection (see Policy unit CRUD).GetUpdateUserAudits(dataPortal, updateUser)— constructs a criteria withRetrieveType = RetrieveTypes.UpdateUser, but bothCriteria.IsRetrieveByPolicyUnitandCriteria.IsRetrieveByUpdateUsertestRetrieveType = RetrieveTypes.PolicyUnit, so neither branch (nor any other) inRetrieveSQL's dispatch matches anUpdateUserretrieve type; the call falls through to theElsebranch and raises anApplicationException* rather than returning results.- Collection error-flag evaluation.
HasPolicyUnitErrors,HasExposureErrors, andHasLossErrorsare computed in memory over an already-loaded collection (no additional query):HasPolicyUnitErrorsis true if any member has bothExposureSummarySeqNumandClaimIDpopulated (BR-US-024);HasExposureErrorsis true if any member hasExposureSummarySeqNumpopulated;HasLossErrorsis true if any member hasClaimIDpopulated. - Bulk delete. The shared functions on
clsAuditConditionCollectionbuild parameterizedDELETE US_AUDIT_CONDITIONstatements from combinations of the WHERE-clause fragments and return the affected row count: DeletePolicyPeriodAudits(dataPortal, policyNumber, policyPeriodEffectiveDate)— deletes all conditions for policy units in the policy period, with no edit-type filter (SQL-031).DeletePolicyPeriodExposureAudits/ one overload ofDeletePolicyPeriodLossAuditsroute throughDeletePolicyPeriodAuditsByEditType(dataPortal, policyNumber, policyPeriodEffectiveDate, editType)— deletes conditions for the policy period filtered to a specific edit type (Constants.EXPOSURE_AUDITorConstants.CLAIM_AUDIT) (SQL-032).- The other
DeletePolicyPeriodLossAuditsoverload routes throughDeletePolicyUnitAuditsByType(dataPortal, policyUnitSeqNum, editType)— deletes conditions for a single policy unit filtered to a specific edit type (SQL-033). DeleteAllAuditsByType(dataPortal, editTypeCode)— deletes every condition of a given edit type across all policy units, with no policy-period or policy-unit scoping (SQL-030).
Process flow¶
flowchart TD
Start([Caller creates, retrieves,<br>or deletes audit conditions]) --> Which{Create, retrieve one,<br>retrieve collection,<br>or bulk delete?}
Which -->|Create| Seq[Allocate AuditConditionSeqNum<br>from US_AUDIT_CONDITION_SEQ]
Seq --> ValidateDesc{AuditConditionDescription<br>non-empty?}
ValidateDesc -->|No| Blocked([Broken rule blocks save])
ValidateDesc -->|Yes| Insert[Insert US_AUDIT_CONDITION row]
Insert --> InsRows{RowsAffected = 1?}
InsRows -->|No| InsErr([InsertError: Insert Failed])
InsRows -->|Yes| MarkOldA([MarkOld])
Which -->|Retrieve one| RetOne[Select by AuditConditionSeqNum]
RetOne --> FillOne[Fill object if found;<br>MarkOld regardless]
Which -->|Retrieve collection| RetKind{Which factory method?}
RetKind -->|GetAuditConditions| RetAllBug([Returns ALL rows;<br>policy number/period args ignored])
RetKind -->|GetPolicyPeriodAudits| RetPeriod[Select by policy period]
RetKind -->|GetPolicyUnitAudits| RetUnit[Select by policy unit]
RetKind -->|GetUpdateUserAudits| RetUserBug([Dispatch falls through:<br>ApplicationException raised])
Which -->|Bulk delete| DelKind{Which shared function?}
DelKind -->|DeletePolicyPeriodAudits| DelPeriod[Delete by policy period]
DelKind -->|DeletePolicyPeriodAuditsByEditType| DelPeriodType[Delete by policy period<br>and edit type]
DelKind -->|DeletePolicyUnitAuditsByType| DelUnitType[Delete by policy unit<br>and edit type]
DelKind -->|DeleteAllAuditsByType| DelAllType[Delete by edit type<br>across all policy units]
Failure and edge-case behavior¶
GetAuditConditions(dataPortal, policyNumber, policyPeriodEffectiveDate)silently ignores both of its parameters and retrieves everyUS_AUDIT_CONDITIONrow in the table, because its implementation constructsNew Criteria(dataPortal)(the all-rows constructor) instead of the policy-period constructor used byGetPolicyPeriodAudits; callers of this specific overload should useGetPolicyPeriodAuditsinstead to get policy-period-scoped results.*GetUpdateUserAuditsraises anApplicationException(InvalidSQLProperty) at retrieve time rather than returning update-user-scoped results, becauseCriteria.IsRetrieveByPolicyUnitandCriteria.IsRetrieveByUpdateUserboth compareRetrieveTypeagainstRetrieveTypes.PolicyUnit, so aRetrieveTypes.UpdateUsercriteria never matches any dispatch branch inRetrieveSQL.*- There is no object-level update or delete on
clsAuditCondition; corrections are performed exclusively through the collection's bulkDelete*shared functions followed by re-insertion of corrected conditions. - Insert failures use the literal "Insert Failed" message rather than the shared
DBContentionErrormessage used elsewhere in the library for update/delete contention. - The three
Has*Errorsproperties operate only on whatever audit conditions are already loaded into the collection instance; they do not re-query the database, so a stale in-memory collection can yield stale error results.
Related documentation¶
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¶
Business\SAIF.Business.UnitStat\clsAuditCondition.vbBusiness\SAIF.Business.UnitStat\clsAuditConditionCollection.vb