fastify-hl7 3.0.0 → 3.2.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/README.md CHANGED
@@ -34,48 +34,51 @@ npm install fastify-hl7
34
34
  Register this as a plugin.
35
35
 
36
36
  ```ts
37
- await fastify.register(fastifyHL7)
37
+ await fastify.register(fastifyHL7);
38
38
  ```
39
39
 
40
40
  ### Server Quick Start
41
41
 
42
42
  ```ts
43
43
  const listener = fastify.hl7.createInbound(
44
- 'ib_adt',
45
- {port: 3001},
44
+ "ib_adt",
45
+ { port: 3001 },
46
46
  async (req, res) => {
47
- const messageReq = req.getMessage()
48
- const messageType = req.getType()
47
+ const messageReq = req.getMessage();
48
+ const messageType = req.getType();
49
49
  // your logic here
50
- await res.sendResponse('AA')
51
- })
50
+ await res.sendResponse("AA");
51
+ },
52
+ );
52
53
  ```
53
- This will create a inbound connection. You can optionally return it to a variable to attach advanced listeners.
54
+
55
+ This will create a inbound connection. You can optionally return it to a variable to attach advanced listeners.
54
56
 
55
57
  ### Client Quick Start
56
58
 
57
59
  ```ts
58
60
  import fastify from "fastify";
59
61
 
60
- fastify.hl7.createClient('localhost', {host: '0.0.0.0'})
62
+ fastify.hl7.createClient("localhost", { host: "0.0.0.0" });
61
63
  ```
62
64
 
63
65
  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.
66
+ 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
67
 
66
68
  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
69
 
68
- Within your code now you can use the fastify context and access the ```hl7``` decorator,
70
+ Within your code now you can use the fastify context and access the `hl7` decorator,
69
71
  and create an outbound connection.
70
72
 
71
73
  ```ts
72
74
  const client = fastify.hl7.createConnection(
73
- 'ob_adt',
74
- {port: 3001},
75
+ "ob_adt",
76
+ { port: 3001 },
75
77
  async (res) => {
76
- const messageRes = res.getMessage()
78
+ const messageRes = res.getMessage();
77
79
  // Your code here. Either a failure or a success, but still do your work here.
78
- })
80
+ },
81
+ );
79
82
 
80
83
  // building a HL7 Message Segment
81
84
  const message = app.hl7.buildMessage({
@@ -83,10 +86,10 @@ const message = app.hl7.buildMessage({
83
86
  msh_9_1: "ADT",
84
87
  msh_9_2: "A01",
85
88
  msh_11_1: "D",
86
- }
87
- })
89
+ },
90
+ });
88
91
 
89
- await client.sendMessage(message)
92
+ await client.sendMessage(message);
90
93
  ```
91
94
 
92
95
  ## Full Documentation
@@ -95,17 +98,17 @@ await client.sendMessage(message)
95
98
 
96
99
  ### `enableServer`
97
100
 
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.
101
+ 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
102
 
100
- ### ```serverOptions```
103
+ ### `serverOptions`
101
104
 
102
105
  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.
103
106
  This could be enabling IPv4 or IPv6 and other server options including TLS. Since you cannot set this after run time, it has to be set during registration.
104
107
 
105
108
  ### External Libraries Options
106
109
 
