IF Commons GitHub

logical/tree

Written to: 3 requirements: 3 proved, 0 partly, 0 failing, 0 with no test recorded. 0006-integrations-exchange FR-001, 0006-integrations-exchange FR-002, 0006-integrations-exchange FR-003

The abstract typed tree of exchange (commons integrations 0006-integrations-exchange): an interchange of groups of transactions of segments and loops of elements, the one shape that X12, HL7 v2, EDIFACT and FHIR all map to, so that validation, mapping and redaction are written once.

A path is the ids from the transaction down, joined by ., an element with an empty id (the value of a segment that is one value, a primitive of FHIR) adding nothing: Patient.birthDate, PID.05, NM1.03. A path with no indices is the path of the schema; an indexed one (Patient.name[0].family) is of one instance.

Source: commons/integrations/src/logical/tree.ts

13 of 22 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

Elementtypeno test imports it
type Element = { readonly kind: "element"; readonly id: string; readonly value: string; readonly components: readonly Element[]; readonly scalar?: PrimitiveType };

An element: one value, which may have components (an HL7 v2 composite, an X12 composite).

PrimitiveTypetypeno test imports it
type PrimitiveType = "number" | "boolean" | "null";

The type a value had in a syntax that types its primitives (JSON): a text where absent. It is not part of a path.

Segmenttypeno test imports it
type Segment = { readonly kind: "segment"; readonly id: string; readonly elements: readonly Element[] };

A segment: a named run of elements.

Looptypeno test imports it
type Loop = { readonly kind: "loop"; readonly id: string; readonly children: readonly Part[] };

A loop: a named run of segments and loops.

Parttypeno test imports it
type Part = Segment | Loop;

What a loop or a transaction holds.

Envelopetypeno test imports it
type Envelope = { readonly header: readonly Segment[]; readonly trailer: readonly Segment[]; readonly delimiters?: Readonly<Record<string, string>> };

The segments that open and close a node, where its syntax has them (X12's ISA and IEA, GS and GE, ST and SE): kept so that what was read is written back and its control counts can be checked.

Transactiontype
type Transaction = { readonly kind: "transaction"; readonly id: string; readonly control: string; readonly children: readonly Part[]; readonly envelope?: Envelope };

A transaction: one message or document (an 837, an ADT^A01, a FHIR resource).

Imported by 13 tests of the run (13 passed, 0 failed): the library's results

Grouptypeno test imports it
type Group = { readonly kind: "group"; readonly id: string; readonly control: string; readonly transactions: readonly Transaction[]; readonly envelope?: Envelope };

A group of transactions of one kind.

Interchangetype
type Interchange = { readonly kind: "interchange"; readonly syntax: Ref<"syntax">; readonly control: string; readonly groups: readonly Group[]; readonly envelope?: Envelope };

An interchange: what is sent in one go, in one syntax.

Imported by 13 tests of the run (13 passed, 0 failed): the library's results

TreeNodetypeno test imports it
type TreeNode = Interchange | Group | Transaction | Part | Element;

Any node of the tree.

elementconst
const element: (id: string, value: string, components?: readonly Element[], scalar?: PrimitiveType | undefined) => Element

An element.

Imported by 13 tests of the run (13 passed, 0 failed): the library's results

segmentconst
const segment: (id: string, ...elements: readonly Element[]) => Segment

A segment.

Imported by 13 tests of the run (13 passed, 0 failed): the library's results

loopconst
const loop: (id: string, ...children: readonly Part[]) => Loop

A loop.

Imported by 13 tests of the run (13 passed, 0 failed): the library's results

Entrytypeno test imports it
type Entry = { readonly path: string; readonly at: string; readonly value: string };

One value of a tree, with where it is.

entriesfunction
function entries(t: Transaction): readonly Entry[]

Every value of a transaction, in order, as entries.

Imported by 13 tests of the run (13 passed, 0 failed): the library's results

transactionsOfconst
const transactionsOf: (i: Interchange) => readonly Transaction[]

Every transaction of an interchange, in order.

Imported by 13 tests of the run (13 passed, 0 failed): the library's results

pathsOffunction
function pathsOf(t: Transaction): readonly string[]

The paths of a transaction (no indices), each once, in order of first appearance: its segments, loops and elements.

Imported by 13 tests of the run (13 passed, 0 failed): the library's results

occurrencesfunction
function occurrences(t: Transaction, path: string): readonly (readonly [string, number])[]

How many times each node of a path occurs under each instance of its parent: [parent instance, count]; the root is the transaction itself.

Imported by 13 tests of the run (13 passed, 0 failed): the library's results

valuesOffunction
function valuesOf(i: Interchange): readonly string[]

Every distinct value of a tree, longest first: what a scrub of a text must hide.

Imported by 13 tests of the run (13 passed, 0 failed): the library's results

HIDDENconst
const HIDDEN: "[redacted]"

The text that stands where a value was hidden.

Imported by 13 tests of the run (13 passed, 0 failed): the library's results

redactTreefunction
function redactTree(i: Interchange, hide: (path: string) => boolean): Interchange

The interchange with every value hidden whose path (no indices) hide says, or whose ancestor path it says: redaction is written once for every syntax.

Imported by 13 tests of the run (13 passed, 0 failed): the library's results

hidingAllButconst
const hidingAllBut: (allowed: readonly string[]) => (path: string) => boolean

A predicate that hides every path equal to, or below, one of paths: what minimum-necessary does when it lists the elements a recipient may have (allowed), hiding the rest.

Imported by 13 tests of the run (13 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.