---
title: HiSegment
summary: API reference for HiSegment.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-15
library: SAIF.Framework.Common.Files
reference_type: package
---

# HiSegment

`HiSegment` models the X12 HI health-care diagnosis-code segment, used in 837 claim transactions to carry the repeating list of diagnosis codes (and optionally associated date/date-range information) attached to a claim. It is inbound-only in this library: `Build()` throws `NotImplementedException` ([BR-054](../../business-rules.md#br-054-dmg-hi-sv1-sv2-sv3-are-inbound-only-segments)).

## Purpose
- Represents the HI segment identity via `SegmentId` returning the literal `"HI"` ([BR-020](../../business-rules.md#br-020-first-element-is-the-segment-identifier)).
- Carries parallel arrays `TypeCode`/`CodeValue` for each repeating diagnosis-code composite element, plus `StartDate`/`EndDate` when a composite carries date qualifier information.
- Is inbound-only: `Fill(IEdiSegment)` populates the arrays from a parsed segment, but `Build()` throws `NotImplementedException` ([BR-054](../../business-rules.md#br-054-dmg-hi-sv1-sv2-sv3-are-inbound-only-segments)).

## Context
- Namespace: `SAIF.Common.Files.Edi.Segments`
- Assembly/package: `SAIF.Framework.Common.Files`

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| SegmentId | `string SegmentId { get; }` | Returns the literal X12 segment identifier `"HI"`. |
| TypeCode | `string[] TypeCode { get; set; }` | The diagnosis-code-set qualifier for each repeating composite element (sub-element 1 of each HI0n composite), sized to the segment's element count. |
| CodeValue | `string[] CodeValue { get; set; }` | The diagnosis code value for each repeating composite element (sub-element 2), parallel to `TypeCode`. |
| StartDate | `DateTime?[] StartDate { get; set; }` | The start date for a composite whose format qualifier (sub-element 3) is `"D8"` or `"RD8"`, parallel to `TypeCode`. |
| EndDate | `DateTime?[] EndDate { get; set; }` | The end date for a composite whose format qualifier is `"RD8"`, parallel to `TypeCode`. |
| Build | `IEdiSegment Build()` | Always throws `NotImplementedException`; outbound HI generation is not supported ([BR-054](../../business-rules.md#br-054-dmg-hi-sv1-sv2-sv3-are-inbound-only-segments)). The commented-out implementation in source suggests the intended shape would iterate composite elements and add `TypeCode`/`CodeValue` sub-elements per position*. |
| Fill | `void Fill(IEdiSegment segment)` | Sizes all four arrays to the segment's element count, then for indices 1 through elementCount-1 reads each composite element's type code and code value, and — when the composite carries more than three sub-elements — reads a date-format qualifier (sub-element 3) and derives `StartDate`/`EndDate` for `"D8"`/`"RD8"` formats via `DateMaker`. |
| Parse | `static HiSegment Parse(IEdiSegment segment)` | Instantiates a new `HiSegment`, calls `Fill(segment)` on it, and returns it. |

## Behavioral notes
- The loop in `Fill()` starts at index `i = 1` rather than `0` while sizing all four arrays to `elementCount`, leaving index 0 of every array unused; whether this offset is intentional (e.g. to align with 1-based composite numbering) or an off-by-one defect is unconfirmed**.
- The source carries a comment above the `TypeCode[i]` assignment stating "this line of code produces a null pointer exception"; the surrounding code already allocates the arrays before that assignment, so the comment may be stale relative to the current implementation, but this could not be confirmed**.

## Constraints and usage notes
- Any caller invoking `Build()` on an `HiSegment` receives a `NotImplementedException` rather than a built segment ([BR-054](../../business-rules.md#br-054-dmg-hi-sv1-sv2-sv3-are-inbound-only-segments)).

> **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
- Common\SAIF.Common.Files\Edi\Segments\HiSegment.cs
