---
title: Serialize import metadata
summary: Converts a populated clsImageImport instance into the newline-delimited KEY=VALUE text contract used by downstream imaging consumers.
status: draft
owner: SAIF
last_reviewed: 2026-07-30
library: SAIF.Services.Imaging.Import
reference_type: package
operation_id: OP-SII-01
trigger: A caller invokes clsImageImport.ToString() on a populated instance
---

# Serialize import metadata

This operation converts a populated `clsImageImport` data-transfer object into the fixed-order, newline-delimited `KEY=VALUE` string contract that downstream consumers (such as `SAIF.Services.Printing`) send onward as an outbound imaging request payload. It is the only operation this library implements.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-SII-01 |
| **Trigger** | A caller (e.g. `clsPrint.ImportInfo`) invokes `ToString()` on a populated `clsImageImport` instance |
| **Inputs** | A populated `clsImageImport` instance — string, numeric, and date properties such as `BatID`, `ClaimID`, `ClaimNum`, `CommentText`, `ImageFileCode`, `DocumentDate`, `DocumentDateDays`, `NPages`, `PolicyNum`, `AffiliationId`, `LegalCaseId`, and related task/imaging fields |
| **Outputs** | A single newline-delimited (`vbCrLf`-separated) string of `KEY=VALUE` lines, one per property, in fixed declaration order |
| **Primary components** | `clsImageImport.ToString` |
| **Entry point** | `Services\SAIF.Services.Imaging.Import\clsImageImport.vb` |

## Steps

1. Create a new `Text.StringBuilder` to accumulate the output.
2. Append fixed-order lines for string-backed fields — `BATID`, `CLAIMID`, `CLAIMNUM`, `CommentText`, `CreateUser`, `DiscoveryFlag`, `DisplayField1`–`DisplayField3`, `ImageFileCode`, `ImageCategoryCode`, `ImageDocumentTypeCode`, `ImageDeleteFlag`, `ImageIndexFlag`, `ImageDocumentNameCode`, `ExternalViewCode`, `SystemGeneratedFlag`, `AgencyID`, `ProducerID`, `GroupAssociationCode`, `Spec`, `TaskCategory`, `TaskMailIDList`, `TaskPriority`, `TaskSecurity`, `TaskText`, `PolicyAccount`, `PolicySecuredFlag`, `LegalCaseNum`, `LegalCopyToClaimFlag`, and `LegalDistributionFlag` — appending each property's raw value with no blank-suppression logic.
3. For `DocumentDate`, `ReceivedDate`, and `TaskDate`, emit the value formatted as `MM-dd-yyyy` only when the value is strictly between `Date.MinValue` and `Date.MaxValue`; otherwise emit the key with a blank value ([BR-002](../business-rules.md#br-002-format-optional-dates-as-mm-dd-yyyy-or-blank)).
   - If the date is at either sentinel bound: append the key with an empty value instead of a formatted date.
4. For `DocumentDateDays`, `ImageSeqNum`, `NPages`, `PolicyNum`, `AffiliationId`, and `LegalCaseId`, emit the numeric value only when it is greater than zero; otherwise emit the key with a blank value ([BR-001](../business-rules.md#br-001-blank-numeric-fields-when-unset)).
   - If the numeric value is zero or negative: append the key with an empty value instead of the number.
5. Return the completed string via `Result.ToString`.

## Process flow

The following diagram visualizes the serialization control flow, including the two conditional formatting branches applied while building the output.

```mermaid
flowchart TD
	Start([Caller invokes ToString]) --> Build[Create StringBuilder]
	Build --> AppendStrings[Append fixed-order string fields]
	AppendStrings --> Dates{Date between<br>MinValue and MaxValue?}
	Dates -->|Yes| FormatDates[Append MM-dd-yyyy]
	Dates -->|No| BlankDates[Append blank date value]
	FormatDates --> Numbers{Numeric value greater than 0?}
	BlankDates --> Numbers
	Numbers -->|Yes| AppendNumbers[Append numeric value]
	Numbers -->|No| BlankNumbers[Append blank numeric value]
	AppendNumbers --> Finish([Return completed string])
	BlankNumbers --> Finish
```

## Failure and edge-case behavior

- Empty or default string properties are still emitted as keys with blank values; there is no omission of unset string fields.
- Date properties at the `Date.MinValue`/`Date.MaxValue` sentinel bounds serialize as blank rather than as a formatted date ([BR-002](../business-rules.md#br-002-format-optional-dates-as-mm-dd-yyyy-or-blank)).
- Zero or negative numeric properties serialize as blank rather than as `0` or a negative value ([BR-001](../business-rules.md#br-001-blank-numeric-fields-when-unset)).
- The method performs no validation of field combinations, string lengths, or required values before returning the payload; malformed or incomplete data is serialized as-is.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

## Sources
- `Services\SAIF.Services.Imaging.Import\clsImageImport.vb`
