hl7v2 1.2.7 → 1.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/cjs/hl7-component.js +16 -6
- package/cjs/hl7-field.js +2 -2
- package/cjs/hl7-message.js +5 -5
- package/cjs/hl7-repetition.js +2 -2
- package/cjs/hl7-segment.js +2 -2
- package/cjs/hl7-sub-component.js +13 -3
- package/esm/hl7-component.js +16 -6
- package/esm/hl7-field.js +2 -2
- package/esm/hl7-message.js +6 -6
- package/esm/hl7-repetition.js +2 -2
- package/esm/hl7-segment.js +3 -3
- package/esm/hl7-sub-component.js +13 -3
- package/package.json +2 -2
- package/types/hl7-component.d.ts +4 -2
- package/types/hl7-field.d.ts +4 -2
- package/types/hl7-message.d.ts +6 -3
- package/types/hl7-repetition.d.ts +4 -2
- package/types/hl7-segment.d.ts +4 -2
- package/types/hl7-sub-component.d.ts +4 -1
package/cjs/hl7-component.js
CHANGED
|
@@ -91,7 +91,7 @@ class Hl7Component {
|
|
|
91
91
|
this._data.value = value;
|
|
92
92
|
return this;
|
|
93
93
|
}
|
|
94
|
-
fromHL7String(value) {
|
|
94
|
+
fromHL7String(value, options) {
|
|
95
95
|
if (value === '') {
|
|
96
96
|
this.setValue(undefined);
|
|
97
97
|
return;
|
|
@@ -101,11 +101,15 @@ class Hl7Component {
|
|
|
101
101
|
const unescaped = (0, hl7_escape_js_1.hl7UnEscape)(value, this.field.message);
|
|
102
102
|
try {
|
|
103
103
|
if (Buffer.isBuffer(unescaped) || unescaped == null)
|
|
104
|
-
this._data.
|
|
104
|
+
this._data._value = unescaped;
|
|
105
105
|
else
|
|
106
|
-
this._data.
|
|
106
|
+
this._data._value = decode ? decode(unescaped) : unescaped;
|
|
107
107
|
}
|
|
108
108
|
catch (e) {
|
|
109
|
+
if (!options?.strict) {
|
|
110
|
+
this._data._value = unescaped;
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
109
113
|
const location = `${this.segment.segmentType}.${this.field.position}.${this.position}[${this.repetition.index}]`;
|
|
110
114
|
let segmentIndex = this.segment.index;
|
|
111
115
|
if (segmentIndex < 0)
|
|
@@ -128,7 +132,7 @@ class Hl7Component {
|
|
|
128
132
|
const subComponents = value.split(this.field.message.subComponentSeparator);
|
|
129
133
|
let pos = 1;
|
|
130
134
|
for (const subComponent of subComponents) {
|
|
131
|
-
this.subcomp(pos++).fromHL7String(subComponent);
|
|
135
|
+
this.subcomp(pos++).fromHL7String(subComponent, options);
|
|
132
136
|
}
|
|
133
137
|
}
|
|
134
138
|
}
|
|
@@ -141,8 +145,14 @@ class Hl7Component {
|
|
|
141
145
|
if (v === undefined)
|
|
142
146
|
return '';
|
|
143
147
|
const encode = this.definition.encode || this.typeDef.encode;
|
|
144
|
-
if (encode)
|
|
145
|
-
|
|
148
|
+
if (encode) {
|
|
149
|
+
try {
|
|
150
|
+
v = encode(v);
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
v = v == null ? v : String(v);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
146
156
|
else {
|
|
147
157
|
if (typeof v === 'object' && v instanceof Date)
|
|
148
158
|
v = (0, hl7v2_dictionary_1.toHL7DateTime)(v);
|
package/cjs/hl7-field.js
CHANGED
|
@@ -77,11 +77,11 @@ class HL7Field {
|
|
|
77
77
|
setValue(value, component, subComponent) {
|
|
78
78
|
return this.repetition(0).setValue(value, component, subComponent);
|
|
79
79
|
}
|
|
80
|
-
fromHL7String(value) {
|
|
80
|
+
fromHL7String(value, options) {
|
|
81
81
|
const components = value.split(this.message.repetitionSeparator);
|
|
82
82
|
this._repetitions = [];
|
|
83
83
|
for (const cmp of components) {
|
|
84
|
-
this.add().fromHL7String(cmp);
|
|
84
|
+
this.add().fromHL7String(cmp, options);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
toHL7String(options) {
|
package/cjs/hl7-message.js
CHANGED
|
@@ -91,7 +91,7 @@ class HL7Message {
|
|
|
91
91
|
.filter(v => v)
|
|
92
92
|
.join(constants_js_1.CR) + constants_js_1.CR);
|
|
93
93
|
}
|
|
94
|
-
parse(input) {
|
|
94
|
+
parse(input, options) {
|
|
95
95
|
const raw = HL7Message.parseRaw(input);
|
|
96
96
|
this._clear(raw.version);
|
|
97
97
|
this.fieldSeparator = raw.fieldSeparator;
|
|
@@ -105,7 +105,7 @@ class HL7Message {
|
|
|
105
105
|
if (!line)
|
|
106
106
|
continue;
|
|
107
107
|
try {
|
|
108
|
-
const segment = hl7_segment_js_1.HL7Segment.parse(this, line);
|
|
108
|
+
const segment = hl7_segment_js_1.HL7Segment.parse(this, line, options);
|
|
109
109
|
this._segments.push(segment);
|
|
110
110
|
}
|
|
111
111
|
catch (e) {
|
|
@@ -255,9 +255,9 @@ class HL7Message {
|
|
|
255
255
|
*
|
|
256
256
|
* @static
|
|
257
257
|
*/
|
|
258
|
-
static parse(input,
|
|
259
|
-
const message = new HL7Message(undefined, dictionaries);
|
|
260
|
-
message.parse(input);
|
|
258
|
+
static parse(input, options) {
|
|
259
|
+
const message = new HL7Message(undefined, options?.dictionaries);
|
|
260
|
+
message.parse(input, options);
|
|
261
261
|
return message;
|
|
262
262
|
}
|
|
263
263
|
/**
|
package/cjs/hl7-repetition.js
CHANGED
|
@@ -73,11 +73,11 @@ class HL7Repetition {
|
|
|
73
73
|
this.comp(component ?? 1).setValue(value, subComponent);
|
|
74
74
|
return this;
|
|
75
75
|
}
|
|
76
|
-
fromHL7String(value) {
|
|
76
|
+
fromHL7String(value, options) {
|
|
77
77
|
this._components = [];
|
|
78
78
|
const items = value.split(this.field.message.componentSeparator);
|
|
79
79
|
for (const s of items) {
|
|
80
|
-
this.comp(this._components.length + 1).fromHL7String(s);
|
|
80
|
+
this.comp(this._components.length + 1).fromHL7String(s, options);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
toHL7String(options) {
|
package/cjs/hl7-segment.js
CHANGED
|
@@ -70,7 +70,7 @@ class HL7Segment {
|
|
|
70
70
|
out = out.substring(0, out.length - 1);
|
|
71
71
|
return out;
|
|
72
72
|
}
|
|
73
|
-
static parse(message, input) {
|
|
73
|
+
static parse(message, input, options) {
|
|
74
74
|
const fields = input.split(message.fieldSeparator);
|
|
75
75
|
const segment = new HL7Segment(message, fields[0]);
|
|
76
76
|
if (segment.segmentType === 'MSH')
|
|
@@ -78,7 +78,7 @@ class HL7Segment {
|
|
|
78
78
|
else
|
|
79
79
|
fields.shift();
|
|
80
80
|
for (let i = 0; i < fields.length; i++) {
|
|
81
|
-
segment.field(i + 1).fromHL7String(fields[i]);
|
|
81
|
+
segment.field(i + 1).fromHL7String(fields[i], options);
|
|
82
82
|
}
|
|
83
83
|
return segment;
|
|
84
84
|
}
|
package/cjs/hl7-sub-component.js
CHANGED
|
@@ -39,7 +39,7 @@ class Hl7SubComponent {
|
|
|
39
39
|
isEmpty() {
|
|
40
40
|
return this._value == null;
|
|
41
41
|
}
|
|
42
|
-
fromHL7String(value) {
|
|
42
|
+
fromHL7String(value, options) {
|
|
43
43
|
this._value = undefined;
|
|
44
44
|
if (!value)
|
|
45
45
|
return;
|
|
@@ -53,6 +53,10 @@ class Hl7SubComponent {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
catch (e) {
|
|
56
|
+
if (!options?.strict) {
|
|
57
|
+
this.value = unescaped;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
56
60
|
const location = `${this.segment.segmentType}.${this.field.position}.${this.component.position}.${this.position}[${this.component.repetition.index}]`;
|
|
57
61
|
let segmentIndex = this.segment.index;
|
|
58
62
|
if (segmentIndex < 0)
|
|
@@ -75,8 +79,14 @@ class Hl7SubComponent {
|
|
|
75
79
|
return '""';
|
|
76
80
|
if (v === undefined)
|
|
77
81
|
return '';
|
|
78
|
-
if (encode)
|
|
79
|
-
|
|
82
|
+
if (encode) {
|
|
83
|
+
try {
|
|
84
|
+
v = encode(v);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
v = v == null ? v : String(v);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
80
90
|
else {
|
|
81
91
|
if (typeof v === 'object' && v instanceof Date)
|
|
82
92
|
v = (0, hl7v2_dictionary_1.toHL7DateTime)(v);
|
package/esm/hl7-component.js
CHANGED
|
@@ -88,7 +88,7 @@ export class Hl7Component {
|
|
|
88
88
|
this._data.value = value;
|
|
89
89
|
return this;
|
|
90
90
|
}
|
|
91
|
-
fromHL7String(value) {
|
|
91
|
+
fromHL7String(value, options) {
|
|
92
92
|
if (value === '') {
|
|
93
93
|
this.setValue(undefined);
|
|
94
94
|
return;
|
|
@@ -98,11 +98,15 @@ export class Hl7Component {
|
|
|
98
98
|
const unescaped = hl7UnEscape(value, this.field.message);
|
|
99
99
|
try {
|
|
100
100
|
if (Buffer.isBuffer(unescaped) || unescaped == null)
|
|
101
|
-
this._data.
|
|
101
|
+
this._data._value = unescaped;
|
|
102
102
|
else
|
|
103
|
-
this._data.
|
|
103
|
+
this._data._value = decode ? decode(unescaped) : unescaped;
|
|
104
104
|
}
|
|
105
105
|
catch (e) {
|
|
106
|
+
if (!options?.strict) {
|
|
107
|
+
this._data._value = unescaped;
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
106
110
|
const location = `${this.segment.segmentType}.${this.field.position}.${this.position}[${this.repetition.index}]`;
|
|
107
111
|
let segmentIndex = this.segment.index;
|
|
108
112
|
if (segmentIndex < 0)
|
|
@@ -125,7 +129,7 @@ export class Hl7Component {
|
|
|
125
129
|
const subComponents = value.split(this.field.message.subComponentSeparator);
|
|
126
130
|
let pos = 1;
|
|
127
131
|
for (const subComponent of subComponents) {
|
|
128
|
-
this.subcomp(pos++).fromHL7String(subComponent);
|
|
132
|
+
this.subcomp(pos++).fromHL7String(subComponent, options);
|
|
129
133
|
}
|
|
130
134
|
}
|
|
131
135
|
}
|
|
@@ -138,8 +142,14 @@ export class Hl7Component {
|
|
|
138
142
|
if (v === undefined)
|
|
139
143
|
return '';
|
|
140
144
|
const encode = this.definition.encode || this.typeDef.encode;
|
|
141
|
-
if (encode)
|
|
142
|
-
|
|
145
|
+
if (encode) {
|
|
146
|
+
try {
|
|
147
|
+
v = encode(v);
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
v = v == null ? v : String(v);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
143
153
|
else {
|
|
144
154
|
if (typeof v === 'object' && v instanceof Date)
|
|
145
155
|
v = toHL7DateTime(v);
|
package/esm/hl7-field.js
CHANGED
|
@@ -74,11 +74,11 @@ export class HL7Field {
|
|
|
74
74
|
setValue(value, component, subComponent) {
|
|
75
75
|
return this.repetition(0).setValue(value, component, subComponent);
|
|
76
76
|
}
|
|
77
|
-
fromHL7String(value) {
|
|
77
|
+
fromHL7String(value, options) {
|
|
78
78
|
const components = value.split(this.message.repetitionSeparator);
|
|
79
79
|
this._repetitions = [];
|
|
80
80
|
for (const cmp of components) {
|
|
81
|
-
this.add().fromHL7String(cmp);
|
|
81
|
+
this.add().fromHL7String(cmp, options);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
toHL7String(options) {
|
package/esm/hl7-message.js
CHANGED
|
@@ -4,7 +4,7 @@ import iconv from 'iconv-lite';
|
|
|
4
4
|
import { uid } from 'uid';
|
|
5
5
|
import { COMPONENT_SEPARATOR, CR, ESCAPE_CHARACTER, FIELD_SEPARATOR, FS, LF, REPETITION_SEPARATOR, SUBCOMPONENT_SEPARATOR, VT, } from './constants.js';
|
|
6
6
|
import { HL7Error } from './hl7-error.js';
|
|
7
|
-
import { HL7Segment } from './hl7-segment.js';
|
|
7
|
+
import { HL7Segment, } from './hl7-segment.js';
|
|
8
8
|
export class HL7Message {
|
|
9
9
|
constructor(version = HL7Version.v2_7_1, dictionaries) {
|
|
10
10
|
this.fieldSeparator = FIELD_SEPARATOR;
|
|
@@ -87,7 +87,7 @@ export class HL7Message {
|
|
|
87
87
|
.filter(v => v)
|
|
88
88
|
.join(CR) + CR);
|
|
89
89
|
}
|
|
90
|
-
parse(input) {
|
|
90
|
+
parse(input, options) {
|
|
91
91
|
const raw = HL7Message.parseRaw(input);
|
|
92
92
|
this._clear(raw.version);
|
|
93
93
|
this.fieldSeparator = raw.fieldSeparator;
|
|
@@ -101,7 +101,7 @@ export class HL7Message {
|
|
|
101
101
|
if (!line)
|
|
102
102
|
continue;
|
|
103
103
|
try {
|
|
104
|
-
const segment = HL7Segment.parse(this, line);
|
|
104
|
+
const segment = HL7Segment.parse(this, line, options);
|
|
105
105
|
this._segments.push(segment);
|
|
106
106
|
}
|
|
107
107
|
catch (e) {
|
|
@@ -251,9 +251,9 @@ export class HL7Message {
|
|
|
251
251
|
*
|
|
252
252
|
* @static
|
|
253
253
|
*/
|
|
254
|
-
static parse(input,
|
|
255
|
-
const message = new HL7Message(undefined, dictionaries);
|
|
256
|
-
message.parse(input);
|
|
254
|
+
static parse(input, options) {
|
|
255
|
+
const message = new HL7Message(undefined, options?.dictionaries);
|
|
256
|
+
message.parse(input, options);
|
|
257
257
|
return message;
|
|
258
258
|
}
|
|
259
259
|
/**
|
package/esm/hl7-repetition.js
CHANGED
|
@@ -70,11 +70,11 @@ export class HL7Repetition {
|
|
|
70
70
|
this.comp(component ?? 1).setValue(value, subComponent);
|
|
71
71
|
return this;
|
|
72
72
|
}
|
|
73
|
-
fromHL7String(value) {
|
|
73
|
+
fromHL7String(value, options) {
|
|
74
74
|
this._components = [];
|
|
75
75
|
const items = value.split(this.field.message.componentSeparator);
|
|
76
76
|
for (const s of items) {
|
|
77
|
-
this.comp(this._components.length + 1).fromHL7String(s);
|
|
77
|
+
this.comp(this._components.length + 1).fromHL7String(s, options);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
toHL7String(options) {
|
package/esm/hl7-segment.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HL7Field } from './hl7-field.js';
|
|
1
|
+
import { HL7Field, } from './hl7-field.js';
|
|
2
2
|
export class HL7Segment {
|
|
3
3
|
constructor(message, segmentType) {
|
|
4
4
|
this.segmentType = '';
|
|
@@ -67,7 +67,7 @@ export class HL7Segment {
|
|
|
67
67
|
out = out.substring(0, out.length - 1);
|
|
68
68
|
return out;
|
|
69
69
|
}
|
|
70
|
-
static parse(message, input) {
|
|
70
|
+
static parse(message, input, options) {
|
|
71
71
|
const fields = input.split(message.fieldSeparator);
|
|
72
72
|
const segment = new HL7Segment(message, fields[0]);
|
|
73
73
|
if (segment.segmentType === 'MSH')
|
|
@@ -75,7 +75,7 @@ export class HL7Segment {
|
|
|
75
75
|
else
|
|
76
76
|
fields.shift();
|
|
77
77
|
for (let i = 0; i < fields.length; i++) {
|
|
78
|
-
segment.field(i + 1).fromHL7String(fields[i]);
|
|
78
|
+
segment.field(i + 1).fromHL7String(fields[i], options);
|
|
79
79
|
}
|
|
80
80
|
return segment;
|
|
81
81
|
}
|
package/esm/hl7-sub-component.js
CHANGED
|
@@ -36,7 +36,7 @@ export class Hl7SubComponent {
|
|
|
36
36
|
isEmpty() {
|
|
37
37
|
return this._value == null;
|
|
38
38
|
}
|
|
39
|
-
fromHL7String(value) {
|
|
39
|
+
fromHL7String(value, options) {
|
|
40
40
|
this._value = undefined;
|
|
41
41
|
if (!value)
|
|
42
42
|
return;
|
|
@@ -50,6 +50,10 @@ export class Hl7SubComponent {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
catch (e) {
|
|
53
|
+
if (!options?.strict) {
|
|
54
|
+
this.value = unescaped;
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
53
57
|
const location = `${this.segment.segmentType}.${this.field.position}.${this.component.position}.${this.position}[${this.component.repetition.index}]`;
|
|
54
58
|
let segmentIndex = this.segment.index;
|
|
55
59
|
if (segmentIndex < 0)
|
|
@@ -72,8 +76,14 @@ export class Hl7SubComponent {
|
|
|
72
76
|
return '""';
|
|
73
77
|
if (v === undefined)
|
|
74
78
|
return '';
|
|
75
|
-
if (encode)
|
|
76
|
-
|
|
79
|
+
if (encode) {
|
|
80
|
+
try {
|
|
81
|
+
v = encode(v);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
v = v == null ? v : String(v);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
77
87
|
else {
|
|
78
88
|
if (typeof v === 'object' && v instanceof Date)
|
|
79
89
|
v = toHL7DateTime(v);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hl7v2",
|
|
3
3
|
"description": "HL7 v2 parser, serializer, validator for NodeJS",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"dependencies": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"uid": "^2.0.2"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"hl7v2-dictionary": "^1.
|
|
18
|
+
"hl7v2-dictionary": "^1.3.0"
|
|
19
19
|
},
|
|
20
20
|
"type": "module",
|
|
21
21
|
"exports": {
|
package/types/hl7-component.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { HL7Field } from './hl7-field.js';
|
|
|
3
3
|
import type { HL7Message } from './hl7-message.js';
|
|
4
4
|
import type { HL7Repetition } from './hl7-repetition.js';
|
|
5
5
|
import type { HL7Segment } from './hl7-segment.js';
|
|
6
|
-
import { Hl7SubComponent, type Hl7SubComponentSerializeOptions } from './hl7-sub-component.js';
|
|
6
|
+
import { Hl7SubComponent, Hl7SubComponentParseOptions, type Hl7SubComponentSerializeOptions } from './hl7-sub-component.js';
|
|
7
7
|
export declare class Hl7Component {
|
|
8
8
|
protected _subComponents?: Hl7SubComponent[];
|
|
9
9
|
protected _data?: Hl7SubComponent;
|
|
@@ -24,10 +24,12 @@ export declare class Hl7Component {
|
|
|
24
24
|
subcomp(position: number): Hl7SubComponent;
|
|
25
25
|
getValue(subComponent?: number): any | undefined;
|
|
26
26
|
setValue(value: any, subComponent?: number): this;
|
|
27
|
-
fromHL7String(value: string): void;
|
|
27
|
+
fromHL7String(value: string, options?: Hl7ComponentParseOptions): void;
|
|
28
28
|
toHL7String(options?: Hl7ComponentSerializeOptions): any;
|
|
29
29
|
[Symbol.toStringTag](): any;
|
|
30
30
|
}
|
|
31
|
+
export interface Hl7ComponentParseOptions extends Hl7SubComponentParseOptions {
|
|
32
|
+
}
|
|
31
33
|
export interface Hl7ComponentSerializeOptions extends Hl7SubComponentSerializeOptions {
|
|
32
34
|
serializeComponent?: (component: Hl7Component, serializedString: string, options?: Hl7ComponentSerializeOptions) => string;
|
|
33
35
|
}
|
package/types/hl7-field.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HL7DataTypeDefinition, HL7FieldDefinition } from 'hl7v2-dictionary';
|
|
2
2
|
import type { Hl7Component } from './hl7-component.js';
|
|
3
3
|
import type { HL7Message } from './hl7-message.js';
|
|
4
|
-
import { HL7Repetition, type HL7RepetitionSerializeOptions } from './hl7-repetition.js';
|
|
4
|
+
import { HL7Repetition, HL7RepetitionParseOptions, type HL7RepetitionSerializeOptions } from './hl7-repetition.js';
|
|
5
5
|
import type { HL7Segment } from './hl7-segment.js';
|
|
6
6
|
import { Hl7SubComponent } from './hl7-sub-component.js';
|
|
7
7
|
export declare class HL7Field {
|
|
@@ -36,10 +36,12 @@ export declare class HL7Field {
|
|
|
36
36
|
subcomp(componentPos: number, subComponentPos: number): Hl7SubComponent;
|
|
37
37
|
getValue(component?: number, subComponent?: number): any;
|
|
38
38
|
setValue(value: any, component?: number, subComponent?: number): any;
|
|
39
|
-
fromHL7String(value: string): void;
|
|
39
|
+
fromHL7String(value: string, options?: Hl7FieldParseOptions): void;
|
|
40
40
|
toHL7String(options?: Hl7FieldSerializeOptions): string;
|
|
41
41
|
[Symbol.toStringTag](): string;
|
|
42
42
|
}
|
|
43
|
+
export interface Hl7FieldParseOptions extends HL7RepetitionParseOptions {
|
|
44
|
+
}
|
|
43
45
|
export interface Hl7FieldSerializeOptions extends HL7RepetitionSerializeOptions {
|
|
44
46
|
serializeField?: (field: HL7Field, serializedString: string, options?: Hl7FieldSerializeOptions) => string;
|
|
45
47
|
}
|
package/types/hl7-message.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AcknowledgmentCode, HL7Dictionary, HL7Version } from 'hl7v2-dictionary';
|
|
2
|
-
import { HL7Segment, Hl7SegmentSerializeOptions } from './hl7-segment.js';
|
|
2
|
+
import { HL7Segment, Hl7SegmentParseOptions, Hl7SegmentSerializeOptions } from './hl7-segment.js';
|
|
3
3
|
export declare class HL7Message {
|
|
4
4
|
private readonly _dictionaries;
|
|
5
5
|
protected _segments: HL7Segment[];
|
|
@@ -28,7 +28,7 @@ export declare class HL7Message {
|
|
|
28
28
|
*/
|
|
29
29
|
getSegmentFromLast(segmentType: string, index?: number): HL7Segment | undefined;
|
|
30
30
|
toHL7String(options?: HL7MessageSerializeOptions): string;
|
|
31
|
-
parse(input: string | Buffer): void;
|
|
31
|
+
parse(input: string | Buffer, options?: HL7MessageParseOptions): void;
|
|
32
32
|
createAck(ackCode?: AcknowledgmentCode, textMessage?: string): HL7Message;
|
|
33
33
|
createNak(errors: (Error | string)[]): HL7Message;
|
|
34
34
|
addError(error: Error | string): void;
|
|
@@ -37,7 +37,7 @@ export declare class HL7Message {
|
|
|
37
37
|
*
|
|
38
38
|
* @static
|
|
39
39
|
*/
|
|
40
|
-
static parse(input: string | Buffer,
|
|
40
|
+
static parse(input: string | Buffer, options?: HL7MessageParseOptions): HL7Message;
|
|
41
41
|
/**
|
|
42
42
|
*
|
|
43
43
|
* @static
|
|
@@ -79,5 +79,8 @@ export declare class HL7Message {
|
|
|
79
79
|
'UNICODE UTF-16': string;
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
+
export interface HL7MessageParseOptions extends Hl7SegmentParseOptions {
|
|
83
|
+
dictionaries?: Record<string, HL7Dictionary>;
|
|
84
|
+
}
|
|
82
85
|
export interface HL7MessageSerializeOptions extends Hl7SegmentSerializeOptions {
|
|
83
86
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Hl7Component, type Hl7ComponentSerializeOptions } from './hl7-component.js';
|
|
1
|
+
import { Hl7Component, Hl7ComponentParseOptions, type Hl7ComponentSerializeOptions } from './hl7-component.js';
|
|
2
2
|
import type { HL7Field } from './hl7-field.js';
|
|
3
3
|
import type { HL7Message } from './hl7-message.js';
|
|
4
4
|
import type { HL7Segment } from './hl7-segment.js';
|
|
@@ -28,9 +28,11 @@ export declare class HL7Repetition {
|
|
|
28
28
|
subcomp(componentPos: number, subComponentPos: number): Hl7SubComponent;
|
|
29
29
|
getValue(component?: number, subComponent?: number): any;
|
|
30
30
|
setValue(value: any, component?: number, subComponent?: number): this;
|
|
31
|
-
fromHL7String(value: string): void;
|
|
31
|
+
fromHL7String(value: string, options?: HL7RepetitionParseOptions): void;
|
|
32
32
|
toHL7String(options?: HL7RepetitionSerializeOptions): string;
|
|
33
33
|
[Symbol.toStringTag](): string;
|
|
34
34
|
}
|
|
35
|
+
export interface HL7RepetitionParseOptions extends Hl7ComponentParseOptions {
|
|
36
|
+
}
|
|
35
37
|
export interface HL7RepetitionSerializeOptions extends Hl7ComponentSerializeOptions {
|
|
36
38
|
}
|
package/types/hl7-segment.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HL7FieldDefinition, HL7SegmentDefinition } from 'hl7v2-dictionary';
|
|
2
|
-
import { HL7Field, Hl7FieldSerializeOptions } from './hl7-field.js';
|
|
2
|
+
import { HL7Field, Hl7FieldParseOptions, Hl7FieldSerializeOptions } from './hl7-field.js';
|
|
3
3
|
import type { HL7Message } from './hl7-message.js';
|
|
4
4
|
export declare class HL7Segment {
|
|
5
5
|
protected _fields: HL7Field[];
|
|
@@ -15,7 +15,9 @@ export declare class HL7Segment {
|
|
|
15
15
|
defineField(position: number, def: HL7FieldDefinition): HL7Field;
|
|
16
16
|
next(segmentType?: string): HL7Segment | undefined;
|
|
17
17
|
toHL7String(options?: Hl7SegmentSerializeOptions): string;
|
|
18
|
-
static parse(message: HL7Message, input: string): HL7Segment;
|
|
18
|
+
static parse(message: HL7Message, input: string, options?: Hl7SegmentParseOptions): HL7Segment;
|
|
19
|
+
}
|
|
20
|
+
export interface Hl7SegmentParseOptions extends Hl7FieldParseOptions {
|
|
19
21
|
}
|
|
20
22
|
export interface Hl7SegmentSerializeOptions extends Hl7FieldSerializeOptions {
|
|
21
23
|
serializeSegment?: (segment: HL7Segment, serializedString: string, options?: Hl7FieldSerializeOptions) => string;
|
|
@@ -18,10 +18,13 @@ export declare class Hl7SubComponent {
|
|
|
18
18
|
get value(): any | undefined;
|
|
19
19
|
set value(value: any);
|
|
20
20
|
isEmpty(): boolean;
|
|
21
|
-
fromHL7String(value: string): void;
|
|
21
|
+
fromHL7String(value: string, options?: Hl7SubComponentParseOptions): void;
|
|
22
22
|
toHL7String(options?: Hl7SubComponentSerializeOptions): string;
|
|
23
23
|
[Symbol.toStringTag](): string;
|
|
24
24
|
}
|
|
25
|
+
export interface Hl7SubComponentParseOptions {
|
|
26
|
+
strict?: boolean;
|
|
27
|
+
}
|
|
25
28
|
export interface Hl7SubComponentSerializeOptions {
|
|
26
29
|
serializeSubComponent?: (subComponent: Hl7SubComponent, serializedString: string, options?: Hl7SubComponentSerializeOptions) => string;
|
|
27
30
|
}
|