hl7v2

package module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2026 License: MIT Imports: 14 Imported by: 0

README

hl7v2

Go Version Go Reference Documentation

[!WARNING] Pre-v1 API Notice: This repository is under active development. The API is not yet stable and may undergo breaking changes until a v1.0.0 release.

hl7v2 is a high-performance, feature-complete Go library for Health Level Seven (HL7) v2 message parsing, object model manipulation, schema validation, transformation, and MLLP TCP network transmission.

Designed for modern healthcare integration engines and microservices, hl7v2 balances ultra-fast zero-allocation routing with a rich, ergonomic document object model for message mutation and validation.

📖 Full Documentation: https://blushift-io.github.io/hl7v2


Key Features

  • Dual Parsing Architecture:
    • RawMessage: High-speed, zero/low-allocation parser ideal for message routing, filtering, and header inspection.
    • Message: Rich document tree for field mutation, segment insertion, unmarshaling, and schema validation.
  • Location Querying & Grammar Matching:
    • Intuitive location syntax (PID-3.1, MSH-9.2).
    • Structural grammar parsing and selection for complex segment patterns (MSH EVN PID [PD1] {NK1}).
  • Built-in Schemas (v2.1 – v2.8+):
    • Embedded specification definitions for messages, segments, data types, and value tables across HL7 versions v2.1 through v2.8.
  • Automatic Acknowledgments:
    • Effortless ACK/NACK message generation (msg.Ack(), msg.Nack()).
  • MLLP & TCP Networking:
    • Low-level MLLP framing primitives (mllp package).
    • High-level concurrent TCP MLLP server framework (net/tcp package) with context-driven handlers.
    • Reference MLLP server implementation (cmd/mllp_server).
  • Transformation Engine:
    • JavaScript-powered transformation scripts using Goja for dynamic HL7 message mapping.

Installation

Install hl7v2 using standard Go tooling:

go get github.com/blushift-io/hl7v2

Requires Go 1.25 or higher.


Quick Start

1. Fast Read-Only Query (RawMessage)

For message routing or header inspection without constructing a full object tree:

package main

import (
	"fmt"
	"log"

	"github.com/blushift-io/hl7v2"
)

func main() {
	rawHL7 := []byte("MSH|^~\\&|SENDING_APP|SENDING_FAC|REC_APP|REC_FAC|20260810120000||ADT^A01|MSG00001|P|2.5\rPID|1||12345^^^HOSP^MR||DOE^JOHN||19800101|M")

	raw, err := hl7v2.ParseRaw(rawHL7)
	if err != nil {
		log.Fatalf("Parse error: %v", err)
	}

	patientID, _ := raw.Get("PID-3.1")
	fmt.Printf("Patient ID: %s\n", patientID)
}
2. Message Tree & Mutation (Message)

For updating fields, appending segments, or validating against schemas:

package main

import (
	"fmt"
	"log"

	"github.com/blushift-io/hl7v2"
)

func main() {
	hl7Data := []byte("MSH|^~\\&|SEND|FAC|REC|FAC|20260810||ADT^A01|101|P|2.5\rPID|1||999||SMITH^JANE")

	msg, err := hl7v2.NewMessage(hl7Data)
	if err != nil {
		log.Fatalf("Message error: %v", err)
	}

	pid, err := msg.Segment("PID")
	if err == nil {
		fmt.Printf("Segment Name: %s\n", pid.Name())
	}

	// Generate an ACK response
	ack, err := msg.Ack(hl7v2.AckCodeAA)
	if err == nil {
		fmt.Println(string(ack.Encode()))
	}
}
3. MLLP TCP Server (net/tcp)

Set up a concurrent TCP server that accepts HL7 messages over MLLP:

package main

import (
	"log"

	"github.com/blushift-io/hl7v2"
	"github.com/blushift-io/hl7v2/net/tcp"
)

type ServerHandler struct{}

func (h *ServerHandler) OnConnect(ctx *tcp.Context) error { return nil }
func (h *ServerHandler) OnError(ctx *tcp.Context) error   { return nil }
func (h *ServerHandler) OnClose(ctx *tcp.Context) error   { return nil }

func (h *ServerHandler) OnMessage(ctx *tcp.Context) error {
	msg, ok := ctx.Data.(*hl7v2.RawMessage)
	if !ok {
		return nil
	}

	// Auto-send ACK over MLLP socket
	_, err := ctx.Conn.AckMessage(msg)
	return err
}

func main() {
	server, err := tcp.NewServer(&ServerHandler{}, tcp.WithAddresses(":2525"))
	if err != nil {
		log.Fatalf("Server create error: %v", err)
	}

	log.Println("Starting MLLP server on :2525...")
	if err := server.Start(); err != nil {
		log.Fatalf("Server error: %v", err)
	}
}

Documentation

Comprehensive guides, architecture overviews, and API references are available on our documentation site:

🌐 https://blushift-io.github.io/hl7v2

Topics covered:


Contributing

We welcome contributions from the healthcare and open-source community!

Local Development Setup
  1. Prerequisites:

    • Go 1.25+
    • pnpm (for building/running documentation site)
    • Mage (optional helper runner)
  2. Clone the repository:

    git clone https://github.com/blushift-io/hl7v2.git
    cd hl7v2
    
  3. Run Unit Tests:

    go test ./...
    
  4. Code Formatting & Verification:

    go fmt ./...
    go vet ./...
    
  5. Documentation Development: To preview the VitePress documentation site locally:

    # Using pnpm
    pnpm --prefix docs dev
    
    # Or using mage
    mage docsdev
    

For detailed pull request guidelines, commit standards, and architecture details, please see CONTRIBUTING.md.


License

This project is licensed under the MIT License.

Documentation

Overview

Package hl7v2 provides tools for parsing, building, manipulating, and marshaling HL7 v2 messages.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEncodingTooShort is returned when encoding characters are fewer than 5 bytes.
	ErrEncodingTooShort = errors.New("invalid delimiters, encoding chars must be at least 5 bytes")
	// ErrEncodingInvalid is returned when duplicate characters are found in encoding chars.
	ErrEncodingInvalid = errors.New("invalid encoding chars")
)
View Source
var (
	// ErrMsgLength is returned when an HL7 message is shorter than the minimum length of 8 bytes.
	ErrMsgLength = errors.New("invalid message: message length must be at least 8 bytes")
	// ErrElementNotFound is returned when a requested element is not found.
	ErrElementNotFound = errors.New("element not found")
	// ErrValueNotFound is returned when a requested value is not found.
	ErrValueNotFound = errors.New("value not found")
)

Functions

func AckRawMessage

func AckRawMessage(msg []byte) ([]byte, error)

AckRawMessage generates a raw HL7 ACK message for the given raw HL7 message.

func Marshal

func Marshal(v any) ([]byte, error)

Marshal returns the HL7 v2 wire byte representation of v.

