HL7.Query.data

You're seeing just the function data, go back to HL7.Query module for more information.

Specs

data(t(), (t() -> map())) :: t()

Associates data with each selection. This data remains accessible to child selections.

Each selection stores a map of data. The supplied fun should accept an HL7.Query and return a map of key-values to be merged into the existing map of data.

Selections automatically include the index of the current selection, i.e., %{index: 5}. For HL7 numbering, the index values begin at 1.

Examples

iex> import HL7.Query
iex> HL7.Examples.nist_immunization_hl7()
...> |> select("ORC RXA RXR {[OBX]}")
...> |> data(fn q -> %{order_num: get_part(q, "ORC-3.1")} end)
...> |> select("OBX")
...> |> replace_parts("6", fn q -> get_datum(q, :order_num) end)
...> |> root()
...> |> get_part("OBX-6")
"IZ-783278"

iex> import HL7.Query
iex> HL7.Examples.nist_immunization_hl7()
...> |> select("ORC RXA RXR {[OBX]}")
...> |> data(fn q -> %{group_num: get_index(q)} end)
...> |> select("OBX")
...> |> replace_parts("6", fn q -> get_datum(q, :group_num) end)
...> |> root()
...> |> get_parts("OBX-6")
[1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]