---
title: Icd10CodeService
summary: API reference for Icd10CodeService.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Services
reference_type: package
---

# Icd10CodeService

Implements `IIcd10CodeService`, the batch loader that reconciles an incoming ICD-10 code feed (`Icd10Class` rows) against the CBP procedure, service, service-description, and diagnosis code tables, inserting new codes and updating changed or deleted ones. It depends on `IUnitOfWork` for persistence, `IBillQueryProvider`/`IClaimQueryProvider` for looking up existing CBP codes, and `IUserProfileService` to stamp records with the current user. It commits work in batches of 2,000 rows to limit transaction size, and applies a Medicare-reportability rule that flags certain diagnosis codes (an explicit deny-list plus codes starting with `V`, `W`, `X`, `Y`, or `Z`) as invalid for Medicare reporting.

## Purpose
- Processes a full ICD-10 file, classifying each row as complete/incomplete and routing complete rows to procedure or diagnosis processing while periodically committing the unit of work.
- Determines whether an ICD-10 entry is a procedure classification or clinical-modification (diagnosis) code and dispatches it accordingly.
- Inserts or updates CBP procedure codes, service codes, service descriptions, and diagnoses, expiring records whose source entry has been marked deleted.
- Flags diagnosis codes that must be excluded from Medicare reporting based on a known list of codes and code-prefix rules.
- Writes control-report log lines describing each add/update action for audit purposes.

