---
title: 801 document management
summary: Creates, updates, and retrieves Online 801 document metadata rows through the PK82538_ONLINE_801_CLAIM Oracle package.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-07-30
library: SAIF.Business.Claim.Entry
reference_type: package
operation_id: OP-CE-11
trigger: cls801Document CRUD lifecycle and cls801DocumentCollection retrieval
---

# 801 document management

Each Online 801 electronic submission can have one or more supporting documents (images) attached to it. `cls801Document` tracks the metadata for each document — file name, document type, and the sequence number that ties it back to `CL_801_DOCUMENT` — while the actual document content is managed elsewhere. Document delete is present in code but not operational.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-CE-11 |
| **Trigger** | `cls801Document` CRUD lifecycle (`BeforeCreate`, `BeforeInsert`, `BeforeUpdate`) and `cls801DocumentCollection` retrieval |
| **Inputs** | `ClaimID`, `ImageSeqNum`, `FileName`, `DocTypeCode`, `LastUpdateNum` |
| **Outputs** | Persisted `CL_801_DOCUMENT` row, or a retrieved/sorted document collection |
| **Primary components** | `cls801Document.BeforeCreate`, `cls801Document.BeforeInsert`, `cls801Document.BeforeUpdate`, `cls801DocumentCollection` |
| **Entry point** | `Business\SAIF.Business.Claim.Entry\Online801\Submission\cls801Document.vb` |

## Steps

1. **Reserve a document sequence number.** `BeforeCreate` issues a scalar stored-procedure call to obtain the next `ImageSeqNum` value ([SQL-003](../sql/SQL-003.md)).
2. **Insert the document metadata row.** `BeforeInsert` binds `ClaimID`, `ImageSeqNum`, `FileName`, and `DocTypeCode`, and issues the insert through `PK82538_ONLINE_801_CLAIM.document_insert` ([SQL-011](../sql/SQL-011.md), [CL_801_DOCUMENT](../database-tables.md#cl_801_document)).
3. **Update the document metadata row under version checking** ([BR-PROC-003](../business-rules.md#br-proc-003-document-updates-are-version-checked-with-lastupdatenum)). `BeforeUpdate` binds the caller-supplied `LastUpdateNum` alongside the updated fields, and the underlying procedure call rejects the update unless the supplied version matches the current row ([SQL-023](../sql/SQL-023.md), [CL_801_DOCUMENT](../database-tables.md#cl_801_document)).
   - If the rows-affected value is not `1`: add an `UpdateError` broken rule ([BR-CE-011](../business-rules.md#br-ce-011-optimistic-concurrency-update-fails-if-rowsaffected-1)).
4. **Retrieve and sort documents for a claim.** `cls801DocumentCollection` calls `document_select` (or `document_select_by_imageseqnum` for a single document) to load the document metadata rows tied to a claim, then sorts the collection for display.*
5. **Delete is prepared but not wired.** `cls801Document` prepares delete parameters, but its criteria class throws `InvalidSQLProperty` for `DeleteSQL`, so calling delete on a document object does not reach a working `document_delete` procedure call.*

## Process flow

```mermaid
flowchart TD
	Start([Caller manages an<br>Online 801 document]) --> Mode{Create, update,<br>or retrieve?}
	Mode -->|Create| Seq[Reserve next<br>ImageSeqNum]
	Seq --> Insert[Insert CL_801_DOCUMENT<br>via document_insert]
	Mode -->|Update| Update[Update row via<br>document_update, checking LastUpdateNum]
	Update --> Rows{RowsAffected = 1?}
	Rows -->|No| Conflict([Raise UpdateError])
	Rows -->|Yes| Done([Document updated])
	Mode -->|Retrieve| Select[Call document_select /<br>document_select_by_imageseqnum]
	Select --> Sort[Sort document collection]
	Sort --> Return([Return document<br>collection])
	Insert --> Return
```

## Failure and edge-case behavior

- Deleting Online 801 documents is not operational: the criteria class throws `InvalidSQLProperty` for `DeleteSQL`, so no `document_delete` procedure is wired despite delete parameters being prepared in `cls801Document`.*
- `document_select` and `document_select_by_imageseqnum` are not individually catalogued as `SQL-*` documents in this run; they are traced from `cls801DocumentCollection` call sites rather than linked to a numbered SQL catalog entry.*
- Version checking on update relies entirely on the caller supplying an accurate `LastUpdateNum` ([BR-PROC-003](../business-rules.md#br-proc-003-document-updates-are-version-checked-with-lastupdatenum)); a stale value produces the same `UpdateError` broken rule as a genuine concurrent edit.

## Related documentation

- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [SQL catalog](../sql/index.md)
- [Database tables](../database-tables.md)

> **Note:** Statements marked with `*` were inferred from code structure, naming
> conventions, or contextual evidence where direct confirmation was not available
> in source artifacts.

## Sources

- `Business\SAIF.Business.Claim.Entry\Online801\Submission\cls801Document.vb`
