HL7v2.Type.ED (HL7v2 v3.10.1)

Copy Markdown View Source

Encapsulated Data (ED) -- HL7v2 composite data type.

Used for transmitting encapsulated data from other standards (e.g., PDF, JPEG, DICOM, CDA). Common in OBX-5 when value_type is "ED".

5 components:

  1. Source Application (HD) -- sub-components delimited by &
  2. Type of Data (ID) -- Table 0191: e.g., "Application", "Audio", "Image", "TEXT"
  3. Data Subtype (ID) -- Table 0291: e.g., "PDF", "RTF", "JPEG", "DICOM", "x-hl7-cda-level-one"
  4. Encoding (ID) -- Table 0299: "A" (no encoding), "Hex", "Base64"
  5. Data (TX) -- the actual encoded data

Summary

Functions

Encodes an ED to a list of component strings.

Parses an ED from a list of components.

Types

t()

@type t() :: %HL7v2.Type.ED{
  data: binary() | nil,
  data_subtype: binary() | nil,
  encoding: binary() | nil,
  source_application: HL7v2.Type.HD.t() | nil,
  type_of_data: binary() | nil
}

Functions

encode(ed)

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

Encodes an ED to a list of component strings.

Examples

iex> HL7v2.Type.ED.encode(%HL7v2.Type.ED{
...>   source_application: %HL7v2.Type.HD{namespace_id: "LAB"},
...>   type_of_data: "Application",
...>   data_subtype: "PDF",
...>   encoding: "Base64",
...>   data: "JVBER..."
...> })
["LAB", "Application", "PDF", "Base64", "JVBER..."]

iex> HL7v2.Type.ED.encode(%HL7v2.Type.ED{type_of_data: "TEXT", data_subtype: "plain", encoding: "A", data: "Hello"})
["", "TEXT", "plain", "A", "Hello"]

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

parse(components)

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

Parses an ED from a list of components.

Examples

iex> HL7v2.Type.ED.parse(["LAB&1.2.3&ISO", "Application", "PDF", "Base64", "JVBER..."])
%HL7v2.Type.ED{
  source_application: %HL7v2.Type.HD{namespace_id: "LAB", universal_id: "1.2.3", universal_id_type: "ISO"},
  type_of_data: "Application",
  data_subtype: "PDF",
  encoding: "Base64",
  data: "JVBER..."
}

iex> HL7v2.Type.ED.parse(["", "TEXT", "plain", "A", "Hello world"])
%HL7v2.Type.ED{type_of_data: "TEXT", data_subtype: "plain", encoding: "A", data: "Hello world"}

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