Dicomquery and result array

  • Hi,


    I 'd like some informations about how to use dicomquery.
    I have searching on forums, manual and samples and I don´t found a detailed information to use it.
    However, I found some samples.

    I have the next dicom query:

    Code
    b=newdicomobject(); b.QueryRetrieveLevel='STUDY' b.StudyModality= '' b.StudyInstanceUID='' b.PatientID='' b.PatientName='*RENATO*' b.StudyDate = '' b.StudyDescription='' patis=dicomquery(s, 'STUDY', b);


    When I loop around "patis", I see all my StudyModality = nil. Others fields are ok and have values differents from nil.
    Why StudyModality is nil, if I have values filled in this field in table DicomStudies.
    Am I doing something wrong?



    When I loop around "images", I see all my SliceLocation = nil. Others fields are ok and have values differents from nil.
    Why SliceLocation is nil, if I have values filled in this field in table Image table.



    My questions:


    1. Why StudyModality is nil on first query and SliceLocation is nil on 2nd query?


    2. What is the purpose QueryRetrieveLevel?
    if Dicomquery has a parameter to LEVEL, then why do I need setting it?


    3. What fields do I have on result of dicomquery? Can I choice which fields return from dicomquery result?


    4. What is difference in use b.PatientID='' or b.PatientID='*' ? Sometimes I have to use '*' and othertimes I have to use '' to show results.


    5. If I need more field informations from Patient Level, do I have to execute an other dicomquery or I can use only one?


    Thanks in Advance,
    Luiz

  • Hi Luiz,


    The behavior is the same as any DICOM query.


    1) a field is not returned if you ask for it but the server does not support it. It may also be absent from the dictionary (dgate.dic), if so it is not asked for correctly.


    2) it is superfluous but needed, just set it to the same value.


    3) anything that you ask by passing e.g. b.PatientID=''


    4) What is difference in use b.PatientID='' orb.PatientID='*' ? No real difference in effect but '' fields are not queried just retrieved so they are more efficient.


    5) You can query from the selected level up, e.g. a SERIES query also returns all STUDY and PATIENT info


    Marcel

  • Mr Marcel,


    Thanks for your response.


    I need retrieve SliceLocation from image to use to show the image.
    You retrieve this value with default wado web server of conquest. I am doing my web server based on your version.


    My dgate.dic has:
    (0020,1041) VERS="3" VR="DS" VM="1" Keyword="SliceLocation"


    I am using the next query and the value of SliceLocation is allways nil.


    b=newdicomobject();
    b.QueryRetrieveLevel='IMAGE'
    b.PatientID = pid
    b.SeriesInstanceUID = siuid
    b.SOPInstanceUID = '';
    b.ImageNumber = '';
    b.SliceLocation = '';
    b.PatientName=''
    b.ImageDate=''

    images=dicomquery(s, 'IMAGE', b);


    Loop on images shows SliceLocation = nil.


    Please, could you tell me how to do it?


    Regards,
    Luiz

  • Hi,


    Code
    a=DicomObject:new()a.QueryRetrieveLevel='IMAGE'a.StudyInstanceUID=''a.SliceLocation = ''a.StudyDate='20010101-20130404'b=dicomquery('CONQUESTSRV1', 'IMAGE', a)for i=0, #b-1 do print(b[i].SliceLocation)end


    prints



    I would suggest to install zerobrane studio to allow debugging your scripts. I do not see an error in your script though, it returns slice location for me. Some objects do not store it though. Have you looked in the database browser to see it is there?


    Marcel

  • Mr Marcel,


    I found my problem. Thank you. The code was correct. The values were empties and I thought they were wrong.


    When I finish my work I I intend post all web server lua scripts as reference to newbies( including me). I will do, If you agree.
    I don´t know if you have a files repository on site.


    I'm moving faster now after your help, but not always a bed of roses , mainly for a newbie.


    Can you help me with the next cases?


    1. First Case:
    I have SOPInstanceUID and other fields of a image.

    With these data, How do I can retrieve the parameter "lw" (level/window) of the image for use in this line:


    print("<IMG SRC=dgate%s?%s&mode=slice&slice=%s&size=%s&graphic=%s&lw=%s HEIGHT=%s>", ex, extra, slice, dsize, graphic, lw, size);


    I did the next function, but I have always nil on results and I don´t know if the return values would be the correct to use with the code above.


    function get_lw(n,siuid)
    local b,s,a
    s = servercommand('get_param:MyACRNema')
    b=newdicomobject();
    b.QueryRetrieveLevel='IMAGE'
    b['0028,1050']=''
    b['0028,1051']=''
    b.SOPInstanceUID = siuid
    b.ImageNumber = n;
    b.PatientName ='';
    a=dicomquery(s, 'IMAGE', b);
    return a[0]['0028,1050'], a[0]['0028,1051']
    end


    2. Second Case:
    I am also trying getting the header info from image to show in web browse. Searching on files sample and manual, I have tried some options with no success.
    I did:


    local ss=CGI("slice") -->PatientID:SOPInstanceUID format.


    1) readdicom(ss)
    print(Data.Dump())
    doesn´t work. I can´t put a file parameter to Dunp because I am doing a page web browse


    2) b = newdicomobject()
    readdicom(b,ss)
    print(b:Dump())
    doesn´t work


    3) s = string.format("dump_header:%s", ss);
    print(servercommand(s));
    doesn´t work


    Regards,
    Luiz

  • Hi Luiz,


    I will post your web server pages with all pleasure.


    1) you can only query those items that are in the database. If not you will have to load the image to get to the values. lw in the original web pages is interpreted from the url but typically not set. So you can ignore that for now.


    2) The easiest is to link to the exising page to show the header dump. This uses a servercommand like (dgate --dumpheader:patientid:sopinstanceuid,cgi)


    servercommand("dump_header:patid:sopuid,cgi") would do the same


    Marcel

  • Mr Marcel,


    Sorry, but it didn't work.


    When I use:
    ss=CGI("slice")
    s = string.format("dump_header:%s, cgi", ss);
    print(servercommand(s));


    The server log is:
    CONQUESTSRV1] 9999,0400 74 LO ConquestConsoleComma "dump_header:54823:1.3.46.670589.30.1.6.1.116520970982.1381927789312.2, cgi"
    [CONQUESTSRV1] Query Tables: DICOMImages
    [CONQUESTSRV1] Columns : ObjectFile, DeviceName
    [CONQUESTSRV1] Where : SOPInstanc = '1.3.46.670589.30.1.6.1.116520970982.1381927789312.2' AND ImagePat = '54823'
    [CONQUESTSRV1] Order : (null)
    [CONQUESTSRV1] Locating file:MAG0 54823\1.3.46.670589.30.1.6.1.116520970982.1381927789375.1_0001_00


    But no result is returning to shows in web browser.
    Am I doing something wrong?


    Regards, Luiz

  • Mr Marcel,


    Sorry, but it didn´t work. No results to browser.
    My code:
    ss=CGI("slice")
    s = string.format("dump_header:%s,cgi", ss);
    HTML("<PRE>");
    HTML(servercommand(s))
    HTML("</PRE>");


    Log:
    [CONQUESTSRV1] 0000,0800 2 US DataSetType 257
    [CONQUESTSRV1] 0002,0010 17 UI TransferSyntaxUID "1.2.840.10008.1.2"
    [CONQUESTSRV1] 9999,0400 74 LO ConquestConsoleComma "dump_header:54823:1.3.46.670589.30.1.6.1.116520970982.1381927789484.2,cgi"
    [CONQUESTSRV1] Query Tables: DICOMImages
    [CONQUESTSRV1] Columns : ObjectFile, DeviceName
    [CONQUESTSRV1] Where : SOPInstanc = '1.3.46.670589.30.1.6.1.116520970982.1381927789484.2' AND ImagePat = '54823'
    [CONQUESTSRV1] Order : (null)
    [CONQUESTSRV1] Locating file:MAG0 54823\1.3.46.670589.30.1.6.1.116520970982.1381927790609.1_0002_000001_13819262550836.dcm



    Regards,
    Luiz

  • Here is the code to display the header in OpenClinica/WadoViewer:


    print([[<a href=# onclick="javascript:PopupCenter(']]..script_name..[[?requestType=WADO]]..bridge..[[&contentType=text/html&studyUID=]]..studyuid..[[&seriesUID=]]..CGI('seriesUID')..[[&objectUID=' + document.forms[0].slice.value + '&dum=.txt', 'hoi', 500, 500)">[original header]</a>]])


    Marcel

  • Mr Marcel,
    Thanks for sample.
    I solve my problem.


    Now, I need help on two things:
    1. I am now translating to Lua the piece of code of patientfinder, studyfinder, ....
    I was searching on manual and I have seen the syntax: patientfinder:srv|str|fmt|file List patients on server
    I look at dgate.cpp and did the translate to lua.
    I have tried many options.
    The log on server shows my code was executed on server. It find records but no returns are showing on webserver.
    Here is my code:

    Code
    command = string.format("patientfinder:%s|%s", dest, query)
    command = command.."|%s"
    HTML(servercommand(command))


    I have noted other commands sent to conquest server via servercommand has no response to web browser.


    Is there some tip to solve the problem?


    2. When I use your sample to download the header of a image, it is done, but I have no way to format the lines. Dgate.cpp use <pre>..</pre>.
    Do you know if exists a workaround to shows the line pre-formatted? It´s too hard look the window without line breaks.


    Regards,
    Luiz

  • Hi Luiz,


    I checked and indeed it does not work for dump_header. My guess is that the texts created by these commands may have odd length and are therefore not transmitted to the web interface. The best way around this problem for now is to explicitly use dbquery and dicomquery to create lists of patients etc. It may also be more readable in the long term compared to using servercommand all the time.


    Marcel

  • Mr Marcel,


    That´s ok.


    I solved the lines breaks and formating problem of the header opening in a new window with the next function:



    Luiz

Participate now!

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