Skip to main content
Version: v0.0.4

Interface: Patient

PID-derived patient view (HELPERS-02). msg.patient is undefined (D-04) when no PID segment exists; this interface describes the shape when present. identifiers and phoneNumbers are ALWAYS present as arrays (D-09 / D-20): empty when the underlying field is absent. name is ALWAYS present (D-19) even if {} when PID-5 is empty.

Example

import type { Patient } from "@cosyte/hl7";
const p: Patient = {
mrn: "MRN123",
identifiers: [{ idNumber: "MRN123", identifierTypeCode: "MR" }],
name: { familyName: "Smith", givenName: "Jane" },
familyName: "Smith",
givenName: "Jane",
fullName: "Jane Smith",
phoneNumbers: [],
};
console.log(p.dateOfBirth?.raw, p.dateOfBirth?.precision);

Properties

address?

readonly optional address?: XAD

PID-11 home address parsed as XAD.


dateOfBirth?

readonly optional dateOfBirth?: DtmParts

PID-7 date of birth as the fidelity TS. A day-only DOB keeps precision: "day": never coerced to a UTC-midnight instant that would read as the previous day in a negative-offset zone.


ethnicity?

readonly optional ethnicity?: CWE

PID-22 ethnic group.


familyName?

readonly optional familyName?: string

PID-5.1 flat family name convenience (D-19).


fullName?

readonly optional fullName?: string

Composed Western-order name "Given Middle Family, Suffix" (D-17).


givenName?

readonly optional givenName?: string

PID-5.2 flat given name convenience (D-19).


identifiers

readonly identifiers: readonly CX[]

Full PID-3 identifier list, each parsed as a CX. Always present (D-09).


language?

readonly optional language?: CE

PID-15 primary language.


middleName?

readonly optional middleName?: string

PID-5.3 mapped from XPN.secondName (D-19).


mrn?

readonly optional mrn?: string

Medical record number picked via pickMrn (D-07 / D-08).


name

readonly name: XPN

Full PID-5 parsed name (first repetition). Always present as {} when empty (D-19).


notes?

readonly optional notes?: readonly string[]

NTE note lines positionally attached to the (first) PID: notes immediately following the patient's PID segment, HL7-unescaped, in document order. OMITTED when the patient carries no notes. High-PHI-risk clinical narrative.


phoneNumbers

readonly phoneNumbers: readonly XTN[]

PID-13 (home) + PID-14 (business) repetitions concatenated. Always present (D-20).


race?

readonly optional race?: CWE

PID-10 race.


sex?

readonly optional sex?: string

PID-8 administrative sex code.