@syncbridge/hl7 0.4.17 → 0.4.19
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/components/hl7-client.component.d.ts +2 -0
- package/components/hl7-client.component.js +43 -20
- package/components/hl7-client.variables.js +1 -0
- package/components/hl7-server.component.d.ts +2 -0
- package/components/hl7-server.component.js +46 -28
- package/constants.js +1 -1
- package/package.json +6 -6
|
@@ -15,6 +15,8 @@ export declare class HL7ClientComponent<TEvents extends HL7ClientComponent.Event
|
|
|
15
15
|
transmitLogger?: TransmitLogger;
|
|
16
16
|
values: HL7ClientVariables;
|
|
17
17
|
protected _init(): Promise<void>;
|
|
18
|
+
protected _configureClient(): Promise<void>;
|
|
19
|
+
protected _configureTransmitLogger(): void;
|
|
18
20
|
protected _start(abortSignal: AbortSignal): Promise<void>;
|
|
19
21
|
protected _stop(): Promise<void>;
|
|
20
22
|
use(handler: HL7Middleware, priority?: number): void;
|
|
@@ -15,7 +15,26 @@ let HL7ClientComponent = class HL7ClientComponent extends ComponentBase {
|
|
|
15
15
|
async _init() {
|
|
16
16
|
await super._init();
|
|
17
17
|
this.values.reconnect = this.values.reconnect || {};
|
|
18
|
+
this.on('data', (data, info) => {
|
|
19
|
+
this.transmitLogger?.received(data, info);
|
|
20
|
+
});
|
|
21
|
+
this.on('transmit', (data, info) => {
|
|
22
|
+
this.transmitLogger?.transmitted(data, info);
|
|
23
|
+
});
|
|
24
|
+
this.on('values-updated', async () => {
|
|
25
|
+
await this._configureClient();
|
|
26
|
+
this._configureTransmitLogger();
|
|
27
|
+
});
|
|
28
|
+
await this._configureClient();
|
|
29
|
+
this._configureTransmitLogger();
|
|
30
|
+
}
|
|
31
|
+
async _configureClient() {
|
|
18
32
|
try {
|
|
33
|
+
const isStopped = this.stopped;
|
|
34
|
+
if (!isStopped)
|
|
35
|
+
await this._stop();
|
|
36
|
+
if (this.client)
|
|
37
|
+
await this.client.close();
|
|
19
38
|
if (this.values.tls) {
|
|
20
39
|
this.client = Hl7Client.createTlsClient({
|
|
21
40
|
host: this.values.host,
|
|
@@ -42,7 +61,10 @@ let HL7ClientComponent = class HL7ClientComponent extends ComponentBase {
|
|
|
42
61
|
});
|
|
43
62
|
}
|
|
44
63
|
this.client.on('connect', () => {
|
|
45
|
-
this._address = {
|
|
64
|
+
this._address = {
|
|
65
|
+
address: this.values.host || '127.0.0.1',
|
|
66
|
+
port: this.client.remotePort,
|
|
67
|
+
};
|
|
46
68
|
this._address.toString = function () {
|
|
47
69
|
return `${this.address}:${this.port}`;
|
|
48
70
|
}.bind(this._address);
|
|
@@ -76,24 +98,8 @@ let HL7ClientComponent = class HL7ClientComponent extends ComponentBase {
|
|
|
76
98
|
this.client.on('data', data => {
|
|
77
99
|
this.emit('data', data, this._address);
|
|
78
100
|
});
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (communicationLogs) {
|
|
82
|
-
const transmitLogger = (this.transmitLogger = new TransmitLogger({
|
|
83
|
-
...communicationLogs,
|
|
84
|
-
logDirectory: dataDirectory
|
|
85
|
-
? path.join(dataDirectory, 'comm-logs')
|
|
86
|
-
: undefined,
|
|
87
|
-
name: this.path.replace(/\//g, '-'),
|
|
88
|
-
maxFiles: communicationLogs?.maxFiles,
|
|
89
|
-
maxFileSize: communicationLogs?.maxFileSize,
|
|
90
|
-
}));
|
|
91
|
-
this.on('data', (data, info) => {
|
|
92
|
-
transmitLogger.received(data, info);
|
|
93
|
-
});
|
|
94
|
-
this.on('transmit', (data, info) => {
|
|
95
|
-
transmitLogger.transmitted(data, info);
|
|
96
|
-
});
|
|
101
|
+
if (!isStopped) {
|
|
102
|
+
await this._start(new AbortController().signal);
|
|
97
103
|
}
|
|
98
104
|
}
|
|
99
105
|
catch (err) {
|
|
@@ -101,6 +107,23 @@ let HL7ClientComponent = class HL7ClientComponent extends ComponentBase {
|
|
|
101
107
|
this.setStatus(ServiceStatus.unhealthy, err.message);
|
|
102
108
|
}
|
|
103
109
|
}
|
|
110
|
+
_configureTransmitLogger() {
|
|
111
|
+
const { communicationLogs } = this.values;
|
|
112
|
+
const { dataDirectory } = this.processor;
|
|
113
|
+
if (this.transmitLogger)
|
|
114
|
+
this.transmitLogger.close();
|
|
115
|
+
if (communicationLogs) {
|
|
116
|
+
this.transmitLogger = new TransmitLogger({
|
|
117
|
+
...communicationLogs,
|
|
118
|
+
logDirectory: dataDirectory
|
|
119
|
+
? path.join(dataDirectory, 'comm-logs')
|
|
120
|
+
: undefined,
|
|
121
|
+
name: this.path.replace(/\//g, '-'),
|
|
122
|
+
maxFiles: communicationLogs?.maxFiles,
|
|
123
|
+
maxFileSize: communicationLogs?.maxFileSize,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
104
127
|
async _start(abortSignal) {
|
|
105
128
|
await super._start(abortSignal);
|
|
106
129
|
this._stopping = false;
|
|
@@ -110,7 +133,7 @@ let HL7ClientComponent = class HL7ClientComponent extends ComponentBase {
|
|
|
110
133
|
}
|
|
111
134
|
async _stop() {
|
|
112
135
|
this._stopping = true;
|
|
113
|
-
await this.client
|
|
136
|
+
await this.client?.close(30000);
|
|
114
137
|
return super._stop();
|
|
115
138
|
}
|
|
116
139
|
use(handler, priority) {
|
|
@@ -16,6 +16,8 @@ export declare class HL7ServerComponent<TEvents extends HL7ServerComponent.Event
|
|
|
16
16
|
protected _init(): Promise<void>;
|
|
17
17
|
protected _start(abortSignal: AbortSignal): Promise<void>;
|
|
18
18
|
protected _stop(): Promise<void>;
|
|
19
|
+
protected _configureTransmitLogger(): void;
|
|
20
|
+
protected _configureServer(): Promise<void>;
|
|
19
21
|
use(handler: HL7Middleware, priority?: number): void;
|
|
20
22
|
}
|
|
21
23
|
/**
|
|
@@ -14,6 +14,49 @@ let HL7ServerComponent = class HL7ServerComponent extends ComponentBase {
|
|
|
14
14
|
transmitLogger;
|
|
15
15
|
async _init() {
|
|
16
16
|
await super._init();
|
|
17
|
+
this.on('data', (data, info) => {
|
|
18
|
+
this.transmitLogger?.received(data, info);
|
|
19
|
+
});
|
|
20
|
+
this.on('transmit', (data, info) => {
|
|
21
|
+
this.transmitLogger?.transmitted(data, info);
|
|
22
|
+
});
|
|
23
|
+
this.on('values-updated', async () => {
|
|
24
|
+
await this._configureServer();
|
|
25
|
+
this._configureTransmitLogger();
|
|
26
|
+
});
|
|
27
|
+
await this._configureServer();
|
|
28
|
+
this._configureTransmitLogger();
|
|
29
|
+
}
|
|
30
|
+
async _start(abortSignal) {
|
|
31
|
+
this._stopping = false;
|
|
32
|
+
await this.server.listen(this.values.port);
|
|
33
|
+
await super._start(abortSignal);
|
|
34
|
+
}
|
|
35
|
+
async _stop() {
|
|
36
|
+
this._stopping = true;
|
|
37
|
+
await this.server.close(30000);
|
|
38
|
+
}
|
|
39
|
+
_configureTransmitLogger() {
|
|
40
|
+
const { communicationLogs } = this.values;
|
|
41
|
+
const { dataDirectory } = this.processor;
|
|
42
|
+
if (communicationLogs) {
|
|
43
|
+
this.transmitLogger = new TransmitLogger({
|
|
44
|
+
...communicationLogs,
|
|
45
|
+
logDirectory: dataDirectory
|
|
46
|
+
? path.join(dataDirectory, 'comm-logs')
|
|
47
|
+
: undefined,
|
|
48
|
+
name: this.path.replace(/\//g, '-'),
|
|
49
|
+
maxFiles: communicationLogs?.maxFiles,
|
|
50
|
+
maxFileSize: communicationLogs?.maxFileSize,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async _configureServer() {
|
|
55
|
+
const isStopped = this.stopped;
|
|
56
|
+
if (!isStopped)
|
|
57
|
+
await this._stop();
|
|
58
|
+
if (this.server)
|
|
59
|
+
await this.server.close();
|
|
17
60
|
try {
|
|
18
61
|
if (this.values.tls) {
|
|
19
62
|
this.server = HL7Server.createTlsServer(this.values.tls);
|
|
@@ -86,39 +129,14 @@ let HL7ServerComponent = class HL7ServerComponent extends ComponentBase {
|
|
|
86
129
|
};
|
|
87
130
|
this.emit('transmit', data, info, socket);
|
|
88
131
|
});
|
|
89
|
-
const { communicationLogs } = this.values;
|
|
90
|
-
const { dataDirectory } = this.processor;
|
|
91
|
-
if (communicationLogs) {
|
|
92
|
-
const transmitLogger = (this.transmitLogger = new TransmitLogger({
|
|
93
|
-
...communicationLogs,
|
|
94
|
-
logDirectory: dataDirectory
|
|
95
|
-
? path.join(dataDirectory, 'comm-logs')
|
|
96
|
-
: undefined,
|
|
97
|
-
name: this.path.replace(/\//g, '-'),
|
|
98
|
-
maxFiles: communicationLogs?.maxFiles,
|
|
99
|
-
maxFileSize: communicationLogs?.maxFileSize,
|
|
100
|
-
}));
|
|
101
|
-
this.on('data', (data, info) => {
|
|
102
|
-
transmitLogger.received(data, info);
|
|
103
|
-
});
|
|
104
|
-
this.on('transmit', (data, info) => {
|
|
105
|
-
transmitLogger.transmitted(data, info);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
132
|
}
|
|
109
133
|
catch (err) {
|
|
110
134
|
this.logger?.error(err);
|
|
111
135
|
this.setStatus(ServiceStatus.unhealthy, err.message);
|
|
112
136
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
await this.server.listen(this.values.port);
|
|
117
|
-
await super._start(abortSignal);
|
|
118
|
-
}
|
|
119
|
-
async _stop() {
|
|
120
|
-
this._stopping = true;
|
|
121
|
-
await this.server.close(30000);
|
|
137
|
+
if (!isStopped) {
|
|
138
|
+
await this._start(new AbortController().signal);
|
|
139
|
+
}
|
|
122
140
|
}
|
|
123
141
|
use(handler, priority) {
|
|
124
142
|
return this.server.use(handler, priority);
|
package/constants.js
CHANGED
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syncbridge/hl7",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.19",
|
|
4
4
|
"description": "SyncBridge HL7 connection components",
|
|
5
5
|
"author": "Panates Inc",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"ansi-colors": "^4.1.3",
|
|
9
9
|
"fast-tokenizer": "^1.9.0",
|
|
10
|
-
"hl7v2": "^1.
|
|
11
|
-
"hl7v2-net": "^1.
|
|
10
|
+
"hl7v2": "^1.8.0",
|
|
11
|
+
"hl7v2-net": "^1.8.0",
|
|
12
12
|
"node-events-async": "^1.5.0"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@syncbridge/common": "^0.
|
|
16
|
-
"@syncbridge/builtins": "^0.4.
|
|
17
|
-
"@syncbridge/net": "^0.4.
|
|
15
|
+
"@syncbridge/common": "^0.6.0",
|
|
16
|
+
"@syncbridge/builtins": "^0.4.19",
|
|
17
|
+
"@syncbridge/net": "^0.4.19"
|
|
18
18
|
},
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|