---
title: Legal case queries
summary: Resolve a claim id for a legal case, resolve preferred employee names, and retrieve financial transactions by invoice number.
status: draft
owner: SAIF.Core documentation team
last_reviewed: 2026-09-24
library: SAIF.Data
reference_type: package
operation_id: OP-SD-18
trigger: Legal case processing workflow.
---

# Legal case queries

Resolve a claim id for a legal case, resolve preferred employee names, and retrieve financial transactions by invoice number.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-SD-18 |
| **Trigger** | Legal case processing workflow. |
| **Inputs** | Case number(s), invoice number |
| **Outputs** | Claim id, name, payment |
| **Primary components** | `LegalQueryProvider` |
| **Entry point** | `Data/SAIF.Data/Queries/Legal/LegalQueryProvider.cs` |

## Steps

1. `GetClaimIdForCase`: try the CC API first, then fall back to the WCB, BRB, DCBS, OALJ and OWCP numbers, in order ([SD-BR-060](../business-rules.md#sd-br-060-case-to-claim-resolution-precedence), [SQL-152](../sql/SQL-152-legal-query-provider-get-legal-case.md), [SQL-153](../sql/SQL-153-legal-query-provider-get-legal-cases.md), [SQL-154](../sql/SQL-154-legal-query-provider-get-claim-id-for-case.md), [SQL-155](../sql/SQL-155-legal-query-provider-get-case-cost.md), [SQL-156](../sql/SQL-156-legal-query-provider-get-legal-bills.md), [SQL-157](../sql/SQL-157-legal-query-provider-get-subpoenas.md)). Delegates: `CCClaimApiService`. Data: `LegalCase` (`LEGAL_CASE`).
2. `GetAdpEmployeeName`: use the preferred name when present, otherwise the legal name ([SD-BR-061](../business-rules.md#sd-br-061-preferred-employee-name-takes-precedence)).
3. `GetFinancialTransaction`: get the payment by invoice number.
   > **Origin**: This step delegates to [`FinancialDataApiClient.GetPaymentsByInvoiceNumber`](../../saif-data-guidewire/api/SAIF.Data.Guidewire.Clients/FinancialDataApiClient.md), implemented in `SAIF.Data.Guidewire`, which issues a cached GET of `payments?invoiceNumber={invoiceNumber}` and optionally includes zero-pay payments.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([Legal case processing workflow.]) --> S1["`LegalQueryProvider`"]
	S1 --> S2{"Rules satisfied?"}
	S2 -->|Yes| EndOk([Result returned])
	S2 -->|No| EndErr([Exception / empty result])
```

## Failure and edge-case behavior
- No case number resolves to a claim: `GetClaimIdForCase` falls through all five sources and returns none found*.

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


## Sources
- `Data/SAIF.Data/Queries/Legal/LegalQueryProvider.cs`
- `Data/SAIF.Data/Queries/Legal/LegalQueryProvider.cs:35`
- `Data/SAIF.Data/Queries/Legal/LegalQueryProvider.cs:40`
- `Data/SAIF.Data/Queries/Legal/LegalQueryProvider.cs:55`
