View Source ExDicom.Util.Misc (EX_DICOM v0.2.0)

Utility functions for DICOM parsing and data handling.

Summary

Types

Type representing a parsed person name with standard DICOM components.

Functions

Parses a PN (Person Name) formatted string into a map with standardized name components.

Tests if a given tag in the format xggggeeee is a private tag. Private tags are identified by having an odd group number.

Tests if the given VR (Value Representation) is a string type.

Types

person_name()

@type person_name() :: %{
  family_name: String.t() | nil,
  given_name: String.t() | nil,
  middle_name: String.t() | nil,
  prefix: String.t() | nil,
  suffix: String.t() | nil
}

Type representing a parsed person name with standard DICOM components.

Functions

parse_pn(person_name)

@spec parse_pn(String.t() | nil) :: person_name() | nil

Parses a PN (Person Name) formatted string into a map with standardized name components.

Parameters

  • person_name - A string in the PN VR format (components separated by ^)

Returns

  • A map with :family_name, :given_name, :middle_name, :prefix, and :suffix keys
  • nil if input is nil

Examples

iex> ExDicom.Util.parse_pn("Smith^John^A^Dr^Jr")
%{
  family_name: "Smith",
  given_name: "John",
  middle_name: "A",
  prefix: "Dr",
  suffix: "Jr"
}

iex> ExDicom.Util.parse_pn(nil)
nil

private_tag?(tag)

@spec private_tag?(String.t()) :: boolean()

Tests if a given tag in the format xggggeeee is a private tag. Private tags are identified by having an odd group number.

Parameters

  • tag - The DICOM tag in format xggggeeee

Returns

  • true if the tag is private
  • false if the tag is not private

Raises

  • RuntimeError if the fourth character of the tag cannot be parsed as hex

Examples

iex> ExDicom.Util.private_tag?("x00090010")
true

iex> ExDicom.Util.private_tag?("x00080010")
false

string_vr?(vr)

@spec string_vr?(String.t()) :: boolean() | nil

Tests if the given VR (Value Representation) is a string type.

Parameters

  • vr - The VR code to test

Returns

  • true if string type
  • false if not string type
  • nil if unknown VR or UN type

Examples

iex> ExDicom.Util.string_vr?("PN")
true

iex> ExDicom.Util.string_vr?("UN")
nil