Replies: 13 comments 12 replies
-
You need to juggle it around differently:
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply. Is there any way to have two variables that behave like the msg object? I.E. msg1 = msgAck, msg2 = msgData? |
Beta Was this translation helpful? Give feedback.
-
Try it! The code I suggested should work the way you want.
If that does not work then I would look at the serializer call. I think it is correct though. |
Beta Was this translation helpful? Give feedback.
-
Yep. Something with the conversion it doesn't like. I'll play around with it. Wrapped com.mirth.connect.donkey.model.message.MessageSerializerException: Error converting ER7 to XML |
Beta Was this translation helpful? Give feedback.
-
Here is the sample JSON I'm getting. I'm wondering if the '\r' in the message is throwing it off. On the other hand, it works fine when assigned to the msg object, This looks ugly in preview, and it is putting a strikethrough in part of the message. Not sure if there is a better way to post this. { |
Beta Was this translation helpful? Give feedback.
-
It actually is escaped but it appears to have been removed when I pasted it in here. See the screenshot. |
Beta Was this translation helpful? Give feedback.
-
Here it is |
Beta Was this translation helpful? Give feedback.
-
var serializationProperties = SerializerFactory.getDefaultSerializationProperties('HL7V2');
$c('msg1', new XML(SerializerFactory.getSerializer('HL7V2', serializationProperties, null).toXML(escape(msg['acknowledgement']))))
$c('msg2', new XML(SerializerFactory.getSerializer('HL7V2', serializationProperties, null).toXML(escape(msg['message_data']))))
$c('msg1_PID3', $c('msg1')['PID']['PID.3']['PID.3.1'].toString())
$c('msg2_PID3', $c('msg2')['PID']['PID.3']['PID.3.1'].toString()) |
Beta Was this translation helpful? Give feedback.
-
Interesting. So I tried that and then logging out the msg1
but it says msg1 is not defined. How do you access it? |
Beta Was this translation helpful? Give feedback.
-
Gotcha. Thank you for your help. |
Beta Was this translation helpful? Give feedback.
-
Follow-up question if I may. I'm getting a different error (different message) saying this:
The incoming Json has been stripped down to basically nothing trying to remove the error.
Any ideas on this? I'm thinking it may have to do with the conversion between JSON and HL7 in the mirth source since I'm setting inbound to JSON and outbound to HL7v2.x in the Set Data Types box. |
Beta Was this translation helpful? Give feedback.
-
The source Inbound is set to JSON and the remaining are set to HL7v2.x |
Beta Was this translation helpful? Give feedback.
-
Yes. I think that was the issue. I was originally setting the msg object to the acknowledgment HL7 from the JSON. With your code, that was removed, so no HL7 was getting sent to the destinations. I think it is working as I need it now. Thanks much for the help. |
Beta Was this translation helpful? Give feedback.
-
I have a listener channel that receives a JSON message which contains an HL7 formatted ack in the acknowledgement node as well as a HL7 formatted original message in the message_data mode.
I can assign either of these to the msg object using msg = SerializerFactory.getSerializer('HL7V2').toXML(msg.acknowledgement); or
msg = SerializerFactory.getSerializer('HL7V2').toXML(msg.message_data);
I can then work with it as you would a normal msg. What I want to do is to read both of these HL7 messages into two different variables:
var origMsg = new XML();
msg = SerializerFactory.getSerializer('HL7V2').toXML(msg.acknowledgement);
origMsg = SerializerFactory.getSerializer('HL7V2').toXML(msg.message_data);
At this point, orgMsg doesn't appear to contains any data:
origMsg
The problem is, origMsg doesn't behave like the msg object. I can't access anything in the message using standard conventions. For example, I'd like to set the ack msg MSH-6.1 = the original message MSH-6.1. but I can't figure out how to do that.
(msg['MSH']['MSH.6']['MSH.6.1'] = origMsg['MSH']['MSH.6']['MSH.6.1'].toString()).
Any suggestions?
Beta Was this translation helpful? Give feedback.
All reactions