func NackRawMessage added in v0.3.0

func NackRawMessage(msg []byte, code AcknowledgmentCode, errMsg string, cond ...MessageErrorCode) ([]byte, error)

NackRawMessage generates a raw HL7 NACK message for the given raw HL7 message.

func ReplaceLineEndings added in v0.3.1

func ReplaceLineEndings(b []byte) []byte

ReplaceLineEndings replaces CRLF (\r\n) and LF (\n) with CR (\r) segment delimiters.

func Unmarshal

func Unmarshal(b []byte, v any) error

Unmarshal unmarshals HL7 wire format bytes into the provided struct pointer or Unmarshaler.

Types

type Acknowledgement

type Acknowledgement struct {
	MessageHeader
	Code             string
	ControlID        string
	Message          string
	ExpectedSequence string
	DelayedAckType   string
	ErrorCondition   string
}

Acknowledgement represents an HL7 acknowledgment message structure.

type AcknowledgmentCode

type AcknowledgmentCode int

AcknowledgmentCode represents an HL7 acknowledgment code.

const (
	// AckUnknown indicates an unknown acknowledgment code.
	AckUnknown AcknowledgmentCode = iota //UN
	// AckApplicationAccept indicates application accept (AA).
	AckApplicationAccept //AA
	// AckApplicationError indicates application error (AE).
	AckApplicationError //AE
	// AckApplicationReject indicates application reject (AR).
	AckApplicationReject //AR
	// AckCommitAccept indicates commit accept (CA).
	AckCommitAccept //CA
	// AckCommitError indicates commit error (CE).
	AckCommitError //CE
	// AckCommitReject indicates commit reject (CR).
	AckCommitReject //CR
)

func (AcknowledgmentCode) String added in v0.3.0

func (a AcknowledgmentCode) String() string

String returns the 2-character string representation of the AcknowledgmentCode.

type Component

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

Component represents an HL7 component element within a repetition or field.

func NewComponent

func NewComponent(parent Element, pos int, raw RawComponent) *Component

NewComponent creates a new Component instance with the given parent, position, and raw content.

func (*Component) Append

func (c *Component) Append(ne Element) error

Append appends a subcomponent element to the component.

func (*Component) Children

func (c *Component) Children() []Element

Children returns the subcomponents as child elements.

func (*Component) Delimiters

func (c *Component) Delimiters() *Delimiters

Delimiters returns the message delimiters.

func (*Component) Encode

func (c *Component) Encode() ([]byte, error)

Encode encodes the component into its byte representation.

func (*Component) GetLocation

func (c *Component) GetLocation(loc query.Location) (Element, error)

GetLocation resolves an element inside the component by its location query.

func (*Component) Header

func (c *Component) Header() *MessageHeader

Header returns the message header.

func (*Component) Length

func (c *Component) Length() int

Length returns the number of subcomponents in the component.

func (*Component) Location

func (c *Component) Location() query.Location

Location returns the query Location of the component.

func (*Component) Name

func (c *Component) Name() string

Name returns the name of the component.

func (*Component) Parent

func (c *Component) Parent() Element

Parent returns the parent element.

func (*Component) Position

func (c *Component) Position() int

Position returns the 1-indexed position of the component within its parent.

func (*Component) SetLocation

func (c *Component) SetLocation(loc query.Location, val Value) error

SetLocation updates the value at the given location inside the component.

func (*Component) Subcomponent

func (c *Component) Subcomponent(index int) (*Subcomponent, error)

Subcomponent returns the subcomponent at the specified 1-indexed position.

func (*Component) Subcomponents

func (c *Component) Subcomponents() []*Subcomponent

Subcomponents returns the child subcomponents.

func (*Component) Type

func (c *Component) Type() ElementType

Type returns the element type for Component.

func (*Component) Value

func (c *Component) Value(escape ...bool) Value

Value returns the Value of the component.

type Condition

type Condition struct {
	Name  string
	Check ConditionFunc
}

Condition represents a named rule for testing HL7 elements.

func Has

func Has(q string) (*Condition, error)

Has returns a Condition that checks if the specified query location exists and is non-empty.

func ValueContains

func ValueContains(q, v string) (*Condition, error)

ValueContains returns a Condition that checks if the value at the location contains the substring v.

func ValueContainsAny

func ValueContainsAny(q string, v ...string) (*Condition, error)

ValueContainsAny returns a Condition that checks if the value at the location contains any of the substrings in v.

type ConditionFunc

type ConditionFunc func(Element) bool

ConditionFunc is a predicate function that evaluates an HL7 Element.

type Delimiter

type Delimiter byte

Delimiter is a byte representation of a single delimiter

func (Delimiter) Byte

func (d Delimiter) Byte() byte

Byte returns the delimiter as a byte.

func (Delimiter) Bytes

func (d Delimiter) Bytes() []byte

Bytes returns the delimiter as a byte slice.

func (Delimiter) String

func (d Delimiter) String() string

String returns the delimiter as a string.

type DelimiterType

type DelimiterType int

Type is an enum of valid delimiters

const (
	// InvalidDelimiter represents an invalid delimiter.
	InvalidDelimiter DelimiterType = iota //invalid
	// SegmentDelimiter represents the segment delimiter character (\r).
	SegmentDelimiter //segment
	// FieldDelimiter represents the field delimiter character (|).
	FieldDelimiter //field
	// RepetitionDelimiter represents the field repetition delimiter character (~).
	RepetitionDelimiter //repetition
	// ComponentDelimiter represents the component delimiter character (^).
	ComponentDelimiter //component
	// SubcomponentDelimiter represents the subcomponent delimiter character (&).
	SubcomponentDelimiter //subcomponent
	// EscapeDelimiter represents the escape character (\).
	EscapeDelimiter //escape
	// TruncationDelimiter represents the truncation delimiter character (#).
	TruncationDelimiter //truncation

)

func DelimiterTypeString

func DelimiterTypeString(s string) (DelimiterType, error)

DelimiterTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func DelimiterTypeValues

func DelimiterTypeValues() []DelimiterType

DelimiterTypeValues returns all values of the enum

func (DelimiterType) IsADelimiterType

func (i DelimiterType) IsADelimiterType() bool

IsADelimiterType returns "true" if the value is listed in the enum definition. "false" otherwise

func (DelimiterType) String

func (i DelimiterType) String() string

type Delimiters

type Delimiters struct {
	Segment      Delimiter
	Field        Delimiter
	Repetition   Delimiter
	Component    Delimiter
	Subcomponent Delimiter
	Escape       Delimiter
	Truncation   Delimiter
}

Delimiters holds the message delimiters

func DefaultDelimiters

func DefaultDelimiters() *Delimiters

DefaultDelimiters returns the default delimiters

func NewDelimiters

func NewDelimiters(setters ...SetDelimiter) *Delimiters

NewDelimiters creates a new Delimiters instance with default settings and applies any functional options.

