﻿---
title: SAIF.Business.Imaging business rules
summary: Enumerated business rules enforced by this library.
status: draft
owner: <owner>
last_reviewed: 2026-07-30
library: SAIF.Business.Imaging
reference_type: package
---

# SAIF.Business.Imaging business rules

This page captures the business rules enforced by this library.

## BR-IMG-01: EAIP specialist selection by active/new period status

| Field | Value |
| --- | --- |
| **Statement** | An EAIP claim's assigned specialist is determined by rows in `EAIP_PERIOD` where `EAIP_STATUS_CODE` is `'A'` (active) or `'N'` (new), ordered by `EAIP_PERIOD_EFF_DATE` ascending. The earliest qualifying active or new period record for a claim identifies the responsible specialist user.* |
| **Trigger** | Retrieval of the EAIP specialist for a given claim ID via `clsEAIPMessages.GetEAIPSpecialist`. |
| **Enforcement** | `clsEAIPMessages.SQLGetEAIPSpecialist` constant (`clsEAIP.vb`): `select eaip_user from eaip_period where claim_id = :inClaimID and (eaip_status_code = 'A' OR eaip_status_code = 'N') order by eaip_period_eff_date`. The WHERE clause limits rows to active/new periods; the ORDER BY clause sorts by effective date. |
| **Outcome** | The first row returned contains the `eaip_user` for the claim. If no qualifying rows exist, the caller falls back to `clsMessages.EAIP_MAILID`*. |
| **Confidence** | Inferred |
| **Tables** | [EAIP_PERIOD](database-tables.md#eaip_period) |
| **SQL** | [SQL-015](sql/SQL-015-saif-business-imaging.md) |
| **Source** | `Business\SAIF.Business.Imaging\clsEAIP.vb` |

---

## BR-IMG-02: Image index required fields

| Field | Value |
| --- | --- |
| **Statement** | When an image index record (`clsImageIdx`) has been locally modified, it must have a non-empty `ImageFileCode`, `ImageDocumentTypeCode`, `ImageCategoryCode`, and a `DocumentDate` other than `Date.MinValue`. Unmodified records are exempt from these checks. |
| **Trigger** | `IsValid`/`CheckRules` evaluation of a `clsImageIdx` instance whenever `ImageFileCode`, `ImageDocumentTypeCode`, `ImageCategoryCode`, or `DocumentDate` changes. |
| **Enforcement** | `clsImageIdx.AddBusinessRules` registers `HasImageFileCode` (`IMGIDX1`), `HasImageTypeCode` (`IMGIDX2`), `HasImageCategoryCode` (`IMGIDX3`), and `HasDocumentDate` (`IMGIDX4`); each returns `False` only `If IsLocalDirty` and the corresponding field is empty/default. |
| **Outcome** | A broken rule is added with the associated message (`MSG_REQ_IMAGE_FILE_CODE`, `MSG_REQ_IMG_DOC_TYP_CODE`, `MSG_REQ_IMG_CAT_CODE`, `MSG_REQ_DOC_DATE`), which blocks `IsValid` from returning true until corrected. |
| **Confidence** | Verified |
| **Source** | `Business\SAIF.Business.Imaging\clsImageIdx.vb` |

---

## BR-IMG-03: Image document date cannot be in the future

| Field | Value |
| --- | --- |
| **Statement** | A locally-modified image index record's `DocumentDate` cannot be later than today plus the record's configured `DocumentDateDays` tolerance (an allowed number of future days, defaulting to `0`). |
| **Trigger** | `IsValid`/`CheckRules` evaluation of a `clsImageIdx` instance whenever `DocumentDate` changes. |
| **Enforcement** | `clsImageIdx.HasFutureDocumentDate` (`IMGIDX5`) compares `DocumentDate.Date` to `Today.AddDays(DocumentDateDays)` `If IsLocalDirty`. |
| **Outcome** | If the date is too far in the future, a broken rule is added with `MSG_DOC_DATE_FUTURE` (when `DocumentDateDays = 0`) or a formatted message naming the allowed number of days.* |
| **Confidence** | Verified |
| **Source** | `Business\SAIF.Business.Imaging\clsImageIdx.vb` |

---

## BR-IMG-04: Document type must belong to the selected category and file group

| Field | Value |
| --- | --- |
| **Statement** | A locally-modified image index record's `ImageDocumentTypeCode` must exist in `IMAGE_DOCUMENT_TYPE_CODE` for the record's own `ImageCategoryCode` and `ImageFileCode` combination; otherwise the document type/category pairing is considered a mismatch. |
| **Trigger** | `IsValid`/`CheckRules` evaluation of a `clsImageIdx` instance whenever `ImageDocumentTypeCode` changes. |
| **Enforcement** | `clsImageIdx.HasCatTypeMisMatch` (`IMGIDX7`), `If IsLocalDirty`, executes [SQL-029](sql/SQL-029-saif-business-imaging.md) against [IMAGE_DOCUMENT_TYPE_CODE](database-tables.md#image_document_type_code) with `ImageDocumentTypeCode`, `ImageCategoryCode`, and `ImageFileCode`; a scalar count of `0` fails the rule. |
| **Outcome** | A broken rule is added with `MSG_CAT_TYPE_MISMATCH` ("The Doc Type must be in the Doc Category") when no matching row is found. |
| **Confidence** | Verified |
| **Tables** | [IMAGE_DOCUMENT_TYPE_CODE](database-tables.md#image_document_type_code) |
| **SQL** | [SQL-029](sql/SQL-029-saif-business-imaging.md) |
| **Source** | `Business\SAIF.Business.Imaging\clsImageIdx.vb`, `Business\SAIF.Business.Imaging\clsImageMsgConst.vb` |

---

## BR-IMG-05: External view visibility conflicts with discovery and security level

| Field | Value |
| --- | --- |
| **Statement** | An image index record cannot have its `ExternalViewCode` set to `"SHOW"` while `DiscoveryFlag = "N"` (non-discoverable), nor while `SecurityLevelNum > 0` (a secured document). |
| **Trigger** | `IsValid`/`CheckRules` evaluation of a `clsImageIdx` instance whenever `ExternalViewCode` changes. |
| **Enforcement** | `clsImageIdx.HasExternalViewCode` (`IMGIDX8`), `If IsLocalDirty`, checks both conditions in sequence and returns `False` on the first match. |
| **Outcome** | A broken rule is added with `MSG_HAS_EXTERNAL_VIEW_AND_DISCOVERY` ("Non Discoverable documents cannot be externally viewable") or `MSG_HAS_EXTERNAL_VIEW_AND_SECURE` ("Secured documents cannot be externally viewable"). |
| **Confidence** | Verified |
| **Source** | `Business\SAIF.Business.Imaging\clsImageIdx.vb`, `Business\SAIF.Business.Imaging\clsImageMsgConst.vb` |

---

## BR-IMG-06: Index batch retrieval excludes automated import batches

| Field | Value |
| --- | --- |
| **Statement** | The active-batch list retrieved for indexing excludes any `IMGSYS` batch whose `BATID` (uppercased) is `AUTOIMPORT` or `FAXIMPORT`, in addition to excluding indexed (`IDXFL <> 'N'`) or deleted (`DELCD <> ' '`) rows. |
| **Trigger** | Retrieval of the active index-batch list via `clsIndexBatchCollection.BeforeRetrieve`. |
| **Enforcement** | The collection's `RetrieveSQL` property appends `and upper(nvl(batid,' ')) not in ('AUTOIMPORT','FAXIMPORT')` to the WHERE clause alongside the `idxfl`/`delcd` filters, grouping remaining rows by batch and scan date. |
| **Outcome** | Batches created by the automated-import and fax-import processes never appear in the manual indexing batch list, even while otherwise eligible.* |
| **Confidence** | Inferred |
| **Tables** | [IMGSYS](database-tables.md#imgsys) |
| **SQL** | [SQL-032](sql/SQL-032-saif-business-imaging.md) |
| **Source** | `Business\SAIF.Business.Imaging\clsIndexBatchCollection.vb` |

---

## Notes
- Only one explicit, code-evidenced business rule ([BR-IMG-01](#br-img-01-eaip-specialist-selection-by-activenew-period-status)) was identified in the original Phase 1 analysis of this library. [BR-IMG-02](#br-img-02-image-index-required-fields) through [BR-IMG-06](#br-img-06-index-batch-retrieval-excludes-automated-import-batches) were added during the operations-and-processes redo pass after tracing `clsImageIdx`'s registered rule set (`AddBusinessRules`) and `clsIndexBatchCollection`'s retrieve criteria, both of which contain code-evidenced validation logic that was previously only summarized as generic "failure and edge-case behavior" rather than enumerated as rules.
- The `clsEAIP` class whose SQL defines [BR-IMG-01](#br-img-01-eaip-specialist-selection-by-activenew-period-status) has its BOF base-class inheritance commented out; the rule is present in live source code as a string constant but its runtime invocation path was not fully traced**.
- Additional business rule enforcement points (e.g., row-count checks in `AfterInsert`/`AfterUpdate` lifecycle methods) exist throughout the codebase but are structural BOF patterns rather than named business rules. See [Operations and processes](operations-processes.md) for details.

## Inherited business rules

`SAIF.Business.Imaging` classes inherit from `clsBusinessBase` and `clsBusinessCollectionBase` (from `SAIF.BOF.Business`). No inherited business rules from these base classes can be documented here: the Legends CLI documentation index does not contain indexed content for the BOF framework base classes, so any business rules enforced in the framework layer cannot be confirmed or enumerated from available analysis artifacts*.

## Related documentation
- [Index](index.md)
- [Overview](overview.md)
- [Architecture](architecture.md)
- [Dependencies](dependencies.md)
- [Operations and processes](operations-processes.md)
- [Database tables](database-tables.md)
- [SQL catalog](sql/index.md)
- [API reference](api/index.md)
- [Configuration](configuration.md)


> **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.Imaging\clsEAIP.vb`
- `Business\SAIF.Business.Imaging\clsImageIdx.vb`
- `Business\SAIF.Business.Imaging\clsImageMsgConst.vb`
- `Business\SAIF.Business.Imaging\clsIndexBatchCollection.vb`
