Block certain studies from Query

  • Hi


    I debug the Lua script (appended below), i came on following conclusion that after the second IF statement the print is executed but the reject () function doesn't execute. I think that is the reason all the records are returned.


    print("Hello")

    if Data.QueryRetrieveLevel=='STUDY' then

    local a = dbquery("DICOMStudies","Status","StudyInsta","StudyInsta='"..Data.StudyInstanceUID.."'")

    if (#a==0) then destroy() end

    print("Value of A is::"..#a)

    print ("Status value is:: "..a[1][1])

    if (a[1][1]=='B') then print("Block Status") destroy() end

    end



    Output


    [PACS]

    [PACS] UPACS THREAD 2: STARTED AT: Fri Jul 30 15:50:12 2021

    [PACS] Calling Application Title : "RADIANT "

    [PACS] Called Application Title : "PACS "

    [PACS] Application Context : "1.2.840.10008.3.1.1.1", PDU length: 16384

    [PACS] Presentation Context 0 "1.2.840.10008.5.1.4.1.2.2.1" 1

    [PACS] Hello

    [PACS] Value of A is::7

    [PACS] Status value is:: B

    [PACS] Block Status

    [PACS] (StudyRootQuery) search level: STUDY

    [PACS] C-Find (StudyRoot) located 0 records

    [PACS] UPACS THREAD 2: ENDED AT: Fri Jul 30 15:50:12 2021

    [PACS] UPACS THREAD 2: TOTAL RUNNING TIME: 0 SECONDS


    Now i have some scan with status A and some with B. But the above script shows all scans or no scans (in some cases). The script doesn't loop through the fetched records. It reads only one first record (that can be first, last or middle one) and on status of that executes the second IF.


    I think (might be i am wrong) the if statements are not executed for each fetched records.... Is there some sort of loop which checks and then throw the result???

  • robert , I tried with your suggestion( change QueryConverter to QueryResultConverter). Now the script doesn't execute this command (if Data.QueryRetrieveLevel=='STUDY'). If i comment this it works but all records/studies result are viewed.


    Can somebody tell me how can i read the private tag (0x9999,0x9003 status 16 SQL_C_CHAR DT_STR) in my lua.


    I had tried local status =Data['9999,9002']. and local status =Data.Status. Both prints Nil Result.


    This is the modified version of the script


    local a = dbquery("DICOMStudies","Status","StudyInsta","StudyInsta='"..Data.StudyInstanceUID.."'")

    print ("Status value is:: "..a[1][1])

    if (a[1][1]=='B') then print("Block Status") reject() print("After Reject") end



    Output


    [PACS] UPACS THREAD 3: STARTED AT: Fri Jul 30 19:54:18 2021

    [PACS] Calling Application Title : "RADIANT "

    [PACS] Called Application Title : "PACS "

    [PACS] Application Context : "1.2.840.10008.3.1.1.1", PDU length: 16384

    [PACS] Presentation Context 0 "1.2.840.10008.5.1.4.1.2.2.1" 1

    [PACS] (StudyRootQuery) search level: STUDY

    [PACS] Hello

    [PACS] Status value is:: A

    [PACS] Hello

    [PACS] Status value is:: B

    [PACS] Block Status

    [PACS] After Reject .................................................. It doesn't reject this record but executes it.Can somebody guide how to skip this in the query result

    [PACS] Hello

    [PACS] Status value is:: A

    [PACS] Hello

    [PACS] Status value is:: A

    [PACS] Hello

    [PACS] Status value is:: A

    [PACS] Hello

    [PACS] Status value is:: A

    [PACS] Hello

    [PACS] Status value is:: A

    [PACS] C-Find (StudyRoot) located 7 records

    [PACS] UPACS THREAD 3: ENDED AT: Fri Jul 30 19:54:18 2021

    [PACS] UPACS THREAD 3: TOTAL RUNNING TIME: 0 SECONDS

  • Thanks Robert for your help.


    You can query for anything. But queryResultConverter only has stuff in its Data that you queried for, so if you want to process Data['9999,9002'], say:


    [lua]

    QueryConverter0 = Data['9999,9002']=''

    QueryResultConverter0 = if Data['9999,9002']=='A' then reject() end


    Assuming 9999,9002 is in the database.


    Marcel

Participate now!

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