--[[
	This sorting script sorts sequences for AS, CD, CP, DD, LP, LS, VL, XA 
	and similiar modality images which may be either cine or still frames. In
	this version, the hints for sorting are generated within the study
	so the sequence containing stills is first, and then cine clip sequences
	by acquisition date/time 
	
	Allan Noordvyk		January 19, 2005
     -	Created based on old SortAS version 
	Allan Noordvyk		April 11, 2005
     -	added more sort hints
	Allan Noordvyk		September 16, 2005
     -	Added modality as first sort criteria so that like modality series
          a grouped together in combo studies even when simultaneous acquisition
          was done (or acquistion time information is missing or uniform).
	Mahesh Nagarajan	January 31, 2007
	- 	Modified syntaxes for sorting hints as part of v11.5 re-write
	-	Site customized code will be removed and re-located to SortGenericCine.site 
		files -> starting with 11.5, unless sort orders are fundamentally flawed, 
		all change requests to sorting schemes will be go into a site file
--]]

function DeclareTags()
end

-- ////////////////////////////////////////////////////////////////////////////
-- end common scripting context (temp)
-- ////////////////////////////////////////////////////////////////////////////

-- ////////////////////////////////////////////////////////////////////////////
-- Generic Cine sequence sorting function
-- ////////////////////////////////////////////////////////////////////////////

function Execute()
-- ////////////////////////////////////////////////////////////////////////////
-- generates the hints for sorting the Generic Cine sequences as follows 
-- stills first, clips last, and then series date, time, number and UID
-- ////////////////////////////////////////////////////////////////////////////

    DeclareTags()
    
    -- Note that since this is a generic script covering multiple modalities
    -- we do not do a modality sanity check.
	
    local sortHint01 = SortingHint:new("Cine/Still Sequence Sort", "DEFAULT")
    
    -- Used to group modalities separately in combo exams
    sortHint01:AddEntry(MODALITY_PROP)   
     
    -- Beyond that, simply chronological
    sortHint01:AddEntry(SERIES_DATE_TAG)
    sortHint01:AddEntry(SERIES_TIME_TAG)
    sortHint01:AddEntry(SERIES_NUMBER_TAG)
    sortHint01:AddEntry(PHASE_PROP)    
    sortHint01:AddEntry(ACQ_NUMBER_TAG)   
    sortHint01:AddEntry(SERIES_UID_TAG)
    sortHint01:AddEntry(ACQUISITON_DATETIME_TAG)
    sortHint01:AddEntry(ACQUISITON_DATE_TAG)
    sortHint01:AddEntry(ACQUISITON_TIME_TAG)
    sortHint01:AddEntry(IMAGE_ACQUISITON_TIME_TAG)
    sortHint01:AddEntry(INSTANCE_NUMBER_TAG) 
    sortHint01:AddEntry(ALI_IMAGE_FILENAME_TAG) 
    sortHint01:AddEntry(IMAGE_UID_TAG)    
    
    -- Ensure some unique order even if all time is the same
    sortHint01:AddEntry(SERIES_UID_TAG)
    
    SortSequencesInStudy(sortHint01)

end

if( AliDSDebugEdit == 1 ) then
    Execute()
end
