# `Dicom.VR`
[🔗](https://github.com/Balneario-de-Cofrentes/dicom/blob/v0.9.1/lib/dicom/vr.ex#L1)

DICOM Value Representations (VR).

Defines the data types used in DICOM attributes: Person Name (PN),
Date (DA), Unique Identifier (UI), Other Byte (OB), etc.

Reference: DICOM PS3.5 Section 6.2.

# `t`

```elixir
@type t() ::
  :AE
  | :AS
  | :AT
  | :CS
  | :DA
  | :DS
  | :DT
  | :FL
  | :FD
  | :IS
  | :LO
  | :LT
  | :OB
  | :OD
  | :OF
  | :OL
  | :OV
  | :OW
  | :PN
  | :SH
  | :SL
  | :SQ
  | :SS
  | :ST
  | :SV
  | :TM
  | :UC
  | :UI
  | :UL
  | :UN
  | :UR
  | :US
  | :UT
  | :UV
```

# `all`

```elixir
@spec all() :: [t()]
```

Returns a sorted list of all 34 VR atoms.

## Examples

    iex> :PN in Dicom.VR.all()
    true

    iex> length(Dicom.VR.all())
    34

# `binary?`

```elixir
@spec binary?(t()) :: boolean()
```

Returns true if the VR represents binary/pixel data.

# `binary_vrs`

```elixir
@spec binary_vrs() :: [t()]
```

Returns the list of binary VR atoms.

# `description`

```elixir
@spec description(t()) :: String.t()
```

Returns the human-readable description for a VR per PS3.5 Table 6.2-1.

## Examples

    iex> Dicom.VR.description(:PN)
    "Person Name"

    iex> Dicom.VR.description(:DA)
    "Date"

# `fixed_length?`

```elixir
@spec fixed_length?(t()) :: boolean()
```

Returns true if the VR has a fixed byte length (AT, FL, FD, SL, SS, UL, US, SV, UV).

# `from_binary`

```elixir
@spec from_binary(binary()) :: {:ok, t()} | {:error, :unknown_vr}
```

Parses a 2-byte VR string into an atom.

## Examples

    iex> Dicom.VR.from_binary("PN")
    {:ok, :PN}

    iex> Dicom.VR.from_binary("XX")
    {:error, :unknown_vr}

# `long_length?`

```elixir
@spec long_length?(t()) :: boolean()
```

Returns true if the VR uses explicit length encoding with a 4-byte length field
(the "long" VRs that use 2 reserved bytes + 4-byte length in Explicit VR).

# `max_length`

```elixir
@spec max_length(t()) :: pos_integer() | :unlimited
```

Returns the maximum character/byte length for a VR, or `:unlimited`.

## Examples

    iex> Dicom.VR.max_length(:PN)
    64

    iex> Dicom.VR.max_length(:UT)
    :unlimited

# `numeric?`

```elixir
@spec numeric?(t()) :: boolean()
```

Returns true if the VR represents a numeric type.

# `numeric_vrs`

```elixir
@spec numeric_vrs() :: [t()]
```

Returns the list of numeric VR atoms.

# `pad_value`

```elixir
@spec pad_value(binary(), t()) :: binary()
```

Pads a binary value to even length per DICOM requirements.

All DICOM value fields must have even length. If the value has
odd length, a single padding byte is appended based on the VR.

# `padding_byte`

```elixir
@spec padding_byte(t()) :: byte()
```

Returns the padding byte for this VR.

Per PS3.5 Section 6.2: UI values are padded with NULL (0x00),
other string VRs are padded with SPACE (0x20), and binary VRs
are padded with 0x00.

# `string?`

```elixir
@spec string?(t()) :: boolean()
```

Returns true if the VR represents a string type.

# `string_vrs`

```elixir
@spec string_vrs() :: [t()]
```

Returns the list of string VR atoms.

# `to_binary`

```elixir
@spec to_binary(t()) :: binary()
```

Converts a VR atom to its 2-byte binary representation.

---

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