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

# SQL-211: ProviderQueryProvider.GetProviderIdentitiesByNpi

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

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `nationalProviderId` | Input | string | N/A | Method argument of `ProviderQueryProvider.GetProviderIdentitiesByNpi` bound into the ORM expression; NHibernate generates the bind variable at runtime |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [PROVIDER_IDENTITY](../database-tables.md#provider_identity) | SELECT | PROVIDER_IDENTITY_SEQ_NUM, UPDATE_NUM, IDENTITY_VALUE, UPDATE_USER, UPDATE_DATE, PROVIDER_LOCATION_SEQ_NUM, PROVIDER_IDENTITY_CODE |

## LINQ statement

Source: `Data/SAIF.Data/Queries/Providers/ProviderQueryProvider.cs:172-177`.

```csharp
public IEnumerable<ProviderIdentity> GetProviderIdentitiesByNpi(string nationalProviderId)
{
    string[] npiCodes = { NationalProviderId, OrganizationalNationalProviderId };

    return Factory.GetRepository<ProviderIdentity>()
        .Query()
        .Where(i =>
            i.Value.TrimEnd() == nationalProviderId &&
            npiCodes.Contains(i.IdentityType.Code))
        .ToList();
}
```

## 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
  PI.PROVIDER_IDENTITY_SEQ_NUM,
  PI.UPDATE_NUM,
  PI.IDENTITY_VALUE,
  PI.UPDATE_USER,
  PI.UPDATE_DATE,
  PI.PROVIDER_LOCATION_SEQ_NUM,
  PI.PROVIDER_IDENTITY_CODE
FROM PROVIDER_IDENTITY PI
WHERE RTRIM(PI.IDENTITY_VALUE) = :nationalProviderId
  AND PI.PROVIDER_IDENTITY_CODE IN ('NPI', 'ONPI')
```

Translation notes:
- `TrimEnd()` with no arguments → Oracle `RTRIM(col)`.
- Mapping quirk: the column is declared as `"IDENTITY_VALUE "` with a trailing space (`ProviderIdentityMap.cs:16`). The generated SQL would carry that spacing; it is normalized to `IDENTITY_VALUE` here. Oracle ignores the whitespace in an unquoted identifier.
- `npiCodes.Contains(x.Code)` → `IN (:p0, :p1)`. The values are shown inline.

## Operations and processes

- [Provider queries](../operations/provider-queries.md)

## Business rules

- [SD-BR-080 Provider identity relationship and address code sets](../business-rules.md#sd-br-080-provider-identity-relationship-and-address-code-sets)
- [SD-BR-082 Dismissed bills excluded from provider location ids](../business-rules.md#sd-br-082-dismissed-bills-excluded-from-provider-location-ids)
- [SD-BR-083 Provider in MCO only within date window](../business-rules.md#sd-br-083-provider-in-mco-only-within-date-window)

## Sources
- `Data/SAIF.Data/Queries/Providers/ProviderQueryProvider.cs:172`
