Help with simple LUA script to move files

  • Hello,


    Based on the information on this forum, I put together the following LUA script to copy images for several patients based on a text file of patient id's.



    However, when I run it, I'm getting this error:


    [XYZ] *** lua run error simple.lua:14: attempt to call global 'dicommove' (a nil value) in 'dofile('simple.lua')'


    I'm not especially familiar with LUA, so any help would be appreciated. A similar script to query the server based on patient id seems to work fine. Copying through the Query/Move tab also appears to work, but I would like to set up a script to speed things up.


    Thanks

  • Hi Marcel,


    Thank you for the quick response. I started the script using


    dgate "--lua:dofile('simple.lua')"


    I'm running version 1.4.16 (dicomserver1416.zip from the main page). Not sure which subversion that is, as I'm away from that computer at the moment.

  • Hi,


    you need to upgrade dgate(64).exe. Most of the lua commands were introduced in later updates of 1.4.16. 1.4.17beta is a good choice (very close to release). Working on a nice integration with a debugger as well.


    Marcel

  • Hi Marcel,


    Thank you for the advice. I upgraded to 1.4.17beta, and I no longer get the previous lua error. I'm closer, but still having a little trouble. When I run the script now, I get the message:


    [XYZ] ***dicommove: remote DICOM error


    I realize a remote error is not possible for you to diagnose, and I'm not sure why this is happening. When I use a command like "dgate64 --movepatient:ABC,XYZ,1234" it transfers the patient without issues. Does dicommove behave differently than this command?


    As a different approach, I wrote a batch file to call dgate64 --movepatient. It transfers the files, but I have no way to make it wait until one patient is completely transferred before starting the next.


    Any advice you can offer on the lua script is much appreciated.

  • Hi,


    The syntax of the move command is right, this will instantiate a studyroot move of an entire patient. Maybe there is an invalid entry in your input file?


    This works:


    cmd = newdicomobject()
    cmd.QueryRetrieveLevel = 'PATIENT'
    cmd.PatientID = '0009703828'
    dicommove('CONQUESTSRV1', 'CONQUESTSRV1', cmd);


    Marcel

  • Hi,


    I did find a small bug. It might be that your move should be a patient root move to work for the entire patient (this depends on the DICOM server, it is not necessary for conquest).


    This should be done as follows:


    dicommove('CONQUESTSRV1', 'CONQUESTSRV1', cmd, 1);


    However, the fourth parameter (patientroot flag) is by mistake also used as a callback script, so it provokes error messages. However if you ignore these things works. A made a bug note.


    Marcel

  • Hi Marcel,


    It looks like making it a root move did the trick! The script works okay now. I'm still getting a few remote errors, but they also occur occasionally when copying manually in conquest, and I'm guessing they are due to some peculiarities of the remote server.


    As predicted, I do get a lua error:


    *** lua syntax error [string "1"]:1: unexpected symbol near '1' in '1'


    The error message pops up repeatedly after the initial dicommove command (once every 24 seconds in the log). Not a big deal, but I thought you might like to know.


    Thank you for your assistance and continuing work on this fine program.

Participate now!

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