fastify-hl7 1.0.0-beta.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Shane
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,122 @@
1
+ # Fastify HL7
2
+
3
+ A Fastify Hl7 Plugin Developed in Pure TypeScript.
4
+ It uses the [node-hl7-client](https://github.com/Bugs5382/node-hl7-client) and [node-hl7-server](https://github.com/Bugs5382/node-hl7-server) plugin as a wrapper.
5
+
6
+ The build exports this to valid ESM and CJS for ease of cross-compatibility.
7
+
8
+ If you are using this NPM package, please consider giving it a :star: star.
9
+ This will increase its visibility and solicit more contribution from the outside.
10
+
11
+ This documentation is how to use this plugin, not on how to use the libraries above.
12
+ Head [here](#external-libraries) if you need help with those.
13
+
14
+ ## Table of Contents
15
+
16
+ 1. [Install](#install)
17
+ 2. [Basic Usage](#basic-usage)
18
+ 1. [Server Quick Start](#server-quick-start)
19
+ 2. [Client Quick Start](#client-quick-start)
20
+ 3. [Full Documentation](#full-documentation)
21
+ 1. [This Library Options](#this-library-options)
22
+ 2. [External Libraries](#external-libraries)
23
+ 4. [Acknowledgements](#acknowledgements)
24
+ 5. [License](#license)
25
+
26
+ ## Install
27
+
28
+ ```
29
+ npm install fastify-hl7
30
+ ```
31
+
32
+ ## Basic Usage
33
+
34
+ Register this as a plugin.
35
+
36
+ ```ts
37
+ await fastify.register(fastifyHL7)
38
+ ```
39
+
40
+ ### Server Quick Start
41
+
42
+ ```ts
43
+ const listener = fastify.hl7.createInbound(
44
+ 'ib_adt',
45
+ {port: 3001},
46
+ async (req, res) => {
47
+ const messageReq = req.getMessage()
48
+ const messageType = req.getType()
49
+ // your logic here
50
+ await res.sendResponse('AA')
51
+ })
52
+ ```
53
+ This will create a inbound connection. You can optionally return it to a variable to attach advanced listeners.
54
+
55
+ ### Client Quick Start
56
+
57
+ ```ts
58
+ import fastify from "fastify";
59
+
60
+ fastify.hl7.createClient('localhost', {host: '0.0.0.0'})
61
+ ```
62
+
63
+ This will create a "client" class that will then allow you to attach different outbound connections.
64
+ The name ```localhost``` in a unique identifier to this host, so it can be used to attach different outbound connections to this server/broker.
65
+
66
+ There might be times when your HL7 messages need to cross-over to different hosts/server/inbound endpoints and this is how you would get them.
67
+
68
+ Within your code now you can use the fastify context and access the ```hl7``` decorator,
69
+ and create an outbound connection.
70
+
71
+ ```ts
72
+ const client = fastify.hl7.createOutbound(
73
+ 'ob_adt',
74
+ {port: 3001},
75
+ async (res) => {
76
+ const messageRes = res.getMessage()
77
+ // Your code here. Either a failure or a success, but still do your work here.
78
+ })
79
+
80
+ // building a HL7 Message Segment
81
+ const message = app.hl7.buildMessage({
82
+ messageHeader: {
83
+ msh_9_1: "ADT",
84
+ msh_9_2: "A01",
85
+ msh_11_1: "D",
86
+ }
87
+ })
88
+
89
+ await client.sendMessage(message)
90
+ ```
91
+
92
+ ## Full Documentation
93
+
94
+ ### This Library Options
95
+
96
+ ### `enableServer`
97
+
98
+ If this is not set, enableServer will be set to ```true```. You need to set this to ```false``` will turn off the server capabilities.
99
+
100
+
101
+ ### ```serverOptions```
102
+
103
+ Set this using the options from the [node-hl7-serer](https://github.com/Bugs5382/node-hl7-server/blob/main/README.md) library ServerOptions values to override server creation.
104
+ This could be enabling IPv4 or IPv6 and other server options including TLS. SInce you can not set this after run time, it has to be set during registration.
105
+
106
+
107
+
108
+ ### External Libraries
109
+
110
+ * [node-hl7-client](https://github.com/Bugs5382/node-hl7-client/blob/main/README.md) - For the Client, Parser, and Builder to review their options that can be passed as props.
111
+ * [node-hl7-server](https://github.com/Bugs5382/node-hl7-server/blob/main/README.md) - For the Server to the options that can be passed as props.
112
+
113
+ Please review the library for more complete documentation.
114
+ A far as this plugin for Fastify, there are no options to pass.
115
+
116
+ ## Acknowledgements
117
+
118
+ - My Wife and Baby Girl.
119
+
120
+ ## License
121
+
122
+ Licensed under [MIT](./LICENSE).
package/lib/cjs/api.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.HL7Server = exports.HL7Client = exports.fastifyHL7 = void 0;
7
+ var _1 = __importDefault(require("."));
8
+ exports.fastifyHL7 = _1.default;
9
+ var hL7Client_js_1 = require("./class/hL7Client.js");
10
+ Object.defineProperty(exports, "HL7Client", { enumerable: true, get: function () { return hL7Client_js_1.HL7Client; } });
11
+ var hL7Server_js_1 = require("./class/hL7Server.js");
12
+ Object.defineProperty(exports, "HL7Server", { enumerable: true, get: function () { return hL7Server_js_1.HL7Server; } });
13
+ exports.default = _1.default;
@@ -0,0 +1,244 @@
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
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
45
+ var __generator = (this && this.__generator) || function (thisArg, body) {
46
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
47
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
48
+ function verb(n) { return function (v) { return step([n, v]); }; }
49
+ function step(op) {
50
+ if (f) throw new TypeError("Generator is already executing.");
51
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
52
+ 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;
53
+ if (y = 0, t) op = [op[0] & 2, t.value];
54
+ switch (op[0]) {
55
+ case 0: case 1: t = op; break;
56
+ case 4: _.label++; return { value: op[1], done: false };
57
+ case 5: _.label++; y = op[1]; op = [0]; continue;
58
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
59
+ default:
60
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
61
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
62
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
63
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
64
+ if (t[2]) _.ops.pop();
65
+ _.trys.pop(); continue;
66
+ }
67
+ op = body.call(thisArg, _);
68
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
69
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
70
+ }
71
+ };
72
+ Object.defineProperty(exports, "__esModule", { value: true });
73
+ exports.HL7Client = void 0;
74
+ var node_hl7_client_1 = __importStar(require("node-hl7-client"));
75
+ var errors_1 = require("../errors");
76
+ var HL7Client = /** @class */ (function () {
77
+ function HL7Client() {
78
+ this._clientConnections = [];
79
+ }
80
+ /**
81
+ * Close All Connections for this Client
82
+ * @since 1.0.0
83
+ */
84
+ HL7Client.prototype.closeAll = function () {
85
+ return __awaiter(this, void 0, void 0, function () {
86
+ var _this = this;
87
+ return __generator(this, function (_a) {
88
+ this._clientConnections.forEach(function (outbound) {
89
+ outbound.ports.map(function (port) { return __awaiter(_this, void 0, void 0, function () {
90
+ return __generator(this, function (_a) {
91
+ switch (_a.label) {
92
+ case 0: return [4 /*yield*/, port.connection.close()];
93
+ case 1:
94
+ _a.sent();
95
+ return [2 /*return*/];
96
+ }
97
+ });
98
+ }); });
99
+ });
100
+ return [2 /*return*/, true];
101
+ });
102
+ });
103
+ };
104
+ /**
105
+ * Build a HL7 Batch
106
+ * @description Create a properly formatted HL7 Batch.
107
+ * @since 1.0.0
108
+ * @param props
109
+ */
110
+ HL7Client.prototype.buildBatch = function (props) {
111
+ if (typeof props !== 'undefined' && typeof props.text !== 'undefined') {
112
+ throw new errors_1.errors.FASTIFY_HL7_ERR_USAGE('Use processMessage method. This is for building.');
113
+ }
114
+ return new node_hl7_client_1.Batch(__assign({}, props));
115
+ };
116
+ /**
117
+ * Build a HL7 File Batch
118
+ * @description Create a properly formatted HL7 File Batch.
119
+ * @since 1.0.0
120
+ * @param props
121
+ */
122
+ HL7Client.prototype.buildFileBatch = function (props) {
123
+ if (typeof props !== 'undefined' && (typeof props.fullFilePath !== 'undefined' || typeof props.fileBuffer !== 'undefined')) {
124
+ throw new errors_1.errors.FASTIFY_HL7_ERR_USAGE('Use readFile or readFileBuffer method. This is for building.');
125
+ }
126
+ return new node_hl7_client_1.FileBatch(__assign({}, props));
127
+ };
128
+ /**
129
+ * Build a HL7 Message
130
+ * @description Create a properly formatted HL7 message.
131
+ * @since 1.0.0
132
+ * @param props
133
+ */
134
+ HL7Client.prototype.buildMessage = function (props) {
135
+ if (typeof props !== 'undefined' && typeof props.text !== 'undefined') {
136
+ throw new errors_1.errors.FASTIFY_HL7_ERR_USAGE('Use processMessage method. This is for building.');
137
+ }
138
+ return new node_hl7_client_1.Message(__assign({}, props));
139
+ };
140
+ /**
141
+ *
142
+ * @param name
143
+ * @param props
144
+ */
145
+ HL7Client.prototype.createClient = function (name, props) {
146
+ var nameFormat = /[ `!@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?~]/; //eslint-disable-line
147
+ if (nameFormat.test(name)) {
148
+ throw new errors_1.errors.FASTIFY_HL7_ERR_USAGE('name must not contain certain characters: `!@#$%^&*()+\\-=\\[\\]{};\':"\\\\|,.<>\\/?~.');
149
+ }
150
+ // make sure that this does not exist already...
151
+ this._clientConnections.forEach(function (connections) {
152
+ if (connections.name === name) {
153
+ throw new errors_1.errors.FASTIFY_HL7_ERR_USAGE('name must be unique.');
154
+ }
155
+ // nto in the Client class yet
156
+ // if (client.getHost() === props.host) {
157
+ // throw new errors.FASTIFY_HL7_ERR_USAGE(`host is already a pointer. Name is: ${connections.name}`)
158
+ // }
159
+ });
160
+ // new client
161
+ var client = new node_hl7_client_1.default(props);
162
+ // add it to the collection
163
+ this._clientConnections.push({
164
+ name: name,
165
+ client: client,
166
+ ports: []
167
+ });
168
+ };
169
+ /**
170
+ * Create an HL7 Outbound Connection
171
+ * @description Connect to an HL7 Server/Broker
172
+ * @since 1.0.0
173
+ * @param name The name stored within created client connections.
174
+ * @param props
175
+ * @param handler
176
+ */
177
+ HL7Client.prototype.createOutbound = function (name, props, handler) {
178
+ var nameFormat = /[ `!@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?~]/; //eslint-disable-line
179
+ if (nameFormat.test(name)) {
180
+ throw new errors_1.errors.FASTIFY_HL7_ERR_USAGE('name must not contain certain characters: `!@#$%^&*()+\\-=\\[\\]{};\':"\\\\|,.<>\\/?~.');
181
+ }
182
+ var getConnection = this._clientConnections.find(function (client) { return client.name === name; });
183
+ if (typeof getConnection !== 'undefined') {
184
+ // make sure port is not used all ready
185
+ getConnection.ports.forEach(function (outbound) {
186
+ if (outbound.port === props.port.toString()) {
187
+ throw new errors_1.errors.FASTIFY_HL7_ERR_USAGE("port ".concat(props.port, " is already used with this client. Choose a new outgoing port."));
188
+ }
189
+ });
190
+ // create outbound port to the server in getConnection.client
191
+ var outbound = new node_hl7_client_1.HL7Outbound(getConnection.client, props, handler);
192
+ // add it to the array of known ports. need to know this, so we can get it later if needed.
193
+ getConnection.ports.push({ port: props.port.toString(), connection: outbound });
194
+ // return it right away. the user might do something with it.
195
+ return outbound;
196
+ }
197
+ throw new errors_1.errors.FASTIFY_HL7_ERR_USAGE('No valid client. Improper setup of a outbound connection.');
198
+ };
199
+ /**
200
+ * Process a HL7
201
+ * @description A HL7 message that could either be a Message (MSH) or Batch (BHS)
202
+ * @since 1.0.0
203
+ * @param text Raw HL& String
204
+ */
205
+ HL7Client.prototype.processHL7 = function (text) {
206
+ if ((0, node_hl7_client_1.isBatch)(text)) {
207
+ return new node_hl7_client_1.Batch({ text: text });
208
+ }
209
+ else {
210
+ return new node_hl7_client_1.Message({ text: text });
211
+ }
212
+ };
213
+ /**
214
+ * Read File
215
+ * @description Pass the correct path of the file you want to read.
216
+ * @since 1.0.0
217
+ * @param fullFilePath
218
+ * @returns FileBatch
219
+ * @example
220
+ *
221
+ * fastify.hl7.readFile( path.join('temp/', 'hl7.readTestBHS.20231208.hl7') )
222
+ *
223
+ */
224
+ HL7Client.prototype.readFile = function (fullFilePath) {
225
+ return new node_hl7_client_1.FileBatch({ fullFilePath: fullFilePath });
226
+ };
227
+ /**
228
+ * Read a File Buffer
229
+ * @description Translate an already Buffered HL7 FHS segment to decode it.
230
+ * @since 1.0.0
231
+ * @param fileBuffer
232
+ * @returns FileBatch
233
+ * @example
234
+ *
235
+ * const fileBuffer = fs.readFileSync(path.join('temp/', 'hl7.readTestBHS.20231208.hl7'))
236
+ * fastify.hl7.readFileBuffer(fileBuffer)
237
+ *
238
+ */
239
+ HL7Client.prototype.readFileBuffer = function (fileBuffer) {
240
+ return new node_hl7_client_1.FileBatch({ fileBuffer: fileBuffer });
241
+ };
242
+ return HL7Client;
243
+ }());
244
+ exports.HL7Client = HL7Client;
@@ -0,0 +1,111 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.HL7Server = void 0;
40
+ var node_hl7_server_1 = require("node-hl7-server");
41
+ var errors_1 = require("../errors");
42
+ var HL7Server = /** @class */ (function () {
43
+ function HL7Server(server) {
44
+ this._server = server;
45
+ this._serverInboundConnections = [];
46
+ }
47
+ /**
48
+ * Close Inbound connection.
49
+ * @since 1.0.0
50
+ * @param port
51
+ */
52
+ HL7Server.prototype.close = function (port) {
53
+ return __awaiter(this, void 0, void 0, function () {
54
+ var inbound;
55
+ return __generator(this, function (_a) {
56
+ switch (_a.label) {
57
+ case 0:
58
+ inbound = this._serverInboundConnections.find(function (server) { return server.port === port; });
59
+ if (!(typeof inbound !== 'undefined')) return [3 /*break*/, 2];
60
+ return [4 /*yield*/, inbound.server.close()]; // close the server for all inbound connections
61
+ case 1: return [2 /*return*/, _a.sent()]; // close the server for all inbound connections
62
+ case 2: throw new errors_1.errors.FASTIFY_HL7_ERR_USAGE("No inbound server listening on port: ".concat(port));
63
+ }
64
+ });
65
+ });
66
+ };
67
+ /**
68
+ * Close all Inbound connections.
69
+ * @since 1.0.0
70
+ */
71
+ HL7Server.prototype.closeAll = function () {
72
+ return __awaiter(this, void 0, void 0, function () {
73
+ var _this = this;
74
+ return __generator(this, function (_a) {
75
+ this._serverInboundConnections.map(function (inbound) { return __awaiter(_this, void 0, void 0, function () {
76
+ return __generator(this, function (_a) {
77
+ switch (_a.label) {
78
+ case 0: return [4 /*yield*/, inbound.server.close()];
79
+ case 1:
80
+ _a.sent();
81
+ return [2 /*return*/];
82
+ }
83
+ });
84
+ }); });
85
+ return [2 /*return*/, true];
86
+ });
87
+ });
88
+ };
89
+ /**
90
+ * Create Inbound connection.
91
+ * @since 1.0.0
92
+ * @param name
93
+ * @param props
94
+ * @param handler
95
+ */
96
+ HL7Server.prototype.createInbound = function (name, props, handler) {
97
+ var nameFormat = /[ `!@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?~]/; //eslint-disable-line
98
+ if (nameFormat.test(name)) {
99
+ throw new errors_1.errors.FASTIFY_HL7_ERR_USAGE('name must not contain certain characters: `!@#$%^&*()+\\-=\\[\\]{};\':"\\\\|,.<>\\/?~.');
100
+ }
101
+ var inbound = new node_hl7_server_1.HL7Inbound(this._server, props, handler);
102
+ this._serverInboundConnections.push({
103
+ name: name,
104
+ port: props.port.toString(),
105
+ server: inbound
106
+ });
107
+ return inbound;
108
+ };
109
+ return HL7Server;
110
+ }());
111
+ exports.HL7Server = HL7Server;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.errors = void 0;
7
+ var error_1 = __importDefault(require("@fastify/error"));
8
+ exports.errors = {
9
+ /** Error if there is an setup error of the plugin itself. */
10
+ FASTIFY_HL7_ERR_SETUP_ERRORS: (0, error_1.default)('FASTIFY_HL7_ERR_SETUP_ERRORS', 'Setup error: %s'),
11
+ /** If an invalid usage error was done, this error would pop up. */
12
+ FASTIFY_HL7_ERR_USAGE: (0, error_1.default)('FASTIFY_HL7_ERR_USAGE', 'Usage error: %s')
13
+ };