Audit condition history tracking¶
clsAuditConditionHistory preserves a longer-lived record of an audit condition than the working US_AUDIT_CONDITION table, keyed by policy unit sequence number, claim ID, and the audit condition description text, tracking when it was first created and last updated. This operation covers the object's create/insert/retrieve/update lifecycle and the collection's retrieval of all history rows for a given policy unit and claim.
| Field | Value |
|---|---|
| Operation ID | OP-US-05 |
| Trigger | clsAuditConditionHistory.NewAuditConditionHistory / GetAuditConditionHistory, followed by property edits and Save(), or clsAuditConditionHistoryCollection.GetAuditConditionHistoryByPolicyUnitClaimId |
| Inputs | Policy unit sequence number, claim ID, audit condition description, edit type code, error flag |
| Outputs | Persisted US_AUDIT_CONDITION_HISTORY row; populated clsAuditConditionHistory or clsAuditConditionHistoryCollection |
| Primary components | clsAuditConditionHistory.BeforeInsert/AfterInsert, clsAuditConditionHistory.BeforeRetrieve/AfterRetrieve, clsAuditConditionHistory.BeforeUpdate/AfterUpdate, clsAuditConditionHistoryCollection.BeforeRetrieve/AfterRetrieve |
| Entry point | Business\SAIF.Business.UnitStat\clsAuditConditionHistory.vb, Business\SAIF.Business.UnitStat\clsAuditConditionHistoryCollection.vb |
Steps¶
- Create.
NewAuditConditionHistory(dataPortal)creates a blank object (there is no customCreate()override, so no key value is pre-populated); the caller is responsible for settingPolicyUnitSeqNum,ClaimID, andAuditConditionDescriptionbefore save. - Validate.
Save()runsValidAuditDescription, requiringAuditConditionDescription.Length <> 0. - On failure: the broken-rule collection blocks the save.
- Insert.
BeforeInsertbinds all columns, includingCreateDateandLastUpdateDatefrom whatever values the caller has already set on the object (there is no automatic stamping to "now" inBeforeInsert, unlike other insert paths in this library) (SQL-002, US_AUDIT_CONDITION_HISTORY).AfterInsertchecks rows affected: - If
RowsAffected <> 1: addsInsertErrorwith the literal "Insert Failed" message. - Otherwise:
MarkOld(). - Retrieve single history record.
GetAuditConditionHistory(dataPortal, policyUnitSeqNum, claimId, auditMessage)selects by the composite key (policy unit sequence number, claim ID, audit condition description) (SQL-010).AfterRetrievefills the object when a row is found and always callsMarkOld(). - Retrieve history collection.
clsAuditConditionHistoryCollection.GetAuditConditionHistoryByPolicyUnitClaimId(dataPortal, policyUnitSeqNum, claimId, message)selects by the same composite key, returning every matching row (SQL-011). - Update (object level).
BeforeUpdatesets the in-memoryLastUpdateDateproperty toToday, but the bound SQL statement itself setsLAST_UPDATE_DATE = trim(sysdate)(a server-side expression) rather than binding a:LastUpdateDateparameter (SQL-026, US_AUDIT_CONDITION_HISTORY) — so the client-sideLastUpdateDate = Todayassignment has no effect on what is actually written; the database's own clock determines the persisted value.*AfterUpdatechecks rows affected: - If
RowsAffected <> 1: addsUpdateErrorwithclsConstants.Messages.DBContentionError(BR-US-020). - Otherwise:
MarkOld(). - Update (collection level, unused).
clsAuditConditionHistoryCollection.Criteriaseparately defines anUpdateSQLthat binds a:LastUpdateDateparameter instead of usingtrim(sysdate)(SQL-027), but the collection class has noBeforeUpdate/AfterUpdateoverride that references it, so this alternate statement is never actually executed by any code path in this library.** It is dead code as far as the documented public surface is concerned. - No orchestrating check-then-insert-or-update method. No method inside this library first attempts a retrieve and conditionally inserts or updates a history record; callers must perform that decision themselves (for example, retrieving via
GetAuditConditionHistoryand checking whether the result is new/blank before deciding to insert or update).*
Process flow¶
flowchart TD
Start([Caller creates, retrieves,<br>or updates audit-condition history]) --> Which{Create, retrieve one,<br>retrieve collection,<br>or update?}
Which -->|Create| Blank[Create blank object;<br>caller sets composite key]
Blank --> ValidateDesc{AuditConditionDescription<br>non-empty?}
ValidateDesc -->|No| Blocked([Broken rule blocks save])
ValidateDesc -->|Yes| Insert[Insert US_AUDIT_CONDITION_HISTORY<br>row using caller-set dates]
Insert --> InsRows{RowsAffected = 1?}
InsRows -->|No| InsErr([InsertError: Insert Failed])
InsRows -->|Yes| MarkOldA([MarkOld])
Which -->|Retrieve one| RetOne[Select by PolicyUnitSeqNum,<br>ClaimID, AuditConditionDescription]
RetOne --> FillOne[Fill object if found;<br>MarkOld regardless]
Which -->|Retrieve collection| RetAll[Select all rows by<br>PolicyUnitSeqNum, ClaimID,<br>AuditConditionDescription]
Which -->|Update| SetToday[Set LastUpdateDate = Today<br>on the in-memory object]
SetToday --> DBWrite[SQL sets LAST_UPDATE_DATE<br>= trim sysdate, ignoring<br>the client-side value]
DBWrite --> UpdRows{RowsAffected = 1?}
UpdRows -->|No| Contention([UpdateError: DB contention])
UpdRows -->|Yes| MarkOldB([MarkOld])
Failure and edge-case behavior¶
- The object's
BeforeInsertdoes not stampCreateDate/LastUpdateDateautomatically; both must already be set on the object by the caller beforeSave(), unlike the automaticUpdateUser/UpdateDatestamping seen elsewhere in the library.* - The object-level update writes
LAST_UPDATE_DATE = trim(sysdate)server-side; settingLastUpdateDateon the .NET object before callingSave()has no observable effect on the persisted value, since that property is never bound as a SQL parameter in the update statement.* - The collection-level
UpdateSQL(bound:LastUpdateDateparameter) is defined but never invoked by anyBeforeUpdate/AfterUpdateoverride inclsAuditConditionHistoryCollection, making it unreachable dead code as currently written.** - No method in this library encapsulates "retrieve, then insert if missing or update if present" logic for a history record; that orchestration, if it exists, lives outside this library's traced source.**
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\clsAuditConditionHistory.vbBusiness\SAIF.Business.UnitStat\clsAuditConditionHistoryCollection.vb