web stats
String to HL7 - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 01-21-2020, 06:49 AM
gojoshi gojoshi is offline
OBX.1 Kenobi
 
Join Date: Jul 2013
Posts: 50
gojoshi is on a distinguished road
Default String to HL7

I have a channel that captures the raw source messages (which are simple HL7 V2 messages), with the following code:

channelMap.put('sourceInbound',connectorMessage.ge tRawData());

This channel has numerous destination connectors. On one (AND ONLY ONE) of the destination connectors, I need to manipulate the raw message from the source.

So basically, on the destination there is a transformer that captures the raw source message with the following code-

var toHL7 = $('RawInbound');

I would like to use the native mirth functions such as:

msg['MSH']['MSH.4']['MSH.4.1'] = "BlaBlaBla";
msg['IN1']['IN1.4']['IN1.4.1'] = "BlaBlaBla";

or even mirth's native interators such as

for each (seg in msg.children()) {
if (seg.name().toString() == "SEG") {
var sample_value = seg['SEG.1']['SEG.1.1'].toString();
}
}

However, since the destination transformer sees the raw message as a string, it is not recognizing the message as an HL7 message.
What would be the best way to have the destination connector recognize the message as a HL7 message and not a string value?

I have tried to convert to XML and convert back to HL7 using mirth’s built in functions, and it does the conversion, to XML and back to HL7, but it still does not recognize the message as an HL7 message, even after converting it back to HL7 from XML.

Any ideas on how to have the destination connector recognize the value stored in the variable “toHL7” as an HL7 message, so that I can use the stated built in Mirth functions?
Reply With Quote
  #2  
Old 01-21-2020, 07:01 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,360
cory_cole is on a distinguished road
Default

msg = new XML(toHL7);
Reply With Quote
  #3  
Old 01-21-2020, 07:53 AM
gojoshi gojoshi is offline
OBX.1 Kenobi
 
Join Date: Jul 2013
Posts: 50
gojoshi is on a distinguished road
Default

Cory_cole, I think we've tried that already, anyways, just tried again, and got this:

Transformer error
ERROR MESSAGE: Error evaluating transformer
java.lang.NullPointerException
at org.mozilla.javascript.xmlimpl.XmlNode$InternalLis t.add(XmlNode.java:835)
at org.mozilla.javascript.xmlimpl.XMLList.replace(XML List.java:55)
at org.mozilla.javascript.xmlimpl.XMLList.putXMLPrope rty(XMLList.java:151)
at org.mozilla.javascript.xmlimpl.XMLList.putXMLPrope rty(XMLList.java:150)
at org.mozilla.javascript.xmlimpl.XMLObjectImpl.put(X MLObjectImpl.java:261)
at org.mozilla.javascript.ScriptRuntime.setObjectElem (ScriptRuntime.java:1622)
at org.mozilla.javascript.ScriptRuntime.setObjectElem (ScriptRuntime.java:1615)
at org.mozilla.javascript.Interpreter.doSetElem(Inter preter.java:2237)
at org.mozilla.javascript.Interpreter.interpretLoop(I nterpreter.java:1268)
at org.mozilla.javascript.Interpreter.interpret(Inter preter.java:815)
at org.mozilla.javascript.InterpretedFunction.call(In terpretedFunction.java:109)
at org.mozilla.javascript.ContextFactory.doTopCall(Co ntextFactory.java:393)
at org.mozilla.javascript.ScriptRuntime.doTopCall(Scr iptRuntime.java:3280)
at org.mozilla.javascript.InterpretedFunction.exec(In terpretedFunction.java:120)
at com.mirth.connect.server.util.javascript.JavaScrip tTask.executeScript(JavaScriptTask.java:150)
at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.doCall(JavaS criptFilterTransformer.java:143)
at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.doCall(JavaS criptFilterTransformer.java:119)
at com.mirth.connect.server.util.javascript.JavaScrip tTask.call(JavaScriptTask.java:113)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker( Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source)
at java.lang.Thread.run(Unknown Source)
Reply With Quote
  #4  
Old 01-21-2020, 08:02 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,360
cory_cole is on a distinguished road
Default

what do you get if you do

logger.info(toHL7)?
Reply With Quote
  #5  
