README

HL7

Parses HL7 v2.x messages encoded in ER7.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(segments []Segment) ([]byte, error)

Marshal converts a slice of Segment structs to a byte array containing an HL7 message in "pipehat" format.

Types

type Component

type Component []Data

Component is a type that contains Fields and SubComponents. Usually separated by '^'. e.g. component1^component2

func (*Component) Append

func (c *Component) Append(values ...Data) error

Append appends Data to this Component.

func (Component) Index

func (c Component) Index(index int) (Data, bool)

Index returns the Data at a certain index inside this Component.

func (Component) Len

func (c Component) Len() int

type Composer

type Composer interface {
	Data
	Append(values ...Data) error
}

Composer is an interface that represents a piece of data that is indexable and composable.

type Data

type Data interface {
	Index(index int) (Data, bool)
	Len() int
}

Data is an interface the represents a piece of data that is indexable.

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

func (*Decoder) Decode

func (d *Decoder) Decode() (segments []Segment, err error)

type Encoder

type Encoder struct {
	Writer io.Writer
	// contains filtered or unexported fields
}

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

NewEncoder creates and initializes an Encoder which will write an encoded HL7 message to the provided io.Writer.

func (*Encoder) Encode

func (e *Encoder) Encode(segments []Segment) (err error)

Encode converts the provided slice of Segments stored in the Encoder to an HL7 "pipehat" encoded message and writes it to the io.Writer set in its Writer field. The Segment slice must contain a valid message header (MSH) segment with fields 1 and 2 populated with the field separator and escape characters; if this segment is not present, Encode will return an error.

type Field

type Field []byte

Field represents a slice of bytes. This is the most basic type in a HL7 message. e.g., in: MSH|^~\&|field|component1^component2 "MSH", "^~\&", "field", "component1", "component2" are all Fields.

func (Field) Index

func (f Field) Index(index int) (Data, bool)

Index just returns itself at index 0.

func (Field) Len

func (f Field) Len() int

func (Field) String

func (f Field) String() string

type Repeated

type Repeated []Data

Repeated is a type that contains Fields, SubComponents, and Components. Usually separated by '~'. e.g. component1a^component2a~component1b^component2b

func (*Repeated) Append

func (r *Repeated) Append(values ...Data) error

Append appends Data to this Repeated.

func (Repeated) Index

func (r Repeated) Index(index int) (Data, bool)

Index returns the Data at a certain index inside this Repeated.

func (Repeated) Len

func (r Repeated) Len() int

type Segment

type Segment []Data

Segment is a type that contains Fields, SubComponents, Components, and Repeated. Usually separated by '|'. e.g. MSH|field1

func Unmarshal

func Unmarshal(b []byte) (segments []Segment, err error)

Unmarshal takes the bytes passed and returns the segments of the hl7 message.

func (*Segment) Append

func (s *Segment) Append(values ...Data) (err error)

Append appends Data to this Segment.

func (Segment) Index

func (s Segment) Index(index int) (Data, bool)

Index returns the Data at a certain index inside this Segment.

func (Segment) Len

func (s Segment) Len() int

type SubComponent

type SubComponent []Field

SubComponent is a type that contains Fields. Usually separated by '&'. e.g. subcomponent1&subcomponent2

func (*SubComponent) Append

func (s *SubComponent) Append(values ...Data) error

Append appends Data to this SubComponent.

func (SubComponent) Index

func (s SubComponent) Index(index int) (Data, bool)

Index returns the Data at a certain index inside this SubComponent.

func (SubComponent) Len

func (s SubComponent) Len() int