npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fastify-hl7

v3.2.0

Published

A Fastify HL7 Plugin Developed in Pure TypeScript.

Downloads

156

Readme

Fastify HL7

A Fastify Hl7 Plugin Developed in Pure TypeScript. It uses the node-hl7-client and node-hl7-server plugin as a wrapper.

The build exports this to valid ESM and CJS for ease of cross-compatibility.

If you are using this NPM package, please consider giving it a :star: star. This will increase its visibility and solicit more contribution from the outside.

This documentation is how to use this plugin, not on how to use the libraries above. Head here if you need help with those.

Table of Contents

  1. Install
  2. Basic Usage
    1. Server Quick Start
    2. Client Quick Start
  3. Full Documentation
    1. This Library Options
    2. External Libraries Options
  4. Acknowledgements
  5. License

Install

npm install fastify-hl7

Basic Usage

Register this as a plugin.

await fastify.register(fastifyHL7);

Server Quick Start

const listener = fastify.hl7.createInbound(
  "ib_adt",
  { port: 3001 },
  async (req, res) => {
    const messageReq = req.getMessage();
    const messageType = req.getType();
    // your logic here
    await res.sendResponse("AA");
  },
);

This will create a inbound connection. You can optionally return it to a variable to attach advanced listeners.

Client Quick Start

import fastify from "fastify";

fastify.hl7.createClient("localhost", { host: "0.0.0.0" });

This will create a "client" class that will then allow you to attach different outbound connections. The name localhost in a unique identifier to this host, so it can be used to attach different outbound connections to this server/broker.

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.

Within your code now you can use the fastify context and access the hl7 decorator, and create an outbound connection.

const client = fastify.hl7.createConnection(
  "ob_adt",
  { port: 3001 },
  async (res) => {
    const messageRes = res.getMessage();
    // Your code here. Either a failure or a success, but still do your work here.
  },
);

// building a HL7 Message Segment
const message = app.hl7.buildMessage({
  messageHeader: {
    msh_9_1: "ADT",
    msh_9_2: "A01",
    msh_11_1: "D",
  },
});

await client.sendMessage(message);

Full Documentation

This Library Options

enableServer

If this is not set, enableServer will be set to true. You need to set this to false will turn off the server capabilities.

serverOptions

Set this using the options from the node-hl7-serer library ServerOptions values to override server creation. 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.

External Libraries Options

  • node-hl7-client - For the Client, Parser, and Builder to review their options that can be passed as props.
  • node-hl7-server - For the Server to the options that can be passed as props.

Please review the libraries for more complete documentation.

Acknowledgements

  • My Wife and Baby Girl.

License

Licensed under MIT.