HL7v2.Type.TS (HL7v2 v3.10.1)

Copy Markdown View Source

Time Stamp (TS) -- HL7v2 composite data type.

Legacy composite with 2 components: time (DTM format) and degree of precision. Retained for backward compatibility with v2.4 and earlier. In v2.5+, DTM is preferred for new fields.

Component 2 (degree of precision) is deprecated. Values from Table 0529: Y (year), L (month), D (day), H (hour), M (minute), S (second).

Summary

Functions

Encodes a timestamp to a list of component strings.

Parses a timestamp from a list of components.

Types

t()

@type t() :: %HL7v2.Type.TS{
  degree_of_precision: binary() | nil,
  time: HL7v2.Type.DTM.t() | nil
}

Functions

encode(ts)

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

Encodes a timestamp to a list of component strings.

Examples

iex> HL7v2.Type.TS.encode(%HL7v2.Type.TS{time: %HL7v2.Type.DTM{year: 2026, month: 3, day: 22}})
["20260322"]

iex> HL7v2.Type.TS.encode(%HL7v2.Type.TS{time: %HL7v2.Type.DTM{year: 2026, month: 3, day: 22}, degree_of_precision: "D"})
["20260322", "D"]

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

parse(components)

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

Parses a timestamp from a list of components.

Examples

iex> HL7v2.Type.TS.parse(["20260322143022"])
%HL7v2.Type.TS{time: %HL7v2.Type.DTM{year: 2026, month: 3, day: 22, hour: 14, minute: 30, second: 22}}

iex> HL7v2.Type.TS.parse(["20260322", "D"])
%HL7v2.Type.TS{time: %HL7v2.Type.DTM{year: 2026, month: 3, day: 22}, degree_of_precision: "D"}

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