Skip to content
This repository has been archived by the owner on Aug 14, 2023. It is now read-only.

Fixed inconsistencies for #1 #6

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
contents: read
packages: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
# Setup .npmrc file to publish to GitHub Packages
- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: '14.x'
registry-url: 'https://npm.pkg.github.com'
Expand All @@ -23,5 +23,3 @@ jobs:
- run: yarn publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}


5 changes: 2 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ jobs:
contents: read
packages: read
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
# Setup .npmrc file to publish to GitHub Packages
- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: '14.x'
registry-url: 'https://npm.pkg.github.com'
# Defaults to the user or organization that owns the workflow file
- run: yarn
- run: yarn build
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added .yarn/install-state.gz
Binary file not shown.
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@b-techbw/mllp",
"version": "3.1.0",
"name": "@i-tech-uw/mllp-server",
"version": "3.1.3",
"description": "MLLP (HL7) implementation in Node.js",
"main": "lib/mllp.js",
"types": "lib/mllp.d.ts",
Expand All @@ -16,10 +16,10 @@
},
"author": "Piotr Mankowski [email protected]>",
"repository": {
"url": "git://github.com/b-techbw/mllp.git"
"url": "git://github.com/i-tech-uw/mllp-server.git"
},
"bugs": {
"url": "https://github.com/b-techbw/mllp/issues"
"url": "https://github.com/i-tech-uw/mllp-server/issues"
},
"mocha": {
"require": [
Expand Down
51 changes: 25 additions & 26 deletions src/mllp.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Socket } from 'dgram';
import * as net from 'net'
import { TypedEmitter } from 'tiny-typed-emitter';

Expand Down Expand Up @@ -35,6 +36,7 @@ export class MllpServer extends TypedEmitter<MllpEvents> {
host: string
logger: any
server: net.Server
message: string;

static readonly VT = String.fromCharCode(0x0b);
static readonly FS = String.fromCharCode(0x1c);
Expand All @@ -45,33 +47,23 @@ export class MllpServer extends TypedEmitter<MllpEvents> {

this.host = host || '127.0.0.1'
this.port = port || 6969
this.logger = logger || console;

this.logger = logger || console
this.message = ''
this.server = net.createServer(this.serverListener.bind(this))

}

private serverListener(sock: net.Socket) {
this.logger.info('CONNECTED: ' + sock.remoteAddress + ':' + sock.remotePort);

sock.on('data', (data: any) => {
let { msg, ack } = this.handleData(data.toString())

/**
* MLLP HL7 Event. Fired when a HL7 Message is received.
* @event MllpServer#hl7
* @type {string}
* @property {string} message string containing the HL7 Message (see example below)
* @example MSH|^~\&|XXXX|C|SOMELAB|SOMELAB|20080511103530||ORU^R01|Q335939501T337311002|P|2.3|||
*/
this.emit('hl7', msg);
data = data.toString()
this.logger.info("DATA:\nfrom " + sock.remoteAddress + ':\n' + data.split("\r").join("\n"));

sock.write(MllpServer.VT + this.ackn(ack, "AA") + MllpServer.FS + MllpServer.CR);
this.handleData(data.toString(), sock)
})
sock.on('close', (data) => {
this.logger.info('CLOSED: ' + sock.remoteAddress + ' ' + sock.remotePort);
});

}

private ackn(data: any, ack_type: string): string {
Expand Down Expand Up @@ -99,24 +91,31 @@ export class MllpServer extends TypedEmitter<MllpEvents> {
return result;
}

private handleData(msg: string) {
let message: string = ''
let ackData: any

private handleData(msg: string, sock: net.Socket) {
//strip separators
if (msg.indexOf(MllpServer.VT) > -1) {
message = '';
this.message = '';
}

message += msg.replace(MllpServer.VT, '');
this.message += msg.replace(MllpServer.VT, '');

if (msg.indexOf(MllpServer.FS + MllpServer.CR) > -1) {
message = message.replace(MllpServer.FS + MllpServer.CR, '');
ackData = hl7.parseString(message);
this.logger.info("Message:\r\n" + message + "\r\n\r\n");
}
this.message = this.message.replace(MllpServer.FS + MllpServer.CR, '');
let ackData: any = hl7.parseString(this.message);
this.logger.info("Message:\r\n" + this.message + "\r\n\r\n");

/**
* MLLP HL7 Event. Fired when a full HL7 Message is received.
* @event MllpServer#hl7
* @type {string}
* @property {string} message string containing the HL7 Message (see example below)
* @example MSH|^~\&|XXXX|C|SOMELAB|SOMELAB|20080511103530||ORU^R01|Q335939501T337311002|P|2.3|||
*/
this.emit('hl7', this.message);
let ack = this.ackn(ackData, "AA")

return { msg: message, ack: ackData };
sock.write(MllpServer.VT + ack + MllpServer.FS + MllpServer.CR);
}
}

send(receivingHost: string, receivingPort: number, hl7Data: any, callback: Function) {
Expand Down
Loading