web stats
Parse Filename for data fields - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 04-12-2012, 02:50 PM
Noaeill13 Noaeill13 is offline
Mirth Newb
 
Join Date: Apr 2012
Posts: 13
Noaeill13 is on a distinguished road
Default Parse Filename for data fields

I am new to Mirth and am in need of some help. My goal is to create an MDM from a PDF filename.

The filename has the following format LastName_FirstName_MRN_DOB_Date.pdf

I created a source of FileReader to bring in the PDF and a destination of a FileWrite to export an HL7 message file.

What I can't figure out is how to parse the filename into variable so I can build my HL7 message.

Please help...

Last edited by Noaeill13; 04-12-2012 at 04:59 PM.
Reply With Quote
  #2  
Old 04-13-2012, 05:44 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 4,075
narupley is on a distinguished road
Default

If you're using a File Reader, then an "originalFilename" channel map variable will be available to you. Simply reference it with: $('originalFilename')
Reply With Quote
  #3  
Old 04-13-2012, 08:30 AM
Noaeill13 Noaeill13 is offline
Mirth Newb
 
Join Date: Apr 2012
Posts: 13
Noaeill13 is on a distinguished road
Default

I have the transformer with a variable for filename mapping the $('originalFilename'). I can't figure out how to breakdown the filename from there to create variables from the data inbetween the _ in the filename.
Reply With Quote
  #4  
Old 04-13-2012, 09:53 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 4,075
narupley is on a distinguished road
Default

Quote:
Originally Posted by Noaeill13 View Post
I have the transformer with a variable for filename mapping the $('originalFilename'). I can't figure out how to breakdown the filename from there to create variables from the data inbetween the _ in the filename.
This will definitely help:

http://www.hunlock.com/blogs/The_Com...ings_Reference
Reply With Quote
  #5  
Old 04-15-2012, 11:14 AM
mourisj mourisj is offline
Mirth Guru
 
Join Date: Feb 2007
Location: Luxembourg
Posts: 399
mourisj is an unknown quantity at this point
Default

Use the split function to split the filename into an array, then use the items in that array:

Code:
var file_name = $('originalFilename');

var parts = file_name.split('_');

var lastname = parts[0];
var firstname = parts[1];
etc.
__________________
JJ Mouris
FFE Luxembourg
IT-Department
Reply With Quote
  #6  
Old 04-17-2012, 09:09 PM
Noaeill13 Noaeill13 is offline
Mirth Newb
 
Join Date: Apr 2012
Posts: 13
Noaeill13 is on a distinguished road
Default

This is great! I have my script working to parse the name. Thank you both!!!
I have a new problem, getting Mirth to identify the PDF. My source is a FileReader looking for *.PDF files. I am getting the following error...

[2012-04-17 23:01:54,953] FATAL (org.mule.impl.DefaultComponentExceptionStrategy:8 4): The error is: org.mule.MuleException: Error happened while listing files
java.lang.Exception: org.mule.MuleException: Error happened while listing files
at com.mirth.connect.connectors.file.FileMessageRecei ver.poll(FileMessageReceiver.java:124)
at org.mule.providers.PollingMessageReceiver.run(Poll ingMessageReceiver.java:97)
at org.mule.impl.work.WorkerContext.run(WorkerContext .java:290)
at edu.emory.mathcs.backport.java.util.concurrent.Thr eadPoolExecutor.runWorker(ThreadPoolExecutor.java: 1061)
at edu.emory.mathcs.backport.java.util.concurrent.Thr eadPoolExecutor$Worker.run(ThreadPoolExecutor.java :575)
at java.lang.Thread.run(Unknown Source)Caused by: org.mule.MuleException: Error happened while listing files
at com.mirth.connect.connectors.file.filesystems.File Connection.listFiles(FileConnection.java:136)
at com.mirth.connect.connectors.file.FileMessageRecei ver.listFiles(FileMessageReceiver.java:416)
at com.mirth.connect.connectors.file.FileMessageRecei ver.poll(FileMessageReceiver.java:104)
... 5 moreCaused by: java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0*.pdf^
at java.util.regex.Pattern.error(Unknown Source)
at java.util.regex.Pattern.sequence(Unknown Source)
at java.util.regex.Pattern.expr(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.util.regex.Pattern.<init>(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at com.mirth.connect.connectors.file.filters.RegexFil enameFilter.accept(RegexFilenameFilter.java:24)
at java.io.File.listFiles(Unknown Source)
at com.mirth.connect.connectors.file.filesystems.File Connection.listFiles(FileConnection.java:121)
... 7 more
Reply With Quote
  #7  
Old 04-17-2012, 10:31 PM
glenn71 glenn71 is offline
OBX.2 Kenobi
 
Join Date: Nov 2010
Location: Sydney Australia
Posts: 87
glenn71 is on a distinguished road
Default

looks like you have the regex checkbox ticked.. untick it on the file reader.
Reply With Quote
  #8  
Old 12-13-2012, 12:34 PM
sistla88 sistla88 is offline
What's HL7?
 
Join Date: Oct 2011
Posts: 2
sistla88 is on a distinguished road
Default

Hi I have a similar requirement, can you please send the information how you parsed the file name information and constructed the hl7 mdm message. Appreciate all your help.
Reply With Quote
Reply

Tags
filename, hl7, mdm, pdf

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 -7. The time now is 02:38 PM.


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