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

# AutoImportHelperService

Implements `IAutoImportHelperService`, generating the `.idx` index file that accompanies an auto-imported document, resolving all index metadata (claim/policy identifiers, document date, alert recipients) from reference data. It depends on `IUnitOfWork` for `AutoImportIndexDefaults`/`FileRequest`/`Employee` lookups, `IEnvironmentService` for the configured output directory (`idmfilepath`), `IClaimInformationService` for claim/adjuster lookups, `IConfigurationService` for legal-alert eligibility, `IPolicyQueryProvider` for policy lookups, and `IClaimQueryProvider` for cross-referenced claim numbers.

## Purpose
- Loads the `AutoImportIndexDefaults` configuration row matching a document's description code and uses it to seed the majority of index-file fields.
- Resolves claim or policy details (based on the default's image-file code) to populate claim number, claim ID, and display fields.
- Resolves the dynamic alert-recipient list (`TASK_MAIL_ID_LIST`) by user-ID token: adjuster, legal, requester, VOC (not implemented), or a specific active employee user ID.
- Resolves the document date from the configured date source (date of injury, a fixed policy-default date, or the date parsed from the file name), rejecting dates more than seven days in the future.
- Writes the fully populated `.idx` file to the configured auto-import directory and returns its `FileInfo`.

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

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| AutoImportHelperService(...) | `public AutoImportHelperService(IUnitOfWork unitOfWork, IEnvironmentService environmentService, IClaimInformationService claimInformationService, IConfigurationService imageConfigurationService, IPolicyQueryProvider policyQueryProvider, IClaimQueryProvider claimQueryProvider)` | Wires in all collaborators (enforcing non-null unit of work, environment service, and claim information service) and resolves the auto-import output directory from the `"idmfilepath"` configuration setting. |
| GenerateIdxFile | `public FileInfo GenerateIdxFile(GenerateIdxFileDetail details)` | Loads the index defaults for the document's description code, resolves claim/policy info, alert recipients, and document date, validates the assembled index parameters, writes them as a `.idx` file, and returns the resulting `FileInfo`; throws if no matching index defaults exist or if referenced data cannot be resolved. |
| AutoImportPath | `public string AutoImportPath()` | Returns the configured auto-import output directory path, with a trailing backslash appended. |

## Behavioral notes
- Throws (rather than returning an error result) for essentially every unresolvable condition: missing index defaults, an unrecognized `ImageFileCode`, an invalid claim/policy number, a missing responsible adjuster, a missing file request for a policy, an inactive/unknown alert user ID, a missing injury date when `DOI` is the configured date source, and a document date more than seven days in the future.
- When the index default specifies an `LPTCode`, the document's reference number is rewritten to the cross-referenced claim number (via `IClaimQueryProvider`) before further processing, or an exception is thrown if no cross-reference exists.
- The private `LoadAndValidateIdxKeyValuePairs` helper enforces that several index fields (batch ID, create user, discovery flag, document date, image category code, image document type code, received date, system-generated flag, image file code) are non-null before the file is written, guarding against writing an incomplete index file.

## Sources
- Services/SAIF.Services/Imaging/AutoImportHelperService.cs
