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?
readonlyoptionaladdress?:XAD
PID-11 home address parsed as XAD.
dateOfBirth?
readonlyoptionaldateOfBirth?: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?
readonlyoptionalethnicity?:CWE
PID-22 ethnic group.
familyName?
readonlyoptionalfamilyName?:string
PID-5.1 flat family name convenience (D-19).
fullName?
readonlyoptionalfullName?:string
Composed Western-order name "Given Middle Family, Suffix" (D-17).
givenName?
readonlyoptionalgivenName?:string
PID-5.2 flat given name convenience (D-19).
identifiers
readonlyidentifiers: readonlyCX[]
Full PID-3 identifier list, each parsed as a CX. Always present (D-09).
language?
readonlyoptionallanguage?:CE
PID-15 primary language.
middleName?
readonlyoptionalmiddleName?:string
PID-5.3 mapped from XPN.secondName (D-19).
mrn?
readonlyoptionalmrn?:string
Medical record number picked via pickMrn (D-07 / D-08).
name
readonlyname:XPN
Full PID-5 parsed name (first repetition). Always present as {} when empty (D-19).
notes?
readonlyoptionalnotes?: readonlystring[]
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
readonlyphoneNumbers: readonlyXTN[]
PID-13 (home) + PID-14 (business) repetitions concatenated. Always present (D-20).
race?
readonlyoptionalrace?:CWE
PID-10 race.
sex?
readonlyoptionalsex?:string
PID-8 administrative sex code.