# `HL7v2.Segment.MSH`
[🔗](https://github.com/Balneario-de-Cofrentes/hl7v2/blob/v3.10.1/lib/hl7v2/segment/msh.ex#L1)

Message Header (MSH) segment — HL7v2 v2.5.1, with v2.7+ extensions.

The first segment of every HL7v2 message. MSH-1 and MSH-2 receive special
treatment: MSH-1 is the field separator character itself, and MSH-2 is the
encoding characters literal string.

21 fields per HL7 v2.5.1 specification, plus v2.7+ optional fields 22-25:
sending/receiving responsible organization (XON) and sending/receiving
network address (HD).

# `t`

```elixir
@type t() :: %HL7v2.Segment.MSH{
  accept_acknowledgment_type: term(),
  alternate_character_set_handling_scheme: term(),
  application_acknowledgment_type: term(),
  character_set: term(),
  continuation_pointer: term(),
  country_code: term(),
  date_time_of_message: term(),
  encoding_characters: term(),
  extra_fields: term(),
  field_separator: term(),
  message_control_id: term(),
  message_profile_identifier: term(),
  message_type: term(),
  principal_language_of_message: term(),
  processing_id: term(),
  receiving_application: term(),
  receiving_facility: term(),
  receiving_network_address: term(),
  receiving_responsible_organization: term(),
  security: term(),
  sending_application: term(),
  sending_facility: term(),
  sending_network_address: term(),
  sending_responsible_organization: term(),
  sequence_number: term(),
  version_id: term()
}
```

# `encode`

```elixir
@spec encode(t()) :: list()
@spec encode(t()) :: list()
```

Encodes MSH with special handling for MSH-1 and MSH-2.

# `parse`

```elixir
@spec parse(list(), HL7v2.Separator.t()) :: t()
@spec parse(list(), HL7v2.Separator.t()) :: t()
```

Parses MSH with special handling for MSH-1 (field separator) and MSH-2
(encoding characters), which are stored as-is rather than type-parsed.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
