Skip to content

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

  1. Create. NewAuditConditionHistory(dataPortal) creates a blank object (there is no custom Create() override, so no key value is pre-populated); the caller is responsible for setting PolicyUnitSeqNum, ClaimID, and AuditConditionDescription before save.
  2. Validate. Save() runs ValidAuditDescription, requiring AuditConditionDescription.Length <> 0.
  3. On failure: the broken-rule collection blocks the save.
  4. Insert. BeforeInsert binds all columns, including CreateDate and LastUpdateDate from whatever values the caller has already set on the object (there is no automatic stamping to "now" in BeforeInsert, unlike other insert paths in this library) (SQL-002, US_AUDIT_CONDITION_HISTORY). AfterInsert checks rows affected:
  5. If RowsAffected <> 1: adds InsertError with the literal "Insert Failed" message.
  6. Otherwise: MarkOld().
  7. 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). AfterRetrieve fills the object when a row is found and always calls MarkOld().
  8. Retrieve history collection. clsAuditConditionHistoryCollection.GetAuditConditionHistoryByPolicyUnitClaimId(dataPortal, policyUnitSeqNum, claimId, message) selects by the same composite key, returning every matching row (SQL-011).
  9. Update (object level). BeforeUpdate sets the in-memory LastUpdateDate property to Today, but the bound SQL statement itself sets LAST_UPDATE_DATE = trim(sysdate) (a server-side expression) rather than binding a :LastUpdateDate parameter (SQL-026, US_AUDIT_CONDITION_HISTORY) — so the client-side LastUpdateDate = Today assignment has no effect on what is actually written; the database's own clock determines the persisted value.* AfterUpdate checks rows affected:
  10. If RowsAffected <> 1: adds UpdateError with clsConstants.Messages.DBContentionError (BR-US-020).
  11. Otherwise: MarkOld().
  12. Update (collection level, unused). clsAuditConditionHistoryCollection.Criteria separately defines an UpdateSQL that binds a :LastUpdateDate parameter instead of using trim(sysdate) (SQL-027), but the collection class has no BeforeUpdate/AfterUpdate override 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.
  13. 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 GetAuditConditionHistory and 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 BeforeInsert does not stamp CreateDate/LastUpdateDate automatically; both must already be set on the object by the caller before Save(), unlike the automatic UpdateUser/UpdateDate stamping seen elsewhere in the library.*
  • The object-level update writes LAST_UPDATE_DATE = trim(sysdate) server-side; setting LastUpdateDate on the .NET object before calling Save() 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 :LastUpdateDate parameter) is defined but never invoked by any BeforeUpdate/AfterUpdate override in clsAuditConditionHistoryCollection, 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.**

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.vb
  • Business\SAIF.Business.UnitStat\clsAuditConditionHistoryCollection.vb