IF Commons GitHub

logical/mapping

Written to: 2 requirements: 2 proved, 0 partly, 0 failing, 0 with no test recorded. 0006-integrations-exchange FR-008, 0006-integrations-exchange FR-009

Mappings between standards, declared as data (commons integrations 0006-integrations-exchange): from a standard to a canonical shape or to another standard, such as an X12 837 to a FHIR Claim. Each field of the source ends in exactly one of three states (Kanon rule 5): mapped, carried (kept as it is in a named place) or dropped by name with its reason. A field that ends in none is a finding, and so is a mapping that drops anything, because a lossy mapping is a finding.

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

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

Transformtypeno test imports it
type Transform =
  | { readonly kind: "identity" }
  | { readonly kind: "upper" }
  | { readonly kind: "lower" }
  | { readonly kind: "trim" }
  | { readonly kind: "table"; readonly table: Readonly<Record<string, string>>; readonly otherwise: "keep" | "drop" };

How a value changes on its way.

MapRuletypeno test imports it
type MapRule =
  | { readonly kind: "map"; readonly from: string; readonly to: string; readonly transform: Transform }
  | { readonly kind: "carry"; readonly from: string; readonly to: string }
  | { readonly kind: "drop"; readonly from: string; readonly reason: string };

What a mapping does with one field, or a subtree, of the source (a path stands for everything below it).

Mappingtype
type Mapping = { readonly id: string; readonly source: Ref<"schema">; readonly target: Ref<"schema">; readonly sourceTransaction: string; readonly targetTransaction: string; readonly rules: readonly MapRule[] };

A mapping between two schemas.

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

applyTransformfunctionno test imports it
function applyTransform(t: Transform, value: string): string | undefined

A value through a transform; undefined where a table drops it.

ruleForfunctionno test imports it
function ruleFor(m: Mapping, path: string): MapRule | undefined

The rule that says what becomes of a path: the most specific one.

coveragefunction
function coverage(m: Mapping, sourcePaths: readonly string[]): readonly Finding[]

The findings of a mapping against the paths of its source (the value-bearing ones): a path that ends in no rule, a rule on no path, a target written by two rules, and a drop.

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

valuePathsfunctionno test imports it
function valuePaths(t: Transaction): readonly string[]

The value-bearing paths of a transaction, each once.

allPathsconstno test imports it
const allPaths: (t: Transaction) => readonly string[]

Every path a transaction has: for a schema's own list of paths.

translatefunction
function translate(m: Mapping, source: Transaction): Result<Transaction, readonly Finding[]>

A source transaction translated by a mapping into a flat transaction of the target: one segment for each value, its id the path below the target's root. A value of a field that is dropped is not written; a value whose path has no rule stops the translation with unmapped-source-field, so that nothing is lost silently.

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

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