--[[
   This script generates the hints for sorting the US sequences within the study
   stills first, then cine clips by acquisition date/time 
   
	Cristian Bonciu	August 2004
	-	CREATED and implemented the above functionality for development testing purposes      
	Mahesh Nagarajan	05 FEB 2007
	- 	Modified syntaxes for sorting hints as part of v11.5 re-write
--]]

function DeclareTags()
end

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

-- ////////////////////////////////////////////////////////////////////////////
-- US sequence sorting function
-- ////////////////////////////////////////////////////////////////////////////

function Execute()
-- ////////////////////////////////////////////////////////////////////////////
-- generates the hints for sorting the US sequences as follows 
-- stills first, clips last, and then series date, time, number and UID
-- ////////////////////////////////////////////////////////////////////////////
    DeclareTags()
    
    -- If this is the wrong script for the supplied image...
    if (not SanityOK("US")) then
      return nil
      -- =====================================================
    end	
	
    local sortHint01 = SortingHint:new("US Sequence Sort", "DEFAULT")
    
    -- Descending sort with "STILLS" < "CINE" so stills come first, then the clips
    sortHint01:AddEntry(FRAME_TYPE_PROP,false) 
    
    -- Beyond that, simply chronological
    sortHint01:AddEntry(SERIES_DATE_TAG)
    sortHint01:AddEntry(SERIES_TIME_TAG)
    sortHint01:AddEntry(SERIES_NUMBER_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
