---
title: Retrieve billed-cost and payment details
summary: Reconciles medical bill-audit service line amounts and claim payment transaction details between lien and non-lien portions, and looks up cost category codes and policy note/mail routing used by recovery reporting.
status: draft
owner: SAIF
last_reviewed: 2026-07-30
library: SAIF.Business.Claim.ThirdParty
reference_type: package
operation_id: OP-TP-08
trigger: clsBillAuditService.Save() / clsClaimPaymentTransDetail.Save(); read-only lookups of clsClaimCostCategoryCode and clsPolicyNote
---

# Retrieve billed-cost and payment details

This operation supports the financial-reconciliation side of recovery: `clsBillAuditService` splits a medical bill-audit service line's allowed amount between lien and non-lien portions, and `clsClaimPaymentTransDetail` performs the equivalent split for a claim payment transaction, adding an unknown-amount bucket. `clsClaimCostCategoryCode` is a read-only cost-category lookup used across lien, prediction, and expense categorization, while `clsPolicyNote` provides write-only policy-memo and mail-routing integration used to notify policy-side systems of recovery activity.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-TP-08 |
| **Trigger** | `clsBillAuditService.Save()`; `clsClaimPaymentTransDetail.Save()`; direct calls to `clsClaimCostCategoryCode` retrieval and `clsPolicyNote.InsertMemoEntry`/`GetTeamMailID` |
| **Inputs** | `LienAmt`, `NonLienAmt`, `AllowedAmt` (bill-audit service); `LienAmt`, `NonLienAmt`, `UnknownAmt`, `TransactionAmt` (claim payment trans detail); policy number, team code, memo text |
| **Outputs** | Persisted `THRDPARTY_BILL_SERVICE` rows reconciled to the allowed amount; persisted claim payment transaction detail rows reconciled to the transaction amount; cost-category code lookups; inserted policy memo entries and resolved team mail IDs |
| **Primary components** | `clsBillAuditService.ValidTotal`, `clsClaimPaymentTransDetail.ValidTotal`, `clsClaimCostCategoryCode`, `clsPolicyNote.InsertMemoEntry`, `clsPolicyNote.GetTeamMailID` |
| **Entry point** | `Business\SAIF.Business.Claim.ThirdParty\clsBillAuditService.vb` |

## Steps

1. **Create or retrieve a bill-audit service line** for a lien category (fetched by its parent lien-category retrieval; see [Manage liens and settlements](manage-liens-and-settlements.md)).
2. **Validate the bill-audit service line (`IsValid`):**
   - Lien amount plus non-lien amount must equal the allowed amount ([BR-033](../business-rules.md#br-033-bill-audit-service-and-claim-payment-transaction-detail-lien-and-non-lien-amounts-must-reconcile-to-the-allowed-or-paid-amount)).
3. **Persist the bill-audit service line** via insert ([SQL-017](../sql/sql-017-pk82033_thirdparty-billservice_insert.md)) or update ([SQL-071](../sql/sql-071-pk82033_thirdparty-billservice_update.md)) against [THRDPARTY_BILL_SERVICE](../database-tables.md#thrdparty_bill_service).
4. **Create or retrieve a claim payment transaction detail row** for a lien.
5. **Validate the claim payment transaction detail (`IsValid`):**
   - Lien amount plus non-lien amount plus unknown amount must equal the transaction amount ([BR-033](../business-rules.md#br-033-bill-audit-service-and-claim-payment-transaction-detail-lien-and-non-lien-amounts-must-reconcile-to-the-allowed-or-paid-amount)).
6. **Persist the claim payment transaction detail row** via its own insert/update SQL (criteria-driven; catalogued generically under the parent claim-payment integration rather than as a standalone SQL entry).*
7. **Look up cost category codes.** `clsClaimCostCategoryCode` retrieves the list of valid third-party claim cost category codes used to categorize liens, predictions, and expenses ([SQL-040](../sql/sql-040-pk82033_thirdparty-cost_category_select.md), [TP_CLAIM_COST_CATEGORY_CODE](../database-tables.md#tp_claim_cost_category_code)); no business rules are registered — this is a pure reference lookup.*
8. **Insert a policy memo entry.** `clsPolicyNote.InsertMemoEntry` writes a memo record directly against the legacy policy system via `sp72155_insert_memo_entry` ([SQL-033](../sql/sql-033-sp72155_insert_memo_entry.md)); this call bypasses the BOF business-object save pipeline and issues the stored procedure directly, so no `RulesAffected`/row-count validation is performed.*
9. **Resolve a team mail ID.** `clsPolicyNote.GetTeamMailID` calls `policy_pkg.get_team_mailid` directly to resolve the mailbox for a policy/team combination, used to route recovery correspondence ([SQL-032](../sql/sql-032-policy_pkg-get_team_mailid.md)); likewise bypasses the standard save pipeline.*

## Process flow

The following diagram visualizes the two reconciliation validations that anchor this operation.

```mermaid
flowchart TD
	Start([Caller edits a bill-audit<br>service line or payment trans detail])
	Start --> Kind{Which object?}
	Kind -->|BillAuditService| BillCheck{Lien + Non-lien<br>= Allowed?}
	Kind -->|ClaimPaymentTransDetail| PayCheck{Lien + Non-lien<br>+ Unknown = Transaction?}
	BillCheck -->|No| BillFail([Error: amounts<br>must reconcile])
	BillCheck -->|Yes| BillSave[Insert or update<br>THRDPARTY_BILL_SERVICE]
	PayCheck -->|No| PayFail([Error: amounts<br>must reconcile])
	PayCheck -->|Yes| PaySave[Insert or update<br>payment trans detail]
	BillSave --> Done([Reconciled amounts persisted])
	PaySave --> Done
```

## Failure and edge-case behavior

- Both reconciliation rules use an exact equality check (`<>`) rather than a tolerance/rounding band, so even a one-cent rounding discrepancy between the summed components and the target amount fails validation.*
- `clsPolicyNote`'s memo-insert and mail-ID lookup calls issue their stored procedures directly rather than through the standard `Save()`/business-rule pipeline used elsewhere in this library, so they carry no `IsValid`/broken-rules protection of their own.*
- `clsClaimCostCategoryCode` has no registered business rules — it is a pure reference lookup shared by liens, predictions, and expenses.*
- No length or format validation is documented for the policy memo text passed to `InsertMemoEntry`; any constraint is enforced by the target stored procedure rather than the BOF layer.**

> **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 `**` denote areas where the
> underlying behavior could not be determined from the available source and
> should be validated with a subject-matter expert before being treated as fact.

## Related documentation

- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [SQL catalog](../sql/index.md)
- [Database tables](../database-tables.md)

## Sources

- `Business\SAIF.Business.Claim.ThirdParty\clsBillAuditService.vb`
- `Business\SAIF.Business.Claim.ThirdParty\clsBillAuditServiceCollection.vb`
- `Business\SAIF.Business.Claim.ThirdParty\clsClaimPaymentTransDetail.vb`
- `Business\SAIF.Business.Claim.ThirdParty\clsClaimPaymentTransDetailCollection.vb`
- `Business\SAIF.Business.Claim.ThirdParty\clsClaimCostCategoryCode.vb`
- `Business\SAIF.Business.Claim.ThirdParty\clsPolicyNote.vb`
