@medplum/hl7 4.1.7 → 4.1.9
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/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +3 -3
- package/dist/cjs/index.d.ts +3 -2
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +3 -3
- package/package.json +3 -3
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var L=Object.create;var p=Object.defineProperty;var
|
|
1
|
+
"use strict";var L=Object.create;var p=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty;var T=(n,t)=>{for(var e in t)p(n,e,{get:t[e],enumerable:!0})},f=(n,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of A(t))!B.call(n,r)&&r!==e&&p(n,r,{get:()=>t[r],enumerable:!(s=C(t,r))||s.enumerable});return n};var g=(n,t,e)=>(e=n!=null?L(O(n)):{},f(t||!n||!n.__esModule?p(e,"default",{value:n,enumerable:!0}):e,n)),S=n=>f(p({},"__esModule",{value:!0}),n);var P={};T(P,{CR:()=>E,FS:()=>k,Hl7Base:()=>a,Hl7Client:()=>m,Hl7CloseEvent:()=>l,Hl7Connection:()=>d,Hl7ErrorEvent:()=>c,Hl7MessageEvent:()=>h,Hl7Server:()=>u,VT:()=>I});module.exports=S(P);var a=class extends EventTarget{addEventListener(t,e,s){super.addEventListener(t,e,s)}removeEventListener(t,e,s){super.removeEventListener(t,e,s)}};var x=require("node:net");var H=require("@medplum/core"),v=g(require("iconv-lite"));var I=11,E=13,k=28;var h=class extends Event{constructor(t,e){super("message"),this.connection=t,this.message=e}},c=class extends Event{constructor(t){super("error"),this.error=t}},l=class extends Event{constructor(){super("close")}};var d=class extends a{constructor(e,s="utf-8",r=!1){super();this.chunks=[];this.messageQueue=[];this.socket=e,this.encoding=s,this.enhancedMode=r,e.on("data",o=>{try{if(this.appendData(o),o.at(-2)===28&&o.at(-1)===13){let i=Buffer.concat(this.chunks),M=i.subarray(1,i.length-2),w=v.default.decode(M,this.encoding),b=H.Hl7Message.parse(w);this.dispatchEvent(new h(this,b)),this.resetBuffer()}}catch(i){this.dispatchEvent(new c(i))}}),e.on("error",o=>{this.resetBuffer(),this.dispatchEvent(new c(o))}),e.on("end",()=>{this.close()}),this.addEventListener("message",o=>{r&&this.send(o.message.buildAck({ackCode:"CA"}));let i=this.messageQueue.shift();if(!i){this.dispatchEvent(new c(new Error(`Received a message when no pending messages were in the queue. Message: ${o.message}`)));return}i.resolve?.(o.message)})}sendImpl(e,s){this.messageQueue.push(s);let r=e.toString(),o=v.default.encode(r,this.encoding),i=Buffer.alloc(o.length+3);i.writeInt8(11,0),o.copy(i,1),i.writeInt8(28,o.length+1),i.writeInt8(13,o.length+2),this.socket.write(i)}send(e){this.sendImpl(e,{message:e})}async sendAndWait(e){return new Promise((s,r)=>{let o={message:e,resolve:s,reject:r};this.sendImpl(e,o)})}close(){this.socket.end(),this.socket.destroy(),this.dispatchEvent(new l)}appendData(e){this.chunks.push(e)}resetBuffer(){this.chunks=[]}};var m=class extends a{constructor(t){super(),this.options=t,this.host=this.options.host,this.port=this.options.port,this.encoding=this.options.encoding,this.keepAlive=this.options.keepAlive??!1,this.connectTimeout=this.options.connectTimeout??3e4}connect(){return this.connection?Promise.resolve(this.connection):(this.socket&&(this.socket.removeAllListeners(),this.socket.destroy(),this.socket=void 0),new Promise((t,e)=>{this.socket=(0,x.connect)({host:this.host,port:this.port,keepAlive:this.keepAlive}),this.connectTimeout>0&&(this.socket.setTimeout(this.connectTimeout),this.socket.on("timeout",()=>{let s=new Error(`Connection timeout after ${this.connectTimeout}ms`);this.socket&&(this.socket.destroy(),this.socket=void 0),e(s)})),this.socket.on("connect",()=>{if(!this.socket)return;let s;this.connection=s=new d(this.socket,this.encoding),this.socket.setTimeout(0),s.addEventListener("close",()=>{this.socket=void 0,this.dispatchEvent(new l)}),s.addEventListener("error",r=>{this.dispatchEvent(new c(r.error))}),t(this.connection)}),this.socket.on("error",s=>{this.socket&&(this.socket.destroy(),this.socket=void 0),e(s)})}))}async send(t){return(await this.connect()).send(t)}async sendAndWait(t){return(await this.connect()).sendAndWait(t)}close(){this.socket&&(this.socket.removeAllListeners(),this.socket.destroy(),this.socket=void 0),this.connection&&(this.connection.close(),delete this.connection)}};var y=g(require("node:net"));var u=class{constructor(t){this.handler=t}start(t,e,s=!1){let r=y.default.createServer(o=>{let i=new d(o,e,s);this.handler(i)});r.listen(t),this.server=r}async stop(){return new Promise((t,e)=>{if(!this.server){e(new Error("Stop was called but there is no server running"));return}this.server.close(s=>{if(s){e(s);return}t()}),this.server=void 0})}};0&&(module.exports={CR,FS,Hl7Base,Hl7Client,Hl7CloseEvent,Hl7Connection,Hl7ErrorEvent,Hl7MessageEvent,Hl7Server,VT});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts", "../../src/base.ts", "../../src/client.ts", "../../src/connection.ts", "../../src/constants.ts", "../../src/events.ts", "../../src/server.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './base';\nexport * from './client';\nexport * from './connection';\nexport * from './constants';\nexport * from './events';\nexport * from './server';\n", "import { Hl7CloseEvent, Hl7ErrorEvent, Hl7MessageEvent } from './events';\n\nexport interface Hl7EventMap {\n message: Hl7MessageEvent;\n error: Hl7ErrorEvent;\n close: Hl7CloseEvent;\n}\n\nexport abstract class Hl7Base extends EventTarget {\n addEventListener<K extends keyof Hl7EventMap>(\n type: K,\n listener: ((event: Hl7EventMap[K]) => void) | EventListenerObject | null,\n options?: boolean | AddEventListenerOptions\n ): void;\n\n addEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject | null,\n options?: boolean | AddEventListenerOptions\n ): void {\n super.addEventListener(type, listener, options);\n }\n removeEventListener<K extends keyof Hl7EventMap>(\n type: K,\n listener: ((event: Hl7EventMap[K]) => void) | EventListenerObject | null,\n options?: boolean | AddEventListenerOptions\n ): void;\n\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject | null,\n options?: boolean | AddEventListenerOptions\n ): void {\n super.removeEventListener(type, listener, options);\n }\n}\n", "import { Hl7Message } from '@medplum/core';\nimport { connect, Socket } from 'node:net';\nimport { Hl7Base } from './base';\nimport { Hl7Connection } from './connection';\nimport { Hl7CloseEvent, Hl7ErrorEvent } from './events';\n\nexport interface Hl7ClientOptions {\n host: string;\n port: number;\n encoding?: string;\n keepAlive?: boolean;\n connectTimeout?: number; // Add timeout option\n}\n\nexport class Hl7Client extends Hl7Base {\n options: Hl7ClientOptions;\n host: string;\n port: number;\n encoding?: string;\n connection?: Hl7Connection;\n keepAlive: boolean;\n private socket?: Socket;\n private connectTimeout: number;\n\n constructor(options: Hl7ClientOptions) {\n super();\n this.options = options;\n this.host = this.options.host;\n this.port = this.options.port;\n this.encoding = this.options.encoding;\n this.keepAlive = this.options.keepAlive ?? false;\n this.connectTimeout = this.options.connectTimeout ?? 30000; // Default 30 seconds\n }\n\n connect(): Promise<Hl7Connection> {\n // If we already have a connection, use it\n if (this.connection) {\n return Promise.resolve(this.connection);\n }\n\n // If there's an ongoing connection attempt, destroy it\n if (this.socket) {\n this.socket.removeAllListeners();\n this.socket.destroy();\n this.socket = undefined;\n }\n\n return new Promise((resolve, reject) => {\n // Create the socket\n this.socket = connect({\n host: this.host,\n port: this.port,\n keepAlive: this.keepAlive,\n });\n\n // Set timeout if specified\n if (this.connectTimeout > 0) {\n this.socket.setTimeout(this.connectTimeout);\n\n // Handle timeout event\n this.socket.on('timeout', () => {\n const error = new Error(`Connection timeout after ${this.connectTimeout}ms`);\n if (this.socket) {\n this.socket.destroy();\n this.socket = undefined;\n }\n reject(error);\n });\n }\n\n // Handle successful connection\n this.socket.on('connect', () => {\n if (!this.socket) {\n return; // Socket was already destroyed\n }\n\n // Create the HL7 connection\n let connection: Hl7Connection;\n this.connection = connection = new Hl7Connection(this.socket, this.encoding);\n\n // Remove the timeout listener as we're now connected\n this.socket.setTimeout(0);\n\n // Set up event handlers\n connection.addEventListener('close', () => {\n this.socket = undefined;\n this.dispatchEvent(new Hl7CloseEvent());\n });\n\n connection.addEventListener('error', (event) => {\n this.dispatchEvent(new Hl7ErrorEvent(event.error));\n });\n\n resolve(this.connection);\n });\n\n // Handle connection errors\n this.socket.on('error', (err) => {\n if (this.socket) {\n this.socket.destroy();\n this.socket = undefined;\n }\n reject(err);\n });\n });\n }\n\n async send(msg: Hl7Message): Promise<void> {\n return (await this.connect()).send(msg);\n }\n\n async sendAndWait(msg: Hl7Message): Promise<Hl7Message> {\n return (await this.connect()).sendAndWait(msg);\n }\n\n close(): void {\n // Close the socket if it exists\n if (this.socket) {\n this.socket.removeAllListeners();\n this.socket.destroy();\n this.socket = undefined;\n }\n\n // Close established connection if it exists\n if (this.connection) {\n this.connection.close();\n delete this.connection;\n }\n }\n}\n", "import { Hl7Message } from '@medplum/core';\nimport iconv from 'iconv-lite';\nimport net from 'node:net';\nimport { Hl7Base } from './base';\nimport { CR, FS, VT } from './constants';\nimport { Hl7CloseEvent, Hl7ErrorEvent, Hl7MessageEvent } from './events';\n\n// iconv-lite docs have great examples and explanations for how to use Buffers with iconv-lite:\n// See: https://github.com/ashtuchkin/iconv-lite/wiki/Use-Buffers-when-decoding\n\nexport type Hl7MessageQueueItem = {\n message: Hl7Message;\n resolve?: (reply: Hl7Message) => void;\n reject?: (err: Error) => void;\n};\n\nexport class Hl7Connection extends Hl7Base {\n readonly socket: net.Socket;\n readonly encoding: string;\n private chunks: Buffer[] = [];\n private readonly messageQueue: Hl7MessageQueueItem[] = [];\n\n constructor(socket: net.Socket, encoding: string = 'utf-8') {\n super();\n\n this.socket = socket;\n this.encoding = encoding;\n\n socket.on('data', (data: Buffer) => {\n try {\n this.appendData(data);\n if (data.at(-2) === FS && data.at(-1) === CR) {\n const buffer = Buffer.concat(this.chunks);\n const contentBuffer = buffer.subarray(1, buffer.length - 2);\n const contentString = iconv.decode(contentBuffer, this.encoding);\n const message = Hl7Message.parse(contentString);\n this.dispatchEvent(new Hl7MessageEvent(this, message));\n this.resetBuffer();\n }\n } catch (err) {\n this.dispatchEvent(new Hl7ErrorEvent(err as Error));\n }\n });\n\n socket.on('error', (err) => {\n this.resetBuffer();\n this.dispatchEvent(new Hl7ErrorEvent(err));\n });\n\n socket.on('end', () => {\n this.close();\n });\n\n this.addEventListener('message', (event) => {\n // Get the queue item at the head of the queue\n const next = this.messageQueue.shift();\n // If there isn't an item, then throw an error\n if (!next) {\n this.dispatchEvent(\n new Hl7ErrorEvent(\n new Error(`Received a message when no pending messages were in the queue. Message: ${event.message}`)\n )\n );\n return;\n }\n // Resolve the promise if there is one pending for this message\n next.resolve?.(event.message);\n });\n }\n\n private sendImpl(reply: Hl7Message, queueItem: Hl7MessageQueueItem): void {\n this.messageQueue.push(queueItem);\n const replyString = reply.toString();\n const replyBuffer = iconv.encode(replyString, this.encoding);\n const outputBuffer = Buffer.alloc(replyBuffer.length + 3);\n outputBuffer.writeInt8(VT, 0);\n replyBuffer.copy(outputBuffer, 1);\n outputBuffer.writeInt8(FS, replyBuffer.length + 1);\n outputBuffer.writeInt8(CR, replyBuffer.length + 2);\n this.socket.write(outputBuffer);\n }\n\n send(reply: Hl7Message): void {\n this.sendImpl(reply, { message: reply });\n }\n\n async sendAndWait(msg: Hl7Message): Promise<Hl7Message> {\n return new Promise<Hl7Message>((resolve, reject) => {\n const queueItem = { message: msg, resolve, reject };\n this.sendImpl(msg, queueItem);\n });\n }\n\n close(): void {\n this.socket.end();\n this.socket.destroy();\n this.dispatchEvent(new Hl7CloseEvent());\n }\n\n private appendData(data: Buffer): void {\n this.chunks.push(data);\n }\n\n private resetBuffer(): void {\n this.chunks = [];\n }\n}\n", "/**\n * VT (Vertical Tab) character.\n *\n * In HL7 messages, this character is used to indicate the start of a message.\n */\nexport const VT = 0x0b;\n\n/**\n * CR (Carriage Return) character.\n *\n * In HL7 messages, this character is used to indicate the end of a message.\n */\nexport const CR = 0x0d;\n\n/**\n * FS (File Separator) character.\n *\n * In HL7 messages, this character is used to separate fields.\n */\nexport const FS = 0x1c;\n", "import { Hl7Message } from '@medplum/core';\nimport { Hl7Connection } from './connection';\n\nexport class Hl7MessageEvent extends Event {\n readonly connection: Hl7Connection;\n readonly message: Hl7Message;\n\n constructor(connection: Hl7Connection, message: Hl7Message) {\n super('message');\n this.connection = connection;\n this.message = message;\n }\n}\n\nexport class Hl7ErrorEvent extends Event {\n readonly error: Error;\n\n constructor(error: Error) {\n super('error');\n this.error = error;\n }\n}\n\nexport class Hl7CloseEvent extends Event {\n constructor() {\n super('close');\n }\n}\n", "import net from 'node:net';\nimport { Hl7Connection } from './connection';\n\nexport class Hl7Server {\n readonly handler: (connection: Hl7Connection) => void;\n server?: net.Server;\n\n constructor(handler: (connection: Hl7Connection) => void) {\n this.handler = handler;\n }\n\n start(port: number, encoding?: string): void {\n const server = net.createServer((socket) => {\n const connection = new Hl7Connection(socket, encoding);\n this.handler(connection);\n });\n\n server.listen(port);\n this.server = server;\n }\n\n async stop(): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (!this.server) {\n reject(new Error('Stop was called but there is no server running'));\n return;\n }\n this.server.close((err) => {\n if (err) {\n reject(err);\n return;\n }\n resolve();\n });\n this.server = undefined;\n });\n }\n}\n"],
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,QAAAE,EAAA,OAAAC,EAAA,YAAAC,EAAA,cAAAC,EAAA,kBAAAC,EAAA,kBAAAC,EAAA,kBAAAC,EAAA,oBAAAC,EAAA,cAAAC,EAAA,OAAAC,IAAA,eAAAC,EAAAZ,GCQO,IAAea,EAAf,cAA+B,WAAY,CAOhD,iBACEC,EACAC,EACAC,EACM,CACN,MAAM,iBAAiBF,EAAMC,EAAUC,CAAO,CAChD,CAOA,oBACEF,EACAC,EACAC,EACM,CACN,MAAM,oBAAoBF,EAAMC,EAAUC,CAAO,CACnD,CACF,EClCA,IAAAC,EAAgC,oBCDhC,IAAAC,EAA2B,yBAC3BC,EAAkB,yBCIX,IAAMC,EAAK,GAOLC,EAAK,GAOLC,EAAK,GChBX,IAAMC,EAAN,cAA8B,KAAM,CAIzC,YAAYC,EAA2BC,EAAqB,CAC1D,MAAM,SAAS,EACf,KAAK,WAAaD,EAClB,KAAK,QAAUC,CACjB,CACF,EAEaC,EAAN,cAA4B,KAAM,CAGvC,YAAYC,EAAc,CACxB,MAAM,OAAO,EACb,KAAK,MAAQA,CACf,CACF,EAEaC,EAAN,cAA4B,KAAM,CACvC,aAAc,CACZ,MAAM,OAAO,CACf,CACF,EFXO,IAAMC,EAAN,cAA4BC,CAAQ,
|
|
6
|
-
"names": ["index_exports", "__export", "CR", "FS", "Hl7Base", "Hl7Client", "Hl7CloseEvent", "Hl7Connection", "Hl7ErrorEvent", "Hl7MessageEvent", "Hl7Server", "VT", "__toCommonJS", "Hl7Base", "type", "listener", "options", "import_node_net", "import_core", "import_iconv_lite", "VT", "CR", "FS", "Hl7MessageEvent", "connection", "message", "Hl7ErrorEvent", "error", "Hl7CloseEvent", "Hl7Connection", "Hl7Base", "socket", "encoding", "data", "buffer", "contentBuffer", "contentString", "iconv", "message", "Hl7MessageEvent", "err", "Hl7ErrorEvent", "event", "next", "reply", "queueItem", "replyString", "replyBuffer", "outputBuffer", "msg", "resolve", "reject", "Hl7CloseEvent", "Hl7Client", "Hl7Base", "options", "resolve", "reject", "error", "connection", "Hl7Connection", "Hl7CloseEvent", "event", "Hl7ErrorEvent", "err", "msg", "import_node_net", "Hl7Server", "handler", "port", "encoding", "server", "net", "socket", "connection", "Hl7Connection", "resolve", "reject", "err"]
|
|
4
|
+
"sourcesContent": ["export * from './base';\nexport * from './client';\nexport * from './connection';\nexport * from './constants';\nexport * from './events';\nexport * from './server';\n", "import { Hl7CloseEvent, Hl7ErrorEvent, Hl7MessageEvent } from './events';\n\nexport interface Hl7EventMap {\n message: Hl7MessageEvent;\n error: Hl7ErrorEvent;\n close: Hl7CloseEvent;\n}\n\nexport abstract class Hl7Base extends EventTarget {\n addEventListener<K extends keyof Hl7EventMap>(\n type: K,\n listener: ((event: Hl7EventMap[K]) => void) | EventListenerObject | null,\n options?: boolean | AddEventListenerOptions\n ): void;\n\n addEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject | null,\n options?: boolean | AddEventListenerOptions\n ): void {\n super.addEventListener(type, listener, options);\n }\n removeEventListener<K extends keyof Hl7EventMap>(\n type: K,\n listener: ((event: Hl7EventMap[K]) => void) | EventListenerObject | null,\n options?: boolean | AddEventListenerOptions\n ): void;\n\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject | null,\n options?: boolean | AddEventListenerOptions\n ): void {\n super.removeEventListener(type, listener, options);\n }\n}\n", "import { Hl7Message } from '@medplum/core';\nimport { connect, Socket } from 'node:net';\nimport { Hl7Base } from './base';\nimport { Hl7Connection } from './connection';\nimport { Hl7CloseEvent, Hl7ErrorEvent } from './events';\n\nexport interface Hl7ClientOptions {\n host: string;\n port: number;\n encoding?: string;\n keepAlive?: boolean;\n connectTimeout?: number; // Add timeout option\n}\n\nexport class Hl7Client extends Hl7Base {\n options: Hl7ClientOptions;\n host: string;\n port: number;\n encoding?: string;\n connection?: Hl7Connection;\n keepAlive: boolean;\n private socket?: Socket;\n private connectTimeout: number;\n\n constructor(options: Hl7ClientOptions) {\n super();\n this.options = options;\n this.host = this.options.host;\n this.port = this.options.port;\n this.encoding = this.options.encoding;\n this.keepAlive = this.options.keepAlive ?? false;\n this.connectTimeout = this.options.connectTimeout ?? 30000; // Default 30 seconds\n }\n\n connect(): Promise<Hl7Connection> {\n // If we already have a connection, use it\n if (this.connection) {\n return Promise.resolve(this.connection);\n }\n\n // If there's an ongoing connection attempt, destroy it\n if (this.socket) {\n this.socket.removeAllListeners();\n this.socket.destroy();\n this.socket = undefined;\n }\n\n return new Promise((resolve, reject) => {\n // Create the socket\n this.socket = connect({\n host: this.host,\n port: this.port,\n keepAlive: this.keepAlive,\n });\n\n // Set timeout if specified\n if (this.connectTimeout > 0) {\n this.socket.setTimeout(this.connectTimeout);\n\n // Handle timeout event\n this.socket.on('timeout', () => {\n const error = new Error(`Connection timeout after ${this.connectTimeout}ms`);\n if (this.socket) {\n this.socket.destroy();\n this.socket = undefined;\n }\n reject(error);\n });\n }\n\n // Handle successful connection\n this.socket.on('connect', () => {\n if (!this.socket) {\n return; // Socket was already destroyed\n }\n\n // Create the HL7 connection\n let connection: Hl7Connection;\n this.connection = connection = new Hl7Connection(this.socket, this.encoding);\n\n // Remove the timeout listener as we're now connected\n this.socket.setTimeout(0);\n\n // Set up event handlers\n connection.addEventListener('close', () => {\n this.socket = undefined;\n this.dispatchEvent(new Hl7CloseEvent());\n });\n\n connection.addEventListener('error', (event) => {\n this.dispatchEvent(new Hl7ErrorEvent(event.error));\n });\n\n resolve(this.connection);\n });\n\n // Handle connection errors\n this.socket.on('error', (err) => {\n if (this.socket) {\n this.socket.destroy();\n this.socket = undefined;\n }\n reject(err);\n });\n });\n }\n\n async send(msg: Hl7Message): Promise<void> {\n return (await this.connect()).send(msg);\n }\n\n async sendAndWait(msg: Hl7Message): Promise<Hl7Message> {\n return (await this.connect()).sendAndWait(msg);\n }\n\n close(): void {\n // Close the socket if it exists\n if (this.socket) {\n this.socket.removeAllListeners();\n this.socket.destroy();\n this.socket = undefined;\n }\n\n // Close established connection if it exists\n if (this.connection) {\n this.connection.close();\n delete this.connection;\n }\n }\n}\n", "import { Hl7Message } from '@medplum/core';\nimport iconv from 'iconv-lite';\nimport net from 'node:net';\nimport { Hl7Base } from './base';\nimport { CR, FS, VT } from './constants';\nimport { Hl7CloseEvent, Hl7ErrorEvent, Hl7MessageEvent } from './events';\n\n// iconv-lite docs have great examples and explanations for how to use Buffers with iconv-lite:\n// See: https://github.com/ashtuchkin/iconv-lite/wiki/Use-Buffers-when-decoding\n\nexport type Hl7MessageQueueItem = {\n message: Hl7Message;\n resolve?: (reply: Hl7Message) => void;\n reject?: (err: Error) => void;\n};\n\nexport class Hl7Connection extends Hl7Base {\n readonly socket: net.Socket;\n readonly encoding: string;\n readonly enhancedMode: boolean;\n private chunks: Buffer[] = [];\n private readonly messageQueue: Hl7MessageQueueItem[] = [];\n\n constructor(socket: net.Socket, encoding: string = 'utf-8', enhancedMode = false) {\n super();\n\n this.socket = socket;\n this.encoding = encoding;\n this.enhancedMode = enhancedMode;\n\n socket.on('data', (data: Buffer) => {\n try {\n this.appendData(data);\n if (data.at(-2) === FS && data.at(-1) === CR) {\n const buffer = Buffer.concat(this.chunks);\n const contentBuffer = buffer.subarray(1, buffer.length - 2);\n const contentString = iconv.decode(contentBuffer, this.encoding);\n const message = Hl7Message.parse(contentString);\n this.dispatchEvent(new Hl7MessageEvent(this, message));\n this.resetBuffer();\n }\n } catch (err) {\n this.dispatchEvent(new Hl7ErrorEvent(err as Error));\n }\n });\n\n socket.on('error', (err) => {\n this.resetBuffer();\n this.dispatchEvent(new Hl7ErrorEvent(err));\n });\n\n socket.on('end', () => {\n this.close();\n });\n\n this.addEventListener('message', (event) => {\n if (enhancedMode) {\n this.send(event.message.buildAck({ ackCode: 'CA' }));\n }\n // Get the queue item at the head of the queue\n const next = this.messageQueue.shift();\n // If there isn't an item, then throw an error\n if (!next) {\n this.dispatchEvent(\n new Hl7ErrorEvent(\n new Error(`Received a message when no pending messages were in the queue. Message: ${event.message}`)\n )\n );\n return;\n }\n // Resolve the promise if there is one pending for this message\n next.resolve?.(event.message);\n });\n }\n\n private sendImpl(reply: Hl7Message, queueItem: Hl7MessageQueueItem): void {\n this.messageQueue.push(queueItem);\n const replyString = reply.toString();\n const replyBuffer = iconv.encode(replyString, this.encoding);\n const outputBuffer = Buffer.alloc(replyBuffer.length + 3);\n outputBuffer.writeInt8(VT, 0);\n replyBuffer.copy(outputBuffer, 1);\n outputBuffer.writeInt8(FS, replyBuffer.length + 1);\n outputBuffer.writeInt8(CR, replyBuffer.length + 2);\n this.socket.write(outputBuffer);\n }\n\n send(reply: Hl7Message): void {\n this.sendImpl(reply, { message: reply });\n }\n\n async sendAndWait(msg: Hl7Message): Promise<Hl7Message> {\n return new Promise<Hl7Message>((resolve, reject) => {\n const queueItem = { message: msg, resolve, reject };\n this.sendImpl(msg, queueItem);\n });\n }\n\n close(): void {\n this.socket.end();\n this.socket.destroy();\n this.dispatchEvent(new Hl7CloseEvent());\n }\n\n private appendData(data: Buffer): void {\n this.chunks.push(data);\n }\n\n private resetBuffer(): void {\n this.chunks = [];\n }\n}\n", "/**\n * VT (Vertical Tab) character.\n *\n * In HL7 messages, this character is used to indicate the start of a message.\n */\nexport const VT = 0x0b;\n\n/**\n * CR (Carriage Return) character.\n *\n * In HL7 messages, this character is used to indicate the end of a message.\n */\nexport const CR = 0x0d;\n\n/**\n * FS (File Separator) character.\n *\n * In HL7 messages, this character is used to separate fields.\n */\nexport const FS = 0x1c;\n", "import { Hl7Message } from '@medplum/core';\nimport { Hl7Connection } from './connection';\n\nexport class Hl7MessageEvent extends Event {\n readonly connection: Hl7Connection;\n readonly message: Hl7Message;\n\n constructor(connection: Hl7Connection, message: Hl7Message) {\n super('message');\n this.connection = connection;\n this.message = message;\n }\n}\n\nexport class Hl7ErrorEvent extends Event {\n readonly error: Error;\n\n constructor(error: Error) {\n super('error');\n this.error = error;\n }\n}\n\nexport class Hl7CloseEvent extends Event {\n constructor() {\n super('close');\n }\n}\n", "import net from 'node:net';\nimport { Hl7Connection } from './connection';\n\nexport class Hl7Server {\n readonly handler: (connection: Hl7Connection) => void;\n server?: net.Server;\n\n constructor(handler: (connection: Hl7Connection) => void) {\n this.handler = handler;\n }\n\n start(port: number, encoding?: string, enhancedMode = false): void {\n const server = net.createServer((socket) => {\n const connection = new Hl7Connection(socket, encoding, enhancedMode);\n this.handler(connection);\n });\n\n server.listen(port);\n this.server = server;\n }\n\n async stop(): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (!this.server) {\n reject(new Error('Stop was called but there is no server running'));\n return;\n }\n this.server.close((err) => {\n if (err) {\n reject(err);\n return;\n }\n resolve();\n });\n this.server = undefined;\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,QAAAE,EAAA,OAAAC,EAAA,YAAAC,EAAA,cAAAC,EAAA,kBAAAC,EAAA,kBAAAC,EAAA,kBAAAC,EAAA,oBAAAC,EAAA,cAAAC,EAAA,OAAAC,IAAA,eAAAC,EAAAZ,GCQO,IAAea,EAAf,cAA+B,WAAY,CAOhD,iBACEC,EACAC,EACAC,EACM,CACN,MAAM,iBAAiBF,EAAMC,EAAUC,CAAO,CAChD,CAOA,oBACEF,EACAC,EACAC,EACM,CACN,MAAM,oBAAoBF,EAAMC,EAAUC,CAAO,CACnD,CACF,EClCA,IAAAC,EAAgC,oBCDhC,IAAAC,EAA2B,yBAC3BC,EAAkB,yBCIX,IAAMC,EAAK,GAOLC,EAAK,GAOLC,EAAK,GChBX,IAAMC,EAAN,cAA8B,KAAM,CAIzC,YAAYC,EAA2BC,EAAqB,CAC1D,MAAM,SAAS,EACf,KAAK,WAAaD,EAClB,KAAK,QAAUC,CACjB,CACF,EAEaC,EAAN,cAA4B,KAAM,CAGvC,YAAYC,EAAc,CACxB,MAAM,OAAO,EACb,KAAK,MAAQA,CACf,CACF,EAEaC,EAAN,cAA4B,KAAM,CACvC,aAAc,CACZ,MAAM,OAAO,CACf,CACF,EFXO,IAAMC,EAAN,cAA4BC,CAAQ,CAOzC,YAAYC,EAAoBC,EAAmB,QAASC,EAAe,GAAO,CAChF,MAAM,EAJR,KAAQ,OAAmB,CAAC,EAC5B,KAAiB,aAAsC,CAAC,EAKtD,KAAK,OAASF,EACd,KAAK,SAAWC,EAChB,KAAK,aAAeC,EAEpBF,EAAO,GAAG,OAASG,G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AK,QAAQI,CAAU,CACzB,CAAC,EAEDH,EAAO,OAAOH,CAAI,EAClB,KAAK,OAASG,CAChB,CAEA,MAAM,MAAsB,CAC1B,OAAO,IAAI,QAAc,CAACK,EAASC,IAAW,CAC5C,GAAI,CAAC,KAAK,OAAQ,CAChBA,EAAO,IAAI,MAAM,gDAAgD,CAAC,EAClE,MACF,CACA,KAAK,OAAO,MAAOC,GAAQ,CACzB,GAAIA,EAAK,CACPD,EAAOC,CAAG,EACV,MACF,CACAF,EAAQ,CACV,CAAC,EACD,KAAK,OAAS,MAChB,CAAC,CACH,CACF",
|
|
6
|
+
"names": ["index_exports", "__export", "CR", "FS", "Hl7Base", "Hl7Client", "Hl7CloseEvent", "Hl7Connection", "Hl7ErrorEvent", "Hl7MessageEvent", "Hl7Server", "VT", "__toCommonJS", "Hl7Base", "type", "listener", "options", "import_node_net", "import_core", "import_iconv_lite", "VT", "CR", "FS", "Hl7MessageEvent", "connection", "message", "Hl7ErrorEvent", "error", "Hl7CloseEvent", "Hl7Connection", "Hl7Base", "socket", "encoding", "enhancedMode", "data", "buffer", "contentBuffer", "contentString", "iconv", "message", "Hl7MessageEvent", "err", "Hl7ErrorEvent", "event", "next", "reply", "queueItem", "replyString", "replyBuffer", "outputBuffer", "msg", "resolve", "reject", "Hl7CloseEvent", "Hl7Client", "Hl7Base", "options", "resolve", "reject", "error", "connection", "Hl7Connection", "Hl7CloseEvent", "event", "Hl7ErrorEvent", "err", "msg", "import_node_net", "Hl7Server", "handler", "port", "encoding", "enhancedMode", "server", "net", "socket", "connection", "Hl7Connection", "resolve", "reject", "err"]
|
|
7
7
|
}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -51,9 +51,10 @@ export declare class Hl7CloseEvent extends Event {
|
|
|
51
51
|
export declare class Hl7Connection extends Hl7Base {
|
|
52
52
|
readonly socket: net.Socket;
|
|
53
53
|
readonly encoding: string;
|
|
54
|
+
readonly enhancedMode: boolean;
|
|
54
55
|
private chunks;
|
|
55
56
|
private readonly messageQueue;
|
|
56
|
-
constructor(socket: net.Socket, encoding?: string);
|
|
57
|
+
constructor(socket: net.Socket, encoding?: string, enhancedMode?: boolean);
|
|
57
58
|
private sendImpl;
|
|
58
59
|
send(reply: Hl7Message): void;
|
|
59
60
|
sendAndWait(msg: Hl7Message): Promise<Hl7Message>;
|
|
@@ -89,7 +90,7 @@ export declare class Hl7Server {
|
|
|
89
90
|
readonly handler: (connection: Hl7Connection) => void;
|
|
90
91
|
server?: net.Server;
|
|
91
92
|
constructor(handler: (connection: Hl7Connection) => void);
|
|
92
|
-
start(port: number, encoding?: string): void;
|
|
93
|
+
start(port: number, encoding?: string, enhancedMode?: boolean): void;
|
|
93
94
|
stop(): Promise<void>;
|
|
94
95
|
}
|
|
95
96
|
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -51,9 +51,10 @@ export declare class Hl7CloseEvent extends Event {
|
|
|
51
51
|
export declare class Hl7Connection extends Hl7Base {
|
|
52
52
|
readonly socket: net.Socket;
|
|
53
53
|
readonly encoding: string;
|
|
54
|
+
readonly enhancedMode: boolean;
|
|
54
55
|
private chunks;
|
|
55
56
|
private readonly messageQueue;
|
|
56
|
-
constructor(socket: net.Socket, encoding?: string);
|
|
57
|
+
constructor(socket: net.Socket, encoding?: string, enhancedMode?: boolean);
|
|
57
58
|
private sendImpl;
|
|
58
59
|
send(reply: Hl7Message): void;
|
|
59
60
|
sendAndWait(msg: Hl7Message): Promise<Hl7Message>;
|
|
@@ -89,7 +90,7 @@ export declare class Hl7Server {
|
|
|
89
90
|
readonly handler: (connection: Hl7Connection) => void;
|
|
90
91
|
server?: net.Server;
|
|
91
92
|
constructor(handler: (connection: Hl7Connection) => void);
|
|
92
|
-
start(port: number, encoding?: string): void;
|
|
93
|
+
start(port: number, encoding?: string, enhancedMode?: boolean): void;
|
|
93
94
|
stop(): Promise<void>;
|
|
94
95
|
}
|
|
95
96
|
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var a=class extends EventTarget{addEventListener(
|
|
1
|
+
var a=class extends EventTarget{addEventListener(t,e,s){super.addEventListener(t,e,s)}removeEventListener(t,e,s){super.removeEventListener(t,e,s)}};import{connect as y}from"node:net";import{Hl7Message as x}from"@medplum/core";import m from"iconv-lite";var H=11,p=13,v=28;var h=class extends Event{constructor(t,e){super("message"),this.connection=t,this.message=e}},i=class extends Event{constructor(t){super("error"),this.error=t}},l=class extends Event{constructor(){super("close")}};var d=class extends a{constructor(e,s="utf-8",r=!1){super();this.chunks=[];this.messageQueue=[];this.socket=e,this.encoding=s,this.enhancedMode=r,e.on("data",n=>{try{if(this.appendData(n),n.at(-2)===28&&n.at(-1)===13){let o=Buffer.concat(this.chunks),g=o.subarray(1,o.length-2),E=m.decode(g,this.encoding),k=x.parse(E);this.dispatchEvent(new h(this,k)),this.resetBuffer()}}catch(o){this.dispatchEvent(new i(o))}}),e.on("error",n=>{this.resetBuffer(),this.dispatchEvent(new i(n))}),e.on("end",()=>{this.close()}),this.addEventListener("message",n=>{r&&this.send(n.message.buildAck({ackCode:"CA"}));let o=this.messageQueue.shift();if(!o){this.dispatchEvent(new i(new Error(`Received a message when no pending messages were in the queue. Message: ${n.message}`)));return}o.resolve?.(n.message)})}sendImpl(e,s){this.messageQueue.push(s);let r=e.toString(),n=m.encode(r,this.encoding),o=Buffer.alloc(n.length+3);o.writeInt8(11,0),n.copy(o,1),o.writeInt8(28,n.length+1),o.writeInt8(13,n.length+2),this.socket.write(o)}send(e){this.sendImpl(e,{message:e})}async sendAndWait(e){return new Promise((s,r)=>{let n={message:e,resolve:s,reject:r};this.sendImpl(e,n)})}close(){this.socket.end(),this.socket.destroy(),this.dispatchEvent(new l)}appendData(e){this.chunks.push(e)}resetBuffer(){this.chunks=[]}};var u=class extends a{constructor(t){super(),this.options=t,this.host=this.options.host,this.port=this.options.port,this.encoding=this.options.encoding,this.keepAlive=this.options.keepAlive??!1,this.connectTimeout=this.options.connectTimeout??3e4}connect(){return this.connection?Promise.resolve(this.connection):(this.socket&&(this.socket.removeAllListeners(),this.socket.destroy(),this.socket=void 0),new Promise((t,e)=>{this.socket=y({host:this.host,port:this.port,keepAlive:this.keepAlive}),this.connectTimeout>0&&(this.socket.setTimeout(this.connectTimeout),this.socket.on("timeout",()=>{let s=new Error(`Connection timeout after ${this.connectTimeout}ms`);this.socket&&(this.socket.destroy(),this.socket=void 0),e(s)})),this.socket.on("connect",()=>{if(!this.socket)return;let s;this.connection=s=new d(this.socket,this.encoding),this.socket.setTimeout(0),s.addEventListener("close",()=>{this.socket=void 0,this.dispatchEvent(new l)}),s.addEventListener("error",r=>{this.dispatchEvent(new i(r.error))}),t(this.connection)}),this.socket.on("error",s=>{this.socket&&(this.socket.destroy(),this.socket=void 0),e(s)})}))}async send(t){return(await this.connect()).send(t)}async sendAndWait(t){return(await this.connect()).sendAndWait(t)}close(){this.socket&&(this.socket.removeAllListeners(),this.socket.destroy(),this.socket=void 0),this.connection&&(this.connection.close(),delete this.connection)}};import M from"node:net";var f=class{constructor(t){this.handler=t}start(t,e,s=!1){let r=M.createServer(n=>{let o=new d(n,e,s);this.handler(o)});r.listen(t),this.server=r}async stop(){return new Promise((t,e)=>{if(!this.server){e(new Error("Stop was called but there is no server running"));return}this.server.close(s=>{if(s){e(s);return}t()}),this.server=void 0})}};export{p as CR,v as FS,a as Hl7Base,u as Hl7Client,l as Hl7CloseEvent,d as Hl7Connection,i as Hl7ErrorEvent,h as Hl7MessageEvent,f as Hl7Server,H as VT};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/base.ts", "../../src/client.ts", "../../src/connection.ts", "../../src/constants.ts", "../../src/events.ts", "../../src/server.ts"],
|
|
4
|
-
"sourcesContent": ["import { Hl7CloseEvent, Hl7ErrorEvent, Hl7MessageEvent } from './events';\n\nexport interface Hl7EventMap {\n message: Hl7MessageEvent;\n error: Hl7ErrorEvent;\n close: Hl7CloseEvent;\n}\n\nexport abstract class Hl7Base extends EventTarget {\n addEventListener<K extends keyof Hl7EventMap>(\n type: K,\n listener: ((event: Hl7EventMap[K]) => void) | EventListenerObject | null,\n options?: boolean | AddEventListenerOptions\n ): void;\n\n addEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject | null,\n options?: boolean | AddEventListenerOptions\n ): void {\n super.addEventListener(type, listener, options);\n }\n removeEventListener<K extends keyof Hl7EventMap>(\n type: K,\n listener: ((event: Hl7EventMap[K]) => void) | EventListenerObject | null,\n options?: boolean | AddEventListenerOptions\n ): void;\n\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject | null,\n options?: boolean | AddEventListenerOptions\n ): void {\n super.removeEventListener(type, listener, options);\n }\n}\n", "import { Hl7Message } from '@medplum/core';\nimport { connect, Socket } from 'node:net';\nimport { Hl7Base } from './base';\nimport { Hl7Connection } from './connection';\nimport { Hl7CloseEvent, Hl7ErrorEvent } from './events';\n\nexport interface Hl7ClientOptions {\n host: string;\n port: number;\n encoding?: string;\n keepAlive?: boolean;\n connectTimeout?: number; // Add timeout option\n}\n\nexport class Hl7Client extends Hl7Base {\n options: Hl7ClientOptions;\n host: string;\n port: number;\n encoding?: string;\n connection?: Hl7Connection;\n keepAlive: boolean;\n private socket?: Socket;\n private connectTimeout: number;\n\n constructor(options: Hl7ClientOptions) {\n super();\n this.options = options;\n this.host = this.options.host;\n this.port = this.options.port;\n this.encoding = this.options.encoding;\n this.keepAlive = this.options.keepAlive ?? false;\n this.connectTimeout = this.options.connectTimeout ?? 30000; // Default 30 seconds\n }\n\n connect(): Promise<Hl7Connection> {\n // If we already have a connection, use it\n if (this.connection) {\n return Promise.resolve(this.connection);\n }\n\n // If there's an ongoing connection attempt, destroy it\n if (this.socket) {\n this.socket.removeAllListeners();\n this.socket.destroy();\n this.socket = undefined;\n }\n\n return new Promise((resolve, reject) => {\n // Create the socket\n this.socket = connect({\n host: this.host,\n port: this.port,\n keepAlive: this.keepAlive,\n });\n\n // Set timeout if specified\n if (this.connectTimeout > 0) {\n this.socket.setTimeout(this.connectTimeout);\n\n // Handle timeout event\n this.socket.on('timeout', () => {\n const error = new Error(`Connection timeout after ${this.connectTimeout}ms`);\n if (this.socket) {\n this.socket.destroy();\n this.socket = undefined;\n }\n reject(error);\n });\n }\n\n // Handle successful connection\n this.socket.on('connect', () => {\n if (!this.socket) {\n return; // Socket was already destroyed\n }\n\n // Create the HL7 connection\n let connection: Hl7Connection;\n this.connection = connection = new Hl7Connection(this.socket, this.encoding);\n\n // Remove the timeout listener as we're now connected\n this.socket.setTimeout(0);\n\n // Set up event handlers\n connection.addEventListener('close', () => {\n this.socket = undefined;\n this.dispatchEvent(new Hl7CloseEvent());\n });\n\n connection.addEventListener('error', (event) => {\n this.dispatchEvent(new Hl7ErrorEvent(event.error));\n });\n\n resolve(this.connection);\n });\n\n // Handle connection errors\n this.socket.on('error', (err) => {\n if (this.socket) {\n this.socket.destroy();\n this.socket = undefined;\n }\n reject(err);\n });\n });\n }\n\n async send(msg: Hl7Message): Promise<void> {\n return (await this.connect()).send(msg);\n }\n\n async sendAndWait(msg: Hl7Message): Promise<Hl7Message> {\n return (await this.connect()).sendAndWait(msg);\n }\n\n close(): void {\n // Close the socket if it exists\n if (this.socket) {\n this.socket.removeAllListeners();\n this.socket.destroy();\n this.socket = undefined;\n }\n\n // Close established connection if it exists\n if (this.connection) {\n this.connection.close();\n delete this.connection;\n }\n }\n}\n", "import { Hl7Message } from '@medplum/core';\nimport iconv from 'iconv-lite';\nimport net from 'node:net';\nimport { Hl7Base } from './base';\nimport { CR, FS, VT } from './constants';\nimport { Hl7CloseEvent, Hl7ErrorEvent, Hl7MessageEvent } from './events';\n\n// iconv-lite docs have great examples and explanations for how to use Buffers with iconv-lite:\n// See: https://github.com/ashtuchkin/iconv-lite/wiki/Use-Buffers-when-decoding\n\nexport type Hl7MessageQueueItem = {\n message: Hl7Message;\n resolve?: (reply: Hl7Message) => void;\n reject?: (err: Error) => void;\n};\n\nexport class Hl7Connection extends Hl7Base {\n readonly socket: net.Socket;\n readonly encoding: string;\n private chunks: Buffer[] = [];\n private readonly messageQueue: Hl7MessageQueueItem[] = [];\n\n constructor(socket: net.Socket, encoding: string = 'utf-8') {\n super();\n\n this.socket = socket;\n this.encoding = encoding;\n\n socket.on('data', (data: Buffer) => {\n try {\n this.appendData(data);\n if (data.at(-2) === FS && data.at(-1) === CR) {\n const buffer = Buffer.concat(this.chunks);\n const contentBuffer = buffer.subarray(1, buffer.length - 2);\n const contentString = iconv.decode(contentBuffer, this.encoding);\n const message = Hl7Message.parse(contentString);\n this.dispatchEvent(new Hl7MessageEvent(this, message));\n this.resetBuffer();\n }\n } catch (err) {\n this.dispatchEvent(new Hl7ErrorEvent(err as Error));\n }\n });\n\n socket.on('error', (err) => {\n this.resetBuffer();\n this.dispatchEvent(new Hl7ErrorEvent(err));\n });\n\n socket.on('end', () => {\n this.close();\n });\n\n this.addEventListener('message', (event) => {\n // Get the queue item at the head of the queue\n const next = this.messageQueue.shift();\n // If there isn't an item, then throw an error\n if (!next) {\n this.dispatchEvent(\n new Hl7ErrorEvent(\n new Error(`Received a message when no pending messages were in the queue. Message: ${event.message}`)\n )\n );\n return;\n }\n // Resolve the promise if there is one pending for this message\n next.resolve?.(event.message);\n });\n }\n\n private sendImpl(reply: Hl7Message, queueItem: Hl7MessageQueueItem): void {\n this.messageQueue.push(queueItem);\n const replyString = reply.toString();\n const replyBuffer = iconv.encode(replyString, this.encoding);\n const outputBuffer = Buffer.alloc(replyBuffer.length + 3);\n outputBuffer.writeInt8(VT, 0);\n replyBuffer.copy(outputBuffer, 1);\n outputBuffer.writeInt8(FS, replyBuffer.length + 1);\n outputBuffer.writeInt8(CR, replyBuffer.length + 2);\n this.socket.write(outputBuffer);\n }\n\n send(reply: Hl7Message): void {\n this.sendImpl(reply, { message: reply });\n }\n\n async sendAndWait(msg: Hl7Message): Promise<Hl7Message> {\n return new Promise<Hl7Message>((resolve, reject) => {\n const queueItem = { message: msg, resolve, reject };\n this.sendImpl(msg, queueItem);\n });\n }\n\n close(): void {\n this.socket.end();\n this.socket.destroy();\n this.dispatchEvent(new Hl7CloseEvent());\n }\n\n private appendData(data: Buffer): void {\n this.chunks.push(data);\n }\n\n private resetBuffer(): void {\n this.chunks = [];\n }\n}\n", "/**\n * VT (Vertical Tab) character.\n *\n * In HL7 messages, this character is used to indicate the start of a message.\n */\nexport const VT = 0x0b;\n\n/**\n * CR (Carriage Return) character.\n *\n * In HL7 messages, this character is used to indicate the end of a message.\n */\nexport const CR = 0x0d;\n\n/**\n * FS (File Separator) character.\n *\n * In HL7 messages, this character is used to separate fields.\n */\nexport const FS = 0x1c;\n", "import { Hl7Message } from '@medplum/core';\nimport { Hl7Connection } from './connection';\n\nexport class Hl7MessageEvent extends Event {\n readonly connection: Hl7Connection;\n readonly message: Hl7Message;\n\n constructor(connection: Hl7Connection, message: Hl7Message) {\n super('message');\n this.connection = connection;\n this.message = message;\n }\n}\n\nexport class Hl7ErrorEvent extends Event {\n readonly error: Error;\n\n constructor(error: Error) {\n super('error');\n this.error = error;\n }\n}\n\nexport class Hl7CloseEvent extends Event {\n constructor() {\n super('close');\n }\n}\n", "import net from 'node:net';\nimport { Hl7Connection } from './connection';\n\nexport class Hl7Server {\n readonly handler: (connection: Hl7Connection) => void;\n server?: net.Server;\n\n constructor(handler: (connection: Hl7Connection) => void) {\n this.handler = handler;\n }\n\n start(port: number, encoding?: string): void {\n const server = net.createServer((socket) => {\n const connection = new Hl7Connection(socket, encoding);\n this.handler(connection);\n });\n\n server.listen(port);\n this.server = server;\n }\n\n async stop(): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (!this.server) {\n reject(new Error('Stop was called but there is no server running'));\n return;\n }\n this.server.close((err) => {\n if (err) {\n reject(err);\n return;\n }\n resolve();\n });\n this.server = undefined;\n });\n }\n}\n"],
|
|
5
|
-
"mappings": "AAQO,IAAeA,EAAf,cAA+B,WAAY,CAOhD,iBACEC,EACAC,EACAC,EACM,CACN,MAAM,iBAAiBF,EAAMC,EAAUC,CAAO,CAChD,CAOA,oBACEF,EACAC,EACAC,EACM,CACN,MAAM,oBAAoBF,EAAMC,EAAUC,CAAO,CACnD,CACF,EClCA,OAAS,WAAAC,MAAuB,WCDhC,OAAS,cAAAC,MAAkB,gBAC3B,OAAOC,MAAW,aCIX,IAAMC,EAAK,GAOLC,EAAK,GAOLC,EAAK,GChBX,IAAMC,EAAN,cAA8B,KAAM,CAIzC,YAAYC,EAA2BC,EAAqB,CAC1D,MAAM,SAAS,EACf,KAAK,WAAaD,EAClB,KAAK,QAAUC,CACjB,CACF,EAEaC,EAAN,cAA4B,KAAM,CAGvC,YAAYC,EAAc,CACxB,MAAM,OAAO,EACb,KAAK,MAAQA,CACf,CACF,EAEaC,EAAN,cAA4B,KAAM,CACvC,aAAc,CACZ,MAAM,OAAO,CACf,CACF,EFXO,IAAMC,EAAN,cAA4BC,CAAQ,
|
|
6
|
-
"names": ["Hl7Base", "type", "listener", "options", "connect", "Hl7Message", "iconv", "VT", "CR", "FS", "Hl7MessageEvent", "connection", "message", "Hl7ErrorEvent", "error", "Hl7CloseEvent", "Hl7Connection", "Hl7Base", "socket", "encoding", "data", "buffer", "contentBuffer", "contentString", "iconv", "message", "Hl7Message", "Hl7MessageEvent", "err", "Hl7ErrorEvent", "event", "next", "reply", "queueItem", "replyString", "replyBuffer", "outputBuffer", "msg", "resolve", "reject", "Hl7CloseEvent", "Hl7Client", "Hl7Base", "options", "resolve", "reject", "connect", "error", "connection", "Hl7Connection", "Hl7CloseEvent", "event", "Hl7ErrorEvent", "err", "msg", "net", "Hl7Server", "handler", "port", "encoding", "server", "net", "socket", "connection", "Hl7Connection", "resolve", "reject", "err"]
|
|
4
|
+
"sourcesContent": ["import { Hl7CloseEvent, Hl7ErrorEvent, Hl7MessageEvent } from './events';\n\nexport interface Hl7EventMap {\n message: Hl7MessageEvent;\n error: Hl7ErrorEvent;\n close: Hl7CloseEvent;\n}\n\nexport abstract class Hl7Base extends EventTarget {\n addEventListener<K extends keyof Hl7EventMap>(\n type: K,\n listener: ((event: Hl7EventMap[K]) => void) | EventListenerObject | null,\n options?: boolean | AddEventListenerOptions\n ): void;\n\n addEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject | null,\n options?: boolean | AddEventListenerOptions\n ): void {\n super.addEventListener(type, listener, options);\n }\n removeEventListener<K extends keyof Hl7EventMap>(\n type: K,\n listener: ((event: Hl7EventMap[K]) => void) | EventListenerObject | null,\n options?: boolean | AddEventListenerOptions\n ): void;\n\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject | null,\n options?: boolean | AddEventListenerOptions\n ): void {\n super.removeEventListener(type, listener, options);\n }\n}\n", "import { Hl7Message } from '@medplum/core';\nimport { connect, Socket } from 'node:net';\nimport { Hl7Base } from './base';\nimport { Hl7Connection } from './connection';\nimport { Hl7CloseEvent, Hl7ErrorEvent } from './events';\n\nexport interface Hl7ClientOptions {\n host: string;\n port: number;\n encoding?: string;\n keepAlive?: boolean;\n connectTimeout?: number; // Add timeout option\n}\n\nexport class Hl7Client extends Hl7Base {\n options: Hl7ClientOptions;\n host: string;\n port: number;\n encoding?: string;\n connection?: Hl7Connection;\n keepAlive: boolean;\n private socket?: Socket;\n private connectTimeout: number;\n\n constructor(options: Hl7ClientOptions) {\n super();\n this.options = options;\n this.host = this.options.host;\n this.port = this.options.port;\n this.encoding = this.options.encoding;\n this.keepAlive = this.options.keepAlive ?? false;\n this.connectTimeout = this.options.connectTimeout ?? 30000; // Default 30 seconds\n }\n\n connect(): Promise<Hl7Connection> {\n // If we already have a connection, use it\n if (this.connection) {\n return Promise.resolve(this.connection);\n }\n\n // If there's an ongoing connection attempt, destroy it\n if (this.socket) {\n this.socket.removeAllListeners();\n this.socket.destroy();\n this.socket = undefined;\n }\n\n return new Promise((resolve, reject) => {\n // Create the socket\n this.socket = connect({\n host: this.host,\n port: this.port,\n keepAlive: this.keepAlive,\n });\n\n // Set timeout if specified\n if (this.connectTimeout > 0) {\n this.socket.setTimeout(this.connectTimeout);\n\n // Handle timeout event\n this.socket.on('timeout', () => {\n const error = new Error(`Connection timeout after ${this.connectTimeout}ms`);\n if (this.socket) {\n this.socket.destroy();\n this.socket = undefined;\n }\n reject(error);\n });\n }\n\n // Handle successful connection\n this.socket.on('connect', () => {\n if (!this.socket) {\n return; // Socket was already destroyed\n }\n\n // Create the HL7 connection\n let connection: Hl7Connection;\n this.connection = connection = new Hl7Connection(this.socket, this.encoding);\n\n // Remove the timeout listener as we're now connected\n this.socket.setTimeout(0);\n\n // Set up event handlers\n connection.addEventListener('close', () => {\n this.socket = undefined;\n this.dispatchEvent(new Hl7CloseEvent());\n });\n\n connection.addEventListener('error', (event) => {\n this.dispatchEvent(new Hl7ErrorEvent(event.error));\n });\n\n resolve(this.connection);\n });\n\n // Handle connection errors\n this.socket.on('error', (err) => {\n if (this.socket) {\n this.socket.destroy();\n this.socket = undefined;\n }\n reject(err);\n });\n });\n }\n\n async send(msg: Hl7Message): Promise<void> {\n return (await this.connect()).send(msg);\n }\n\n async sendAndWait(msg: Hl7Message): Promise<Hl7Message> {\n return (await this.connect()).sendAndWait(msg);\n }\n\n close(): void {\n // Close the socket if it exists\n if (this.socket) {\n this.socket.removeAllListeners();\n this.socket.destroy();\n this.socket = undefined;\n }\n\n // Close established connection if it exists\n if (this.connection) {\n this.connection.close();\n delete this.connection;\n }\n }\n}\n", "import { Hl7Message } from '@medplum/core';\nimport iconv from 'iconv-lite';\nimport net from 'node:net';\nimport { Hl7Base } from './base';\nimport { CR, FS, VT } from './constants';\nimport { Hl7CloseEvent, Hl7ErrorEvent, Hl7MessageEvent } from './events';\n\n// iconv-lite docs have great examples and explanations for how to use Buffers with iconv-lite:\n// See: https://github.com/ashtuchkin/iconv-lite/wiki/Use-Buffers-when-decoding\n\nexport type Hl7MessageQueueItem = {\n message: Hl7Message;\n resolve?: (reply: Hl7Message) => void;\n reject?: (err: Error) => void;\n};\n\nexport class Hl7Connection extends Hl7Base {\n readonly socket: net.Socket;\n readonly encoding: string;\n readonly enhancedMode: boolean;\n private chunks: Buffer[] = [];\n private readonly messageQueue: Hl7MessageQueueItem[] = [];\n\n constructor(socket: net.Socket, encoding: string = 'utf-8', enhancedMode = false) {\n super();\n\n this.socket = socket;\n this.encoding = encoding;\n this.enhancedMode = enhancedMode;\n\n socket.on('data', (data: Buffer) => {\n try {\n this.appendData(data);\n if (data.at(-2) === FS && data.at(-1) === CR) {\n const buffer = Buffer.concat(this.chunks);\n const contentBuffer = buffer.subarray(1, buffer.length - 2);\n const contentString = iconv.decode(contentBuffer, this.encoding);\n const message = Hl7Message.parse(contentString);\n this.dispatchEvent(new Hl7MessageEvent(this, message));\n this.resetBuffer();\n }\n } catch (err) {\n this.dispatchEvent(new Hl7ErrorEvent(err as Error));\n }\n });\n\n socket.on('error', (err) => {\n this.resetBuffer();\n this.dispatchEvent(new Hl7ErrorEvent(err));\n });\n\n socket.on('end', () => {\n this.close();\n });\n\n this.addEventListener('message', (event) => {\n if (enhancedMode) {\n this.send(event.message.buildAck({ ackCode: 'CA' }));\n }\n // Get the queue item at the head of the queue\n const next = this.messageQueue.shift();\n // If there isn't an item, then throw an error\n if (!next) {\n this.dispatchEvent(\n new Hl7ErrorEvent(\n new Error(`Received a message when no pending messages were in the queue. Message: ${event.message}`)\n )\n );\n return;\n }\n // Resolve the promise if there is one pending for this message\n next.resolve?.(event.message);\n });\n }\n\n private sendImpl(reply: Hl7Message, queueItem: Hl7MessageQueueItem): void {\n this.messageQueue.push(queueItem);\n const replyString = reply.toString();\n const replyBuffer = iconv.encode(replyString, this.encoding);\n const outputBuffer = Buffer.alloc(replyBuffer.length + 3);\n outputBuffer.writeInt8(VT, 0);\n replyBuffer.copy(outputBuffer, 1);\n outputBuffer.writeInt8(FS, replyBuffer.length + 1);\n outputBuffer.writeInt8(CR, replyBuffer.length + 2);\n this.socket.write(outputBuffer);\n }\n\n send(reply: Hl7Message): void {\n this.sendImpl(reply, { message: reply });\n }\n\n async sendAndWait(msg: Hl7Message): Promise<Hl7Message> {\n return new Promise<Hl7Message>((resolve, reject) => {\n const queueItem = { message: msg, resolve, reject };\n this.sendImpl(msg, queueItem);\n });\n }\n\n close(): void {\n this.socket.end();\n this.socket.destroy();\n this.dispatchEvent(new Hl7CloseEvent());\n }\n\n private appendData(data: Buffer): void {\n this.chunks.push(data);\n }\n\n private resetBuffer(): void {\n this.chunks = [];\n }\n}\n", "/**\n * VT (Vertical Tab) character.\n *\n * In HL7 messages, this character is used to indicate the start of a message.\n */\nexport const VT = 0x0b;\n\n/**\n * CR (Carriage Return) character.\n *\n * In HL7 messages, this character is used to indicate the end of a message.\n */\nexport const CR = 0x0d;\n\n/**\n * FS (File Separator) character.\n *\n * In HL7 messages, this character is used to separate fields.\n */\nexport const FS = 0x1c;\n", "import { Hl7Message } from '@medplum/core';\nimport { Hl7Connection } from './connection';\n\nexport class Hl7MessageEvent extends Event {\n readonly connection: Hl7Connection;\n readonly message: Hl7Message;\n\n constructor(connection: Hl7Connection, message: Hl7Message) {\n super('message');\n this.connection = connection;\n this.message = message;\n }\n}\n\nexport class Hl7ErrorEvent extends Event {\n readonly error: Error;\n\n constructor(error: Error) {\n super('error');\n this.error = error;\n }\n}\n\nexport class Hl7CloseEvent extends Event {\n constructor() {\n super('close');\n }\n}\n", "import net from 'node:net';\nimport { Hl7Connection } from './connection';\n\nexport class Hl7Server {\n readonly handler: (connection: Hl7Connection) => void;\n server?: net.Server;\n\n constructor(handler: (connection: Hl7Connection) => void) {\n this.handler = handler;\n }\n\n start(port: number, encoding?: string, enhancedMode = false): void {\n const server = net.createServer((socket) => {\n const connection = new Hl7Connection(socket, encoding, enhancedMode);\n this.handler(connection);\n });\n\n server.listen(port);\n this.server = server;\n }\n\n async stop(): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (!this.server) {\n reject(new Error('Stop was called but there is no server running'));\n return;\n }\n this.server.close((err) => {\n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AK,OAAS,MAChB,CAAC,CACH,CACF",
|
|
6
|
+
"names": ["Hl7Base", "type", "listener", "options", "connect", "Hl7Message", "iconv", "VT", "CR", "FS", "Hl7MessageEvent", "connection", "message", "Hl7ErrorEvent", "error", "Hl7CloseEvent", "Hl7Connection", "Hl7Base", "socket", "encoding", "enhancedMode", "data", "buffer", "contentBuffer", "contentString", "iconv", "message", "Hl7Message", "Hl7MessageEvent", "err", "Hl7ErrorEvent", "event", "next", "reply", "queueItem", "replyString", "replyBuffer", "outputBuffer", "msg", "resolve", "reject", "Hl7CloseEvent", "Hl7Client", "Hl7Base", "options", "resolve", "reject", "connect", "error", "connection", "Hl7Connection", "Hl7CloseEvent", "event", "Hl7ErrorEvent", "err", "msg", "net", "Hl7Server", "handler", "port", "encoding", "enhancedMode", "server", "net", "socket", "connection", "Hl7Connection", "resolve", "reject", "err"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medplum/hl7",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.9",
|
|
4
4
|
"description": "Medplum HL7 Utilities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"medplum",
|
|
@@ -54,11 +54,11 @@
|
|
|
54
54
|
"test": "jest"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@medplum/core": "4.1.
|
|
57
|
+
"@medplum/core": "4.1.9",
|
|
58
58
|
"iconv-lite": "0.6.3"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@medplum/fhirtypes": "4.1.
|
|
61
|
+
"@medplum/fhirtypes": "4.1.9"
|
|
62
62
|
},
|
|
63
63
|
"engines": {
|
|
64
64
|
"node": ">=20.0.0"
|