hl7v2 1.1.2 → 1.1.3
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 +3 -2
- package/cjs/hl7-segment.js +6 -0
- package/cjs/hl7-sub-component.js +8 -1
- package/esm/hl7-component.js +4 -3
- package/esm/hl7-segment.js +6 -0
- package/esm/hl7-sub-component.js +9 -2
- package/package.json +2 -2
- package/types/hl7-segment.d.ts +1 -0
- package/types/hl7-sub-component.d.ts +3 -1
package/cjs/hl7-component.js
CHANGED
|
@@ -77,7 +77,8 @@ class Hl7Component {
|
|
|
77
77
|
this.subcomp(subComponent || 1).value = value;
|
|
78
78
|
return this;
|
|
79
79
|
}
|
|
80
|
-
this.
|
|
80
|
+
const decode = this.definition.decode || this.typeDef.decode;
|
|
81
|
+
this._data.value = decode && value != null ? decode(value) : value;
|
|
81
82
|
return this;
|
|
82
83
|
}
|
|
83
84
|
fromHL7String(value) {
|
|
@@ -132,7 +133,7 @@ class Hl7Component {
|
|
|
132
133
|
v = encode(v);
|
|
133
134
|
else {
|
|
134
135
|
if (typeof v === 'object' && v instanceof Date)
|
|
135
|
-
v = (0, hl7v2_dictionary_1.
|
|
136
|
+
v = (0, hl7v2_dictionary_1.toHL7DateTime)(v);
|
|
136
137
|
}
|
|
137
138
|
str = (0, hl7_escape_js_1.hl7Escape)(v, this.field.message);
|
|
138
139
|
}
|
package/cjs/hl7-segment.js
CHANGED
|
@@ -43,6 +43,12 @@ class HL7Segment {
|
|
|
43
43
|
def.type = def.type || 'ST';
|
|
44
44
|
return (this._fields[position - 1] = new hl7_field_js_1.HL7Field(this, position, def));
|
|
45
45
|
}
|
|
46
|
+
next(segmentType) {
|
|
47
|
+
const index = this.index + 1;
|
|
48
|
+
const segment = this.message.segments[index];
|
|
49
|
+
if (segment && (!segmentType || segment.segmentType === segmentType))
|
|
50
|
+
return segment;
|
|
51
|
+
}
|
|
46
52
|
toHL7String(options) {
|
|
47
53
|
const { fieldSeparator } = this.message;
|
|
48
54
|
let out = this.segmentType + fieldSeparator;
|
package/cjs/hl7-sub-component.js
CHANGED
|
@@ -29,6 +29,13 @@ class Hl7SubComponent {
|
|
|
29
29
|
get typeDef() {
|
|
30
30
|
return this._typeDef;
|
|
31
31
|
}
|
|
32
|
+
get value() {
|
|
33
|
+
return this._value;
|
|
34
|
+
}
|
|
35
|
+
set value(value) {
|
|
36
|
+
const decode = this.definition.decode || this.typeDef.decode;
|
|
37
|
+
this._value = decode && value != null ? decode(value) : value;
|
|
38
|
+
}
|
|
32
39
|
fromHL7String(value) {
|
|
33
40
|
const decode = this.definition.decode || this.typeDef.decode;
|
|
34
41
|
if (!value) {
|
|
@@ -69,7 +76,7 @@ class Hl7SubComponent {
|
|
|
69
76
|
v = encode(v);
|
|
70
77
|
else {
|
|
71
78
|
if (typeof v === 'object' && v instanceof Date)
|
|
72
|
-
v = (0, hl7v2_dictionary_1.
|
|
79
|
+
v = (0, hl7v2_dictionary_1.toHL7DateTime)(v);
|
|
73
80
|
}
|
|
74
81
|
const str = (0, hl7_escape_js_1.hl7Escape)(v, this.field.message);
|
|
75
82
|
if (options?.serializeSubComponent)
|
package/esm/hl7-component.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toHL7DateTime, } from 'hl7v2-dictionary';
|
|
2
2
|
import { HL7Error } from './hl7-error.js';
|
|
3
3
|
import { Hl7SubComponent, } from './hl7-sub-component.js';
|
|
4
4
|
import { hl7Escape, hl7UnEscape } from './utils/hl7-escape.js';
|
|
@@ -74,7 +74,8 @@ export class Hl7Component {
|
|
|
74
74
|
this.subcomp(subComponent || 1).value = value;
|
|
75
75
|
return this;
|
|
76
76
|
}
|
|
77
|
-
this.
|
|
77
|
+
const decode = this.definition.decode || this.typeDef.decode;
|
|
78
|
+
this._data.value = decode && value != null ? decode(value) : value;
|
|
78
79
|
return this;
|
|
79
80
|
}
|
|
80
81
|
fromHL7String(value) {
|
|
@@ -129,7 +130,7 @@ export class Hl7Component {
|
|
|
129
130
|
v = encode(v);
|
|
130
131
|
else {
|
|
131
132
|
if (typeof v === 'object' && v instanceof Date)
|
|
132
|
-
v =
|
|
133
|
+
v = toHL7DateTime(v);
|
|
133
134
|
}
|
|
134
135
|
str = hl7Escape(v, this.field.message);
|
|
135
136
|
}
|
package/esm/hl7-segment.js
CHANGED
|
@@ -40,6 +40,12 @@ export class HL7Segment {
|
|
|
40
40
|
def.type = def.type || 'ST';
|
|
41
41
|
return (this._fields[position - 1] = new HL7Field(this, position, def));
|
|
42
42
|
}
|
|
43
|
+
next(segmentType) {
|
|
44
|
+
const index = this.index + 1;
|
|
45
|
+
const segment = this.message.segments[index];
|
|
46
|
+
if (segment && (!segmentType || segment.segmentType === segmentType))
|
|
47
|
+
return segment;
|
|
48
|
+
}
|
|
43
49
|
toHL7String(options) {
|
|
44
50
|
const { fieldSeparator } = this.message;
|
|
45
51
|
let out = this.segmentType + fieldSeparator;
|
package/esm/hl7-sub-component.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toHL7DateTime, } from 'hl7v2-dictionary';
|
|
2
2
|
import { HL7Error } from './hl7-error.js';
|
|
3
3
|
import { hl7Escape, hl7UnEscape } from './utils/hl7-escape.js';
|
|
4
4
|
export class Hl7SubComponent {
|
|
@@ -26,6 +26,13 @@ export class Hl7SubComponent {
|
|
|
26
26
|
get typeDef() {
|
|
27
27
|
return this._typeDef;
|
|
28
28
|
}
|
|
29
|
+
get value() {
|
|
30
|
+
return this._value;
|
|
31
|
+
}
|
|
32
|
+
set value(value) {
|
|
33
|
+
const decode = this.definition.decode || this.typeDef.decode;
|
|
34
|
+
this._value = decode && value != null ? decode(value) : value;
|
|
35
|
+
}
|
|
29
36
|
fromHL7String(value) {
|
|
30
37
|
const decode = this.definition.decode || this.typeDef.decode;
|
|
31
38
|
if (!value) {
|
|
@@ -66,7 +73,7 @@ export class Hl7SubComponent {
|
|
|
66
73
|
v = encode(v);
|
|
67
74
|
else {
|
|
68
75
|
if (typeof v === 'object' && v instanceof Date)
|
|
69
|
-
v =
|
|
76
|
+
v = toHL7DateTime(v);
|
|
70
77
|
}
|
|
71
78
|
const str = hl7Escape(v, this.field.message);
|
|
72
79
|
if (options?.serializeSubComponent)
|
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.1.
|
|
4
|
+
"version": "1.1.3",
|
|
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.1.
|
|
18
|
+
"hl7v2-dictionary": "^1.1.3"
|
|
19
19
|
},
|
|
20
20
|
"type": "module",
|
|
21
21
|
"exports": {
|
package/types/hl7-segment.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare class HL7Segment {
|
|
|
13
13
|
clear(): void;
|
|
14
14
|
field(fieldPos: number): HL7Field;
|
|
15
15
|
defineField(position: number, def: HL7FieldDefinition): HL7Field;
|
|
16
|
+
next(segmentType?: string): HL7Segment | undefined;
|
|
16
17
|
toHL7String(options?: Hl7SegmentSerializeOptions): string;
|
|
17
18
|
static parse(message: HL7Message, input: string): HL7Segment;
|
|
18
19
|
}
|
|
@@ -8,13 +8,15 @@ export declare class Hl7SubComponent {
|
|
|
8
8
|
protected _typeDef: HL7DataTypeDefinition;
|
|
9
9
|
readonly component: Hl7Component;
|
|
10
10
|
readonly position: number;
|
|
11
|
-
|
|
11
|
+
protected _value?: any;
|
|
12
12
|
constructor(component: Hl7Component, position: number, def: HL7FieldDefinition);
|
|
13
13
|
get message(): HL7Message;
|
|
14
14
|
get segment(): HL7Segment;
|
|
15
15
|
get field(): HL7Field;
|
|
16
16
|
get definition(): HL7FieldDefinition;
|
|
17
17
|
get typeDef(): HL7DataTypeDefinition;
|
|
18
|
+
get value(): any | undefined;
|
|
19
|
+
set value(value: any);
|
|
18
20
|
fromHL7String(value: string): void;
|
|
19
21
|
toHL7String(options?: Hl7SubComponentSerializeOptions): string;
|
|
20
22
|
[Symbol.toStringTag](): string;
|