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

CID validation for coded concepts.

Validates whether a `Dicom.SR.Code` is a member of a DICOM Context Group (CID).
Non-extensible CIDs reject codes not in the defined set; extensible CIDs accept
any code but signal it via `{:ok, :extensible}`.

# `validation_result`

```elixir
@type validation_result() ::
  :ok | {:ok, :extensible} | {:error, :not_in_cid} | {:error, :unknown_cid}
```

# `extensible?`

```elixir
@spec extensible?(non_neg_integer()) :: boolean() | :error
```

Returns whether a context group is extensible.

# `name`

```elixir
@spec name(non_neg_integer()) :: {:ok, String.t()} | :error
```

Returns the name of a context group.

# `size`

```elixir
@spec size() :: non_neg_integer()
```

Returns the number of context groups in the registry.

# `valid?`

```elixir
@spec valid?(Dicom.SR.Code.t(), non_neg_integer()) :: boolean()
```

Returns `true` if the code is valid for the given CID.

A code is valid if it is a defined member or the CID is extensible.

# `validate`

```elixir
@spec validate(Dicom.SR.Code.t(), non_neg_integer()) :: validation_result()
```

Validates a code against a context group.

Returns:
  - `:ok` — code is a defined member of the CID
  - `{:ok, :extensible}` — code is not in the CID but the CID is extensible
  - `{:error, :not_in_cid}` — code is not in a non-extensible CID
  - `{:error, :unknown_cid}` — CID does not exist in the registry

---

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