Execute LUA batch script in dgate

  • Hi,


    Thanks for the LUA updates - it really makes a big difference.


    I am currently using the 1.4.16k version and LUA to auto forward data from our PACS to clients in the clinic (xvi, iview, brachy etc.).


    In cases where we need a large group of patient for a research study, I would like to use Conquest (dgate) to DICOM move the list of patient from the PACS to a research client machine for data processing. We could do this manually in Conquest but it becomes a tedious task to move hundreds or even thousands of patients.


    I was thinking of writing a LUA script for gdate and let the script read a text file containing all the patient IDs and requested modality, and then move the DICOM data from one destination to another.


    Is it possible to execute a LUA script in dgate only once? And is it save for large jobs (batches) - the Conquest Windows manual says "works directly - use with care" on page 44 in appendix 6?

  • Hi,


    The following command starts a lua script:


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


    I use it for scripts with similar tasks as you outlined. The command returns when the script is done or after 5 minutes (when the TCP/IP link between the dgate above and the dgate server breaks). So you have to careful to use it in a batch script. Below is a sample script we used to find patients where the dutch person number was (incorrectly) used as patientID. Not that I print stuff with **** first. This puts it in pacstrouble.log.


    Marcel


  • Ok, thanks for clarifying - I will execute the script manually and only once.


    I wrote the script below but get a dicommove error AFTER the files have been written to the disk! It seems to work just fine but I am a little bit concerned about the reported error. What the script basically does is reading a text file with patient IDs, and for each patient it will fetch the requested modalites on the source server at SERIES level. Each series will then be copied (dicommove) to the destination server.


    The reason that I iterate the series is because the destination server (Mosaiq Oncology PACS - now Data Director) only supports the STUDY QueryRetrieveLevel on dicommove and requires the StudyInstanceUID, and I don't want to send the hole study as it might contain other modalities.


    Code
    -- execute this script by calling: dgate "--lua:dofile('script.lua')"inputFile = 'patient_ids.txt'srcAet = 'MOP_SCP'destAet = 'JONASPC'modalities = {'RTPLAN', 'RTIMAGE'}for line in io.lines(inputFile) do -- send series of the requested modalities from the source to the destination ptId = line for key, modality in ipairs(modalities) do print('Query: patient', ptId, 'on', modality, 'from', srcAet, 'to', destAet) -- create query for dicom move q = newdicomobject() q.PatientID = ptId q.Modality = modality -- values to retrive should be included in the query as well q.StudyInstanceUID = '' -- StudyInstanceUID is required on the MOP for dicommove q.SeriesInstanceUID = '' q.PatientName = '' q.SeriesDescription = '' -- execute query for infomation on patient data on the source machine a = dicomquery(srcAet, 'SERIES', q) -- sets QueryRetrieveLevel at call time n = #a print(' Query results:', n) for i=0,n-1 do r = a[i] print(' - Result ', i+1, 'of', n, '(', a[i].PatientID, '):', a[i].Modality, '-', a[i].SeriesDescription) --print(' - Result ', i+1, 'of', n, '(', r.PatientID, '):', r.Modality, '-', r.StudyInstanceUID) cmd = newdicomobject() cmd.QueryRetrieveLevel = 'STUDY' -- only level supported by the MOP for dicom move cmd.PatientID = ptId cmd.Modality = modality cmd.StudyInstanceUID = r.StudyInstanceUID cmd.SeriesInstanceUID = r.SeriesInstanceUID -- execute the move dicommove(srcAet, destAet, cmd); end endendprint('..script done!')


    And this is the output from conquest (I removed the patient ID)



    All the files are copied and written successfully (5 files in 3 series with RTPLAN and RTIMAGE), but after each line containing TOTAL RUNNING TIME (the dicommove command) it report an error.


    I know it is a tricky question to answer regarding remote dicom errors, but I hope you might be able to help me - and maybe others can reuse the script for inspiration.


    Regards,


    Jonas

  • Hi Jonas,


    this is a great script. Are you using server version 1.4.16K from the forum? The remote DICOM error means the server reports an error at the end of transfer - or maybe it is an error in our dicommove command (I have not seen it though). Can you try to run this script against a conquest server and see if you get the same error?


    Marcel

  • Thanks. I have tested the script as you suggested using three Conquest 1.4.16k servers (source, destination and a third for running the script) on my local computer. It did NOT report any error - great! I assume the error occures in dicommove when communicating with some non-Conquester servers - but I cannot determine if the error is in the Conquest/dgate code or not. I checked the logs on the Mosaiq Data Director (MDD) but there haven't been any dicom error for a long time.


    Can I perform other tests to locate the error?

  • Hi,


    you can use a sniffer like wireshark or test.exe (I believe test -fa is the option) from the dicom library as a dicom forwarder logger to investigate the error. I feel the error occurs after communication ends, so it is not a big problem. I would still like to know what message mosaic sends, maybe it is just misinterpreted by me.


    Marcel

Participate now!

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