Documentation
¶
Overview ¶
Package edifact reads and writes UN/EDIFACT interchanges (ISO 9735): the UNA service string advice, the UNB/UNZ interchange envelope, optional UNG/UNE functional groups, and UNH/UNT messages, with the release character and, for syntax version 4, the repetition separator. It checks the envelope's counts and references, addresses data elements for filters, splits an interchange into one per message, and builds a CONTRL acknowledgement.
It reads any message type (ORDERS, INVOIC, IFTSTA, MEDRPT ...); it does not hold the directories that say which segments a message type may contain, so it checks structure, not content.
Index ¶
- Variables
- func Describe(ic *Interchange) string
- func ParseFilter(src string) (expr.Expr[*Interchange], error)
- func Read(ic *Interchange, p Path) []string
- type Action
- type Delimiters
- type Element
- type Group
- type Interchange
- func (ic *Interchange) AllMessages() []Message
- func (ic *Interchange) Bytes() []byte
- func (ic *Interchange) Recipient() (id, qualifier string)
- func (ic *Interchange) Ref() string
- func (ic *Interchange) Segments() []Segment
- func (ic *Interchange) Sender() (id, qualifier string)
- func (ic *Interchange) Syntax() string
- type Message
- type Path
- type Problem
- type Resolver
- type Segment
Constants ¶
This section is empty.
Variables ¶
var Default = Delimiters{Component: ':', Element: '+', Decimal: '.', Release: '?', Repetition: ' ', Segment: '\''}
Default is ISO 9735's default service characters (syntax levels A and B), used when there is no UNA.
Functions ¶
func Describe ¶
func Describe(ic *Interchange) string
Describe names an interchange for logs: its message types and parties, never content.
func ParseFilter ¶
func ParseFilter(src string) (expr.Expr[*Interchange], error)
ParseFilter compiles a filter expression over an interchange.
func Read ¶
func Read(ic *Interchange, p Path) []string
Read returns every value the path addresses in the interchange.
Types ¶
type Delimiters ¶
type Delimiters struct {
Component byte // :
Element byte // +
Decimal byte // .
Release byte // ?
Repetition byte // * in syntax 4; ' ' (none) before it
Segment byte // '
}
Delimiters are the service characters, from UNA or the defaults.
type Element ¶
type Element [][]string
Element is one data element: its repetitions, each a list of components.
type Interchange ¶
type Interchange struct {
Delims Delimiters
// HasUNA records whether the interchange began with a service string advice, so it is written back the same way.
HasUNA bool
Header Segment // UNB
// Groups is set when the interchange uses functional groups; Messages otherwise.
Groups []Group
Messages []Message
Trailer Segment // UNZ
}
Interchange is one UNB ... UNZ interchange.
func CONTRL ¶
func CONTRL(ic *Interchange, action Action, ourRef string, now time.Time) *Interchange
CONTRL builds the syntax and service report for an interchange: UCI naming it, accepted or rejected, from us (the interchange's recipient) back to its sender. ourRef is our own interchange reference for the CONTRL.
func Parse ¶
func Parse(data []byte) (*Interchange, error)
Parse reads one interchange. Envelope counts are not checked here; see Check.
func Split ¶
func Split(ic *Interchange) []*Interchange
Split returns one interchange per message, each with the original UNB (and group header) and trailers counting one.
func (*Interchange) AllMessages ¶
func (ic *Interchange) AllMessages() []Message
AllMessages lists the messages, whether or not they are in groups.
func (*Interchange) Bytes ¶
func (ic *Interchange) Bytes() []byte
Bytes writes the interchange, with a UNA when it arrived with one or its delimiters are not the defaults.
func (*Interchange) Recipient ¶
func (ic *Interchange) Recipient() (id, qualifier string)
func (*Interchange) Ref ¶
func (ic *Interchange) Ref() string
Ref is the interchange control reference (UNB 0020).
func (*Interchange) Segments ¶
func (ic *Interchange) Segments() []Segment
Segments lists every segment in order, UNB to UNZ.
func (*Interchange) Sender ¶
func (ic *Interchange) Sender() (id, qualifier string)
Sender and Recipient are the interchange's UNB parties (0004 and 0010) with their code qualifiers.
func (*Interchange) Syntax ¶
func (ic *Interchange) Syntax() string
Syntax is the syntax identifier and version (UNB 0001:0002), such as UNOC:3.
type Message ¶
type Message struct {
// Segments runs from UNH to UNT inclusive.
Segments []Segment
}
Message is one UNH ... UNT message.
type Path ¶
type Path struct {
Tag string
Occurrence int // 0: every one
Element, Repetition, Component int // 0: whole / every
}
Path addresses data elements, in the notation the HL7 and X12 paths here use:
BGM the whole segment, as written BGM-2 element 2 (every component, joined with the component separator) BGM-1.1 element 1, component 1 NAD(2)-3.1 the second NAD, element 3, component 1 LIN-3(2).1 element 3, second repetition, component 1 UNB-2.1 the interchange sender
Element and component numbers count from 1 in the order the segment is written, which is how implementation guides number them (BGM's C002 is element 1, 1004 is element 2). A segment without a number means every occurrence.
type Problem ¶
type Problem struct {
Where, What string
}
Problem is one thing wrong with an interchange's envelope.
func Check ¶
func Check(ic *Interchange) []Problem
Check compares the envelope's own counts and references with what it holds: how a truncated or spliced transfer shows.