fastify-hl7 2.1.0 → 3.0.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/lib/cjs/index.js CHANGED
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
3
  if (k2 === undefined) k2 = k;
15
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -24,52 +13,16 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
24
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
25
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
26
15
  };
27
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
28
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
29
- return new (P || (P = Promise))(function (resolve, reject) {
30
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
31
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
32
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
33
- step((generator = generator.apply(thisArg, _arguments || [])).next());
34
- });
35
- };
36
- var __generator = (this && this.__generator) || function (thisArg, body) {
37
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
38
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
39
- function verb(n) { return function (v) { return step([n, v]); }; }
40
- function step(op) {
41
- if (f) throw new TypeError("Generator is already executing.");
42
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
43
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
44
- if (y = 0, t) op = [op[0] & 2, t.value];
45
- switch (op[0]) {
46
- case 0: case 1: t = op; break;
47
- case 4: _.label++; return { value: op[1], done: false };
48
- case 5: _.label++; y = op[1]; op = [0]; continue;
49
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
50
- default:
51
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
52
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
53
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
54
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
55
- if (t[2]) _.ops.pop();
56
- _.trys.pop(); continue;
57
- }
58
- op = body.call(thisArg, _);
59
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
60
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
61
- }
62
- };
63
16
  var __importDefault = (this && this.__importDefault) || function (mod) {
64
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
65
18
  };
66
19
  Object.defineProperty(exports, "__esModule", { value: true });
67
- var fastify_plugin_1 = __importDefault(require("fastify-plugin"));
68
- var node_hl7_server_1 = __importDefault(require("node-hl7-server"));
69
- var hL7Server_js_1 = require("./class/hL7Server.js");
70
- var hL7Client_js_1 = require("./class/hL7Client.js");
71
- var errors_js_1 = require("./errors.js");
72
- var validation_js_1 = require("./validation.js");
20
+ const fastify_plugin_1 = __importDefault(require("fastify-plugin"));
21
+ const node_hl7_server_1 = __importDefault(require("node-hl7-server"));
22
+ const hL7Server_js_1 = require("./class/hL7Server.js");
23
+ const hL7Client_js_1 = require("./class/hL7Client.js");
24
+ const errors_js_1 = require("./errors.js");
25
+ const validation_js_1 = require("./validation.js");
73
26
  __exportStar(require("./types.js"), exports);
74
27
  /**
75
28
  * @since 1.0.0
@@ -77,7 +30,7 @@ __exportStar(require("./types.js"), exports);
77
30
  * @param _opts
78
31
  * @param connection
79
32
  */
