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

Repeat Interval (RI) -- HL7v2 composite data type.

Specifies the interval between repeated services. Used in TQ-2
(Timing/Quantity interval component).

2 components:
1. Repeat Pattern (IS) -- coded pattern, e.g., "Q6H", "BID", "TID"
2. Explicit Time Interval (ST) -- explicit interval, e.g., "Q2H", "300S"

# `t`

```elixir
@type t() :: %HL7v2.Type.RI{
  explicit_time_interval: binary() | nil,
  repeat_pattern: binary() | nil
}
```

# `encode`

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

Encodes an RI to a list of component strings.

## Examples

    iex> HL7v2.Type.RI.encode(%HL7v2.Type.RI{repeat_pattern: "Q6H", explicit_time_interval: "6 hours"})
    ["Q6H", "6 hours"]

    iex> HL7v2.Type.RI.encode(%HL7v2.Type.RI{repeat_pattern: "BID"})
    ["BID"]

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

# `parse`

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

Parses an RI from a list of components.

## Examples

    iex> HL7v2.Type.RI.parse(["Q6H", "6 hours"])
    %HL7v2.Type.RI{repeat_pattern: "Q6H", explicit_time_interval: "6 hours"}

    iex> HL7v2.Type.RI.parse(["BID"])
    %HL7v2.Type.RI{repeat_pattern: "BID"}

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

---

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