---
title: Run case search and predictions
summary: Searches recovery cases and computes/validates lien-recovery predictions, statute dates, unit-stat forecasts, and claim-condition lookups used in reporting.
status: draft
owner: SAIF
last_reviewed: 2026-07-30
library: SAIF.Business.Claim.ThirdParty
reference_type: package
operation_id: OP-TP-07
trigger: clsThrdpartyCaseSearchCollection criteria search; clsThrdpartyPrediction retrieval followed by Save(); read-only statute-date, unit-stat, and claim-condition lookups
---

# Run case search and predictions

This operation groups the analytical and lookup surfaces of the library: case search (`clsThrdpartyCaseSearch(Collection)`) filters open/pending cases by adjuster and status criteria; predictions (`clsThrdpartyPrediction(Collection/Detail)`) project recoverable amounts per lien category and are the only class in this group with save behavior and business rules; statute dates (`clsThirdpartyStatuteDate`), unit-stat predictions (`clsThirdpartyUnitStatPrediction`), and claim conditions (`clsThrdpartyClaimCondition(Collection)`) are read-only supporting lookups.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-TP-07 |
| **Trigger** | `clsThrdpartyCaseSearchCollection` criteria-based search; `clsThrdpartyPrediction.GetThrdpartyPrediction`/`NewThrdpartyPrediction` followed by `Save()`; direct reads of statute date, unit-stat prediction, and claim condition |
| **Inputs** | Search criteria (adjuster, status, case type), `LienSeqNum`, prediction percent factor or amount, prediction status code, claim ID |
| **Outputs** | Filtered case-search collection; persisted `THRDPARTY_PREDICTION`/`THRDPARTY_PREDICTION_DETAIL` rows; read-only statute-date, unit-stat prediction, and claim-condition projections |
| **Primary components** | `clsThrdpartyCaseSearchCollection`, `clsThrdpartyPrediction.AddBusinessRules`, `clsThrdpartyPrediction.ValidDispersement` |
| **Entry point** | `Business\SAIF.Business.Claim.ThirdParty\clsThrdpartyCaseSearchCollection.vb` |

## Steps

