HL7.Message (elixir_hl7 v0.9.0) View Source

Creates, parses and modifies HL7 messages with a focus on performance. Contains a list of parsed segments and header metadata.

Use Hl7.Message.new/2 to create an Hl7.Message struct that contains a fully parsed HL7 message alongside header metadata. The parsed data is represented as minimally as possible as lists of string and lists.

The second argument is an options map supporting the following values:

copy: true -- Will create binary copies while parsing to avoid keeping references. validate_string: true -- Will generate an HL7.InvalidMessage if the source text is not UTF-8 compatible. accept_latin1: true -- If used with validate_string: true, this will take failed validations and attempt to encode any latin1 as UTF-8.

                     If used without `validate_string: true`, this will always attempt to encode any latin1 as UTF-8.

Link to this section Summary

Functions

Returns the first parsed segment matching segment_name from an HL7 message or content.

Creates an HL7.Message struct containing parsed segment list data. It will also expose basic header information (e.g. encoding characters, message type) for routing.

Creates an HL7.Message struct containing the raw HL7 text for further processing. It will also expose basic header information (e.g. encoding characters, message type) for routing.

Returns a parsed list of segments from an HL7 message or content.

Link to this section Types

Specs

content_hl7() :: raw_hl7() | parsed_hl7()

Specs

fragment_hl7() :: String.t() | [list() | String.t()]

Specs

parsed_hl7() :: [segment_hl7()] | t()

Specs

raw_hl7() :: String.t() | HL7.RawMessage.t()

Specs

segment_hl7() :: [fragment_hl7()]

Specs

t() :: %HL7.Message{
  fragments: term(),
  header: nil | HL7.Header.t(),
  segments: nil | list(),
  tag: term()
}

Link to this section Functions

Link to this function

find(segments, segment_name)

View Source

Specs

find(content_hl7(), String.t() | non_neg_integer()) :: segment_hl7() | nil

Returns the first parsed segment matching segment_name from an HL7 message or content.

Link to this function

new(content, options \\ %{copy: false})

View Source

Specs

Creates an HL7.Message struct containing parsed segment list data. It will also expose basic header information (e.g. encoding characters, message type) for routing.

Pass copy: true as the second argument to generate binary copies of all substrings as it parses the message.

Invalid MSH formats will return an HL7.InvalidMessage.

Examples

iex> HL7.Examples.wikipedia_sample_hl7()
...> |> HL7.Message.new()
...> |> HL7.Query.get_segment_names()
["MSH", "EVN", "PID", "PV1", "OBX", "OBX", "AL1", "DG1"]

iex> HL7.Message.new(
...>   "MSH|^~\\&|MegaReg|XYZHospC|SuperOE|XYZImgCtr|" <>
...>   "20060529090131-0500||ADT^A01^ADT_A01|01052901|P|2.5")
...> |> HL7.Query.get_segment_names()
["MSH"]

iex> HL7.Message.new(
...>   [["MSH", "|", "^~\\&", "App", "Facility", "", "",
...>     "20060529090131-0500", "", [["ADT", "A01", "ADT_A01"]],
...>     "01052901", "P", "2.5"]])
...> |> HL7.Query.get_segment_names()
["MSH"]

Specs

Creates an HL7.Message struct containing the raw HL7 text for further processing. It will also expose basic header information (e.g. encoding characters, message type) for routing.

Invalid MSH formats will return an HL7.InvalidMessage struct.

Specs

to_list(content_hl7()) :: [list()]

Returns a parsed list of segments from an HL7 message or content.