mllp-node-sl7 2.1.4 → 2.1.5
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/package.json +1 -1
- package/src/index.d.ts +1 -1
- package/src/index.js +9 -10
- package/src/index.ts +13 -9
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { Message } from "@sourceblock-ug/sb-sl7";
|
|
|
7
7
|
export interface Renderable {
|
|
8
8
|
render(): string | Buffer;
|
|
9
9
|
}
|
|
10
|
-
export declare function mllpSendMessage(receivingHost: string, receivingPort: number, hl7Data: Buffer | Renderable | string, callback: (err: Error | null, response: string | null) => void, logger?: (msg: string) => void): void;
|
|
10
|
+
export declare function mllpSendMessage(receivingHost: string, receivingPort: number, hl7Data: Buffer | Renderable | string, callback: (err: Error | null, response: string | null, responseMessage: string | null) => void, logger?: (msg: string) => void): void;
|
|
11
11
|
export interface MessageResponseEvent {
|
|
12
12
|
id: string;
|
|
13
13
|
ack: string | Renderable | unknown;
|
package/src/index.js
CHANGED
|
@@ -45,20 +45,19 @@ function mllpSendMessage(receivingHost, receivingPort, hl7Data, callback, logger
|
|
|
45
45
|
log(`closing connection with ${receivingHost}:${receivingPort}`);
|
|
46
46
|
sendingClient.end();
|
|
47
47
|
};
|
|
48
|
-
|
|
48
|
+
const cleanup = (msg) => {
|
|
49
|
+
return msg.replace(VT, '').replace(FS, '').replace(CR, '');
|
|
50
|
+
};
|
|
51
|
+
sendingClient.on('data', (rawAckData) => {
|
|
49
52
|
log(`${receivingHost}:${receivingPort} ACKED data`);
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
.split("\r")[1] // Ack data
|
|
54
|
-
.replace(FS, "")
|
|
55
|
-
.replace(CR, "");
|
|
56
|
-
callback(null, ackData);
|
|
53
|
+
const responseMessage = rawAckData.toString().replace(VT, '');
|
|
54
|
+
const ackData = responseMessage.split('\r')[1]; // Ack data
|
|
55
|
+
callback(null, cleanup(ackData), cleanup(responseMessage));
|
|
57
56
|
terminate();
|
|
58
57
|
});
|
|
59
|
-
sendingClient.on(
|
|
58
|
+
sendingClient.on('error', (error) => {
|
|
60
59
|
log(`${receivingHost}:${receivingPort} couldn't process data`);
|
|
61
|
-
callback(error, null);
|
|
60
|
+
callback(error, null, null);
|
|
62
61
|
terminate();
|
|
63
62
|
});
|
|
64
63
|
}
|
package/src/index.ts
CHANGED
|
@@ -34,7 +34,11 @@ export function mllpSendMessage(
|
|
|
34
34
|
receivingHost: string,
|
|
35
35
|
receivingPort: number,
|
|
36
36
|
hl7Data: Buffer | Renderable | string,
|
|
37
|
-
callback: (
|
|
37
|
+
callback: (
|
|
38
|
+
err: Error | null,
|
|
39
|
+
response: string | null,
|
|
40
|
+
responseMessage: string | null
|
|
41
|
+
) => void,
|
|
38
42
|
logger?: (msg: string) => void
|
|
39
43
|
) {
|
|
40
44
|
// Render Message if it is an object:
|
|
@@ -62,24 +66,24 @@ export function mllpSendMessage(
|
|
|
62
66
|
sendingClient.end();
|
|
63
67
|
};
|
|
64
68
|
|
|
69
|
+
const cleanup = (msg: string): string => {
|
|
70
|
+
return msg.replace(VT, "").replace(FS, "").replace(CR, "");
|
|
71
|
+
};
|
|
72
|
+
|
|
65
73
|
sendingClient.on("data", (rawAckData) => {
|
|
66
74
|
log(`${receivingHost}:${receivingPort} ACKED data`);
|
|
67
75
|
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
.replace(VT, "")
|
|
71
|
-
.split("\r")[1] // Ack data
|
|
72
|
-
.replace(FS, "")
|
|
73
|
-
.replace(CR, "");
|
|
76
|
+
const responseMessage = rawAckData.toString().replace(VT, "");
|
|
77
|
+
const ackData = responseMessage.split("\r")[1]; // Ack data
|
|
74
78
|
|
|
75
|
-
callback(null, ackData);
|
|
79
|
+
callback(null, cleanup(ackData), cleanup(responseMessage));
|
|
76
80
|
terminate();
|
|
77
81
|
});
|
|
78
82
|
|
|
79
83
|
sendingClient.on("error", (error) => {
|
|
80
84
|
log(`${receivingHost}:${receivingPort} couldn't process data`);
|
|
81
85
|
|
|
82
|
-
callback(error, null);
|
|
86
|
+
callback(error, null, null);
|
|
83
87
|
terminate();
|
|
84
88
|
});
|
|
85
89
|
}
|