--[[
	This script generates the hints for sorting the PT sequences within the study. 
	
	Mahesh Nagarajan		31 JAN 2007
	- 	Modified syntaxes for sorting hints as part of v11.5 re-write
	-	Site customized code will be removed and re-located to SortPT.site files -> starting with 11.5, 
		unless sort orders are fundamentally flawed, all change requests to sorting schemes will be
		incorporated into a site file for the site.	
--]]

-- Enable tracing in this module for debugging (comment out for production version)
-- AliDSTraceLevel = 2 

-- ////////////////////////////////////////////////////////////////////////////
-- end common scripting context 
-- ////////////////////////////////////////////////////////////////////////////

-- ////////////////////////////////////////////////////////////////////////////
-- PT grouping function
-- ////////////////////////////////////////////////////////////////////////////

function Execute()
-- ////////////////////////////////////////////////////////////////////////////
-- generates the hints for sorting the PT sequences within a study as follows 
-- scouts first, then the others, by series date, time, number and UID
--- ////////////////////////////////////////////////////////////////////////////

    TraceC( "Executing sort for PT...\n" )
 
	local modalityAttr = GetAttr(MODALITY_TAG)
	if( not modalityAttr ) then
		return -- wrong context (no modality in the input collection)
		-- =====================================================
	end
	if( not BestMatchInAttr(modalityAttr, "PT") ) then
		return -- wrong script or wrong context (PT script applied on other modality)
		-- =====================================================
	end	
	
    local sortHint01 = SortingHint:new("PT Sequence Sort", "DEFAULT")
    
    sortHint01:AddEntry(IMAGE_TYPE,false) -- "Scout" < "Original","Recon", etc. so scouts come first, then the other series
    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)
    
    SortSequencesInStudy(sortHint01) 
    
    TraceC( "Completed sort for PT.\n" )
end
