Skip to content

SQL-255: Retrieve PharmacyDispenseAsWrittenCode

BillServiceService.CreateService and UpdateService look up a single PharmacyDispenseAsWrittenCode row by its code, using a LINQ query over an NHibernate-backed repository. NHibernate translates this expression into the row-limited SELECT shown below at execution time.

Classification

Field Value
SQL ID SQL-255
Operation type Read
Execution method ORM (NHibernate LINQ)
Database Oracle
Schema [unqualified]**
Command type N/A (ORM-generated)
Business object BillServiceService
Criteria property N/A — ORM
Lifecycle method CreateService, UpdateService

Parameters

Parameter Direction Type Max length Description
:PharmacyDispenseAsWrittenCode Input string N/A newService.PharmacyDispenseAsWrittenCode (CreateService) / updatedServiceLine.PharmacyDispenseAsWrittenCode (UpdateService) — the DAW code to look up

Tables

Table Access Columns used
CL_PHARMACY_DAW_CODE SELECT CODE, UPDATE_NUM, CODE_DESCR, UPDATE_DATE, UPDATE_USER

LINQ statement

Source: Services/SAIF.Services/Claims/Bills/BillServiceService.cs:59

// Services/SAIF.Services/Claims/Bills/BillServiceService.cs:59
newServiceLine.PharmacyDispenseAsWrittenCode = unitOfWork.GetRepository<PharmacyDispenseAsWrittenCode>().Query().FirstOrDefault(x => x.Code == newService.PharmacyDispenseAsWrittenCode);

// Services/SAIF.Services/Claims/Bills/BillServiceService.cs:126-127
dataServiceLine.PharmacyDispenseAsWrittenCode = updatedServiceLine.PharmacyDispenseAsWrittenCode.IsNull() ? null : unitOfWork.GetRepository<PharmacyDispenseAsWrittenCode>()
    .Query().FirstOrDefault(x => x.Code == updatedServiceLine.PharmacyDispenseAsWrittenCode);

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.

-- Inferred from LINQ (NHibernate mapping translation); not concrete SQL
SELECT *
FROM (
  SELECT
  CPDC.CODE,
  CPDC.UPDATE_NUM,
  CPDC.CODE_DESCR,
  CPDC.UPDATE_DATE,
  CPDC.UPDATE_USER
  FROM CL_PHARMACY_DAW_CODE CPDC
  WHERE CPDC.CODE = :PharmacyDispenseAsWrittenCode
)
WHERE ROWNUM <= 1

Translation notes: - Both call sites have the same shape; L126 only runs when the incoming code is not null (ternary in C#, not a SQL predicate).

Operations and processes

Business rules

Sources

  • Services/SAIF.Services/Claims/Bills/BillServiceService.cs (L59, L126)