Delete studies based on age

  • Hi,


    use option LRUSort. Normally, patients entered into the server's database first will be deleted or archived first. By setting this option to StudyDate, patients with the oldest last studydate will be selected for deletion or archival first. Can also be set to PatientBir, or AccessTime. Default "".


    You can then use the normal disk threshold mechanism to delete entries. But it will only be based on disk size, so you have to monitor if you are at 6 year yet.


    Marcel

  • okay, but instead of looking at disk space, can I tell conquest to delete on these conditions:


    study date is more than or equal to (days old) '2196', the patients birth date is more than or equal to (days old) '8400', modalities in study doesn't contain 'MG'



    This would be an fantastic feature added to conquest -- can this be added to the wishlist?


    thanks - Pacsdude

  • 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!

  • Should be easy:


    x = DicomObject:new()
    x.PatientID = '*test*'
    x.QueryRetrieveLevel = 'PATIENT'
    y = dicomquery('CONQUESTSRV1', 'PATIENT', x)
    print('about to delete', #y, 'patients')
    -- dicomdelete(x) -- remove the first -- only if you are really sure


    Save this is a file and run dgate "--lua:dofile('file.lua')"


    Marcel

  • 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

  • Hi,


    think of lua as basic or any other language. There is a lot of lua documentation on the internet. Here is the corrected example with a DICOM date range match and a delete loop:


    x = DicomObject:new()
    x.PatientNam = '*phantom*'
    x.PatientID = ''
    x.StudyDate = '19700101-12312002' -- data range match
    x.QueryRetrieveLevel = 'STUDY'
    x.StudyInstanceUID = '' -- you want these returned for the loop


    y = dicomquery('RADARCH4', 'STUDY', x)
    -- now y is an array with all requested items


    print('about to delete', #y, 'Studies')
    for i=0, #y-1 do
    z = DicomObject:new()
    z.PatientID = y[i].PatientID
    z.StudyInstanceUID = y[i].StudyInstanceUID
    print('deleting', y[i].PatientID, y[i].PatientName, y[i].StudyDate)
    -- dicomdelete(z)
    end


    Use with care!


    Marcel

  • 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


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


  • 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 :)

  • Hi,


    x.ModalitiesInStudy ~= 'MG' is a boolean that should be used in an if statement. If you say:


    x.ModalitiesInStudy = ''


    it will be returned in the query (which must be at STUDY level).


    Then you can use


    for i=0, #y-1 do
    if string.find(y.ModalitiesInStudy, 'MG')==NIL then
    -- put orginal delete code here
    end
    end


    Marcel

  • Marcel,


    So, it should look like this?



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

Participate now!

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