/*******************************************************************************
 *  Copyright 2017-2018 Centre for Development of Advanced Computing(C-DAC), Pune
 *  
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *  
 *   http://www.apache.org/licenses/LICENSE-2.0
 *  
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/
package cdac.medinfo.sdk.dcm30_04.baselibs;



import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataElement;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDicomValue;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDictionaryReader;
import cdac.medinfo.sdk.dcm30_04.commoninterface.ITransferSyntax;
import cdac.medinfo.sdk.dcm30_04.enums.EnumImageType;
import cdac.medinfo.sdk.dcm30_04.exceptions.ConditionFailedException;
import cdac.medinfo.sdk.dcm30_04.exceptions.InvalidItemException;
import cdac.medinfo.sdk.dcm30_04.exceptions.MandatoryMissingException;
import cdac.medinfo.sdk.dcm30_04.exceptions.ValidationException;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConfig;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConstants;
import cdac.medinfo.sdk.dcm30_04.utils.DicomLogger;




/**
 * This class describes all the set/get methods required to set/get attributes of Detector Information Sequence
 */
public class DetectorInformationSequenceItem extends Item   
{
	


	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * This constructor creates the item and with default TransferSyntax 
	 */
	DetectorInformationSequenceItem()
	{
		super();
	}

	/**
	 * This constructor creates the item with default TransferSyntax.
	 * @param objITransferSyntax specifies the DICOM Standard defined TransfeSyntax  
	 */
	DetectorInformationSequenceItem(ITransferSyntax objITransferSyntax)
	{
		super(objITransferSyntax);
	}

	/**
	 * This constructor creates Item with specified transferSyntax and specified DictionaryReader
	 * @param objTransferSyntax specifies the DICOM Standard defined TransfeSyntax
	 * @param objDictionaryReader specifies the DICOM Dictionary reader to be used 
	 */
	DetectorInformationSequenceItem(ITransferSyntax objTransferSyntax, IDictionaryReader objDictionaryReader)
	{
		super(objTransferSyntax,objDictionaryReader);
	}

