hl7-tstd 0.2.0 → 0.3.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/dist/index.cjs ADDED
@@ -0,0 +1,420 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ default: () => index_default
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+ var Node = class {
27
+ constructor(data, next = null, prev = null) {
28
+ this.data = data;
29
+ this.next = next;
30
+ this.prev = prev;
31
+ }
32
+ };
33
+ var Segment = class {
34
+ constructor(type, data = null, parseOptions) {
35
+ this.type = type;
36
+ this.data = data;
37
+ var _a, _b, _c, _d;
38
+ this.parseOptions = {
39
+ fieldDelim: (_a = parseOptions == null ? void 0 : parseOptions.fieldDelim) != null ? _a : "|",
40
+ repeatingDelim: (_b = parseOptions == null ? void 0 : parseOptions.repeatingDelim) != null ? _b : "~",
41
+ componentDelim: (_c = parseOptions == null ? void 0 : parseOptions.componentDelim) != null ? _c : "^",
42
+ subCompDelim: (_d = parseOptions == null ? void 0 : parseOptions.subCompDelim) != null ? _d : "&"
43
+ };
44
+ }
45
+ get(field, repeatingIndex = 0, subComponentIndex = 0) {
46
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
47
+ if (!this.data) return null;
48
+ if (!field || !/^[A-Z\d]{3}(\.\d+){0,2}$/.test(field))
49
+ throw new Error(`Invalid parameter: 'field' [${field}]`);
50
+ if (typeof repeatingIndex !== "number" || repeatingIndex < -1)
51
+ throw new Error(`Invalid parameter: 'repeatingIndex' [${repeatingIndex}]`);
52
+ if (typeof subComponentIndex !== "number" || subComponentIndex < -1)
53
+ throw new Error(`Invalid parameter: 'subComponentIndex' [${subComponentIndex}]`);
54
+ const { fieldDelim, repeatingDelim, componentDelim, subCompDelim } = this.parseOptions;
55
+ const [type, fieldIdx, compIdx] = field.split(".");
56
+ if (!type || type !== this.type)
57
+ throw new Error(
58
+ `Invalid parameter: 'field' [${field}]. Cannot get [${field}] from [${this.type}] segment.`
59
+ );
60
+ if (fieldIdx && compIdx) {
61
+ if (subComponentIndex === -1) {
62
+ return (_d = (_c = (_b = (_a = this.data[`${type}.${fieldIdx}`]) == null ? void 0 : _a[repeatingIndex]) == null ? void 0 : _b[`${type}.${fieldIdx}.${compIdx}`]) == null ? void 0 : _c.join(subCompDelim)) != null ? _d : null;
63
+ } else {
64
+ return (_h = (_g = (_f = (_e = this.data[`${type}.${fieldIdx}`]) == null ? void 0 : _e[repeatingIndex]) == null ? void 0 : _f[`${type}.${fieldIdx}.${compIdx}`]) == null ? void 0 : _g[subComponentIndex]) != null ? _h : null;
65
+ }
66
+ } else if (fieldIdx) {
67
+ let field2 = repeatingIndex === -1 ? this.data[`${type}.${fieldIdx}`] : [(_i = this.data[`${type}.${fieldIdx}`]) == null ? void 0 : _i[repeatingIndex]];
68
+ const repeatingFieldsArr = [];
69
+ if (!field2 || !field2[0]) return null;
70
+ for (const repeatingField of field2) {
71
+ const componentsArr = [];
72
+ for (const compKey in repeatingField) {
73
+ componentsArr.push(repeatingField[compKey].join(subCompDelim));
74
+ }
75
+ repeatingFieldsArr.push(componentsArr.join(componentDelim));
76
+ }
77
+ return repeatingFieldsArr.join(repeatingDelim);
78
+ } else {
79
+ if (!this.data) return null;
80
+ const fieldsArr = [this.type];
81
+ for (const fieldKey in this.data) {
82
+ const repeatingCompsArr = [];
83
+ for (const repeatingField of this.data[fieldKey]) {
84
+ const compsArr = [];
85
+ for (const compKey in repeatingField) {
86
+ compsArr.push((_j = repeatingField[compKey]) == null ? void 0 : _j.join(subCompDelim));
87
+ }
88
+ repeatingCompsArr.push(compsArr.join(componentDelim));
89
+ }
90
+ fieldsArr.push(repeatingCompsArr.join(repeatingDelim));
91
+ }
92
+ return fieldsArr.join(fieldDelim);
93
+ }
94
+ }
95
+ set(field, value, repeatingIndex = 0, subComponentIndex = 0) {
96
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
97
+ if (!field || !/^[A-Z\d]{3}(\.\d+){1,2}$/.test(field))
98
+ throw new Error(`Invalid parameter: 'field' [${field}]`);
99
+ if (!value || typeof value !== "string")
100
+ throw new Error(`Invalid parameter: 'value' [${value}]`);
101
+ if (typeof repeatingIndex !== "number" && repeatingIndex < 0)
102
+ throw new Error(`Invalid parameter: 'repeatingIndex' [${repeatingIndex}]`);
103
+ if (typeof subComponentIndex !== "number" && subComponentIndex < 0)
104
+ throw new Error(`Invalid parameter: 'subComponentIndex' [${subComponentIndex}]`);
105
+ const [type, fieldIdx, compIdx] = field.split(".");
106
+ if (!type || type !== this.type)
107
+ throw new Error(
108
+ `Invalid parameter: 'field' [${field}]. Cannot set [${field}] from [${this.type}] segment.`
109
+ );
110
+ if (!fieldIdx) throw new Error(`Invalid parameter: 'field' [${field}]`);
111
+ if (!this.data) this.data = {};
112
+ for (let i = type === "MSH" ? 2 : 1; i <= parseInt(fieldIdx, 10); i++) {
113
+ if (((_b = (_a = this.data[`${type}.${i}`]) == null ? void 0 : _a[0]) == null ? void 0 : _b[`${type}.${i}.${1}`]) == null)
114
+ this.data[`${type}.${i}`] = [{ [`${type}.${i}.${1}`]: [""] }];
115
+ }
116
+ for (let i = 0; i <= repeatingIndex; i++) {
117
+ if (((_d = (_c = this.data[`${type}.${fieldIdx}`]) == null ? void 0 : _c[i]) == null ? void 0 : _d[`${type}.${fieldIdx}.${1}`]) == null)
118
+ this.data[`${type}.${fieldIdx}`][i] = { [`${type}.${fieldIdx}.${1}`]: [""] };
119
+ }
120
+ if (compIdx) {
121
+ for (let i = 1; i <= parseInt(compIdx, 10); i++) {
122
+ if (((_f = (_e = this.data[`${type}.${fieldIdx}`]) == null ? void 0 : _e[repeatingIndex]) == null ? void 0 : _f[`${type}.${fieldIdx}.${i}`]) == null)
123
+ this.data[`${type}.${fieldIdx}`][repeatingIndex][`${type}.${fieldIdx}.${i}`] = [""];
124
+ }
125
+ for (let i = 0; i <= subComponentIndex; i++) {
126
+ if (((_i = (_h = (_g = this.data[`${type}.${fieldIdx}`]) == null ? void 0 : _g[repeatingIndex]) == null ? void 0 : _h[`${type}.${fieldIdx}.${compIdx}`]) == null ? void 0 : _i[i]) == null)
127
+ this.data[`${type}.${fieldIdx}`][repeatingIndex][`${type}.${fieldIdx}.${compIdx}`][i] = "";
128
+ }
129
+ this.data[`${type}.${fieldIdx}`][repeatingIndex][`${type}.${fieldIdx}.${compIdx}`][subComponentIndex] = value;
130
+ } else {
131
+ this.data[`${type}.${fieldIdx}`][repeatingIndex] = {
132
+ [`${type}.${fieldIdx}.${1}`]: [value]
133
+ };
134
+ }
135
+ }
136
+ };
137
+ var HL7 = class {
138
+ constructor(hl7Msg, parseOptions) {
139
+ this.head = null;
140
+ this.tail = null;
141
+ var _a, _b, _c, _d, _e, _f;
142
+ this.raw = typeof hl7Msg === "string" ? hl7Msg : "";
143
+ this.parseOptions = {
144
+ fieldDelim: (_a = parseOptions == null ? void 0 : parseOptions.fieldDelim) != null ? _a : "|",
145
+ repeatingDelim: (_b = parseOptions == null ? void 0 : parseOptions.repeatingDelim) != null ? _b : "~",
146
+ componentDelim: (_c = parseOptions == null ? void 0 : parseOptions.componentDelim) != null ? _c : "^",
147
+ subCompDelim: (_d = parseOptions == null ? void 0 : parseOptions.subCompDelim) != null ? _d : "&",
148
+ eolDelim: (_e = parseOptions == null ? void 0 : parseOptions.eolDelim) != null ? _e : "\r?\n|\r",
149
+ buildEolChar: (_f = parseOptions == null ? void 0 : parseOptions.buildEolChar) != null ? _f : "\r\n"
150
+ };
151
+ this.transform();
152
+ }
153
+ /**
154
+ * @deprecated This method is triggered internally and doesnt need to be invoked manually.
155
+ */
156
+ transform() {
157
+ if (!this.raw.startsWith("MSH")) {
158
+ throw new Error(
159
+ "Expected raw msg to be HL7 message. Message does not start with MSH segment."
160
+ );
161
+ }
162
+ const segmentsStr = this.raw.split(RegExp(this.parseOptions.eolDelim)).filter((segmentStr) => /^[A-Z\d]{3}\|/.test(segmentStr));
163
+ const { fieldDelim, repeatingDelim, componentDelim, subCompDelim } = this.parseOptions;
164
+ for (const segmentStr of segmentsStr) {
165
+ const type = segmentStr.substring(0, 3);
166
+ const segment = new Segment(type, null, this.parseOptions);
167
+ const fields = segmentStr.split(fieldDelim);
168
+ segment.data = {};
169
+ for (let i = 1; i < fields.length; i++) {
170
+ const fieldIdx = type === "MSH" ? i + 1 : i;
171
+ const repeatingComps = fields[i].split(repeatingDelim);
172
+ segment.data[`${type}.${fieldIdx}`] = [];
173
+ for (let j = 0; j < repeatingComps.length; j++) {
174
+ const components = repeatingComps[j].split(componentDelim);
175
+ segment.data[`${type}.${fieldIdx}`][j] = {};
176
+ for (let k = 0; k < components.length; k++) {
177
+ const subComps = components[k].split(subCompDelim);
178
+ segment.data[`${type}.${fieldIdx}`][j][`${type}.${fieldIdx}.${k + 1}`] = [];
179
+ for (let l = 0; l < subComps.length; l++) {
180
+ segment.data[`${type}.${fieldIdx}`][j][`${type}.${fieldIdx}.${k + 1}`][l] = subComps[l];
181
+ }
182
+ }
183
+ }
184
+ }
185
+ if (type === "MSH") {
186
+ segment.data["MSH.2"] = [
187
+ { "MSH.2.1": [`${componentDelim}${repeatingDelim}\\${subCompDelim}`] }
188
+ ];
189
+ }
190
+ this.appendSegmentNode(segment);
191
+ }
192
+ }
193
+ build() {
194
+ var _a;
195
+ const segments = this.getSegments();
196
+ const { fieldDelim, repeatingDelim, componentDelim, subCompDelim, buildEolChar } = this.parseOptions;
197
+ const segmentsStrArr = [];
198
+ for (const segment of segments) {
199
+ const fieldsArr = [segment.type];
200
+ for (const fieldKey in segment.data) {
201
+ const repeatingCompsArr = [];
202
+ for (const component of segment.data[fieldKey]) {
203
+ const compsArr = [];
204
+ for (const subCompsKey in component) {
205
+ compsArr.push((_a = component[subCompsKey]) == null ? void 0 : _a.join(subCompDelim));
206
+ }
207
+ repeatingCompsArr.push(compsArr.join(componentDelim));
208
+ }
209
+ fieldsArr.push(repeatingCompsArr.join(repeatingDelim));
210
+ }
211
+ segmentsStrArr.push(fieldsArr.join(fieldDelim));
212
+ }
213
+ return segmentsStrArr.join(buildEolChar);
214
+ }
215
+ getSegment(type) {
216
+ if (!/^[A-Z\d]{3}$/.test(type)) throw new Error(`Invalid parameter: 'type' [${type}]`);
217
+ let curr = this.head;
218
+ while (curr) {
219
+ if (curr.data.type === type) return curr.data;
220
+ curr = curr.next;
221
+ }
222
+ return curr;
223
+ }
224
+ getSegments(type) {
225
+ if (type && !/^[A-Z\d]{3}$/.test(type)) throw new Error(`Invalid parameter: 'type' [${type}]`);
226
+ const segments = [];
227
+ let curr = this.head;
228
+ while (curr) {
229
+ if (type) {
230
+ if (type === curr.data.type) segments.push(curr.data);
231
+ } else {
232
+ segments.push(curr.data);
233
+ }
234
+ curr = curr.next;
235
+ }
236
+ return segments;
237
+ }
238
+ getSegmentsAfter(startSegment, type, stopSegmentType = [], consecutive = false) {
239
+ if (!startSegment || !(startSegment instanceof Segment))
240
+ throw new Error(`Invalid parameter: 'startSegment'`);
241
+ if (!/^[A-Z\d]{3}$/.test(type)) throw new Error(`Invalid parameter: 'type' [${type}]`);
242
+ if (!stopSegmentType || !Array.isArray(stopSegmentType))
243
+ throw new Error(`Invalid parameter: 'stopSegmentType'`);
244
+ if (typeof consecutive !== "boolean")
245
+ throw new Error(`Invalid parameter: 'consecutive' [${consecutive}]`);
246
+ const startNode = this.getNode(startSegment);
247
+ if (!startNode) throw new Error(`Failed to locate: 'startSegment' [${startSegment.type}]`);
248
+ const res = [];
249
+ let curr = startNode.next;
250
+ while (curr) {
251
+ if (stopSegmentType.length && stopSegmentType.includes(curr.data.type)) break;
252
+ if (curr.data.type === type) res.push(curr.data);
253
+ else if (consecutive && res.length) break;
254
+ curr = curr.next;
255
+ }
256
+ return res;
257
+ }
258
+ createSegment(type) {
259
+ if (!/^[A-Z\d]{3}$/.test(type)) throw new Error(`Invalid parameter: 'type' [${type}]`);
260
+ return this.appendSegmentNode(new Segment(type, null, this.parseOptions));
261
+ }
262
+ createSegmentAfter(type, targetSegment) {
263
+ if (!/^[A-Z\d]{3}$/.test(type)) throw new Error(`Invalid parameter: 'type' [${type}]`);
264
+ if (!targetSegment || !(targetSegment instanceof Segment))
265
+ throw new Error(`Invalid parameter: 'targetSegment'`);
266
+ return this.appendSegmentNode(new Segment(type, null, this.parseOptions), targetSegment);
267
+ }
268
+ createSegmentBefore(type, targetSegment) {
269
+ if (!/^[A-Z\d]{3}$/.test(type)) throw new Error(`Invalid parameter: 'type' [${type}]`);
270
+ if (!targetSegment || !(targetSegment instanceof Segment))
271
+ throw new Error(`Invalid parameter: 'targetSegment'`);
272
+ return this.prependSegmentNode(new Segment(type, null, this.parseOptions), targetSegment);
273
+ }
274
+ deleteSegment(segment) {
275
+ if (!segment || !(segment instanceof Segment)) throw new Error(`Invalid parameter: 'segment'`);
276
+ this.deleteSegments([segment]);
277
+ }
278
+ deleteSegments(segments) {
279
+ var _a, _b;
280
+ for (const segment of segments) {
281
+ if (!segment || !(segment instanceof Segment))
282
+ throw new Error(`Invalid parameter: 'segments'`);
283
+ }
284
+ for (const segment of segments) {
285
+ const node = this.getNode(segment);
286
+ if (!node) break;
287
+ if ((_a = node.prev) == null ? void 0 : _a.next) node.prev.next = node.next;
288
+ if ((_b = node.next) == null ? void 0 : _b.prev) node.next.prev = node.prev;
289
+ if (this.head === node) this.head = this.head.next;
290
+ if (this.tail === node) this.tail = this.tail.prev;
291
+ node.next = null;
292
+ node.prev = null;
293
+ }
294
+ }
295
+ moveSegmentAfter(segment, targetSegment) {
296
+ var _a, _b, _c;
297
+ if (!segment || !(segment instanceof Segment)) throw new Error(`Invalid parameter: 'segment'`);
298
+ if (!targetSegment || !(targetSegment instanceof Segment))
299
+ throw new Error(`Invalid parameter: 'targetSegment'`);
300
+ if (segment === targetSegment) return;
301
+ const node = this.getNode(segment);
302
+ if (!node) throw new Error(`Failed to locate: 'segment' [${segment.type}]`);
303
+ const targetNode = this.getNode(targetSegment);
304
+ if (!targetNode) throw new Error(`Failed to locate: 'targetSegment' [${targetSegment.type}]`);
305
+ if (node === this.head) this.head = this.head.next;
306
+ if ((_a = node.prev) == null ? void 0 : _a.next) node.prev.next = node.next;
307
+ if ((_b = node.next) == null ? void 0 : _b.prev) node.next.prev = node.prev;
308
+ node.next = targetNode.next;
309
+ node.prev = targetNode;
310
+ targetNode.next = node;
311
+ if ((_c = node.next) == null ? void 0 : _c.prev) node.next.prev = node;
312
+ if (targetNode === this.tail) this.tail = this.tail.next;
313
+ }
314
+ moveSegmentBefore(segment, targetSegment) {
315
+ var _a, _b, _c;
316
+ if (!segment || !(segment instanceof Segment)) throw new Error(`Invalid parameter: 'segment'`);
317
+ if (!targetSegment || !(targetSegment instanceof Segment))
318
+ throw new Error(`Invalid parameter: 'targetSegment'`);
319
+ if (segment === targetSegment) return;
320
+ const node = this.getNode(segment);
321
+ if (!node) throw new Error(`Failed to locate: 'segment' [${segment.type}]`);
322
+ const targetNode = this.getNode(targetSegment);
323
+ if (!targetNode) throw new Error(`Failed to locate: 'targetSegment' [${targetSegment.type}]`);
324
+ if (node === this.tail) this.tail = this.tail.prev;
325
+ if ((_a = node.prev) == null ? void 0 : _a.next) node.prev.next = node.next;
326
+ if ((_b = node.next) == null ? void 0 : _b.prev) node.next.prev = node.prev;
327
+ node.next = targetNode;
328
+ node.prev = targetNode.prev;
329
+ targetNode.prev = node;
330
+ if ((_c = node.prev) == null ? void 0 : _c.next) node.prev.next = node;
331
+ if (targetNode === this.head) this.head = this.head.prev;
332
+ }
333
+ reindexSegments(resetRules, startIndex = 1, field = "1.1") {
334
+ if (!resetRules || typeof resetRules !== "object")
335
+ throw new Error(`Invalid parameter: 'resetRules'`);
336
+ if (!startIndex || typeof startIndex !== "number")
337
+ throw new Error(`Invalid parameter: 'startIndex' [${startIndex}]`);
338
+ if (field && !/^(\d+)(\.\d+){0,1}$/.test(field))
339
+ throw new Error(`Invalid parameter: 'field' [${field}]`);
340
+ let curr = this.head;
341
+ const indexMap = {};
342
+ for (const key of Object.keys(resetRules)) {
343
+ if (!Array.isArray(resetRules[key]))
344
+ throw new Error(
345
+ `Invalid parameter: 'resetRules'. Expected key [${key}] value to be an array.`
346
+ );
347
+ indexMap[key] = startIndex;
348
+ }
349
+ while (curr) {
350
+ const segment = curr.data;
351
+ if (segment.type in resetRules)
352
+ segment.set(`${segment.type}.${field}`, String(indexMap[segment.type]++));
353
+ for (const [segmentType, resetTriggers] of Object.entries(resetRules)) {
354
+ for (const resetTrigger of resetTriggers) {
355
+ if (segment.type === resetTrigger) {
356
+ indexMap[segmentType] = startIndex;
357
+ break;
358
+ }
359
+ }
360
+ }
361
+ curr = curr.next;
362
+ }
363
+ }
364
+ getNode(segment) {
365
+ if (!segment || !(segment instanceof Segment)) {
366
+ throw new Error(`Invalid parameter: 'segment'`);
367
+ }
368
+ let curr = this.head;
369
+ while (curr) {
370
+ if (curr.data === segment) return curr;
371
+ curr = curr.next;
372
+ }
373
+ return curr;
374
+ }
375
+ appendSegmentNode(newSegment, targetSegment) {
376
+ var _a;
377
+ if (!newSegment || !(newSegment instanceof Segment))
378
+ throw new Error(`Invalid parameter: 'newSegment'`);
379
+ if (targetSegment && !(targetSegment instanceof Segment))
380
+ throw new Error(`Invalid parameter: 'targetSegment'`);
381
+ const newNode = new Node(newSegment);
382
+ if (targetSegment) {
383
+ const targetNode = this.getNode(targetSegment);
384
+ if (!targetNode) throw new Error(`Failed to locate: 'targetSegment' [${targetSegment.type}]`);
385
+ newNode.next = targetNode.next;
386
+ newNode.prev = targetNode;
387
+ targetNode.next = newNode;
388
+ if ((_a = newNode.next) == null ? void 0 : _a.prev) newNode.next.prev = newNode;
389
+ if (targetNode === this.tail) this.tail = this.tail.next;
390
+ } else if (!this.head) {
391
+ this.head = newNode;
392
+ this.tail = newNode;
393
+ } else if (this.tail) {
394
+ newNode.prev = this.tail;
395
+ this.tail.next = newNode;
396
+ this.tail = this.tail.next;
397
+ } else {
398
+ throw new Error(`Failed to append segment: ${newSegment.type}`);
399
+ }
400
+ return newSegment;
401
+ }
402
+ prependSegmentNode(newSegment, targetSegment) {
403
+ var _a;
404
+ if (!newSegment || !(newSegment instanceof Segment))
405
+ throw new Error(`Invalid parameter: 'newSegment'`);
406
+ if (!targetSegment || !(targetSegment instanceof Segment))
407
+ throw new Error(`Invalid parameter: 'targetSegment'`);
408
+ const targetNode = this.getNode(targetSegment);
409
+ if (!targetNode) throw new Error(`Failed to locate: 'targetSegment' [${targetSegment.type}]`);
410
+ const newNode = new Node(newSegment);
411
+ newNode.next = targetNode;
412
+ newNode.prev = targetNode.prev;
413
+ targetNode.prev = newNode;
414
+ if ((_a = newNode.prev) == null ? void 0 : _a.next) newNode.prev.next = newNode;
415
+ if (targetNode === this.head) this.head = this.head.prev;
416
+ return newSegment;
417
+ }
418
+ };
419
+ var index_default = HL7;
420
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["type Prettify<T> = {\n [K in keyof T]: T[K];\n} & {};\n\ntype TSegmentType =\n | 'DG1'\n | 'EVN'\n | 'GT1'\n | 'IN1'\n | 'MSH'\n | 'NK1'\n | 'NTE'\n | 'OBR'\n | 'OBX'\n | 'ORC'\n | 'PID'\n | 'PR1'\n | 'PV1'\n | 'PV2'\n | (string & {});\n\ntype TSegmentData = Record<string, Array<Record<string, Array<string>>>>;\n\ntype TParseOptions = {\n fieldDelim: string;\n repeatingDelim: string;\n componentDelim: string;\n subCompDelim: string;\n eolDelim: '\\r?\\n|\\r' | '\\r\\n' | '\\n' | '\\r';\n buildEolChar: '\\r\\n' | '\\n' | '\\r';\n};\n\nclass Node<T> {\n constructor(\n public readonly data: T,\n public next: Node<T> | null = null,\n public prev: Node<T> | null = null\n ) {}\n}\n\nclass Segment {\n private parseOptions: Prettify<Omit<TParseOptions, 'eolDelim' | 'buildEolChar'>>;\n\n constructor(\n public readonly type: TSegmentType,\n public data: TSegmentData | null = null,\n parseOptions?: Prettify<Omit<TParseOptions, 'eolDelim' | 'buildEolChar'>>\n ) {\n this.parseOptions = {\n fieldDelim: parseOptions?.fieldDelim ?? '|',\n repeatingDelim: parseOptions?.repeatingDelim ?? '~',\n componentDelim: parseOptions?.componentDelim ?? '^',\n subCompDelim: parseOptions?.subCompDelim ?? '&',\n };\n }\n\n get(field: string, repeatingIndex = 0, subComponentIndex = 0) {\n if (!this.data) return null;\n\n if (!field || !/^[A-Z\\d]{3}(\\.\\d+){0,2}$/.test(field))\n throw new Error(`Invalid parameter: 'field' [${field}]`);\n if (typeof repeatingIndex !== 'number' || repeatingIndex < -1)\n throw new Error(`Invalid parameter: 'repeatingIndex' [${repeatingIndex}]`);\n if (typeof subComponentIndex !== 'number' || subComponentIndex < -1)\n throw new Error(`Invalid parameter: 'subComponentIndex' [${subComponentIndex}]`);\n\n const { fieldDelim, repeatingDelim, componentDelim, subCompDelim } = this.parseOptions;\n const [type, fieldIdx, compIdx] = field.split('.');\n\n if (!type || type !== this.type)\n throw new Error(\n `Invalid parameter: 'field' [${field}]. Cannot get [${field}] from [${this.type}] segment.`\n );\n\n if (fieldIdx && compIdx) {\n if (subComponentIndex === -1) {\n return (\n this.data[`${type}.${fieldIdx}`]?.[repeatingIndex]?.[\n `${type}.${fieldIdx}.${compIdx}`\n ]?.join(subCompDelim) ?? null\n );\n } else {\n return (\n this.data[`${type}.${fieldIdx}`]?.[repeatingIndex]?.[`${type}.${fieldIdx}.${compIdx}`]?.[\n subComponentIndex\n ] ?? null\n );\n }\n } else if (fieldIdx) {\n let field =\n repeatingIndex === -1\n ? this.data[`${type}.${fieldIdx}`]\n : [this.data[`${type}.${fieldIdx}`]?.[repeatingIndex]];\n const repeatingFieldsArr: string[] = [];\n\n if (!field || !field[0]) return null;\n\n for (const repeatingField of field) {\n const componentsArr: string[] = [];\n\n for (const compKey in repeatingField) {\n componentsArr.push(repeatingField[compKey]!.join(subCompDelim));\n }\n\n repeatingFieldsArr.push(componentsArr.join(componentDelim));\n }\n\n return repeatingFieldsArr.join(repeatingDelim);\n } else {\n if (!this.data) return null;\n\n const fieldsArr = [this.type];\n\n for (const fieldKey in this.data) {\n const repeatingCompsArr = [];\n\n for (const repeatingField of this.data[fieldKey]!) {\n const compsArr = [];\n\n for (const compKey in repeatingField) {\n compsArr.push(repeatingField[compKey]?.join(subCompDelim));\n }\n\n repeatingCompsArr.push(compsArr.join(componentDelim));\n }\n\n fieldsArr.push(repeatingCompsArr.join(repeatingDelim));\n }\n\n return fieldsArr.join(fieldDelim);\n }\n }\n\n set(field: string, value: string, repeatingIndex = 0, subComponentIndex = 0) {\n if (!field || !/^[A-Z\\d]{3}(\\.\\d+){1,2}$/.test(field))\n throw new Error(`Invalid parameter: 'field' [${field}]`);\n if (!value || typeof value !== 'string')\n throw new Error(`Invalid parameter: 'value' [${value}]`);\n if (typeof repeatingIndex !== 'number' && repeatingIndex < 0)\n throw new Error(`Invalid parameter: 'repeatingIndex' [${repeatingIndex}]`);\n if (typeof subComponentIndex !== 'number' && subComponentIndex < 0)\n throw new Error(`Invalid parameter: 'subComponentIndex' [${subComponentIndex}]`);\n\n const [type, fieldIdx, compIdx] = field.split('.');\n\n if (!type || type !== this.type)\n throw new Error(\n `Invalid parameter: 'field' [${field}]. Cannot set [${field}] from [${this.type}] segment.`\n );\n\n if (!fieldIdx) throw new Error(`Invalid parameter: 'field' [${field}]`);\n\n if (!this.data) this.data = {};\n\n for (let i = type === 'MSH' ? 2 : 1; i <= parseInt(fieldIdx, 10); i++) {\n if (this.data[`${type}.${i}`]?.[0]?.[`${type}.${i}.${1}`] == null)\n this.data[`${type}.${i}`] = [{ [`${type}.${i}.${1}`]: [''] }];\n }\n\n for (let i = 0; i <= repeatingIndex; i++) {\n if (this.data[`${type}.${fieldIdx}`]?.[i]?.[`${type}.${fieldIdx}.${1}`] == null)\n this.data[`${type}.${fieldIdx}`]![i] = { [`${type}.${fieldIdx}.${1}`]: [''] };\n }\n\n if (compIdx) {\n for (let i = 1; i <= parseInt(compIdx, 10); i++) {\n if (\n this.data[`${type}.${fieldIdx}`]?.[repeatingIndex]?.[`${type}.${fieldIdx}.${i}`] == null\n )\n this.data[`${type}.${fieldIdx}`]![repeatingIndex]![`${type}.${fieldIdx}.${i}`] = [''];\n }\n\n for (let i = 0; i <= subComponentIndex; i++) {\n if (\n this.data[`${type}.${fieldIdx}`]?.[repeatingIndex]?.[`${type}.${fieldIdx}.${compIdx}`]?.[\n i\n ] == null\n )\n this.data[`${type}.${fieldIdx}`]![repeatingIndex]![`${type}.${fieldIdx}.${compIdx}`]![i] =\n '';\n }\n\n this.data[`${type}.${fieldIdx}`]![repeatingIndex]![`${type}.${fieldIdx}.${compIdx}`]![\n subComponentIndex\n ] = value;\n } else {\n this.data[`${type}.${fieldIdx}`]![repeatingIndex] = {\n [`${type}.${fieldIdx}.${1}`]: [value],\n };\n }\n }\n}\n\nclass HL7 {\n raw: string;\n parseOptions: TParseOptions;\n private head: Node<Segment> | null = null;\n private tail: Node<Segment> | null = null;\n\n constructor(hl7Msg: string, parseOptions?: Prettify<Partial<TParseOptions>>) {\n this.raw = typeof hl7Msg === 'string' ? hl7Msg : '';\n this.parseOptions = {\n fieldDelim: parseOptions?.fieldDelim ?? '|',\n repeatingDelim: parseOptions?.repeatingDelim ?? '~',\n componentDelim: parseOptions?.componentDelim ?? '^',\n subCompDelim: parseOptions?.subCompDelim ?? '&',\n eolDelim: parseOptions?.eolDelim ?? '\\r?\\n|\\r',\n buildEolChar: parseOptions?.buildEolChar ?? '\\r\\n',\n };\n\n this.transform();\n }\n\n /**\n * @deprecated This method is triggered internally and doesnt need to be invoked manually.\n */\n transform() {\n if (!this.raw.startsWith('MSH')) {\n throw new Error(\n 'Expected raw msg to be HL7 message. Message does not start with MSH segment.'\n );\n }\n\n const segmentsStr = this.raw\n .split(RegExp(this.parseOptions.eolDelim))\n .filter((segmentStr) => /^[A-Z\\d]{3}\\|/.test(segmentStr));\n\n const { fieldDelim, repeatingDelim, componentDelim, subCompDelim } = this.parseOptions;\n\n for (const segmentStr of segmentsStr) {\n const type = segmentStr.substring(0, 3);\n const segment = new Segment(type, null, this.parseOptions);\n const fields = segmentStr.split(fieldDelim);\n segment.data = {};\n\n for (let i = 1; i < fields.length; i++) {\n const fieldIdx = type === 'MSH' ? i + 1 : i;\n const repeatingComps = fields[i]!.split(repeatingDelim);\n segment.data[`${type}.${fieldIdx}`] = [];\n\n for (let j = 0; j < repeatingComps.length; j++) {\n const components = repeatingComps[j]!.split(componentDelim);\n segment.data[`${type}.${fieldIdx}`]![j] = {};\n\n for (let k = 0; k < components.length; k++) {\n const subComps = components[k]!.split(subCompDelim);\n segment.data[`${type}.${fieldIdx}`]![j]![`${type}.${fieldIdx}.${k + 1}`] = [];\n\n for (let l = 0; l < subComps.length; l++) {\n segment.data[`${type}.${fieldIdx}`]![j]![`${type}.${fieldIdx}.${k + 1}`]![l] =\n subComps[l]!;\n }\n }\n }\n }\n\n if (type === 'MSH') {\n segment.data['MSH.2'] = [\n { 'MSH.2.1': [`${componentDelim}${repeatingDelim}\\\\${subCompDelim}`] },\n ];\n }\n\n this.appendSegmentNode(segment);\n }\n }\n\n build() {\n const segments = this.getSegments();\n const { fieldDelim, repeatingDelim, componentDelim, subCompDelim, buildEolChar } =\n this.parseOptions;\n const segmentsStrArr = [];\n\n for (const segment of segments) {\n const fieldsArr = [segment.type];\n\n for (const fieldKey in segment.data) {\n const repeatingCompsArr = [];\n\n for (const component of segment.data[fieldKey]!) {\n const compsArr = [];\n\n for (const subCompsKey in component) {\n compsArr.push(component[subCompsKey]?.join(subCompDelim));\n }\n\n repeatingCompsArr.push(compsArr.join(componentDelim));\n }\n\n fieldsArr.push(repeatingCompsArr.join(repeatingDelim));\n }\n\n segmentsStrArr.push(fieldsArr.join(fieldDelim));\n }\n\n return segmentsStrArr.join(buildEolChar);\n }\n\n getSegment(type: TSegmentType) {\n if (!/^[A-Z\\d]{3}$/.test(type)) throw new Error(`Invalid parameter: 'type' [${type}]`);\n\n let curr = this.head;\n\n while (curr) {\n if (curr.data.type === type) return curr.data;\n\n curr = curr.next;\n }\n\n return curr;\n }\n\n getSegments(type?: TSegmentType) {\n if (type && !/^[A-Z\\d]{3}$/.test(type)) throw new Error(`Invalid parameter: 'type' [${type}]`);\n\n const segments = [];\n let curr = this.head;\n\n while (curr) {\n if (type) {\n if (type === curr.data.type) segments.push(curr.data);\n } else {\n segments.push(curr.data);\n }\n\n curr = curr.next;\n }\n\n return segments;\n }\n\n getSegmentsAfter(\n startSegment: Segment,\n type: TSegmentType,\n stopSegmentType: TSegmentType[] = [],\n consecutive = false\n ) {\n if (!startSegment || !(startSegment instanceof Segment))\n throw new Error(`Invalid parameter: 'startSegment'`);\n if (!/^[A-Z\\d]{3}$/.test(type)) throw new Error(`Invalid parameter: 'type' [${type}]`);\n if (!stopSegmentType || !Array.isArray(stopSegmentType))\n throw new Error(`Invalid parameter: 'stopSegmentType'`);\n if (typeof consecutive !== 'boolean')\n throw new Error(`Invalid parameter: 'consecutive' [${consecutive}]`);\n\n const startNode = this.getNode(startSegment);\n\n if (!startNode) throw new Error(`Failed to locate: 'startSegment' [${startSegment.type}]`);\n\n const res = [];\n let curr = startNode.next;\n\n while (curr) {\n if (stopSegmentType.length && stopSegmentType.includes(curr.data.type)) break;\n\n if (curr.data.type === type) res.push(curr.data);\n else if (consecutive && res.length) break;\n\n curr = curr.next;\n }\n\n return res;\n }\n\n createSegment(type: TSegmentType) {\n if (!/^[A-Z\\d]{3}$/.test(type)) throw new Error(`Invalid parameter: 'type' [${type}]`);\n\n return this.appendSegmentNode(new Segment(type, null, this.parseOptions));\n }\n\n createSegmentAfter(type: TSegmentType, targetSegment: Segment) {\n if (!/^[A-Z\\d]{3}$/.test(type)) throw new Error(`Invalid parameter: 'type' [${type}]`);\n if (!targetSegment || !(targetSegment instanceof Segment))\n throw new Error(`Invalid parameter: 'targetSegment'`);\n\n return this.appendSegmentNode(new Segment(type, null, this.parseOptions), targetSegment);\n }\n\n createSegmentBefore(type: TSegmentType, targetSegment: Segment) {\n if (!/^[A-Z\\d]{3}$/.test(type)) throw new Error(`Invalid parameter: 'type' [${type}]`);\n if (!targetSegment || !(targetSegment instanceof Segment))\n throw new Error(`Invalid parameter: 'targetSegment'`);\n\n return this.prependSegmentNode(new Segment(type, null, this.parseOptions), targetSegment);\n }\n\n deleteSegment(segment: Segment) {\n if (!segment || !(segment instanceof Segment)) throw new Error(`Invalid parameter: 'segment'`);\n\n this.deleteSegments([segment]);\n }\n\n deleteSegments(segments: Segment[]) {\n for (const segment of segments) {\n if (!segment || !(segment instanceof Segment))\n throw new Error(`Invalid parameter: 'segments'`);\n }\n\n for (const segment of segments) {\n const node = this.getNode(segment);\n\n if (!node) break;\n\n if (node.prev?.next) node.prev.next = node.next;\n if (node.next?.prev) node.next.prev = node.prev;\n if (this.head === node) this.head = this.head.next;\n if (this.tail === node) this.tail = this.tail.prev;\n\n node.next = null;\n node.prev = null;\n }\n }\n\n moveSegmentAfter(segment: Segment, targetSegment: Segment) {\n if (!segment || !(segment instanceof Segment)) throw new Error(`Invalid parameter: 'segment'`);\n if (!targetSegment || !(targetSegment instanceof Segment))\n throw new Error(`Invalid parameter: 'targetSegment'`);\n\n if (segment === targetSegment) return;\n\n const node = this.getNode(segment);\n\n if (!node) throw new Error(`Failed to locate: 'segment' [${segment.type}]`);\n\n const targetNode = this.getNode(targetSegment);\n\n if (!targetNode) throw new Error(`Failed to locate: 'targetSegment' [${targetSegment.type}]`);\n\n if (node === this.head) this.head = this.head.next;\n if (node.prev?.next) node.prev.next = node.next;\n if (node.next?.prev) node.next.prev = node.prev;\n\n node.next = targetNode.next;\n node.prev = targetNode;\n targetNode.next = node;\n\n if (node.next?.prev) node.next.prev = node;\n\n if (targetNode === this.tail) this.tail = this.tail.next;\n }\n\n moveSegmentBefore(segment: Segment, targetSegment: Segment) {\n if (!segment || !(segment instanceof Segment)) throw new Error(`Invalid parameter: 'segment'`);\n if (!targetSegment || !(targetSegment instanceof Segment))\n throw new Error(`Invalid parameter: 'targetSegment'`);\n\n if (segment === targetSegment) return;\n\n const node = this.getNode(segment);\n\n if (!node) throw new Error(`Failed to locate: 'segment' [${segment.type}]`);\n\n const targetNode = this.getNode(targetSegment);\n\n if (!targetNode) throw new Error(`Failed to locate: 'targetSegment' [${targetSegment.type}]`);\n\n if (node === this.tail) this.tail = this.tail.prev;\n if (node.prev?.next) node.prev.next = node.next;\n if (node.next?.prev) node.next.prev = node.prev;\n\n node.next = targetNode;\n node.prev = targetNode.prev;\n targetNode.prev = node;\n\n if (node.prev?.next) node.prev.next = node;\n\n if (targetNode === this.head) this.head = this.head.prev;\n }\n\n reindexSegments(\n resetRules: { [k in TSegmentType]?: TSegmentType[] },\n startIndex = 1,\n field = '1.1'\n ) {\n if (!resetRules || typeof resetRules !== 'object')\n throw new Error(`Invalid parameter: 'resetRules'`);\n if (!startIndex || typeof startIndex !== 'number')\n throw new Error(`Invalid parameter: 'startIndex' [${startIndex}]`);\n if (field && !/^(\\d+)(\\.\\d+){0,1}$/.test(field))\n throw new Error(`Invalid parameter: 'field' [${field}]`);\n\n let curr = this.head;\n const indexMap: Record<string, number> = {};\n\n for (const key of Object.keys(resetRules)) {\n if (!Array.isArray(resetRules[key]))\n throw new Error(\n `Invalid parameter: 'resetRules'. Expected key [${key}] value to be an array.`\n );\n\n indexMap[key] = startIndex;\n }\n\n while (curr) {\n const segment = curr.data;\n\n if (segment.type in resetRules)\n segment.set(`${segment.type}.${field}`, String(indexMap[segment.type]!++));\n\n for (const [segmentType, resetTriggers] of Object.entries(resetRules)) {\n for (const resetTrigger of resetTriggers!) {\n if (segment.type === resetTrigger) {\n indexMap[segmentType] = startIndex;\n break;\n }\n }\n }\n\n curr = curr.next;\n }\n }\n\n private getNode(segment: Segment) {\n if (!segment || !(segment instanceof Segment)) {\n throw new Error(`Invalid parameter: 'segment'`);\n }\n\n let curr = this.head;\n\n while (curr) {\n if (curr.data === segment) return curr;\n\n curr = curr.next;\n }\n\n return curr;\n }\n\n private appendSegmentNode(newSegment: Segment, targetSegment?: Segment) {\n if (!newSegment || !(newSegment instanceof Segment))\n throw new Error(`Invalid parameter: 'newSegment'`);\n\n if (targetSegment && !(targetSegment instanceof Segment))\n throw new Error(`Invalid parameter: 'targetSegment'`);\n\n const newNode = new Node(newSegment);\n\n if (targetSegment) {\n const targetNode = this.getNode(targetSegment);\n\n if (!targetNode) throw new Error(`Failed to locate: 'targetSegment' [${targetSegment.type}]`);\n\n newNode.next = targetNode.next;\n newNode.prev = targetNode;\n targetNode.next = newNode;\n\n if (newNode.next?.prev) newNode.next.prev = newNode;\n if (targetNode === this.tail) this.tail = this.tail.next;\n } else if (!this.head) {\n this.head = newNode;\n this.tail = newNode;\n } else if (this.tail) {\n newNode.prev = this.tail;\n this.tail.next = newNode;\n this.tail = this.tail.next;\n } else {\n throw new Error(`Failed to append segment: ${newSegment.type}`);\n }\n\n return newSegment;\n }\n\n private prependSegmentNode(newSegment: Segment, targetSegment: Segment) {\n if (!newSegment || !(newSegment instanceof Segment))\n throw new Error(`Invalid parameter: 'newSegment'`);\n\n if (!targetSegment || !(targetSegment instanceof Segment))\n throw new Error(`Invalid parameter: 'targetSegment'`);\n\n const targetNode = this.getNode(targetSegment);\n\n if (!targetNode) throw new Error(`Failed to locate: 'targetSegment' [${targetSegment.type}]`);\n\n const newNode = new Node(newSegment);\n\n newNode.next = targetNode;\n newNode.prev = targetNode.prev;\n targetNode.prev = newNode;\n\n if (newNode.prev?.next) newNode.prev.next = newNode;\n if (targetNode === this.head) this.head = this.head.prev;\n\n return newSegment;\n }\n}\n\nexport type { Segment };\nexport default HL7;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgCA,IAAM,OAAN,MAAc;AAAA,EACZ,YACkB,MACT,OAAuB,MACvB,OAAuB,MAC9B;AAHgB;AACT;AACA;AAAA,EACN;AACL;AAEA,IAAM,UAAN,MAAc;AAAA,EAGZ,YACkB,MACT,OAA4B,MACnC,cACA;AAHgB;AACT;AA7CX;AAgDI,SAAK,eAAe;AAAA,MAClB,aAAY,kDAAc,eAAd,YAA4B;AAAA,MACxC,iBAAgB,kDAAc,mBAAd,YAAgC;AAAA,MAChD,iBAAgB,kDAAc,mBAAd,YAAgC;AAAA,MAChD,eAAc,kDAAc,iBAAd,YAA8B;AAAA,IAC9C;AAAA,EACF;AAAA,EAEA,IAAI,OAAe,iBAAiB,GAAG,oBAAoB,GAAG;AAxDhE;AAyDI,QAAI,CAAC,KAAK,KAAM,QAAO;AAEvB,QAAI,CAAC,SAAS,CAAC,2BAA2B,KAAK,KAAK;AAClD,YAAM,IAAI,MAAM,+BAA+B,KAAK,GAAG;AACzD,QAAI,OAAO,mBAAmB,YAAY,iBAAiB;AACzD,YAAM,IAAI,MAAM,wCAAwC,cAAc,GAAG;AAC3E,QAAI,OAAO,sBAAsB,YAAY,oBAAoB;AAC/D,YAAM,IAAI,MAAM,2CAA2C,iBAAiB,GAAG;AAEjF,UAAM,EAAE,YAAY,gBAAgB,gBAAgB,aAAa,IAAI,KAAK;AAC1E,UAAM,CAAC,MAAM,UAAU,OAAO,IAAI,MAAM,MAAM,GAAG;AAEjD,QAAI,CAAC,QAAQ,SAAS,KAAK;AACzB,YAAM,IAAI;AAAA,QACR,+BAA+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+ type TSegmentType = 'DG1' | 'EVN' | 'GT1' | 'IN1' | 'MSH' | 'NK1' | 'NTE' | 'OBR' | 'OBX' | 'ORC' | 'PID' | 'PR1' | 'PV1' | 'PV2' | (string & {});
5
+ type TSegmentData = Record<string, Array<Record<string, Array<string>>>>;
6
+ type TParseOptions = {
7
+ fieldDelim: string;
8
+ repeatingDelim: string;
9
+ componentDelim: string;
10
+ subCompDelim: string;
11
+ eolDelim: '\r?\n|\r' | '\r\n' | '\n' | '\r';
12
+ buildEolChar: '\r\n' | '\n' | '\r';
13
+ };
14
+ declare class Segment {
15
+ readonly type: TSegmentType;
16
+ data: TSegmentData | null;
17
+ private parseOptions;
18
+ constructor(type: TSegmentType, data?: TSegmentData | null, parseOptions?: Prettify<Omit<TParseOptions, 'eolDelim' | 'buildEolChar'>>);
19
+ get(field: string, repeatingIndex?: number, subComponentIndex?: number): string | null;
20
+ set(field: string, value: string, repeatingIndex?: number, subComponentIndex?: number): void;
21
+ }
22
+ declare class HL7 {
23
+ raw: string;
24
+ parseOptions: TParseOptions;
25
+ private head;
26
+ private tail;
27
+ constructor(hl7Msg: string, parseOptions?: Prettify<Partial<TParseOptions>>);
28
+ /**
29
+ * @deprecated This method is triggered internally and doesnt need to be invoked manually.
30
+ */
31
+ transform(): void;
32
+ build(): string;
33
+ getSegment(type: TSegmentType): Segment | null;
34
+ getSegments(type?: TSegmentType): Segment[];
35
+ getSegmentsAfter(startSegment: Segment, type: TSegmentType, stopSegmentType?: TSegmentType[], consecutive?: boolean): Segment[];
36
+ createSegment(type: TSegmentType): Segment;
37
+ createSegmentAfter(type: TSegmentType, targetSegment: Segment): Segment;
38
+ createSegmentBefore(type: TSegmentType, targetSegment: Segment): Segment;
39
+ deleteSegment(segment: Segment): void;
40
+ deleteSegments(segments: Segment[]): void;
41
+ moveSegmentAfter(segment: Segment, targetSegment: Segment): void;
42
+ moveSegmentBefore(segment: Segment, targetSegment: Segment): void;
43
+ reindexSegments(resetRules: {
44
+ [k in TSegmentType]?: TSegmentType[];
45
+ }, startIndex?: number, field?: string): void;
46
+ private getNode;
47
+ private appendSegmentNode;
48
+ private prependSegmentNode;
49
+ }
50
+
51
+ export { Segment, HL7 as default };
package/dist/index.d.ts CHANGED
@@ -40,11 +40,12 @@ declare class HL7 {
40
40
  deleteSegments(segments: Segment[]): void;
41
41
  moveSegmentAfter(segment: Segment, targetSegment: Segment): void;
42
42
  moveSegmentBefore(segment: Segment, targetSegment: Segment): void;
43
- reindexSegments(resetRules: Record<TSegmentType, TSegmentType[]>, startIndex?: number, field?: string): void;
43
+ reindexSegments(resetRules: {
44
+ [k in TSegmentType]?: TSegmentType[];
45
+ }, startIndex?: number, field?: string): void;
44
46
  private getNode;
45
47
  private appendSegmentNode;
46
48
  private prependSegmentNode;
47
49
  }
48
- export type { Segment };
49
- export default HL7;
50
- //# sourceMappingURL=index.d.ts.map
50
+
51
+ export { Segment, HL7 as default };