fastify-hl7 1.0.0-beta.1 → 1.0.0-beta.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/lib/cjs/class/hL7Client.js +29 -0
- package/lib/cjs/class/hL7Server.js +24 -0
- package/lib/cjs/index.js +19 -1
- package/lib/esm/class/hL7Client.js +29 -0
- package/lib/esm/class/hL7Server.js +24 -0
- package/lib/esm/index.js +19 -1
- package/lib/types/class/hL7Client.d.ts +14 -2
- package/lib/types/class/hL7Server.d.ts +12 -0
- package/lib/types/types.d.ts +43 -15
- package/package.json +7 -7
|
@@ -165,6 +165,7 @@ var HL7Client = /** @class */ (function () {
|
|
|
165
165
|
client: client,
|
|
166
166
|
ports: []
|
|
167
167
|
});
|
|
168
|
+
return client;
|
|
168
169
|
};
|
|
169
170
|
/**
|
|
170
171
|
* Create an HL7 Outbound Connection
|
|
@@ -196,6 +197,34 @@ var HL7Client = /** @class */ (function () {
|
|
|
196
197
|
}
|
|
197
198
|
throw new errors_1.errors.FASTIFY_HL7_ERR_USAGE('No valid client. Improper setup of a outbound connection.');
|
|
198
199
|
};
|
|
200
|
+
/**
|
|
201
|
+
* Get Client by the name
|
|
202
|
+
* @since 1.0.0
|
|
203
|
+
* @param name
|
|
204
|
+
*/
|
|
205
|
+
HL7Client.prototype.getClientByName = function (name) {
|
|
206
|
+
var connection = this._clientConnections.find(function (connection) { return connection.name === name; });
|
|
207
|
+
if (typeof connection !== 'undefined') {
|
|
208
|
+
return connection.client;
|
|
209
|
+
}
|
|
210
|
+
return undefined;
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Get Connection by Port
|
|
214
|
+
* @since 1.0.0
|
|
215
|
+
* @param port
|
|
216
|
+
*/
|
|
217
|
+
HL7Client.prototype.getClientConnectionByPort = function (port) {
|
|
218
|
+
var connection;
|
|
219
|
+
this._clientConnections.forEach(function (outbound) {
|
|
220
|
+
outbound.ports.forEach(function (aPort) {
|
|
221
|
+
if (aPort.port === port) {
|
|
222
|
+
connection = aPort.connection;
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
return connection;
|
|
227
|
+
};
|
|
199
228
|
/**
|
|
200
229
|
* Process a HL7
|
|
201
230
|
* @description A HL7 message that could either be a Message (MSH) or Batch (BHS)
|
|
@@ -106,6 +106,30 @@ var HL7Server = /** @class */ (function () {
|
|
|
106
106
|
});
|
|
107
107
|
return inbound;
|
|
108
108
|
};
|
|
109
|
+
/**
|
|
110
|
+
* Get Server Inbound Connection by Name
|
|
111
|
+
* @since 1.0.0
|
|
112
|
+
* @param name
|
|
113
|
+
*/
|
|
114
|
+
HL7Server.prototype.getServerByName = function (name) {
|
|
115
|
+
var inbound = this._serverInboundConnections.find(function (inbound) { return inbound.name === name; });
|
|
116
|
+
if (typeof inbound !== 'undefined') {
|
|
117
|
+
return inbound.server;
|
|
118
|
+
}
|
|
119
|
+
return undefined;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Get Server Inbound Connection by Port
|
|
123
|
+
* @since 1.0.0
|
|
124
|
+
* @param port
|
|
125
|
+
*/
|
|
126
|
+
HL7Server.prototype.getServerByPort = function (port) {
|
|
127
|
+
var inbound = this._serverInboundConnections.find(function (inbound) { return inbound.port === port; });
|
|
128
|
+
if (typeof inbound !== 'undefined') {
|
|
129
|
+
return inbound.server;
|
|
130
|
+
}
|
|
131
|
+
return undefined;
|
|
132
|
+
};
|
|
109
133
|
return HL7Server;
|
|
110
134
|
}());
|
|
111
135
|
exports.HL7Server = HL7Server;
|
package/lib/cjs/index.js
CHANGED
|
@@ -164,7 +164,7 @@ var fastifyHL7 = (0, fastify_plugin_1.default)(function (fastify, opts) { return
|
|
|
164
164
|
});
|
|
165
165
|
}); },
|
|
166
166
|
createClient: function (name, props) {
|
|
167
|
-
client.createClient(name, props);
|
|
167
|
+
return client.createClient(name, props);
|
|
168
168
|
},
|
|
169
169
|
createInbound: function (name, props, handler) {
|
|
170
170
|
if (typeof server !== 'undefined') {
|
|
@@ -175,6 +175,24 @@ var fastifyHL7 = (0, fastify_plugin_1.default)(function (fastify, opts) { return
|
|
|
175
175
|
createOutbound: function (name, props, handler) {
|
|
176
176
|
return client.createOutbound(name, props, handler);
|
|
177
177
|
},
|
|
178
|
+
getClientByName: function (name) {
|
|
179
|
+
return client.getClientByName(name);
|
|
180
|
+
},
|
|
181
|
+
getClientConnectionByPort: function (port) {
|
|
182
|
+
return client.getClientConnectionByPort(port);
|
|
183
|
+
},
|
|
184
|
+
getServerByName: function (name) {
|
|
185
|
+
if (typeof server !== 'undefined') {
|
|
186
|
+
return server.getServerByName(name);
|
|
187
|
+
}
|
|
188
|
+
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('server was not started. re-register plugin with enableServer set to true.');
|
|
189
|
+
},
|
|
190
|
+
getServerByPort: function (port) {
|
|
191
|
+
if (typeof server !== 'undefined') {
|
|
192
|
+
return server.getServerByPort(port);
|
|
193
|
+
}
|
|
194
|
+
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('server was not started. re-register plugin with enableServer set to true.');
|
|
195
|
+
},
|
|
178
196
|
processHL7: function (text) {
|
|
179
197
|
return client.processHL7(text);
|
|
180
198
|
},
|
|
@@ -82,6 +82,7 @@ export class HL7Client {
|
|
|
82
82
|
client,
|
|
83
83
|
ports: []
|
|
84
84
|
});
|
|
85
|
+
return client;
|
|
85
86
|
}
|
|
86
87
|
/**
|
|
87
88
|
* Create an HL7 Outbound Connection
|
|
@@ -113,6 +114,34 @@ export class HL7Client {
|
|
|
113
114
|
}
|
|
114
115
|
throw new errors.FASTIFY_HL7_ERR_USAGE('No valid client. Improper setup of a outbound connection.');
|
|
115
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Get Client by the name
|
|
119
|
+
* @since 1.0.0
|
|
120
|
+
* @param name
|
|
121
|
+
*/
|
|
122
|
+
getClientByName(name) {
|
|
123
|
+
const connection = this._clientConnections.find(connection => connection.name === name);
|
|
124
|
+
if (typeof connection !== 'undefined') {
|
|
125
|
+
return connection.client;
|
|
126
|
+
}
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Get Connection by Port
|
|
131
|
+
* @since 1.0.0
|
|
132
|
+
* @param port
|
|
133
|
+
*/
|
|
134
|
+
getClientConnectionByPort(port) {
|
|
135
|
+
let connection;
|
|
136
|
+
this._clientConnections.forEach(outbound => {
|
|
137
|
+
outbound.ports.forEach(aPort => {
|
|
138
|
+
if (aPort.port === port) {
|
|
139
|
+
connection = aPort.connection;
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
return connection;
|
|
144
|
+
}
|
|
116
145
|
/**
|
|
117
146
|
* Process a HL7
|
|
118
147
|
* @description A HL7 message that could either be a Message (MSH) or Batch (BHS)
|
|
@@ -49,4 +49,28 @@ export class HL7Server {
|
|
|
49
49
|
});
|
|
50
50
|
return inbound;
|
|
51
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Get Server Inbound Connection by Name
|
|
54
|
+
* @since 1.0.0
|
|
55
|
+
* @param name
|
|
56
|
+
*/
|
|
57
|
+
getServerByName(name) {
|
|
58
|
+
const inbound = this._serverInboundConnections.find(inbound => inbound.name === name);
|
|
59
|
+
if (typeof inbound !== 'undefined') {
|
|
60
|
+
return inbound.server;
|
|
61
|
+
}
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Get Server Inbound Connection by Port
|
|
66
|
+
* @since 1.0.0
|
|
67
|
+
* @param port
|
|
68
|
+
*/
|
|
69
|
+
getServerByPort(port) {
|
|
70
|
+
const inbound = this._serverInboundConnections.find(inbound => inbound.port === port);
|
|
71
|
+
if (typeof inbound !== 'undefined') {
|
|
72
|
+
return inbound.server;
|
|
73
|
+
}
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
52
76
|
}
|
package/lib/esm/index.js
CHANGED
|
@@ -74,7 +74,7 @@ const fastifyHL7 = fp(async (fastify, opts) => {
|
|
|
74
74
|
throw new errors.FASTIFY_HL7_ERR_USAGE('server was not started. re-register plugin with enableServer set to true.');
|
|
75
75
|
},
|
|
76
76
|
createClient: function (name, props) {
|
|
77
|
-
client.createClient(name, props);
|
|
77
|
+
return client.createClient(name, props);
|
|
78
78
|
},
|
|
79
79
|
createInbound: function (name, props, handler) {
|
|
80
80
|
if (typeof server !== 'undefined') {
|
|
@@ -85,6 +85,24 @@ const fastifyHL7 = fp(async (fastify, opts) => {
|
|
|
85
85
|
createOutbound: function (name, props, handler) {
|
|
86
86
|
return client.createOutbound(name, props, handler);
|
|
87
87
|
},
|
|
88
|
+
getClientByName: function (name) {
|
|
89
|
+
return client.getClientByName(name);
|
|
90
|
+
},
|
|
91
|
+
getClientConnectionByPort: function (port) {
|
|
92
|
+
return client.getClientConnectionByPort(port);
|
|
93
|
+
},
|
|
94
|
+
getServerByName: function (name) {
|
|
95
|
+
if (typeof server !== 'undefined') {
|
|
96
|
+
return server.getServerByName(name);
|
|
97
|
+
}
|
|
98
|
+
throw new errors.FASTIFY_HL7_ERR_USAGE('server was not started. re-register plugin with enableServer set to true.');
|
|
99
|
+
},
|
|
100
|
+
getServerByPort: function (port) {
|
|
101
|
+
if (typeof server !== 'undefined') {
|
|
102
|
+
return server.getServerByPort(port);
|
|
103
|
+
}
|
|
104
|
+
throw new errors.FASTIFY_HL7_ERR_USAGE('server was not started. re-register plugin with enableServer set to true.');
|
|
105
|
+
},
|
|
88
106
|
processHL7: function (text) {
|
|
89
107
|
return client.processHL7(text);
|
|
90
108
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { Batch, ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuilderOptions, ClientListenerOptions, ClientOptions, FileBatch, HL7Outbound, Message, OutboundHandler } from 'node-hl7-client';
|
|
2
|
+
import Client, { Batch, ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuilderOptions, ClientListenerOptions, ClientOptions, FileBatch, HL7Outbound, Message, OutboundHandler } from 'node-hl7-client';
|
|
3
3
|
export declare class HL7Client {
|
|
4
4
|
constructor();
|
|
5
5
|
/**
|
|
@@ -33,7 +33,7 @@ export declare class HL7Client {
|
|
|
33
33
|
* @param name
|
|
34
34
|
* @param props
|
|
35
35
|
*/
|
|
36
|
-
createClient(name: string, props: ClientOptions):
|
|
36
|
+
createClient(name: string, props: ClientOptions): Client;
|
|
37
37
|
/**
|
|
38
38
|
* Create an HL7 Outbound Connection
|
|
39
39
|
* @description Connect to an HL7 Server/Broker
|
|
@@ -43,6 +43,18 @@ export declare class HL7Client {
|
|
|
43
43
|
* @param handler
|
|
44
44
|
*/
|
|
45
45
|
createOutbound(name: string, props: ClientListenerOptions, handler: OutboundHandler): HL7Outbound;
|
|
46
|
+
/**
|
|
47
|
+
* Get Client by the name
|
|
48
|
+
* @since 1.0.0
|
|
49
|
+
* @param name
|
|
50
|
+
*/
|
|
51
|
+
getClientByName(name: string): Client | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Get Connection by Port
|
|
54
|
+
* @since 1.0.0
|
|
55
|
+
* @param port
|
|
56
|
+
*/
|
|
57
|
+
getClientConnectionByPort(port: string): HL7Outbound | undefined;
|
|
46
58
|
/**
|
|
47
59
|
* Process a HL7
|
|
48
60
|
* @description A HL7 message that could either be a Message (MSH) or Batch (BHS)
|
|
@@ -22,4 +22,16 @@ export declare class HL7Server {
|
|
|
22
22
|
* @param handler
|
|
23
23
|
*/
|
|
24
24
|
createInbound(name: string, props: ListenerOptions, handler: InboundHandler): HL7Inbound;
|
|
25
|
+
/**
|
|
26
|
+
* Get Server Inbound Connection by Name
|
|
27
|
+
* @since 1.0.0
|
|
28
|
+
* @param name
|
|
29
|
+
*/
|
|
30
|
+
getServerByName(name: string): HL7Inbound | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Get Server Inbound Connection by Port
|
|
33
|
+
* @since 1.0.0
|
|
34
|
+
* @param port
|
|
35
|
+
*/
|
|
36
|
+
getServerByPort(port: string): HL7Inbound | undefined;
|
|
25
37
|
}
|
package/lib/types/types.d.ts
CHANGED
|
@@ -1,35 +1,63 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import Server, { HL7Inbound, InboundHandler, ListenerOptions } from 'node-hl7-server';
|
|
3
|
-
import { Batch, ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuilderOptions, ClientListenerOptions, ClientOptions, FileBatch, HL7Outbound, Message, OutboundHandler } from 'node-hl7-client';
|
|
3
|
+
import Client, { Batch, ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuilderOptions, ClientListenerOptions, ClientOptions, FileBatch, HL7Outbound, Message, OutboundHandler } from 'node-hl7-client';
|
|
4
4
|
declare module 'fastify' {
|
|
5
5
|
interface HL7 {
|
|
6
|
-
/** Server Instance
|
|
6
|
+
/** Server Instance
|
|
7
|
+
* @since 1.0.0 **/
|
|
7
8
|
_serverInstance?: Server;
|
|
8
|
-
/**
|
|
9
|
+
/** Build HL7 Batch
|
|
10
|
+
* @since 1.0.0 */
|
|
9
11
|
buildBatch: (props?: ClientBuilderOptions) => Batch;
|
|
10
|
-
/**
|
|
12
|
+
/** Build HL7 File Batch
|
|
13
|
+
* @since 1.0.0 */
|
|
11
14
|
buildFileBatch: (props?: ClientBuilderFileOptions) => FileBatch;
|
|
12
|
-
/**
|
|
15
|
+
/** Build HL7 Message
|
|
16
|
+
* @since 1.0.0 */
|
|
13
17
|
buildMessage: (props?: ClientBuilderMessageOptions) => Message;
|
|
14
|
-
/**
|
|
18
|
+
/** Close a incoming HL7 port.
|
|
19
|
+
* @since 1.0.0 */
|
|
15
20
|
closeServer: (port: string) => Promise<boolean>;
|
|
16
|
-
/**
|
|
21
|
+
/** Close all incoming HL7 ports.
|
|
22
|
+
* @since 1.0.0 */
|
|
17
23
|
closeServerAll: () => Promise<boolean>;
|
|
18
|
-
/** Create Client
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
/** Create Client
|
|
25
|
+
* @description Connecting to a remote server/broker that accepts connections.
|
|
26
|
+
* @since 1.0.0 */
|
|
27
|
+
createClient: (name: string, props: ClientOptions) => Client;
|
|
28
|
+
/** Create an incoming port connection on the server.
|
|
29
|
+
* @since 1.0.0 */
|
|
21
30
|
createInbound: (name: string, props: ListenerOptions, handler: InboundHandler) => HL7Inbound;
|
|
22
|
-
/** Create Outgoing Client Port
|
|
31
|
+
/** Create Outgoing Client Port
|
|
32
|
+
* @description This is on the established client that we are already a part off.
|
|
33
|
+
* @since 1.0.0 */
|
|
23
34
|
createOutbound: (name: string, props: ClientListenerOptions, handler: OutboundHandler) => HL7Outbound;
|
|
24
|
-
/**
|
|
35
|
+
/** Get Client (Outbound) connection by name.
|
|
36
|
+
* @since 1.0.0 */
|
|
37
|
+
getClientByName: (name: string) => Client | undefined;
|
|
38
|
+
/** Get Client Connection (Outbound) connection by port.
|
|
39
|
+
* @since 1.0.0 */
|
|
40
|
+
getClientConnectionByPort: (port: string) => HL7Outbound | undefined;
|
|
41
|
+
/** Get Server (Inbound) connection by port.
|
|
42
|
+
* @since 1.0.0 */
|
|
43
|
+
getServerByPort: (port: string) => HL7Inbound | undefined;
|
|
44
|
+
/** Get Server (Inbound) connection by name.
|
|
45
|
+
* @since 1.0.0 */
|
|
46
|
+
getServerByName: (name: string) => HL7Inbound | undefined;
|
|
47
|
+
/** Process an HL7 string.
|
|
48
|
+
* @since 1.0.0 */
|
|
25
49
|
processHL7: (text: string) => Message | Batch;
|
|
26
|
-
/**
|
|
50
|
+
/** Read a file from a path.
|
|
51
|
+
* @since 1.0.0 */
|
|
27
52
|
readFile: (fullFilePath: string) => FileBatch;
|
|
28
|
-
/**
|
|
53
|
+
/** Read a buffer that was a file batch.
|
|
54
|
+
* @since 1.0.0 */
|
|
29
55
|
readFileBuffer: (fileBuffer: Buffer) => FileBatch;
|
|
30
56
|
}
|
|
31
57
|
interface FastifyInstance {
|
|
32
|
-
/** Main Decorator for Fastify
|
|
58
|
+
/** Main Decorator for Fastify
|
|
59
|
+
* @description hl7 is the decorator that everything hangs off.
|
|
60
|
+
* @since 1.0.0 **/
|
|
33
61
|
hl7: HL7;
|
|
34
62
|
}
|
|
35
63
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fastify-hl7",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
4
4
|
"description": "A Fastify HL7 Plugin Developed in Pure TypeScript.",
|
|
5
5
|
"module": "./lib/esm/index.js",
|
|
6
6
|
"main": "./lib/cjs/index.js",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@fastify/error": "^3.4.1",
|
|
62
62
|
"fastify-plugin": "^4.5.1",
|
|
63
|
-
"node-hl7-client": "^1.1.
|
|
64
|
-
"node-hl7-server": "^1.
|
|
63
|
+
"node-hl7-client": "^1.1.2",
|
|
64
|
+
"node-hl7-server": "^1.2.1"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@semantic-release/changelog": "^6.0.3",
|
|
@@ -70,10 +70,10 @@
|
|
|
70
70
|
"@semantic-release/release-notes-generator": "^12.1.0",
|
|
71
71
|
"@the-rabbit-hole/semantic-release-config": "^1.4.0",
|
|
72
72
|
"@types/jest": "^29.5.11",
|
|
73
|
-
"@types/node": "^20.10.
|
|
73
|
+
"@types/node": "^20.10.8",
|
|
74
74
|
"@types/randomstring": "^1.1.11",
|
|
75
75
|
"@types/tcp-port-used": "^1.0.4",
|
|
76
|
-
"@typescript-eslint/parser": "^6.
|
|
76
|
+
"@typescript-eslint/parser": "^6.18.1",
|
|
77
77
|
"clean-publish": "^4.2.0",
|
|
78
78
|
"fastify": "^4.25.2",
|
|
79
79
|
"jest": "^29.7.0",
|
|
@@ -88,8 +88,8 @@
|
|
|
88
88
|
"ts-jest": "^29.1.1",
|
|
89
89
|
"ts-node": "^10.9.2",
|
|
90
90
|
"ts-standard": "^12.0.2",
|
|
91
|
-
"tsd": "^0.30.
|
|
92
|
-
"typedoc": "^0.25.
|
|
91
|
+
"tsd": "^0.30.3",
|
|
92
|
+
"typedoc": "^0.25.7",
|
|
93
93
|
"typescript": "^5.3.3"
|
|
94
94
|
},
|
|
95
95
|
"pre-commit": []
|