107
- * [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.
108
- * [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.
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.
109
112
 
110
113
  Please review the libraries for more complete documentation.
111
114
 
@@ -115,4 +118,4 @@ Please review the libraries for more complete documentation.
115
118
 
116
119
  ## License
117
120
 
118
- Licensed under [MIT](./LICENSE).
121
+ Licensed under [MIT](./LICENSE).
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.HL7Client = void 0;
27
37
  const node_hl7_client_1 = __importStar(require("node-hl7-client"));
@@ -35,7 +45,7 @@ class HL7Client {
35
45
  * @since 1.0.0
36
46
  */
37
47
  async closeAll() {
38
- this._clientConnections.forEach(outbound => {
48
+ this._clientConnections.forEach((outbound) => {
39
49
  outbound.ports.map(async (port) => {
40
50
  await port.connection.close();
41
51
  });
@@ -44,19 +54,19 @@ class HL7Client {
44
54
  }
45
55
  /**
46
56
  * Build a HL7 Batch
47
- *@remarks Create a properly formatted HL7 Batch.
57
+ * @remarks Create a properly formatted HL7 Batch.
48
58
  * @since 1.0.0
49
59
  * @param props
50
60
  */
51
61
  buildBatch(props) {
52
- if (typeof props !== 'undefined' && typeof props.text !== 'undefined') {
53
- throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('Use processMessage method. This is for building.');
62
+ if (typeof props !== "undefined" && typeof props.text !== "undefined") {
63
+ throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("Use processMessage method. This is for building.");
54
64
  }
55
65
  return new node_hl7_client_1.Batch({ ...props });
56
66
  }
57
67
  /**
58
68
  * Build Date
59
- *@remarks Build a date string based off HL7 Standards
69
+ * @remarks Build a date string based off HL7 Standards
60
70
  * @since 2.1.0
61
71
  * @param date
62
72
  * @param length Options are 8, 12, or 14 (default)
@@ -66,25 +76,27 @@ class HL7Client {
66
76
  }
67
77
  /**
68
78
  * Build a HL7 File Batch
69
- *@remarks Create a properly formatted HL7 File Batch.
79
+ * @remarks Create a properly formatted HL7 File Batch.
70
80
  * @since 1.0.0
71
81
  * @param props
72
82
  */
73
83
  buildFileBatch(props) {
74
- if (typeof props !== 'undefined' && (typeof props.fullFilePath !== 'undefined' || typeof props.fileBuffer !== 'undefined')) {
75
- throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('Use readFile or readFileBuffer method. This is for building.');
84
+ if (typeof props !== "undefined" &&
85
+ (typeof props.fullFilePath !== "undefined" ||
86
+ typeof props.fileBuffer !== "undefined")) {
87
+ throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("Use readFile or readFileBuffer method. This is for building.");
76
88
  }
77
89
  return new node_hl7_client_1.FileBatch({ ...props });
78
90
  }
79
91
  /**
80
92
  * Build a HL7 Message
81
- *@remarks Create a properly formatted HL7 message.
93
+ * @remarks Create a properly formatted HL7 message.
82
94
  * @since 1.0.0
83
95
  * @param props
84
96
  */
85
97
  buildMessage(props) {
86
- if (typeof props !== 'undefined' && typeof props.text !== 'undefined') {
87
- throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('Use processMessage method. This is for building.');
98
+ if (typeof props !== "undefined" && typeof props.text !== "undefined") {
99
+ throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("Use processMessage method. This is for building.");
88
100
  }
89
101
  return new node_hl7_client_1.Message({ ...props });
90
102
  }
@@ -96,12 +108,12 @@ class HL7Client {
96
108
  createClient(name, props) {
97
109
  const nameFormat = /[ `!@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?~]/; //eslint-disable-line
98
110
  if (nameFormat.test(name)) {
99
- throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('name must not contain certain characters: `!@#$%^&*()+\\-=\\[\\]{};\':"\\\\|,.<>\\/?~.');
111
+ throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("name must not contain certain characters: `!@#$%^&*()+\\-=\\[\\]{};':\"\\\\|,.<>\\/?~.");
100
112
  }
101
113
  // make sure that this does not exist already...
102
114
  this._clientConnections.forEach((connections) => {
103
115
  if (connections.name === name) {
104
- throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('name must be unique.');
116
+ throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("name must be unique.");
105
117
  }
106
118
  // nto in the Client class yet
107
119
  // if (client.getHost() === props.host) {
@@ -114,13 +126,13 @@ class HL7Client {
114
126
  this._clientConnections.push({
115
127
  name,
116
128
  client,
117
- ports: []
129
+ ports: [],
118
130
  });
119
131
  return client;
120
132
  }
121
133
  /**
122
134
  * Create an HL7 Outbound Connection
123
- *@remarks Connect to an HL7 Server/Broker
135
+ * @remarks Connect to an HL7 Server/Broker
124
136
  * @since 1.0.0
125
137
  * @param name The name stored within created client connections.
126
138
  * @param props
@@ -129,10 +141,10 @@ class HL7Client {
129
141
  createConnection(name, props, handler) {
130
142
  const nameFormat = /[ `!@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?~]/; //eslint-disable-line
131
143
  if (nameFormat.test(name)) {
132
- throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('name must not contain certain characters: `!@#$%^&*()+\\-=\\[\\]{};\':"\\\\|,.<>\\/?~.');
144
+ throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("name must not contain certain characters: `!@#$%^&*()+\\-=\\[\\]{};':\"\\\\|,.<>\\/?~.");
133
145
  }
134
- const getConnection = this._clientConnections.find(client => client.name === name);
135
- if (typeof getConnection !== 'undefined') {
146
+ const getConnection = this._clientConnections.find((client) => client.name === name);
147
+ if (typeof getConnection !== "undefined") {
136
148
  // make sure port is not used all ready
137
149
  getConnection.ports.forEach((outbound) => {
138
150
  if (outbound.port === props.port.toString()) {
@@ -142,11 +154,14 @@ class HL7Client {
142
154
  // create outbound port to the server in getConnection.client
143
155
  const outbound = new node_hl7_client_1.Connection(getConnection.client, props, handler);
144
156
  // add it to the array of known ports. need to know this, so we can get it later if needed.
145
- getConnection.ports.push({ port: props.port.toString(), connection: outbound });
157
+ getConnection.ports.push({
158
+ port: props.port.toString(),
159
+ connection: outbound,
160
+ });
146
161
  // return it right away. the user might do something with it.
147
162
  return outbound;
148
163
  }
149
- throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('No valid client. Improper setup of a outbound connection.');
164
+ throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("No valid client. Improper setup of a outbound connection.");
150
165
  }
151
166
  /**
152
167
  * Get Client by the name
@@ -154,8 +169,8 @@ class HL7Client {
154
169
  * @param name
155
170
  */
156
171
  getClientByName(name) {
157
- const connection = this._clientConnections.find(connection => connection.name === name);
158
- if (typeof connection !== 'undefined') {
172
+ const connection = this._clientConnections.find((connection) => connection.name === name);
173
+ if (typeof connection !== "undefined") {
159
174
  return connection.client;
160
175
  }
161
176
  return undefined;
@@ -167,8 +182,8 @@ class HL7Client {
167
182
  */
168
183
  getClientConnectionByPort(port) {
169
184
  let connection;
170
- this._clientConnections.forEach(outbound => {
171
- outbound.ports.forEach(aPort => {
185
+ this._clientConnections.forEach((outbound) => {
186
+ outbound.ports.forEach((aPort) => {
172
187
  if (aPort.port === port) {
173
188
  connection = aPort.connection;
174
189
  }
@@ -178,7 +193,7 @@ class HL7Client {
178
193
  }
179
194
  /**
180
195
  * Process a HL7
181
- *@remarks A HL7 message that could either be a Message (MSH) or Batch (BHS)
196
+ * @remarks A HL7 message that could either be a Message (MSH) or Batch (BHS)
182
197
  * @since 1.0.0
183
198
  * @param text Raw HL& String
184
199
  */
@@ -192,7 +207,7 @@ class HL7Client {
192
207
  }
193
208
  /**
194
209
  * Read File
195
- *@remarks Pass the correct path of the file you want to read.
210
+ * @remarks Pass the correct path of the file you want to read.
196
211
  * @since 1.0.0
197
212
  * @param fullFilePath
198
213
  * @returns FileBatch
@@ -206,7 +221,7 @@ class HL7Client {
206
221
  }
207
222
  /**
208
223
  * Read a File Buffer
209
- *@remarks Translate an already Buffered HL7 FHS segment to decode it.
224
+ * @remarks Translate an already Buffered HL7 FHS segment to decode it.
210
225
  * @since 1.0.0
211
226
  * @param fileBuffer
212
227
  * @returns FileBatch
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HL7Server = void 0;
4
+ const node_events_1 = require("node:events");
4
5
  const node_hl7_server_1 = require("node-hl7-server");
5
6
  const errors_js_1 = require("../errors.js");
6
- class HL7Server {
7
+ class HL7Server extends node_events_1.EventEmitter {
7
8
  constructor(server) {
9
+ super();
8
10
  this._server = server;
9
11
  this._serverInboundConnections = [];
10
12
  }
@@ -14,8 +16,8 @@ class HL7Server {
14
16
  * @param port
15
17
  */
16
18
  async close(port) {
17
- const inbound = this._serverInboundConnections.find(server => server.port === port);
18
- if (typeof inbound !== 'undefined') {
19
+ const inbound = this._serverInboundConnections.find((server) => server.port === port);
20
+ if (typeof inbound !== "undefined") {
19
21
  return await inbound.server.close(); // close the server for all inbound connections
20
22
  }
21
23
  throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE(`No inbound server listening on port: ${port}`);
@@ -40,14 +42,15 @@ class HL7Server {
40
42
  createInbound(name, props, handler) {
41
43
  const nameFormat = /[ `!@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?~]/; //eslint-disable-line
42
44
  if (nameFormat.test(name)) {
43
- throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('name must not contain certain characters: `!@#$%^&*()+\\-=\\[\\]{};\':"\\\\|,.<>\\/?~.');
45
+ throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("name must not contain certain characters: `!@#$%^&*()+\\-=\\[\\]{};':\"\\\\|,.<>\\/?~.");
44
46
  }
45
47
  const inbound = new node_hl7_server_1.Inbound(this._server, props, handler);
46
48
  this._serverInboundConnections.push({
47
49
  name,
48
50
  port: props.port.toString(),
49
- server: inbound
51
+ server: inbound,
50
52
  });
53
+ this.emit("inbound", props.port.toString());
51
54
  return inbound;
52
55
  }
53
56
  /**
@@ -56,8 +59,8 @@ class HL7Server {
56
59
  * @param name
57
60
  */
58
61
  getServerByName(name) {
59
- const inbound = this._serverInboundConnections.find(inbound => inbound.name === name);
60
- if (typeof inbound !== 'undefined') {
62
+ const inbound = this._serverInboundConnections.find((inbound) => inbound.name === name);
63
+ if (typeof inbound !== "undefined") {
61
64
  return inbound.server;
62
65
  }
63
66
  return undefined;
@@ -68,8 +71,8 @@ class HL7Server {
68
71
  * @param port
69
72
  */
70
73
  getServerByPort(port) {
71
- const inbound = this._serverInboundConnections.find(inbound => inbound.port === port);
72
- if (typeof inbound !== 'undefined') {
74
+ const inbound = this._serverInboundConnections.find((inbound) => inbound.port === port);
75
+ if (typeof inbound !== "undefined") {
73
76
  return inbound.server;
74
77
  }
75
78
  return undefined;
package/lib/cjs/errors.js CHANGED
@@ -7,7 +7,7 @@ exports.errors = void 0;
7
7
  const error_1 = __importDefault(require("@fastify/error"));
8
8
  exports.errors = {
9
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'),
10
+ FASTIFY_HL7_ERR_SETUP_ERRORS: (0, error_1.default)("FASTIFY_HL7_ERR_SETUP_ERRORS", "Setup error: %s"),
11
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')
12
+ FASTIFY_HL7_ERR_USAGE: (0, error_1.default)("FASTIFY_HL7_ERR_USAGE", "Usage error: %s"),
13
13
  };
package/lib/cjs/index.js CHANGED
@@ -31,12 +31,12 @@ __exportStar(require("./types.js"), exports);
31
31
  * @param connection
32
32
  */
33
33
  const decorateFastifyInstance = (fastify, _opts, connection) => {
34
- if (typeof fastify.hl7 !== 'undefined') {
35
- throw new errors_js_1.errors.FASTIFY_HL7_ERR_SETUP_ERRORS('Already registered.');
34
+ if (typeof fastify.hl7 !== "undefined") {
35
+ throw new errors_js_1.errors.FASTIFY_HL7_ERR_SETUP_ERRORS("Already registered.");
36
36
  }
37
- if (typeof fastify.hl7 === 'undefined') {
38
- fastify.log.trace('[fastify-hl7] Decorate Fastify');
39
- fastify.decorate('hl7', connection);
37
+ if (typeof fastify.hl7 === "undefined") {
38
+ fastify.log.trace("[fastify-hl7] Decorate Fastify");
39
+ fastify.decorate("hl7", connection);
40
40
  }
41
41
  };
42
42
  const fastifyHL7 = (0, fastify_plugin_1.default)(async (fastify, opts) => {
@@ -48,15 +48,20 @@ const fastifyHL7 = (0, fastify_plugin_1.default)(async (fastify, opts) => {
48
48
  // A server can host many HL7 Inbound connections via different ports, this is fine.
49
49
  // Clients are different as an app could talk to different servers, on many ports.
50
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;
51
+ const serverInstance = typeof opts.enableServer !== "undefined" && opts.enableServer
52
+ ? new node_hl7_server_1.default(opts.serverOptions)
53
+ : undefined;
52
54
  // Server Functions
53
55
  let server;
54
- if (typeof serverInstance !== 'undefined') {
56
+ if (typeof serverInstance !== "undefined") {
55
57
  // Server Functions
56
58
  server = new hL7Server_js_1.HL7Server(serverInstance);
59
+ server.on("inbound", (port) => {
60
+ fastify.log.info("HL7 Inbound Server Listening on Port %s", port);
61
+ });
57
62
  // before we close fastify, make sure all server instances are closed
58
- fastify.addHook('preClose', async () => {
59
- if (typeof server !== 'undefined') {
63
+ fastify.addHook("preClose", async () => {
64
+ if (typeof server !== "undefined") {
60
65
  await server.closeAll();
61
66
  }
62
67
  });
@@ -64,8 +69,8 @@ const fastifyHL7 = (0, fastify_plugin_1.default)(async (fastify, opts) => {
64
69
  // Client Functions
65
70
  const client = new hL7Client_js_1.HL7Client();
66
71
  // run these before fastify closes
67
- fastify.addHook('preClose', async () => {
68
- if (typeof client !== 'undefined') {
72
+ fastify.addHook("preClose", async () => {
73
+ if (typeof client !== "undefined") {
69
74
  await client.closeAll();
70
75
  }
71
76
  });
@@ -84,25 +89,25 @@ const fastifyHL7 = (0, fastify_plugin_1.default)(async (fastify, opts) => {
84
89
  return client.buildMessage(props);
85
90
  },
86
91
  closeServer: async function (port) {
87
- if (typeof server !== 'undefined') {
92
+ if (typeof server !== "undefined") {
88
93
  return await server.close(port);
89
94
  }
90
- throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('server was not started. re-register plugin with enableServer set to true.');
95
+ throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("server was not started. re-register plugin with enableServer set to true.");
91
96
  },
92
97
  closeServerAll: async () => {
93
- if (typeof server !== 'undefined') {
98
+ if (typeof server !== "undefined") {
94
99
  return await server.closeAll();
95
100
  }
96
- throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('server was not started. re-register plugin with enableServer set to true.');
101
+ throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("server was not started. re-register plugin with enableServer set to true.");
97
102
  },
98
103
  createClient: function (name, props) {
99
104
  return client.createClient(name, props);
100
105
  },
101
106
  createInbound: function (name, props, handler) {
102
- if (typeof server !== 'undefined') {
107
+ if (typeof server !== "undefined") {
103
108
  return server.createInbound(name, props, handler);
104
109
  }
105
- throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('server was not started. re-register plugin with enableServer set to true.');
110
+ throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("server was not started. re-register plugin with enableServer set to true.");
106
111
  },
107
112
  createConnection: function (name, props, handler) {
108
113
  return client.createConnection(name, props, handler);
@@ -114,16 +119,16 @@ const fastifyHL7 = (0, fastify_plugin_1.default)(async (fastify, opts) => {
114
119
  return client.getClientConnectionByPort(port);
115
120
  },
116
121
  getServerByName: function (name) {
117
- if (typeof server !== 'undefined') {
122
+ if (typeof server !== "undefined") {
118
123
  return server.getServerByName(name);
119
124
  }
120
- throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('server was not started. re-register plugin with enableServer set to true.');
125
+ throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("server was not started. re-register plugin with enableServer set to true.");
121
126
  },
122
127
  getServerByPort: function (port) {
123
- if (typeof server !== 'undefined') {
128
+ if (typeof server !== "undefined") {
124
129
  return server.getServerByPort(port);
125
130
  }
126
- throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('server was not started. re-register plugin with enableServer set to true.');
131
+ throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("server was not started. re-register plugin with enableServer set to true.");
127
132
  },
128
133
  processHL7: function (text) {
129
134
  return client.processHL7(text);
@@ -133,7 +138,7 @@ const fastifyHL7 = (0, fastify_plugin_1.default)(async (fastify, opts) => {
133
138
  },
134
139
  readFileBuffer: function (fileBuffer) {
135
140
  return client.readFileBuffer(fileBuffer);
136
- }
141
+ },
137
142
  });
138
143
  });
139
144
  exports.default = fastifyHL7;
@@ -7,7 +7,7 @@ exports.validateOpts = void 0;
7
7
  */
8
8
  const validateOpts = async (opts) => {
9
9
  // Mandatory, Defaulted
10
- if (typeof opts.enableServer === 'undefined') {
10
+ if (typeof opts.enableServer === "undefined") {
11
11
  opts.enableServer = true;
12
12
  }
13
13
  return opts;
package/lib/esm/api.d.ts CHANGED
@@ -1,7 +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';
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
6
  export default fastifyHL7;
7
7
  export { fastifyHL7, HL7, FastifyHL7Options, HL7Client, HL7Server, AServers };
package/lib/esm/api.js CHANGED
@@ -1,5 +1,5 @@
1
- import fastifyHL7 from '.';
2
- import { HL7Client } from './class/hL7Client.js';
3
- import { HL7Server } from './class/hL7Server.js';
1
+ import fastifyHL7 from ".";
2
+ import { HL7Client } from "./class/hL7Client.js";
3
+ import { HL7Server } from "./class/hL7Server.js";
4
4
  export default fastifyHL7;
5
5
  export { fastifyHL7, HL7Client, HL7Server };
@@ -1,4 +1,4 @@
1
- import Client, { Batch, ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuilderOptions, ClientListenerOptions, ClientOptions, FileBatch, Connection, Message, OutboundHandler } from 'node-hl7-client';
1
+ import Client, { Batch, ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuilderOptions, ClientListenerOptions, ClientOptions, FileBatch, Connection, Message, OutboundHandler } from "node-hl7-client";
2
2
  export declare class HL7Client {
3
3
  /** @internal */
4
4
  private readonly _clientConnections;
@@ -10,14 +10,14 @@ export declare class HL7Client {
10
10
  closeAll(): Promise<boolean>;
11
11
  /**
12
12
  * Build a HL7 Batch
13
- *@remarks Create a properly formatted HL7 Batch.
13
+ * @remarks Create a properly formatted HL7 Batch.
14
14
  * @since 1.0.0
15
15
  * @param props
16
16
  */
17
17
  buildBatch(props?: ClientBuilderOptions): Batch;
18
18
  /**
19
19
  * Build Date
20
- *@remarks Build a date string based off HL7 Standards
20
+ * @remarks Build a date string based off HL7 Standards
21
21
  * @since 2.1.0
22
22
  * @param date
23
23
  * @param length Options are 8, 12, or 14 (default)
@@ -25,14 +25,14 @@ export declare class HL7Client {
25
25
  buildDate(date: Date, length?: string): string;
26
26
  /**
27
27
  * Build a HL7 File Batch
28
- *@remarks Create a properly formatted HL7 File Batch.
28
+ * @remarks Create a properly formatted HL7 File Batch.
29
29
  * @since 1.0.0
30
30
  * @param props
31
31
  */
32
32
  buildFileBatch(props?: ClientBuilderFileOptions): FileBatch;
33
33
  /**
34
34
  * Build a HL7 Message
35
- *@remarks Create a properly formatted HL7 message.
35
+ * @remarks Create a properly formatted HL7 message.
36
36
  * @since 1.0.0
37
37
  * @param props
38
38
  */
@@ -45,7 +45,7 @@ export declare class HL7Client {
45
45
  createClient(name: string, props: ClientOptions): Client;
46
46
  /**
47
47
  * Create an HL7 Outbound Connection
48
- *@remarks Connect to an HL7 Server/Broker
48
+ * @remarks Connect to an HL7 Server/Broker
49
49
  * @since 1.0.0
50
50
  * @param name The name stored within created client connections.
51
51
  * @param props
@@ -66,14 +66,14 @@ export declare class HL7Client {
66
66
  getClientConnectionByPort(port: string): Connection | undefined;
67
67
  /**
68
68
  * Process a HL7
69
- *@remarks A HL7 message that could either be a Message (MSH) or Batch (BHS)
69
+ * @remarks A HL7 message that could either be a Message (MSH) or Batch (BHS)
70
70
  * @since 1.0.0
71
71
  * @param text Raw HL& String
72
72
  */
73
73
  processHL7(text: string): Message | Batch;
74
74
  /**
75
75
  * Read File
76
- *@remarks Pass the correct path of the file you want to read.
76
+ * @remarks Pass the correct path of the file you want to read.
77
77
  * @since 1.0.0
78
78
  * @param fullFilePath
79
79
  * @returns FileBatch
@@ -85,7 +85,7 @@ export declare class HL7Client {
85
85
  readFile(fullFilePath: string): FileBatch;
86
86
  /**
87
87
  * Read a File Buffer
88
- *@remarks Translate an already Buffered HL7 FHS segment to decode it.
88
+ * @remarks Translate an already Buffered HL7 FHS segment to decode it.
89
89
  * @since 1.0.0
90
90
  * @param fileBuffer
91
91
  * @returns FileBatch