Create a zip of dicom files for selection of patients

  • Hi Marcel,


    I would like to have one functionality, but I am not sure if it is supported so I rather ask you directly. I would like to provide a users a function where they can select patients which they are interested in and ConQuest will create a zip from the dicom files for selected patients that way that the hierarchy of files keeps the same as it is on the server. Basically the zip will have bunch of subfolders named with patient ids and in each subfolder there will the dicom data.


    Is there a possibility to do this in a lua script? Can you give me a hint what API I need to call to accomplish this. My idea is to have a script which will read patients ids from querystring and that it locates the data on ConQuest, zip them a provide to download.


    I would be grateful if you could point me to the good direction.


    best


    Tomas

  • Hi Tomas,


    with lua you can query the server (samples are in the distribution), and load and save DICOM data or copy files (load the file as a lua string and save the string again). As for zipping I would 7za that is in the distribution as well.


    From the image database you can query private items 0x9999, 0x0800 for the filename and 0x9999, 0x0801 for the device if you have more than one.


    So in pseudocode:


    read list of patients
    for each patient
    query list of images including its filename
    for each image
    create target folder (use something like script('mkdir ' .. filename ))
    copy image
    at the end zip all using 7za.


    Marcel

  • Hi marcel


    I checked the samples, but I was unable to find there how it is possible to query the private items 0x9999, 0x0800 for the filename etc. so I can copy them afterwards. I would be grateful if you can elaborate this process in more details.


    I also found one problem script('rm ' .. directoryname) does not work for the directory... is there another command how I can delete created directory to clean up.


    tnx


    this is the script so far...




    best
    Tomas

  • Ok, now it is querying the values, but still have a problem to use them:


    Code
    images[k]["9999,0800"]


    seems to return null,


    actually it would be nice to know exactly how the userstructure returned from dicomquery fucntion looks like. I am new to lua and this is not apparent to me.


    thanks a lot


    Tomas

  • Hi Tomas,


    I never tried this and it appears that the lua query command fails to return this information (it is actually filtered out). You will have to use a database query (dbquery command) to get access to this inside information.


    Marcel

  • Hi Tomas,


    To simplify things, you can zip patient by patient with builtin functionality (dgate --export:patient,,,,file) , or lua servercommand('export:patient,,,,file') but that will not maintain the directory structure.


    Marcel

Participate now!

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