Skip to content

Getting Started

Create a Glion app, run it locally, and process your first HL7v2 message.

Quick Start

  1. Create a new Glion app with the CLI.
  2. cd my-app.
  3. Start the dev server. The server is now waiting for MLLP traffic on 127.0.0.1:2575.
Terminal
npm create glion@latest my-app
cd my-app
npm run dev
  1. Open another terminal and send your first message.
Terminal
printf '\x0bMSH|^~\&|SENDER|SENDER|GLION|NODE|20260509120000||ADT^A01|MSG001|P|2.5.1\rEVN||20260509120000\rPID|||123456^^^MRN||Doe^John\r\x1c\x0d' \
  | nc 127.0.0.1 2575

That's a working MLLP server. nc is fine for one-off pokes; for a typed client with NAK handling, TLS, and Cloudflare Workers support, see Sending HL7v2 messages.

System requirements

Before you begin, make sure your development environment meets the following requirements:

  • Minimum Node.js version: 20.x
  • Operating systems: macOS, Windows (including WSL), and Linux.

Manual installation

To manually create a new Glion app, install the required packages:

Terminal
npm install @glion/cli @glion/mllp @glion/mllp-ack @glion/hl7v2 @glion/ack

Create the Glion configuration

  1. Create a new file glion.config.ts with the following content:
glion.config.ts
import { defineConfig } from "@glion/cli/config";

export default defineConfig({
  entry: "./src/app.ts",
  port: 2575,
});
  1. Add the following scripts to your package.json file:
package.json
{
  "scripts": {
    "dev": "glion dev",
    "start": "glion start"
  }
}

These scripts refer to the different stages of developing an application:

  • glion dev: Starts the development server using our mllp-server implementation. It watches for file changes and automatically restarts the server, providing a smooth development experience with hot reloading and detailed error messages.
  • glion start: Starts the production server.

Create the router

  1. Create a new directory src in the root of your project. This is where you will write your Glion application code.
  2. Create a new file src/app.ts. This is the root router of your application, where you will define your routes and middleware. It must export a default Mllp instance.
src/app.ts
import { UnsupportedMessageTypeReject } from "@glion/ack";
import { parseHL7v2 } from "@glion/hl7v2";
import { Mllp } from "@glion/mllp";
import { ackMiddleware } from "@glion/mllp-ack";

const app = new Mllp();

app.parser(parseHL7v2);

// Turn handler return values into AA ACKs and throws into the matching NAK.
app.use(ackMiddleware());

// One route: accept ADT^A01 (patient admit).
app.on("ADT^A01", () => {
  // Returning normally produces an AA (Application Accept) ACK.
});

// Catch-all — reject anything else with an AR NAK.
app.on("*", (ctx) => {
  throw new UnsupportedMessageTypeReject(
    `Unsupported message type: ${ctx.messageType}^${ctx.triggerEvent}`
  );
});

export default app;

Run the development server

  1. Run npm run dev to start the development server.
  2. The server is now waiting for MLLP traffic on 127.0.0.1:2575.
  3. Edit the src/app.ts file and save it to see the server automatically restart with your changes.

You have a working MLLP server! Next, send your first message to see it in action. You can use nc or any MLLP client to send a message to 127.0.0.1:2575. For a typed client with NAK handling, TLS, etc., see Sending HL7v2 messages.