Export Converter Script Execution

  • Hi,


    I have two ExportConverters one at series level while the other is study level:


    Code
    ExportConverters = 2
    ExportConverter0 = process series after 10 by F:\myApp\processSeries.bat "%d" "%u" "%i" "%V0020,000E" "%V0020,000D" "%V0008,0060" "%V0008,103E" "%V0018,1030"
    ExportConverter1 = process study after 15 by F:\myApp\processStudy.bat "%u" "%i" "%V0020,000D" "%V0010,0010"

    processSeries.bat writes the series into a text file.


    processStudy.bat calls a Nodejs script with the study arguments.

    The above scripts work fine and they do the operations as intended 95% of the time.

    ISSUE:
    The below issue has been observed when multiple studies come at the same time to the Conquest Node.
    For example, say two studies come at the same time.

    Code: serverstatus
    22/03/2024 12:47:31 [MYNODE0] Exportconverter0.0: queued process ser - (single object of <Patient1>) to F:\myApp\processSeries.bat <Arguments>
    22/03/2024 12:47:31 [MYNODE0] Exportconverter1.0: queued process stu - (single object of <Patient1>) to F:\myApp\processStudy.bat <Arguments>

    Like the above entry, I see that both the studies have the ExportConverters queued.
    But sometimes, the second Export Converter: ExportConverter1 for one of the study never gets executed as the batch script processStudy.bat (PFA second image) never logs successful execution. There is no error messages from batch script too.

    I am not whether this is a Conquest issue or anything else. But just checking whether you have any idea to debug the execution of ExportConverters properly?

    Any help would be appreciated. Thank you.

  • Hi,


    The (ancient ;->>>) code is in dgate.cpp.


    A string is made containing the converter and selection in function prefetch_queue (at line 12257, called from line 6154). This string is passed into function into_queue_unique. The fact that your log shows both entries means that into_queue_unique returned true, i.e. entering succeeded.


    So likely something goes wrong when processing the queue. The queue is handled by prefetchprocess (line 12195) which calls WinExec() at line 12236.


    What you can do to test is replace your two batch files by two lua files, and see if it fails in the same way. This would exclude a problem in WinExec itself. In lua the parameters are in command_line.


    regards


    Marcel

  • marcelvanherk


    Thanks for the suggestion.

    I tried calling lua script in ExportConverter.

    Code
    ExportConverter0 = process series after 10 by F:\myApp\processSeries.lua "%u" "%i" "%V0020,000E" "%V0020,000D" "%V0008,0060" "%V0008,103E" "%V0018,1030"

    In the lua script, I tried to access the arguments:


    Code
    local sender, patientid, seriesuid, studyuid, modality, seriesdescription, protocol = ...
    print(sender)
    print(patientid)
    print(seriesuid)

    But they are all nil.

    What am I doing wrong? Thanks

  • Hi,


    I typically concatenate the paramaters with a '|' and use a split function to unpack them:


    function split(str, pat)

    local t = {}

    local fpat = "(.-)" .. pat

    local last_end = 1

    local s, e, cap = str:find(fpat, 1)

    while s do

    if s ~= 1 or cap ~= "" then

    table.insert(t,cap)

    end

    last_end = e+1

    s, e, cap = str:find(fpat, last_end)

    end

    if last_end <= #str then

    cap = str:sub(last_end)

    table.insert(t, cap)

    end

    return t

    end


    Marcel

  • marcelvanherk,

    Sorry, probably I wasn't clear with my issue:

    Now, I just have simple ExportConverter0 = process series after 10 by F:\myApp\processSeries.lua "%u" with just one argument.

    However, in the lua script file, I just try to get that argument and print it.

    Neither this

    Code
    local sender = ...
    print(sender)

    Nor this

    Code
    print(args[0])

    Works for me. I am not sure how to unpack the arguments.


    When I look it up, everything points to ... should be the way to unpack. Not sure what am I doing wrong?

  • marcelvanherk

    What you can do to test is replace your two batch files by two lua files, and see if it fails in the same way. This would exclude a problem in WinExec itself. In lua the parameters are in command_line.

    As per suggestion, I replaced the batch files with lua scripts,

    Code
    ExportConverters = 2
    ExportConverter0 = process series after 15 by F:\myApp\processSeries.lua "%u"|"%i"|"%V0020,000E"|"%V0020,000D"|"%V0008,0060"|"%V0008,103E"|"%V0018,1030"
    ExportConverter1 = process study after 30 by F:\myApp\processStudy.lua "%u"|"%i"|"%V0020,000D"|"%V0010,0010"

    There is no issue with the scripts but now the order of their execution is not always the same.
    I expect the ExportConverter0 to be triggered first always and then ExportConverter1 but sometimes ExportConverter1 gets executed before ExportConverter0 (FYI - When I had batch scripts, this order issue never occurred even though the delay was just 5 seconds b/w series and study)
    I even increased the delay between the series and the study to 15 seconds yet the issue persists.

    This issue doesn't happen consistently. Sometimes it executes in order and sometimes it doesn't.
    Not sure how to resolve this! :/

    Any help would be appreciated. Thank you.

  • Hm,


    Ok, well we identified one issue, which seems to be due to WinExec.


    Export converters, however, are asynchoroneous, so they will not keep to a particular order. You could try to run them as importconverters and see what happens.


    Marcel

  • marcelvanherk

    Ah alright which makes it so hard to get my use case right. ImportConverters works fine when a single series comes in.

    Code
    ImportConverters = 2
    ImportConverter0 = process series after 15 by F:\Programming\CORA\myDev\artemis-wspark\processSeries.lua "%u"|"%i"|"%V0020,000E"|"%V0020,000D"|"%V0008,0060"|"%V0008,103E"|"%V0018,1030"
    ImportConverter1 = process study after 30 by F:\Programming\CORA\myDev\artemis-wspark\processStudy.lua "%u"|"%i"|"%V0020,000D"|"%V0010,0010"

    processSeries and processStudy gets called in order when a single series comes in. So no problem.

    But wWhen multiple series' (say 3) come in, the current order is:


    processSeries - for series 1
    processStudy

    processSeries - for series 2

    processSeries - for series 3

    How I would like the order to be is:


    processSeries - for series

    processSeries - for series 2

    processSeries - for series 3

    processStudy


    I am not sure how to achieve my desired order with either ImportConverters or ExportConverters !!!? ||

  • Hm,


    maybe you should not use this mechanism, that is not meant to keep a particular order. You can just use processStudy, and write a simple query to extract all series in that lua file.


    Marcel

  • marcelvanherk

    >> You can just use processStudy, and write a simple query to extract all series in that lua file.

    But the issue with this is that it would retrieve all series belonging to that study. I want only those series which came in at the time before processStudy got triggered!!!

  • Hi,


    something like this. It does not work with an exportconverter though. This (I think) creates a file with all just stored series in a file studyinstanceuif.txt


    [lua]

    Association = local list = {}, list2={}

    ImportConverter99 = list[Data.SeriesInstanceUID]= Data.SeriesInstanceUID; list2[Data.StudyInstanceUID]= Data.StudyInstanceUID

    EndAssociation = local f=io.open(list2[1], 'wt') f:write(table.concat(list, '\n') f:close()


    Marcel

Participate now!

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