AckStatustypeno test imports ittype AckStatus = "accepted" | "accepted-with-errors" | "rejected";What an acknowledgement says of what it acknowledges.
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.
AckStatustypeno test imports ittype AckStatus = "accepted" | "accepted-with-errors" | "rejected";What an acknowledgement says of what it acknowledges.
Hl7AckCodetypeno test imports ittype Hl7AckCode = "AA" | "AE" | "AR" | "CA" | "CE" | "CR";The codes of an HL7 v2 acknowledgement: application (AA, AE, AR) and commit (CA, CE, CR).
Acknowledgementtypetype 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.
statusOffunctionfunction statusOf(a: Acknowledgement): AckStatusWhat an acknowledgement comes to.
ACK_KINDSconstconst 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.
ACK_STATUSESconstconst ACK_STATUSES: readonly AckStatus[]Every acknowledgement status.
REJECTION_KINDSconstconst REJECTION_KINDS: readonly ("invalid" | "nack")[]Every reason a message is rejected: the partner said no (nack), or it was invalid on receipt (invalid).
ExchangeStatetypetype 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.
ExchangeEventtypetype 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.
TransitionPolicytypeno test imports ittype TransitionPolicy = { readonly maxAttempts: number };What the agreement allows.
TransitionErrortypeno test imports ittype TransitionError = { readonly kind: "illegal"; readonly from: ExchangeState["kind"]; readonly event: ExchangeEvent["kind"] };An event that does not fit the state it came in.
transitionfunctionfunction 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.
isFinalfunctionfunction isFinal(s: ExchangeState): booleanWhether a state is final: nothing follows it.