---
title: Lazy-load policy detail
summary: Lazily loads the extended policy detail block and its derived status values.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-07-31
library: SAIF.Business.View.Policy
reference_type: package
operation_id: OP-02
trigger: A detail-backed property is read for the first time
---

# Lazy-load policy detail

The policy header deliberately stays small. Chapter code, combination and wrap-up flags, current balance, entity description, group name, and similar fields are loaded only when something actually reads them. This operation performs that deferred load, along with the several derived values — coverage-bound flag, secondary status, gaps, last audit date — that each carry their own database call.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-02 |
| **Trigger** | A detail-backed property is read for the first time |
| **Inputs** | The already-loaded `clsPolicyData` instance |
| **Outputs** | Roughly twenty detail fields populated on the same instance |
| **Primary components** | `clsPolicyData.RetrievePolicyDetail`, `clsPolicyData.FillDetail` |
| **Entry point** | `Business/SAIF.Business.View.Policy/clsPolicyData.vb` |

## Steps

1. Check the detail-read guard flag. Set it immediately, before the request runs, so that the load happens at most once per instance.
   - If the flag is already set, return without any database work.
2. Build a stored procedure request for `pk72846_view_policy.getviewdetail` with the policy number and a result cursor, registering the fill routine as the after-request callback.
3. Map roughly twenty detail columns onto the instance, converting string-typed dates and numbers through the framework's smart-type wrappers.
   - Values that the procedure masks for an unprinted reduced-form period arrive as empty strings or zeros and are stored as such.
4. Swallow any failure raised during the lazy read so that the already-loaded header stays usable ([BR-014](../business-rules.md#br-014-association-date-defaults-differ-per-association-family-and-detail-load-failures-are-non-fatal)).
   - On failure the detail properties keep their empty defaults, and the caller cannot distinguish a failed load from genuinely empty data.**
5. Resolve the derived values that are not part of the detail row, each on its own first read:
   - Coverage-bound flag, through an Oracle function wrapped in a `SELECT ... FROM DUAL` ([SQL-014](../sql/SQL-014-coverage-bound-flag.md)).
   - Secondary cancellation and collection status, through the same wrapping pattern ([SQL-020](../sql/SQL-020-secondary-policy-status.md)).
   - Pending future cancellation date, from the most recent non-reinstated, non-rescinded cancellation row ([SQL-015](../sql/SQL-015-future-cancel-date.md), [CANCELLATION](../database-tables.md#cancellation)).
   - Last completed final audit date, ranked by a fixed selection-category priority ([SQL-018](../sql/SQL-018-last-audit-date.md), [PA_AUDIT](../database-tables.md#pa-audit)).
   - Coverage gaps ([SQL-016](../sql/SQL-016-coverage-gaps.md)), information-page-printed status ([SQL-017](../sql/SQL-017-info-page-printed.md)), and the wrap-up legal name ([SQL-021](../sql/SQL-021-wrapup-legal-name.md)).

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
    Start([Detail property read]) --> G{Detail already loaded?}
    G -->|Yes| Ret([Return cached value])
    G -->|No| M[Set the guard flag]
    M --> Q[(pk72846_view_policy.getviewdetail)]
    Q --> OkQ{Request succeeded?}
    OkQ -->|Yes| F[Map detail columns<br>onto the instance]
    OkQ -->|No| Sw[Swallow the failure<br>and keep empty defaults]
    F --> D[Resolve derived values<br>on their own first read]
    Sw --> D
    D --> Ret
```

## Failure and edge-case behavior

- Detail load failure: swallowed, leaving empty detail values and a usable header ([BR-014](../business-rules.md#br-014-association-date-defaults-differ-per-association-family-and-detail-load-failures-are-non-fatal)).
- A masked reduced-form period returns empty or zero values that are indistinguishable from missing data.**
- Each derived value is a separate round trip, so a view that reads all of them issues several calls.

> **Note:** Statements marked with `†` are derived from dependency library
> documentation via the Legends CLI. Statements marked with `*` were inferred
> from code structure or contextual evidence. Statements marked with `**` could
> not be confirmed; treat as unknown until verified.

## Related documentation

- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [SQL catalog](../sql/index.md)
- [Database tables](../database-tables.md)
- [Procedures](../procedures/index.md)
- [Security and authorization](../security-authorization.md)
- [API reference](../api/index.md)

## Sources

- `Business/SAIF.Business.View.Policy/clsPolicyData.vb`
