--[[
    This file provides a number of common variables and function for 
    to be used by the grouping scripts
    
	Cristian Bonciu		August-September 2004
     -	Created and implemented the functionality from pseudo-code prototypes provided by Allan 
	Cristian Bonciu,        June 9, 2005
     -	Added the id of IMAGE_LOCATION_PATIENT_PROP to be used during sorting
	Allan Noordvyk          Oct 1, 2005
     -	Grouped and sorted tag definitions adding in those now needed for all series
	Mahesh Nagarajan     Oct 6, 2005
     -	Added missing definitions for  - PULSE_SEQ_PROP, MG_PROJECTION_PROP, 
		NM_IMAGE_TYPE_PROP and INTENT_PROP
	Allan Noordvyk          Nov 13, 2005
     -	Added INSTITUTION_NAME_TAG to fix missing declaration in GroupCT.tls
		change for Elkhart.
	Allan Noordvyk          Nov 14, 2005
     -	Added DELAYED_PROP defn to allow grouping by DELAYED property
	Mahesh Nagarajan		13 FEB 2007
	 -	As part of v11.5, re-organised the "DeclareTags section owing to its messy structure
    Shudong Liu	Jan 20, 2009
     -	Added INSTITUTION_ADDRESS_TAG so that it can be used to distinguish sites which 
        have the same institution name. (CRDB70726)	
	James Zhang	June 19, 2009
     -	Added group hint ALI_DERIVED_IDENTIFIER_TAG for CRDB75126.			
]]--

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

