fastify-hl7 4.0.0 → 4.0.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/CHANGELOG.md CHANGED
@@ -1,9 +1,34 @@
1
1
  # Fastify HL7
2
2
 
3
+ ## v4.0.1 - 2026-08-11
4
+
5
+ ### What Changed 👀
6
+
7
+ #### 🐛 Bug Fixes
8
+
9
+ - fix(deps): raise the node-hl7 floor to 4.1.1 @Bugs5382 (#136)
10
+
11
+ #### 📄 Documentation
12
+
13
+ - docs(changelog): put every release in the release-drafter format @Bugs5382 (#138)
14
+ - docs: add encapsulation recipe for a user plugin that streamlines sending HL7 @Bugs5382 (#128)
15
+
16
+ #### 🧩 Dependency Updates
17
+
18
+ - chore(deps): bump the github-actions group with 9 updates @[dependabot[bot]](https://github.com/apps/dependabot) (#125)
19
+ - chore(deps): bump the production-dependencies group with 2 updates @[dependabot[bot]](https://github.com/apps/dependabot) (#123)
20
+ - chore(deps-dev): bump the development-dependencies group with 2 updates @[dependabot[bot]](https://github.com/apps/dependabot) (#124)
21
+
22
+ ### Extra
23
+
24
+ **Full Changelog**: https://github.com/Bugs5382/fastify-hl7/compare/v4.0.0...v4.0.1
25
+
3
26
  ## v4.0.0 - 2026-06-08
4
27
 
5
28
  ### What Changed 👀
6
29
 
30
+ - fix(ci): skip PR Body check for Dependabot @Bugs5382 (#105)
31
+
7
32
  #### 💥 Breaking Changes
8
33
 
9
34
  - feat!: upgrade to node-hl7 v4.0.0 @Bugs5382 (#88)
@@ -22,7 +47,7 @@
22
47
 
23
48
  ## v3.3.0 - 2025-03-25
24
49
 
25
- #### What Changed 👀
50
+ ### What Changed 👀
26
51
 
27
52
  #### 🧩 Dependency Updates
28
53
 
@@ -34,7 +59,7 @@
34
59
 
35
60
  ## v3.2.0 - 2024-12-18
36
61
 
37
- #### What Changed 👀
62
+ ### What Changed 👀
38
63
 
39
64
  #### 🚀 Features
40
65
 
@@ -46,7 +71,7 @@
46
71
 
47
72
  ## v3.1.0 - 2024-11-16
48
73
 
49
- #### What Changed 👀
74
+ ### What Changed 👀
50
75
 
51
76
  #### 🚀 Features
52
77
 
@@ -55,3 +80,237 @@
55
80
  ### Extra
56
81
 
57
82
  **Full Changelog**: https://github.com/Bugs5382/fastify-hl7/compare/v3.0.0...v3.1.0
83
+
84
+ ## v3.0.0 - 2024-10-31
85
+
86
+ ### What Changed 👀
87
+
88
+ #### 💥 Breaking Changes
89
+
90
+ - update node-hl7-server package to 3.0.0 which has a breaking change
91
+
92
+ #### 🚀 Features
93
+
94
+ - feat: 3.0.0 @Bugs5382 (#78)
95
+ - feat: update typedoc plugin @Bugs5382 (#79)
96
+ - updated packages @Bugs5382 ([743e34c](https://github.com/Bugs5382/fastify-hl7/commit/743e34c40ce44ef1a04a48fb22c52f197a2a0497))
97
+
98
+ ### Extra
99
+
100
+ **Full Changelog**: https://github.com/Bugs5382/fastify-hl7/compare/v2.2.0...v3.0.0
101
+
102
+ ## v2.2.0 - 2024-06-25
103
+
104
+ ### What Changed 👀
105
+
106
+ #### 🚀 Features
107
+
108
+ - feat: updates packages @Bugs5382 (#43)
109
+
110
+ ### Extra
111
+
112
+ **Full Changelog**: https://github.com/Bugs5382/fastify-hl7/compare/v2.1.0...v2.2.0
113
+
114
+ ## v2.1.0 - 2024-02-22
115
+
116
+ ### What Changed 👀
117
+
118
+ #### 🚀 Features
119
+
120
+ - feat: added buildDate @Bugs5382 (#29)
121
+ - feat: added new features in @Bugs5382 (#30)
122
+
123
+ ### Extra
124
+
125
+ **Full Changelog**: https://github.com/Bugs5382/fastify-hl7/compare/v2.0.0...v2.1.0
126
+
127
+ ## v2.0.0 - 2024-02-04
128
+
129
+ ### What Changed 👀
130
+
131
+ #### 💥 Breaking Changes
132
+
133
+ - node 20
134
+
135
+ #### 🚀 Features
136
+
137
+ - feat: first batch of changes @Bugs5382 (#19)
138
+ - feat: v2.0.0 @Bugs5382 (#20)
139
+
140
+ #### 🐛 Bug Fixes
141
+
142
+ - fix: ci actions @Bugs5382 (#22)
143
+
144
+ ### Extra
145
+
146
+ **Full Changelog**: https://github.com/Bugs5382/fastify-hl7/compare/v1.2.0...v2.0.0
147
+
148
+ ## v1.2.0 - 2024-01-18
149
+
150
+ ### What Changed 👀
151
+
152
+ #### 🚀 Features
153
+
154
+ - feat: update server package @Bugs5382 (#17)
155
+ - update server version @Bugs5382 ([f0548d6](https://github.com/Bugs5382/fastify-hl7/commit/f0548d63649546f3b67d4c3d9e9a993e2a4dbced))
156
+
157
+ ### Extra
158
+
159
+ **Full Changelog**: https://github.com/Bugs5382/fastify-hl7/compare/v1.1.4...v1.2.0
160
+
161
+ ## v1.1.4 - 2024-01-18
162
+
163
+ ### What Changed 👀
164
+
165
+ #### 🐛 Bug Fixes
166
+
167
+ - fix: import for ESM @Bugs5382 (#14)
168
+ - update import with .js @Bugs5382 ([4527548](https://github.com/Bugs5382/fastify-hl7/commit/4527548796647c2af74116b8b18273d331bda92b))
169
+ - fix: update import with .js @Bugs5382 (#13)
170
+
171
+ ### Extra
172
+
173
+ **Full Changelog**: https://github.com/Bugs5382/fastify-hl7/compare/v1.1.3...v1.1.4
174
+
175
+ ## v1.1.3 - 2024-01-18
176
+
177
+ ### What Changed 👀
178
+
179
+ #### 🐛 Bug Fixes
180
+
181
+ - fix: added export of FastifyHL7Options @Bugs5382 (#10)
182
+ - fix: export of FastifyHL7Options @Bugs5382 (#11)
183
+
184
+ ### Extra
185
+
186
+ **Full Changelog**: https://github.com/Bugs5382/fastify-hl7/compare/v1.1.2...v1.1.3
187
+
188
+ ## v1.1.2 - 2024-01-11
189
+
190
+ ### What Changed 👀
191
+
192
+ #### 🐛 Bug Fixes
193
+
194
+ - fix: update packages @Bugs5382 (#7)
195
+
196
+ ### Extra
197
+
198
+ **Full Changelog**: https://github.com/Bugs5382/fastify-hl7/compare/v1.1.1...v1.1.2
199
+
200
+ ## v1.1.1 - 2024-01-10
201
+
202
+ ### What Changed 👀
203
+
204
+ #### 🐛 Bug Fixes
205
+
206
+ - fix: update packages @Bugs5382 (#6)
207
+
208
+ ### Extra
209
+
210
+ **Full Changelog**: https://github.com/Bugs5382/fastify-hl7/compare/v1.1.0...v1.1.1
211
+
212
+ ## v1.1.1-beta.1 - 2024-01-10
213
+
214
+ ### What Changed 👀
215
+
216
+ #### 🐛 Bug Fixes
217
+
218
+ - update packages @Bugs5382 ([62dc1ec](https://github.com/Bugs5382/fastify-hl7/commit/62dc1ec5e1735c59f7417df7b102b17404d90030))
219
+
220
+ ### Extra
221
+
222
+ **Full Changelog**: https://github.com/Bugs5382/fastify-hl7/compare/v1.1.0...v1.1.1-beta.1
223
+
224
+ ## v1.0.0-beta.3 - 2024-01-10
225
+
226
+ ### What Changed 👀
227
+
228
+ #### 🐛 Bug Fixes
229
+
230
+ - update packages @Bugs5382 ([62dc1ec](https://github.com/Bugs5382/fastify-hl7/commit/62dc1ec5e1735c59f7417df7b102b17404d90030))
231
+
232
+ ### Extra
233
+
234
+ **Full Changelog**: https://github.com/Bugs5382/fastify-hl7/compare/v1.0.0-beta.2...v1.0.0-beta.3
235
+
236
+ ## v1.1.0 - 2023-12-31
237
+
238
+ ### What Changed 👀
239
+
240
+ #### 🚀 Features
241
+
242
+ - feat: updated packages @Bugs5382 (#5)
243
+
244
+ ### Extra
245
+
246
+ **Full Changelog**: https://github.com/Bugs5382/fastify-hl7/compare/v1.0.0...v1.1.0
247
+
248
+ ## v1.0.0 - 2023-12-30
249
+
250
+ ### What Changed 👀
251
+
252
+ #### 🚀 Features
253
+
254
+ - feat: added functions that get @Bugs5382 (#3)
255
+ - added in @Bugs5382 ([3c340d5](https://github.com/Bugs5382/fastify-hl7/commit/3c340d59ac2861bbf58c90acb28615914410b3ca))
256
+ - buildMessage, publishMessage @Bugs5382 ([fc1d7db](https://github.com/Bugs5382/fastify-hl7/commit/fc1d7db9968030247c518817ce5a6c8f231fa91d))
257
+ - client stuff done @Bugs5382 ([bd6cb46](https://github.com/Bugs5382/fastify-hl7/commit/bd6cb464ad45833b0c3df2623db22ff5737a36ba))
258
+ - develop branch for release @Bugs5382 ([28c5f30](https://github.com/Bugs5382/fastify-hl7/commit/28c5f30f01a88cbec9b04b37b1aadf7ed959a369))
259
+ - first working version @Bugs5382 ([f9d3ffd](https://github.com/Bugs5382/fastify-hl7/commit/f9d3ffd660c9802778adb9732d6e3587be109139))
260
+ - fixed client connections @Bugs5382 ([c421328](https://github.com/Bugs5382/fastify-hl7/commit/c4213281c43f8ee7655f4e6c88cf0d0ad15e8d3b))
261
+ - full example @Bugs5382 ([7c36b2d](https://github.com/Bugs5382/fastify-hl7/commit/7c36b2d02c65a05050ec44889f8745a2c61ede62))
262
+ - initial build @Bugs5382 ([36b35d9](https://github.com/Bugs5382/fastify-hl7/commit/36b35d904231507b6a6004bda4a5f07c2d224233))
263
+ - new design, again. @Bugs5382 ([2113ca3](https://github.com/Bugs5382/fastify-hl7/commit/2113ca3183d91a085791a067e2af6fc69d305aba))
264
+ - registration working @Bugs5382 ([6f54019](https://github.com/Bugs5382/fastify-hl7/commit/6f54019a66aa5c24ec1d7ce3130475ef6b602426))
265
+ - release branch for release @Bugs5382 ([c85e0be](https://github.com/Bugs5382/fastify-hl7/commit/c85e0bec4fbb6019d460e0b5743292e58097cb41))
266
+ - feat: standardized project @Bugs5382 (#1)
267
+ - update server signatures @Bugs5382 ([d1fc0da](https://github.com/Bugs5382/fastify-hl7/commit/d1fc0dad4c3ca5dbfa40b4850cd092f43a82e3d8))
268
+ - feat: v1.0.0 @Bugs5382 (#4)
269
+
270
+ #### 🐛 Bug Fixes
271
+
272
+ - removed .npmignore @Bugs5382 ([bd788da](https://github.com/Bugs5382/fastify-hl7/commit/bd788dad661f7f4e271458d5b633280a9d561fef))
273
+
274
+ ### Extra
275
+
276
+ **Full Changelog**: https://github.com/Bugs5382/fastify-hl7/releases/tag/v1.0.0
277
+
278
+ ## v1.0.0-beta.2 - 2023-12-30
279
+
280
+ ### What Changed 👀
281
+
282
+ #### 🚀 Features
283
+
284
+ - feat: added functions that get @Bugs5382 (#3)
285
+
286
+ ### Extra
287
+
288
+ **Full Changelog**: https://github.com/Bugs5382/fastify-hl7/compare/v1.0.0-beta.1...v1.0.0-beta.2
289
+
290
+ ## v1.0.0-beta.1 - 2023-12-29
291
+
292
+ ### What Changed 👀
293
+
294
+ #### 🚀 Features
295
+
296
+ - added in @Bugs5382 ([3c340d5](https://github.com/Bugs5382/fastify-hl7/commit/3c340d59ac2861bbf58c90acb28615914410b3ca))
297
+ - buildMessage, publishMessage @Bugs5382 ([fc1d7db](https://github.com/Bugs5382/fastify-hl7/commit/fc1d7db9968030247c518817ce5a6c8f231fa91d))
298
+ - client stuff done @Bugs5382 ([bd6cb46](https://github.com/Bugs5382/fastify-hl7/commit/bd6cb464ad45833b0c3df2623db22ff5737a36ba))
299
+ - develop branch for release @Bugs5382 ([28c5f30](https://github.com/Bugs5382/fastify-hl7/commit/28c5f30f01a88cbec9b04b37b1aadf7ed959a369))
300
+ - first working version @Bugs5382 ([f9d3ffd](https://github.com/Bugs5382/fastify-hl7/commit/f9d3ffd660c9802778adb9732d6e3587be109139))
301
+ - fixed client connections @Bugs5382 ([c421328](https://github.com/Bugs5382/fastify-hl7/commit/c4213281c43f8ee7655f4e6c88cf0d0ad15e8d3b))
302
+ - full example @Bugs5382 ([7c36b2d](https://github.com/Bugs5382/fastify-hl7/commit/7c36b2d02c65a05050ec44889f8745a2c61ede62))
303
+ - initial build @Bugs5382 ([36b35d9](https://github.com/Bugs5382/fastify-hl7/commit/36b35d904231507b6a6004bda4a5f07c2d224233))
304
+ - new design, again. @Bugs5382 ([2113ca3](https://github.com/Bugs5382/fastify-hl7/commit/2113ca3183d91a085791a067e2af6fc69d305aba))
305
+ - registration working @Bugs5382 ([6f54019](https://github.com/Bugs5382/fastify-hl7/commit/6f54019a66aa5c24ec1d7ce3130475ef6b602426))
306
+ - release branch for release @Bugs5382 ([c85e0be](https://github.com/Bugs5382/fastify-hl7/commit/c85e0bec4fbb6019d460e0b5743292e58097cb41))
307
+ - feat: standardized project @Bugs5382 (#1)
308
+ - update server signatures @Bugs5382 ([d1fc0da](https://github.com/Bugs5382/fastify-hl7/commit/d1fc0dad4c3ca5dbfa40b4850cd092f43a82e3d8))
309
+
310
+ #### 🐛 Bug Fixes
311
+
312
+ - removed .npmignore @Bugs5382 ([bd788da](https://github.com/Bugs5382/fastify-hl7/commit/bd788dad661f7f4e271458d5b633280a9d561fef))
313
+
314
+ ### Extra
315
+
316
+ **Full Changelog**: https://github.com/Bugs5382/fastify-hl7/releases/tag/v1.0.0-beta.1
package/README.md CHANGED
@@ -39,6 +39,7 @@ contribution from the outside.
39
39
  8. [TLS and server options](#8-tls-and-server-options)
40
40
  9. [Look up live clients and listeners](#9-look-up-live-clients-and-listeners)
41
41
  10. [Error handling when the server is disabled](#10-error-handling-when-the-server-is-disabled)
42
+ 11. [Encapsulate sending in your own plugin](#11-encapsulate-sending-in-your-own-plugin)
42
43
  4. [API Reference](#-api-reference-fastifyhl7)
43
44
  5. [Plugin Options](#-plugin-options)
44
45
  6. [External Libraries](#-external-libraries)
@@ -369,6 +370,152 @@ try {
369
370
 
370
371
  Registering the plugin twice also throws (`FASTIFY_HL7_ERR_SETUP_ERRORS: "Already registered."`).
371
372
 
373
+ ### 11. Encapsulate sending in your own plugin
374
+
375
+ This is the pattern the plugin is built for, and the reason it is a plugin at all. Fastify's
376
+ encapsulation lets you keep every HL7 concern — registering `fastify-hl7`, the version pin, the
377
+ client, the outbound connection, and the ACK handling — in **one plugin**, and expose just a small,
378
+ intent-named surface (a decorator like `app.adt`) to the rest of the app. Routes then send a message
379
+ in one call; they never touch clients, connections, or message headers.
380
+
381
+ Wrap your plugin with [`fastify-plugin`](https://github.com/fastify/fastify-plugin) so the decorator
382
+ is visible to sibling plugins and routes. Without `fp`, the decorator would be trapped inside this
383
+ plugin's own encapsulation context and the rest of the app could not see it.
384
+
385
+ The helper below builds a **validated** `ADT^A01` with `createBuilder("2.7")`, sends it over a
386
+ connection created once at startup, and resolves with the remote's acknowledgement code (`MSA.1`):
387
+
388
+ ```ts
389
+ // plugins/adt.ts
390
+ import fp from "fastify-plugin";
391
+ import fastifyHL7 from "fastify-hl7";
392
+
393
+ // The HL7 version is pinned in one place. The client, the connection, and the
394
+ // builder all use it, so MSH.12 can never drift out of sync.
395
+ const HL7_VERSION = "2.7" as const;
396
+
397
+ // A small, route-facing input — the business shape, not an HL7 message.
398
+ interface Patient {
399
+ mrn: string;
400
+ name: string; // HL7 XPN, e.g. "DOE^JANE^A"
401
+ sex?: string; // HL7 administrative sex, e.g. "F"
402
+ }
403
+
404
+ declare module "fastify" {
405
+ interface FastifyInstance {
406
+ adt: {
407
+ /** Send an ADT^A01 (patient admit) and resolve with the ACK code from MSA.1. */
408
+ sendA01: (patient: Patient) => Promise<string>;
409
+ };
410
+ }
411
+ }
412
+
413
+ export default fp(
414
+ async (app) => {
415
+ // 1. Register fastify-hl7. This app only sends, so the inbound server is off.
416
+ await app.register(fastifyHL7, { enableServer: false });
417
+
418
+ // 2. Wire the client and one outbound connection once, at startup. The ACK
419
+ // handler resolves a pending promise so the helper can await the reply.
420
+ const host = process.env.ADT_HOST ?? "127.0.0.1";
421
+ const port = Number(process.env.ADT_PORT ?? 3001);
422
+
423
+ app.hl7.createClient("adt_host", { host, version: HL7_VERSION });
424
+
425
+ let resolveAck: ((code: string) => void) | undefined;
426
+ const connection = app.hl7.createConnection(
427
+ "adt_host",
428
+ { port, version: HL7_VERSION },
429
+ async (res) => {
430
+ // The remote replies with an ACK/NAK message; MSA.1 carries the code.
431
+ const code = res.getMessage().get("MSA.1").toString();
432
+ resolveAck?.(code);
433
+ },
434
+ );
435
+
436
+ // 3. Expose one intent-named helper. Routes call app.adt.sendA01(patient)
437
+ // and stay ignorant of HL7 framing, the connection, and the version.
438
+ app.decorate("adt", {
439
+ sendA01: async (patient: Patient): Promise<string> => {
440
+ const message = app.hl7
441
+ .createBuilder(HL7_VERSION)
442
+ .buildMSH({
443
+ msh_3: "MY_APP",
444
+ msh_4: "MY_FAC",
445
+ msh_5: "EPIC",
446
+ msh_6: "HOSP",
447
+ msh_9_1: "ADT",
448
+ msh_9_2: "A01",
449
+ msh_10: app.hl7.buildDate(new Date()),
450
+ msh_11_1: "P",
451
+ })
452
+ .buildEVN({ evn_1: "A01", evn_2: new Date() })
453
+ .buildPID({ pid_3: patient.mrn, pid_5: patient.name, pid_8: patient.sex })
454
+ .buildPV1({ pv1_2: "I" }) // patient class: I = inpatient
455
+ .toMessage();
456
+
457
+ const ack = new Promise<string>((resolve) => {
458
+ resolveAck = resolve;
459
+ });
460
+ await connection.sendMessage(message);
461
+ return ack;
462
+ },
463
+ });
464
+
465
+ // 4. No teardown to write: fastify-hl7 registers preClose hooks that close
466
+ // the client and connection automatically when the app shuts down.
467
+ },
468
+ { name: "adt" },
469
+ );
470
+ ```
471
+
472
+ > The ACK handler above resolves a single pending promise, which keeps the example focused on the
473
+ > encapsulation pattern. The handler is per-connection and is not correlated to a specific outgoing
474
+ > message, so if you send several messages concurrently over the same connection you should match each
475
+ > reply to its request yourself — e.g. key pending promises by the `MSH.10` message-control id you set
476
+ > on the outgoing message and read back from the ACK's `MSA.2`.
477
+
478
+ Register it once, then admit a patient from anywhere with a single call:
479
+
480
+ ```ts
481
+ import fastify from "fastify";
482
+ import adt from "./plugins/adt";
483
+
484
+ const app = fastify();
485
+ await app.register(adt);
486
+
487
+ app.post("/admit", async (request) => {
488
+ const ackCode = await app.adt.sendA01(request.body as never);
489
+ return { accepted: ackCode === "AA", ackCode };
490
+ });
491
+
492
+ await app.listen({ port: 3000 });
493
+ ```
494
+
495
+ Why this shape works well:
496
+
497
+ - **One place owns HL7.** Registration, version pin, client, connection, and message building live
498
+ together; the rest of the app depends only on `app.adt`.
499
+ - **Startup wires, routes send.** The client and connection are created once at boot, so the first
500
+ request does not rebuild the connection or re-pin the version.
501
+ - **The version cannot drift.** `HL7_VERSION` feeds `createClient` and `createBuilder`, and the
502
+ builder stamps it into `MSH.12` — so the message a client sends always matches the version that
503
+ client was created with.
504
+ - **Lifecycle is handled for you.** `fastify-hl7`'s `preClose` hooks close the client and connection
505
+ with the app (see [Graceful shutdown](#7-graceful-shutdown)) — important for clean restarts and for
506
+ tests that start and stop Fastify repeatedly.
507
+ - **Swappable.** Because routes only know `app.adt`, you can repoint the host, add a second trigger
508
+ (`sendA08`, an `ORU` result via [recipe 4](#4-build-messages-batches-and-file-batches)), or stub the
509
+ decorator in a test without touching route code.
510
+
511
+ > **Registration order:** register your wrapper plugin (which registers `fastify-hl7` internally)
512
+ > before any plugin or route that uses `app.adt`. Because the wrapper is an `fp` plugin, Fastify
513
+ > guarantees its decorators are in place before sibling plugins and routes load.
514
+ >
515
+ > The types you need — `HL7`, `FastifyHL7Options`, and the client/server option types — are described
516
+ > in the [API Reference](#-api-reference-fastifyhl7); the underlying message, segment, and builder
517
+ > types come from `node-hl7-client` (see [External Libraries](#-external-libraries)).
518
+
372
519
  ## 📖 API Reference (`fastify.hl7`)
373
520
 
374
521
  All methods hang off the `hl7` decorator on the Fastify instance.
package/dist/index.cjs CHANGED
@@ -15,7 +15,7 @@ var __copyProps = (to, from, except, desc) => {
15
15
  }
16
16
  return to;
17
17
  };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
19
19
  value: mod,
20
20
  enumerable: true
21
21
  }) : target, mod));
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["HL7_2_1","HL7_2_2","HL7_2_3","HL7_2_3_1","HL7_2_4","HL7_2_5","HL7_2_5_1","HL7_2_6","HL7_2_7","HL7_2_7_1","HL7_2_8","Batch","FileBatch","Message","Client","Connection","EventEmitter","Inbound","validateOptions","Server"],"sources":["../src/errors.ts","../src/class/hL7Client.ts","../src/class/hL7Server.ts","../src/validation.ts","../src/index.ts"],"sourcesContent":["/*\nMIT License\n\nCopyright (c) 2026 Shane Froebel\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n*/\nimport createError from \"@fastify/error\";\n\nexport const errors = {\n /** Error if there is an setup error of the plugin itself. */\n FASTIFY_HL7_ERR_SETUP_ERRORS: createError(\n \"FASTIFY_HL7_ERR_SETUP_ERRORS\",\n \"Setup error: %s\",\n ),\n /** If an invalid usage error was done, this error would pop up. */\n FASTIFY_HL7_ERR_USAGE: createError(\n \"FASTIFY_HL7_ERR_USAGE\",\n \"Usage error: %s\",\n ),\n};\n","/*\nMIT License\n\nCopyright (c) 2026 Shane Froebel\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n*/\nimport Client, {\n Batch,\n ClientBuilderFileOptions,\n ClientBuilderMessageOptions,\n ClientBuilderOptions,\n ClientListenerOptions,\n ClientOptions,\n Connection,\n createHL7Date,\n FileBatch,\n HL7_2_1,\n HL7_2_2,\n HL7_2_3,\n HL7_2_3_1,\n HL7_2_4,\n HL7_2_5,\n HL7_2_5_1,\n HL7_2_6,\n HL7_2_7,\n HL7_2_7_1,\n HL7_2_8,\n HL7Version,\n isBatch,\n Message,\n OutboundHandler,\n} from \"node-hl7-client\";\n\nimport { AClients } from \"../decorate.js\";\nimport { errors } from \"../errors.js\";\n\n/** Accepted HL7 date-length values, derived from node-hl7-client's\n * `createHL7Date` so it stays in sync with the upstream type. */\nexport type DateLength = Parameters<typeof createHL7Date>[1];\n\n/** Maps an `HL7Version` string to the matching node-hl7-client builder class,\n * so `createBuilder(\"2.7\")` returns a fully typed `HL7_2_7`. */\nexport interface HL7VersionBuilders {\n \"2.1\": HL7_2_1;\n \"2.2\": HL7_2_2;\n \"2.3\": HL7_2_3;\n \"2.3.1\": HL7_2_3_1;\n \"2.4\": HL7_2_4;\n \"2.5\": HL7_2_5;\n \"2.5.1\": HL7_2_5_1;\n \"2.6\": HL7_2_6;\n \"2.7\": HL7_2_7;\n \"2.7.1\": HL7_2_7_1;\n \"2.8\": HL7_2_8;\n}\n\n/** Runtime version -> builder-class lookup backing `createBuilder`. */\nconst HL7_BUILDERS = {\n \"2.1\": HL7_2_1,\n \"2.2\": HL7_2_2,\n \"2.3\": HL7_2_3,\n \"2.3.1\": HL7_2_3_1,\n \"2.4\": HL7_2_4,\n \"2.5\": HL7_2_5,\n \"2.5.1\": HL7_2_5_1,\n \"2.6\": HL7_2_6,\n \"2.7\": HL7_2_7,\n \"2.7.1\": HL7_2_7_1,\n \"2.8\": HL7_2_8,\n} as const;\n\nexport class HL7Client {\n /** @internal */\n private readonly _clientConnections: AClients[];\n\n constructor() {\n this._clientConnections = [];\n }\n\n /**\n * Build a HL7 Batch\n * @remarks Create a properly formatted HL7 Batch.\n * @since 1.0.0\n * @param props\n */\n buildBatch(properties?: ClientBuilderOptions): Batch {\n return new Batch({ ...properties });\n }\n\n /**\n * Build Date\n * @remarks Build a date string based off HL7 Standards\n * @since 2.1.0\n * @param date\n * @param length Options are 8, 12, or 14 (default)\n */\n buildDate(date: Date, length?: DateLength): string {\n return createHL7Date(date, length);\n }\n\n /**\n * Build a HL7 File Batch\n * @remarks Create a properly formatted HL7 File Batch.\n * @since 1.0.0\n * @param props\n */\n buildFileBatch(properties?: ClientBuilderFileOptions): FileBatch {\n if (\n properties !== undefined &&\n (properties.fullFilePath !== undefined ||\n properties.fileBuffer !== undefined)\n ) {\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n \"Use readFile or readFileBuffer method. This is for building.\",\n );\n }\n return new FileBatch({ ...properties });\n }\n\n /**\n * Build a HL7 Message\n * @remarks Create a properly formatted HL7 message.\n * @since 1.0.0\n * @param props\n */\n buildMessage(properties?: ClientBuilderMessageOptions): Message {\n if (properties !== undefined && properties.text !== undefined) {\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n \"Use processMessage method. This is for building.\",\n );\n }\n return new Message({ ...properties });\n }\n\n /**\n * Close All Connections for this Client\n * @since 1.0.0\n */\n async closeAll(): Promise<boolean> {\n for (const outbound of this._clientConnections) {\n outbound.ports.map(async (port) => {\n await port.connection.close();\n });\n }\n return true;\n }\n\n /**\n * Create a version-pinned HL7 message builder\n * @remarks Returns the node-hl7-client builder for the given HL7 version, with\n * per-version field validation (withdrawn fields throw, backward-compatibility\n * fields warn, segments not in that version are rejected). Chain `build*`\n * methods and finish with `toMessage()`.\n * @since 4.0.0\n * @param version One of the supported HL7 versions (\"2.1\" - \"2.8\").\n * @param properties Optional builder options (date format, separators, hardError).\n * @example\n * ```ts\n * const message = fastify.hl7.createBuilder(\"2.7\")\n * .buildMSH({ msh_9_1: \"ADT\", msh_9_2: \"A01\", msh_11_1: \"P\" })\n * .buildPID({ pid_3: \"MRN12345\", pid_5: \"DOE^JANE^A\" })\n * .toMessage();\n * ```\n */\n createBuilder<V extends HL7Version>(\n version: V,\n properties?: ClientBuilderOptions,\n ): HL7VersionBuilders[V] {\n const Builder = HL7_BUILDERS[version] as new (\n properties?: ClientBuilderOptions,\n ) => HL7VersionBuilders[V];\n return new Builder(properties);\n }\n\n /**\n *\n * @param name\n * @param props\n */\n createClient(name: string, properties: ClientOptions): Client {\n const nameFormat = /[ `!@#$%^&*()+\\-=\\[\\]{};':\"\\\\|,.<>\\/?~]/;\n if (nameFormat.test(name)) {\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n \"name must not contain certain characters: `!@#$%^&*()+\\\\-=\\\\[\\\\]{};':\\\"\\\\\\\\|,.<>\\\\/?~.\",\n );\n }\n\n // make sure that this does not exist already...\n for (const connections of this._clientConnections) {\n if (connections.name === name) {\n throw new errors.FASTIFY_HL7_ERR_USAGE(\"name must be unique.\");\n }\n // nto in the Client class yet\n // if (client.getHost() === props.host) {\n // throw new errors.FASTIFY_HL7_ERR_USAGE(`host is already a pointer. Name is: ${connections.name}`)\n // }\n }\n\n // new client\n const client = new Client(properties);\n\n // add it to the collection\n this._clientConnections.push({\n client,\n name,\n ports: [],\n });\n\n return client;\n }\n\n /**\n * Create an HL7 Outbound Connection\n * @remarks Connect to an HL7 Server/Broker\n * @since 1.0.0\n * @param name The name stored within created client connections.\n * @param props\n * @param handler\n */\n createConnection(\n name: string,\n properties: ClientListenerOptions,\n handler: OutboundHandler,\n ): Connection {\n const nameFormat = /[ `!@#$%^&*()+\\-=\\[\\]{};':\"\\\\|,.<>\\/?~]/;\n if (nameFormat.test(name)) {\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n \"name must not contain certain characters: `!@#$%^&*()+\\\\-=\\\\[\\\\]{};':\\\"\\\\\\\\|,.<>\\\\/?~.\",\n );\n }\n\n const getConnection = this._clientConnections.find(\n (client) => client.name === name,\n );\n\n if (getConnection !== undefined) {\n // make sure port is not used all ready\n for (const outbound of getConnection.ports) {\n if (outbound.port === properties.port.toString()) {\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n `port ${properties.port} is already used with this client. Choose a new outgoing port.`,\n );\n }\n }\n\n // create outbound port to the server in getConnection.client\n const outbound = new Connection(\n getConnection.client,\n properties,\n handler,\n );\n\n // add it to the array of known ports. need to know this, so we can get it later if needed.\n getConnection.ports.push({\n connection: outbound,\n port: properties.port.toString(),\n });\n\n // return it right away. the user might do something with it.\n return outbound;\n }\n\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n \"No valid client. Improper setup of a outbound connection.\",\n );\n }\n\n /**\n * Get Client by the name\n * @since 1.0.0\n * @param name\n */\n getClientByName(name: string): Client | undefined {\n const connection = this._clientConnections.find(\n (connection) => connection.name === name,\n );\n if (connection !== undefined) {\n return connection.client;\n }\n return undefined;\n }\n\n /**\n * Get Connection by Port\n * @since 1.0.0\n * @param port\n */\n getClientConnectionByPort(port: string): Connection | undefined {\n let connection: Connection | undefined;\n for (const outbound of this._clientConnections) {\n for (const aPort of outbound.ports) {\n if (aPort.port === port) {\n connection = aPort.connection;\n }\n }\n }\n return connection;\n }\n\n /**\n * Process a HL7\n * @remarks A HL7 message that could either be a Message (MSH) or Batch (BHS)\n * @since 1.0.0\n * @param text Raw HL& String\n */\n processHL7(text: string): Batch | Message {\n return isBatch(text) ? new Batch({ text }) : new Message({ text });\n }\n\n /**\n * Read File\n * @remarks Pass the correct path of the file you want to read.\n * @since 1.0.0\n * @param fullFilePath\n * @returns FileBatch\n * @example\n * ```ts\n * fastify.hl7.readFile( path.join('temp/', 'hl7.readTestBHS.20231208.hl7') )\n * ```\n */\n readFile(fullFilePath: string): FileBatch {\n return new FileBatch({ fullFilePath });\n }\n\n /**\n * Read a File Buffer\n * @remarks Translate an already Buffered HL7 FHS segment to decode it.\n * @since 1.0.0\n * @param fileBuffer\n * @returns FileBatch\n * @example\n * ```ts\n * const fileBuffer = fs.readFileSync(path.join('temp/', 'hl7.readTestBHS.20231208.hl7'))\n * fastify.hl7.readFileBuffer(fileBuffer)\n * ```\n */\n readFileBuffer(fileBuffer: Buffer): FileBatch {\n return new FileBatch({ fileBuffer });\n }\n}\n","/*\nMIT License\n\nCopyright (c) 2026 Shane Froebel\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n*/\nimport Server, {\n Inbound,\n InboundHandler,\n ListenerOptions,\n} from \"node-hl7-server\";\nimport { EventEmitter } from \"node:events\";\n\nimport { AServers } from \"../decorate.js\";\nimport { errors } from \"../errors.js\";\n\nexport class HL7Server extends EventEmitter {\n private readonly _server: Server;\n private readonly _serverInboundConnections: AServers[];\n\n constructor(server: Server) {\n super();\n this._server = server;\n this._serverInboundConnections = [];\n }\n\n /**\n * Close Inbound connection.\n * @since 1.0.0\n * @param port\n */\n async close(port: string): Promise<boolean> {\n const inbound = this._serverInboundConnections.find(\n (server) => server.port === port,\n );\n if (inbound !== undefined) {\n return await inbound.server.close(); // close the server for all inbound connections\n }\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n `No inbound server listening on port: ${port}`,\n );\n }\n\n /**\n * Close all Inbound connections.\n * @since 1.0.0\n */\n async closeAll(): Promise<boolean> {\n this._serverInboundConnections.map(async (inbound) => {\n await inbound.server.close();\n });\n return true;\n }\n\n /**\n * Create Inbound connection.\n * @since 1.0.0\n * @param name\n * @param props\n * @param handler\n */\n createInbound(\n name: string,\n properties: ListenerOptions,\n handler: InboundHandler,\n ): Inbound {\n const nameFormat = /[ `!@#$%^&*()+\\-=\\[\\]{};':\"\\\\|,.<>\\/?~]/;\n if (nameFormat.test(name)) {\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n \"name must not contain certain characters: `!@#$%^&*()+\\\\-=\\\\[\\\\]{};':\\\"\\\\\\\\|,.<>\\\\/?~.\",\n );\n }\n\n const inbound = new Inbound(this._server, properties, handler);\n\n this._serverInboundConnections.push({\n name,\n port: properties.port.toString(),\n server: inbound,\n });\n\n this.emit(\"inbound\", properties.port.toString());\n\n return inbound;\n }\n\n /**\n * Get Server Inbound Connection by Name\n * @since 1.0.0\n * @param name\n */\n getServerByName(name: string): Inbound | undefined {\n const inbound = this._serverInboundConnections.find(\n (inbound) => inbound.name === name,\n );\n if (inbound !== undefined) {\n return inbound.server;\n }\n return undefined;\n }\n\n /**\n * Get Server Inbound Connection by Port\n * @since 1.0.0\n * @param port\n */\n getServerByPort(port: string): Inbound | undefined {\n const inbound = this._serverInboundConnections.find(\n (inbound) => inbound.port === port,\n );\n if (inbound !== undefined) {\n return inbound.server;\n }\n return undefined;\n }\n}\n","/*\nMIT License\n\nCopyright (c) 2026 Shane Froebel\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n*/\nimport { FastifyHL7Options } from \"./decorate.js\";\n\n/**\n * @since 1.0.0\n * @param opts\n */\nexport const validateOpts = async (\n options: FastifyHL7Options,\n): Promise<FastifyHL7Options> => {\n // Mandatory, Defaulted\n if (options.enableServer === undefined) {\n options.enableServer = true;\n }\n\n return options;\n};\n","/*\nMIT License\n\nCopyright (c) 2026 Shane Froebel\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n*/\nimport { FastifyInstance, HL7 } from \"fastify\";\nimport fp from \"fastify-plugin\";\nimport Client, {\n Batch,\n ClientBuilderFileOptions,\n ClientBuilderMessageOptions,\n ClientBuilderOptions,\n Connection,\n FileBatch,\n HL7Version,\n Message,\n} from \"node-hl7-client\";\nimport Server, {\n Inbound,\n InboundHandler,\n ListenerOptions,\n} from \"node-hl7-server\";\n\nimport type { FastifyHL7Options } from \"./decorate.js\";\n\nimport {\n type DateLength,\n HL7Client,\n type HL7VersionBuilders,\n} from \"./class/hL7Client.js\";\nimport { HL7Server } from \"./class/hL7Server.js\";\nimport { errors } from \"./errors.js\";\nimport { validateOpts as validateOptions } from \"./validation.js\";\nexport { type FastifyHL7Options } from \"./decorate.js\";\n\n/**\n * @since 1.0.0\n * @param fastify\n * @param _opts\n * @param connection\n */\nconst decorateFastifyInstance = (\n fastify: FastifyInstance,\n _options: FastifyHL7Options,\n connection: HL7,\n): void => {\n if (fastify.hl7 !== undefined) {\n throw new errors.FASTIFY_HL7_ERR_SETUP_ERRORS(\"Already registered.\");\n }\n\n if (fastify.hl7 === undefined) {\n fastify.log.trace(\"[fastify-hl7] Decorate Fastify\");\n fastify.decorate(\"hl7\", connection);\n }\n};\n\nconst fastifyHL7 = fp<FastifyHL7Options>(async (fastify, options) => {\n const generatedOptions = await validateOptions(options);\n options = { ...options, ...generatedOptions };\n\n // Create server.\n // Since there can only be one server per IP address\n // (i.e., the host this is running on.) There can only be more than one.\n // A server can host many HL7 Inbound connections via different ports, this is fine.\n // Clients are different as an app could talk to different servers, on many ports.\n // So we need to do something different.\n const serverInstance =\n options.enableServer !== undefined && options.enableServer\n ? new Server(options.serverOptions)\n : undefined;\n\n // Server Functions\n let server: HL7Server | undefined;\n if (serverInstance !== undefined) {\n // Server Functions\n server = new HL7Server(serverInstance);\n\n server.on(\"inbound\", (port: string) => {\n fastify.log.info(\"HL7 Inbound Server Listening on Port %s\", port);\n });\n\n // before we close fastify, make sure all server instances are closed\n fastify.addHook(\"preClose\", async () => {\n if (server !== undefined) {\n await server.closeAll();\n }\n });\n }\n\n // Client Functions\n const client = new HL7Client();\n\n // run these before fastify closes\n fastify.addHook(\"preClose\", async () => {\n if (client !== undefined) {\n await client.closeAll();\n }\n });\n\n decorateFastifyInstance(fastify, options, {\n _serverInstance: serverInstance,\n buildBatch: function (properties: ClientBuilderOptions | undefined): Batch {\n return client.buildBatch(properties);\n },\n buildDate: function (date: Date, length?: DateLength): string {\n return client.buildDate(date, length);\n },\n buildFileBatch: function (\n properties: ClientBuilderFileOptions | undefined,\n ): FileBatch {\n return client.buildFileBatch(properties);\n },\n buildMessage: function (\n properties: ClientBuilderMessageOptions | undefined,\n ): Message {\n return client.buildMessage(properties);\n },\n closeServer: async function (port: string): Promise<boolean> {\n if (server !== undefined) {\n return await server.close(port);\n }\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n \"server was not started. re-register plugin with enableServer set to true.\",\n );\n },\n closeServerAll: async (): Promise<boolean> => {\n if (server !== undefined) {\n return await server.closeAll();\n }\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n \"server was not started. re-register plugin with enableServer set to true.\",\n );\n },\n createBuilder: function <V extends HL7Version>(\n version: V,\n properties?: ClientBuilderOptions,\n ): HL7VersionBuilders[V] {\n return client.createBuilder(version, properties);\n },\n createClient: function (name, properties): Client {\n return client.createClient(name, properties);\n },\n createConnection: function (name, properties, handler) {\n return client.createConnection(name, properties, handler);\n },\n createInbound: function (\n name: string,\n properties: ListenerOptions,\n handler: InboundHandler,\n ): Inbound {\n if (server !== undefined) {\n return server.createInbound(name, properties, handler);\n }\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n \"server was not started. re-register plugin with enableServer set to true.\",\n );\n },\n getClientByName: function (name: string): Client | undefined {\n return client.getClientByName(name);\n },\n getClientConnectionByPort: function (port: string): Connection | undefined {\n return client.getClientConnectionByPort(port);\n },\n getServerByName: function (name: string): Inbound | undefined {\n if (server !== undefined) {\n return server.getServerByName(name);\n }\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n \"server was not started. re-register plugin with enableServer set to true.\",\n );\n },\n getServerByPort: function (port: string): Inbound | undefined {\n if (server !== undefined) {\n return server.getServerByPort(port);\n }\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n \"server was not started. re-register plugin with enableServer set to true.\",\n );\n },\n processHL7: function (text: string): Batch | Message {\n return client.processHL7(text);\n },\n readFile: function (fullFilePath: string): FileBatch {\n return client.readFile(fullFilePath);\n },\n readFileBuffer: function (fileBuffer: Buffer): FileBatch {\n return client.readFileBuffer(fileBuffer);\n },\n });\n});\n\nexport default fastifyHL7;\n\nexport * from \"./types.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,SAAS;;CAEpB,+BAAA,GAAA,eAAA,QAAA,CACE,gCACA,iBACF;;CAEA,wBAAA,GAAA,eAAA,QAAA,CACE,yBACA,iBACF;AACF;;;;ACsCA,MAAM,eAAe;CACnB,OAAOA,gBAAAA;CACP,OAAOC,gBAAAA;CACP,OAAOC,gBAAAA;CACP,SAASC,gBAAAA;CACT,OAAOC,gBAAAA;CACP,OAAOC,gBAAAA;CACP,SAASC,gBAAAA;CACT,OAAOC,gBAAAA;CACP,OAAOC,gBAAAA;CACP,SAASC,gBAAAA;CACT,OAAOC,gBAAAA;AACT;AAEA,IAAa,YAAb,MAAuB;;CAErB;CAEA,cAAc;EACZ,KAAK,qBAAqB,CAAC;CAC7B;;;;;;;CAQA,WAAW,YAA0C;EAC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OAAO,OAAO,cAAc,SAAS,UAAU;EACjD;EACA,cAAc,SAAU,MAAM,YAAoB;GAChD,OAAO,OAAO,aAAa,MAAM,UAAU;EAC7C;EACA,kBAAkB,SAAU,MAAM,YAAY,SAAS;GACrD,OAAO,OAAO,iBAAiB,MAAM,YAAY,OAAO;EAC1D;EACA,eAAe,SACb,MACA,YACA,SACS;GACT,IAAI,WAAW,KAAA,GACb,OAAO,OAAO,cAAc,MAAM,YAAY,OAAO;GAEvD,MAAM,IAAI,OAAO,sBACf,2EACF;EACF;EACA,iBAAiB,SAAU,MAAkC;GAC3D,OAAO,OAAO,gBAAgB,IAAI;EACpC;EACA,2BAA2B,SAAU,MAAsC;GACzE,OAAO,OAAO,0BAA0B,IAAI;EAC9C;EACA,iBAAiB,SAAU,MAAmC;GAC5D,IAAI,WAAW,KAAA,GACb,OAAO,OAAO,gBAAgB,IAAI;GAEpC,MAAM,IAAI,OAAO,sBACf,2EACF;EACF;EACA,iBAAiB,SAAU,MAAmC;GAC5D,IAAI,WAAW,KAAA,GACb,OAAO,OAAO,gBAAgB,IAAI;GAEpC,MAAM,IAAI,OAAO,sBACf,2EACF;EACF;EACA,YAAY,SAAU,MAA+B;GACnD,OAAO,OAAO,WAAW,IAAI;EAC/B;EACA,UAAU,SAAU,cAAiC;GACnD,OAAO,OAAO,SAAS,YAAY;EACrC;EACA,gBAAgB,SAAU,YAA+B;GACvD,OAAO,OAAO,eAAe,UAAU;EACzC;CACF,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"index.cjs","names":["createError","HL7_2_1","HL7_2_2","HL7_2_3","HL7_2_3_1","HL7_2_4","HL7_2_5","HL7_2_5_1","HL7_2_6","HL7_2_7","HL7_2_7_1","HL7_2_8","Batch","createHL7Date","FileBatch","Message","Client","Connection","isBatch","EventEmitter","Inbound","fp","validateOptions","Server"],"sources":["../src/errors.ts","../src/class/hL7Client.ts","../src/class/hL7Server.ts","../src/validation.ts","../src/index.ts"],"sourcesContent":["/*\nMIT License\n\nCopyright (c) 2026 Shane Froebel\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n*/\nimport createError from \"@fastify/error\";\n\nexport const errors = {\n /** Error if there is an setup error of the plugin itself. */\n FASTIFY_HL7_ERR_SETUP_ERRORS: createError(\n \"FASTIFY_HL7_ERR_SETUP_ERRORS\",\n \"Setup error: %s\",\n ),\n /** If an invalid usage error was done, this error would pop up. */\n FASTIFY_HL7_ERR_USAGE: createError(\n \"FASTIFY_HL7_ERR_USAGE\",\n \"Usage error: %s\",\n ),\n};\n","/*\nMIT License\n\nCopyright (c) 2026 Shane Froebel\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n*/\nimport Client, {\n Batch,\n ClientBuilderFileOptions,\n ClientBuilderMessageOptions,\n ClientBuilderOptions,\n ClientListenerOptions,\n ClientOptions,\n Connection,\n createHL7Date,\n FileBatch,\n HL7_2_1,\n HL7_2_2,\n HL7_2_3,\n HL7_2_3_1,\n HL7_2_4,\n HL7_2_5,\n HL7_2_5_1,\n HL7_2_6,\n HL7_2_7,\n HL7_2_7_1,\n HL7_2_8,\n HL7Version,\n isBatch,\n Message,\n OutboundHandler,\n} from \"node-hl7-client\";\n\nimport { AClients } from \"../decorate.js\";\nimport { errors } from \"../errors.js\";\n\n/** Accepted HL7 date-length values, derived from node-hl7-client's\n * `createHL7Date` so it stays in sync with the upstream type. */\nexport type DateLength = Parameters<typeof createHL7Date>[1];\n\n/** Maps an `HL7Version` string to the matching node-hl7-client builder class,\n * so `createBuilder(\"2.7\")` returns a fully typed `HL7_2_7`. */\nexport interface HL7VersionBuilders {\n \"2.1\": HL7_2_1;\n \"2.2\": HL7_2_2;\n \"2.3\": HL7_2_3;\n \"2.3.1\": HL7_2_3_1;\n \"2.4\": HL7_2_4;\n \"2.5\": HL7_2_5;\n \"2.5.1\": HL7_2_5_1;\n \"2.6\": HL7_2_6;\n \"2.7\": HL7_2_7;\n \"2.7.1\": HL7_2_7_1;\n \"2.8\": HL7_2_8;\n}\n\n/** Runtime version -> builder-class lookup backing `createBuilder`. */\nconst HL7_BUILDERS = {\n \"2.1\": HL7_2_1,\n \"2.2\": HL7_2_2,\n \"2.3\": HL7_2_3,\n \"2.3.1\": HL7_2_3_1,\n \"2.4\": HL7_2_4,\n \"2.5\": HL7_2_5,\n \"2.5.1\": HL7_2_5_1,\n \"2.6\": HL7_2_6,\n \"2.7\": HL7_2_7,\n \"2.7.1\": HL7_2_7_1,\n \"2.8\": HL7_2_8,\n} as const;\n\nexport class HL7Client {\n /** @internal */\n private readonly _clientConnections: AClients[];\n\n constructor() {\n this._clientConnections = [];\n }\n\n /**\n * Build a HL7 Batch\n * @remarks Create a properly formatted HL7 Batch.\n * @since 1.0.0\n * @param props\n */\n buildBatch(properties?: ClientBuilderOptions): Batch {\n return new Batch({ ...properties });\n }\n\n /**\n * Build Date\n * @remarks Build a date string based off HL7 Standards\n * @since 2.1.0\n * @param date\n * @param length Options are 8, 12, or 14 (default)\n */\n buildDate(date: Date, length?: DateLength): string {\n return createHL7Date(date, length);\n }\n\n /**\n * Build a HL7 File Batch\n * @remarks Create a properly formatted HL7 File Batch.\n * @since 1.0.0\n * @param props\n */\n buildFileBatch(properties?: ClientBuilderFileOptions): FileBatch {\n if (\n properties !== undefined &&\n (properties.fullFilePath !== undefined ||\n properties.fileBuffer !== undefined)\n ) {\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n \"Use readFile or readFileBuffer method. This is for building.\",\n );\n }\n return new FileBatch({ ...properties });\n }\n\n /**\n * Build a HL7 Message\n * @remarks Create a properly formatted HL7 message.\n * @since 1.0.0\n * @param props\n */\n buildMessage(properties?: ClientBuilderMessageOptions): Message {\n if (properties !== undefined && properties.text !== undefined) {\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n \"Use processMessage method. This is for building.\",\n );\n }\n return new Message({ ...properties });\n }\n\n /**\n * Close All Connections for this Client\n * @since 1.0.0\n */\n async closeAll(): Promise<boolean> {\n for (const outbound of this._clientConnections) {\n outbound.ports.map(async (port) => {\n await port.connection.close();\n });\n }\n return true;\n }\n\n /**\n * Create a version-pinned HL7 message builder\n * @remarks Returns the node-hl7-client builder for the given HL7 version, with\n * per-version field validation (withdrawn fields throw, backward-compatibility\n * fields warn, segments not in that version are rejected). Chain `build*`\n * methods and finish with `toMessage()`.\n * @since 4.0.0\n * @param version One of the supported HL7 versions (\"2.1\" - \"2.8\").\n * @param properties Optional builder options (date format, separators, hardError).\n * @example\n * ```ts\n * const message = fastify.hl7.createBuilder(\"2.7\")\n * .buildMSH({ msh_9_1: \"ADT\", msh_9_2: \"A01\", msh_11_1: \"P\" })\n * .buildPID({ pid_3: \"MRN12345\", pid_5: \"DOE^JANE^A\" })\n * .toMessage();\n * ```\n */\n createBuilder<V extends HL7Version>(\n version: V,\n properties?: ClientBuilderOptions,\n ): HL7VersionBuilders[V] {\n const Builder = HL7_BUILDERS[version] as new (\n properties?: ClientBuilderOptions,\n ) => HL7VersionBuilders[V];\n return new Builder(properties);\n }\n\n /**\n *\n * @param name\n * @param props\n */\n createClient(name: string, properties: ClientOptions): Client {\n const nameFormat = /[ `!@#$%^&*()+\\-=\\[\\]{};':\"\\\\|,.<>\\/?~]/;\n if (nameFormat.test(name)) {\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n \"name must not contain certain characters: `!@#$%^&*()+\\\\-=\\\\[\\\\]{};':\\\"\\\\\\\\|,.<>\\\\/?~.\",\n );\n }\n\n // make sure that this does not exist already...\n for (const connections of this._clientConnections) {\n if (connections.name === name) {\n throw new errors.FASTIFY_HL7_ERR_USAGE(\"name must be unique.\");\n }\n // nto in the Client class yet\n // if (client.getHost() === props.host) {\n // throw new errors.FASTIFY_HL7_ERR_USAGE(`host is already a pointer. Name is: ${connections.name}`)\n // }\n }\n\n // new client\n const client = new Client(properties);\n\n // add it to the collection\n this._clientConnections.push({\n client,\n name,\n ports: [],\n });\n\n return client;\n }\n\n /**\n * Create an HL7 Outbound Connection\n * @remarks Connect to an HL7 Server/Broker\n * @since 1.0.0\n * @param name The name stored within created client connections.\n * @param props\n * @param handler\n */\n createConnection(\n name: string,\n properties: ClientListenerOptions,\n handler: OutboundHandler,\n ): Connection {\n const nameFormat = /[ `!@#$%^&*()+\\-=\\[\\]{};':\"\\\\|,.<>\\/?~]/;\n if (nameFormat.test(name)) {\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n \"name must not contain certain characters: `!@#$%^&*()+\\\\-=\\\\[\\\\]{};':\\\"\\\\\\\\|,.<>\\\\/?~.\",\n );\n }\n\n const getConnection = this._clientConnections.find(\n (client) => client.name === name,\n );\n\n if (getConnection !== undefined) {\n // make sure port is not used all ready\n for (const outbound of getConnection.ports) {\n if (outbound.port === properties.port.toString()) {\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n `port ${properties.port} is already used with this client. Choose a new outgoing port.`,\n );\n }\n }\n\n // create outbound port to the server in getConnection.client\n const outbound = new Connection(\n getConnection.client,\n properties,\n handler,\n );\n\n // add it to the array of known ports. need to know this, so we can get it later if needed.\n getConnection.ports.push({\n connection: outbound,\n port: properties.port.toString(),\n });\n\n // return it right away. the user might do something with it.\n return outbound;\n }\n\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n \"No valid client. Improper setup of a outbound connection.\",\n );\n }\n\n /**\n * Get Client by the name\n * @since 1.0.0\n * @param name\n */\n getClientByName(name: string): Client | undefined {\n const connection = this._clientConnections.find(\n (connection) => connection.name === name,\n );\n if (connection !== undefined) {\n return connection.client;\n }\n return undefined;\n }\n\n /**\n * Get Connection by Port\n * @since 1.0.0\n * @param port\n */\n getClientConnectionByPort(port: string): Connection | undefined {\n let connection: Connection | undefined;\n for (const outbound of this._clientConnections) {\n for (const aPort of outbound.ports) {\n if (aPort.port === port) {\n connection = aPort.connection;\n }\n }\n }\n return connection;\n }\n\n /**\n * Process a HL7\n * @remarks A HL7 message that could either be a Message (MSH) or Batch (BHS)\n * @since 1.0.0\n * @param text Raw HL& String\n */\n processHL7(text: string): Batch | Message {\n return isBatch(text) ? new Batch({ text }) : new Message({ text });\n }\n\n /**\n * Read File\n * @remarks Pass the correct path of the file you want to read.\n * @since 1.0.0\n * @param fullFilePath\n * @returns FileBatch\n * @example\n * ```ts\n * fastify.hl7.readFile( path.join('temp/', 'hl7.readTestBHS.20231208.hl7') )\n * ```\n */\n readFile(fullFilePath: string): FileBatch {\n return new FileBatch({ fullFilePath });\n }\n\n /**\n * Read a File Buffer\n * @remarks Translate an already Buffered HL7 FHS segment to decode it.\n * @since 1.0.0\n * @param fileBuffer\n * @returns FileBatch\n * @example\n * ```ts\n * const fileBuffer = fs.readFileSync(path.join('temp/', 'hl7.readTestBHS.20231208.hl7'))\n * fastify.hl7.readFileBuffer(fileBuffer)\n * ```\n */\n readFileBuffer(fileBuffer: Buffer): FileBatch {\n return new FileBatch({ fileBuffer });\n }\n}\n","/*\nMIT License\n\nCopyright (c) 2026 Shane Froebel\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n*/\nimport Server, {\n Inbound,\n InboundHandler,\n ListenerOptions,\n} from \"node-hl7-server\";\nimport { EventEmitter } from \"node:events\";\n\nimport { AServers } from \"../decorate.js\";\nimport { errors } from \"../errors.js\";\n\nexport class HL7Server extends EventEmitter {\n private readonly _server: Server;\n private readonly _serverInboundConnections: AServers[];\n\n constructor(server: Server) {\n super();\n this._server = server;\n this._serverInboundConnections = [];\n }\n\n /**\n * Close Inbound connection.\n * @since 1.0.0\n * @param port\n */\n async close(port: string): Promise<boolean> {\n const inbound = this._serverInboundConnections.find(\n (server) => server.port === port,\n );\n if (inbound !== undefined) {\n return await inbound.server.close(); // close the server for all inbound connections\n }\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n `No inbound server listening on port: ${port}`,\n );\n }\n\n /**\n * Close all Inbound connections.\n * @since 1.0.0\n */\n async closeAll(): Promise<boolean> {\n this._serverInboundConnections.map(async (inbound) => {\n await inbound.server.close();\n });\n return true;\n }\n\n /**\n * Create Inbound connection.\n * @since 1.0.0\n * @param name\n * @param props\n * @param handler\n */\n createInbound(\n name: string,\n properties: ListenerOptions,\n handler: InboundHandler,\n ): Inbound {\n const nameFormat = /[ `!@#$%^&*()+\\-=\\[\\]{};':\"\\\\|,.<>\\/?~]/;\n if (nameFormat.test(name)) {\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n \"name must not contain certain characters: `!@#$%^&*()+\\\\-=\\\\[\\\\]{};':\\\"\\\\\\\\|,.<>\\\\/?~.\",\n );\n }\n\n const inbound = new Inbound(this._server, properties, handler);\n\n this._serverInboundConnections.push({\n name,\n port: properties.port.toString(),\n server: inbound,\n });\n\n this.emit(\"inbound\", properties.port.toString());\n\n return inbound;\n }\n\n /**\n * Get Server Inbound Connection by Name\n * @since 1.0.0\n * @param name\n */\n getServerByName(name: string): Inbound | undefined {\n const inbound = this._serverInboundConnections.find(\n (inbound) => inbound.name === name,\n );\n if (inbound !== undefined) {\n return inbound.server;\n }\n return undefined;\n }\n\n /**\n * Get Server Inbound Connection by Port\n * @since 1.0.0\n * @param port\n */\n getServerByPort(port: string): Inbound | undefined {\n const inbound = this._serverInboundConnections.find(\n (inbound) => inbound.port === port,\n );\n if (inbound !== undefined) {\n return inbound.server;\n }\n return undefined;\n }\n}\n","/*\nMIT License\n\nCopyright (c) 2026 Shane Froebel\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n*/\nimport { FastifyHL7Options } from \"./decorate.js\";\n\n/**\n * @since 1.0.0\n * @param opts\n */\nexport const validateOpts = async (\n options: FastifyHL7Options,\n): Promise<FastifyHL7Options> => {\n // Mandatory, Defaulted\n if (options.enableServer === undefined) {\n options.enableServer = true;\n }\n\n return options;\n};\n","/*\nMIT License\n\nCopyright (c) 2026 Shane Froebel\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n*/\nimport { FastifyInstance, HL7 } from \"fastify\";\nimport fp from \"fastify-plugin\";\nimport Client, {\n Batch,\n ClientBuilderFileOptions,\n ClientBuilderMessageOptions,\n ClientBuilderOptions,\n Connection,\n FileBatch,\n HL7Version,\n Message,\n} from \"node-hl7-client\";\nimport Server, {\n Inbound,\n InboundHandler,\n ListenerOptions,\n} from \"node-hl7-server\";\n\nimport type { FastifyHL7Options } from \"./decorate.js\";\n\nimport {\n type DateLength,\n HL7Client,\n type HL7VersionBuilders,\n} from \"./class/hL7Client.js\";\nimport { HL7Server } from \"./class/hL7Server.js\";\nimport { errors } from \"./errors.js\";\nimport { validateOpts as validateOptions } from \"./validation.js\";\nexport { type FastifyHL7Options } from \"./decorate.js\";\n\n/**\n * @since 1.0.0\n * @param fastify\n * @param _opts\n * @param connection\n */\nconst decorateFastifyInstance = (\n fastify: FastifyInstance,\n _options: FastifyHL7Options,\n connection: HL7,\n): void => {\n if (fastify.hl7 !== undefined) {\n throw new errors.FASTIFY_HL7_ERR_SETUP_ERRORS(\"Already registered.\");\n }\n\n if (fastify.hl7 === undefined) {\n fastify.log.trace(\"[fastify-hl7] Decorate Fastify\");\n fastify.decorate(\"hl7\", connection);\n }\n};\n\nconst fastifyHL7 = fp<FastifyHL7Options>(async (fastify, options) => {\n const generatedOptions = await validateOptions(options);\n options = { ...options, ...generatedOptions };\n\n // Create server.\n // Since there can only be one server per IP address\n // (i.e., the host this is running on.) There can only be more than one.\n // A server can host many HL7 Inbound connections via different ports, this is fine.\n // Clients are different as an app could talk to different servers, on many ports.\n // So we need to do something different.\n const serverInstance =\n options.enableServer !== undefined && options.enableServer\n ? new Server(options.serverOptions)\n : undefined;\n\n // Server Functions\n let server: HL7Server | undefined;\n if (serverInstance !== undefined) {\n // Server Functions\n server = new HL7Server(serverInstance);\n\n server.on(\"inbound\", (port: string) => {\n fastify.log.info(\"HL7 Inbound Server Listening on Port %s\", port);\n });\n\n // before we close fastify, make sure all server instances are closed\n fastify.addHook(\"preClose\", async () => {\n if (server !== undefined) {\n await server.closeAll();\n }\n });\n }\n\n // Client Functions\n const client = new HL7Client();\n\n // run these before fastify closes\n fastify.addHook(\"preClose\", async () => {\n if (client !== undefined) {\n await client.closeAll();\n }\n });\n\n decorateFastifyInstance(fastify, options, {\n _serverInstance: serverInstance,\n buildBatch: function (properties: ClientBuilderOptions | undefined): Batch {\n return client.buildBatch(properties);\n },\n buildDate: function (date: Date, length?: DateLength): string {\n return client.buildDate(date, length);\n },\n buildFileBatch: function (\n properties: ClientBuilderFileOptions | undefined,\n ): FileBatch {\n return client.buildFileBatch(properties);\n },\n buildMessage: function (\n properties: ClientBuilderMessageOptions | undefined,\n ): Message {\n return client.buildMessage(properties);\n },\n closeServer: async function (port: string): Promise<boolean> {\n if (server !== undefined) {\n return await server.close(port);\n }\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n \"server was not started. re-register plugin with enableServer set to true.\",\n );\n },\n closeServerAll: async (): Promise<boolean> => {\n if (server !== undefined) {\n return await server.closeAll();\n }\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n \"server was not started. re-register plugin with enableServer set to true.\",\n );\n },\n createBuilder: function <V extends HL7Version>(\n version: V,\n properties?: ClientBuilderOptions,\n ): HL7VersionBuilders[V] {\n return client.createBuilder(version, properties);\n },\n createClient: function (name, properties): Client {\n return client.createClient(name, properties);\n },\n createConnection: function (name, properties, handler) {\n return client.createConnection(name, properties, handler);\n },\n createInbound: function (\n name: string,\n properties: ListenerOptions,\n handler: InboundHandler,\n ): Inbound {\n if (server !== undefined) {\n return server.createInbound(name, properties, handler);\n }\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n \"server was not started. re-register plugin with enableServer set to true.\",\n );\n },\n getClientByName: function (name: string): Client | undefined {\n return client.getClientByName(name);\n },\n getClientConnectionByPort: function (port: string): Connection | undefined {\n return client.getClientConnectionByPort(port);\n },\n getServerByName: function (name: string): Inbound | undefined {\n if (server !== undefined) {\n return server.getServerByName(name);\n }\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n \"server was not started. re-register plugin with enableServer set to true.\",\n );\n },\n getServerByPort: function (port: string): Inbound | undefined {\n if (server !== undefined) {\n return server.getServerByPort(port);\n }\n throw new errors.FASTIFY_HL7_ERR_USAGE(\n \"server was not started. re-register plugin with enableServer set to true.\",\n );\n },\n processHL7: function (text: string): Batch | Message {\n return client.processHL7(text);\n },\n readFile: function (fullFilePath: string): FileBatch {\n return client.readFile(fullFilePath);\n },\n readFileBuffer: function (fileBuffer: Buffer): FileBatch {\n return client.readFileBuffer(fileBuffer);\n },\n });\n});\n\nexport default fastifyHL7;\n\nexport * from \"./types.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,SAAS;;CAEpB,+BAAA,GAA8BA,eAAAA,QAAAA,CAC5B,gCACA,iBACF;;CAEA,wBAAA,GAAuBA,eAAAA,QAAAA,CACrB,yBACA,iBACF;AACF;;;;ACsCA,MAAM,eAAe;CACnB,OAAOC,gBAAAA;CACP,OAAOC,gBAAAA;CACP,OAAOC,gBAAAA;CACP,SAASC,gBAAAA;CACT,OAAOC,gBAAAA;CACP,OAAOC,gBAAAA;CACP,SAASC,gBAAAA;CACT,OAAOC,gBAAAA;CACP,OAAOC,gBAAAA;CACP,SAASC,gBAAAA;CACT,OAAOC,gBAAAA;AACT;AAEA,IAAa,YAAb,MAAuB;;CAErB;CAEA,cAAc;EACZ,KAAK,qBAAqB,CAAC;CAC7B;;;;;;;CAQA,WAAW,YAA0C;EACnD,OAAO,IAAIC,gBAAAA,MAAM,EAAE,GAAG,WAAW,CAAC;CACpC;;;;;;;;CASA,UAAU,M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OAAO,OAAO,aAAa,MAAM,UAAU;EAC7C;EACA,kBAAkB,SAAU,MAAM,YAAY,SAAS;GACrD,OAAO,OAAO,iBAAiB,MAAM,YAAY,OAAO;EAC1D;EACA,eAAe,SACb,MACA,YACA,SACS;GACT,IAAI,WAAW,KAAA,GACb,OAAO,OAAO,cAAc,MAAM,YAAY,OAAO;GAEvD,MAAM,IAAI,OAAO,sBACf,2EACF;EACF;EACA,iBAAiB,SAAU,MAAkC;GAC3D,OAAO,OAAO,gBAAgB,IAAI;EACpC;EACA,2BAA2B,SAAU,MAAsC;GACzE,OAAO,OAAO,0BAA0B,IAAI;EAC9C;EACA,iBAAiB,SAAU,MAAmC;GAC5D,IAAI,WAAW,KAAA,GACb,OAAO,OAAO,gBAAgB,IAAI;GAEpC,MAAM,IAAI,OAAO,sBACf,2EACF;EACF;EACA,iBAAiB,SAAU,MAAmC;GAC5D,IAAI,WAAW,KAAA,GACb,OAAO,OAAO,gBAAgB,IAAI;GAEpC,MAAM,IAAI,OAAO,sBACf,2EACF;EACF;EACA,YAAY,SAAU,MAA+B;GACnD,OAAO,OAAO,WAAW,IAAI;EAC/B;EACA,UAAU,SAAU,cAAiC;GACnD,OAAO,OAAO,SAAS,YAAY;EACrC;EACA,gBAAgB,SAAU,YAA+B;GACvD,OAAO,OAAO,eAAe,UAAU;EACzC;CACF,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastify-hl7",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "A Fastify HL7 Plugin Developed in Pure TypeScript.",
5
5
  "type": "module",
6
6
  "module": "./dist/index.mjs",
@@ -62,15 +62,15 @@
62
62
  },
63
63
  "homepage": "https://github.com/Bugs5382/fastify-hl7#readme",
64
64
  "dependencies": {
65
- "@fastify/error": "^4.1.0",
66
- "fastify-plugin": "^5.0.1",
67
- "node-hl7-client": "^4.0.0",
68
- "node-hl7-server": "^4.0.0"
65
+ "@fastify/error": "^4.2.0",
66
+ "fastify-plugin": "^6.0.0",
67
+ "node-hl7-client": "^4.1.1",
68
+ "node-hl7-server": "^4.1.1"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@shipgirl/typedoc-plugin-versions": "^0.3.2",
72
72
  "@the-rabbit-hole/eslint-config": "^0.4.0",
73
- "@types/node": "^25.9.2",
73
+ "@types/node": "^25.9.3",
74
74
  "@types/tcp-port-used": "^1.0.4",
75
75
  "@vitest/coverage-v8": "^4.1.8",
76
76
  "@vitest/ui": "^4.1.8",
@@ -79,7 +79,7 @@
79
79
  "npm-check-updates": "^22.2.3",
80
80
  "portfinder": "^1.0.38",
81
81
  "pre-commit": "^2.0.0",
82
- "prettier": "^3.8.3",
82
+ "prettier": "^3.8.4",
83
83
  "tcp-port-used": "^1.0.3",
84
84
  "tsd": "^0.33.0",
85
85
  "tsdown": "^0.22.2",