Documentation
¶
Index ¶
- Constants
- Variables
- func FormatString(str string) string
- type Component
- type Field
- type Fields
- type Message
- type MessageFunc
- type Reader
- type Segment
- func (s Segment) GetComponent(fieldsIdx, fieldIdx, compIdx int) (Component, bool)
- func (s Segment) GetField(fieldsIdx, fieldIdx int) (Field, bool)
- func (s Segment) GetFields(idx int) (Fields, bool)
- func (s Segment) GetSubComponent(fieldsIdx, fieldIdx, compIdx, subCompIdx int) (SubComponent, bool)
- func (s Segment) Type() string
- type SubComponent
Constants ¶
const ( CR = '\r' // Carriage return LF = '\n' // Line feed FF = '\f' // Form feed NB = '\x00' // Null byte )
Constants describing possible message boundaries.
Variables ¶
var ErrUnknownTimeFormat = errors.New("unknown time format")
ErrUnknownTimeFormat is used to represent the case where the time format encountered in the HL7 file is unknown. Maybe we don't know how to parse it yet, or maybe the HL7 file is not complying with the spec?
Functions ¶
func FormatString ¶
FormatString is used to perform basic HL7 formatting rules on the string. This function does not aim to have 100% coverage of the HL7 formatted text spec since a lot of those rules do not seem to be widely used. This does aim to address the common and easy cases, though.
Types ¶
type Component ¶
type Component []SubComponent
Component is used to represent a slice of sub-components.
func (Component) GetSubComponent ¶
func (c Component) GetSubComponent(idx int) (SubComponent, bool)
GetSubComponent is used to get the sub-component at the given index.
type Field ¶
type Field []Component
Field is a slice of components.
func (Field) GetComponent ¶
GetComponent is used to get the component at the given index.
func (Field) GetSubComponent ¶
func (f Field) GetSubComponent(compIdx, subCompIdx int) (SubComponent, bool)
GetSubComponent is used to get the sub-component at the given index.
type Fields ¶
type Fields []Field
Fields is a slice of fields
func (Fields) GetComponent ¶
GetComponent is used to get the component at the given index.
func (Fields) GetSubComponent ¶
func (f Fields) GetSubComponent(fieldIdx, compIdx, subCompIdx int) (SubComponent, bool)
GetSubComponent is used to get the component at the given index.
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message is used to describe the parsed message.
func NewMessage ¶
NewMessage takes a byte slice and returns a Message that is ready to use.
func (*Message) Parse ¶
Parse is used to parse the segments within the message so that they can be queried and iterated. This is a different paradigm from the ReadSegment method, which parses the segments as-needed.
func (*Message) ReadSegment ¶
ReadSegment is used to "read" the next segment from the message.
type MessageFunc ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is the type used to read messages from an internal bufio.Reader.
func (*Reader) EachMessage ¶
func (r *Reader) EachMessage(fn MessageFunc) error
EachMessage is used to create a bit of a friendlier API for reading messages if all you're doing is (for example) importing the messages' data into a database or something. Each message is passed into the MessageFunc provided and executed in order. The downside of this implementation is that it will not happen concurrently, which could have some performance ramifications.
Errors returned from this will not include io.EOF, so when you're done processing the work, only "real" errors are returned here, such as errors parsing the HL7 data and errors reading from the input io.Reader.
func (*Reader) ReadMessage ¶
ReadMessage is used to read the next message in the internal reader.
If the reader is empty (or at io.EOF), io.EOF is returned with an empty message. Otherwise, error will always be nil.
type Segment ¶
type Segment []Fields
Segment is a slice of fields.
func (Segment) GetComponent ¶
GetComponent is used to get the component at the given index
func (Segment) GetSubComponent ¶
func (s Segment) GetSubComponent(fieldsIdx, fieldIdx, compIdx, subCompIdx int) (SubComponent, bool)
GetSubComponent is used to get the sub-component at the given index
type SubComponent ¶
type SubComponent []byte
SubComponent is the basic unit in HL7s. This is not strictly standards- compliant, since not all fields have sub-components but it is close enough.
func (SubComponent) DirtyString ¶
func (s SubComponent) DirtyString() string
DirtyString is the string value value without any escaping performed.
func (SubComponent) Int ¶
func (s SubComponent) Int() (int, error)
Int is used to return an integer value housed in a SubComponent.
func (SubComponent) String ¶
func (s SubComponent) String() string
String is used to return the string value housed in a SubComponent. We convert HL7 escape codes, linebreaks, etc. into standard values.