---
title: "SQL-058: ClaimQueryProvider.GetClaimStatusDate"
summary: Read operation for `ClaimQueryProvider.GetClaimStatusDate`
status: draft
owner: SAIF.Core documentation team
last_reviewed: 2026-09-24
library: SAIF.Data
reference_type: package
---

# SQL-058: ClaimQueryProvider.GetClaimStatusDate

This statement is a read operation invoked through ORM (NHibernate LINQ). Executed by `ClaimQueryProvider.GetClaimStatusDate`.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-058 |
| **Operation type** | Read |
| **Execution method** | ORM (NHibernate LINQ) |
| **Database** | Oracle* |
| **Schema** | [unqualified]** |
| **Command type** | N/A (ORM-generated) |
| **Business object** | `ClaimQueryProvider` |
| **Criteria property** | N/A — ORM |
| **Lifecycle method** | `GetClaimStatusDate` |


## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [CL_CLAIM_STATUS_ACTIVITY](../database-tables.md#cl_claim_status_activity) | SELECT (outer query and scalar subquery) | CLAIM_ID, CLAIM_STATUS_CODE, CLAIM_STATUS_ACTIVITY_SEQ_NUM, UPDATE_NUM, EFF_DATE, UPDATE_USER, UPDATE_DATE |

## LINQ statement

Source: `Data/SAIF.Data/Queries/Claims/ClaimQueryProvider.cs:182-186`.

```csharp
var table = Factory.GetRepository<ClaimStatusActivity>().Query();
return table.Single(x =>
        x.ClaimId == claimId &&
        x.SubId == (table.Where(y => y.ClaimId == claimId)
                                        .Max(z => z.SubId))).EffectiveDate.GetValueOrDefault();
```

## Sample SQL

> **Inferred SQL:** This SQL was inferred from the LINQ statement above and the NHibernate mappings. It is not concrete SQL from source code; NHibernate generates the executed statement at runtime, so aliases, column order, join syntax, and bind-parameter names may differ.

```sql
-- Inferred from LINQ (NHibernate mapping translation); not concrete SQL
SELECT
  CCSA.CLAIM_ID,
  CCSA.CLAIM_STATUS_CODE,
  CCSA.CLAIM_STATUS_ACTIVITY_SEQ_NUM,
  CCSA.UPDATE_NUM,
  CCSA.EFF_DATE,
  CCSA.UPDATE_USER,
  CCSA.UPDATE_DATE
FROM CL_CLAIM_STATUS_ACTIVITY CCSA
WHERE CCSA.CLAIM_ID = :claimId
  AND CCSA.CLAIM_STATUS_ACTIVITY_SEQ_NUM = (
    SELECT MAX(CCSA2.CLAIM_STATUS_ACTIVITY_SEQ_NUM)
    FROM CL_CLAIM_STATUS_ACTIVITY CCSA2
    WHERE CCSA2.CLAIM_ID = :claimId
  )
-- NHibernate expects at most one row
```

Translation notes:
- The subquery on the same `IQueryable` (`table`) becomes a correlated-by-value scalar subquery bound to the same `:claimId` parameter.
- `Single` throws when no row matches. It also throws if two rows share the max sequence number under different `CLAIM_STATUS_CODE` values, because the composite key is (`CLAIM_ID`, `CLAIM_STATUS_CODE`, `CLAIM_STATUS_ACTIVITY_SEQ_NUM`).
- Only `EFF_DATE` is consumed by the caller; `.GetValueOrDefault()` runs in memory after materialization.

## Operations and processes

- [Claim status and compensability](../operations/claim-status-and-compensability.md)

## Business rules

- [SD-BR-041 Latest claim status falls back to WCD status when no history](../business-rules.md#sd-br-041-latest-claim-status-falls-back-to-wcd-status-when-no-history)
- [SD-BR-042 Compensability status mapping](../business-rules.md#sd-br-042-compensability-status-mapping)
- [SD-BR-043 Original acceptance requires request type I with decision A](../business-rules.md#sd-br-043-original-acceptance-requires-request-type-i-with-decision-a)

## Sources
- `Data/SAIF.Data/Queries/Claims/ClaimQueryProvider.cs:182`
