Skip to main content
Version: v0.0.3

Interface: IdentityEvent

One recognized patient-identity event. For merge / move kinds the surviving (PID/PV1-sourced) and prior (MRG-sourced) parties are also exposed directly, with the spec-constant direction: "MRG_TO_PID": the prior identifiers are the ones being retired in favour of the surviving ones, never the reverse (HL7 v2 Ch. 3, A18/A39/A40).

parties is the complete role-labelled surface in document order: nothing present in the message is dropped, including a nonconforming MRG in a link/add message (surfaced as a prior-role party).

warnings carries the event's own fail-safe warnings (currently MERGE_MISSING_PRIOR_OR_SURVIVOR); they are scoped to the event and are NOT appended to Hl7Message.warnings (a read-side helper never mutates the message).

Example

import { parseHL7 } from "@cosyte/hl7";
for (const ev of parseHL7(raw).identityEvents()) {
if (ev.kind === "merge" && ev.prior && ev.surviving) {
// retire ev.prior.identifiers in favour of ev.surviving.identifiers
} else if (ev.warnings.length > 0) {
// incomplete pair: do NOT apply; route for review
}
}

Properties

direction?

readonly optional direction?: "MRG_TO_PID"

Spec-constant merge/move direction: the MRG (prior) identifiers merge INTO the PID (surviving) identifiers. Present on merge / move events only; never inferred from content.


eventType

readonly eventType: string

Trigger event code (MSH-9.2, falling back to EVN-1), e.g. "A40".


kind

readonly kind: IdentityEventKind

Classification of the trigger event.


parties

readonly parties: readonly IdentityParty[]

Every party in document order, role-labelled: the complete surface.


prior?

readonly optional prior?: IdentityParty

The prior (non-surviving) party (merge/move): ONLY ever sourced from MRG.


surviving?

readonly optional surviving?: IdentityParty

The surviving party (merge/move): ONLY ever sourced from PID/PV1.


warnings

readonly warnings: readonly Hl7ParseWarning[]

Event-scoped fail-safe warnings (never PHI-bearing).