@medplum/agent 4.3.0 → 4.3.2

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.
Files changed (2) hide show
  1. package/dist/cjs/index.cjs +23 -6
  2. package/package.json +5 -5
@@ -33207,7 +33207,7 @@ var $t = class {
33207
33207
  return this.masterSubEmitter || (this.masterSubEmitter = new Ye(...Array.from(this.criteriaEntries.keys()))), this.masterSubEmitter;
33208
33208
  }
33209
33209
  };
33210
- var Yr = "4.3.0-2385e056c";
33210
+ var Yr = "4.3.2-2ad244a48";
33211
33211
  var ma = w.FHIR_JSON + ", */*; q=0.1";
33212
33212
  var ya = "https://api.medplum.com/";
33213
33213
  var ga = 1e3;
@@ -34317,7 +34317,7 @@ var f2 = class extends a {
34317
34317
  if (!this.socket) return;
34318
34318
  let s;
34319
34319
  this.connection = s = new d2(this.socket, this.encoding), this.socket.setTimeout(0), s.addEventListener("close", () => {
34320
- this.socket = void 0, this.dispatchEvent(new l2());
34320
+ this.socket = void 0, this.connection = void 0, this.dispatchEvent(new l2());
34321
34321
  }), s.addEventListener("error", (r6) => {
34322
34322
  this.dispatchEvent(new i(r6.error));
34323
34323
  }), t(this.connection);
@@ -34624,10 +34624,16 @@ var AgentHl7Channel = class extends BaseChannel {
34624
34624
  const connection = this.connections.get(msg.remote);
34625
34625
  if (connection) {
34626
34626
  connection.hl7Connection.send(io.parse(msg.body));
34627
+ } else {
34628
+ this.log.warn(`Attempted to send message to disconnected remote: ${msg.remote}`);
34627
34629
  }
34628
34630
  }
34629
34631
  handleNewConnection(connection) {
34630
34632
  const c = new AgentHl7ChannelConnection(this, connection);
34633
+ c.hl7Connection.addEventListener("close", () => {
34634
+ this.log.info(`Closing connection: ${c.remote}`);
34635
+ this.connections.delete(c.remote);
34636
+ });
34631
34637
  this.log.info(`HL7 connection established: ${c.remote}`);
34632
34638
  this.connections.set(c.remote, c);
34633
34639
  }
@@ -34637,9 +34643,10 @@ var AgentHl7ChannelConnection = class {
34637
34643
  this.channel = channel;
34638
34644
  this.hl7Connection = hl7Connection;
34639
34645
  this.remote = `${hl7Connection.socket.remoteAddress}:${hl7Connection.socket.remotePort}`;
34640
- this.hl7Connection.addEventListener("message", (event) => this.handler(event));
34646
+ this.hl7Connection.addEventListener("message", (event) => this.handleMessage(event));
34647
+ this.hl7Connection.addEventListener("error", (event) => this.handleError(event));
34641
34648
  }
34642
- async handler(event) {
34649
+ async handleMessage(event) {
34643
34650
  try {
34644
34651
  this.channel.log.info(`Received: ${event.message.toString().replaceAll("\r", "\n")}`);
34645
34652
  this.channel.app.addToWebSocketQueue({
@@ -34655,6 +34662,9 @@ var AgentHl7ChannelConnection = class {
34655
34662
  this.channel.log.error(`HL7 error: ${Oe(err)}`);
34656
34663
  }
34657
34664
  }
34665
+ async handleError(event) {
34666
+ this.channel.log.error(`HL7 connection error: ${Oe(event.error)}`);
34667
+ }
34658
34668
  close() {
34659
34669
  this.hl7Connection.close();
34660
34670
  }
@@ -35506,8 +35516,15 @@ ${result}`);
35506
35516
  });
35507
35517
  }
35508
35518
  }
35509
- client.sendAndWait(io.parse(message.body)).then((response2) => {
35510
- this.log.info(`Response: ${response2.toString().replaceAll("\r", "\n")}`);
35519
+ const requestMsg = io.parse(message.body);
35520
+ const msh10 = requestMsg.getSegment("MSH")?.getField(10);
35521
+ if (!msh10) {
35522
+ this.log.error("MSH.10 is missing but required");
35523
+ return;
35524
+ }
35525
+ this.log.info(`[Request -- ID: ${msh10}]: ${requestMsg.toString().replaceAll("\r", "\n")}`);
35526
+ client.sendAndWait(requestMsg).then((response2) => {
35527
+ this.log.info(`[Response -- ID: ${msh10}]: ${response2.toString().replaceAll("\r", "\n")}`);
35511
35528
  this.addToWebSocketQueue({
35512
35529
  type: "agent:transmit:response",
35513
35530
  channel: message.channel,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medplum/agent",
3
- "version": "4.3.0",
3
+ "version": "4.3.2",
4
4
  "description": "Medplum Agent",
5
5
  "homepage": "https://www.medplum.com/",
6
6
  "bugs": {
@@ -24,15 +24,15 @@
24
24
  "test": "jest"
25
25
  },
26
26
  "dependencies": {
27
- "@medplum/core": "4.3.0",
28
- "@medplum/hl7": "4.3.0",
27
+ "@medplum/core": "4.3.2",
28
+ "@medplum/hl7": "4.3.2",
29
29
  "dcmjs-dimse": "0.2.7",
30
30
  "iconv-lite": "0.6.3",
31
31
  "ws": "8.18.3"
32
32
  },
33
33
  "devDependencies": {
34
- "@medplum/fhirtypes": "4.3.0",
35
- "@medplum/mock": "4.3.0",
34
+ "@medplum/fhirtypes": "4.3.2",
35
+ "@medplum/mock": "4.3.2",
36
36
  "@types/async-eventemitter": "0.2.4",
37
37
  "@types/ws": "8.18.1",
38
38
  "mock-socket": "9.3.1",