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

Typed HL7v2 message with parsed segment structs.

A `TypedMessage` is the result of converting a `RawMessage` through the
`HL7v2.TypedParser`. Known segments (MSH, PID, PV1, etc.) are represented as
their typed struct, Z-segments as `HL7v2.Segment.ZXX` structs, and truly
unknown segments are preserved as raw `{name, fields}` tuples.

## Escape sequences

Typed field values preserve HL7 escape sequences literally (e.g. `\F\`,
`\S\`, `\R\`, `\E\`, `\T\`, `\Xhh\`). The parser does **not**
decode them automatically because doing so would lose the distinction between
a literal delimiter and an escaped one, breaking round-trip fidelity.

To decode escape sequences in a field value, call `HL7v2.Escape.decode/2`
explicitly:

    sep = msg.separators
    decoded = HL7v2.Escape.decode(pid.patient_name |> hd() |> to_string(), sep)

To encode delimiter characters before setting a field, use `HL7v2.Escape.encode/2`.

# `t`

```elixir
@type t() :: %HL7v2.TypedMessage{
  segments: [struct() | {binary(), list()}],
  separators: HL7v2.Separator.t(),
  type: {binary(), binary()} | {binary(), binary(), binary()}
}
```

---

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