hl7

package module
v0.0.0-...-3a6d5d9 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2018 License: BSD-3-Clause Imports: 3 Imported by: 0

README

hl7

GoDoc

Overview

HL7v2 stands for "Health Level 7: Version 2" - a specification for shuttling clinical data around and between medical institutions. While working on Medtasker with Nimblic, I've written this library for reading the protocol and querying the messages it contains.

I have a blog post on my website if you'd like to hear a bit more of the story.

Install

$ go get fknsrs.biz/p/hl7

License

3-clause BSD. A copy is included with the source.

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseMessage

func ParseMessage(buf []byte) (Message, *Delimiters, error)

ParseMessage takes input as a `[]byte`, and returns the whole message, the control characters (as `*Delimiters`), and maybe an error.

Types

type Component

type Component []Subcomponent

type Delimiters

type Delimiters struct {
	Field, Component, Repeat, Escape, Subcomponent byte
}

type ErrInvalidHeader

type ErrInvalidHeader error

ErrInvalidHeader is returned if a message doesn't start with "MSH", or the header isn't exactly the correct length, or any of the control characters aren't unique

type ErrInvalidQuery

type ErrInvalidQuery error

type ErrTooShort

type ErrTooShort error

ErrTooShort is returned if a message isn't long enough to contain a valid header

type Field

type Field []FieldItem

type FieldItem

type FieldItem []Component

type Message

type Message []Segment

func (Message) Query

func (m Message) Query(s string) (res string, ok bool, err error)

func (Message) Segment

func (m Message) Segment(name string, index int) Segment

func (Message) Segments

func (m Message) Segments(name string) []Segment

type Query

type Query struct {
	Segment          string
	HasSegmentOffset bool
	SegmentOffset    int
	HasField         bool
	Field            int
	HasFieldOffset   bool
	FieldOffset      int
	HasComponent     bool
	Component        int
	HasSubComponent  bool
	SubComponent     int
}

func New

func New(segment string, segmentOffset, field, fieldOffset, component, subComponent int) Query

func ParseQuery

func ParseQuery(s string) (*Query, error)

func (Query) Count

func (q Query) Count(m Message) int

func (Query) Get

func (q Query) Get(m Message) (string, bool)

func (Query) GetString

func (q Query) GetString(m Message) string
Example
m, _, _ := ParseMessage([]byte(longTestMessageContent))

msh9_1, _ := ParseQuery("MSH-9-1")
msh9_2, _ := ParseQuery("MSH-9-2")

fmt.Printf("%s_%s", msh9_1.GetString(m), msh9_2.GetString(m))
Output:

ORU_R01

func (Query) String

func (q Query) String() string

type Segment

type Segment []Field

type Subcomponent

type Subcomponent string

Jump to

Keyboard shortcuts

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