	/**
	 * Sets Label describing the collimator used.
	 * @param strCollimatorOrGridName String value of Collimator/Grid Name. 
	 */
	public void setCollimatorOrGridName(String strCollimatorOrGridName)
	{
		/*Accept the Collimator/Grid Name in String format of type SH.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0018,0x1180, strCollimatorOrGridName,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0018,0x1180,DicomConstants.DCM_DT_SH, strCollimatorOrGridName);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves Label describing the collimator used.
	 * @return String - value of Collimator/Grid Name.
	 */
	public String getCollimatorOrGridName()
	{
		Object objValue = getValue(0x0018,0x1180);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets Collimator type. Defined Terms: PARA = Parallel (default),PINH = Pinhole,FANB = Fan-beam,CONE = Cone-beam,
	 * SLNT = Slant hole,ASTG = Astigmatic,DIVG = Diverging,NONE = No collimator,UNKN = Unknown
	 * Required if a sequence Item is present.
	 * @param strCollimatorType String value of Collimator Type. 
	 */
	public void setCollimatorType(String strCollimatorType)
	{
		/*Accept the Collimator Type in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0018,0x1181, strCollimatorType,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0018,0x1181,DicomConstants.DCM_DT_CS, strCollimatorType);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves Collimator type. 
	 * @return String - value of Collimator Type. 
	 */
	public String getCollimatorType()
	{
		Object objValue = getValue(0x0018,0x1181);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets Shape of the field of view of the Nuclear Medicine detector. Defined Terms: RECTANGLE,
	 * ROUND,HEXAGONAL.
	 * @param strFieldOfViewShape String value of Field of View Shape
	 */
	public void setFieldOfViewShape(String strFieldOfViewShape)
	{
		/*Accept the Field of View Shape in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0018,0x1147, strFieldOfViewShape,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0018,0x1147,DicomConstants.DCM_DT_CS, strFieldOfViewShape);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves Shape of the field of view of the Nuclear Medicine detector. Defined Terms: RECTANGLE,
	 * ROUND,HEXAGONAL.
	 * @return String - value of Field of View Shape.
	 */
	public String getFieldOfViewShape()
	{
		Object objValue = getValue(0x0018,0x1147);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets dimensions of the field of view, in mm.
	 * If Field of View Shape (0018,1147) is:
	 * RECTANGLE: row dimension followed by column. 
	 * ROUND: diameter.
	 * HEXAGONAL: diameter of a circumscribed circle.
	 * @param arrStrFieldOfViewDimensions String array of Field of View Dimension(s).
	 */
	public void setFieldOfViewDimensions(String[] arrStrFieldOfViewDimensions)
	{
		/*Accept the Field of View Dimension(s) in String format of type IS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0018,0x1149, arrStrFieldOfViewDimensions,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0018,0x1149,DicomConstants.DCM_DT_IS, arrStrFieldOfViewDimensions);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves Dimensions of the field of view, in mm.
	 * @return String[] - String Array of Field of View Dimension(s).
	 */
	public String[] getFieldOfViewDimensions()
	{
		Object objValue = getValue(0x0018,0x1149);
		if(objValue != null)
			return (String[])objValue;
		return null;
	}

	/**
	 * Sets Focal distance, in mm. A value of 0 means infinite distance for parallel collimation.
	 * @param  arrStrFocalDistance String array of Focal Distance.
	 */
	public void setFocalDistance(String[] arrStrFocalDistance)
	{
		/*Accept the Focal Distance in String Array format of type IS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0018,0x1182, arrStrFocalDistance,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0018,0x1182,DicomConstants.DCM_DT_IS, arrStrFocalDistance);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves Focal distance, in mm.
	 * @return String[] - String array of Focal Distance.
	 */
	public String[] getFocalDistance()
	{
		Object objValue = getValue(0x0018,0x1182);
		if(objValue != null)
			return (String[])objValue;
		return null;
	}

	/**
	 * Sets Center of focus along a row.
	 * @param arrStrXFocusCenter String array of X Focus Center.
	 */
	public void setXFocusCenter(String[] arrStrXFocusCenter)
	{
		/*Accept the X Focus Center in String format of type DS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * 
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0018,0x1183, arrStrXFocusCenter,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0018,0x1183,DicomConstants.DCM_DT_DS, arrStrXFocusCenter);

		addDataElement(objIDataElement);
	}

	/**
	 * Return Center of focus along a row.
	 * @return String[] - String array of X Focus Center.
	 */
	public String[] getXFocusCenter()
	{
		Object objValue = getValue(0x0018,0x1183);
		if(objValue != null)
			return (String[])objValue;
		return null;
	}

	/**
	 * Sets Center of focus along a column.
	 * @param arrStrYFocusCenter String array of Y Focus Center.
	 */
	public void setYFocusCenter(String[] arrStrYFocusCenter)
	{
		/*Accept the Y Focus Center in String Array format of type DS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0018,0x1184, arrStrYFocusCenter,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0018,0x1184,DicomConstants.DCM_DT_DS, arrStrYFocusCenter);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves Center of focus along a column.
	 * @return String[] -  String array of Y Focus Center.
	 */
	public String[] getYFocusCenter()
	{
		Object objValue = getValue(0x0018,0x1184);
		if(objValue != null)
			return (String[])objValue;
		return null;
	}

	/**
	 * Sets the amount of offset from (0,0) applied to each pixel in the image before application
	 * of the zoom factor, specified by a numeric pair: row value (delimiter) column value (in mm).
	 * @param arrStrZoomCenter String array of Zoom Center values.
	 */
	public void setZoomCenter(String[] arrStrZoomCenter)
	{
		/*Accept the Zoom Center in String format of type DS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0028,0x0032, arrStrZoomCenter,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0028,0x0032,DicomConstants.DCM_DT_DS, arrStrZoomCenter);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves the amount of offset from (0,0) applied to each pixel in the image before application
	 * of the zoom factor.
	 * @return String[] - String array of of Zoom Center values.
	 */
	public String[] getZoomCenter()
	{
		Object objValue = getValue(0x0028,0x0032);
		if(objValue != null)
			return (String[])objValue;
		return null;
	}

	/**
	 * Sets the amount of magnification applied to each pixel in the image, specified by a
	 * numeric pair: row value (delimiter) column value.
	 * @param arrStrZoomFactor String array of Zoom Factor values.
	 */
	public void setZoomFactor(String[] arrStrZoomFactor)
	{
		/*Accept the Zoom Factor in String format of type DS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0028,0x0031, arrStrZoomFactor,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0028,0x0031,DicomConstants.DCM_DT_DS, arrStrZoomFactor);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves the amount of magnification applied to each pixel in the image.
	 * @return String[] -  String array of Zoom Factor values. 
	 */
	public String[] getZoomFactor()
	{
		Object objValue = getValue(0x0028,0x0031);
		if(objValue != null)
			return (String[])objValue;
		return null;
	}
	/**
	 * Sets average center of rotation offset of Nuclear Medicine detector in mm.
	 * @param strCenterOfRotationOffset String value of Center of Rotation Offset.
	 */
	public void setCenterOfRotationOffset(String strCenterOfRotationOffset)
	{
		/*Accept the Center of Rotation Offset in String format of type DS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0018,0x1145, strCenterOfRotationOffset,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0018,0x1145,DicomConstants.DCM_DT_DS, strCenterOfRotationOffset);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves Average center of rotation offset of Nuclear Medicine detector in mm.
	 * @return String - value of Center of Rotation Offset.
	 */
	public String getCenterOfRotationOffset()
	{
		Object objValue = getValue(0x0018,0x1145);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets Angle of tilt in degrees of the detector.
	 * @param strGantryOrDetectorTilt String value of Gantry/Detector Tilt.
	 */
	public void setGantryOrDetectorTilt(String strGantryOrDetectorTilt)
	{
		/*Accept the Gantry/Detector Tilt in String format of type DS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0018,0x1120, strGantryOrDetectorTilt,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0018,0x1120,DicomConstants.DCM_DT_DS, strGantryOrDetectorTilt);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves Angle of tilt in degrees of the detector.
	 * @return String - value of Gantry/Detector Tilt.
	 */
	public String getGantryOrDetectorTilt()
	{
		Object objValue = getValue(0x0018,0x1120);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets Distance in mm from transmission source to the detector face. Required if Image
	 * Type (0008,0008) Value 4 is TRANSMISSION, Value 3 is not TOMO,
	 * and a sequence Item is present.
	 * @param strDistanceSourceToDetector String value of Distance Source to Detector.
	 */
	public void setDistanceSourceToDetector(String strDistanceSourceToDetector)
	{
		/*Accept the Distance Source to Detector in String format of type DS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0018,0x1110, strDistanceSourceToDetector,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0018,0x1110,DicomConstants.DCM_DT_DS, strDistanceSourceToDetector);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves Distance in mm from transmission source to the detector face
	 * @return String - value of Distance Source to Detector.
	 */
	public String getDistanceSourceToDetector()
	{
		Object objValue = getValue(0x0018,0x1110);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets Position of the detector about the patient for the start of the acquisition, in degrees.
	 *  Zero degrees is referenced to the origin at the patient's back. Viewing from the
	 *  patient's feet, angle increases in a counterclockwise direction (detector normal
	 *  rotating from the patient's back towards the patient's left side). Should not be included
	 *  if Image Type (0008,0008), Value 3, is TOMO, GATED TOMO, RECON TOMO or RECON GATED TOMO.
	 *  @param strStartAngle String value of Start Angle.
	 */
	public void setStartAngle(String strStartAngle)
	{
		/*Accept the Start Angle to Detector in String format of type DS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0054,0x0200, strStartAngle,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0054,0x0200,DicomConstants.DCM_DT_DS, strStartAngle);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves Position of the detector about the patient for the start of the acquisition, in degrees.
	 * @return String - value of Start Angle.
	 */
	public String getStartAngle()
	{
		Object objValue = getValue(0x0054,0x0200);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets Radial distance of the detector from the center of rotation, in mm. Should not be
	 * included if Image Type (0008,0008), Value 3, is TOMO, GATED TOMO, RECON TOMO or
	 * RECON GATED TOMO.
	 * @param arrStrRadialPosition String array of Radial Position.
	 */
	public void setRadialPosition(String[] arrStrRadialPosition)
	{
		/*Accept the Radial Position in String format of type DS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0018,0x1142, arrStrRadialPosition,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0018,0x1142,DicomConstants.DCM_DT_DS, arrStrRadialPosition);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves Radial distance of the detector from the center of rotation, in mm.
	 * @return String[] - String array of Radial Position.
	 */
	public String[] getRadialPosition()
	{
		Object objValue = getValue(0x0018,0x1142);
		if(objValue != null)
			return (String[])objValue;
		return null;
	}

	/**
	 * Sets the direction cosines of the first row and the first column with respect to the patient.
	 * @param arrStrImageOrientation String array of Image Orientation values.
	 */
	public void setImageOrientation(String[] arrStrImageOrientation)
	{
		/*Accept the Image Orientation in String format of type DS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0020,0x0037, arrStrImageOrientation,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0020,0x0037,DicomConstants.DCM_DT_DS, arrStrImageOrientation);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves the direction cosines of the first row and the first column with respect to the patient.
	 * @return String[] - String array of Image Orientation values.
	 */
	public String[] getImageOrientation()
	{
		Object objValue = getValue(0x0020,0x0037);
		if(objValue != null)
			return (String[])objValue;
		return null;
	}

	/**
	 * Sets the x, y, and z coordinates of the upper left hand corner (center of the first voxel
	 * transmitted) of the image, in mm.
	 * @param arrStrImagePosition String array of Image Orientation values.	
	 */
	public void setImagePosition(String[] arrStrImagePosition)
	{
		/*Accept the ImagePosition in String format of type DS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0020,0x0032, arrStrImagePosition,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0020,0x0032,DicomConstants.DCM_DT_DS, arrStrImagePosition);

		addDataElement(objIDataElement);
	}
	/**
	 * Retrieves the x, y, and z coordinates of the upper left hand corner (center of the first voxel
	 * transmitted) of the image, in mm.
	 * @return String array x, y, and z coordinates
	 */
	public String[] getImagePosition()
	{
		Object objValue = getValue(0x0020,0x0032);
		if(objValue != null)
			return (String[])objValue;
		return null;
	}

	/**
	 * Retrieves pre-initialized object of View Code Sequence.If the module contains the sequence object
	 * it returns the same otherwise it creates the sequence adds to the module with proper initialization
	 * and then returns the object of sequence.
	 * @return ViewCodeSequence - instance of ViewCodeSequence. 
	 */
	public ViewCodeSequence getViewCodeSequence()
	{
		ViewCodeSequence objViewCodeSequence = null;
		IDataElement objIDataElement =  getDataForTag(0x0018,0x002A);
		if(objIDataElement != null)
		{
			IDicomValue objIDicomValue = objIDataElement.getDicomValue();
			if(objIDicomValue != null)
				objViewCodeSequence = (ViewCodeSequence)objIDicomValue;
		}
		else
		{
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			int iVRTransferSyntax = objITransferSyntax.getVRTransferSyntax();
			objIDataElement = null;
			objViewCodeSequence = (ViewCodeSequence)objDicomV3Factory.createSequence(0x0018,0x002A, objITransferSyntax, objIDictionaryReader);

			if(iVRTransferSyntax == DicomConstants.DCM_VR_IMPLICIT)
				objIDataElement = new ImplicitDE(0x0018,0x002A, objViewCodeSequence.getValue(),objIDictionaryReader);
			else
				objIDataElement = new ExplicitDE(0x0018,0x002A, DicomConstants.DCM_DT_SQ, objViewCodeSequence.getValue());
			objIDataElement.setTransferSyntax(objITransferSyntax);
			if(objIDataElement != null)
				addDataElement(objIDataElement);
		}
		return objViewCodeSequence;
	}

	/**
	 * Validates all the attributes in Detector Information Sequence Item that are present in the DataSet
	 * @return boolean - Success -true, Failure - false
	 * @throws InvalidItemException throws InvalidItemException If Mandatory or Conditional element fails.
	 */
	public boolean validateForModule() throws InvalidItemException
	{
		try
		{
			if((getDataForTag(0x0008, 0x0008).getValue().equals(EnumImageType.Value4.TRANSMISSION))&&((getDataForTag(0x0008, 0x0008).getValue().equals(EnumImageType.Value3.TOMO))||
					(getDataForTag(0x0008, 0x0008).getValue().equals(EnumImageType.Value3.GATED_TOMO))||(getDataForTag(0x0008, 0x0008).getValue().equals(EnumImageType.Value3.RECON_TOMO))||
					(getDataForTag(0x0008, 0x0008).getValue().equals(EnumImageType.Value3.RECON_GATED_TOMO))))
					if(!contains(0x0018,0x1110))
						throw new ConditionFailedException("Required 0018,1110 if Image Type (0008,0008) Value 4 is TRANSMISSION and Value 3 is " +
								"not any of TOMO,GATED TOMO,RECON TOMO or RECON GATEDTOMO.");
						
			if(!contains(0x0018,0x1181))
				throw new MandatoryMissingException("0018,1181");
			if(!contains(0x0018,0x1182))	
				throw new MandatoryMissingException("0018,1182");
			if(!contains(0x0020,0x0037))
				throw new MandatoryMissingException("0020,0037");
			if(!contains(0x0020,0x0032))	
				throw new MandatoryMissingException("0020,0032");
			if(contains(0x0054,0x0220))
				getViewCodeSequence().validateForModule();
			/*
			 * Validation for attribute Distance Source to Detector(0018,1110) done at IOD level bcoz of module level dependency.
			 */

		}
		catch(ConditionFailedException ce)
		{
			if(DicomConfig.createInstance().isLoggingOn())
			{
				DicomLogger.getLogger().log(ce.getMessage());
			}
			throw new ValidationException(this.getClass().getSimpleName(),ce); 
		}
		catch( MandatoryMissingException me)
		{
			if(DicomConfig.createInstance().isLoggingOn())
			{
				DicomLogger.getLogger().log(me.getMessage());
			}
			throw new InvalidItemException(this.getClass().getSimpleName(),me);
		}
		return true;
	}

}
