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

# SQL-016: AuditQueryProvider.IsNurseReviewRequired

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

## Classification

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


## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [CBP_SERVICE_CODE](../database-tables.md#cbp_service_code) | SELECT | CODE, NURSE_REVIEW_REQUIRED_FLAG |

## LINQ statement

Source: `Data/SAIF.Data/Queries/AuditQueryProvider.cs:51`, where `codeRepo` is defined, and `:53-55`, where it executes.

```csharp
var codeRepo = Factory.GetRepository<CbpServiceCode>().Query();
var svcs = Factory.GetRepository<CbpAuditedService>().Query().Where(x => x.Audit.Bill.Id == billId).ToList();
return svcs.Any(
    x => codeRepo.Any(y => y.IsNurseReviewRequired
        && x.BillServiceCode == y.Code));
```

## 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 1
FROM CBP_SERVICE_CODE CSC
WHERE CSC.NURSE_REVIEW_REQUIRED_FLAG = 'Y'
  AND CSC.CODE = :BillServiceCode
  AND ROWNUM <= 1
```

Translation notes:
- **How it executes:** `svcs` is already materialized (`ToList()`, see SQL-017), so `svcs.Any(...)` is LINQ-to-Objects.
- **N+1 pattern:** the inner `codeRepo.Any(...)` is an NHibernate query executed once per audited-service row, short-circuiting on the first `true`.
- **Match is by code only:** the service-type key part is ignored, so any service type with a matching `CODE` and the flag set qualifies.
- The commented-out alternative at `:57-64` is not executed.

## Operations and processes

- [Bill audit evaluation](../operations/bill-audit-evaluation.md)

## Business rules

- [SD-BR-030 Nurse review required if any audited service code flags it](../business-rules.md#sd-br-030-nurse-review-required-if-any-audited-service-code-flags-it)
- [SD-BR-031 Duplicate services excluded from count](../business-rules.md#sd-br-031-duplicate-services-excluded-from-count)
- [SD-BR-032 Unset thru-date treated as open-ended](../business-rules.md#sd-br-032-unset-thru-date-treated-as-open-ended)

## Sources
- `Data/SAIF.Data/Queries/AuditQueryProvider.cs:51`
