Replies: 6 comments 18 replies
-
Also using My first thought was that maybe the ORM message is the root cause but on the other hand it works perfectly (no PID segment) when setting the channel to "Auto-generate (Before processing)". Sorry for pushing again... I didn't find the source code - wanted to check how Mirth itself does it. Could someone help to find it? Many thanks. |
Beta Was this translation helpful? Give feedback.
-
Seems that using this method works better using But still, there are issues:
Any ideas? |
Beta Was this translation helpful? Give feedback.
-
This is so weird, after hours of investigation I tried today: var ack = com.mirth.connect.plugins.datatypes.hl7v2.HL7v2ACKGenerator.generateAckResponse(connectorMessage.getRawData(), false, "AA", "", "yyyyMMddHHmmss", "");
$r("RESPONSE", ack); and still includes the strange PID segment in the response. Could anyone lead me to the source code to see how Mirth does it when channel is set to "Auto-generate (Before processing)"? |
Beta Was this translation helpful? Give feedback.
-
Step by step getting forward... 😁 not giving up The following works (no PID segment) except that the ACK response has no linebreak before MSA segment: var xmlMessage = SerializerFactory.getSerializer('HL7V2').toXML(message);
var xmlAck = ACKGenerator.generateAckResponse(xmlMessage, true, "AA", "", "yyyyMMddHHmmss", "");
var hl7Ack = SerializerFactory.getSerializer('HL7V2').fromXML(xmlAck);
$r("RESPONSE", hl7Ack); Result:
If I omit the last step (converting ACK in XML format to HL7v2) then the resulting XML looks fine: var xmlMessage = SerializerFactory.getSerializer('HL7V2').toXML(message);
var xmlAck = ACKGenerator.generateAckResponse(xmlMessage, true, "AA", "", "yyyyMMddHHmmss", "");
$r("RESPONSE", xmlAck); So what's wrong when converting XML (string) message to HL7v2? Any idea why linebreak is missing Result:
|
Beta Was this translation helpful? Give feedback.
-
Just found in the user guide: in |
Beta Was this translation helpful? Give feedback.
-
Problem was that inbound message has linefeed Solution: convert // Inbound message as HL7v2 formatted string
var inboundMessage = connectorMessage.getRawData();
// Ensure to convert message to java String in order to use replaceAll method, then replace all linefeed to carriage return according to HL7v2 standard
inboundMessage = new java.lang.String(inboundMessage.toString()).replaceAll('\n', '\r');
// Create new ACK response
ack = ACKGenerator.generateAckResponse(inboundMessage, "AA", "");
$r("RESPONSE", ack); ... or as a one-liner: $r("RESPONSE", ACKGenerator.generateAckResponse(new java.lang.String(connectorMessage.getRawData().toString()).replaceAll('\n', '\r'), "AA", "")); |
Beta Was this translation helpful? Give feedback.
-
GIVEN my channel settings: "Source" tab under "Source Settings", Response is set to: "RESPONSE" (referring to
$r("RESPONSE")
)AND GIVEN my Preprocessor script contains the line:
$r("RESPONSE", ACKGenerator.generateAckResponse(connectorMessage.getRawData(), "AA", ""));
WHEN inbound message is:
THEN the response contains an empty PID segment:
Why?
Compared to:
GIVEN my channel settings: "Source" tab under "Source Settings", Response is set to: "Auto-generate (Before processing)"
THEN the response contains no PID segment
Mirth v3.11.0
Beta Was this translation helpful? Give feedback.
All reactions