web stats
how to create an unique filename per poll run? - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 04-04-2013, 07:31 AM
Jurjan Jurjan is offline
OBX.1 Kenobi
 
Join Date: Feb 2011
Posts: 37
Jurjan is on a distinguished road
Question how to create an unique filename per poll run?

Hi fellow Mirthlings.

What I would like to do is the following:
Every 15 minutes a channel starts.
This reads a database table (only records changed since the last polling 'run').
This run can take up to about 10 minutes.
I need to write an interface file (one) with every record in it.
This means I have to put append in my destination filewriter.
Up to here I get it, and it works as expected.

What I can't find is the following:
How can I create a unique filename for that run?
The timestamp/formatted date/unique id mappings etc. are per record I retrieve from the database (as far as I know).
Even if I just take the hour from the formatted date I can't guarantee that I will only ever write one file per polling run.

As you no doubt have guessed: I'm a newby.
I've searched the forums and the internet in general, but perhaps without the right keywords as I couldn't find an answer.

Can any of you help / point me in the right direction?
Thanks.
Jurjan
Reply With Quote
  #2  
Old 04-04-2013, 09:20 AM
randyl randyl is offline
OBX.1 Kenobi
 
Join Date: Jun 2012
Location: Oregon Country
Posts: 31
randyl is on a distinguished road
Default

There are some built in variables you can use to help create unique filenames.

For one lab interface I have going into Centricity EMR's LinkLogic I use the following: ${patientID}_${lastName}_${firstName}_${orderNumbe r}_${date.get("yyyyMMdd-HHmmssSS")}_${COUNT}_RAD.HT

This helps the LinkLogic manager read the filenames easily when resolving errors and also keeps filenames unique so they don't walk over each other.

The key pieces I use to make the name unique are the date function with the count. ${date.get("yyyyMMdd-HHmmssSS")}_${COUNT}.

Note that every time you re-publish the channel it will reset the count. Since you only run this every 15 minutes you probably don't need a counter on your files. The date-time stamp down to the hundredths of a second should be sufficient.
__________________
Mirth Connect 2.2.1.5861
Reply With Quote
  #3  
Old 04-04-2013, 11:40 PM
Jurjan Jurjan is offline
OBX.1 Kenobi
 
Join Date: Feb 2011
Posts: 37
Jurjan is on a distinguished road
Default

Randyl,
thanks for your response, however, i can make the files unique easily enough (as you pointed out).
As far as I know / tested, your solutions create an unique (enough) filename for each record found in the source database reader through the output filewriter.
what we need is for all 10.000 records (say) in the source database reader resultset to go to the same file.
BUT the next batch (15 min's later) needs to go to a different file.

Thanks for taking the time to help out though.

Jurjan
Reply With Quote
  #4  
Old 04-05-2013, 06:13 AM
sandersmr sandersmr is offline
OBX.2 Kenobi
 
Join Date: Feb 2013
Posts: 71
sandersmr is on a distinguished road
Default

Well, I had an idea about using the preprocessor step, but I'm not sure if that would kick off for each record returned or just once. Plus, it seems that versions 2.* don't let you access mappings in the preprocessor.

Have you considered using a Javascript Reader instead of a Database Reader and building your XML message structure from there?

Another potential option is to create your variable in the SQL statement (e.g. create a field that keeps a timestamp that all records would have).
Reply With Quote
  #5  
Old 04-05-2013, 07:33 AM
Jurjan Jurjan is offline
OBX.1 Kenobi
 
Join Date: Feb 2011
Posts: 37
Jurjan is on a distinguished road
Default

Sandersmr,
Yeah, as far as I can tell the preprocessor run per record (that's why it returns message).

So no luck there.

I think I'll have to go the Javascript way, it's less easy for others in our organisation to use, but I'll probably have to go that way anyhow, since I've got invalid XML characters in my data as well.
And the Database Reader makes XML from the data (it even sets the data type for the inbound data source to XML, even if you've defined it as delimited).

I'll try the Javascript and get back if that works.

Thanks,
Jurjan
Reply With Quote
  #6  
Old 04-06-2013, 01:26 PM
mourisj mourisj is offline
Mirth Guru
 
Join Date: Feb 2007
Location: Luxembourg
Posts: 407
mourisj is an unknown quantity at this point
Default

I'm not sure right now about the preprocessor thing, I'd have to give it a try. You can put values on the globalChannelMap or on the globalMap in your preprocessor step.

Another suggestion from me: in the query on your database, you add a field "sysdate" like so:

select sysdate, pid, name, firstname
from yourtable
where ...

AFAIK, this should give you the same value in every row in your query; you format it as you like / as required, and there you have your single identifier per poll.

HTH
__________________
JJ Mouris
FFE Luxembourg
IT-Department

Last edited by mourisj; 04-06-2013 at 01:29 PM.
Reply With Quote
  #7  
Old 04-07-2013, 11:33 PM
Jurjan Jurjan is offline
OBX.1 Kenobi
 
Join Date: Feb 2011
Posts: 37
Jurjan is on a distinguished road
Default

mourisj,
yeah, that should work.

thanks.
however, because of the illegal XML characters,I'll probably have to switch to Javascript anyway.

Jurjan

Last edited by Jurjan; 04-09-2013 at 07:37 AM. Reason: typo (hoewver instead of however)
Reply With Quote
Reply

Tags
file writer, polling, unique

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 08:06 AM.


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