func ParseDelimiters

func ParseDelimiters(b []byte) (*Delimiters, error)

ParseDelimiters parses delimiters from an HL7 encoding characters byte slice.

func (*Delimiters) EncodingCharsValue

func (d *Delimiters) EncodingCharsValue() Value

EncodingCharsValue returns the encoding characters as a Value.

func (*Delimiters) Escaper

func (d *Delimiters) Escaper() *Escaper

Escaper creates a new Escaper configured with these delimiters.

func (*Delimiters) FieldSeparatorValue

func (d *Delimiters) FieldSeparatorValue() Value

FieldSeparatorValue returns the field delimiter as a Value.

func (*Delimiters) Join

func (d *Delimiters) Join(b [][]byte, typ DelimiterType) []byte

Join joins byte slices using the specified delimiter type.

func (*Delimiters) Split

func (d *Delimiters) Split(b []byte, typ DelimiterType) [][]byte

Split splits a byte slice using the specified delimiter type.

type Element

type Element interface {
	Type() ElementType
	Name() string
	Delimiters() *Delimiters
	Header() *MessageHeader
	Parent() Element
	Children() []Element
	Length() int
	Position() int
	Location() query.Location
	Value(escape ...bool) Value
	GetLocation(query.Location) (Element, error)
	SetLocation(query.Location, Value) error
	Append(Element) error
	Encode() ([]byte, error)
}

Element interface for HL7 elements

type ElementIterator

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

ElementIterator provides sequential iteration over child elements of an HL7 Element.

func NewIterator

func NewIterator(el Element) *ElementIterator

NewIterator creates a new ElementIterator for traversing the children of el.

func (*ElementIterator) Next

func (i *ElementIterator) Next() Element

Next advances the iterator and returns the next child element, or nil if done.

type ElementType

type ElementType int

ElementType is an enum of valid element types

const (
	// ElementInvalid represents an invalid or uninitialized element type.
	ElementInvalid ElementType = iota //invalid
	// ElementBatch represents an HL7 batch element type.
	ElementBatch //batch
	// ElementFile represents an HL7 file element type.
	ElementFile //file
	// ElementMessage represents an HL7 message element type.
	ElementMessage //message
	// ElementSegmentGroup represents an HL7 segment group element type.
	ElementSegmentGroup //group
	// ElementSegment represents an HL7 segment element type.
	ElementSegment //segment
	// ElementField represents an HL7 field element type.
	ElementField //field
	// ElementRepetition represents an HL7 field repetition element type.
	ElementRepetition //repetition
	// ElementComponent represents an HL7 component element type.
	ElementComponent //component
	// ElementSubcomponent represents an HL7 subcomponent element type.
	ElementSubcomponent //subcomponent
)

func ElementTypeString

func ElementTypeString(s string) (ElementType, error)

ElementTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func ElementTypeValues

func ElementTypeValues() []ElementType

ElementTypeValues returns all values of the enum

func (ElementType) IsAElementType

func (i ElementType) IsAElementType() bool

IsAElementType returns "true" if the value is listed in the enum definition. "false" otherwise

func (ElementType) String

func (i ElementType) String() string

type Escaper

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

Escaper handles escaping and unescaping of HL7 delimiter characters.

func NewEscaper

func NewEscaper(delims *Delimiters) *Escaper

NewEscaper returns a new Escaper configured with the provided delimiters.

func (*Escaper) Escape

func (e *Escaper) Escape(b []byte) []byte

Escape escapes HL7 delimiter characters in the input byte slice.

func (*Escaper) Unescape

func (e *Escaper) Unescape(b []byte) []byte

Unescape unescapes HL7 escape sequences in the input byte slice.

type Field

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

Field represents an HL7 field element within a segment.

func NewField

func NewField(parent Element, pos int, raw RawField) *Field

NewField creates a new Field instance.

func (*Field) Append

func (f *Field) Append(el Element) error

Append appends a repetition element to the field.

func (*Field) Children

func (f *Field) Children() []Element

Children returns the repetitions as child elements.

func (*Field) Delimiters

func (f *Field) Delimiters() *Delimiters

Delimiters returns the message delimiters.

func (*Field) Encode

func (f *Field) Encode() ([]byte, error)

Encode encodes the field into its byte representation.

func (*Field) GetLocation

func (f *Field) GetLocation(loc query.Location) (Element, error)

GetLocation resolves an element inside the field by its location query.

func (*Field) Header

func (f *Field) Header() *MessageHeader

Header returns the message header.

func (*Field) Length

func (f *Field) Length() int

Length returns the number of repetitions in the field.

func (*Field) Location

func (f *Field) Location() query.Location

Location returns the query Location of the field.

func (*Field) Name

func (f *Field) Name() string

Name returns the name of the field.

func (*Field) Parent

func (f *Field) Parent() Element

Parent returns the parent segment element.

func (*Field) Position

func (f *Field) Position() int

Position returns the 1-indexed field position within the segment.

func (*Field) Repetition

func (f *Field) Repetition(index int) (*Repetition, error)

Repetition returns the repetition at the specified 0-indexed position.

func (*Field) Repetitions

func (f *Field) Repetitions() []*Repetition

Repetitions returns the field repetitions.

func (*Field) SetLocation

func (f *Field) SetLocation(loc query.Location, val Value) error

SetLocation updates the value at the given location inside the field.

func (*Field) Type

func (f *Field) Type() ElementType

Type returns the element type for Field.

func (*Field) Value

func (f *Field) Value(escape ...bool) Value

Value returns the Value of the field.

type Header interface {
	Type() HeaderType
	Delimiters() *Delimiters
	SendingApplication() string
	SendingFacility() string
	ReceivingApplication() string
	ReceivingFacility() string
	DateTime() time.Time
	Security() string
}

Header is an interface representing an HL7 message, file, or batch header.

func NewHeader

func NewHeader(typ HeaderType) Header

NewHeader returns a new Header for the given HeaderType.

type HeaderType

type HeaderType int

HeaderType is an enum type for valid header types

const (
	// HeaderTypeMessage represents an MSH header type.
	HeaderTypeMessage HeaderType = iota //MSH
	// HeaderTypeFile represents an FHS header type.
	HeaderTypeFile //FHS
	// HeaderTypeBatch represents a BHS header type.
	HeaderTypeBatch //BHS
)

func HeaderTypeString

func HeaderTypeString(s string) (HeaderType, error)

HeaderTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func HeaderTypeValues

func HeaderTypeValues() []HeaderType

HeaderTypeValues returns all values of the enum

func (HeaderType) IsAHeaderType

func (i HeaderType) IsAHeaderType() bool

IsAHeaderType returns "true" if the value is listed in the enum definition. "false" otherwise

func (HeaderType) String

func (i HeaderType) String() string

func (HeaderType) Trailer

func (t HeaderType) Trailer() TrailerType

Trailer returns the corresponding TrailerType for the HeaderType.

