---
title: Determine an agency's contract type on a date
summary: Return the first active contract type for an agency.
status: draft
owner: Technical Writer
last_reviewed: 2026-07-31
library: SAIF.Business.Policy.Agency
reference_type: package
operation_id: OP-005
trigger: A caller reads an agency's contract type for a date.
---

# Determine an agency's contract type on a date

This operation derives an agency-level contract classification by filtering the agency's loaded contracts to those active on a requested date and returning the first surviving contract type.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-005 |
| **Trigger** | A caller invokes `clsAgency.ContractType(inDate)`. |
| **Inputs** | `clsAgency`, as-of date |
| **Outputs** | `AgencyContractTypes` value |
| **Primary components** | `clsAgency.ContractType`, `clsAgency.Contracts`, `clsAgencyContractCollection.Active` |
| **Entry point** | `Business\SAIF.Business.Policy.Agency\clsAgency.vb` |

## Steps
1. Ensure the agency's `Contracts` collection is available, lazily loading it through [Retrieve agency contracts](retrieve-agency-contracts.md) when necessary.
2. Filter the contracts to those active on the requested date ([BR-008](../business-rules.md#br-008-active-status-uses-effective-and-expiration-windows)).
3. If at least one active contract remains, return the first contract's domain contract type.
4. If no active contract remains, return `AgencyContractTypes.Unassigned` ([BR-009](../business-rules.md#br-009-missing-active-contracts-mean-unassigned-contract-type)).
5. When lazy loading is required, the contract retrieve executes [SQL-004](../sql/SQL-004-retrieve-agency-contracts.md) against [AGENCY_CONTRACT](../database-tables.md#agency_contract).

## Process flow

The following diagram visualizes the contract-type decision.

```mermaid
flowchart TD
  Start([ContractType]) --> Load[Ensure contracts loaded]
  Load --> Filter[Filter active contracts]
  Filter --> Any{Any active contract?}
  Any -->|Yes| First[Return first contract type]
  Any -->|No| Unassigned[Return Unassigned]
```

## Failure and edge-case behavior
- The operation depends on the ordering of the loaded contract collection when multiple active contracts exist on the same date.

## Related documentation
- [Index](../index.md)
- [Overview](../overview.md)
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [Database tables](../database-tables.md)
- [SQL catalog](../sql/index.md)
- [API reference](../api/index.md)

## Sources
- `Business\SAIF.Business.Policy.Agency\clsAgency.vb`
- `Business\SAIF.Business.Policy.Agency\clsAgencyContractCollection.vb`
