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

# BhtSegment

`BhtSegment` models the X12 BHT beginning-of-hierarchical-transaction segment, the header that opens the business-transaction body of an 837/835/277 transaction set, carrying the transaction's purpose, reference identifier, date/time, and transaction type. Its `IsOriginal` flag records whether the transaction is an original submission or a reissue, mapped to the literal codes `"00"`/`"08"` ([BR-044](../../business-rules.md#br-044-bht-original-vs-reissue-flag)).

## Purpose
- Represents the BHT segment identity via `SegmentId` returning the literal `"BHT"` ([BR-020](../../business-rules.md#br-020-first-element-is-the-segment-identifier)).
- Carries the hierarchical structure code, an original/reissue flag, a reference identifier, a transaction date/time, and a transaction type code that together open the business transaction body.
- Encodes `IsOriginal` as `"00"` (original submission) or `"08"` (reissue) on `Build()`, and decodes it back to a boolean by comparing against `"00"` on `Fill()` ([BR-044](../../business-rules.md#br-044-bht-original-vs-reissue-flag)).

## 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 `"BHT"`. |
| StructureCode | `string StructureCode { get; set; }` | The hierarchical structure code describing the transaction's structural purpose (BHT01), read/written at element 1. |
| IsOriginal | `bool IsOriginal { get; set; }` | True for an original submission (written/read as `"00"`), false for a reissue (written as `"08"`) ([BR-044](../../business-rules.md#br-044-bht-original-vs-reissue-flag)). |
| ReferenceId | `string ReferenceId { get; set; }` | The submitter's reference identifier for the transaction (BHT03), read/written at element 3. |
| TransactionDate | `DateTime TransactionDate { get; set; }` | The transaction's creation date and time, split into date (`yyyyMMdd`) and time (`HHmmss`) across elements 4-5 on `Build()`, and combined via `DateMaker` on `Fill()`. |
| TransactionType | `string TransactionType { get; set; }` | The transaction type code (BHT06), read/written at element 6. |
| Build | `IEdiSegment Build()` | Creates a `SegmentBuilder("BHT")`, adds `StructureCode`, the `IsOriginal` flag as `"00"`/`"08"`, `ReferenceId`, `TransactionDate` split into date and time elements, and `TransactionType`, returning the built segment. |
| Fill | `void Fill(IEdiSegment segment)` | Reads elements 1-6 via `GetChildValue`, deriving `IsOriginal` from equality with `"00"` and combining elements 4-5 via `DateMaker.MakeDateTime` into `TransactionDate`. |
| Parse | `static BhtSegment Parse(IEdiSegment segment)` | Instantiates a new `BhtSegment`, calls `Fill(segment)` on it, and returns it. |

## Sources
- Common\SAIF.Common.Files\Edi\Segments\BhtSegment.cs