type Marshaler

type Marshaler interface {
	MarshalHL7() ([]byte, error)
}

Marshaler is the interface implemented by types that can marshal themselves into valid HL7 v2 wire bytes.

type Message

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

Message represents a parsed HL7 message containing structured segments and fields.

func NewMessage

func NewMessage(b []byte, opts ...ParserOption) (*Message, error)

NewMessage parses an HL7 message from a byte slice.

func NewMessageFromFile

func NewMessageFromFile(f string, opts ...ParserOption) (*Message, error)

NewMessageFromFile reads and parses an HL7 message from a file path.

func ReadMessage added in v0.3.0

func ReadMessage(r io.Reader, opts ...ParserOption) (*Message, error)

ReadMessage parses an HL7 message from an io.Reader.

func (*Message) Append

func (m *Message) Append(el Element) error

Append appends a segment element to the message.

func (*Message) Children

func (m *Message) Children() []Element

Children returns the segments of the message as child elements.

func (*Message) Delimiters

func (m *Message) Delimiters() *Delimiters

Delimiters returns the message delimiters.

func (*Message) Encode

func (m *Message) Encode() ([]byte, error)

Encode encodes the message into HL7 wire format bytes.

func (*Message) GetLocation

func (m *Message) GetLocation(loc query.Location) (Element, error)

GetLocation resolves an element in the message by a query Location.

func (*Message) HasSegment

func (m *Message) HasSegment(id string) bool

HasSegment checks if the message contains at least one segment with the given ID.

func (*Message) Header

func (m *Message) Header() *MessageHeader

Header returns the parsed MessageHeader.

func (*Message) Length

func (m *Message) Length() int

Length returns the number of segments in the message.

func (*Message) Location

func (m *Message) Location() query.Location

Location returns the location query of the message.

func (*Message) Name

func (m *Message) Name() string

Name returns the message type name.

func (*Message) Parent

func (m *Message) Parent() Element

Parent returns the parent element.

func (*Message) Position

func (m *Message) Position() int

Position returns the position of the message.

func (*Message) Query

func (m *Message) Query(q string) (Element, error)

Query finds an element in the message using a location query string.

func (*Message) QueryValue

func (m *Message) QueryValue(q string) (*Value, error)

QueryValue retrieves the Value at the given location query string.

func (*Message) Raw

func (m *Message) Raw() (*RawMessage, error)

Raw returns a RawMessage parsed from the current Message bytes.

func (*Message) Schema

func (m *Message) Schema() (*schema.Message, error)

Schema loads the schema specification matching the message header version and type.

func (*Message) Segment

func (m *Message) Segment(name string, idx ...int) (*Segment, error)

Segment returns the segment matching the given name and optional position index.

func (*Message) SegmentList

func (m *Message) SegmentList() []string

SegmentList returns a slice of all segment names present in the message.

func (*Message) Segments

func (m *Message) Segments(id ...string) []*Segment

Segments returns segments matching the specified ID, or all segments if no ID is given.

func (*Message) Select

func (m *Message) Select(q string) ([]Element, error)

Select filters elements in the message using a grammar query string.

func (*Message) SetLocation

func (m *Message) SetLocation(loc query.Location, val Value) error

SetLocation updates the value at the specified query Location.

func (*Message) Type

func (m *Message) Type() ElementType

Type returns the element type for Message.

func (*Message) Value

func (m *Message) Value(escape ...bool) Value

Value returns the combined Value of the message segments.

type MessageErrorCode added in v0.3.0

type MessageErrorCode int

MessageErrorCode represents an HL7 error condition code used in ERR segments.

const (
	// MessageErrorAccepted indicates success (0).
	MessageErrorAccepted MessageErrorCode = 0
	// MessageErrorSegmentSequence indicates a segment sequence error (100).
	MessageErrorSegmentSequence MessageErrorCode = 100
	// MessageErrorRequiredFieldMissing indicates a missing required field (101).
	MessageErrorRequiredFieldMissing MessageErrorCode = 101
	// MessageErrorDataTypeError indicates a data type error (102).
	MessageErrorDataTypeError MessageErrorCode = 102
	// MessageErrorTableValueNotFound indicates a table value was not found (103).
	MessageErrorTableValueNotFound MessageErrorCode = 103
	// MessageErrorUnsupportedMsgType indicates an unsupported message type (200).
	MessageErrorUnsupportedMsgType MessageErrorCode = 200
	// MessageErrorUnsupportedEventCode indicates an unsupported event code (201).
	MessageErrorUnsupportedEventCode MessageErrorCode = 201
	// MessageErrorUnsupportedProcessingID indicates an unsupported processing ID (202).
	MessageErrorUnsupportedProcessingID MessageErrorCode = 202
	// MessageErrorUnsupportedVersionID indicates an unsupported version ID (203).
	MessageErrorUnsupportedVersionID MessageErrorCode = 203
	// MessageErrorUnknownKeyID indicates an unknown key ID (204).
	MessageErrorUnknownKeyID MessageErrorCode = 204
	// MessageErrorDuplicateKeyID indicates a duplicate key ID (205).
	MessageErrorDuplicateKeyID MessageErrorCode = 205
	// MessageErrorAppRecordLocked indicates an application record is locked (206).
	MessageErrorAppRecordLocked MessageErrorCode = 206
	// MessageErrorApplicationInternalError indicates an application internal error (207).
	MessageErrorApplicationInternalError MessageErrorCode = 207
)

type MessageHeader

type MessageHeader struct {
	Delimiters                    *Delimiters `json:"delimiters" hl7:"MSH.1"`
	SendingApplication            string      `json:"sending_application" hl7:"MSH.3"`
	SendingFacility               string      `json:"sending_facility" hl7:"MSH.4"`
	ReceivingApplication          string      `json:"receiving_application" hl7:"MSH.5"`
	ReceivingFacility             string      `json:"receiving_facility" hl7:"MSH.6"`
	MessageDate                   time.Time   `json:"message_date" hl7:"MSH.7"`
	Security                      string      `json:"security" hl7:"MSH.8"`
	MessageCode                   string      `json:"type" hl7:"MSH.9.1"`
	TriggerEvent                  string      `json:"event_trigger" hl7:"MSH.9.2"`
	MessageStructure              string      `json:"message_structure" hl7:"MSH.9.3"`
	ControlID                     string      `json:"control_id" hl7:"MSH.10"`
	ProcessingID                  string      `json:"processing_id" hl7:"MSH.11"`
	VersionID                     string      `json:"version_id" hl7:"MSH.12"`
	SequenceNumber                int         `json:"sequence_number" hl7:"MSH.13"`
	ContinuationPointer           string      `json:"continuation_pointer" hl7:"MSH.14"`
	AcceptAcknowledgmentType      string      `json:"accept_acknowledgment" hl7:"MSH.15"`
	ApplicationAcknowledgmentType string      `json:"application_acknowledgment" hl7:"MSH.16"`
	CountryCode                   string      `json:"country_code" hl7:"MSH.17"`
	CharacterSet                  string      `json:"character_set" hl7:"MSH.18"`
	PrincipalLanguage             string      `json:"principal_language" hl7:"MSH.19"`
	AlternateCharacterSet         string      `json:"alternate_character_set" hl7:"MSH.20"`
	ProfileID                     string      `json:"profile_id" hl7:"MSH.21"`
	SendingResponsibleOrgCode     string      `json:"sending_responsible_org_code" hl7:"MSH.22"`
	ReceivingResponsibleOrgCode   string      `json:"receiving_responsible_org_code" hl7:"MSH.23"`
	SendingNetworkAddress         string      `json:"sending_network_address" hl7:"MSH.24"`
	ReceivingNetworkAddress       string      `json:"receiving_network_address" hl7:"MSH.25"`
}

