IF Commons GitHub

logical/exchange

Written to: 3 requirements: 3 proved, 0 partly, 0 failing, 0 with no test recorded. 0006-integrations-exchange FR-010, 0006-integrations-exchange FR-011, 0006-integrations-exchange FR-012

Acknowledgements, outcomes and the exchange state machine (commons integrations 0006-integrations-exchange): the typed acknowledgements of the standards (X12 TA1 and 999, HL7 ACK, FHIR OperationOutcome) reduced to one status, and the life of a message as a total transition function of a state and an event.

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

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

AckStatustypeno test imports it
type AckStatus = "accepted" | "accepted-with-errors" | "rejected";

What an acknowledgement says of what it acknowledges.

Hl7AckCodetypeno test imports it
type Hl7AckCode = "AA" | "AE" | "AR" | "CA" | "CE" | "CR";

The codes of an HL7 v2 acknowledgement: application (AA, AE, AR) and commit (CA, CE, CR).

Acknowledgementtype
type Acknowledgement = | { readonly kind: "x12-ta1"; readonly control: string; readonly status: AckStatus; readonly no… (447 characters)
type Acknowledgement =
  | { readonly kind: "x12-ta1"; readonly control: string; readonly status: AckStatus; readonly note: string }
  | { readonly kind: "x12-999"; readonly control: string; readonly groupControl: string; readonly status: AckStatus; readonly errors: number }
  | { readonly kind: "hl7-ack"; readonly control: string; readonly code: Hl7AckCode }
  | { readonly kind: "fhir-operation-outcome"; readonly issues: readonly Finding[] };

An acknowledgement or an outcome, by standard. It carries codes and counts and the findings (which hold no value), never a payload.

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

statusOffunction
function statusOf(a: Acknowledgement): AckStatus

What an acknowledgement comes to.

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

ACK_KINDSconst
const ACK_KINDS: readonly ("fhir-operation-outcome" | "hl7-ack" | "x12-999" | "x12-ta1")[]

Every kind of acknowledgement, as a closed list of strings a consumer may carry as data.

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

ACK_STATUSESconst
const ACK_STATUSES: readonly AckStatus[]

Every acknowledgement status.

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

REJECTION_KINDSconst
const REJECTION_KINDS: readonly ("invalid" | "nack")[]

Every reason a message is rejected: the partner said no (nack), or it was invalid on receipt (invalid).

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

ExchangeStatetype
type ExchangeState = | { readonly kind: "pending" } | { readonly kind: "sent"; readonly attempt: number; readonly at… (473 characters)
type ExchangeState =
  | { readonly kind: "pending" }
  | { readonly kind: "sent"; readonly attempt: number; readonly at: Instant }
  | { readonly kind: "received"; readonly at: Instant }
  | { readonly kind: "retrying"; readonly attempt: number }
  | { readonly kind: "acknowledged"; readonly status: "accepted" | "accepted-with-errors" }
  | { readonly kind: "rejected"; readonly reason: "nack" | "invalid" }
  | { readonly kind: "abandoned"; readonly attempts: number };

Where a message is in its life.

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

ExchangeEventtype
type ExchangeEvent =
  | { readonly kind: "send"; readonly at: Instant }
  | { readonly kind: "receive"; readonly at: Instant }
  | { readonly kind: "ack"; readonly status: AckStatus }
  | { readonly kind: "timeout" }
  | { readonly kind: "retry"; readonly at: Instant }
  | { readonly kind: "invalid" };

What happens to a message.

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

TransitionPolicytypeno test imports it
type TransitionPolicy = { readonly maxAttempts: number };

What the agreement allows.

TransitionErrortypeno test imports it
type TransitionError = { readonly kind: "illegal"; readonly from: ExchangeState["kind"]; readonly event: ExchangeEvent["kind"] };

An event that does not fit the state it came in.

transitionfunction
function transition(state: ExchangeState, event: ExchangeEvent, policy: TransitionPolicy): Result<ExchangeState, TransitionError>

The next state: total over every state and every event, an illegal pair giving an error and never throwing.

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

isFinalfunction
function isFinal(s: ExchangeState): boolean

Whether a state is final: nothing follows it.

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

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