@pritiranjan/hl7v2 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +434 -0
- package/dist/chunk-Q6NISXHR.js +130 -0
- package/dist/chunk-Q6NISXHR.js.map +1 -0
- package/dist/index.cjs +344 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +309 -0
- package/dist/index.d.ts +309 -0
- package/dist/index.js +200 -0
- package/dist/index.js.map +1 -0
- package/dist/schema-qr-scwmL.d.cts +106 -0
- package/dist/schema-qr-scwmL.d.ts +106 -0
- package/dist/segments/index.cjs +636 -0
- package/dist/segments/index.cjs.map +1 -0
- package/dist/segments/index.d.cts +457 -0
- package/dist/segments/index.d.ts +457 -0
- package/dist/segments/index.js +532 -0
- package/dist/segments/index.js.map +1 -0
- package/package.json +100 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/escape.ts","../../src/errors.ts","../../src/datetime.ts","../../src/segments/base.ts","../../src/segments/msh.ts","../../src/segments/pid.ts","../../src/segments/obx.ts","../../src/segments/pv1.ts"],"names":[],"mappings":";;;AAGA,SAAS,MAAM,CAAA,EAAmB;AAChC,EAAA,OAAO,CAAA,CAAE,OAAA,CAAQ,qBAAA,EAAuB,MAAM,CAAA;AAChD;AAqBO,SAAS,aAAA,CAAc,OAAe,GAAA,EAA4B;AACvE,EAAA,MAAM,MAAM,GAAA,CAAI,MAAA;AAChB,EAAA,IAAI,CAAC,KAAA,CAAM,QAAA,CAAS,GAAG,GAAG,OAAO,KAAA;AAEjC,EAAA,MAAM,UAAU,IAAI,MAAA,CAAO,CAAA,EAAG,KAAA,CAAM,GAAG,CAAC,CAAA,GAAA,EAAM,KAAA,CAAM,GAAG,CAAC,CAAA,GAAA,EAAM,KAAA,CAAM,GAAG,CAAC,IAAI,GAAG,CAAA;AAE/E,EAAA,OAAO,KAAA,CAAM,OAAA,CAAQ,OAAA,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K,EAAA;AAAA,MAC3B,MAAA,EAAY,GAAA,CAAI,CAAC,CAAA,GAAI,CAAC,CAAA,IAAK,EAAA;AAAA,MAC3B,KAAA,EAAY,GAAA,CAAI,CAAC,CAAA,GAAI,CAAC,CAAA,IAAK,EAAA;AAAA,MAC3B,MAAA,EAAY,GAAA,CAAI,CAAC,CAAA,GAAI,CAAC,CAAA,IAAK,EAAA;AAAA,MAC3B,UAAA,EAAY,GAAA,CAAI,CAAC,CAAA,GAAI,CAAC,CAAA,IAAK;AAAA,KAC7B,CAAE,CAAA;AAAA,EACJ;AAAA;AAAA,EAGA,eAAA,GAA0B;AAAE,IAAA,OAAO,IAAA,CAAK,IAAI,EAAE,CAAA;AAAA,EAAG;AAAA;AAAA,EAGjD,WAAA,GAAsB;AAAE,IAAA,OAAO,IAAA,CAAK,IAAI,EAAE,CAAA;AAAA,EAAG;AAAA;AAAA,EAG7C,WAAA,GAAsB;AAAE,IAAA,OAAO,IAAA,CAAK,IAAI,EAAE,CAAA;AAAA,EAAG;AAAA;AAAA,EAG7C,WAAA,GAAsB;AAAE,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,EAAA,EAAI,CAAC,CAAA;AAAA,EAAG;AAAA;AAAA,EAGhD,oBAAA,GAA+B;AAAE,IAAA,OAAO,IAAA,CAAK,IAAI,EAAE,CAAA;AAAA,EAAG;AAAA;AAAA;AAAA;AAAA;AAAA,EAMtD,aAAA,GAAkC;AAAE,IAAA,OAAO,IAAA,CAAK,KAAK,EAAE,CAAA;AAAA,EAAG;AAAA;AAAA;AAAA;AAAA;AAAA,EAM1D,iBAAA,GAAsC;AAAE,IAAA,OAAO,IAAA,CAAK,KAAK,EAAE,CAAA;AAAA,EAAG;AAChE","file":"index.cjs","sourcesContent":["import type { EncodingChars } from './schema.js';\n\n/** Escape a string for use in a regex character class. */\nfunction escRx(s: string): string {\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n/**\n * Decode HL7 v2 escape sequences within a field value.\n *\n * Handles all standard sequences defined in the HL7 v2.x specification:\n * - `\\F\\` → field separator\n * - `\\S\\` → component separator\n * - `\\T\\` → sub-component separator\n * - `\\R\\` → repetition separator\n * - `\\E\\` → escape character\n * - `\\H\\` → start highlighting (stripped — presentation concern)\n * - `\\N\\` → normal text / end highlighting (stripped)\n * - `\\.br\\` → carriage return / line break → `\\n`\n * - `\\Xhh…\\` → hex-encoded bytes → UTF-8 string\n *\n * Unknown or locally-defined sequences (`\\Zxxx\\`) are preserved as-is.\n *\n * @param value - Raw field value that may contain escape sequences\n * @param enc - Encoding characters from the message's MSH segment\n */\nexport function decodeEscapes(value: string, enc: EncodingChars): string {\n const esc = enc.escape;\n if (!value.includes(esc)) return value;\n\n const pattern = new RegExp(`${escRx(esc)}([^${escRx(esc)}]*)${escRx(esc)}`, 'g');\n\n return value.replace(pattern, (match: string, seq: string): string => {\n switch (seq) {\n case 'F': return enc.field;\n case 'S': return enc.component;\n case 'T': return enc.subComponent;\n case 'R': return enc.repetition;\n case 'E': return enc.escape;\n case 'H': return '\\x1b[1m';\n case 'N': return '\\x1b[0m';\n case '.br': return '\\n';\n default: {\n if (seq.startsWith('X') && seq.length > 1) {\n try {\n const hex = seq.slice(1);\n const bytes = new Uint8Array(hex.match(/.{1,2}/g)?.map(b => parseInt(b, 16)) ?? []);\n return new TextDecoder().decode(bytes);\n } catch {\n return match;\n }\n }\n // Preserve unknown / locally-defined sequences unchanged\n return match;\n }\n }\n });\n}\n\n/**\n * Encode a plain string value for safe inclusion in an HL7 v2 field,\n * escaping any characters that have special meaning in the given encoding.\n *\n * Characters are escaped in this order to avoid double-escaping:\n * 1. Escape character itself (`\\E\\`)\n * 2. Field separator (`\\F\\`)\n * 3. Component separator (`\\S\\`)\n * 4. Repetition separator(`\\R\\`)\n * 5. Sub-component sep (`\\T\\`)\n *\n * @param value - Plain string to encode\n * @param enc - Encoding characters from the target message\n */\nexport function encodeEscapes(value: string, enc: EncodingChars): string {\n const esc = enc.escape;\n // Escape the escape character first to avoid double-escaping\n return value\n .replace(new RegExp(escRx(esc), 'g'), `${esc}E${esc}`)\n .replace(new RegExp(escRx(enc.field), 'g'), `${esc}F${esc}`)\n .replace(new RegExp(escRx(enc.component), 'g'), `${esc}S${esc}`)\n .replace(new RegExp(escRx(enc.repetition), 'g'), `${esc}R${esc}`)\n .replace(new RegExp(escRx(enc.subComponent), 'g'), `${esc}T${esc}`);\n}\n","/**\n * Thrown when an HL7 v2 message string cannot be parsed.\n *\n * The `line` and `segmentId` properties help pinpoint the exact failure location\n * when debugging multi-segment messages from production systems.\n */\nexport class HL7ParseError extends Error {\n /** 1-based line number in the source string where the error occurred. */\n readonly line: number | undefined;\n /** Segment identifier that was being parsed when the error occurred. */\n readonly segmentId: string | undefined;\n\n constructor(\n message: string,\n options?: { line?: number; segmentId?: string; cause?: unknown },\n ) {\n super(message);\n this.name = 'HL7ParseError';\n this.line = options?.line;\n this.segmentId = options?.segmentId;\n if (options?.cause !== undefined) {\n Object.defineProperty(this, 'cause', {\n value: options.cause,\n writable: true,\n configurable: true,\n });\n }\n }\n}\n\n/**\n * Thrown when a required segment is not present in the message.\n *\n * @example\n * // Thrown by segment() when the segment is not found\n * const pid = segment(msg, 'PID'); // throws if no PID segment\n */\nexport class SegmentNotFoundError extends Error {\n readonly segmentId: string;\n\n constructor(segmentId: string) {\n super(\n `Segment '${segmentId}' not found in message. ` +\n `Use hasSegment() to check before calling segment(), ` +\n `or segments() to get an empty array when absent.`,\n );\n this.name = 'SegmentNotFoundError';\n this.segmentId = segmentId;\n }\n}\n\n/**\n * Thrown when an HL7 message cannot be identified as valid HL7 v2.\n * Usually means the input is empty, truncated, or a completely different format.\n */\nexport class InvalidHL7Error extends Error {\n constructor(reason: string) {\n super(`Input is not a valid HL7 v2 message: ${reason}`);\n this.name = 'InvalidHL7Error';\n }\n}\n","import { HL7ParseError } from './errors.js';\n\n/**\n * Parse an HL7 v2 Date/Time string into a JavaScript `Date`.\n *\n * Supported formats (per HL7 v2 spec section 2.8.21):\n * - `YYYY`\n * - `YYYYMM`\n * - `YYYYMMDD`\n * - `YYYYMMDDHHMM`\n * - `YYYYMMDDHHMMSS`\n * - `YYYYMMDDHHMMSS.S[SSS]`\n * - Any of the above with `+HHMM` or `-HHMM` timezone offset suffix\n *\n * @returns A `Date` object in UTC, or `undefined` if the value is empty.\n * @throws {HL7ParseError} If the string is non-empty but unparseable.\n */\nexport function parseHL7DateTime(raw: string): Date | undefined {\n const s = raw.trim();\n if (!s) return undefined;\n\n // Minimum valid length is 4 (year only)\n if (s.length < 4) {\n throw new HL7ParseError(`Cannot parse HL7 date/time: \"${s}\" — minimum format is YYYY`);\n }\n\n // Extract optional timezone offset: +HHMM or -HHMM at end\n let base = s;\n let offsetMin = 0;\n\n const tzMatch = /([+-])(\\d{2})(\\d{2})$/.exec(s);\n if (tzMatch) {\n const sign = tzMatch[1] === '+' ? 1 : -1;\n const tzHours = parseInt(tzMatch[2] ?? '0', 10);\n const tzMins = parseInt(tzMatch[3] ?? '0', 10);\n offsetMin = sign * (tzHours * 60 + tzMins);\n base = s.slice(0, s.length - 5);\n }\n\n // Parse fractional seconds: YYYYMMDDHHMMSS.SSSS\n let fracMs = 0;\n const dotIdx = base.indexOf('.');\n if (dotIdx !== -1) {\n const fracStr = base.slice(dotIdx);\n fracMs = Math.round(parseFloat(fracStr) * 1000);\n base = base.slice(0, dotIdx);\n }\n\n const year = parseInt(base.slice(0, 4), 10);\n const month = parseInt(base.slice(4, 6) || '01', 10) - 1; // 0-indexed\n const day = parseInt(base.slice(6, 8) || '01', 10);\n const hour = parseInt(base.slice(8, 10) || '00', 10);\n const min = parseInt(base.slice(10, 12)|| '00', 10);\n const sec = parseInt(base.slice(12, 14)|| '00', 10);\n\n if (isNaN(year) || isNaN(month) || isNaN(day)) {\n throw new HL7ParseError(`Cannot parse HL7 date/time: \"${s}\"`);\n }\n\n // Build UTC epoch, then subtract the timezone offset to normalise to UTC\n const utcMs = Date.UTC(year, month, day, hour, min, sec, fracMs) - offsetMin * 60_000;\n const result = new Date(utcMs);\n\n if (isNaN(result.getTime())) {\n throw new HL7ParseError(`Cannot parse HL7 date/time: \"${s}\"`);\n }\n\n return result;\n}\n\n/**\n * Format a JavaScript `Date` as an HL7 v2 timestamp string in UTC.\n * Output format: `YYYYMMDDHHMMSS`\n */\nexport function formatHL7DateTime(date: Date): string {\n const pad = (n: number, len = 2): string => String(n).padStart(len, '0');\n return (\n pad(date.getUTCFullYear(), 4) +\n pad(date.getUTCMonth() + 1) +\n pad(date.getUTCDate()) +\n pad(date.getUTCHours()) +\n pad(date.getUTCMinutes()) +\n pad(date.getUTCSeconds())\n );\n}\n\n/**\n * Format a JavaScript `Date` as an HL7 v2 date-only string in UTC.\n * Output format: `YYYYMMDD`\n */\nexport function formatHL7Date(date: Date): string {\n const pad = (n: number, len = 2): string => String(n).padStart(len, '0');\n return (\n pad(date.getUTCFullYear(), 4) +\n pad(date.getUTCMonth() + 1) +\n pad(date.getUTCDate())\n );\n}\n","import { decodeEscapes } from '../escape.js';\nimport { parseHL7DateTime } from '../datetime.js';\nimport type { EncodingChars, HL7Field, HL7Segment } from '../schema.js';\n\n/**\n * Base class for typed HL7 v2 segment accessors.\n *\n * Typed segments wrap an {@link HL7Segment} and provide strongly-typed,\n * documented accessor methods for each field — eliminating the need to\n * remember field numbers or component positions.\n *\n * @example\n * import { PID } from 'hl7v2/segments';\n * import { parse, segment } from 'hl7v2';\n *\n * const msg = parse(rawString);\n * const pid = new PID(segment(msg, 'PID'), msg.encoding);\n *\n * pid.patientName() // { family: 'Doe', given: 'John', middle: 'A' }\n * pid.dateOfBirth() // Date | undefined\n * pid.sex() // 'M' | 'F' | 'O' | 'U' | undefined\n */\nexport abstract class TypedSegment {\n constructor(\n protected readonly seg: HL7Segment,\n protected readonly enc: EncodingChars,\n ) {}\n\n /** The raw underlying {@link HL7Segment}. */\n get raw(): HL7Segment {\n return this.seg;\n }\n\n /** Return the raw field structure at the given 1-based field number. */\n protected field(num: number): HL7Field | undefined {\n return this.seg.fields[num - 1];\n }\n\n /**\n * Extract a scalar string value from the segment.\n * All arguments are 1-based. Missing elements return `''`.\n * Escape sequences are decoded automatically.\n */\n protected str(\n fieldNum: number,\n component = 1,\n subComponent = 1,\n repetition = 1,\n ): string {\n const f = this.field(fieldNum);\n if (!f) return '';\n const raw = f[repetition - 1]?.[component - 1]?.[subComponent - 1] ?? '';\n return decodeEscapes(raw, this.enc);\n }\n\n /**\n * Extract a string value from the segment without escape decoding.\n * Useful when you need to preserve the raw HL7 encoding.\n */\n protected rawStr(\n fieldNum: number,\n component = 1,\n subComponent = 1,\n repetition = 1,\n ): string {\n const f = this.field(fieldNum);\n if (!f) return '';\n return f[repetition - 1]?.[component - 1]?.[subComponent - 1] ?? '';\n }\n\n /** Extract a Date from an HL7 date/time field. Returns `undefined` if empty. */\n protected date(fieldNum: number, component = 1): Date | undefined {\n const raw = this.rawStr(fieldNum, component);\n if (!raw) return undefined;\n try {\n return parseHL7DateTime(raw);\n } catch {\n return undefined;\n }\n }\n\n /** Extract a numeric value from a field. Returns `undefined` if empty or non-numeric. */\n protected num(fieldNum: number, component = 1): number | undefined {\n const raw = this.str(fieldNum, component);\n if (!raw) return undefined;\n const n = parseFloat(raw);\n return isNaN(n) ? undefined : n;\n }\n\n /** Return all repetitions of a field as an array of first-component strings. */\n protected repetitions(fieldNum: number, component = 1): string[] {\n const f = this.field(fieldNum);\n if (!f) return [];\n return f.map(rep => {\n const raw = rep[component - 1]?.[0] ?? '';\n return decodeEscapes(raw, this.enc);\n }).filter(v => v !== '');\n }\n}\n","import type { EncodingChars, HL7Segment, MessageType } from '../schema.js';\nimport { TypedSegment } from './base.js';\n\n/** Processing ID values defined in HL7 v2 table 0103. */\nexport type ProcessingId = 'P' | 'D' | 'T';\n\n/**\n * Typed accessor for the MSH (Message Header) segment.\n *\n * MSH is mandatory and always the first segment in any HL7 v2 message.\n * It identifies the message type, version, sender, receiver, and timestamp.\n *\n * @example\n * import { parse, segment } from 'hl7v2';\n * import { MSH } from 'hl7v2/segments';\n *\n * const msg = parse(raw);\n * const msh = new MSH(segment(msg, 'MSH'), msg.encoding);\n *\n * msh.sendingApplication() // 'HOSPITAL_ADT'\n * msh.messageType() // { type: 'ADT', event: 'A01', structure: 'ADT_A01' }\n * msh.messageControlId() // 'MSG000001'\n * msh.version() // '2.5.1'\n */\nexport class MSH extends TypedSegment {\n constructor(seg: HL7Segment, enc: EncodingChars) {\n super(seg, enc);\n }\n\n /** MSH.3 — Sending Application */\n sendingApplication(): string { return this.str(3); }\n\n /** MSH.4 — Sending Facility */\n sendingFacility(): string { return this.str(4); }\n\n /** MSH.5 — Receiving Application */\n receivingApplication(): string { return this.str(5); }\n\n /** MSH.6 — Receiving Facility */\n receivingFacility(): string { return this.str(6); }\n\n /** MSH.7 — Date/Time of Message */\n dateTimeOfMessage(): Date | undefined { return this.date(7); }\n\n /** MSH.9 — Message Type (e.g., `{ type: 'ADT', event: 'A01', structure: 'ADT_A01' }`). */\n messageType(): MessageType {\n const field = this.field(9);\n const firstRep = field?.[0] ?? [];\n const struct = firstRep[2]?.[0];\n return {\n type: firstRep[0]?.[0] ?? '',\n event: firstRep[1]?.[0] ?? '',\n structure: struct !== undefined && struct !== '' ? struct : undefined,\n };\n }\n\n /** MSH.10 — Message Control ID (used for ACK correlation). */\n messageControlId(): string { return this.str(10); }\n\n /**\n * MSH.11 — Processing ID.\n * `'P'` = Production, `'D'` = Debugging, `'T'` = Training.\n */\n processingId(): ProcessingId | string { return this.str(11); }\n\n /** MSH.12 — HL7 version (e.g., `'2.5.1'`). */\n version(): string { return this.str(12); }\n\n /** MSH.15 — Accept Acknowledgement Type. */\n acceptAcknowledgementType(): string { return this.str(15); }\n\n /** MSH.16 — Application Acknowledgement Type. */\n applicationAcknowledgementType(): string { return this.str(16); }\n\n /** MSH.17 — Country Code (ISO 3166). */\n countryCode(): string { return this.str(17); }\n}\n","import type { EncodingChars, HL7Segment } from '../schema.js';\nimport { TypedSegment } from './base.js';\n\n/** Administrative sex codes from HL7 v2 table 0001. */\nexport type AdministrativeSex = 'M' | 'F' | 'O' | 'U' | 'A' | 'N' | 'C';\n\n/** A structured patient name following HL7 XPN (Extended Person Name). */\nexport interface PersonName {\n /** Family (last) name. */\n family: string;\n /** Given (first) name. */\n given: string;\n /** Middle name or initial. */\n middle: string;\n /** Name suffix (e.g., `'JR'`, `'SR'`, `'III'`). */\n suffix: string;\n /** Name prefix (e.g., `'DR'`, `'MR'`, `'MS'`). */\n prefix: string;\n /** Degree (e.g., `'MD'`, `'PHD'`). */\n degree: string;\n}\n\n/** A structured address following HL7 XAD (Extended Address). */\nexport interface Address {\n streetAddress: string;\n otherDesignation: string;\n city: string;\n state: string;\n postalCode: string;\n country: string;\n addressType: string;\n}\n\n/** A patient identifier from PID.3 (Patient Identifier List). */\nexport interface PatientIdentifier {\n /** The identifier value (e.g., MRN, SSN). */\n id: string;\n /** Check digit. */\n checkDigit: string;\n /** Assigning authority (e.g., `'HOSPITAL'`). */\n assigningAuthority: string;\n /** Identifier type code (e.g., `'MR'` = Medical Record, `'PI'` = Patient Internal). */\n identifierTypeCode: string;\n}\n\n/**\n * Typed accessor for the PID (Patient Identification) segment.\n *\n * PID carries all core patient demographic information and appears in\n * virtually every HL7 v2 message type (ADT, ORU, ORM, SIU, etc.).\n *\n * @example\n * import { parse, segment } from 'hl7v2';\n * import { PID } from 'hl7v2/segments';\n *\n * const msg = parse(raw);\n * const pid = new PID(segment(msg, 'PID'), msg.encoding);\n *\n * pid.patientName() // { family: 'Doe', given: 'John', middle: 'A', ... }\n * pid.dateOfBirth() // Date | undefined\n * pid.sex() // 'M' | 'F' | ...\n * pid.patientIdentifiers() // PatientIdentifier[]\n */\nexport class PID extends TypedSegment {\n constructor(seg: HL7Segment, enc: EncodingChars) {\n super(seg, enc);\n }\n\n /** PID.1 — Set ID (1-based sequence number within the message). */\n setId(): number | undefined { return this.num(1); }\n\n /**\n * PID.3 — Patient Identifier List.\n *\n * Returns all patient identifiers (MRN, SSN, national ID, etc.).\n * Each identifier has its own type code and assigning authority.\n *\n * @example\n * pid.patientIdentifiers()\n * // [{ id: 'MRN123', assigningAuthority: 'HOSPITAL', identifierTypeCode: 'MR' }]\n */\n patientIdentifiers(): PatientIdentifier[] {\n const field = this.field(3);\n if (!field) return [];\n return field.map(rep => ({\n id: rep[0]?.[0] ?? '',\n checkDigit: rep[1]?.[0] ?? '',\n assigningAuthority: rep[3]?.[0] ?? '',\n identifierTypeCode: rep[4]?.[0] ?? '',\n }));\n }\n\n /**\n * PID.3 — Primary patient identifier (first in the list).\n * Returns the raw identifier string (e.g., `'MRN123'`).\n */\n patientId(): string { return this.str(3, 1); }\n\n /**\n * PID.5 — Patient Name (first/primary name).\n *\n * Patient names follow the XPN (Extended Person Name) data type.\n * Components: family ^ given ^ middle ^ suffix ^ prefix ^ degree\n */\n patientName(): PersonName {\n return {\n family: this.str(5, 1),\n given: this.str(5, 2),\n middle: this.str(5, 3),\n suffix: this.str(5, 4),\n prefix: this.str(5, 5),\n degree: this.str(5, 6),\n };\n }\n\n /**\n * PID.5 — All patient names (legal, alias, display, etc.).\n * Most messages contain a single name; some include aliases or prior names.\n */\n allPatientNames(): PersonName[] {\n const field = this.field(5);\n if (!field) return [];\n return field.map(rep => ({\n family: rep[0]?.[0] ?? '',\n given: rep[1]?.[0] ?? '',\n middle: rep[2]?.[0] ?? '',\n suffix: rep[3]?.[0] ?? '',\n prefix: rep[4]?.[0] ?? '',\n degree: rep[5]?.[0] ?? '',\n }));\n }\n\n /**\n * PID.7 — Date/Time of Birth.\n * Returns `undefined` if absent or unparseable.\n */\n dateOfBirth(): Date | undefined { return this.date(7); }\n\n /**\n * PID.8 — Administrative Sex (HL7 table 0001).\n * `'M'` Male · `'F'` Female · `'O'` Other · `'U'` Unknown\n * `'A'` Ambiguous · `'N'` Not applicable · `'C'` Complex\n */\n sex(): AdministrativeSex | string { return this.str(8); }\n\n /**\n * PID.10 — Race (HL7 table 0005, CWE data type).\n * Returns the race code (first component).\n */\n race(): string { return this.str(10, 1); }\n\n /**\n * PID.11 — Patient Address (first address).\n * Addresses follow the XAD (Extended Address) data type.\n */\n address(): Address {\n return {\n streetAddress: this.str(11, 1),\n otherDesignation: this.str(11, 2),\n city: this.str(11, 3),\n state: this.str(11, 4),\n postalCode: this.str(11, 5),\n country: this.str(11, 6),\n addressType: this.str(11, 7),\n };\n }\n\n /** PID.13 — Phone Number - Home (first number, XTN data type). */\n homePhone(): string { return this.str(13, 1); }\n\n /** PID.14 — Phone Number - Business (first number, XTN data type). */\n workPhone(): string { return this.str(14, 1); }\n\n /**\n * PID.15 — Primary Language (CE data type).\n * Returns the language code (e.g., `'ENG'`, `'SPA'`).\n */\n primaryLanguage(): string { return this.str(15, 1); }\n\n /** PID.16 — Marital Status (HL7 table 0002). */\n maritalStatus(): string { return this.str(16, 1); }\n\n /** PID.17 — Religion (HL7 table 0006). */\n religion(): string { return this.str(17, 1); }\n\n /**\n * PID.18 — Patient Account Number.\n * The billing/visit account number (distinct from the medical record number).\n */\n accountNumber(): string { return this.str(18, 1); }\n\n /** PID.19 — SSN Number - Patient (US Social Security Number). */\n ssn(): string { return this.str(19); }\n\n /** PID.22 — Ethnic Group (HL7 table 0189, CWE data type). */\n ethnicGroup(): string { return this.str(22, 1); }\n\n /** PID.29 — Patient Death Date and Time. `undefined` if patient is not deceased. */\n deathDateTime(): Date | undefined { return this.date(29); }\n\n /**\n * PID.30 — Patient Death Indicator.\n * `'Y'` = deceased, `'N'` = not deceased.\n */\n deathIndicator(): 'Y' | 'N' | string { return this.str(30); }\n}\n","import type { EncodingChars, HL7Segment } from '../schema.js';\nimport { TypedSegment } from './base.js';\n\n/** OBX.2 — Value type codes from HL7 v2 table 0125. */\nexport type ObservationValueType =\n | 'NM' // Numeric\n | 'ST' // String\n | 'TX' // Text\n | 'FT' // Formatted text\n | 'CWE' // Coded with Exceptions\n | 'CE' // Coded Element (deprecated in v2.7+)\n | 'DT' // Date\n | 'TM' // Time\n | 'TS' // Time Stamp (deprecated in v2.7+)\n | 'DTM' // Date/Time (v2.7+)\n | 'SN' // Structured Numeric\n | 'RP' // Reference Pointer (e.g., image URL)\n | 'ED' // Encapsulated Data\n | string;\n\n/** OBX.11 — Observation Result Status codes from HL7 v2 table 0085. */\nexport type ResultStatus =\n | 'F' // Final\n | 'P' // Preliminary\n | 'C' // Correction\n | 'X' // Result cannot be obtained\n | 'I' // Specimen in lab — results pending\n | 'R' // Results entered — not yet verified\n | 'S' // Partial results\n | 'D' // Deletes the OBX record\n | 'N' // Not asked — not reported\n | 'W' // Post original as wrong (in error)\n | string;\n\n/** Abnormal flags from HL7 v2 table 0078. */\nexport type AbnormalFlag =\n | 'H' // Above high normal\n | 'HH' // Above upper panic limits\n | 'L' // Below low normal\n | 'LL' // Below lower panic limits\n | 'A' // Abnormal (generic)\n | 'AA' // Very abnormal\n | 'N' // Normal\n | 'IND' // Indeterminate\n | 'NEG' // Negative\n | 'POS' // Positive\n | string;\n\n/** A coded observation identifier (LOINC, SNOMED, local). */\nexport interface ObservationIdentifier {\n /** Identifier code (e.g., LOINC code `'718-7'`). */\n code: string;\n /** Human-readable description (e.g., `'Hemoglobin'`). */\n description: string;\n /** Coding system (e.g., `'LN'` for LOINC, `'SCT'` for SNOMED CT). */\n codingSystem: string;\n}\n\n/**\n * Typed accessor for the OBX (Observation/Result) segment.\n *\n * OBX carries a single clinical observation — a lab result, vital sign,\n * pathology finding, or any structured clinical measurement. A message\n * typically contains multiple OBX segments, one per result.\n *\n * @example\n * import { parse, segments } from 'hl7v2';\n * import { OBX } from 'hl7v2/segments';\n *\n * const msg = parse(raw);\n * const obxs = segments(msg, 'OBX').map(s => new OBX(s, msg.encoding));\n *\n * for (const obx of obxs) {\n * console.log(obx.observationIdentifier().description); // 'Hemoglobin'\n * console.log(obx.numericValue()); // 13.5\n * console.log(obx.units()); // 'g/dL'\n * console.log(obx.referenceRange()); // '13.5-17.5'\n * console.log(obx.abnormalFlags()); // ['H']\n * console.log(obx.resultStatus()); // 'F'\n * }\n */\nexport class OBX extends TypedSegment {\n constructor(seg: HL7Segment, enc: EncodingChars) {\n super(seg, enc);\n }\n\n /** OBX.1 — Set ID (sequence number within the message, 1-based). */\n setId(): number | undefined { return this.num(1); }\n\n /**\n * OBX.2 — Value Type.\n * Indicates the data type of the observation value in OBX.5.\n * Common values: `'NM'` (numeric), `'ST'` (string), `'CWE'` (coded).\n */\n valueType(): ObservationValueType { return this.str(2); }\n\n /**\n * OBX.3 — Observation Identifier.\n * Typically a LOINC code identifying what was measured.\n *\n * @example\n * obx.observationIdentifier()\n * // { code: '718-7', description: 'Hemoglobin [Mass/volume] in Blood', codingSystem: 'LN' }\n */\n observationIdentifier(): ObservationIdentifier {\n return {\n code: this.str(3, 1),\n description: this.str(3, 2),\n codingSystem: this.str(3, 3),\n };\n }\n\n /** OBX.4 — Observation Sub-ID (groups related OBX segments). */\n observationSubId(): string { return this.str(4); }\n\n /**\n * OBX.5 — Observation Value (raw string).\n *\n * The interpretation depends on OBX.2 (value type).\n * Use {@link numericValue} for `NM`, {@link codedValue} for `CWE`/`CE`.\n */\n observationValue(): string { return this.str(5); }\n\n /**\n * OBX.5 — Observation value interpreted as a number.\n * Returns `undefined` if the value type is not `NM` or the value is absent.\n *\n * For structured numerics (SN type like `'>10.5'`), use {@link observationValue}.\n */\n numericValue(): number | undefined {\n if (this.str(2) !== 'NM') return undefined;\n return this.num(5);\n }\n\n /**\n * OBX.5 — Observation value as a coded element (CWE/CE value type).\n * Returns `{ code, description, codingSystem }`.\n */\n codedValue(): ObservationIdentifier {\n return {\n code: this.str(5, 1),\n description: this.str(5, 2),\n codingSystem: this.str(5, 3),\n };\n }\n\n /**\n * OBX.6 — Units (CWE data type).\n * Returns the unit code (e.g., `'g/dL'`, `'10*3/uL'`, `'mmHg'`).\n */\n units(): string { return this.str(6, 1); }\n\n /**\n * OBX.7 — References Range.\n * The normal range as a string (e.g., `'3.5-5.0'`, `'<200'`).\n */\n referenceRange(): string { return this.str(7); }\n\n /**\n * OBX.8 — Interpretation Codes (formerly Abnormal Flags).\n * Returns all flags for this result (a field can have multiple repetitions).\n *\n * Common values: `'H'` high, `'L'` low, `'HH'` critical high, `'LL'` critical low,\n * `'N'` normal, `'A'` abnormal, `'POS'` positive, `'NEG'` negative.\n */\n abnormalFlags(): AbnormalFlag[] {\n return this.repetitions(8);\n }\n\n /**\n * OBX.8 — Primary interpretation code (first flag).\n * Returns `''` if the result has no flags (i.e., it is normal / in-range).\n */\n primaryAbnormalFlag(): AbnormalFlag { return this.str(8); }\n\n /** OBX.11 — Observation Result Status (HL7 table 0085). */\n resultStatus(): ResultStatus { return this.str(11); }\n\n /** OBX.14 — Date/Time of Observation. */\n observationDateTime(): Date | undefined { return this.date(14); }\n\n /** OBX.15 — Producer's ID (the lab or device that produced the result). */\n producerId(): string { return this.str(15, 1); }\n\n /** OBX.16 — Responsible Observer (clinician who verified the result). */\n responsibleObserver(): string { return this.str(16, 1); }\n\n /** OBX.19 — Date/Time of Analysis. */\n analysisDateTime(): Date | undefined { return this.date(19); }\n\n /**\n * Convenience: return `true` if this result has a critical abnormal flag\n * (`'HH'` or `'LL'`).\n */\n isCritical(): boolean {\n const flags = this.abnormalFlags();\n return flags.includes('HH') || flags.includes('LL');\n }\n\n /**\n * Convenience: return `true` if the result is finalised (`resultStatus() === 'F'`).\n */\n isFinal(): boolean { return this.str(11) === 'F'; }\n}\n","import type { EncodingChars, HL7Segment } from '../schema.js';\nimport { TypedSegment } from './base.js';\n\n/** Patient class codes from HL7 v2 table 0004. */\nexport type PatientClass =\n | 'E' // Emergency\n | 'I' // Inpatient\n | 'O' // Outpatient\n | 'P' // Preadmit\n | 'R' // Recurring patient\n | 'B' // Obstetrics\n | 'C' // Commercial account\n | 'N' // Not applicable\n | 'U' // Unknown\n | string;\n\n/** A structured provider/clinician name and identifier. */\nexport interface Provider {\n /** Provider identifier (e.g., NPI number, employee ID). */\n id: string;\n /** Family (last) name. */\n family: string;\n /** Given (first) name. */\n given: string;\n /** Middle name or initial. */\n middle: string;\n /** Credential suffix (e.g., `'MD'`, `'DO'`, `'NP'`). */\n credential: string;\n}\n\n/** A patient location — room, bed, facility. */\nexport interface PatientLocation {\n pointOfCare: string;\n room: string;\n bed: string;\n facility: string;\n buildingCode: string;\n floor: string;\n}\n\n/**\n * Typed accessor for the PV1 (Patient Visit) segment.\n *\n * PV1 describes the context of a patient's current or historical visit:\n * the patient class (inpatient/outpatient), assigned location, attending\n * and referring physicians, and admission/discharge timestamps.\n *\n * @example\n * import { parse, segment } from 'hl7v2';\n * import { PV1 } from 'hl7v2/segments';\n *\n * const msg = parse(raw);\n * const pv1 = new PV1(segment(msg, 'PV1'), msg.encoding);\n *\n * pv1.patientClass() // 'I' (Inpatient)\n * pv1.assignedLocation() // { pointOfCare: 'CARDIOLOGY', room: '4A', bed: '101', ... }\n * pv1.attendingDoctor() // { id: '1234567', family: 'Smith', given: 'Richard', ... }\n * pv1.admitDateTime() // Date | undefined\n */\nexport class PV1 extends TypedSegment {\n constructor(seg: HL7Segment, enc: EncodingChars) {\n super(seg, enc);\n }\n\n /** PV1.1 — Set ID. */\n setId(): number | undefined { return this.num(1); }\n\n /**\n * PV1.2 — Patient Class (HL7 table 0004).\n * `'I'` Inpatient · `'O'` Outpatient · `'E'` Emergency · `'P'` Preadmit\n */\n patientClass(): PatientClass { return this.str(2); }\n\n /**\n * PV1.3 — Assigned Patient Location.\n * The bed the patient is currently assigned to.\n */\n assignedLocation(): PatientLocation {\n return {\n pointOfCare: this.str(3, 1),\n room: this.str(3, 2),\n bed: this.str(3, 3),\n facility: this.str(3, 4),\n buildingCode:this.str(3, 7),\n floor: this.str(3, 8),\n };\n }\n\n /** PV1.4 — Admission Type (e.g., `'A'` = accident, `'E'` = emergency). */\n admissionType(): string { return this.str(4); }\n\n /**\n * PV1.7 — Attending Doctor.\n * The physician primarily responsible for the patient's care.\n */\n attendingDoctor(): Provider {\n return {\n id: this.str(7, 1),\n family: this.str(7, 2),\n given: this.str(7, 3),\n middle: this.str(7, 4),\n credential: this.str(7, 7),\n };\n }\n\n /**\n * PV1.8 — Referring Doctor.\n * The physician who referred the patient.\n */\n referringDoctor(): Provider {\n return {\n id: this.str(8, 1),\n family: this.str(8, 2),\n given: this.str(8, 3),\n middle: this.str(8, 4),\n credential: this.str(8, 7),\n };\n }\n\n /**\n * PV1.9 — Consulting Doctor.\n * Returns all consulting doctors (field can repeat).\n */\n consultingDoctors(): Provider[] {\n const field = this.field(9);\n if (!field) return [];\n return field.map(rep => ({\n id: rep[0]?.[0] ?? '',\n family: rep[1]?.[0] ?? '',\n given: rep[2]?.[0] ?? '',\n middle: rep[3]?.[0] ?? '',\n credential: rep[7]?.[0] ?? '',\n }));\n }\n\n /** PV1.10 — Hospital Service (e.g., `'MED'`, `'SUR'`, `'CAR'`). */\n hospitalService(): string { return this.str(10); }\n\n /** PV1.14 — Admit Source (HL7 table 0023). */\n admitSource(): string { return this.str(14); }\n\n /** PV1.18 — Patient Type. */\n patientType(): string { return this.str(18); }\n\n /** PV1.19 — Visit Number (account number for this specific visit). */\n visitNumber(): string { return this.str(19, 1); }\n\n /** PV1.36 — Discharge Disposition (HL7 table 0112). */\n dischargeDisposition(): string { return this.str(36); }\n\n /**\n * PV1.44 — Admit Date/Time.\n * When the patient was admitted to this care setting.\n */\n admitDateTime(): Date | undefined { return this.date(44); }\n\n /**\n * PV1.45 — Discharge Date/Time.\n * `undefined` if the patient has not yet been discharged.\n */\n dischargeDateTime(): Date | undefined { return this.date(45); }\n}\n"]}
|
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
import { a as HL7Segment, E as EncodingChars, b as HL7Field, M as MessageType } from '../schema-qr-scwmL.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Base class for typed HL7 v2 segment accessors.
|
|
5
|
+
*
|
|
6
|
+
* Typed segments wrap an {@link HL7Segment} and provide strongly-typed,
|
|
7
|
+
* documented accessor methods for each field — eliminating the need to
|
|
8
|
+
* remember field numbers or component positions.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import { PID } from 'hl7v2/segments';
|
|
12
|
+
* import { parse, segment } from 'hl7v2';
|
|
13
|
+
*
|
|
14
|
+
* const msg = parse(rawString);
|
|
15
|
+
* const pid = new PID(segment(msg, 'PID'), msg.encoding);
|
|
16
|
+
*
|
|
17
|
+
* pid.patientName() // { family: 'Doe', given: 'John', middle: 'A' }
|
|
18
|
+
* pid.dateOfBirth() // Date | undefined
|
|
19
|
+
* pid.sex() // 'M' | 'F' | 'O' | 'U' | undefined
|
|
20
|
+
*/
|
|
21
|
+
declare abstract class TypedSegment {
|
|
22
|
+
protected readonly seg: HL7Segment;
|
|
23
|
+
protected readonly enc: EncodingChars;
|
|
24
|
+
constructor(seg: HL7Segment, enc: EncodingChars);
|
|
25
|
+
/** The raw underlying {@link HL7Segment}. */
|
|
26
|
+
get raw(): HL7Segment;
|
|
27
|
+
/** Return the raw field structure at the given 1-based field number. */
|
|
28
|
+
protected field(num: number): HL7Field | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Extract a scalar string value from the segment.
|
|
31
|
+
* All arguments are 1-based. Missing elements return `''`.
|
|
32
|
+
* Escape sequences are decoded automatically.
|
|
33
|
+
*/
|
|
34
|
+
protected str(fieldNum: number, component?: number, subComponent?: number, repetition?: number): string;
|
|
35
|
+
/**
|
|
36
|
+
* Extract a string value from the segment without escape decoding.
|
|
37
|
+
* Useful when you need to preserve the raw HL7 encoding.
|
|
38
|
+
*/
|
|
39
|
+
protected rawStr(fieldNum: number, component?: number, subComponent?: number, repetition?: number): string;
|
|
40
|
+
/** Extract a Date from an HL7 date/time field. Returns `undefined` if empty. */
|
|
41
|
+
protected date(fieldNum: number, component?: number): Date | undefined;
|
|
42
|
+
/** Extract a numeric value from a field. Returns `undefined` if empty or non-numeric. */
|
|
43
|
+
protected num(fieldNum: number, component?: number): number | undefined;
|
|
44
|
+
/** Return all repetitions of a field as an array of first-component strings. */
|
|
45
|
+
protected repetitions(fieldNum: number, component?: number): string[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Processing ID values defined in HL7 v2 table 0103. */
|
|
49
|
+
type ProcessingId = 'P' | 'D' | 'T';
|
|
50
|
+
/**
|
|
51
|
+
* Typed accessor for the MSH (Message Header) segment.
|
|
52
|
+
*
|
|
53
|
+
* MSH is mandatory and always the first segment in any HL7 v2 message.
|
|
54
|
+
* It identifies the message type, version, sender, receiver, and timestamp.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* import { parse, segment } from 'hl7v2';
|
|
58
|
+
* import { MSH } from 'hl7v2/segments';
|
|
59
|
+
*
|
|
60
|
+
* const msg = parse(raw);
|
|
61
|
+
* const msh = new MSH(segment(msg, 'MSH'), msg.encoding);
|
|
62
|
+
*
|
|
63
|
+
* msh.sendingApplication() // 'HOSPITAL_ADT'
|
|
64
|
+
* msh.messageType() // { type: 'ADT', event: 'A01', structure: 'ADT_A01' }
|
|
65
|
+
* msh.messageControlId() // 'MSG000001'
|
|
66
|
+
* msh.version() // '2.5.1'
|
|
67
|
+
*/
|
|
68
|
+
declare class MSH extends TypedSegment {
|
|
69
|
+
constructor(seg: HL7Segment, enc: EncodingChars);
|
|
70
|
+
/** MSH.3 — Sending Application */
|
|
71
|
+
sendingApplication(): string;
|
|
72
|
+
/** MSH.4 — Sending Facility */
|
|
73
|
+
sendingFacility(): string;
|
|
74
|
+
/** MSH.5 — Receiving Application */
|
|
75
|
+
receivingApplication(): string;
|
|
76
|
+
/** MSH.6 — Receiving Facility */
|
|
77
|
+
receivingFacility(): string;
|
|
78
|
+
/** MSH.7 — Date/Time of Message */
|
|
79
|
+
dateTimeOfMessage(): Date | undefined;
|
|
80
|
+
/** MSH.9 — Message Type (e.g., `{ type: 'ADT', event: 'A01', structure: 'ADT_A01' }`). */
|
|
81
|
+
messageType(): MessageType;
|
|
82
|
+
/** MSH.10 — Message Control ID (used for ACK correlation). */
|
|
83
|
+
messageControlId(): string;
|
|
84
|
+
/**
|
|
85
|
+
* MSH.11 — Processing ID.
|
|
86
|
+
* `'P'` = Production, `'D'` = Debugging, `'T'` = Training.
|
|
87
|
+
*/
|
|
88
|
+
processingId(): ProcessingId | string;
|
|
89
|
+
/** MSH.12 — HL7 version (e.g., `'2.5.1'`). */
|
|
90
|
+
version(): string;
|
|
91
|
+
/** MSH.15 — Accept Acknowledgement Type. */
|
|
92
|
+
acceptAcknowledgementType(): string;
|
|
93
|
+
/** MSH.16 — Application Acknowledgement Type. */
|
|
94
|
+
applicationAcknowledgementType(): string;
|
|
95
|
+
/** MSH.17 — Country Code (ISO 3166). */
|
|
96
|
+
countryCode(): string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Administrative sex codes from HL7 v2 table 0001. */
|
|
100
|
+
type AdministrativeSex = 'M' | 'F' | 'O' | 'U' | 'A' | 'N' | 'C';
|
|
101
|
+
/** A structured patient name following HL7 XPN (Extended Person Name). */
|
|
102
|
+
interface PersonName {
|
|
103
|
+
/** Family (last) name. */
|
|
104
|
+
family: string;
|
|
105
|
+
/** Given (first) name. */
|
|
106
|
+
given: string;
|
|
107
|
+
/** Middle name or initial. */
|
|
108
|
+
middle: string;
|
|
109
|
+
/** Name suffix (e.g., `'JR'`, `'SR'`, `'III'`). */
|
|
110
|
+
suffix: string;
|
|
111
|
+
/** Name prefix (e.g., `'DR'`, `'MR'`, `'MS'`). */
|
|
112
|
+
prefix: string;
|
|
113
|
+
/** Degree (e.g., `'MD'`, `'PHD'`). */
|
|
114
|
+
degree: string;
|
|
115
|
+
}
|
|
116
|
+
/** A structured address following HL7 XAD (Extended Address). */
|
|
117
|
+
interface Address {
|
|
118
|
+
streetAddress: string;
|
|
119
|
+
otherDesignation: string;
|
|
120
|
+
city: string;
|
|
121
|
+
state: string;
|
|
122
|
+
postalCode: string;
|
|
123
|
+
country: string;
|
|
124
|
+
addressType: string;
|
|
125
|
+
}
|
|
126
|
+
/** A patient identifier from PID.3 (Patient Identifier List). */
|
|
127
|
+
interface PatientIdentifier {
|
|
128
|
+
/** The identifier value (e.g., MRN, SSN). */
|
|
129
|
+
id: string;
|
|
130
|
+
/** Check digit. */
|
|
131
|
+
checkDigit: string;
|
|
132
|
+
/** Assigning authority (e.g., `'HOSPITAL'`). */
|
|
133
|
+
assigningAuthority: string;
|
|
134
|
+
/** Identifier type code (e.g., `'MR'` = Medical Record, `'PI'` = Patient Internal). */
|
|
135
|
+
identifierTypeCode: string;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Typed accessor for the PID (Patient Identification) segment.
|
|
139
|
+
*
|
|
140
|
+
* PID carries all core patient demographic information and appears in
|
|
141
|
+
* virtually every HL7 v2 message type (ADT, ORU, ORM, SIU, etc.).
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* import { parse, segment } from 'hl7v2';
|
|
145
|
+
* import { PID } from 'hl7v2/segments';
|
|
146
|
+
*
|
|
147
|
+
* const msg = parse(raw);
|
|
148
|
+
* const pid = new PID(segment(msg, 'PID'), msg.encoding);
|
|
149
|
+
*
|
|
150
|
+
* pid.patientName() // { family: 'Doe', given: 'John', middle: 'A', ... }
|
|
151
|
+
* pid.dateOfBirth() // Date | undefined
|
|
152
|
+
* pid.sex() // 'M' | 'F' | ...
|
|
153
|
+
* pid.patientIdentifiers() // PatientIdentifier[]
|
|
154
|
+
*/
|
|
155
|
+
declare class PID extends TypedSegment {
|
|
156
|
+
constructor(seg: HL7Segment, enc: EncodingChars);
|
|
157
|
+
/** PID.1 — Set ID (1-based sequence number within the message). */
|
|
158
|
+
setId(): number | undefined;
|
|
159
|
+
/**
|
|
160
|
+
* PID.3 — Patient Identifier List.
|
|
161
|
+
*
|
|
162
|
+
* Returns all patient identifiers (MRN, SSN, national ID, etc.).
|
|
163
|
+
* Each identifier has its own type code and assigning authority.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* pid.patientIdentifiers()
|
|
167
|
+
* // [{ id: 'MRN123', assigningAuthority: 'HOSPITAL', identifierTypeCode: 'MR' }]
|
|
168
|
+
*/
|
|
169
|
+
patientIdentifiers(): PatientIdentifier[];
|
|
170
|
+
/**
|
|
171
|
+
* PID.3 — Primary patient identifier (first in the list).
|
|
172
|
+
* Returns the raw identifier string (e.g., `'MRN123'`).
|
|
173
|
+
*/
|
|
174
|
+
patientId(): string;
|
|
175
|
+
/**
|
|
176
|
+
* PID.5 — Patient Name (first/primary name).
|
|
177
|
+
*
|
|
178
|
+
* Patient names follow the XPN (Extended Person Name) data type.
|
|
179
|
+
* Components: family ^ given ^ middle ^ suffix ^ prefix ^ degree
|
|
180
|
+
*/
|
|
181
|
+
patientName(): PersonName;
|
|
182
|
+
/**
|
|
183
|
+
* PID.5 — All patient names (legal, alias, display, etc.).
|
|
184
|
+
* Most messages contain a single name; some include aliases or prior names.
|
|
185
|
+
*/
|
|
186
|
+
allPatientNames(): PersonName[];
|
|
187
|
+
/**
|
|
188
|
+
* PID.7 — Date/Time of Birth.
|
|
189
|
+
* Returns `undefined` if absent or unparseable.
|
|
190
|
+
*/
|
|
191
|
+
dateOfBirth(): Date | undefined;
|
|
192
|
+
/**
|
|
193
|
+
* PID.8 — Administrative Sex (HL7 table 0001).
|
|
194
|
+
* `'M'` Male · `'F'` Female · `'O'` Other · `'U'` Unknown
|
|
195
|
+
* `'A'` Ambiguous · `'N'` Not applicable · `'C'` Complex
|
|
196
|
+
*/
|
|
197
|
+
sex(): AdministrativeSex | string;
|
|
198
|
+
/**
|
|
199
|
+
* PID.10 — Race (HL7 table 0005, CWE data type).
|
|
200
|
+
* Returns the race code (first component).
|
|
201
|
+
*/
|
|
202
|
+
race(): string;
|
|
203
|
+
/**
|
|
204
|
+
* PID.11 — Patient Address (first address).
|
|
205
|
+
* Addresses follow the XAD (Extended Address) data type.
|
|
206
|
+
*/
|
|
207
|
+
address(): Address;
|
|
208
|
+
/** PID.13 — Phone Number - Home (first number, XTN data type). */
|
|
209
|
+
homePhone(): string;
|
|
210
|
+
/** PID.14 — Phone Number - Business (first number, XTN data type). */
|
|
211
|
+
workPhone(): string;
|
|
212
|
+
/**
|
|
213
|
+
* PID.15 — Primary Language (CE data type).
|
|
214
|
+
* Returns the language code (e.g., `'ENG'`, `'SPA'`).
|
|
215
|
+
*/
|
|
216
|
+
primaryLanguage(): string;
|
|
217
|
+
/** PID.16 — Marital Status (HL7 table 0002). */
|
|
218
|
+
maritalStatus(): string;
|
|
219
|
+
/** PID.17 — Religion (HL7 table 0006). */
|
|
220
|
+
religion(): string;
|
|
221
|
+
/**
|
|
222
|
+
* PID.18 — Patient Account Number.
|
|
223
|
+
* The billing/visit account number (distinct from the medical record number).
|
|
224
|
+
*/
|
|
225
|
+
accountNumber(): string;
|
|
226
|
+
/** PID.19 — SSN Number - Patient (US Social Security Number). */
|
|
227
|
+
ssn(): string;
|
|
228
|
+
/** PID.22 — Ethnic Group (HL7 table 0189, CWE data type). */
|
|
229
|
+
ethnicGroup(): string;
|
|
230
|
+
/** PID.29 — Patient Death Date and Time. `undefined` if patient is not deceased. */
|
|
231
|
+
deathDateTime(): Date | undefined;
|
|
232
|
+
/**
|
|
233
|
+
* PID.30 — Patient Death Indicator.
|
|
234
|
+
* `'Y'` = deceased, `'N'` = not deceased.
|
|
235
|
+
*/
|
|
236
|
+
deathIndicator(): 'Y' | 'N' | string;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** OBX.2 — Value type codes from HL7 v2 table 0125. */
|
|
240
|
+
type ObservationValueType = 'NM' | 'ST' | 'TX' | 'FT' | 'CWE' | 'CE' | 'DT' | 'TM' | 'TS' | 'DTM' | 'SN' | 'RP' | 'ED' | string;
|
|
241
|
+
/** OBX.11 — Observation Result Status codes from HL7 v2 table 0085. */
|
|
242
|
+
type ResultStatus = 'F' | 'P' | 'C' | 'X' | 'I' | 'R' | 'S' | 'D' | 'N' | 'W' | string;
|
|
243
|
+
/** Abnormal flags from HL7 v2 table 0078. */
|
|
244
|
+
type AbnormalFlag = 'H' | 'HH' | 'L' | 'LL' | 'A' | 'AA' | 'N' | 'IND' | 'NEG' | 'POS' | string;
|
|
245
|
+
/** A coded observation identifier (LOINC, SNOMED, local). */
|
|
246
|
+
interface ObservationIdentifier {
|
|
247
|
+
/** Identifier code (e.g., LOINC code `'718-7'`). */
|
|
248
|
+
code: string;
|
|
249
|
+
/** Human-readable description (e.g., `'Hemoglobin'`). */
|
|
250
|
+
description: string;
|
|
251
|
+
/** Coding system (e.g., `'LN'` for LOINC, `'SCT'` for SNOMED CT). */
|
|
252
|
+
codingSystem: string;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Typed accessor for the OBX (Observation/Result) segment.
|
|
256
|
+
*
|
|
257
|
+
* OBX carries a single clinical observation — a lab result, vital sign,
|
|
258
|
+
* pathology finding, or any structured clinical measurement. A message
|
|
259
|
+
* typically contains multiple OBX segments, one per result.
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* import { parse, segments } from 'hl7v2';
|
|
263
|
+
* import { OBX } from 'hl7v2/segments';
|
|
264
|
+
*
|
|
265
|
+
* const msg = parse(raw);
|
|
266
|
+
* const obxs = segments(msg, 'OBX').map(s => new OBX(s, msg.encoding));
|
|
267
|
+
*
|
|
268
|
+
* for (const obx of obxs) {
|
|
269
|
+
* console.log(obx.observationIdentifier().description); // 'Hemoglobin'
|
|
270
|
+
* console.log(obx.numericValue()); // 13.5
|
|
271
|
+
* console.log(obx.units()); // 'g/dL'
|
|
272
|
+
* console.log(obx.referenceRange()); // '13.5-17.5'
|
|
273
|
+
* console.log(obx.abnormalFlags()); // ['H']
|
|
274
|
+
* console.log(obx.resultStatus()); // 'F'
|
|
275
|
+
* }
|
|
276
|
+
*/
|
|
277
|
+
declare class OBX extends TypedSegment {
|
|
278
|
+
constructor(seg: HL7Segment, enc: EncodingChars);
|
|
279
|
+
/** OBX.1 — Set ID (sequence number within the message, 1-based). */
|
|
280
|
+
setId(): number | undefined;
|
|
281
|
+
/**
|
|
282
|
+
* OBX.2 — Value Type.
|
|
283
|
+
* Indicates the data type of the observation value in OBX.5.
|
|
284
|
+
* Common values: `'NM'` (numeric), `'ST'` (string), `'CWE'` (coded).
|
|
285
|
+
*/
|
|
286
|
+
valueType(): ObservationValueType;
|
|
287
|
+
/**
|
|
288
|
+
* OBX.3 — Observation Identifier.
|
|
289
|
+
* Typically a LOINC code identifying what was measured.
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* obx.observationIdentifier()
|
|
293
|
+
* // { code: '718-7', description: 'Hemoglobin [Mass/volume] in Blood', codingSystem: 'LN' }
|
|
294
|
+
*/
|
|
295
|
+
observationIdentifier(): ObservationIdentifier;
|
|
296
|
+
/** OBX.4 — Observation Sub-ID (groups related OBX segments). */
|
|
297
|
+
observationSubId(): string;
|
|
298
|
+
/**
|
|
299
|
+
* OBX.5 — Observation Value (raw string).
|
|
300
|
+
*
|
|
301
|
+
* The interpretation depends on OBX.2 (value type).
|
|
302
|
+
* Use {@link numericValue} for `NM`, {@link codedValue} for `CWE`/`CE`.
|
|
303
|
+
*/
|
|
304
|
+
observationValue(): string;
|
|
305
|
+
/**
|
|
306
|
+
* OBX.5 — Observation value interpreted as a number.
|
|
307
|
+
* Returns `undefined` if the value type is not `NM` or the value is absent.
|
|
308
|
+
*
|
|
309
|
+
* For structured numerics (SN type like `'>10.5'`), use {@link observationValue}.
|
|
310
|
+
*/
|
|
311
|
+
numericValue(): number | undefined;
|
|
312
|
+
/**
|
|
313
|
+
* OBX.5 — Observation value as a coded element (CWE/CE value type).
|
|
314
|
+
* Returns `{ code, description, codingSystem }`.
|
|
315
|
+
*/
|
|
316
|
+
codedValue(): ObservationIdentifier;
|
|
317
|
+
/**
|
|
318
|
+
* OBX.6 — Units (CWE data type).
|
|
319
|
+
* Returns the unit code (e.g., `'g/dL'`, `'10*3/uL'`, `'mmHg'`).
|
|
320
|
+
*/
|
|
321
|
+
units(): string;
|
|
322
|
+
/**
|
|
323
|
+
* OBX.7 — References Range.
|
|
324
|
+
* The normal range as a string (e.g., `'3.5-5.0'`, `'<200'`).
|
|
325
|
+
*/
|
|
326
|
+
referenceRange(): string;
|
|
327
|
+
/**
|
|
328
|
+
* OBX.8 — Interpretation Codes (formerly Abnormal Flags).
|
|
329
|
+
* Returns all flags for this result (a field can have multiple repetitions).
|
|
330
|
+
*
|
|
331
|
+
* Common values: `'H'` high, `'L'` low, `'HH'` critical high, `'LL'` critical low,
|
|
332
|
+
* `'N'` normal, `'A'` abnormal, `'POS'` positive, `'NEG'` negative.
|
|
333
|
+
*/
|
|
334
|
+
abnormalFlags(): AbnormalFlag[];
|
|
335
|
+
/**
|
|
336
|
+
* OBX.8 — Primary interpretation code (first flag).
|
|
337
|
+
* Returns `''` if the result has no flags (i.e., it is normal / in-range).
|
|
338
|
+
*/
|
|
339
|
+
primaryAbnormalFlag(): AbnormalFlag;
|
|
340
|
+
/** OBX.11 — Observation Result Status (HL7 table 0085). */
|
|
341
|
+
resultStatus(): ResultStatus;
|
|
342
|
+
/** OBX.14 — Date/Time of Observation. */
|
|
343
|
+
observationDateTime(): Date | undefined;
|
|
344
|
+
/** OBX.15 — Producer's ID (the lab or device that produced the result). */
|
|
345
|
+
producerId(): string;
|
|
346
|
+
/** OBX.16 — Responsible Observer (clinician who verified the result). */
|
|
347
|
+
responsibleObserver(): string;
|
|
348
|
+
/** OBX.19 — Date/Time of Analysis. */
|
|
349
|
+
analysisDateTime(): Date | undefined;
|
|
350
|
+
/**
|
|
351
|
+
* Convenience: return `true` if this result has a critical abnormal flag
|
|
352
|
+
* (`'HH'` or `'LL'`).
|
|
353
|
+
*/
|
|
354
|
+
isCritical(): boolean;
|
|
355
|
+
/**
|
|
356
|
+
* Convenience: return `true` if the result is finalised (`resultStatus() === 'F'`).
|
|
357
|
+
*/
|
|
358
|
+
isFinal(): boolean;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/** Patient class codes from HL7 v2 table 0004. */
|
|
362
|
+
type PatientClass = 'E' | 'I' | 'O' | 'P' | 'R' | 'B' | 'C' | 'N' | 'U' | string;
|
|
363
|
+
/** A structured provider/clinician name and identifier. */
|
|
364
|
+
interface Provider {
|
|
365
|
+
/** Provider identifier (e.g., NPI number, employee ID). */
|
|
366
|
+
id: string;
|
|
367
|
+
/** Family (last) name. */
|
|
368
|
+
family: string;
|
|
369
|
+
/** Given (first) name. */
|
|
370
|
+
given: string;
|
|
371
|
+
/** Middle name or initial. */
|
|
372
|
+
middle: string;
|
|
373
|
+
/** Credential suffix (e.g., `'MD'`, `'DO'`, `'NP'`). */
|
|
374
|
+
credential: string;
|
|
375
|
+
}
|
|
376
|
+
/** A patient location — room, bed, facility. */
|
|
377
|
+
interface PatientLocation {
|
|
378
|
+
pointOfCare: string;
|
|
379
|
+
room: string;
|
|
380
|
+
bed: string;
|
|
381
|
+
facility: string;
|
|
382
|
+
buildingCode: string;
|
|
383
|
+
floor: string;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Typed accessor for the PV1 (Patient Visit) segment.
|
|
387
|
+
*
|
|
388
|
+
* PV1 describes the context of a patient's current or historical visit:
|
|
389
|
+
* the patient class (inpatient/outpatient), assigned location, attending
|
|
390
|
+
* and referring physicians, and admission/discharge timestamps.
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* import { parse, segment } from 'hl7v2';
|
|
394
|
+
* import { PV1 } from 'hl7v2/segments';
|
|
395
|
+
*
|
|
396
|
+
* const msg = parse(raw);
|
|
397
|
+
* const pv1 = new PV1(segment(msg, 'PV1'), msg.encoding);
|
|
398
|
+
*
|
|
399
|
+
* pv1.patientClass() // 'I' (Inpatient)
|
|
400
|
+
* pv1.assignedLocation() // { pointOfCare: 'CARDIOLOGY', room: '4A', bed: '101', ... }
|
|
401
|
+
* pv1.attendingDoctor() // { id: '1234567', family: 'Smith', given: 'Richard', ... }
|
|
402
|
+
* pv1.admitDateTime() // Date | undefined
|
|
403
|
+
*/
|
|
404
|
+
declare class PV1 extends TypedSegment {
|
|
405
|
+
constructor(seg: HL7Segment, enc: EncodingChars);
|
|
406
|
+
/** PV1.1 — Set ID. */
|
|
407
|
+
setId(): number | undefined;
|
|
408
|
+
/**
|
|
409
|
+
* PV1.2 — Patient Class (HL7 table 0004).
|
|
410
|
+
* `'I'` Inpatient · `'O'` Outpatient · `'E'` Emergency · `'P'` Preadmit
|
|
411
|
+
*/
|
|
412
|
+
patientClass(): PatientClass;
|
|
413
|
+
/**
|
|
414
|
+
* PV1.3 — Assigned Patient Location.
|
|
415
|
+
* The bed the patient is currently assigned to.
|
|
416
|
+
*/
|
|
417
|
+
assignedLocation(): PatientLocation;
|
|
418
|
+
/** PV1.4 — Admission Type (e.g., `'A'` = accident, `'E'` = emergency). */
|
|
419
|
+
admissionType(): string;
|
|
420
|
+
/**
|
|
421
|
+
* PV1.7 — Attending Doctor.
|
|
422
|
+
* The physician primarily responsible for the patient's care.
|
|
423
|
+
*/
|
|
424
|
+
attendingDoctor(): Provider;
|
|
425
|
+
/**
|
|
426
|
+
* PV1.8 — Referring Doctor.
|
|
427
|
+
* The physician who referred the patient.
|
|
428
|
+
*/
|
|
429
|
+
referringDoctor(): Provider;
|
|
430
|
+
/**
|
|
431
|
+
* PV1.9 — Consulting Doctor.
|
|
432
|
+
* Returns all consulting doctors (field can repeat).
|
|
433
|
+
*/
|
|
434
|
+
consultingDoctors(): Provider[];
|
|
435
|
+
/** PV1.10 — Hospital Service (e.g., `'MED'`, `'SUR'`, `'CAR'`). */
|
|
436
|
+
hospitalService(): string;
|
|
437
|
+
/** PV1.14 — Admit Source (HL7 table 0023). */
|
|
438
|
+
admitSource(): string;
|
|
439
|
+
/** PV1.18 — Patient Type. */
|
|
440
|
+
patientType(): string;
|
|
441
|
+
/** PV1.19 — Visit Number (account number for this specific visit). */
|
|
442
|
+
visitNumber(): string;
|
|
443
|
+
/** PV1.36 — Discharge Disposition (HL7 table 0112). */
|
|
444
|
+
dischargeDisposition(): string;
|
|
445
|
+
/**
|
|
446
|
+
* PV1.44 — Admit Date/Time.
|
|
447
|
+
* When the patient was admitted to this care setting.
|
|
448
|
+
*/
|
|
449
|
+
admitDateTime(): Date | undefined;
|
|
450
|
+
/**
|
|
451
|
+
* PV1.45 — Discharge Date/Time.
|
|
452
|
+
* `undefined` if the patient has not yet been discharged.
|
|
453
|
+
*/
|
|
454
|
+
dischargeDateTime(): Date | undefined;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
export { type AbnormalFlag, type Address, type AdministrativeSex, MSH, OBX, type ObservationIdentifier, type ObservationValueType, PID, PV1, type PatientClass, type PatientIdentifier, type PatientLocation, type PersonName, type ProcessingId, type Provider, type ResultStatus, TypedSegment };
|