MessageHeader represents the parsed MSH header fields of an HL7 message.

func ParseHeader added in v0.3.1

func ParseHeader(b []byte) (*MessageHeader, error)

ParseHeader parses an MSH message header from raw message bytes.

func (*MessageHeader) MarshalHL7

func (h *MessageHeader) MarshalHL7() ([]byte, error)

MarshalHL7 marshals the MessageHeader into HL7 wire format bytes.

func (*MessageHeader) MessageType

func (h *MessageHeader) MessageType() MessageType

MessageType constructs a MessageType from the MSH header.

type MessageType

type MessageType struct {
	Code      string `json:"code"`
	Event     string `json:"event"`
	Structure string `json:"structure"`
}

MessageType represents the HL7 message type, trigger event, and structure.

func ParseMessageType

func ParseMessageType(s string, delims *Delimiters) (MessageType, error)

ParseMessageType parses a message type string into a MessageType struct.

func (MessageType) Encode

func (t MessageType) Encode(delims *Delimiters) []byte

Encode encodes the MessageType into its byte representation using the given delimiters.

func (MessageType) String

func (t MessageType) String() string

String returns the string representation of the MessageType.

type ParserOption

type ParserOption func(*ParserOptions)

ParserOption is a function that configures ParserOptions.

func FixLineEndings

func FixLineEndings() ParserOption

FixLineEndings returns a ParserOption that normalizes message line endings prior to parsing.

func OnlyHeader added in v0.3.1

func OnlyHeader() ParserOption

OnlyHeader returns a ParserOption that stops parsing after the message header.

func PreParse

func PreParse(t RawTransform) ParserOption

PreParse returns a ParserOption that applies a custom RawTransform before parsing.

type ParserOptions

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

ParserOptions holds configuration options for message parsing.

func NewParserOptions

func NewParserOptions(opts ...ParserOption) *ParserOptions

NewParserOptions creates a new ParserOptions struct configured by the given options.

type Queryable

type Queryable interface {
	Delimiters() *Delimiters
	QueryValue(q string) (*Value, error)
}

Queryable is an interface implemented by elements that can be queried by a location string.

type RawComponent

type RawComponent []RawSubcomponent

RawComponent represents an unparsed HL7 component containing raw subcomponents.

func (RawComponent) Query

func (c RawComponent) Query(loc query.Location, delims ...*Delimiters) (*Value, error)

Query queries the RawComponent at the specified location.

func (RawComponent) String

func (c RawComponent) String(delims ...*Delimiters) string

String converts the RawComponent to its string representation.

func (RawComponent) Value

func (c RawComponent) Value(delims ...*Delimiters) Value

Value wraps the RawComponent bytes in a Value.

type RawField

type RawField []RawRepetition

RawField represents an unparsed field containing raw repetitions.

func (RawField) Query

func (f RawField) Query(loc query.Location, delims ...*Delimiters) (*Value, error)

Query queries the RawField at the specified location.

func (RawField) String

func (f RawField) String(delims ...*Delimiters) string

String converts the RawField to its string representation.

func (RawField) Value

func (f RawField) Value(delims ...*Delimiters) Value

Value wraps the RawField bytes in a Value.

type RawMessage

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

RawMessage represents an unparsed HL7 message consisting of raw segments.

func NewRawMessage

func NewRawMessage(delims *Delimiters, segs ...RawSegment) *RawMessage

NewRawMessage constructs a RawMessage with the provided delimiters and raw segments.

func ParseJSON added in v0.3.0

func ParseJSON(b []byte) (*RawMessage, error)

ParseJSON parses a JSON byte slice into a RawMessage.

func ParseRaw

func ParseRaw(b []byte, opts ...ParserOption) (*RawMessage, error)

ParseRaw parses a byte slice into a RawMessage.

func ReadJSON added in v0.3.0

func ReadJSON(r io.Reader) (*RawMessage, error)

ReadJSON reads JSON representation from an io.Reader and parses it into a RawMessage.

func ReadRaw

func ReadRaw(r io.Reader, opts ...ParserOption) (*RawMessage, error)

ReadRaw reads and parses raw message bytes from an io.Reader.

func (*RawMessage) Decode

func (m *RawMessage) Decode() (*Message, error)

Decode converts the RawMessage into a fully parsed Message.

func (*RawMessage) Delimiters

func (m *RawMessage) Delimiters() *Delimiters

Delimiters returns the message delimiters.

func (*RawMessage) JSON

func (m *RawMessage) JSON(pretty ...bool) ([]byte, error)

JSON formats the RawMessage as a JSON byte slice, optionally indented if pretty is true.

func (*RawMessage) MarshalJSON added in v0.3.0

func (m *RawMessage) MarshalJSON() ([]byte, error)

MarshalJSON marshals the RawMessage into a JSON byte slice.

func (*RawMessage) QueryValue

func (m *RawMessage) QueryValue(q string) (*Value, error)

QueryValue queries a value from the raw message using a location string.

func (*RawMessage) Segments

func (m *RawMessage) Segments(id ...string) []RawSegment

Segments returns all raw segments or those matching the provided ID.

func (*RawMessage) ToMessage

func (m *RawMessage) ToMessage() (*Message, error)

ToMessage converts the RawMessage into a fully parsed Message.

func (*RawMessage) UnmarshalJSON added in v0.3.0

func (m *RawMessage) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a JSON byte slice into the RawMessage.

func (*RawMessage) Value

func (m *RawMessage) Value() Value

Value returns the combined Value of all raw segments in the message.

type RawRepetition

type RawRepetition []RawComponent

RawRepetition represents an unparsed field repetition containing raw components.

func (RawRepetition) Query

func (r RawRepetition) Query(loc query.Location, delims ...*Delimiters) (*Value, error)

Query queries the RawRepetition at the specified location.

func (RawRepetition) String

func (r RawRepetition) String(delims ...*Delimiters) string

String converts the RawRepetition to its string representation.

func (RawRepetition) Value