## Context
- Namespace: `SAIF.Services.Claims.ICDCodeService`
- Assembly/package: `SAIF.Services` (packaged inside the `SAIF.SAIFCode.Core` NuGet package)

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| Icd10CodeService | `public Icd10CodeService(IUnitOfWork uow, IBillQueryProvider qu, IUserProfileService prof, IClaimQueryProvider claimQueryProvider)` | Wires the unit-of-work, bill/claim query providers, and user-profile service used to persist and stamp ICD code changes. |
| ProcessICDFile | `public IcdResultCount ProcessICDFile(IIcd10CodeService service, IEnumerable<Icd10Class> icdData, DateTime effectiveDate, string icdVersion, long rowsToProcess, bool generateReport, ILogWriter controlReport, ILogWriter reportCounts)` | Iterates the supplied ICD-10 rows (up to `rowsToProcess`, or all if zero), commits every 2,000 processed rows, and returns counts of complete vs. incomplete rows processed. |
| ProcessIcdEntry | `public bool ProcessIcdEntry(Icd10Class icd10Entry, DateTime effectiveDate, string icdVersion, bool generateReport, string currentUser, ILogWriter controlReport, ILogWriter countReport)` | Routes a single entry to procedure or diagnosis processing based on its classification; returns `false` if the entry is neither. |
| ProcessProcedure | `public void ProcessProcedure(Icd10Class icd10Entry, DateTime effectiveDate, string icdVersion, bool generateReport, string currentUser, ILogWriter controlReport, ILogWriter countReport)` | Inserts or updates the matching CBP procedure code, and also inserts/updates the associated CBP service code and service description when the entry is not a procedure classification. |
| ProcessDiagnosis | `public void ProcessDiagnosis(Icd10Class icd10Entry, DateTime effectiveDate, string icdVersion, bool generateReport, string currentUser, ILogWriter controlReport, ILogWriter countReport)` | Inserts a new CBP diagnosis row when none exists (and the entry is not deleted), otherwise updates the existing diagnosis row. |
| InsertProcedure | `public void InsertProcedure(Icd10Class icd10Entry, DateTime effectiveDate, string icdVersion, bool generateReport, string currentUser, ILogWriter controlReport, ILogWriter countReport)` | Creates a new `CbpProcedureCode` from the entry's code/descriptions and adds it via the unit of work. |
| InsertService | `public void InsertService(Icd10Class icd10Entry, DateTime effectiveDate, bool generateReport, string currentUser, ILogWriter controlReport, ILogWriter countReport)` | Creates a new `CbpServiceCodeStateless` row with service type `"Z"`, `IsRp1099Required` set to `true`, and `IsNurseReviewRequired` set to `false`. |
| InsertServiceDescription | `public void InsertServiceDescription(Icd10Class icd10Entry, DateTime effectiveDate, bool generateReport, string currentUser, ILogWriter controlReport, ILogWriter countReport)` | Creates a new `CbpServiceDescriptionStateless` row (service type `"Z"`) holding the trimmed description text. |
| InsertDiagnosis | `public void InsertDiagnosis(Icd10Class icd10Entry, DateTime effectiveDate, string icdVersion, bool generateReport, string currentUser, ILogWriter controlReport, ILogWriter countReport)` | Creates a new `CbpDiagnosis` row, assigning category `"UN"` and computing the Medicare-reportability flag via `GetValidMedicareReportFlag`. |
| UpdateDiagnosis | `public void UpdateDiagnosis(CbpDiagnosis cbpDiagnosis, Icd10Class icd10Entry, DateTime effectiveDate, bool generateReport, string currentUser, ILogWriter controlReport, ILogWriter countReport)` | Updates descriptions and sets/clears the diagnosis's expiration date based on whether the source entry is deleted, persisting only when a field actually changed. |
| UpdateProcedure | `public void UpdateProcedure(CbpProcedureCode cbpProcedure, Icd10Class icd10Entry, DateTime effectiveDate, bool generateReport, string currentUser, ILogWriter controlReport, ILogWriter countReport)` | Updates descriptions and sets/clears the procedure's expiration date based on the source entry's deleted flag, persisting only on an actual change. |
| UpdateService | `public void UpdateService(CbpServiceCodeStateless cbpSeviceCode, Icd10Class icd10Entry, DateTime effectiveDate, bool generateReport, string currentUser, ILogWriter controlReport, ILogWriter countReport)` | Sets or clears the service code's expiration date to reflect the source entry's deleted state. |
| UpdateServiceDescription | `public void UpdateServiceDescription(CbpServiceDescriptionStateless cbpServiceDescription, Icd10Class icd10Entry, DateTime effectiveDate, bool generateReport, string currentUser, ILogWriter controlReport, ILogWriter countReport)` | Updates the description text and expiration date of an existing service description when they differ from the source entry. |
| GetCbpProcedureCode | `public CbpProcedureCode GetCbpProcedureCode(string serviceCode, string icdVersion)` | Looks up an existing CBP procedure code for the given code/ICD version via `IClaimQueryProvider.BillQueries`. |
| GetCbpDiagnosisCode | `public CbpDiagnosis GetCbpDiagnosisCode(string serviceCode, string icdVersion)` | Looks up an existing CBP diagnosis for the given code/ICD version via `IClaimQueryProvider.BillQueries`. |
| GetCbpServiceCode | `public CbpServiceCodeStateless GetCbpServiceCode(string serviceCode, DateTime effectiveDate)` | Returns the existing service-code row (type `"Z"`) only if its effective date is on or after the supplied date; otherwise `null`. |
| GetCbpServiceDescription | `public CbpServiceDescriptionStateless GetCbpServiceDescription(string serviceCode, DateTime effectieDate)` | Returns the existing service description only if its effective date is on or after the supplied date; otherwise `null`. |
| GetTrimmedDescription | `public string GetTrimmedDescription(string desc, int maxLength)` | Truncates a description to `maxLength` characters, returning it unchanged if already within the limit. |
| GetValidMedicareReportFlag | `public bool GetValidMedicareReportFlag(string diagnosisCode)` | Returns `false` for a fixed deny-list of diagnosis codes (e.g. symptom/injury R- and T-codes) or any code beginning with `V`, `W`, `X`, `Y`, or `Z`; otherwise `true`, indicating the diagnosis is valid for Medicare reporting. |
| WriteControlReport | `public void WriteControlReport(string writeMessage, Icd10Class icd10Entry, ILogWriter controlReport)` | Writes a log line combining the supplied message with the entry's code and short description. |

## Behavioral notes
- `ProcessICDFile` commits the unit of work every 2,000 rows via `unitOfWork.Begin()`/`Commit()` to keep transactions bounded for large ICD-10 feeds.
- `GetValidMedicareReportFlag` encodes a fixed, hardcoded* deny-list of diagnosis codes rather than reading it from a data table.
- Insert/Update methods only call `unitOfWork...Update(...)` when a field actually changed (`updateFlag`), avoiding no-op writes.

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts. Statements
> marked with ** could not be confirmed; treat as unknown until verified.

## Sources
- Services/SAIF.Services/Claims/ICDCodeService/Icd10CodeService.cs
