Block certain studies from Query

  • Hi


    I wanted some studies to be marked as private and no one can access those studies until their status is changed back to public.


    For this purpose, i created a new column in table dicomstudies with the name and datatype as follow:- status varchar (1) and with default value 'A'. The field has 2 values only A = Active or B = Blocked.


    I wanted whenever a query is made to PACS Server user gets studies that are with the status A.


    Please share sample lua script for an idea and do guide me can i query multiple tables in lua , if yes sample script please.


    --HM

  • Ok,


    You can use dbquery to read the study table, and you can use queryconverter0 to script the lua code that calls reject() for those sepecific studies,


    e.g. (untested)


    [lua]

    queryconverter0 = a=dbquery("DICOMStudies", "status", "StudyInst='"..(Data.StudyInstanceUID or 'xx').."'") if a[1][1]=='B' then reject() end


    Marcel

  • Sorry for the late response .


    This is the error :: "[PACS] *** lua run error [string "a=dbquery("DICOMStudies", "StudyStatu","Stu..."]:1: attempt to index global 'a' (a nil value) in 'a=dbquery("DICOMStudies", "StudyStatu","StudyInst='"..(Data.StudyInstanceUID).."'")if a[1][1]=='B' then reject() end;'".


    Please correct me where i am wrong.

  • My dicom.ini is :


    [lua]


    QueryConverter0 = a = dbquery("DICOMStudies", "StudyStatu", "StudyInsta='"..Data.StudyInstanceUID.."'") if a[1][1]=='B' then reject() end;


    This is the error log


    [PACS] UPACS THREAD 1: STARTED AT: Mon Jul 26 13:30:21 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] *** lua run error [string "a = dbquery("DICOMStudies", "StudyStatu", "..."]:1: attempt to index field '?' (a nil value) in 'a = dbquery("DICOMStudies", "StudyStatu", "StudyInsta='"..Data.StudyInstanceUID.."'") if a[1][1]=='B' then reject() end;'

    [PACS] (StudyRootQuery) search level: STUDY

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

    [PACS] UPACS THREAD 1: ENDED AT: Mon Jul 26 13:30:21 2021

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



    Beside above, i tried to use this but no success:


    QueryConverter0 = if (Data["9999,9003"]=='B' ) script('destroy') end;


    Please guide

  • The first script is giving me error and shows all the records.


    dicom.ini file

    [lua]

    QueryConverter0 = a = dbquery("DICOMStudies", "StudyStatu", "StudyInsta='"..Data.StudyInstanceUID.."'") if a[1][1]=='B' then reject() end;


    server log


    [PACS] UPACS THREAD 22: STARTED AT: Mon Jul 26 18:05:03 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] *** lua run error [string "a = dbquery("DICOMStudies", "StudyStatu", "..."]:1: attempt to index field '?' (a nil value) in 'a = dbquery("DICOMStudies", "StudyStatu", "StudyInsta='"..Data.StudyInstanceUID.."'") if a[1][1]=='B' then reject() end;'

    [PACS] (StudyRootQuery) search level: STUDY

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

    [PACS] UPACS THREAD 22: ENDED AT: Mon Jul 26 18:05:03 2021

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

  • Same error :[PACS] *** lua run error [string "a = dbquery("DICOMStudies", "StudyStatu", "..."]:1: attempt to index field '?' (a nil value) in 'a = dbquery("DICOMStudies", "StudyStatu", "StudyInsta='"..Data.StudyInstanceUID.."'") if a[1][1]=='B' then reject() end;'


    I then use the following lua code


    if Data.QueryRetrieveLevel=='STUDY' then

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

    if #a==0 then reject() end

    if a[1][2]=='B' then reject() end

    end


    [lua]


    Association=print("Hello")


    QueryConverter0 = dofile('test.lua')


    The script worked once. But after restart of the server, its not working as desired.;(;(;(

  • Hi Marcel


    I did some debugging with my lua script and found that StudyInstanceUID is not printing. This is my server log


    [PACS]

    [PACS] UPACS THREAD 35: STARTED AT: Wed Jul 28 14:26:37 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] (Study instance UID should be printed here but its not)

    [PACS] Value of A is::1

    [PACS] Status value is:: B

    [PACS] (Study instance UID should be printed here but its not)

    [PACS] (StudyRootQuery) search level: STUDY

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

    [PACS] UPACS THREAD 35: ENDED AT: Wed Jul 28 14:26:37 2021

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


    my lua script is


    print("Hello")

    print (Data.StudyInstanceUID)

    if Data.QueryRetrieveLevel=='STUDY' then

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

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

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

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

    if (a[1][1]=="B") then print(Data.StudyInstanceUID) end

    end

  • That's the reason StudyInstance UID is not populated as i am making a wild query on the server. BUt my question remains the same WHY DID THE CODE EXECUTED FOR 4 HOURS???


    If there any temp or cache that PACS Server maintains?? Reason is i had deleted a lua file that is associated with filename syntax but the server still save some of the images with defined syntax. I am confused on that.


    Can you guide me on any work around???

  • No cache,


    if you want to filter wild queries you would have to enforce studyUID is included and process QueryResultConverter


    and (unrelated) if you store images already in the database, these will keep the same name.


    Marcel

  • Not directly, if you query


    StudyInstanceUID = ''


    then this means you need to filter all results, because some returned studies will be allowed and others not.


    While if you query e.g.


    StudyInstanceUID = '1.2.3'


    Then it returns 0 or 1 studies and you can filter the query. I.e., it is a bit more complesx than you hoped.


    Marcel

Participate now!

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