---
title: "SQL-038: Create MedicareQueryHistory via InsertMedicareQueryHistory"
summary: Create operation against MedicareQueryHistory via NHibernate ORM.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Services
reference_type: package
---

# SQL-038: Create MedicareQueryHistory via InsertMedicareQueryHistory

This ORM statement performs a create operation on `MedicareQueryHistory` via `InsertMedicareQueryHistory`, executed from `Services/SAIF.Services/Claims/Medicare/MedicareService.cs` (L121).

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-038 |
| **Operation type** | Create |
| **Execution method** | ORM (IRepository.Add) |
| **Database** | Oracle |
| **Schema** | [unqualified]** |
| **Command type** | N/A (ORM-generated) |
| **Business object** | `MedicareQueryHistory` |
| **Criteria property** | N/A — ORM |
| **Lifecycle method** | `InsertMedicareQueryHistory` |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:Id` | Input | `long` | N/A | Identifier from `MEDICARE_QUERY_HISTORY_SEQ.NEXTVAL` |
| `:UpdateNum` | Input | `int` | N/A |  |
| `:PersonId` | Input | `long` | N/A |  |
| `:FirstSubmissionDate` | Input | `DateTime` | N/A |  |
| `:LastSubmissionDate` | Input | `DateTime` | N/A |  |
| `:TaxId` | Input | `string` | N/A |  |
| `:LastName` | Input | `string` | N/A |  |
| `:FirstInitial` | Input | `string` | N/A |  |
| `:GenderCode` | Input | `string` | N/A |  |
| `:BirthDate` | Input | `DateTime?` | N/A |  |
| `:IsPrimaryTaxId` | Input | `bool` | N/A | Bound as `'Y'`/`'N'` (`YesNoType`) |
| `:IsMedicareBeneficiary` | Input | `bool` | N/A | Bound as `'Y'`/`'N'` (`YesNoType`) |
| `:ResponseMedicareClaimNumber` | Input | `string` | N/A |  |
| `:ResponseTaxId` | Input | `string` | N/A |  |
| `:ResponseLastName` | Input | `string` | N/A |  |
| `:ResponseFirstInitial` | Input | `string` | N/A |  |
| `:ResponseGenderCode` | Input | `string` | N/A |  |
| `:ResponseBirthDate` | Input | `DateTime?` | N/A |  |
| `:UpdateUser` | Input | `string` | N/A |  |
| `:UpdateDate` | Input | `DateTime` | N/A |  |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [MEDICARE_QUERY_HISTORY](../database-tables.md#medicare_query_history) | INSERT | MEDICARE_QUERY_HISTORY_SEQ_NUM, UPDATE_NUM, CLAIM_PERSON_ID, FIRST_SUBMISSION_DATE, LAST_SUBMISSION_DATE, TAX_ID, LAST_NAME, FIRST_INITIAL, GENDER_CODE, BIRTH_DATE, PRIMARY_TAX_ID_FLAG, MEDICARE_BENEFICIARY_FLAG, RESPONSE_MEDICARE_CLAIM_NUMBER, RESPONSE_TAX_ID, RESPONSE_LAST_NAME, RESPONSE_FIRST_INITIAL, RESPONSE_GENDER_CODE, RESPONSE_BIRTH_DATE, UPDATE_USER, UPDATE_DATE (identifier from sequence `MEDICARE_QUERY_HISTORY_SEQ.NEXTVAL`) |

## LINQ statement

Source: `Services/SAIF.Services/Claims/Medicare/MedicareService.cs:121`.

```csharp
// Services/SAIF.Services/Claims/Medicare/MedicareService.cs:121
_unitOfWork.GetRepository<MedicareQueryHistory>().Add(newHistory);
```

## 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 MEDICARE_QUERY_HISTORY_SEQ.NEXTVAL
FROM DUAL

INSERT INTO MEDICARE_QUERY_HISTORY (
  MEDICARE_QUERY_HISTORY_SEQ_NUM,
  UPDATE_NUM,
  CLAIM_PERSON_ID,
  FIRST_SUBMISSION_DATE,
  LAST_SUBMISSION_DATE,
  TAX_ID,
  LAST_NAME,
  FIRST_INITIAL,
  GENDER_CODE,
  BIRTH_DATE,
  PRIMARY_TAX_ID_FLAG,
  MEDICARE_BENEFICIARY_FLAG,
  RESPONSE_MEDICARE_CLAIM_NUMBER,
  RESPONSE_TAX_ID,
  RESPONSE_LAST_NAME,
  RESPONSE_FIRST_INITIAL,
  RESPONSE_GENDER_CODE,
  RESPONSE_BIRTH_DATE,
  UPDATE_USER,
  UPDATE_DATE)
VALUES (
  :Id,
  :UpdateNum,
  :PersonId,
  :FirstSubmissionDate,
  :LastSubmissionDate,
  :TaxId,
  :LastName,
  :FirstInitial,
  :GenderCode,
  :BirthDate,
  :IsPrimaryTaxId,
  :IsMedicareBeneficiary,
  :ResponseMedicareClaimNumber,
  :ResponseTaxId,
  :ResponseLastName,
  :ResponseFirstInitial,
  :ResponseGenderCode,
  :ResponseBirthDate,
  :UpdateUser,
  :UpdateDate)
```

Translation notes:
- `:Id` is the value fetched from sequence `MEDICARE_QUERY_HISTORY_SEQ` (`GeneratedBy.Native("MEDICARE_QUERY_HISTORY_SEQ")`) before the INSERT; NHibernate assigns it to `MedicareQueryHistory.Id`.
- `:IsPrimaryTaxId`, `:IsMedicareBeneficiary` are bound as `'Y'` / `'N'` (`YesNoType`).

## Operations and processes
- MedicareService.InsertMedicareQueryHistory — see [Operations and processes](../operations-processes.md)

> **Note:** Statements marked with `**` could not be confirmed; treat as unknown until verified.

## Sources
- `Services/SAIF.Services/Claims/Medicare/MedicareService.cs (L121)`
