Query on Study Status

  • Hi


    Firstly, I wanted to make a query on basis of Study Availability (Column with the name STATUS is added in DICOMSTUDIES table with values 'A' or 'I'). If the status is marked 'A' then it should appear in the query result otherwise not.



    Secondly, can you guide me on how can I make a query on a table (querying multiple columns and passing values from the script) using lua script. The script needs to be called at the time of QueryConvertor and RetrieveConvertor.


    A sample script will help for better understanding.


    Regards


    --HM

  • Hi,


    it is relatively simple, e.g.


    a = dbquery("DICOMStudies","PatientID,StudyInsta","PatientID='".."0009703828".."'"); print(a[1][1],a[1][2])

    0009703828 1.2.826.0.1.3680043.2.135.737434.77669398.6.1578840296.329.202


    a returns nil if query failed

    a return a N tables (N records) of tables with 2 entries as specified in the dbquery command.


    Note that single quotes are needed in the SQL where clause, so I use double quotes around them.


    You can try and debug (as I did just now) with console.bat


    Marcel

  • Hi,


    Then you put that code in your converter and access its (query/response) data with e.g. Data.PatientID.

    If the code becomes too long you just put it in a file that you can call with standard lua dofile()


    Marcel

  • QueryConverter0 = dofile('lua/testavail.lua')


    testavail.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]=='I' then reject() end
    end

    reject stops the query from happening. I hope you get the idea.


    Marcel

Participate now!

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