80
- var decorateFastifyInstance = function (fastify, _opts, connection) {
33
+ const decorateFastifyInstance = (fastify, _opts, connection) => {
81
34
  if (typeof fastify.hl7 !== 'undefined') {
82
35
  throw new errors_js_1.errors.FASTIFY_HL7_ERR_SETUP_ERRORS('Already registered.');
83
36
  }
@@ -86,128 +39,101 @@ var decorateFastifyInstance = function (fastify, _opts, connection) {
86
39
  fastify.decorate('hl7', connection);
87
40
  }
88
41
  };
89
- var fastifyHL7 = (0, fastify_plugin_1.default)(function (fastify, opts) { return __awaiter(void 0, void 0, void 0, function () {
90
- var generatedOpts, serverInstance, server, client;
91
- return __generator(this, function (_a) {
92
- switch (_a.label) {
93
- case 0: return [4 /*yield*/, (0, validation_js_1.validateOpts)(opts)];
94
- case 1:
95
- generatedOpts = _a.sent();
96
- opts = __assign(__assign({}, opts), generatedOpts);
97
- serverInstance = (typeof opts.enableServer !== 'undefined' && opts.enableServer) ? new node_hl7_server_1.default(opts.serverOptions) : undefined;
98
- if (typeof serverInstance !== 'undefined') {
99
- // Server Functions
100
- server = new hL7Server_js_1.HL7Server(serverInstance);
101
- // before we close fastify, make sure all server instances are closed
102
- fastify.addHook('preClose', function () { return __awaiter(void 0, void 0, void 0, function () {
103
- return __generator(this, function (_a) {
104
- switch (_a.label) {
105
- case 0:
106
- if (!(typeof server !== 'undefined')) return [3 /*break*/, 2];
107
- return [4 /*yield*/, server.closeAll()];
108
- case 1:
109
- _a.sent();
110
- _a.label = 2;
111
- case 2: return [2 /*return*/];
112
- }
113
- });
114
- }); });
115
- }
116
- client = new hL7Client_js_1.HL7Client();
117
- // run these before fastify closes
118
- fastify.addHook('preClose', function () { return __awaiter(void 0, void 0, void 0, function () {
119
- return __generator(this, function (_a) {
120
- switch (_a.label) {
121
- case 0:
122
- if (!(typeof client !== 'undefined')) return [3 /*break*/, 2];
123
- return [4 /*yield*/, client.closeAll()];
124
- case 1:
125
- _a.sent();
126
- _a.label = 2;
127
- case 2: return [2 /*return*/];
128
- }
129
- });
130
- }); });
131
- decorateFastifyInstance(fastify, opts, {
132
- _serverInstance: serverInstance,
133
- buildBatch: function (props) {
134
- return client.buildBatch(props);
135
- },
136
- buildDate: function (date, length) {
137
- return client.buildDate(date, length);
138
- },
139
- buildFileBatch: function (props) {
140
- return client.buildFileBatch(props);
141
- },
142
- buildMessage: function (props) {
143
- return client.buildMessage(props);
144
- },
145
- closeServer: function (port) {
146
- return __awaiter(this, void 0, void 0, function () {
147
- return __generator(this, function (_a) {
148
- switch (_a.label) {
149
- case 0:
150
- if (!(typeof server !== 'undefined')) return [3 /*break*/, 2];
151
- return [4 /*yield*/, server.close(port)];
152
- case 1: return [2 /*return*/, _a.sent()];
153
- case 2: throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('server was not started. re-register plugin with enableServer set to true.');
154
- }
155
- });
156
- });
157
- },
158
- closeServerAll: function () { return __awaiter(void 0, void 0, void 0, function () {
159
- return __generator(this, function (_a) {
160
- switch (_a.label) {
161
- case 0:
162
- if (!(typeof server !== 'undefined')) return [3 /*break*/, 2];
163
- return [4 /*yield*/, server.closeAll()];
164
- case 1: return [2 /*return*/, _a.sent()];
165
- case 2: throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('server was not started. re-register plugin with enableServer set to true.');
166
- }
167
- });
168
- }); },
169
- createClient: function (name, props) {
170
- return client.createClient(name, props);
171
- },
172
- createInbound: function (name, props, handler) {
173
- if (typeof server !== 'undefined') {
174
- return server.createInbound(name, props, handler);
175
- }
176
- throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('server was not started. re-register plugin with enableServer set to true.');
177
- },
178
- createConnection: function (name, props, handler) {
179
- return client.createConnection(name, props, handler);
180
- },
181
- getClientByName: function (name) {
182
- return client.getClientByName(name);
183
- },
184
- getClientConnectionByPort: function (port) {
185
- return client.getClientConnectionByPort(port);
186
- },
187
- getServerByName: function (name) {
188
- if (typeof server !== 'undefined') {
189
- return server.getServerByName(name);
190
- }
191
- throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('server was not started. re-register plugin with enableServer set to true.');
192
- },
193
- getServerByPort: function (port) {
194
- if (typeof server !== 'undefined') {
195
- return server.getServerByPort(port);
196
- }
197
- throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('server was not started. re-register plugin with enableServer set to true.');
198
- },
199
- processHL7: function (text) {
200
- return client.processHL7(text);
201
- },
202
- readFile: function (fullFilePath) {
203
- return client.readFile(fullFilePath);
204
- },
205
- readFileBuffer: function (fileBuffer) {
206
- return client.readFileBuffer(fileBuffer);
207
- }
208
- });
209
- return [2 /*return*/];
42
+ const fastifyHL7 = (0, fastify_plugin_1.default)(async (fastify, opts) => {
43
+ const generatedOpts = await (0, validation_js_1.validateOpts)(opts);
44
+ opts = { ...opts, ...generatedOpts };
45
+ // Create server.
46
+ // Since there can only be one server per IP address
47
+ // (i.e., the host this is running on.) There can only be more than one.
48
+ // A server can host many HL7 Inbound connections via different ports, this is fine.
49
+ // Clients are different as an app could talk to different servers, on many ports.
50
+ // So we need to do something different.
51
+ const serverInstance = (typeof opts.enableServer !== 'undefined' && opts.enableServer) ? new node_hl7_server_1.default(opts.serverOptions) : undefined;
52
+ // Server Functions
53
+ let server;
54
+ if (typeof serverInstance !== 'undefined') {
55
+ // Server Functions
56
+ server = new hL7Server_js_1.HL7Server(serverInstance);
57
+ // before we close fastify, make sure all server instances are closed
58
+ fastify.addHook('preClose', async () => {
59
+ if (typeof server !== 'undefined') {
60
+ await server.closeAll();
61
+ }
62
+ });
63
+ }
64
+ // Client Functions
65
+ const client = new hL7Client_js_1.HL7Client();
66
+ // run these before fastify closes
67
+ fastify.addHook('preClose', async () => {
68
+ if (typeof client !== 'undefined') {
69
+ await client.closeAll();
70
+ }
71
+ });
72
+ decorateFastifyInstance(fastify, opts, {
73
+ _serverInstance: serverInstance,
74
+ buildBatch: function (props) {
75
+ return client.buildBatch(props);
76
+ },
77
+ buildDate: function (date, length) {
78
+ return client.buildDate(date, length);
79
+ },
80
+ buildFileBatch: function (props) {
81
+ return client.buildFileBatch(props);
82
+ },
83
+ buildMessage: function (props) {
84
+ return client.buildMessage(props);
85
+ },
86
+ closeServer: async function (port) {
87
+ if (typeof server !== 'undefined') {
88
+ return await server.close(port);
89
+ }
90
+ throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('server was not started. re-register plugin with enableServer set to true.');
91
+ },
92
+ closeServerAll: async () => {
93
+ if (typeof server !== 'undefined') {
94
+ return await server.closeAll();
95
+ }
96
+ throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('server was not started. re-register plugin with enableServer set to true.');
97
+ },
98
+ createClient: function (name, props) {
99
+ return client.createClient(name, props);
100
+ },
101
+ createInbound: function (name, props, handler) {
102
+ if (typeof server !== 'undefined') {
103
+ return server.createInbound(name, props, handler);
104
+ }
105
+ throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('server was not started. re-register plugin with enableServer set to true.');
106
+ },
107
+ createConnection: function (name, props, handler) {
108
+ return client.createConnection(name, props, handler);
109
+ },
110
+ getClientByName: function (name) {
111
+ return client.getClientByName(name);
112
+ },
113
+ getClientConnectionByPort: function (port) {
114
+ return client.getClientConnectionByPort(port);
115
+ },
116
+ getServerByName: function (name) {
117
+ if (typeof server !== 'undefined') {
118
+ return server.getServerByName(name);
119
+ }
120
+ throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('server was not started. re-register plugin with enableServer set to true.');
121
+ },
122
+ getServerByPort: function (port) {
123
+ if (typeof server !== 'undefined') {
124
+ return server.getServerByPort(port);
125
+ }
126
+ throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('server was not started. re-register plugin with enableServer set to true.');
127
+ },
128
+ processHL7: function (text) {
129
+ return client.processHL7(text);
130
+ },
131
+ readFile: function (fullFilePath) {
132
+ return client.readFile(fullFilePath);
133
+ },
134
+ readFileBuffer: function (fileBuffer) {
135
+ return client.readFileBuffer(fileBuffer);
210
136
  }
211
137
  });
212
- }); });
138
+ });
213
139
  exports.default = fastifyHL7;
@@ -1,53 +1,15 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
2
  Object.defineProperty(exports, "__esModule", { value: true });
39
3
  exports.validateOpts = void 0;
40
4
  /**
41
5
  * @since 1.0.0
42
6
  * @param opts
43
7
  */
44
- var validateOpts = function (opts) { return __awaiter(void 0, void 0, void 0, function () {
45
- return __generator(this, function (_a) {
46
- // Mandatory, Defaulted
47
- if (typeof opts.enableServer === 'undefined') {
48
- opts.enableServer = true;
49
- }
50
- return [2 /*return*/, opts];
51
- });
52
- }); };
8
+ const validateOpts = async (opts) => {
9
+ // Mandatory, Defaulted
10
+ if (typeof opts.enableServer === 'undefined') {
11
+ opts.enableServer = true;
12
+ }
13
+ return opts;
14
+ };
53
15
  exports.validateOpts = validateOpts;
@@ -0,0 +1,7 @@
1
+ import { HL7 } from 'fastify';
2
+ import fastifyHL7 from '.';
3
+ import { AServers, FastifyHL7Options } from './decorate.js';
4
+ import { HL7Client } from './class/hL7Client.js';
5
+ import { HL7Server } from './class/hL7Server.js';
6
+ export default fastifyHL7;
7
+ export { fastifyHL7, HL7, FastifyHL7Options, HL7Client, HL7Server, AServers };
@@ -0,0 +1,99 @@
1
+ import Client, { Batch, ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuilderOptions, ClientListenerOptions, ClientOptions, FileBatch, Connection, Message, OutboundHandler } from 'node-hl7-client';
2
+ export declare class HL7Client {
3
+ /** @internal */
4
+ private readonly _clientConnections;
5
+ constructor();
6
+ /**
7
+ * Close All Connections for this Client
8
+ * @since 1.0.0
9
+ */
10
+ closeAll(): Promise<boolean>;
11
+ /**
12
+ * Build a HL7 Batch
13
+ *@remarks Create a properly formatted HL7 Batch.
14
+ * @since 1.0.0
15
+ * @param props
16
+ */
17
+ buildBatch(props?: ClientBuilderOptions): Batch;
18
+ /**
19
+ * Build Date
20
+ *@remarks Build a date string based off HL7 Standards
21
+ * @since 2.1.0
22
+ * @param date
23
+ * @param length Options are 8, 12, or 14 (default)
24
+ */
25
+ buildDate(date: Date, length?: string): string;
26
+ /**
27
+ * Build a HL7 File Batch
28
+ *@remarks Create a properly formatted HL7 File Batch.
29
+ * @since 1.0.0
30
+ * @param props
31
+ */
32
+ buildFileBatch(props?: ClientBuilderFileOptions): FileBatch;
33
+ /**
34
+ * Build a HL7 Message
35
+ *@remarks Create a properly formatted HL7 message.
36
+ * @since 1.0.0
37
+ * @param props
38
+ */
39
+ buildMessage(props?: ClientBuilderMessageOptions): Message;
40
+ /**
41
+ *
42
+ * @param name
43
+ * @param props
44
+ */
45
+ createClient(name: string, props: ClientOptions): Client;
46
+ /**
47
+ * Create an HL7 Outbound Connection
48
+ *@remarks Connect to an HL7 Server/Broker
49
+ * @since 1.0.0
50
+ * @param name The name stored within created client connections.
51
+ * @param props
52
+ * @param handler
53
+ */
54
+ createConnection(name: string, props: ClientListenerOptions, handler: OutboundHandler): Connection;
55
+ /**
56
+ * Get Client by the name
57
+ * @since 1.0.0
58
+ * @param name
59
+ */
60
+ getClientByName(name: string): Client | undefined;
61
+ /**
62
+ * Get Connection by Port
63
+ * @since 1.0.0
64
+ * @param port
65
+ */
66
+ getClientConnectionByPort(port: string): Connection | undefined;
67
+ /**
68
+ * Process a HL7
69
+ *@remarks A HL7 message that could either be a Message (MSH) or Batch (BHS)
70
+ * @since 1.0.0
71
+ * @param text Raw HL& String
72
+ */
73
+ processHL7(text: string): Message | Batch;
74
+ /**
75
+ * Read File
76
+ *@remarks Pass the correct path of the file you want to read.
77
+ * @since 1.0.0
78
+ * @param fullFilePath
79
+ * @returns FileBatch
80
+ * @example
81
+ * ```ts
82
+ * fastify.hl7.readFile( path.join('temp/', 'hl7.readTestBHS.20231208.hl7') )
83
+ * ```
84
+ */
85
+ readFile(fullFilePath: string): FileBatch;
86
+ /**
87
+ * Read a File Buffer
88
+ *@remarks Translate an already Buffered HL7 FHS segment to decode it.
89
+ * @since 1.0.0
90
+ * @param fileBuffer
91
+ * @returns FileBatch
92
+ * @example
93
+ * ```ts
94
+ * const fileBuffer = fs.readFileSync(path.join('temp/', 'hl7.readTestBHS.20231208.hl7'))
95
+ * fastify.hl7.readFileBuffer(fileBuffer)
96
+ * ```
97
+ */
98
+ readFileBuffer(fileBuffer: Buffer): FileBatch;
99
+ }
@@ -1,8 +1,6 @@
1
1
  import Client, { Batch, FileBatch, Connection, isBatch, Message, createHL7Date } from 'node-hl7-client';
2
2
  import { errors } from '../errors.js';
3
3
  export class HL7Client {
4
- /** @internal */
5
- _clientConnections;
6
4
  constructor() {
7
5
  this._clientConnections = [];
8
6
  }
@@ -20,7 +18,7 @@ export class HL7Client {
20
18
  }
21
19
  /**
22
20
  * Build a HL7 Batch
23
- * @description Create a properly formatted HL7 Batch.
21
+ *@remarks Create a properly formatted HL7 Batch.
24
22
  * @since 1.0.0
25
23
  * @param props
26
24
  */
@@ -32,7 +30,7 @@ export class HL7Client {
32
30
  }
33
31
  /**
34
32
  * Build Date
35
- * @description Build a date string based off HL7 Standards
33
+ *@remarks Build a date string based off HL7 Standards
36
34
  * @since 2.1.0
37
35
  * @param date
38
36
  * @param length Options are 8, 12, or 14 (default)
@@ -42,7 +40,7 @@ export class HL7Client {
42
40
  }
43
41
  /**
44
42
  * Build a HL7 File Batch
45
- * @description Create a properly formatted HL7 File Batch.
43
+ *@remarks Create a properly formatted HL7 File Batch.
46
44
  * @since 1.0.0
47
45
  * @param props
48
46
  */
@@ -54,7 +52,7 @@ export class HL7Client {
54
52
  }
55
53
  /**
56
54
  * Build a HL7 Message
57
- * @description Create a properly formatted HL7 message.
55
+ *@remarks Create a properly formatted HL7 message.
58
56
  * @since 1.0.0
59
57
  * @param props
60
58
  */
@@ -96,7 +94,7 @@ export class HL7Client {
96
94
  }
97
95
  /**
98
96
  * Create an HL7 Outbound Connection
99
- * @description Connect to an HL7 Server/Broker
97
+ *@remarks Connect to an HL7 Server/Broker
100
98
  * @since 1.0.0
101
99
  * @param name The name stored within created client connections.
102
100
  * @param props
@@ -154,7 +152,7 @@ export class HL7Client {
154
152
  }
155
153
  /**
156
154
  * Process a HL7
157
- * @description A HL7 message that could either be a Message (MSH) or Batch (BHS)
155
+ *@remarks A HL7 message that could either be a Message (MSH) or Batch (BHS)
158
156
  * @since 1.0.0
159
157
  * @param text Raw HL& String
160
158
  */
@@ -168,29 +166,29 @@ export class HL7Client {
168
166
  }
169
167
  /**
170
168
  * Read File
171
- * @description Pass the correct path of the file you want to read.
169
+ *@remarks Pass the correct path of the file you want to read.
172
170
  * @since 1.0.0
173
171
  * @param fullFilePath
174
172
  * @returns FileBatch
175
173
  * @example
176
- *
174
+ * ```ts
177
175
  * fastify.hl7.readFile( path.join('temp/', 'hl7.readTestBHS.20231208.hl7') )
178
- *
176
+ * ```
179
177
  */
180
178
  readFile(fullFilePath) {
181
179
  return new FileBatch({ fullFilePath });
182
180
  }
183
181
  /**
184
182
  * Read a File Buffer
185
- * @description Translate an already Buffered HL7 FHS segment to decode it.
183
+ *@remarks Translate an already Buffered HL7 FHS segment to decode it.
186
184
  * @since 1.0.0
187
185
  * @param fileBuffer
188
186
  * @returns FileBatch
189
187
  * @example
190
- *
188
+ * ```ts
191
189
  * const fileBuffer = fs.readFileSync(path.join('temp/', 'hl7.readTestBHS.20231208.hl7'))
192
190
  * fastify.hl7.readFileBuffer(fileBuffer)
193
- *
191
+ * ```
194
192
  */
195
193
  readFileBuffer(fileBuffer) {
196
194
  return new FileBatch({ fileBuffer });
@@ -0,0 +1,37 @@
1
+ import Server, { Inbound, InboundHandler, ListenerOptions } from 'node-hl7-server';
2
+ export declare class HL7Server {
3
+ private readonly _server;
4
+ private readonly _serverInboundConnections;
5
+ constructor(server: Server);
6
+ /**
7
+ * Close Inbound connection.
8
+ * @since 1.0.0
9
+ * @param port
10
+ */
11
+ close(port: string): Promise<boolean>;
12
+ /**
13
+ * Close all Inbound connections.
14
+ * @since 1.0.0
15
+ */
16
+ closeAll(): Promise<boolean>;
17
+ /**
18
+ * Create Inbound connection.
19
+ * @since 1.0.0
20
+ * @param name
21
+ * @param props
22
+ * @param handler
23
+ */
24
+ createInbound(name: string, props: ListenerOptions, handler: InboundHandler): Inbound;
25
+ /**
26
+ * Get Server Inbound Connection by Name
27
+ * @since 1.0.0
28
+ * @param name
29
+ */
30
+ getServerByName(name: string): Inbound | undefined;
31
+ /**
32
+ * Get Server Inbound Connection by Port
33
+ * @since 1.0.0
34
+ * @param port
35
+ */
36
+ getServerByPort(port: string): Inbound | undefined;
37
+ }
@@ -1,8 +1,6 @@
1
1
  import { Inbound } from 'node-hl7-server';
2
2
  import { errors } from '../errors.js';
3
3
  export class HL7Server {
4
- _server;
5
- _serverInboundConnections;
6
4
  constructor(server) {
7
5
  this._server = server;
8
6
  this._serverInboundConnections = [];