View Source HL7.Message (elixir_hl7 v0.9.3)

This module is deprecated. Use `HL7` instead..

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.t/0 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.

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.

Types

@type content_hl7() :: raw_hl7() | parsed_hl7()
@type fragment_hl7() :: String.t() | [list() | String.t()]
@type parsed_hl7() :: [segment_hl7()] | t()
@type raw_hl7() :: String.t() | HL7.RawMessage.t()
@type segment_hl7() :: [fragment_hl7()]
@type t() :: %HL7.Message{
  fragments: term(),
  header: nil | HL7.Header.t(),
  segments: nil | list(),
  tag: term()
}

Functions

Link to this function

find(segments, segment_name)

View Source
@spec 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
@spec new(content_hl7() | HL7.Header.t(), map()) :: t() | HL7.InvalidMessage.t()

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"]

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.

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

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