web stats
How to preprocess an HL7 message? - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 05-26-2011, 05:28 AM
bhsuhansc007 bhsuhansc007 is offline
Mirth Newb
 
Join Date: Jul 2010
Posts: 8
bhsuhansc007 is on a distinguished road
Default How to preprocess an HL7 message?

Hi,

I am receiving an HL7 message on a port using Mirth. I want to extract some of its fields and write to a flat-file.

Now my problem is, I want to split one of its fields into two parts, say on space. E.g. if there is a field called attending doctor name with contents as 'last_name first_name'. I want to split it on the space and write to the output file as two fields separated by comma. I guess I can achieve it using preprocessor script. But I don't know how to use it. I guess I can do this using Java also? How?

Can someone please guide me in this?

Thanks.
Reply With Quote
  #2  
Old 05-27-2011, 04:12 AM
martzin martzin is offline
What's HL7?
 
Join Date: Oct 2009
Posts: 2
martzin is on a distinguished road
Default

Hi,
create Transformer for receiving channel "Channel Task>Edit Transformer>Add New Step"
Change type of new step to JavaScript

Add this code
Code:
var splited = msg['PV1']['PV1.7']['PV1.7.1'].toString().split(" ");

tmp['PV1']['PV1.7']['PV1.7.1']=splited[0]+","+splited[1];

//for testing only:
logger.error(msg['PV1']['PV1.7']['PV1.7.1'].toString());
logger.error(tmp['PV1']['PV1.7']['PV1.7.1'].toString());
logger.error(splited[0]);
logger.error(splited[1]);
Best regards,
Marcin

Last edited by martzin; 05-28-2011 at 03:14 AM.
Reply With Quote
  #3  
Old 05-30-2011, 06:37 PM
ppazos ppazos is offline
OBX.2 Kenobi
 
Join Date: May 2008
Posts: 75
ppazos
Default

Hi,

That's cool with HL7v2.x messages, but, do you know how can I do the same operation on a HL7v3 or XML message?


Thanks,
Pablo.
Reply With Quote
  #4  
Old 05-31-2011, 08:03 AM
bhsuhansc007 bhsuhansc007 is offline
Mirth Newb
 
Join Date: Jul 2010
Posts: 8
bhsuhansc007 is on a distinguished road
Default

Thanks a lot Marcin for your reply. I have few more doubts.

Once I split a field in 2 parts, how do I return the new values? I mean, I did what you said in your previous answer. But I cannot see that particular variable under the 'Available Variables' list. And due to this, I am not able to map that to my 'Template' under the Destination tab. How do I do that?

Thanks.
Reply With Quote
  #5  
Old 05-31-2011, 08:39 AM
bhsuhansc007 bhsuhansc007 is offline
Mirth Newb
 
Join Date: Jul 2010
Posts: 8
bhsuhansc007 is on a distinguished road
Default

I just figured it out. Just add channelMap.put("providerName", splited[0]+","+splited[1]);
Reply With Quote
Reply

Tags
connect, custom, java, preprocessor, script

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 10:01 PM.


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