diff --git a/lib/hl7/segment.js b/lib/hl7/segment.js index 701cffc..24a2e2e 100644 --- a/lib/hl7/segment.js +++ b/lib/hl7/segment.js @@ -89,6 +89,9 @@ segment.prototype.getField = function(index, repeatIndex) { segment.prototype.getComponent = function(fieldIndex, componentIndex, subComponentIndex) { if (this.fields.length >= fieldIndex) { var components = this.fields[fieldIndex - 1].value[0]; + + if(components.value) components = components.value[0]; + if (components.length >= componentIndex) { var component = components[componentIndex - 1] if (subComponentIndex) { diff --git a/lib/server/tcp-server.js b/lib/server/tcp-server.js index 161cdc9..236470f 100644 --- a/lib/server/tcp-server.js +++ b/lib/server/tcp-server.js @@ -94,8 +94,8 @@ TcpServer.prototype.createAckMessage = function(msg) { '', ["ACK"], 'ACK' + moment().format('YYYYMMDDHHmmss'), - 'P', - '2.3') + msg.header.getField(9), + msg.header.getField(10)) ack.addSegment("MSA", "AA", msg.header.getField(8)) return ack;