Multiple WatchFolders for routing?

  • Is it possible to create more than one Watchfolder? I've found the watchfolder along with auto-forwarding rules extremely helpful, but it seems I need to create a new instance for each folder/destination that I'd like to work with. I guess my request goes beyond multiple Watchfolders, I may also need a way to differentiate between them in my ExportConverter rules (Ie could I use something like ExportConverter0 = ifequal "%p, "c:\destination1\"; forward to destination1)


    * To those who may have found this via a search for "watchfolder", here are some notes on how I got it working:
    1 - When defining the WatchFolder in the dicom.ini you need to use a \ at the end of the path - WatchFolder = C:\pathto\watchfolder\
    2 - In order to use import and export rules on watchfolders one must enable the ImportExportDragAndDrop function in dicom.ini (change from 0 to 1).

  • You'll have to excuse my lack of understanding how LUA works.


    Here's what I've done:
    I created a file in the c:\dicomserver\lua directory named watchfolder.lua - contents were the code you sent - ImportConverter0 = print('Is there a file dropped?', Filename)
    I then added the following to dicom.ini

    Code
    ImportConverter0 = watchfolder.lua
    ExportConverter0 = watchfolder.lua


    The following is from the server status tab (with debug enabled):
    [C60577] *** Importconverter0.0 error: watchfolder.lua
    [C60577] FreeStore Left 824785 on C:\
    [C60577] Added file: C:\dicomserver\data\11111111\1.2.276.0.7230010.3.1.3.2745455252.10072.1332446330.240_0000_000000_13881774240000.dcm
    [C60577] ***Exportconverter0: Spawning 'watchfolder.lua' failed (argv=C:\dicomserver\data\11111111\1.2.276.0.7230010.3.1.3.2745455252.10072.1332446330.240_0000_000000_13881774240000.dcm)


    I'm not entirely sure what to try next - can you point me in the direction of where the code you sent was intended to go - I'm assuming it should either create a pop-up that gives me the filename - or add the file name to the log.
    Thanks Again!
    Joel

  • so I played just a tiny bit more - it seemed that no matter what filename i put, it didnt' find my lua file. I moved my lua file to c:\dicomserver and it seems to like it there. I also figured out that I had to remove the importconverter part inside of the lua file. I'm now getting "[C60577] Is there a file dropped? C:\dicomserver\watchfolder\Homer.dcm" in my logging window.


    I'll have to dig through the documentation to actually figure out how to get just the folder name, and also how to act upon that. I'll play and document what I find.


    Also blank folders are being wiped out inside of the watchfolder. Is there a way to make it leave the folder structure alone?
    Thanks,
    Joel

  • I got a bit of time to look into this a bit further today. The trick of putting a read only file into each subfolder works well. I researched lua code a bit and found that I don't have to parse the string because lua has a match function. The following code doesn't yet actually forward studies anywhere, but it does successfully identify between subfolders "Folder1" and "Folder2" under my watchfolder. To add more subfolders I'd simply need to add more Elseif lines.

    Code
    if Filename:match "watchfoldername.Folder1" then
    print ('matches Folder1 - ', Filename)
    elseif Filename:match "watchfoldername.Folder2" then
    print ('matches Folder2', Filename)
    end


    The path in the sample above is "watchfoldername.Folder2" If your directory is C:\WatchME\SubFolderName you'd search for "WatchMe.SubFolderName" I couldn't figure out how to match special characters, so I dropped the c:\ and put a wildcard (.) in for the \ character. I'm sure there is a more exact way to match these - but finding the syntax for special characters in LUA has proven a bit difficult. In any case, searching this way results in not finding files whose filename happens to match the directory name (ie - I named a file folder1.dcm and it didn't mess up the matching logic)

  • It took me a bit to figure out how to actually send the DICOM file from inside the lua script. I initially expected to just add "forward to AETITLE" to the .lua code, but that does not work. In order to pass the command back to conquest you must print(script('conquestcodehere')). My final looks very similar to my original code above:

    Code
    if Filename:match "watchfolder.ToPACS" then
    print ('matches ToPACS', Filename)
    print(script('forward to PACS'))


    I have c:\watchfolder set up, with a sub directory of ToPACS. When a DICOM file is dropped in the "c:\watchfolder\ToPACS" folder my lua code is run. The first line of code (the if statement) looks for a match. The second line of code displays information about which subfolder the file matched (I currently have 8 sub-directories, so this is just for informational/troubleshooting purposes - information is displayed in the "server status" tab as well as the log file). The last line basically just passes "forward to PACS" back to conquest to do the actual work of doing the DICOM transfer. (this can accomplish more than just forwarding files if you do ConquestTask1;ConquestTask2;etc). As in the first example, you can do multiple levels with elseif statements, and the if loop needs closed out with an 'end'.


    All-in-all I'm thrilled that I've been able to get this working. The results of using conquest are much more robust and faster than I've previously been able to accomplish using .bat files and the DCMTK/GDCM command line DICOM tools. As an even better bonus the always live watchfolder directory will allow me to let other staff from our radiology support group do some of the tasks that were previously too technical to pass on to others. Many thanks to Marcel for making such a great solution freely available!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!