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

Reference Pointer (RP) -- HL7v2 composite data type.

Points to data stored externally to the message. Common in OBX-5
when value_type is "RP".

4 components:
1. Pointer (ST) -- reference to external data (e.g., URL, file path)
2. Application ID (HD) -- sub-components delimited by `&`
3. Type of Data (ID) -- Table 0191: e.g., "Application", "Audio", "Image", "TEXT"
4. Subtype (ID) -- Table 0291: e.g., "PDF", "JPEG", "DICOM"

# `t`

```elixir
@type t() :: %HL7v2.Type.RP{
  application_id: HL7v2.Type.HD.t() | nil,
  pointer: binary() | nil,
  subtype: binary() | nil,
  type_of_data: binary() | nil
}
```

# `encode`

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

Encodes an RP to a list of component strings.

## Examples

    iex> HL7v2.Type.RP.encode(%HL7v2.Type.RP{
    ...>   pointer: "/reports/12345.pdf",
    ...>   application_id: %HL7v2.Type.HD{namespace_id: "LAB", universal_id: "1.2.3", universal_id_type: "ISO"},
    ...>   type_of_data: "Application",
    ...>   subtype: "PDF"
    ...> })
    ["/reports/12345.pdf", "LAB&1.2.3&ISO", "Application", "PDF"]

    iex> HL7v2.Type.RP.encode(%HL7v2.Type.RP{pointer: "/image.jpg"})
    ["/image.jpg"]

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

# `parse`

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

Parses an RP from a list of components.

## Examples

    iex> HL7v2.Type.RP.parse(["/reports/12345.pdf", "LAB&1.2.3&ISO", "Application", "PDF"])
    %HL7v2.Type.RP{
      pointer: "/reports/12345.pdf",
      application_id: %HL7v2.Type.HD{namespace_id: "LAB", universal_id: "1.2.3", universal_id_type: "ISO"},
      type_of_data: "Application",
      subtype: "PDF"
    }

    iex> HL7v2.Type.RP.parse(["http://example.com/image.jpg"])
    %HL7v2.Type.RP{pointer: "http://example.com/image.jpg"}

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

---

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