Posts by Pacsdude

    Marcel


    Thanks for looking at this. Based on your suggestion, would something like this work? Your talking about only double checking what it has deleted correct?


    Marcel,


    I was hoping that I could run this code by you once more to make sure that it looked okay? Earlier I was writing SUIDs to a .txt file, so that I could double check it and then I was deleting based on that file. Now I have changed it around so that it will delete based on the query. Could you please give me your thoughts on this so that it doesn't also delete MG exams?


    The function of this script is to:


    1) query a StudyDate range from 19000101-six years ago from TODAY (to find all studies that are six years old and older)
    2) query a PatientBirthDate range from 19000101-21 years ago from TODAY (to find all studies with a DOB that is over 21 years of age)
    3) exclude Modality 'MG'
    4) delete everything the query found


    Marcel,


    I've gotten the date range to work in ZeroBraneStudio, but when I use it in the script, it bombs with this error:


    *** lua run error test_date.lua:9: attempt to perform arithmetic on a string value in 'dofile('test_date.lua')'


    Here is my code so far:


    Code
    a=DicomObject:new() a.QueryRetrieveLevel='STUDY' a.StudyInstanceUID='' --a.PatientName='*test*' a.AccessionNumber='' days = 2192 startdate = os.date(19000101) enddate = os.date('%Y%m%d', os.time()-days*24*3600) a.StudyDate = 'startdate .. '-' .. enddate' days = 7670 startDOB = os.date(19000101) endDOB = os.date('%Y%m%d', os.time()-days*24*3600) a.PatientBirthDate = 'startDOB .. '-' .. endDOB' a.ModalitiesInStudy = '' b=dicomquery('RADARCH4', 'STUDY', a) f=io.open('suid.txt', 'wt') for i=0, #b-1 do if string.find(b[i].ModalitiesInStudy, 'MG')==nil then f:write(b[i].StudyInstanceUID, '\t', 'Date', '\t', b[i].StudyDate, '\t', 'MOD', '\t', b[i].ModalitiesInStudy .. '\n') end end f:close()


    also, this is what successfully runs in ZeroBrane Studio:


    Code
    days = 2192
    startdate = os.date(19000101)
    enddate = os.date('%Y%m%d', os.time()-days*24*3600)
    print (startdate .. '-' .. enddate)
    days = 7670
    startDOB = os.date(19000101)
    endDOB = os.date('%Y%m%d', os.time()-days*24*3600)
    print (startDOB .. '-' .. endDOB)

    Marcel,


    thanks again - I'm trying to get MORE output written in my .txt file I am creating. Can you help me? All it will write for me is the 'StudyInstanceUID'. I tried to get it to write 'AccessionNumber' as well but it won't display it correctly, the value is just placed at the end of the SUID with no spaces.


    Here is what I am currently running:


    Marcel,


    thanks for your help on this. You have gone out of your way! The script ran successfully on my end, but came back with over 74,000 rows! Way more than I would expect. I have a question about this line:


    start = os.date('%Y%m%d', os.time()-days*24*3600)


    I know that we are stating that 'days = 100' but is the above multiplying it by 24 & then by 3600? Is it selecting studies that are 100 days and older and not newer?


    Jamie

    Marcel,


    thanks for the example! Forgive me for asking this and really do appreciate your help on this. I have tried to insert that into my code, but it fails. I've also just tried to make it into its own .lua script, but no luck there either. I guess I should insert this at the beginning?


    that worked great, it did exactly what I was expecting.


    Now, if there was only a way to tell the script 'this many days old' from 'today' for the study date instead of giving it a date range? Also, could the same be done for the date of birth?


    Thank you

    Marcel,


    I'm going a different route with this. What I am doing now is gathering up all of the SUID's and writing them to a .txt file. Could you please look at my code below and tell me why it won't work? I am trying to find the following:


    all studies with a date range of '19000101-20070714'
    all studies with a Date of Birth of '19000101-19920714'
    all studies that are NOT MG


    Code
    a=DicomObject:new() a.QueryRetrieveLevel='STUDY' a.StudyInstanceUID='' --a.PatientName='*test*' --a.AccessionNumber='6419216' a.StudyDate='19000101-20070714' a.PatientBirthDate = '19000101-19920714' a.ModalitiesInStudy = '' b=dicomquery('RADARCH4', 'STUDY', a) f=io.open('suid.txt', 'wt') for i=0, #b-1 do if string.find(y[i].ModalitiesInStudy, 'MG')==nil then f:write(b[i].StudyInstanceUID .. '\n') end


    The error I'm getting is: '*** lua run error delete_UID.lua:100: attempt to index global 'y' (a nil value) in 'dofile('delete_UID.lua')''


    I can make the script above run if I take out the 'if string' and pick a modality, but I don't want to have to run this for each of our modalites once a month when it is time to delete old exams.


    this code works fine, but I want it to find all studies that are NOT MG


    thanks!

    OS: Win Server 2008 R2
    Conquest Version: 1.4.17 Beta


    Marcel,


    HI. I am doing two things with lua right now and both are related. What I am trying to accomplish is deletion of our prior exams that we no longer need according to our storage policy (we keep 6 years of each patients exams). I am currently working on the year 2005 and our volume increased dramatically during this year and I simply cannot use a .lua script to delete all of our studies from Conquest that fall within our deletion rules. Dgate crashes when it is given too much to do, so for right now I have to break up the work by giving it the following example.


    Only CR exams with study dates from 5/1/2005 - 5/31/2005. This will yield about 10K to 12K studies. I would like to just give the command to dgate via a .lua script once for it to do 'all; of the work instead of 'breaking up the work' and making sure that dgate doesn't crash (because it will if its given too much work via the script).


    Here is what I am doing with LUA right now.


    first step: I run the following code to generate a list of Study UIDs to delete:


    --suid.lua

    Code
    a=DicomObject:new() a.QueryRetrieveLevel='STUDY' a.StudyInstanceUID='' --a.PatientName='*test*' --a.AccessionNumber='6419216' a.StudyDate='20050501-20050531' a.PatientBirthDate = '19000101-19920423' a.ModalitiesInStudy = 'CR' b=dicomquery('RADARCH4', 'STUDY', a) f=io.open('suid.txt', 'wt') for i=0, #b-1 do f:write(b[i].StudyInstanceUID .. '\n') end f:close()


    2nd step is that I run this code below calling the file generated from the code above:


    --delete.lua


    What I would like to do is generate a larger 'SUID.txt' file so that I can pass more Study UIDs to dgate via the .lua script. My question is can I pass a 'sleep' command to my 'delete.lua' script to wait for 5 seconds after it passes one line to dgate?


    I was reading this page http://stackoverflow.com/quest…p-block-for-a-few-seconds and someone said that this could be used for windows:


    os.execute("CHOICE /n /d:y /c:yn /t:5")


    I'm unsure though, do you have any thoughts on how to tell the .lua script to pause/wait for a set period of time before it reads the next line of a input file?


    thanks


    Jamie

    Marcel,


    So, it should look like this?



    it errors and tells me 'lua run error test3.lua:51: '=' expected near '~=' in 'dofile('test3.lua')''

    Marcel,


    I am trying to do ask for all modalities that are NOT 'MG' like:


    x.ModalitiesInStudy ~= 'MG'


    according to LUA documentation on the web, the way to ask for something that is 'NOT' a value but give me the other values is to use a '~='.


    Any ideas on what I am doing wrong?


    thanks :)

    got our query to work.. had to change the date to 'year, month, day' like:


    current setup:
    conquest v1.4.17beta
    OS: Server 2008 R2


    Marcel,


    Thanks for the help, but I think the 'PatientNam' might not be getting passed to DGATE via the script. I have attached the 'pacsuser.log' file (debug @ level 4) and the test.lua script I have been using.


    Code
    3/20/2013 12:06:17 PM [RADARCH4] 9999,0300 42 LO ConquestConsoleText "Server command sent using DGATE -- option" 3/20/2013 12:06:17 PM [RADARCH4] 9999,0400 22 LO ConquestConsoleComma "lua:dofile('test.lua')" 3/20/2013 12:06:17 PM [RADARCH4] Server command sent using DGATE -- option3/20/2013 12:06:17 PM [RADARCH4] Query Tables: DICOMImages3/20/2013 12:06:17 PM [RADARCH4] Columns : ObjectFile, DeviceName3/20/2013 12:06:17 PM [RADARCH4] Where : SOPInstanc = ''3/20/2013 12:06:17 PM [RADARCH4] Order : (null)3/20/2013 12:06:17 PM [RADARCH4] FreeStore Left 993 on E:\3/20/2013 12:06:17 PM [RADARCH4] FreeStore Left 2658781 on f:\3/20/2013 12:06:17 PM [RADARCH4] No image number3/20/2013 12:06:17 PM [RADARCH4] No Series number3/20/2013 12:06:17 PM [RADARCH4] No Series UID3/20/2013 12:06:17 PM [RADARCH4] No Study UID3/20/2013 12:06:17 PM [RADARCH4] No SOP UID3/20/2013 12:06:17 PM [RADARCH4] No Patient ID3/20/2013 12:06:17 PM [RADARCH4] No Patient Name3/20/2013 12:06:17 PM [RADARCH4] Importconverter-1.0 executes: set PatientID to ""3/20/2013 12:06:17 PM [RADARCH4] Importconverter-1.0 executes: set StudyDate to "01011997-01012002"3/20/2013 12:06:17 PM [RADARCH4] Importconverter-1.0 executes: set QueryRetrieveLevel to "STUDY"3/20/2013 12:06:17 PM [RADARCH4] Importconverter-1.0 executes: set StudyInstanceUID to ""3/20/2013 12:06:17 PM [RADARCH4] Connected by address: 0100007f3/20/2013 12:06:17 PM [RADARCH4] Testing transfer: '1.2.840.10008.1.2' against list #0 = '1.2.840.10008.1.2'3/20/2013 12:06:17 PM [RADARCH4] 3/20/2013 12:06:17 PM [RADARCH4] UPACS THREAD 336: STARTED AT: Wed Mar 20 12:06:17 20133/20/2013 12:06:17 PM [RADARCH4] A-ASSOCIATE-RQ Packet Dump3/20/2013 12:06:17 PM [RADARCH4] Calling Application Title : "RADARCH4 "3/20/2013 12:06:17 PM [RADARCH4] Called Application Title : "RADARCH4 "3/20/2013 12:06:17 PM [RADARCH4] Application Context : "1.2.840.10008.3.1.1.1", PDU length: 163843/20/2013 12:06:17 PM [RADARCH4] Number of Proposed Presentation Contexts: 13/20/2013 12:06:17 PM [RADARCH4] Presentation Context 0 "1.2.840.10008.5.1.4.1.2.2.1" 13/20/2013 12:06:17 PM [RADARCH4] Server Command := 00203/20/2013 12:06:17 PM [RADARCH4] Message ID := c59d3/20/2013 12:06:17 PM [RADARCH4] 0000,0002 28 UI AffectedSOPClassUID "1.2.840.10008.5.1.4.1.2.2.1" 3/20/2013 12:06:17 PM [RADARCH4] 0000,0100 2 US CommandField 32 3/20/2013 12:06:17 PM [RADARCH4] 0000,0110 2 US MessageID 50589 3/20/2013 12:06:17 PM [RADARCH4] 0000,0700 2 US Priority 0 3/20/2013 12:06:17 PM [RADARCH4] 0000,0800 2 US DataSetType 258 3/20/2013 12:06:17 PM [RADARCH4] 0002,0010 17 UI TransferSyntaxUID "1.2.840.10008.1.2" 3/20/2013 12:06:17 PM [RADARCH4] (StudyRootQuery) search level: STUDY 3/20/2013 12:06:17 PM [RADARCH4] 0002,0010 17 UI TransferSyntaxUID "1.2.840.10008.1.2" 3/20/2013 12:06:17 PM [RADARCH4] 0008,0020 18 DA StudyDate "01011997-01012002 " 3/20/2013 12:06:17 PM [RADARCH4] 0008,0052 6 CS QueryRetrieveLevel "STUDY " 3/20/2013 12:06:17 PM [RADARCH4] 0010,0020 0 LO PatientID (empty)3/20/2013 12:06:17 PM [RADARCH4] 0020,000d 0 UI StudyInstanceUID (empty)3/20/2013 12:06:17 PM [RADARCH4] Query On Study3/20/2013 12:06:17 PM [RADARCH4] Issue Query on Columns: DICOMStudies.StudyDate, DICOMStudies.PatientID, DICOMStudies.StudyInsta3/20/2013 12:06:17 PM [RADARCH4] Values: DICOMStudies.StudyDate >= '01011997' and DICOMStudies.StudyDate <= '01012002'3/20/2013 12:06:17 PM [RADARCH4] Tables: DICOMStudies3/20/2013 12:06:17 PM [RADARCH4] Sorting ((null)) DoSort := 03/20/2013 12:06:17 PM [RADARCH4] Query Distinct Tables: DICOMStudies3/20/2013 12:06:17 PM [RADARCH4] Columns : DICOMStudies.StudyDate, DICOMStudies.PatientID, DICOMStudies.StudyInsta3/20/2013 12:06:17 PM [RADARCH4] Where : DICOMStudies.StudyDate >= '01011997' and DICOMStudies.StudyDate <= '01012002'3/20/2013 12:06:17 PM [RADARCH4] Order : (null)3/20/2013 12:06:17 PM [RADARCH4] Records = 03/20/2013 12:06:17 PM [RADARCH4] C-Find (StudyRoot) located 0 records3/20/2013 12:06:17 PM [RADARCH4] UPACS THREAD 336: ENDED AT: Wed Mar 20 12:06:17 20133/20/2013 12:06:17 PM [RADARCH4] UPACS THREAD 336: TOTAL RUNNING TIME: 0 SECONDS3/20/2013 12:06:17 PM [RADARCH4] fixin to delete 0 Studies


    Marcel,


    What we are trying to do with this test script is to delete studies that have a patientnam of 'phantom' and are older than '12/31/2002'.


    When we run this script, it is complaining about our '<=' sign.


    x = DicomObject:new()
    z = DicomObject:new()
    x.PatientNam = '*phantom*'
    z.StudyDate <= '12312002'
    x.QueryRetrieveLevel = 'STUDY'
    y = dicomquery('RADARCH4', 'STUDY', x) and ('RADARCH4', 'STUDY', z)
    print('about to delete', #y, 'Studies')
    dicomdelete(x)


    Our end goal is to write a script that deletes studies that are a certain age (older than 6 years) and patients that are older than 21 years of age and study modalities that are NOT MG.


    Could you please check out the above script and let us know why it misbehaves?


    thanks

    Great news! could I see some examples of this? would like to more than likely delete 'test' images that have the word 'test' or 'QC' in the patient name field or in the Patient ID field.


    thanks!