---
title: Policy
summary: API reference for Policy.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Domain
reference_type: package
---

# Policy

`Policy` wraps a `Data.Model.Policies.Policy` entity and assembles the policy-level contact and location information — county, policy contact, claim contact, office, and rate-account linkage — that claim setup and correspondence workflows read when they need to know where a policy's paperwork and calls should go.

## Purpose
- Resolves the policy's primary location's county via the location query provider, returning `null` when the policy has no primary location or the location has no county.
- Builds a formatted `ContactItem` for the policy's claim-handling location (address, phone, fax) and, separately, for that location's designated claim contact person (name, phone, cell), returning `null` at each stage where the underlying location or contact data is absent.
- Resolves the policy's office code to an `OfficeCode` contract and exposes the policy's rate account as another `Policy` instance, letting callers navigate the rating hierarchy without a separate lookup.
- Determines the policy's current (or, optionally, only past-effective) group association by finding its latest applicable policy period and querying the query provider for the corresponding group association.

## Context
- Namespace: `SAIF.Domain.Model.Policies`
- Assembly/package: `SAIF.Domain` (packaged in `SAIF.SAIFCode.Core`)
- The same source file also declares a public `PolicyMappingHelper` static class (address/office-code/county mapping helpers used internally by `Policy`); it is out of scope for this page and is not documented here.

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| Policy (constructor by policy number) | `public Policy(IRepositoryFactory factory, IPolicyQueryProvider policyQueryProvider, long policyNumber)` | Loads the policy entity identified by `policyNumber`. |
| Policy (constructor from entity) | `public Policy(IRepositoryFactory factory, IPolicyQueryProvider policyQueryProvider, Data.Model.Policies.Policy policy)` | Wraps an already-loaded policy entity. |
| Data | `public Data.Model.Policies.Policy Data { get; }` | Exposes the underlying policy entity. |
| PolicyCounty | `public County PolicyCounty { get; }` | The county of the policy's primary location, mapped to the `County` contract; `null` when there is no primary location or it has no county. |
| PolicyContact | `public ContactItem PolicyContact { get; }` | A `ContactItem` for the policy's claim-handling location — formatted name, address, and phone/fax (tagged `"Phone"`/`"Fax"`) — or `null` when there is no data or no claim location. |
| ClaimContact | `public ContactItem ClaimContact { get; }` | A `ContactItem` (type `"Claim Contact"`) for the claim location's designated contact person — name, phone, cell (tagged `"Phone"`/`"Cell"`) — or `null` when there is no data, no claim location, or no valid contact record. |
| GetGroupAssociation | `public PolicyPeriodGroupAssoc GetGroupAssociation(bool excludeFuturePolicyPeriods)` | Finds the latest policy period (optionally excluding periods effective in the future) and returns its group association from the query provider; `null` when the policy has no matching period. |
| Office | `public Core.Contracts.OfficeCode Office { get; }` | The policy's office, mapped to the `OfficeCode` contract; `null` when there is no data, no office code on the policy, or the office code does not resolve. |
| RateAccount | `public Policy RateAccount { get; }` | A new `Policy` wrapping the policy's rate-account entity, allowing navigation up the rating hierarchy. |

## Inherited public members

Members in this section are inherited from `DomainBase<TItem>` in `SAIF.Domain`. They are available on this type through inheritance (via the intermediate `DomainRepositoryBase<TItem>` base).

| Member | Signature | Purpose | Origin |
| --- | --- | --- | --- |
| HasData | `public virtual bool HasData { get; }` | Reports whether the wrapped policy entity is present, evaluated as `!DataItem.IsNull()`. | `SAIF.Domain` — `DomainBase<TItem>` |

## Behavioral notes
- `PolicyCounty` does not check `HasData` before dereferencing `DataItem.PolicyNumber`, unlike `PolicyContact`/`ClaimContact`/`Office`, so calling it on a `Policy` with no data risks a null-reference failure rather than returning `null` gracefully*.
- `RateAccount` recurses through the constructor-from-entity overload each time it is accessed, so repeated access re-wraps (rather than caches) the rate-account policy*.

## Constraints and usage notes
- `PolicyCounty` is unguarded against a missing `DataItem`; callers should check `HasData` themselves before reading it.

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

## Sources
- `Domain/SAIF.Domain/Model/Policies/Policy.cs`
- `Domain/SAIF.Domain/DomainBase.cs`
- `Domain/SAIF.Domain/DomainRepositoryBase.cs`
