web stats
Removing Carriage Return and Line Feed from OBX segments for Embedded PDF HL7 - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 08-09-2016, 06:52 AM
derickmiller derickmiller is offline
Mirth Newb
 
Join Date: Mar 2015
Posts: 18
derickmiller is on a distinguished road
Default Removing Carriage Return and Line Feed from OBX segments for Embedded PDF HL7

Mirth 3.4.0

When trying to process an embedded PDF, Mirth is seeing the carriage returns and line feeds at the end of each OBX line and causing it to error. I need to know how to remove these in order for the HL7 to process the OBX as on continuous line.


Part of HL7 I am receiving. There is a carriage return and line feed at the end

OBX|1|ED|TDB^^LAB^^^LN||^Img^PDF^Base64^JVBERi0xLj QKMSAwIG9iago8PAovVGl0bGUgKP7/AEQAQQBTKQovQ3JlYXRvciAo/v8pCi9Qcm9k
dWNlciAo/v8AdwBrAGgAdABtAGwAdABvAHAAZABmKQovQ3JlYXRpb25EYXR lIChEOjIwMTYwODA4
MTI1NjU0LTA0JzAwJykKPj4KZW5kb2JqCjMgMCBvYmoKPDwKL1 R5cGUgL0V4dEdTdGF0ZQovU0Eg


Error I am receiving
Transformer error
ERROR MESSAGE: Error evaluating transformer
com.mirth.connect.server.MirthJavascriptTransforme rException:
CHANNEL: PDF to Client
CONNECTOR: Destination 1
SCRIPT SOURCE:
SOURCE CODE:
39: }
40: eval('importPackage(' + Packages.java.lang.Class.forName(className).getPac kage().getName() + ')');
41: }
42: }
43: function doScript() {
44: msg = new XML(connectorMessage.getTransformedData());
45: if (msg.namespace('') != undefined) { default xml namespace = msg.namespace(''); } else { default xml namespace = ''; }
46: tmp = new XML(template);
47: function doFilter() { phase[0] = 'filter'; return true; }function doTransform() { phase[0] = 'transformer'; logger = Packages.org.apache.log4j.Logger.getLogger(phase[0]);
48:
LINE NUMBER: 44
DETAILS: TypeError: Element type "dWNlciAo" must be followed by either attribute specifications, ">" or "/>".
at e1392bda-28d4-4338-aa16-8e029c8b8be4:44 (doScript)
at e1392bda-28d4-4338-aa16-8e029c8b8be4:73
at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.doCall(JavaS criptFilterTransformer.java:154)
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
  #2  
Old 08-09-2016, 07:29 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,119
narupley is on a distinguished road
Default

If that embedded Base64 has only line feeds in it (0x0A) then that's fine. You can disable "Convert Line Breaks" in the inbound HL7 v2.x serialization settings, so that newlines aren't normalized to carriage returns.

If that embedded Base64 has both line feeds and carriage returns in it (CRLFs), then you have an invalid HL7 message. You need to go back to the source and tell them to stop sending you invalid data. The problem is that now you've made the message ambiguous, since carriage returns are meant to delimit new segments. You could check for any line that has 3 alphanumeric characters followed by the field separator (e.g. "|"), and remove line breaks from any other line that doesn't fit that criteria.

You also may want to consider using an attachment handler if you're receiving embedded PDFs. You can use a Regex attachment handler, and tweak the regular expression so it captures CRLFs as well. That way you won't have to deal with anything in the preprocessor.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #3  
Old 08-09-2016, 07:35 AM
derickmiller derickmiller is offline
Mirth Newb
 
Join Date: Mar 2015
Posts: 18
derickmiller is on a distinguished road
Default

Thanks Narupley. How would I go about checking for any line that has 3 alphanumeric characters followed by the field separator (e.g. "|"), and remove line breaks from any other line that doesn't fit that criteria. I am assuming some type of transformer on the source, but I am unsure how to write this. Any help is appreciated
.
Reply With Quote
  #4  
Old 08-09-2016, 07:48 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,119
narupley is on a distinguished road
Default

You would want to use a preprocessor script to do that. You have access to "message" which is the raw inbound message string. Whatever you return is processed through the channel.

I'd recommend using the regex attachment handler. You can tweak the regular expression so it will capture line breaks as well:

Code:
(?:OBX\|(?:[^|]*\|){4}(?:[^|^]*\^){4})([^|^]*?)(?:(?:\r\n|\r|\n)\w{3}\||[|^]|$)
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #5  
Old 08-09-2016, 08:54 AM
derickmiller derickmiller is offline
Mirth Newb
 
Join Date: Mar 2015
Posts: 18
derickmiller is on a distinguished road
Default

Thanks I went with a preprocessor script and was able to resolve the issue.
Reply With Quote
Reply

Tags
encoded, obx

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 09:53 AM.


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