Conquest error using makefilename.lua

  • Hello, at the hospital we are using conquest as a backup pacs server, it is really great and I want to congratulate the entire team that works on its development. But I am having a problem, I am trying to generate a specific saving pattern for the files received, and to do this, reading the manual I found that it can be done through a lua script, and as an example it brings makefilename.lua. I have placed this in my dicom.ini file but I get a lua error: return string near <eof>. I clarify that I use the unmodified makefilename.lua and I get the same thing. What I can be doing wrong?:/

  • Hello Marcel, I have tried with the indicated modification (FilenameSyntax = lua:dofile([[makefilename.lua]]) ), but I still get

    *** lua syntax error [string "return dofile([[makefilename.dcm"]:1: unfinished long string near '<eof>' in 'return dofile([[makefilename.dcm'

    I also don't understand what the error description refers to.


  • Hi Juan,

    somehow conquest loses a few characters of FilenameSyntax when it calls it as a script. I will need to find this bug.

    Can you try this for me:

    FilenameSyntax = lua:dofile([[makefilename.lua]])--addedComment


  • Dear Marcel, I tried to do what you asked, but the error is the same and I am not adding any more information.

    *** lua syntax error [string "return dofile([[makefilename.dcm"]:1: unfinished long string near '<eof>' in 'return dofile([[makefilename.dcm'


  • Hi,

    there is a (poorly tested) fix on Github. Just replace dgate64.exe. Note that makefilename.lua script is just an example, it is not robust e.g. if PatientBirthDate does not exist.


  • Hello Marcel,

    first of all, thank you very much for your response and dedication. Could you tell me the link to the modified dgate64.

    I will use the makefilename.lua as a starting point, but my idea is to generate a hash with the jdb2 algorithm in 8-digit base32 to encode the studyuid and the serieuid in order to store it in order:

    studydate/hash_studyuid/hash_serieuid/ imageuid.dcm

    The purpose of this is to be able to have an easy order to locate the studies, and at the same time not have very long directory names as would be the case with the direct use of studyuid and serieuid.

    If you find this interesting and I manage to make it work I can share it with you.

  • Hi,

    The modified executable can be found here:

    The exe is in folder install64.

    Yes your work is of interest. Conquest has an MD5 function in lua that could be used for that purpose. However, it may not be fully correctly implemented, and not match an MD5 made externally. This would not affect its usability as a foldername, once generated, is stored in the database.


  • Dear Marcel,

    Excellent, I will try the new .exe.

    Regarding dbj2 instead of md5, I thought about this algorithm for the simplicity and speed of execution, since there will surely be a lot of images and speed is essential so as not to slow down the process. On the other hand, I thought about encoding it with base32 since it ensures valid names for directories with a good result space of 8 digits that minimize collisions between 2 hashes.

    It would be very nice to integrate the function as you mention. I will do the test and send you the results and code.

  • ok Marcel, while I'm giving you my code in Lua with the aforementioned algorithm, I haven't been able to test it yet because of the error we've been having, but if you see something you want to suggest, I'll gladly accept it.

  • Yes, this looks good.

    Just be aware that StudyDate may be empty, in which case it is ''. If it is missing (which would be invalid but not impossible), it would return as nil.

    The hash function is nice and small and could easily be integrated into the server source code.

    You can already test this code from 'modify image - advanced', which takes lua code e.g print(dofile('makefilename.lua'))

    >> is not in lua, use math.floor(x/32)


  • I have tried to test the code, but I always have an error. I started doing simpler tests and I realized that when using functions within the Lua code I always get the same error. Could it be that functions cannot be used? In fact, the error it gives me has no association with the code, since any code I enter makes no difference.

  • Lua 5.1 has not have an bitwise and but here is an alternative:


    -- avoid negative numbers, e.g. add 65536 to input

    function bitand(a, b)

    a = a+65536

    local result = 0

    local bitval = 1

    while a > 0 and b > 0 do

    if a % 2 == 1 and b % 2 == 1 then -- test the rightmost bits

    result = result + bitval -- set the current bit


    bitval = bitval * 2 -- shift left

    a = math.floor(a/2) -- shift right

    b = math.floor(b/2)


    return result


  • Well after haggling a bit with lua (in C it would have been very easy) :D, I came to the following conclusions:

    -in the test runner (image - modify), neither indentations nor comments are supported in the code in lua.

    -how lua 5.1 uses bit operations are not available. Therefore I was able to put together the code that is already working, creating the And functions and moving beat using multiplication and division.

    The only thing missing is to be able to launch that script with the arrival of each image at the pacs and everything would be resolved.

    Of course, a much better solution would be to integrate this into the C source code, and through some tag to be able to incorporate it directly into the dicom.ini to create the name.

Participate now!

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