web stats
Whitespace Issue - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 03-03-2011, 11:14 AM
upstart33 upstart33 is offline
Mirth Guru
 
Join Date: Dec 2010
Location: Chicago, IL.
Posts: 459
upstart33 is on a distinguished road
Default Whitespace Issue

I have a SQL Source Connector that executes a stored Procedure.

I then have a Source Transformer that uses Javascript to loop through and create all of the PID, OBR, OBX, etc. segments on the fly.

Everything works fine, but the message that is being sent contains alot of whitespace between values...almost as if Mirth is creating a set length on the fields even if they are not used all the way up (see below
Code:
MSH|^~\&|DYNA|MIS|DCI|ADS|201103031404||ORU^R01|00000000000000784356|P|2.2
PID|||555555  ||DAVIS          ^JOHNNY         ^TP             ||19200918|F|||140447 Main St           ^                         ^NEW BRUNSWICK     ^NJ^08901    ||||||||
OBR|1||390000131953||||200606060000|||||||||A555      ^DOCTOR        ^555-555-5555|||||||||F||1^^^201103031404^^
OBX|1|NM|2498-4              ^Iron SerPl-mCnc                                   |788 |41                  |MCG/DL  |30.0-160.0                    |H|||
Does anyone know how to trim the whitespaces or does it matter?
I tried using the following in the Pre-Processing script, but to no avail.
Code:
message = message.replace(/(^\s*)|(\s*$)/gi,"");
message = message.replace(/[ ]{2,}/gi," ");
message = message.replace(/\n /,"\n");
return message;
Would I have to use some sort of Javascript Trim-like function in the transformer?
Reply With Quote
  #2  
Old 03-04-2011, 10:04 AM
apatwa apatwa is offline
OBX.2 Kenobi
 
Join Date: May 2010
Location: Nashville, TN
Posts: 94
apatwa is on a distinguished road
Default

This has worked for me:
message = message.toString().replace(/\s+/g, ' ');
Reply With Quote
  #3  
Old 03-04-2011, 10:06 AM
dans dans is offline
Mirth Employee
 
Join Date: Apr 2007
Location: Irvine, CA
Posts: 590
dans is an unknown quantity at this point
Default

The database you are reading from is probably padding the fields to a fixed length (maybe using CHAR datatype type instead of VARCHAR??). I would trim each field when selecting from the database. Mirth is definitely NOT padding the fields.

If you want to use trim() I believe java String has it:
Code:
message = new java.lang.String(message).trim();
__________________
Daniel Svanstedt
Software Engineer
Mirth Corporation

Want professional services, support, and enterprise or virtual appliances? It's all available from the Mirth Corporation:
Mirth Support | Mirth Training | Mirth Appliances | Online Training | Developer Q&A

Don't forget, Mirth Support gives you access to all of our online training videos, and silver support gives you access to developer Q&As!
Reply With Quote
  #4  
Old 03-04-2011, 11:20 AM
upstart33 upstart33 is offline
Mirth Guru
 
Join Date: Dec 2010
Location: Chicago, IL.
Posts: 459
upstart33 is on a distinguished road
Default

Thanks @apatw and @dan. I try both those codes. Should I put them in the Post-Processor script section?
Reply With Quote
  #5  
Old 03-30-2011, 09:00 PM
dchibaya dchibaya is offline
Mirth Newb
 
Join Date: Dec 2009
Posts: 17
dchibaya is on a distinguished road
Default

have you considered trimming the whitespace at the SQL select level? Whats your backend DB?
Reply With Quote
  #6  
Old 03-31-2011, 12:37 AM
porista porista is offline
What's HL7?
 
Join Date: Mar 2011
Location: London
Posts: 1
porista is on a distinguished road
Default

interesting information!!! thank you!!!
__________________
If I have variegated posers with doing of elusive scientific narration, I widely locate popular extraordinary collaboration. I often locate college papers underground, which are flooded with attractive perspectives and new depictions of primary plant. I usually quicken this beneficial furtherance to my callow friends, who specifically are surely fiddly in creating of sticky operates.
Reply With Quote
  #7  
Old 05-25-2011, 08:29 AM
praveenkathait praveenkathait is offline
Mirth Newb
 
Join Date: Jun 2008
Posts: 8
praveenkathait
Default Thanks

This has worked for me

Message= new java.lang.String(Message).trim();

Thanks a lot
Reply With Quote
  #8  
Old 05-25-2011, 09:47 AM
fransdw fransdw is offline
OBX.1 Kenobi
 
Join Date: Feb 2007
Location: Tallahassee, FL
Posts: 43
fransdw is an unknown quantity at this point
Send a message via Skype™ to fransdw
Default

I performed the trim at the database level before. RTRIM(LTRIM(FieldName))) worked for my RDBS systems in the stored procedure select statements.

I will have to test some of the other options mentioned here too to know what they do.

Thanks,
Frans
__________________
Frans de Wet
Uber Operations LLC
uberops.com
Phone: (850) 445-7696
Reply With Quote
Reply

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 12:24 PM.


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