Documentation
¶
Overview ¶
Package sanitize turns an accepted X12 set into what the agent may see: the typed body and the notes (control M1, the white list).
Input: an x12.Set that Parse accepted and the partner id from the envelope. Output: a Result with the JSON body, the business reference and the notes.
One rule: an element reaches the body only if it is on the list below and passes the format of its place. A listed element that fails its format is replaced by its note reference ("$note_N", reason "format"). The free text elements (PID05, MSG01, REF03, N1-02, N2, PER, NTE02, MTX) never enter the body: each one becomes a note (reason "free_text"). Elements that are on neither list (N3, N4, DTM, PER01, PO105, ...) are dropped without a note.
Notes are numbered in document order. Each note carries the taint label of the partner and a random canary (16 hex characters) that the quarantined reader uses to notice a model that repeats its input.
Index ¶
Constants ¶
const ( ReasonFreeText = "free_text" ReasonFormat = "format" )
Reasons a piece of text is a note.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Note ¶
type Note struct {
Ref string // $note_1, $note_2, ... in document order
SegmentPath string // for example PO1[2]/PID[1]/PID05
Reason string // free_text or format
Text string
TaintLabel string // partner:<partner_id>
Canary string
}
Note is a piece of partner text kept out of the body.
type Result ¶
type Result struct {
BusinessRef string
// BKRef is the raw BEG03 (850) or BIG02 (810) without spaces at the edges: the
// value the idempotency key is built from. Internal only, never shown to the agent.
BKRef string
Body []byte
Notes []Note
}
Result is what Build returns for one set. BusinessRef is the value the agent sees as the business reference (a note reference if BEG03 or BIG02 failed its format); Notes is empty for a 997.