func (r RawRepetition) Value(delims ...*Delimiters) Value

Value wraps the RawRepetition bytes in a Value.

type RawSegment

type RawSegment []RawField

RawSegment represents an unparsed segment containing raw fields.

func (RawSegment) ID

func (s RawSegment) ID() string

ID returns the segment identifier name (e.g., "MSH", "PID").

func (RawSegment) Query

func (s RawSegment) Query(loc query.Location, delims ...*Delimiters) (*Value, error)

Query queries the RawSegment at the specified location.

func (RawSegment) String

func (s RawSegment) String(delims ...*Delimiters) string

String converts the RawSegment to its string representation.

func (RawSegment) Value

func (s RawSegment) Value(delims ...*Delimiters) Value

Value wraps the RawSegment bytes in a Value.

type RawSegmentGroup

type RawSegmentGroup []RawSegment

RawSegmentGroup represents an unparsed group of segments.

type RawSubcomponent

type RawSubcomponent []byte

RawSubcomponent represents an unparsed byte slice of a subcomponent.

func (RawSubcomponent) String

func (s RawSubcomponent) String() string

String converts the RawSubcomponent to a string.

func (RawSubcomponent) Value

func (s RawSubcomponent) Value() Value

Value wraps the RawSubcomponent in a Value.

type RawTransform

type RawTransform func([]byte) ([]byte, error)

RawTransform is a function type for transforming raw HL7 byte slices.

type Repetition

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

Repetition represents an HL7 field repetition element.

func NewRepetition

func NewRepetition(parent Element, pos int, raw RawRepetition) *Repetition

NewRepetition creates a new Repetition instance.

func (*Repetition) Append

func (r *Repetition) Append(el Element) error

Append appends a component element to the repetition.

func (*Repetition) Children

func (r *Repetition) Children() []Element

Children returns the components as child elements.

func (*Repetition) Component

func (r *Repetition) Component(idx int) (*Component, error)

Component returns the component at the specified 0-indexed position.

func (*Repetition) Components

func (r *Repetition) Components() []*Component

Components returns the child components.

func (*Repetition) Delimiters

func (r *Repetition) Delimiters() *Delimiters

Delimiters returns the message delimiters.

func (*Repetition) Encode

func (r *Repetition) Encode() ([]byte, error)

Encode encodes the repetition into its byte representation.

func (*Repetition) GetLocation

func (r *Repetition) GetLocation(loc query.Location) (Element, error)

GetLocation resolves an element inside the repetition by its location query.

func (*Repetition) Header

func (r *Repetition) Header() *MessageHeader

Header returns the message header.

func (*Repetition) Length

func (r *Repetition) Length() int

Length returns the number of components in the repetition.

func (*Repetition) Location

func (r *Repetition) Location() query.Location

Location returns the query Location of the repetition.

func (*Repetition) Name

func (r *Repetition) Name() string

Name returns the repetition name.

func (*Repetition) Parent

func (r *Repetition) Parent() Element

Parent returns the parent element.

func (*Repetition) Position

func (r *Repetition) Position() int

Position returns the repetition index position.

func (*Repetition) SetLocation

func (r *Repetition) SetLocation(loc query.Location, val Value) error

SetLocation updates the value at the given location inside the repetition.

func (*Repetition) Type

func (r *Repetition) Type() ElementType

Type returns the element type for Repetition.

func (*Repetition) Value

func (r *Repetition) Value(escape ...bool) Value

Value returns the Value of the repetition.

type Segment

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

Segment represents a parsed HL7 segment containing fields.

func NewSegment

func NewSegment(parent Element, pos int, raw RawSegment) *Segment

NewSegment creates a new Segment instance.

func (*Segment) Append

func (s *Segment) Append(el Element) error

Append appends a field element to the segment.

func (*Segment) Children

func (s *Segment) Children() []Element

Children returns the fields as child elements.

func (*Segment) Delimiters

func (s *Segment) Delimiters() *Delimiters

Delimiters returns the message delimiters.

func (*Segment) Encode

func (s *Segment) Encode() ([]byte, error)

Encode encodes the segment into its byte representation.

func (*Segment) Field

func (s *Segment) Field(index int) (*Field, error)

Field returns the field at the specified 0-indexed position.

func (*Segment) Fields

func (s *Segment) Fields() []*Field

Fields returns the child fields in the segment.

func (*Segment) GetLocation

func (s *Segment) GetLocation(loc query.Location) (Element, error)

GetLocation resolves an element inside the segment by its location query.

func (*Segment) Header

func (s *Segment) Header() *MessageHeader

Header returns the message header.

func (*Segment) Index

func (s *Segment) Index() int

Index returns the segment set ID index if present.

func (*Segment) Length

func (s *Segment) Length() int

Length returns the number of fields in the segment.

func (*Segment) Location

func (s *Segment) Location() query.Location

Location returns the query Location of the segment.

func (*Segment) Name

func (s *Segment) Name() string

Name returns the segment identifier name.

func (*Segment) Parent

func (s *Segment) Parent() Element

Parent returns the parent element.

func (*Segment) Position

func (s *Segment) Position() int

Position returns the 1-indexed position of the segment in the message.

func (*Segment) SetLocation

func (s *Segment) SetLocation(loc query.Location, val Value) error

SetLocation updates the value at the given location inside the segment.

func (*Segment) Type

func (s *Segment) Type() ElementType

Type returns the element type for Segment.

func (*Segment) Value

func (s *Segment) Value(escape ...bool) Value

Value returns the Value of the segment.

type SegmentGroup

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

SegmentGroup represents a logical collection of HL7 segments.

func (*SegmentGroup) Children

func (g *SegmentGroup) Children() []Element

Children returns the segments in the group as child elements.

func (*SegmentGroup) Delimiters

func (g *SegmentGroup) Delimiters() *Delimiters

Delimiters returns the message delimiters.

func (*SegmentGroup) GetLocation

func (g *SegmentGroup) GetLocation(_ query.Location) (Element, error)

GetLocation resolves an element inside the segment group by location.

func (*SegmentGroup) Length

func (g *SegmentGroup) Length() int

Length returns the number of segments in the group.

func (*SegmentGroup) Location

func (g *SegmentGroup) Location() query.Location

Location returns the query Location of the segment group.

func (*SegmentGroup) Name

func (g *SegmentGroup) Name() string

Name returns the group name.

func (*SegmentGroup) Parent

func (g *SegmentGroup) Parent() Element

Parent returns the parent element.

func (*SegmentGroup) Position

func (g *SegmentGroup) Position() int

Position returns the position of the segment group.

func (*SegmentGroup) Type

func (g *SegmentGroup) Type() ElementType

Type returns the element type for SegmentGroup.

func (*SegmentGroup) Value

func (g *SegmentGroup) Value(escape ...bool) Value

Value returns the combined Value of all segments in the group.

type SetDelimiter

type SetDelimiter func(*Delimiters)

