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

# SQL-216: ProviderQueryProvider.IsProviderInMco

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

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-216 |
| **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** | `IsProviderInMco` |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `mcoPlanId` | Input | string | N/A | Method argument of `ProviderQueryProvider.IsProviderInMco` bound into the ORM expression; NHibernate generates the bind variable at runtime |
| `providerLocationId` | Input | long | N/A | Method argument of `ProviderQueryProvider.IsProviderInMco` bound into the ORM expression; NHibernate generates the bind variable at runtime |
| `serviceDate` | Input | DateTime | N/A | Method argument of `ProviderQueryProvider.IsProviderInMco` bound into the ORM expression; NHibernate generates the bind variable at runtime |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [MCO_PROVIDER](../database-tables.md#mco_provider) | SELECT (existence) | PROVIDER_LOCATION_SEQ_NUM, MCO_PLAN_ID, EFF_DATE, EXP_DATE |

## LINQ statement

Source: `Data/SAIF.Data/Queries/Providers/ProviderQueryProvider.cs:232-235`.

```csharp
public bool IsProviderInMco(string mcoPlanId, long providerLocationId, DateTime serviceDate)
{
    return Factory.GetRepository<MCOProvider>()
        .Query().Any(m => m.PoviderLocationId == providerLocationId && m.MCOId == mcoPlanId &&             //  (MCOId is MCO_PLAN_ID in the table)                                                            
           ((m.EffectiveDate <= serviceDate && m.ExpirationDate == null)
        || (m.EffectiveDate <= serviceDate && m.ExpirationDate >= serviceDate)));
}
```

## 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 * FROM (
  SELECT 1
  FROM MCO_PROVIDER MP
  WHERE MP.PROVIDER_LOCATION_SEQ_NUM = :providerLocationId
    AND MP.MCO_PLAN_ID = :mcoPlanId
    AND (
      (MP.EFF_DATE <= :serviceDate AND MP.EXP_DATE IS NULL)
      OR (MP.EFF_DATE <= :serviceDate AND MP.EXP_DATE >= :serviceDate)
    )
) WHERE ROWNUM <= 1
```

Translation notes:
- `Any(predicate)` → row-limited existence probe. `MCOId` maps to `MCO_PLAN_ID` (`MCOProviderMap.cs:13`).

## 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:232`
