HL7v2.Type.CX (HL7v2 v3.10.1)

Copy Markdown View Source

Extended Composite ID with Check Digit (CX) -- HL7v2 composite data type.

Used for MRN, patient IDs, visit numbers, and other identifiers.

10 components:

  1. ID Number (ST)
  2. Check Digit (ST)
  3. Check Digit Scheme (ID) -- Table 0061
  4. Assigning Authority (HD) -- sub-components delimited by &
  5. Identifier Type Code (ID) -- Table 0203: MR, PI, VN, AN, SS, etc.
  6. Assigning Facility (HD) -- sub-components delimited by &
  7. Effective Date (DT)
  8. Expiration Date (DT)
  9. Assigning Jurisdiction (CWE) -- sub-components delimited by &
  10. Assigning Agency or Department (CWE) -- sub-components delimited by &

Summary

Functions

Encodes a CX to a list of component strings.

Parses a CX from a list of components.

Types

t()

@type t() :: %HL7v2.Type.CX{
  assigning_agency: HL7v2.Type.CWE.t() | nil,
  assigning_authority: HL7v2.Type.HD.t() | nil,
  assigning_facility: HL7v2.Type.HD.t() | nil,
  assigning_jurisdiction: HL7v2.Type.CWE.t() | nil,
  check_digit: binary() | nil,
  check_digit_scheme: binary() | nil,
  effective_date: Date.t() | HL7v2.Type.DT.t() | nil,
  expiration_date: Date.t() | HL7v2.Type.DT.t() | nil,
  id: binary() | nil,
  identifier_type_code: binary() | nil
}

Functions

encode(cx)

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

Encodes a CX to a list of component strings.

Examples

iex> HL7v2.Type.CX.encode(%HL7v2.Type.CX{id: "12345", assigning_authority: %HL7v2.Type.HD{namespace_id: "MRN"}, identifier_type_code: "MR"})
["12345", "", "", "MRN", "MR"]

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

parse(components)

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

Parses a CX from a list of components.

Components containing sub-components (HD, CWE) are split by & and parsed into their respective structs.

Examples

iex> HL7v2.Type.CX.parse(["12345", "", "", "MRN", "MR"])
%HL7v2.Type.CX{id: "12345", assigning_authority: %HL7v2.Type.HD{namespace_id: "MRN"}, identifier_type_code: "MR"}

iex> HL7v2.Type.CX.parse(["12345", "", "", "MRN&1.2.3&ISO", "MR"])
%HL7v2.Type.CX{
  id: "12345",
  assigning_authority: %HL7v2.Type.HD{namespace_id: "MRN", universal_id: "1.2.3", universal_id_type: "ISO"},
  identifier_type_code: "MR"
}

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