1. **Run a case search.** `clsThrdpartyCaseSearchCollection` builds a criteria-driven query and retrieves matching cases ([SQL-048](../sql/sql-048-pk82033_thirdparty-thrdparty_case_search_select.md), [THRDPARTY_CASE](../database-tables.md#thrdparty_case)); no business rules are registered on the search collection — filtering is expressed entirely through the criteria object and package query.*
2. **Create or retrieve a prediction.** Retrieval reads predictions by lien/case ([SQL-044](../sql/sql-044-pk82033_thirdparty-prediction_select.md), [THRDPARTY_PREDICTION](../database-tables.md#thrdparty_prediction)).
3. **Validate the prediction (`IsValid`), most checks active only while the prediction is dirty:**
   - Lien sequence number must be non-zero unless the prediction is being deleted ([BR-031](../business-rules.md#br-031-recovery-predictions-require-a-valid-lien-and-percent-factor-and-cannot-exceed-projected-plus-lienable-paid-amounts-or-be-negative)).
   - Prediction percent factor must fall between 0 and 100 ([BR-031](../business-rules.md#br-031-recovery-predictions-require-a-valid-lien-and-percent-factor-and-cannot-exceed-projected-plus-lienable-paid-amounts-or-be-negative)).
   - When the prediction is entered as a flat amount (`CalcAmountType = Amount`), it cannot exceed the sum of the projected and lienable-paid category totals ([BR-031](../business-rules.md#br-031-recovery-predictions-require-a-valid-lien-and-percent-factor-and-cannot-exceed-projected-plus-lienable-paid-amounts-or-be-negative)).
   - When the prediction is entered as a flat amount, it cannot be negative ([BR-031](../business-rules.md#br-031-recovery-predictions-require-a-valid-lien-and-percent-factor-and-cannot-exceed-projected-plus-lienable-paid-amounts-or-be-negative)).
   - For a final prediction, if total incurred is positive and the calculated incurred percent is below 50%, the prediction status is forced to pending and a warning is raised that supervisor approval is needed; otherwise the status is set to not-required ([BR-032](../business-rules.md#br-032-predictions-pending-supervisor-approval-are-flagged-with-a-warning-and-prediction-detail-totals-must-match-the-prediction-amount)).
   - Dispersement validation (`ValidDispersement`) recomputes the prediction-detail category total and, when the prediction is percent-driven, cross-checks lienable-paid and projected category totals against the percent factor to confirm the details still reconcile to the prediction amount ([BR-032](../business-rules.md#br-032-predictions-pending-supervisor-approval-are-flagged-with-a-warning-and-prediction-detail-totals-must-match-the-prediction-amount)).
4. **Persist the prediction and its detail rows** via insert ([SQL-021](../sql/sql-021-pk82033_thirdparty-prediction_insert.md), [SQL-020](../sql/sql-020-pk82033_thirdparty-prediction_detail_insert.md)) or update ([SQL-075](../sql/sql-075-pk82033_thirdparty-prediction_update.md), [SQL-074](../sql/sql-074-pk82033_thirdparty-prediction_detail_update.md)) against [THRDPARTY_PREDICTION](../database-tables.md#thrdparty_prediction) and [THRDPARTY_PREDICTION_DETAIL](../database-tables.md#thrdparty_prediction_detail).
   - On a rows-affected value other than `1`: an insert/update error message is added.
5. **Read statute dates.** `clsThirdpartyStatuteDate` retrieves a read-only projection of statute-of-limitations dates for reporting ([SQL-047](../sql/sql-047-pk82033_thirdparty-statute_date_list.md)); no business rules are registered.*
6. **Read unit-stat predictions.** `clsThirdpartyUnitStatPrediction` retrieves a read-only unit-stat forecast used to schedule the "Unit Stat Prediction Due" task in [Maintain recovery case](maintain-recovery-case.md) ([SQL-067](../sql/sql-067-pk82033_thirdparty-unit_stat_prediction_list.md)); no business rules are registered.*
7. **Read claim conditions.** `clsThrdpartyClaimCondition(Collection)` retrieves a read-only list of medical/claim conditions associated with a claim, used to contextualize recovery predictions ([SQL-036](../sql/sql-036-pk82033_thirdparty-claim_condition_select.md)); no business rules are registered.*

## Process flow

The following diagram visualizes prediction validation, the only write-capable path in this operation.

```mermaid
flowchart TD
	Start([Caller creates or edits<br>a prediction]) --> Basic[Validate lien seq number,<br>percent factor]
	Basic --> AmountType{CalcAmountType?}
	AmountType -->|Amount| AmountRules[Validate amount <= projected<br>+ lienable paid; amount >= 0]
	AmountType -->|PercentFactor| SkipAmount[Skip flat-amount checks]
	AmountRules --> Approval{Final prediction?}
	SkipAmount --> Approval
	Approval -->|Yes, incurred% < 50| WarnApproval([Warning: pending<br>supervisor approval])
	Approval -->|Yes, incurred% >= 50| NotRequired[Status set to NOTR]
	Approval -->|No| Dispersement[Validate detail totals<br>reconcile to prediction amount]
	WarnApproval --> Dispersement
	NotRequired --> Dispersement
	Dispersement --> Ok{All rules pass?}
	Ok -->|No| Fail([Broken rules returned])
	Ok -->|Yes| Save[Insert or update prediction<br>and detail rows]
	Save --> Rows{RowsAffected = 1?}
	Rows -->|No| Contention([Insert/Update error added])
	Rows -->|Yes| Done([Prediction persisted])
```

## Failure and edge-case behavior

- The supervisor-approval-needed check (`ValidPercentNeedsApproval`) mutates `PredictionStatusCode` as a side effect of validation rather than only reporting pass/fail, so re-running `IsValid` can change the object's state.*
- Case search, statute-date, unit-stat prediction, and claim-condition classes have no registered business rules — they are pure read/reporting projections with no BOF-level validation of their own.*
- A rows-affected value other than `1` on prediction insert or update is treated as a DB contention failure rather than an exception ([BR-005](../business-rules.md#br-005-recovery-save-operations-require-one-affected-row)).
- The dispersement check only fully cross-validates category totals when the prediction is percent-driven; flat-amount predictions rely solely on the projected/lienable-paid ceiling check.*

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

## 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\clsThrdpartyCaseSearch.vb`
- `Business\SAIF.Business.Claim.ThirdParty\clsThrdpartyCaseSearchCollection.vb`
- `Business\SAIF.Business.Claim.ThirdParty\clsThrdpartyPrediction.vb`
- `Business\SAIF.Business.Claim.ThirdParty\clsThrdpartyPredictionCollection.vb`
- `Business\SAIF.Business.Claim.ThirdParty\clsThrdpartyPredictionDetail.vb`
- `Business\SAIF.Business.Claim.ThirdParty\clsThrdpartyPredictionDetailCollection.vb`
- `Business\SAIF.Business.Claim.ThirdParty\clsThirdpartyStatuteDate.vb`
- `Business\SAIF.Business.Claim.ThirdParty\clsThirdpartyUnitStatPrediction.vb`
- `Business\SAIF.Business.Claim.ThirdParty\clsThrdpartyClaimCondition.vb`
- `Business\SAIF.Business.Claim.ThirdParty\clsThrdpartyClaimCondtionCollection.vb`
