web stats
Newbie Help with Replacing - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 05-22-2012, 10:55 AM
ramblix ramblix is offline
What's HL7?
 
Join Date: Sep 2010
Posts: 5
ramblix is on a distinguished road
Question Newbie Help with Replacing

Hello All,

I am guessing there is a easy script for this but I'm not sure how the best way to do it is. I need to replace the '\S\' with '^'. And these order files will have multiple OBR's & ORC's. I have put the samples below

Before:

OBR|1|184559-5||CPT-85025^CBC with Differential|||20120406||1||N|||||1922000000\S\Joh n\S\Smith\S\S.|||||||||||^^^^^R
ORC|NW|184559-6|||||||20120406|||1922000000\S\John\S\Smith\S\S.

After:


OBR|1|184559-5||CPT-85025^CBC with Differential|||20120406||1||N|||||1922000000^John^ Smith^S.|||||||||||^^^^^R
ORC|NW|184559-6|||||||20120406|||1922000000^John^Smith^S.

This forum has been AWESOME for me so far so Thanks in advance

Shareef Huddle

Last edited by ramblix; 05-22-2012 at 10:57 AM.
Reply With Quote
  #2  
Old 05-22-2012, 11:04 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,360
cory_cole is on a distinguished road
Default

newString = Oldstr.replace('\\S','^'); //you need the \\ because the \ is the escape sequence and you need it as a literal. You may also need the '\^'
Reply With Quote
  #3  
Old 05-22-2012, 11:05 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

You could do this in the preprocessor and simply replace all the escape sequences with literal carets, but obviously that would throw all any subsequent component parsing.

If you're writing to a database and creating map variables to that end, you could just add a .replace(/\\S\\/g,'^') to the end of your mappings.

If you're writing the entire message out with a File Writer, you can do this at the end of your transformer:

Code:
$co('encodedMessage',SerializerFactory.getHL7Serializer().fromXML(msg).replaceAll('\\\\S\\\\','^'));
Then, just put ${encodedMessage} in your destination template.
Reply With Quote
  #4  
Old 05-22-2012, 11:37 AM
ramblix ramblix is offline
What's HL7?
 
Join Date: Sep 2010
Posts: 5
ramblix is on a distinguished road
Default

narupley,

I'm not sure I understand what you mean. Is this a new step to my current transform and if so what type (java, mapper, etc...)? Currently I only have a javascript that is doing something else for me. Do I create a new one or is this something I can put in my current javascript step.

I know, I know, "What a NEWB!"

And do I add the "${encodedMessage}" in the template or do I replace my current "${message.encodedData}"

Also this is a file writer.

Thank you

Shareef
Reply With Quote
  #5  
Old 05-22-2012, 11:40 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

You can place the connector map variable code in a new JavaScript step, or at the end of your current JavaScript step. Then yep, just replace your destination template with the map variable reference.

NOTE: I serialized msg and placed it in the connector map. If you're using an outbound template, then replace that with tmp.
Reply With Quote
  #6  
Old 05-22-2012, 11:51 AM
ramblix ramblix is offline
What's HL7?
 
Join Date: Sep 2010
Posts: 5
ramblix is on a distinguished road
Default

Cory,

When I put that in a script I get an error:

ReferenceError: "Oldstr" is not defined.
Reply With Quote
  #7  
Old 05-23-2012, 05:50 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,360
cory_cole is on a distinguished road
Default

oldStr is the original string. You need use what ever string has...

OBR|1|184559-5||CPT-85025^CBC with Differential|||20120406||1||N|||||1922000000\S\Joh n\S\Smith\S\S.|||||||||||^^^^^R
ORC|NW|184559-6|||||||20120406|||1922000000\S\John\S\Smith\S\S.
Reply With Quote
Reply

Tags
obr, orc, replace

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


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