Old 01-21-2020, 08:48 AM
gojoshi gojoshi is offline
OBX.1 Kenobi
 
Join Date: Jul 2013
Posts: 50
gojoshi is on a distinguished road
Default

Quote:
Originally Posted by cory_cole View Post
msg = new XML(toHL7);


INFO (transformer:?):

it's not doing the transform..
Reply With Quote
  #6  
Old 01-21-2020, 09:05 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,360
cory_cole is on a distinguished road
Default

Do just the logger.info. Don't do the msg = new XML()
Reply With Quote
  #7  
Old 01-21-2020, 09:18 AM
gojoshi gojoshi is offline
OBX.1 Kenobi
 
Join Date: Jul 2013
Posts: 50
gojoshi is on a distinguished road
Default

Getting the HL7 message:

INFO (transformer:?): MSH|^~\&|***************************************** ****

Starred off the actual message.

Please feel free to try it out on your end, there are just a few transforms, one in the source, and 4 in the destination.
Below are the transforms:

Source Transform:
channelMap.put('sourceInbound',connectorMessage.ge tRawData());

Destination Transform:
var toHL7 = $('sourceInbound');
msg = new XML(toHL7);
logger.info(toHL7);
msg['MSH']['MSH.4']['MSH.4.1'] ="BlaBlaBLa";
Reply With Quote
  #8  
Old 01-21-2020, 09:33 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,360
cory_cole is on a distinguished road
Default

try this...

msg = new XML(toHL7.toString());
Reply With Quote
  #9  
Old 01-21-2020, 09:39 AM
gojoshi gojoshi is offline
OBX.1 Kenobi
 
Join Date: Jul 2013
Posts: 50
gojoshi is on a distinguished road
Default

Same error:

Transformer error
ERROR MESSAGE: Error evaluating transformer
java.lang.NullPointerException
at org.mozilla.javascript.xmlimpl.XmlNode$InternalLis t.add(XmlNode.java:835)
at org.mozilla.javascript.xmlimpl.XMLList.replace(XML List.java:55)
at org.mozilla.javascript.xmlimpl.XMLList.putXMLPrope rty(XMLList.java:151)
at org.mozilla.javascript.xmlimpl.XMLList.putXMLPrope rty(XMLList.java:150)
at org.mozilla.javascript.xmlimpl.XMLObjectImpl.put(X MLObjectImpl.java:261)
at org.mozilla.javascript.ScriptRuntime.setObjectElem (ScriptRuntime.java:1622)
at org.mozilla.javascript.ScriptRuntime.setObjectElem (ScriptRuntime.java:1615)
at org.mozilla.javascript.Interpreter.doSetElem(Inter preter.java:2237)
at org.mozilla.javascript.Interpreter.interpretLoop(I nterpreter.java:1268)
at org.mozilla.javascript.Interpreter.interpret(Inter preter.java:815)
at org.mozilla.javascript.InterpretedFunction.call(In terpretedFunction.java:109)
at org.mozilla.javascript.ContextFactory.doTopCall(Co ntextFactory.java:393)
at org.mozilla.javascript.ScriptRuntime.doTopCall(Scr iptRuntime.java:3280)
at org.mozilla.javascript.InterpretedFunction.exec(In terpretedFunction.java:120)
at com.mirth.connect.server.util.javascript.JavaScrip tTask.executeScript(JavaScriptTask.java:150)
at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.doCall(JavaS criptFilterTransformer.java:143)
at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.doCall(JavaS criptFilterTransformer.java:119)
at com.mirth.connect.server.util.javascript.JavaScrip tTask.call(JavaScriptTask.java:113)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker( Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source)
at java.lang.Thread.run(Unknown Source)
Reply With Quote
  #10  
Old 01-21-2020, 09:39 PM
odo odo is offline
OBX.3 Kenobi
 
Join Date: Feb 2017
Location: Luxembourg
Posts: 165
odo is on a distinguished road
Default

Code:
msg = SerializerFactory.getSerializer('HL7V2').toXML($('RawInbound'));
Reply With Quote
Reply

Tags
convert to hl7, hl7, string, string to hl7

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 06:41 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Mirth Corporation