SetDelimiter is a functional option for configuring Delimiters.

func SetComponent

func SetComponent(delim Delimiter) SetDelimiter

SetComponent returns an option function setting the component delimiter.

func SetField

func SetField(delim Delimiter) SetDelimiter

SetField returns an option function setting the field delimiter.

func SetRepetition

func SetRepetition(delim Delimiter) SetDelimiter

SetRepetition returns an option function setting the repetition delimiter.

func SetSegment

func SetSegment(delim Delimiter) SetDelimiter

SetSegment returns an option function setting the segment delimiter.

func SetSubcomponent

func SetSubcomponent(delim Delimiter) SetDelimiter

SetSubcomponent returns an option function setting the subcomponent delimiter.

func SetTruncation

func SetTruncation(delim Delimiter) SetDelimiter

SetTruncation returns an option function setting the truncation delimiter.

type Subcomponent

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

Subcomponent represents an HL7 subcomponent element.

func NewEmptySubcomponent

func NewEmptySubcomponent() *Subcomponent

NewEmptySubcomponent creates an empty Subcomponent.

func NewSubcomponent

func NewSubcomponent(parent Element, pos int, v Value) *Subcomponent

NewSubcomponent creates a new Subcomponent instance.

func NewSubcomponentValue

func NewSubcomponentValue(val Value) *Subcomponent

NewSubcomponentValue creates a standalone Subcomponent with the given Value.

func (*Subcomponent) Append

func (el *Subcomponent) Append(_ Element) error

Append returns an error as subcomponents cannot have child elements appended.

func (*Subcomponent) Children

func (el *Subcomponent) Children() []Element

Children returns nil as subcomponents have no children.

func (*Subcomponent) Delimiters

func (el *Subcomponent) Delimiters() *Delimiters

Delimiters returns the message delimiters.

func (*Subcomponent) Encode

func (el *Subcomponent) Encode() ([]byte, error)

Encode encodes the subcomponent into its byte slice.

func (*Subcomponent) GetLocation

func (el *Subcomponent) GetLocation(loc query.Location) (Element, error)

GetLocation returns the subcomponent itself.

func (*Subcomponent) Header

func (el *Subcomponent) Header() *MessageHeader

Header returns the message header.

func (*Subcomponent) Length

func (el *Subcomponent) Length() int

Length returns 1 for a subcomponent.

func (*Subcomponent) Location

func (el *Subcomponent) Location() query.Location

Location returns the query Location of the subcomponent.

func (*Subcomponent) Name

func (el *Subcomponent) Name() string

Name returns the name of the subcomponent.

func (*Subcomponent) Parent

func (el *Subcomponent) Parent() Element

Parent returns the parent element.

func (*Subcomponent) Position

func (el *Subcomponent) Position() int

Position returns the 1-indexed position of the subcomponent.

func (*Subcomponent) SetLocation

func (el *Subcomponent) SetLocation(loc query.Location, val Value) error

SetLocation updates the value of the subcomponent.

func (*Subcomponent) Type

func (el *Subcomponent) Type() ElementType

Type returns the element type for Subcomponent.

func (*Subcomponent) Value

func (el *Subcomponent) Value(escape ...bool) Value

Value returns the Value of the subcomponent.

type TrailerType

type TrailerType int

TrailerType is an enum for valid trailer segment types.

const (
	// TrailerTypeNone indicates no trailer segment.
	TrailerTypeNone TrailerType = iota //_
	// TrailerTypeFile represents an FTS trailer segment type.
	TrailerTypeFile //FTS
	// TrailerTypeBatch represents a BTS trailer segment type.
	TrailerTypeBatch //BTS
)

func TrailerTypeString

func TrailerTypeString(s string) (TrailerType, error)

TrailerTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func TrailerTypeValues

func TrailerTypeValues() []TrailerType

TrailerTypeValues returns all values of the enum

func (TrailerType) IsATrailerType

func (i TrailerType) IsATrailerType() bool

IsATrailerType returns "true" if the value is listed in the enum definition. "false" otherwise

func (TrailerType) String

func (i TrailerType) String() string

type Unmarshaler

type Unmarshaler interface {
	UnmarshalHL7(b []byte) error
}

Unmarshaler is the interface implemented by types that can unmarshal an HL7 v2 wire byte representation of themselves.

type ValidationFunc

type ValidationFunc func(Element) ValidationResult

ValidationFunc is an adapter allowing a function to be used as a Validator.

func (ValidationFunc) Validate

func (f ValidationFunc) Validate(e Element) ValidationResult

Validate implements the Validator interface for ValidationFunc.

type ValidationResult

type ValidationResult struct {
	Valid  bool
	Errors []error
}

ValidationResult holds the result of a validation operation and any validation errors.

func ValidateMessageSchema

func ValidateMessageSchema(el Element) ValidationResult

ValidateMessageSchema validates an HL7 message against its schema specification.

func ValidateSegmentSchema

func ValidateSegmentSchema(el Element) ValidationResult

ValidateSegmentSchema validates an HL7 segment against its schema specification.

type Validator

type Validator interface {
	Validate(Element) ValidationResult
}

Validator is the interface implemented by types that can validate an HL7 Element.

type Value

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

Value represents an HL7 element value as raw bytes with helper conversion methods.

func MarshalValue

func MarshalValue(v any) Value

MarshalValue creates a Value by casting the input to a string.

func NewDateTimeValue

func NewDateTimeValue(date time.Time) Value

NewDateTimeValue creates a new Value formatted as an HL7 datetime (YYYYMMDDHHMMSS) from a time.Time.

func NewDateValue

func NewDateValue(date time.Time) Value

NewDateValue creates a new Value formatted as an HL7 date (YYYYMMDD) from a time.Time.

func NewEmptyValue

func NewEmptyValue() Value

NewEmptyValue returns an empty Value.

func NewIntValue

func NewIntValue(v int) Value

NewIntValue creates a new Value from an integer.

func NewStringValue

func NewStringValue(v string) Value

NewStringValue creates a new Value from a string.

func NewTimestampValue added in v0.3.0

func NewTimestampValue(t time.Time) Value

NewTimestampValue creates a new Value formatted as an HL7 timestamp from a time.Time.

func NewValue

func NewValue(v []byte) Value

NewValue creates a new Value wrapping the provided byte slice.

func UnescapeElement

func UnescapeElement(el Element) (Value, error)

UnescapeElement extracts the unescaped Value from an Element using its delimiters.

func UnescapeValue

func UnescapeValue(v []byte, delims *Delimiters) Value

UnescapeValue creates a new Value from unescaping the input byte slice with the given delimiters.

func (Value) Bind

func (v Value) Bind(val any) error

Bind binds the byte content of Value to a target variable pointer.

func (Value) Bool

func (v Value) Bool() bool

Bool converts the Value to a boolean.

func (Value) Bytes

func (v Value) Bytes() []byte

