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

# PolicyNodeBuilder

Builds a `PolicyNode` from a `Policy` domain object, formatting policy number/status/customer-service-team/county/district-office details to proper case, resolving rate-account information, policy and claim contacts, agency/agent details (including mailing-location phone fallback to cell phone), group association name, policy relationship (leasing) information, and standard premium via an injected `IPoliciesRepository`.

## Purpose
- Produces the display-ready policy summary (number, status, customer service team, county, district office) with text fields normalized to proper case.
- Resolves rate-account name and county information when the policy has an associated rate account.
- Copies policy and claim contact records from the `Policy` domain object.
- Resolves agent/agency name and phone numbers, preferring the agent's cell phone over the mailing-location phone when both channels are set.
- Resolves the policy's group association name, when one exists.
- Resolves policy relationship (leasing) information: relationship type, related policy number, and leasing entity name.
- Computes the policy's standard premium by looking up the active policy period's effective date and querying `IPoliciesRepository.GetPolicyStandardPremium`.

## Context
- Namespace: `SAIF.Services.Claims.Information.Api`
- Assembly/package: `SAIF.Services` (packaged inside the `SAIF.SAIFCode.Core` NuGet package)

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| Node | `public PolicyNode Node { get; }` | Exposes the node instance being populated by this builder. |
| PolicyNodeBuilder(policy, node) | `public PolicyNodeBuilder(Policy policy, PolicyNode node)` | Stores the policy and target node for later population. |
| AddStandardPremium(repository) | `public PolicyNodeBuilder AddStandardPremium(IPoliciesRepository repository)` | Finds the currently active policy period (status code "0"), then sets `StandardPremium` via `repository.GetPolicyStandardPremium` using that period's effective date (or `DateTime.MinValue` if none is active). |
| AddPolicyDetails() | `public PolicyNodeBuilder AddPolicyDetails()` | Sets `PolicyNumber`, proper-cased `PolicyStatus`/`CustomerServiceTeam`, `PolicyCounty` (name proper-cased), and `DistrictOffice` (description proper-cased). |
| AddRateAcount() | `public PolicyNodeBuilder AddRateAcount()` | Sets `RateAccount` to the rate account's policy number and proper-cased policy name, and `RateAccountCounty` with proper-cased county name, when a rate account exists. |
| AddContacts() | `public PolicyNodeBuilder AddContacts()` | Copies `PolicyContact` and `PolicyClaimContact` from the policy domain object. |
| AddAgency() | `public PolicyNodeBuilder AddAgency()` | Sets proper-cased `AgentName`/`AgencyName` and agency/agent phone numbers (agent cell phone preferred over mailing-location phone) when the policy has an agent with an agency and name. |
| AddGroup() | `public PolicyNodeBuilder AddGroup()` | Sets `GroupName` to the proper-cased group association name when the policy belongs to a group. |
| AddPolicyRelationshipInformation() | `public PolicyNodeBuilder AddPolicyRelationshipInformation()` | Sets `RelationshipPolicyNumber`, proper-cased `RelationshipType`, and proper-cased `LeasingName` when the policy has relationship and related-policy data. |

## Behavioral notes
- Every populated field is guarded by a `!_policyObject.HasData` (or related null) check first, so the builder no-ops entirely when the policy has no backing data.
- Text fields are consistently normalized via `.ToProperCase()` before being written to the node.
- A block of commented-out legacy code for iterating `Agency.Agents` remains in `AddAgency()`, indicating a previously different phone-resolution approach that was replaced.*

## Constraints and usage notes
- `AddStandardPremium` requires an `IPoliciesRepository` supplied by the caller at call time rather than construction time, unlike the other dependencies which are captured in the constructor.

> **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
- Services/SAIF.Services/Claims/Information/Api/PolicyNodeBuilder.cs
