SQL-126: Retrieve CbpDiagnosis via QueryDiagnosis¶
This ORM statement performs a read operation on CbpDiagnosis via IUnitOfWork.GetRepository<T>(), executed from Services/SAIF.Services/Claims/Bills/DiagnosisService.cs (L58).
Classification¶
| Field | Value |
|---|---|
| SQL ID | SQL-126 |
| Operation type | Read |
| Execution method | ORM (NHibernate LINQ) |
| Database | Oracle |
| Schema | [unqualified]** |
| Command type | N/A (ORM-generated) |
| Business object | CbpDiagnosis |
| Criteria property | N/A — ORM |
| Lifecycle method | QueryDiagnosis |
Parameters¶
| Parameter | Direction | Type | Max length | Description |
|---|---|---|---|---|
code |
Input | ** | N/A | x.DiagnosisCode == code → column DIAGNOSIS_CODE |
null |
Input | ** | N/A | x.ExpirationDate == null → column EXP_DATE |
DateTime.Today |
Input | ** | N/A | x.ExpirationDate > … → column EXP_DATE |
Tables¶
| Table | Access | Columns used |
|---|---|---|
| CBP_DIAGNOSIS | SELECT | DIAGNOSIS_CODE, UPDATE_NUM, ICD_VERSION_CODE, DIAGNOSIS_DESCR, DIAGNOSIS_SHORT_DESCR, DIAGNOSIS_CATEGORY_CODE, VALID_MEDICARE_REPORT_FLAG, EFF_DATE, EXP_DATE, UPDATE_USER, UPDATE_DATE |
LINQ statement¶
Source: Services/SAIF.Services/Claims/Bills/DiagnosisService.cs:58
// Services/SAIF.Services/Claims/Bills/DiagnosisService.cs:58-59
var diagnosis = unitOfWork.GetRepository<CbpDiagnosis>().Query().FirstOrDefault(x => x.DiagnosisCode == code
&& (includeExpired == true || (x.ExpirationDate == null || x.ExpirationDate > DateTime.Today)));
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
-- Services/SAIF.Services/Claims/Bills/DiagnosisService.cs:58
SELECT *
FROM (
SELECT
CD.DIAGNOSIS_CODE,
CD.UPDATE_NUM,
CD.ICD_VERSION_CODE,
CD.DIAGNOSIS_DESCR,
CD.DIAGNOSIS_SHORT_DESCR,
CD.DIAGNOSIS_CATEGORY_CODE,
CD.VALID_MEDICARE_REPORT_FLAG,
CD.EFF_DATE,
CD.EXP_DATE,
CD.UPDATE_USER,
CD.UPDATE_DATE
FROM CBP_DIAGNOSIS CD
WHERE CD.DIAGNOSIS_CODE = :code
AND (:includeExpired = 1 OR (CD.EXP_DATE IS NULL OR CD.EXP_DATE > :today))
)
WHERE ROWNUM <= 1
Translation notes:
- includeExpired == true references only a method argument -> pre-evaluated client-side to a constant; rendered as :includeExpired = 1 to show intent.
- DateTime.Today -> :today.
Operations and processes¶
- DiagnosisService.QueryDiagnosis — see Operations and processes
Sources¶
Services/SAIF.Services/Claims/Bills/DiagnosisService.cs (L58)