Bytes returns the underlying raw byte slice of the Value.

func (Value) Date

func (v Value) Date() time.Time

Date converts the Value to a time.Time object. TODO: support for timezone adjustments

func (Value) Empty

func (v Value) Empty() bool

Empty reports whether the Value contains no bytes.

func (Value) Escape

func (v Value) Escape(delims *Delimiters) Value

Escape returns a new Value with HL7 delimiters escaped.

func (Value) Float64

func (v Value) Float64() float64

Float64 converts the Value to a float64.

func (Value) Int

func (v Value) Int() int

Int converts the Value to an integer.

func (Value) String

func (v Value) String() string

String returns the Value as a string.

func (Value) Unescape

func (v Value) Unescape(delims *Delimiters) Value

Unescape returns a new Value with HL7 escape sequences unescaped.

type ValueTransform

type ValueTransform func(el Element) (Value, error)

ValueTransform is a function type for extracting or transforming a Value from an Element.

type Version

type Version int

Version represents an HL7 v2 standard version enum.

const (
	// VersionUnknown represents an unknown or unsupported HL7 version.
	VersionUnknown Version = iota //unknown
	// Version21 represents HL7 version 2.1.
	Version21 //2.1
	// Version22 represents HL7 version 2.2.
	Version22 //2.2
	// Version23 represents HL7 version 2.3.
	Version23 //2.3
	// Version231 represents HL7 version 2.3.1.
	Version231 //2.3.1
	// Version24 represents HL7 version 2.4.
	Version24 //2.4
	// Version25 represents HL7 version 2.5.
	Version25 //2.5
	// Version251 represents HL7 version 2.5.1.
	Version251 //2.5.1
	// Version26 represents HL7 version 2.6.
	Version26 //2.6
	// Version27 represents HL7 version 2.7.
	Version27 //2.7
	// Version271 represents HL7 version 2.7.1.
	Version271 //2.7.1
	// Version28 represents HL7 version 2.8.
	Version28 //2.8
	// Version281 represents HL7 version 2.8.1.
	Version281 //2.8.1
	// Version282 represents HL7 version 2.8.2.
	Version282 //2.8.2
	// Version29 represents HL7 version 2.9.
	Version29 //2.9
)

func GetVersion added in v0.3.0

func GetVersion(ver string) Version

GetVersion parses a version string (e.g. "2.5" or "v2.5") into a Version enum value.

func VersionString

func VersionString(s string) (Version, error)

VersionString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func VersionValues

func VersionValues() []Version

VersionValues returns all values of the enum

func (Version) IsAVersion

func (i Version) IsAVersion() bool

IsAVersion returns "true" if the value is listed in the enum definition. "false" otherwise

func (Version) String

func (i Version) String() string

Directories

Path Synopsis
Package builder provides a fluent API for constructing HL7 v2 messages, segments, fields, repetitions, components, and subcomponents.
Package builder provides a fluent API for constructing HL7 v2 messages, segments, fields, repetitions, components, and subcomponents.
cmd
gen command
Package main provides a code generation tool for HL7v2 schema Go code.
Package main provides a code generation tool for HL7v2 schema Go code.
mllp_server command
Package main implements a server CLI application that receives, processes, saves, and forwards HL7v2 messages via MLLP.
Package main implements a server CLI application that receives, processes, saves, and forwards HL7v2 messages via MLLP.
Package main contains Mage build targets for project development and documentation.
Package main contains Mage build targets for project development and documentation.
Package mllp provides framing, reading, writing, and scanning functionality for the Minimal Lower Layer Protocol (MLLP) used in HL7 v2 communications.
Package mllp provides framing, reading, writing, and scanning functionality for the Minimal Lower Layer Protocol (MLLP) used in HL7 v2 communications.
net
http
Package http provides HTTP handlers and utilities for transmitting and receiving HL7 v2 messages as JSON or ER7 payloads.
Package http provides HTTP handlers and utilities for transmitting and receiving HL7 v2 messages as JSON or ER7 payloads.
tcp
Package tcp implements TCP networking for HL7 v2 messages, including MLLP framing, connection management, message handling, and server lifecycle options.
Package tcp implements TCP networking for HL7 v2 messages, including MLLP framing, connection management, message handling, and server lifecycle options.
Package query provides parsing and matching capabilities for HL7 v2 location queries and message grammar rules.
Package query provides parsing and matching capabilities for HL7 v2 location queries and message grammar rules.
Package schema provides models and registry capabilities for HL7 v2 specifications, messages, segments, data types, and tables.
Package schema provides models and registry capabilities for HL7 v2 specifications, messages, segments, data types, and tables.
spec/v21
Package v21 provides embedded HL7 v2.1 schema specification files and loader.
Package v21 provides embedded HL7 v2.1 schema specification files and loader.
spec/v22
Package v22 provides embedded HL7 v2.2 schema specification files and loader.
Package v22 provides embedded HL7 v2.2 schema specification files and loader.
spec/v23
Package v23 provides embedded HL7 v2.3 schema specification files and loader.
Package v23 provides embedded HL7 v2.3 schema specification files and loader.
spec/v231
Package v231 provides embedded HL7 v2.3.1 schema specification files and loader.
Package v231 provides embedded HL7 v2.3.1 schema specification files and loader.
spec/v24
Package v24 provides embedded HL7 v2.4 schema specification files and loader.
Package v24 provides embedded HL7 v2.4 schema specification files and loader.
spec/v25
Package v25 provides embedded HL7 v2.5 schema specification files and loader.
Package v25 provides embedded HL7 v2.5 schema specification files and loader.
spec/v251
Package v251 provides embedded HL7 v2.5.1 schema specification files and loader.
Package v251 provides embedded HL7 v2.5.1 schema specification files and loader.
spec/v26
Package v26 provides embedded HL7 v2.6 schema specification files and loader.
Package v26 provides embedded HL7 v2.6 schema specification files and loader.
spec/v27
Package v27 provides embedded HL7 v2.7 schema specification files and loader.
Package v27 provides embedded HL7 v2.7 schema specification files and loader.
spec/v271
Package v271 provides embedded HL7 v2.7.1 schema specification files and loader.
Package v271 provides embedded HL7 v2.7.1 schema specification files and loader.
spec/v28
Package v28 provides embedded HL7 v2.8 schema specification files and loader.
Package v28 provides embedded HL7 v2.8 schema specification files and loader.
transform
script
Package script provides JavaScript-based transformation capabilities for HL7 v2 messages using the Goja ECMAScript engine.
Package script provides JavaScript-based transformation capabilities for HL7 v2 messages using the Goja ECMAScript engine.
versions
generator
Package generator provides code generation tools for creating version-specific HL7v2 Go structures from schema specifications.
Package generator provides code generation tools for creating version-specific HL7v2 Go structures from schema specifications.
v21
v22
v23
v24
v25
v26
v27
v28

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址