HL7v2.Segment.OBXValue (HL7v2 v3.10.1)

Copy Markdown View Source

Dispatches OBX-5 (observation_value) parsing based on OBX-2 (value_type).

When OBX-2 declares a known data type, the observation value is parsed into the corresponding typed struct. Unknown types are preserved as raw values.

Per the HL7 v2.5.1 specification (Section 7.4.2), the data type of OBX-5 varies at runtime based on the value of OBX-2.

Summary

Functions

Encodes a typed OBX-5 value back to its raw wire representation.

Returns all known value type codes.

Parses OBX-5 value(s) based on the declared value type from OBX-2.

Returns the type module for a given OBX-2 value, or nil.

Functions

encode(value, value_type)

@spec encode(term(), binary() | nil) :: term()

Encodes a typed OBX-5 value back to its raw wire representation.

Used before segment encoding so the :raw encode path receives a value the wire encoder can serialize (strings and lists of strings).

known_types()

@spec known_types() :: [binary()]

Returns all known value type codes.

parse(raw_value, value_type)

@spec parse(term(), binary() | nil) :: term()

Parses OBX-5 value(s) based on the declared value type from OBX-2.

Returns the parsed value for single values, or a list for repeating values. Unknown types are preserved as-is (raw).

type_for(value_type)

@spec type_for(binary()) :: module() | nil

Returns the type module for a given OBX-2 value, or nil.