web stats
Carriage Return within Fields - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 02-15-2013, 10:11 PM
seaston seaston is offline
OBX.3 Kenobi
 
Join Date: Feb 2010
Location: London, UK
Posts: 168
seaston is on a distinguished road
Default Carriage Return within Fields

Hello all,

We have a system that occasional sends messages into Mirth Connect with a Carriage Return character actually within a field in the OBX so Connect sees this as a segment seperator.

For example (and I've removed the PID) we get:

Code:
MSH|^~\&|PCS|SCM|HL7PRX||20130215202522||ORM^O01|1002158226110001|D|2.3
ORC|NW|001GRYKHP^PCS|||IP||^^^20130215202400^^Routine||20130215202522|malawson^Lawson^Maureen||MMXL^Lawson^Maureen
RXO|Pharm1456^Outpatient prescription^Local_Pharm||||||||||||0
RXR|OTH
OBX|1|TX|PharmChanges^Summary Information^PCS||Modigraf --> 2mg BD
2- Mycophenolate Mofetil suspension --> 45mg BD
3- Magnesium Glycerrophosphate --> 5mmol BD (not prescribed by GP because it is unlicensed)||||||F
Has anyone got any suggestions as to how to deal with this in Mirth Connect (as we cannot correct it at source)? Would it be something in the preprocessor maybe?
Reply With Quote
  #2  
Old 02-15-2013, 11:07 PM
seaston seaston is offline
OBX.3 Kenobi
 
Join Date: Feb 2010
Location: London, UK
Posts: 168
seaston is on a distinguished road
Default

I think I may have answered my own question.
How about this for a solution?

In the preprocessor script, put the following:

Code:
var newmessage = message;

while (newmessage.match(/(\r\n|\r|\n)([^A-Z]|[A-Z][^A-Z]|[A-Z]{2}[^A-Z\d]|[A-Z]{2}[\d][^|]|[A-Z]{3}[^|])/i)) {
	var extrabit = newmessage.match(/(\r\n|\r|\n)([^A-Z]|[A-Z][^A-Z]|[A-Z]{2}[^A-Z\d]|[A-Z]{2}[\d][^|]|[A-Z]{3}[^|])/i)[0].substring(1);
	var newmessage = newmessage.replace(/(\r\n|\r|\n)([^A-Z]|[A-Z][^A-Z]|[A-Z]{2}[^A-Z\d]|[A-Z]{2}[\d][^|]|[A-Z]{3}[^|])/i,'\\.br\\' + extrabit);
}

return newmessage;
Simon

Last edited by seaston; 02-16-2013 at 02:42 AM.
Reply With Quote
  #3  
Old 04-10-2014, 03:14 PM
ben ben is offline
What's HL7?
 
Join Date: Oct 2013
Posts: 3
ben is on a distinguished road
Default

Thanks!

FYI, I changed the first line to remove trailing carriage return/line feeds to prevent the last line from being converted.

var newmessage = message.replace(/[\n\r]$/,"");
Reply With Quote
Reply

Tags
carriage, field, preprocessor, return

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:59 AM.


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