Sidebar

How can I create sub folders on my destination that do not exist?

0 votes
200 views
asked Mar 26, 2014 by michael-h-5027 (13,450 points)
I want my sub folders to be based on some dateTime or some other HL7 field value but the sub folders do not currently exist.

1 Answer

+1 vote

If you wanted to make a sub folder based on date you could use something similar to this:

var year = qie.formatDate('YYYY', qie.deduceDate(source.getNode('MSH-7')));

var month = qie.formatDate('MM', qie.deduceDate(source.getNode('MSH-7')));

var folder = "" + year + "-" + month;

var fullPath = qie.evaluateTemplate("\\\\ServerName\\Test-ADT\\New folder\\{c:folder}\\");

var fullPathDirectory = new java.io.File(fullPath);

if (!fullPathDirectory.exists()) {

   fullPathDirectory.mkdirs();

}

messageCache.setValue('fullPath', fullPath);

 

 

For the destination node use the following:

{c:fullPath}\*.*

answered Mar 26, 2014 by michael-h-5027 (13,450 points)
edited Mar 26, 2014 by mike-r-7535
commented Mar 10, 2016 by chris-m-8014 (760 points)
I had to modify 2 lines in the above code to make it work.

var fullPath = qie.evaluateTemplate("\\\\ServerName\\Test-ADT\\New folder\\{c:folder}\\");
...became...
var fullPath = qie.evaluateTemplate("\\\\ServerName\\Test-ADT\\New folder\\" + folder + "\\");

and

{c:fullPath}\*.*
...became...
{mc:fullPath}\*.*
...