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

Repeat Pattern (RPT) -- HL7v2 composite data type.

Defines a repeating schedule pattern for timing-related segments (TQ1-3).
More expressive than RI, supporting calendar-aligned and phase-based
patterns.

10 components per HL7 v2.5.1:
1. Repeat Pattern Code (CWE) -- sub-components delimited by `&`, Table 0335
2. Calendar Alignment (ID) -- Table 0527
3. Phase Range Begin Value (NM)
4. Phase Range End Value (NM)
5. Period Quantity (NM)
6. Period Units (IS)
7. Institution Specified Time (ID) -- Table 0136 (Y/N)
8. Event (ID) -- Table 0528
9. Event Offset Quantity (NM)
10. Event Offset Units (IS)

# `t`

```elixir
@type t() :: %HL7v2.Type.RPT{
  calendar_alignment: binary() | nil,
  event: binary() | nil,
  event_offset_quantity: HL7v2.Type.NM.t() | nil,
  event_offset_units: binary() | nil,
  institution_specified_time: binary() | nil,
  period_quantity: HL7v2.Type.NM.t() | nil,
  period_units: binary() | nil,
  phase_range_begin_value: HL7v2.Type.NM.t() | nil,
  phase_range_end_value: HL7v2.Type.NM.t() | nil,
  repeat_pattern_code: HL7v2.Type.CWE.t() | nil
}
```

# `encode`

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

Encodes an RPT to a list of component strings.

## Examples

    iex> HL7v2.Type.RPT.encode(%HL7v2.Type.RPT{
    ...>   repeat_pattern_code: %HL7v2.Type.CWE{identifier: "QAM", text: "Every morning", name_of_coding_system: "HL70335"}
    ...> })
    ["QAM&Every morning&HL70335"]

    iex> HL7v2.Type.RPT.encode(%HL7v2.Type.RPT{
    ...>   repeat_pattern_code: %HL7v2.Type.CWE{identifier: "Q6H"},
    ...>   period_quantity: %HL7v2.Type.NM{value: "6", original: "6"},
    ...>   period_units: "h"
    ...> })
    ["Q6H", "", "", "", "6", "h"]

    iex> HL7v2.Type.RPT.encode(nil)
    []

# `parse`

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

Parses an RPT from a list of components.

## Examples

    iex> HL7v2.Type.RPT.parse(["QAM&Every morning&HL70335"])
    %HL7v2.Type.RPT{
      repeat_pattern_code: %HL7v2.Type.CWE{identifier: "QAM", text: "Every morning", name_of_coding_system: "HL70335"}
    }

    iex> HL7v2.Type.RPT.parse(["Q6H&Every 6 hours&HL70335", "DY", "", "", "6", "h"])
    %HL7v2.Type.RPT{
      repeat_pattern_code: %HL7v2.Type.CWE{identifier: "Q6H", text: "Every 6 hours", name_of_coding_system: "HL70335"},
      calendar_alignment: "DY",
      period_quantity: %HL7v2.Type.NM{value: "6", original: "6"},
      period_units: "h"
    }

    iex> HL7v2.Type.RPT.parse([])
    %HL7v2.Type.RPT{}

---

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