-- ////////////////////////////////////////////////////////////////////////////    
-- definitions of the DICOM elements IDs used in this script
-- and available in the context when the modality grouping scripts are called
-- ////////////////////////////////////////////////////////////////////////////    
function DeclareTags()    

    -- McKesson Private Tag Declarations
    -- CB -- July 2004, quick fix for missing functionality for declaring the ids of the properties in the global context
    ALI_IMAGE_FILENAME_TAG = maketag("3711","0001") 
    ALI_FRAME_INDEX = maketag("3711","0090") 
	ALI_DERIVED_IDENTIFIER_TAG = maketag("3711","1022")
    IMAGE_TYPE_PROP = maketag("3711","1101")
    VIEW_PROP = maketag("3711","1102")
    SERIES_DESC_PROP = maketag("3711","1103")
    BODY_REGION_PROP = maketag("3711","1104")
    FRAME_TYPE_PROP = maketag("3711","1105") 
    CONTRAST_PROP = maketag("3711","1106")
    ACQ_DEVICE_PROP = maketag("3711","1107")
    LATERALITY_PROP = maketag("3711","1108")
    PHASE_PROP = maketag("3711","1109")
    MODALITY_PROP = maketag("3711","110a")
    PROJECTION_PROP = maketag("3711","110b")
	INTENT_PROP = maketag("3711","110d")
	IMAGE_LOCATION_PATIENT_PROP = maketag( "3711", "110e" )  -- image location dependent on view and image position 
    DELAYED_PROP = maketag("3711","1111")
	COLOR_PROP = maketag("3711","1113")
    THUMBNAIL_GRP_PROP = maketag("3711","1116")
    SERIES_UID_PROP = maketag("3711","1117")
	PULSE_SEQ_PROP = maketag("3711","1301")
    NM_IMAGE_TYPE_PROP = maketag("3711","1401")  
    MG_PROJECTION_PROP = maketag("3711","1501")
	MG_IMP_DISP_PROP = maketag("3711","1502")
	MG_MAG_FACTOR_PROP = maketag("3711","1503")
    MG_SPOT_COMP_PROP = maketag("3711","1504")
    
    META_INFO_VER_NAME = maketag( "0002", "0013" )	
	
    IMAGE_TYPE_TAG = maketag("0008", "0008")	-- image type, mandatory, regulated, text
	SOP_CLASS_UID_TAG = maketag("0008", "0016")
	IMAGE_UID_TAG = maketag("0008", "0018")		-- SOP instance UID
    ID_STUDY_DATE_TAG = maketag("0008","0020") -- Study Date
    SERIES_DATE_TAG = maketag("0008","0021") 
	ACQUISITON_DATE_TAG = maketag("0008","0022") 
	IMAGE_ACQUISITION_DATE_TAG = maketag("0008","0023")
	ACQUISITON_DATETIME_TAG = maketag("0008","002A") 
	ID_STUDY_TIME_TAG = maketag("0008","0030") -- Study Time    
    SERIES_TIME_TAG = maketag("0008","0031") 
	ACQUISITON_TIME_TAG = maketag("0008","0032") 
    IMAGE_ACQUISITON_TIME_TAG = maketag("0008","0033")
    MODALITY_TAG = maketag("0008", "0060")		-- modality, mandatory, regulated, string    
	DEVICE_MANUFACTURER_TAG = maketag( "0008", "0070" ) -- Manufacturer of acquisition device	
	INSTITUTION_NAME_TAG = maketag("0008","0080")
	INSTITUTION_ADDRESS_TAG = maketag("0008","0081")	
    STUDY_DESC_TAG = maketag("0008", "1030")       -- study description    
    SERIES_DESC_TAG = maketag("0008", "103e")	-- series description, optional, free, text
    DEVICE_MODEL_TAG = maketag( "0008", "1090" ) -- Manufacturer of acquisition device
	
	CONTRAST_TAG = maketag("0018", "0010")		-- contrast bolus/agent
    BODY_PART_EX_TAG = maketag("0018", "0015")   -- body region, conditional / optional, regulated, string
	SCAN_OPTIONS_TAG = maketag("0018","0022")            -- Scan Options
    SLICE_THICKNESS_TAG = maketag("0018", "0050")
	ACQ_PROTOCOL_TAG = maketag("0018","1030")        -- Acquisition Protocol Name    
	ACQ_TRIGGER_TIME_TAG = maketag("0018","1060")   -- ACQ Trigger Time
	ACQ_RECON_DIAMETER_TAG = maketag("0018","1100")  -- ACQ Reconstruction Diameter
	PATIENT_POS_TAG = maketag( "0018", "5100" )         -- Patient position tag
  	
    SERIES_UID_TAG = maketag("0020", "000e")	-- series UID
    STUDY_UID_TAG = maketag("0020","0010")	    -- study UID
	SERIES_NUMBER_TAG = maketag("0020", "0011")	-- series number, conditional / optional, integer
	ACQ_NUMBER_TAG = maketag( "0020", "0012" )          -- Relative Acquisition Number    
    INSTANCE_NUMBER_TAG = maketag("0020","0013") -- formerly image number
	IMAGE_POSITION_PATIENT_TAG = maketag("0020","0032") 
	IMAGE_ORIENTATION_PATIENT_TAG = maketag("0020","0037") 
    LATERALITY_TAG = maketag("0020", "0062")	-- IMAGE (not series) laterality description, optional, regulated string (L,R,U,B)
    TEMP_POSITION_IDENTIFIER_TAG = maketag("0020","0100")
    SERIES_IN_STUDY_TAG = maketag("0020", "1000")
	SLICE_LOC_TAG = maketag("0020", "1041")
	IMAGE_COMMENTS_TAG = maketag("0020","4000") 
	
    NUMBER_OF_FRAMES_TAG = maketag("0028", "0008") -- number of frames, conditional, positive integer
    WINDOW_CENTER_TAG = maketag("0028","1050")  
	
	NMI_IMAGE_INDEX = maketag("0054", "1330")
	
	-- Private tags
	TOSHIBA_4DDATA_TAG = maketag("0029", "1008")
	
    -- Uniform description used to identify the special sequence containing all images (when present)
    -- IMPORTANT: DO NOT CHANGE THIS VALUE UNLESS YOU ALSO CHANGE CODE IN HRS THAT LOOKS FOR IT
    ALL_IMAGES_LABEL = "*All Images*"
    
 end

-- ////////////////////////////////////////////////////////////////////////////
-- commonly used strings definitions
-- ////////////////////////////////////////////////////////////////////////////    
  
-- ////////////////////////////////////////////////////////////////////////////
-- common grouping hints 
-- ////////////////////////////////////////////////////////////////////////////

function Execute()
    DeclareTags()
end

