/*******************************************************************************
 *  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.dicommodel.modules;



import cdac.medinfo.sdk.dcm30_04.baselibs.DerivationCodeSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.DicomV3Factory;
import cdac.medinfo.sdk.dcm30_04.baselibs.IconImageSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.RealWorldValueMappingSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ReferencedImageSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ReferencedImageSequenceItem;
import cdac.medinfo.sdk.dcm30_04.baselibs.SourceImageSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.SourceImageSequenceItem;
import cdac.medinfo.sdk.dcm30_04.baselibs.Tag;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataSet;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IItem;
import cdac.medinfo.sdk.dcm30_04.commoninterface.ITag;
import cdac.medinfo.sdk.dcm30_04.enums.EnumBurnedInAnnotation;
import cdac.medinfo.sdk.dcm30_04.enums.EnumLossyImageCompression;
import cdac.medinfo.sdk.dcm30_04.enums.EnumPatientOrientation;
import cdac.medinfo.sdk.dcm30_04.enums.EnumPresentationLUTShape;
import cdac.medinfo.sdk.dcm30_04.enums.EnumQualityControlImage;

import cdac.medinfo.sdk.dcm30_04.exceptions.ConditionFailedException;
import cdac.medinfo.sdk.dcm30_04.exceptions.InvalidDataTypeException;
import cdac.medinfo.sdk.dcm30_04.exceptions.InvalidModuleException;
import cdac.medinfo.sdk.dcm30_04.exceptions.ItemLimitException;
import cdac.medinfo.sdk.dcm30_04.exceptions.MandatoryMissingException;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConfig;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConstants;
import cdac.medinfo.sdk.dcm30_04.utils.DicomLogger;
import cdac.medinfo.sdk.dcm30_04.utils.ICollectionIterator;
import cdac.medinfo.sdk.dcm30_04.utils.ISingleCollection;
import cdac.medinfo.sdk.dcm30_04.utils.SingleCollection;

/**
 * This class specifies the Attributes that identify and describe an image within a particular series.
 */
public class GeneralImageModule extends Module  
{
	/**
	 * The obj single collection.
	 */
	public static ISingleCollection<ITag> objSingleCollection = null;


	/**
	 * Instantiates a new general image module.
	 * 
	 * @param objIDataSet the obj i data set
	 */
	public GeneralImageModule(IDataSet objIDataSet)
	{
		super(objIDataSet);
	}

	static
	{
		objSingleCollection = new SingleCollection<ITag>();
		objSingleCollection.add(new Tag(0x0008,0x0008));
		objSingleCollection.add(new Tag(0x0008,0x0022));
		objSingleCollection.add(new Tag(0x0008,0x0023));
		objSingleCollection.add(new Tag(0x0008,0x002A));
		objSingleCollection.add(new Tag(0x0008,0x0032));
		objSingleCollection.add(new Tag(0x0008,0x0033));
		objSingleCollection.add(new Tag(0x0008,0x113A));//SQ type Parent DE
		objSingleCollection.add(new Tag(0x0008,0x1140));//SQ type Parent DE
		objSingleCollection.add(new Tag(0x0008,0x2111));
		objSingleCollection.add(new Tag(0x0008,0x2112));//SQ type Parent DE
		objSingleCollection.add(new Tag(0x0008,0x9215));
		objSingleCollection.add(new Tag(0x0020,0x0012));
		objSingleCollection.add(new Tag(0x0020,0x0013));
		objSingleCollection.add(new Tag(0x0020,0x0020));
		objSingleCollection.add(new Tag(0x0020,0x1002));
		objSingleCollection.add(new Tag(0x0020,0x4000));
		objSingleCollection.add(new Tag(0x0028,0x0300));
		objSingleCollection.add(new Tag(0x0028,0x0301));
		objSingleCollection.add(new Tag(0x0028,0x2110));
		objSingleCollection.add(new Tag(0x0028,0x2112));
		objSingleCollection.add(new Tag(0x0028,0x2114));
		objSingleCollection.add(new Tag(0x0088,0x0200));
		objSingleCollection.add(new Tag(0x2050,0x0020));
		objSingleCollection.add(new Tag(0x0008,0x3010));
		objSingleCollection.add(new Tag(0x0040,0x9096));
	}

	/**
	 * This method validates each Attribute in the Module according to the Type
	 * of the Attribute.Attributes are of 5 types.
	 * Type 1,Type 2 are Mandatory:
	 * Mandatory Attributes have to present in the Module.
	 * Type 1C,2C are Conditional:
	 * Conditional Attributes' presence depend on a condition.
	 * If the condition is satisfied the Attribute has to be present.
	 * Type 3 are Optional
	 * Optional Attributes can be added as and when required.
	 * 
	 * @return - returns validation status as success or failure
	 * 
	 * @throws InvalidModuleException - If validation of Module fails
	 */
	public  boolean validateModule() throws InvalidModuleException
	{

		try
		{			/*
		 * Validation Rules for Mandatory Elements
		 */
			if(!isPresent(0x0020,0x0013))
				throw new MandatoryMissingException("0020,0013");

			/*
			 * Validation for attribute PatientOrientation(0020,0020) of GeneralImageModule is implemented at IOD level.
			 * condition :- Required if image does not require Image Orientation (Patient)(0020,0037) and Image Position (Patient)
			 * 				(0020,0032). See C.7.6.1.1.1 for further explanation.
			 * Right now we are taking it as if IOD contains any module which has (0020,0037) and (0020,0032)
			 * and if that module and attribute are compulsory then (0020,0020) is not mandatory.
			 * If no module is there in IOD then (0020,0020) is mandatory.
			 * and if attribute or module is optional or conditional then 0020,0020 is also conditional.
			 * Refer pdf 3 page 268
			 */

			if(isPresent(0x0020,0x0020))
			{
				String[] arrPatientOrientation = getPatientOrientation();
				if(arrPatientOrientation != null)
				{
					if(!(
							(EnumPatientOrientation.ANTERIOR.getValue().equals(arrPatientOrientation[0]) || (EnumPatientOrientation.ANTERIOR.getValue().equals(arrPatientOrientation[1])
									||EnumPatientOrientation.POSTERIOR.getValue().equals(arrPatientOrientation[0]) || EnumPatientOrientation.POSTERIOR.getValue().equals(arrPatientOrientation[1])
									||EnumPatientOrientation.RIGHT.getValue().equals(arrPatientOrientation[0]) || EnumPatientOrientation.RIGHT.getValue().equals(arrPatientOrientation[1])
									||EnumPatientOrientation.LEFT.getValue().equals(arrPatientOrientation[0]) || EnumPatientOrientation.LEFT.getValue().equals(arrPatientOrientation[1])
									||EnumPatientOrientation.HEAD.getValue().equals(arrPatientOrientation[0]) || EnumPatientOrientation.HEAD.getValue().equals(arrPatientOrientation[1])
									||EnumPatientOrientation.FOOT.getValue().equals(arrPatientOrientation[0]) || EnumPatientOrientation.FOOT.getValue().equals(arrPatientOrientation[1])))))

						throw new ConditionFailedException("0020,0020");
				}
			}
			if(isPresent(0x0008,0x1140))
			{
				getReferencedImageSequence().validateForModule();
				// Validation for PurposeOfReferenceCodeSequence 
				ICollectionIterator<IItem> objReferencedImageSequenceIterator = getReferencedImageSequence().iterator();
				ReferencedImageSequenceItem objReferencedImageSequenceItem = null;
				while(objReferencedImageSequenceIterator.hasNext())
				{
					objReferencedImageSequenceItem = (ReferencedImageSequenceItem)objReferencedImageSequenceIterator.next();
					if(objReferencedImageSequenceItem.contains(0x0040,0xA170))
					{
						int iNoOfItems = objReferencedImageSequenceItem.getPurposeOfReferenceCodeSequence().noOfItems();
						if(iNoOfItems > 1)
							throw new ItemLimitException("0040,A170 shall contain Single Item");
					}
				}
			}
			
			if(isPresent(0x0008,0x9215))
				getDerivationCodeSequence().validateForModule();
			if(isPresent(0x0008,0x2112))
			{
				getSourceImageSequence().validateForModule();
				// Validation for PurposeOfReferenceCodeSequence
				ICollectionIterator<IItem> objSourceImageSequenceIterator = getSourceImageSequence().iterator();
				SourceImageSequenceItem objSourceImageSequenceItem = null;
				while(objSourceImageSequenceIterator.hasNext())
				{
					objSourceImageSequenceItem = (SourceImageSequenceItem)objSourceImageSequenceIterator.next();
					if(objSourceImageSequenceItem.contains(0x0040,0xA170))
					{
						int iNoOfItems = objSourceImageSequenceItem.getPurposeOfReferenceCodeSequence().noOfItems();
						if(iNoOfItems > 1)
							throw new ItemLimitException("0040,A170 shall contain Single Item");
					}
				}
			}
			
			if(isPresent(0x0088,0x0200))
				getIconImageSequence().validateForModule();




			/*
			 * Removed code for validating the seuqence
			 */
		}
		catch(InvalidDataTypeException dte)
		{
			if(DicomConfig.createInstance().isLoggingOn())
				DicomLogger.getLogger().log(dte.getMessage());

			
				throw new InvalidModuleException(this.getClass().getSimpleName(),dte);

		}
		catch(ConditionFailedException cfe)
		{
			if(DicomConfig.createInstance().isLoggingOn())
				DicomLogger.getLogger().log(cfe.getMessage());

			
				throw new InvalidModuleException(this.getClass().getSimpleName(),cfe);

		}
		catch(MandatoryMissingException mme)
		{
			if(DicomConfig.createInstance().isLoggingOn())
				DicomLogger.getLogger().log(mme.getMessage());

			
				throw new InvalidModuleException(this.getClass().getSimpleName(),mme);

		}
		catch(ItemLimitException ile)
		{
			if(DicomConfig.createInstance().isLoggingOn())
				DicomLogger.getLogger().log(ile.getMessage());

			
				throw new InvalidModuleException(this.getClass().getSimpleName(),ile);

		}
		return true;
	}

	/**
	 * The method is used to set A number that identifies this image.
	 * The function accepts a String Value and creates the
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This De is then added to the Module HashMap
	 * 
	 * @param strInstanceNumber - String value of Instance Number
	 */
	public void setInstanceNumber(String strInstanceNumber)
	{
		/* Accept Instance Numberin 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
		 */
		addDataElement(0x0020, 0x0013, DicomConstants.DCM_DT_IS, strInstanceNumber);
	}

	/**
	 * The method is used to set Patient direction of the rows and columns of the image.
	 * The function accepts a String Value and creates the
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This De is then added to the Module HashMap
	 * 
	 * @param enumStrPatientOrientation the enum str patient orientation
	 */
	public void setPatientOrientation(EnumPatientOrientation[] enumStrPatientOrientation)
	{
		/*Accept  Patient direction of the rows and columns of the image.
		 * in String Array format of type CS.
		 * Read the Transfer Syntax and check to create ImplicitDE or ExplicitDE .
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Hash Map
		 */
		String[] arrStrPatientOrientation = new String[enumStrPatientOrientation.length];
		for(int i=0;i < enumStrPatientOrientation.length ; i++)
		{
			arrStrPatientOrientation[i] = enumStrPatientOrientation[i].getValue();
		}
		addDataElement(0x0020, 0x0020, DicomConstants.DCM_DT_CS, arrStrPatientOrientation);
	}

	/**
	 * The method is used to set The date on image pixel data creation started.
	 * The function accepts a String Value and creates the
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This De is then added to the Module HashMap
	 * 
	 * @param strContentDate - String value of Content Date
	 */
	public void setContentDate(String strContentDate)
	{
		/*Accept The date on image pixel data creation started in String format of type DA.
		 * 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 Hash Map
		 */
		addDataElement(0x0008,0x0023, DicomConstants.DCM_DT_DA, strContentDate);
	}

	/**
	 * The method is used to set The time at which image pixel data creation started.
	 * The function accepts a String Value and creates the
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This De is then added to the Module HashMap
	 * 
	 * @param strContentTime - String value of Content Time
	 */
	public void setContentTime(String strContentTime)
	{
		/*Accept The Time at which image pixel data creation started in String format of type DA.
		 * 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 Hash Map
		 */
		addDataElement(0x0008, 0x0033, DicomConstants.DCM_DT_TM, strContentTime);
	}

	/**
	 * This method is used to set Image identification characteristics.
	 * The function accepts a String Value and creates the
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This De is then added to the Module HashMap
	 * 
	 * @param arrStrImageType - Image identification characteristics.
	 */	
	public void setImageType(String[] arrStrImageType)
	{
		/*Accept Image identification characteristics in String Array format of type CS.
		 * Read the Transfer Syntax and check to create ImplicitDE or ExplicitDE .
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Hash Map
		 */
		addDataElement(0x0008, 0x0008, DicomConstants.DCM_DT_CS, arrStrImageType);
	}

	/**
	 * The method is used to set A number identifying the single continuous gathering of data over a period of time that resulted in this image.
	 * The function accepts a String Value and creates the
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This De is then added to the Module HashMap
	 * 
	 * @param strAcquisitionNumber - String value of Acquisition Number
	 */
	public void setAcquisitionNumber(String strAcquisitionNumber)
	{
		/*Accept number identifying the single continuous gathering of data
		 * 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 Hash Map
		 */
		addDataElement(0x0020, 0x0012, DicomConstants.DCM_DT_IS, strAcquisitionNumber);
	}

	/**
	 * The method is used to set The date the acquisition of data that resulted in this image started
	 * The function accepts a String Value and creates the
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This De is then added to the Module HashMap
	 * 
	 * @param strAcquisitionDate - String value of Acquisition Date
	 */
	public void setAcquisitionDate(String strAcquisitionDate)
	{
		/*Accept The date the acquisition of data that resulted in this image started in String format of type DA.
		 * 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 Hash Map
		 */
		addDataElement(0x0008, 0x0022, DicomConstants.DCM_DT_DA, strAcquisitionDate);
	}

	/**
	 * The method is used to set The Time the acquisition of data that resulted in this image started
	 * The function accepts a String Value and creates the
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This De is then added to the Module HashMap
	 * 
	 * @param strAcquisitionTime - String value of Acquisition Time
	 */
	public void setAcquisitionTime(String strAcquisitionTime)
	{
		/*Accept The Time the acquisition of data that resulted in this image started in String format of type TM.
		 * 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 Hash Map
		 */
		addDataElement(0x0008, 0x0032, DicomConstants.DCM_DT_TM, strAcquisitionTime);
	}

	/**
	 * The method is used to set The Date and Time the acquisition of data that resulted in this image started
	 * The function accepts a String Value and creates the
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This De is then added to the Module HashMap
	 * 
	 * @param strAcquisitionDatetime - String value of Acquisition Date and Time
	 */
	public void setAcquisitionDatetime(String strAcquisitionDatetime)
	{
		/*Accept The Date and Time the acquisition of data that resulted in this image started in String format of type TM.
		 * 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 Hash Map
		 */
		addDataElement(0x0008, 0x002A, DicomConstants.DCM_DT_DT, strAcquisitionDatetime);
	}

	/**
	 * The method is used to set A text description of how this image was derived.
	 * The function accepts a String Value and creates the
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This De is then added to the Module HashMap
	 * 
	 * @param strDerivationDescription - String value of Derivation Description
	 */
	public void setDerivationDescription(String strDerivationDescription)
	{
		/*AcceptA text description of how this image was derived in String format of type ST.
		 * 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 Hash Map
		 */
		addDataElement(0x0008, 0x2111, DicomConstants.DCM_DT_ST, strDerivationDescription);
	}

	/**
	 * The method is used to set Number of images that resulted from this acquisition of data
	 * The function accepts a String Value and creates the
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This De is then added to the Module HashMap
	 * 
	 * @param strImagesInAcquisition - String value of Images In Acquisition
	 */
	public void setImagesInAcquisition(String strImagesInAcquisition)
	{
		/*Accept Number of images that resulted from this acquisition of data 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 Hash Map
		 */
		addDataElement(0x0020, 0x1002, DicomConstants.DCM_DT_IS, strImagesInAcquisition);
	}

	/**
	 * The method is used to set User-defined comments about the image
	 * The function accepts a String Value and creates the
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This De is then added to the Module HashMap
	 * 
	 * @param strImageComments - String value of Image Comments
	 */
	public void setImageComments(String strImageComments)
	{
		/*Accept the Image Comments in String format of type LT.
		 * 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
		 */
		addDataElement(0x0020, 0x4000, DicomConstants.DCM_DT_LT, strImageComments);
	}

	/**
	 * The method is used to set whether or not this image is a quality control or phantom image.
	 * The function accepts a String Value and creates the
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This De is then added to the Module HashMap
	 * Enumerated Values:
	 * YES
	 * NO
	 * 
	 * @param enumQualityControlImage the enum quality control image
	 */
	public void setQualityControlImage(EnumQualityControlImage enumQualityControlImage)
	{
		/*Accept whether or not this image is a quality control or phantom image 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 Hash Map
		 */
		addDataElement(0x0028, 0x0300, DicomConstants.DCM_DT_CS, enumQualityControlImage.getValue());
	}

	/**
	 * The method is used to set Indicates whether or not image contains
	 * sufficient burned in annotation to identify the patient and date the image was acquired.
	 * The function accepts a String Value and creates the
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This De is then added to the Module HashMap
	 * Enumerated Values:
	 * YES
	 * NO
	 * 
	 * @param enumBurnedInAnnotation - Enum value of Burned In Annotation(Yes or No)
	 */
	public void setBurnedInAnnotation(EnumBurnedInAnnotation enumBurnedInAnnotation)
	{
		/*Accept Indicates whether or not image contains 
		 * sufficient burned in annotation to identify the patient and date the image was acquired 
		 * 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 Hash Map
		 */
		addDataElement(0x0028, 0x0301, DicomConstants.DCM_DT_CS, enumBurnedInAnnotation.getValue());
	}

	/**
	 * The method is used to set Specifies whether an Image has undergone lossy compression.
	 * The function accepts a String Value and creates the
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This De is then added to the Module HashMap
	 * Enumerated values:
	 * 00 = Image has NOT been subjected to lossy compression.
	 * 01 = Image has been subjected to lossy compression.
	 * 
	 * @param enumLossyImageCompression the enum lossy image compression
	 */
	public void setLossyImageCompression(EnumLossyImageCompression enumLossyImageCompression)
	{
		/*Accept Specifies whether an Image has undergone lossy compression.
		 * 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 Hash Map
		 */
		addDataElement(0x0028, 0x2110, DicomConstants.DCM_DT_CS, enumLossyImageCompression.getValue());
	}

	/**
	 * The method is used to set the approximate lossy compression ratio(s) that have been applied to this image.
	 * The function accepts a String Value and creates the
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This De is then added to the Module HashMap
	 * 
	 * @param arrStrLossyImageCompressionRatio - String value of Lossy Image Compression Ratio
	 */
	public void setLossyImageCompressionRatio(String[] arrStrLossyImageCompressionRatio)
	{
		/*Accept the approximate lossy compression ratio(s) that have been applied to this image.
		 * 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 Hash Map
		 */
		addDataElement(0x0028, 0x2112, DicomConstants.DCM_DT_DS, arrStrLossyImageCompressionRatio);
	}

	/**
	 * The method is used to set lossy compression method(s) that have been applied to this image.
	 * The function accepts a String Value and creates the
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This De is then added to the Module HashMap
	 * 
	 * @param arrStrLossyImageCompressionMethod - Lossy Image Compression Method
	 */
	public void setLossyImageCompressionMethod(String[] arrStrLossyImageCompressionMethod)
	{
		/*Accept lossy compression method(s) that have been applied to this image
		 * 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 Hash Map
		 */
		addDataElement(0x0028, 0x2114, DicomConstants.DCM_DT_CS, arrStrLossyImageCompressionMethod);
	}

	/**
	 * The method is used to set identity transformation for the Presentation LUT.
	 * The function accepts a String Value and creates the
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This De is then added to the Module HashMap
	 * Enumerated Values are:
	 * IDENTITY - output is in P-Values - shall be used if Photometric Interpretation (0028,0004) is MONOCHROME2 or any color photometric interpretation.
	 * INVERSE - output after inversion is in PValues - shall be used if Photometric Interpretation (0028,0004) is MONOCHROME1.
	 * 
	 * @param enumPresentationLUTShape the enum presentation lut shape
	 */
	public void setPresentationLUTShape(EnumPresentationLUTShape enumPresentationLUTShape)
	{
		/*Accept identity transformation for the Presentation LUT 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 Hash Map
		 * Enumerated Values are:
			IDENTITY - output is in P-Values - shall
			be used if Photometric Interpretation
			(0028,0004) is MONOCHROME2 or any
			color photometric interpretation.
			INVERSE - output after inversion is in PValues
			- shall be used if Photometric
			Interpretation (0028,0004) is
			MONOCHROME1.
		 */
		addDataElement(0x2050, 0x0020, DicomConstants.DCM_DT_CS, enumPresentationLUTShape.getValue());
	}
	
	/**
	 * Sets Irradiation Event UID.
	 * Unique identification of the irradiation event(s) associated with the acquisition of this image.
	 * @param strIrradiationEventUID - Irradiation Event UID.
	 * 
	 * 
	 */
	public void setIrradiationEventUID(String strIrradiationEventUID)
	{
		/*Accept Irradiation Event UID in String format of type UI.
		 * 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 Hash Map
		 */
		addDataElement(0x0008, 0x3010, DicomConstants.DCM_DT_UI, strIrradiationEventUID);
	}


	/**
	 * This method Returns provides the pre-initialized object of Referenced Image Sequence
	 * return - object of Referenced Image Sequence. If the module contans the sequence object
	 * it retruns the same otherwise it creates the sequence adds to the module with proper initialization
	 * and then returns the object of sequence
	 * 
	 * @return ReferencedImageSequence - the referenced image sequence
	 */
	public ReferencedImageSequence getReferencedImageSequence()
	{
		ReferencedImageSequence objReferencedImageSequence = (ReferencedImageSequence)getDicomValue(0x0008, 0x1140);
		if(objReferencedImageSequence == null)
		{
			/*
			 * If the sequence object is not present in the DataSet, a new sequence object is created and
			 * the TransferSyntax and DictionaryReader is set into it as it is set in the Module. This ensures that 
			 * the DataElements getting added in the DataSet follow the same TransferSyntax and use the same
			 * DictionaryReader object as that of the module.
			 */
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			objReferencedImageSequence = (ReferencedImageSequence)objDicomV3Factory.createSequence(0x0008, 0x1140, objITransferSyntax, objIDictionaryReader);
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0008, 0x1140, DicomConstants.DCM_DT_SQ, objReferencedImageSequence.getValue());
		}
		return objReferencedImageSequence;
	}

	/**
	 * Retrieves the derivation description.
	 * 
	 * @return String - the derivation description
	 */
	public String getDerivationDescription()
	{
		Object objValue = objIDataSet.getValue(0x0008, 0x2111);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * This method Returns provides the pre-initialized object of Derivation Code Sequence
	 * return - object of Derivation Code Sequence. If the module contans the sequence object
	 * it retruns the same otherwise it creates the sequence adds to the module with proper initialization
	 * and then returns the object of sequence
	 * 
	 * @return DerivationCodeSequence - the derivation code sequence
	 */
	public DerivationCodeSequence getDerivationCodeSequence()
	{
		DerivationCodeSequence objDerivationCodeSequence = (DerivationCodeSequence)getDicomValue(0x0008, 0x9215);
		if(objDerivationCodeSequence == null)
		{
			/*
			 * If the sequence object is not present in the DataSet, a new sequence object is created and
			 * the TransferSyntax and DictionaryReader is set into it as it is set in the Module. This ensures that 
			 * the DataElements getting added in the DataSet follow the same TransferSyntax and use the same
			 * DictionaryReader object as that of the module.
			 */
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			objDerivationCodeSequence = (DerivationCodeSequence)objDicomV3Factory.createSequence(0x0008, 0x9215, objITransferSyntax, objIDictionaryReader);
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0008, 0x9215, DicomConstants.DCM_DT_SQ, objDerivationCodeSequence.getValue());
		}
		return objDerivationCodeSequence;
	}

	/**
	 * This method Returns provides the pre-initialized object of Source Image Sequence
	 * return - object of Source Image Sequence. If the module contans 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 SourceImageSequence - the source image sequence
	 */
	public SourceImageSequence getSourceImageSequence()
	{
		SourceImageSequence objSourceImageSequence = (SourceImageSequence)getDicomValue(0x0008, 0x2112);
		if(objSourceImageSequence == null)
		{
			/*
			 * If the sequence object is not present in the DataSet, a new sequence object is created and
			 * the TransferSyntax and DictionaryReader is set into it as it is set in the Module. This ensures that 
			 * the DataElements getting added in the DataSet follow the same TransferSyntax and use the same
			 * DictionaryReader object as that of the module.
			 */
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			objSourceImageSequence = (SourceImageSequence)objDicomV3Factory.createSequence(0x0008, 0x2112, objITransferSyntax, objIDictionaryReader);
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0008, 0x2112, DicomConstants.DCM_DT_SQ, objSourceImageSequence.getValue());
		}
		return objSourceImageSequence;
	}

	/**
	 * This method Returns provides the pre-initialized object of Icon Image Sequence
	 * return - object of Icon Image 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 IconImageSequence - the icom image sequence
	 */
	public IconImageSequence getIconImageSequence()
	{
		IconImageSequence objIconImageSequence = (IconImageSequence)getDicomValue(0x0088, 0x0200);
		if(objIconImageSequence == null)
		{
			/*
			 * If the sequence object is not present in the DataSet, a new sequence object is created and
			 * the TransferSyntax and DictionaryReader is set into it as it is set in the Module. This ensures that 
			 * the DataElements getting added in the DataSet follow the same TransferSyntax and use the same
			 * DictionaryReader object as that of the module.
			 */
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			objIconImageSequence = (IconImageSequence)objDicomV3Factory.createSequence(0x0088, 0x0200, objITransferSyntax, objIDictionaryReader);
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0088, 0x0200, DicomConstants.DCM_DT_SQ, objIconImageSequence.getValue());
		}
		return objIconImageSequence;
	}

	/**
	 * Retrieves the Images In Acquisition.
	 * 
	 * @return String - returns the Images In Acquisition
	 */
	public String getImagesInAcquisition()
	{
		Object objValue = objIDataSet.getValue(0x0020, 0x1002);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Retrieves the Image Contents.
	 * 
	 * @return String - returns the image contents
	 */
	public String getImageComments()
	{
		Object objValue = objIDataSet.getValue(0x0020, 0x4000);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Retrieves the Quality Control Image.
	 * 
	 * @return String - the Quality Control Image
	 */
	public String getQualityControlImage()
	{
		Object objValue = objIDataSet.getValue(0x0028, 0x0300);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Retrieves the Burned In Annotation.
	 * 
	 * @return String - the Burned In Annotation
	 */
	public String getBurnedInAnnotation()
	{
		Object objValue = objIDataSet.getValue(0x0028, 0x0301);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Retrieves the Lossy Image Compression.
	 * 
	 * @return String - the Lossy Image Compression
	 */
	public String getLossyImageCompression()
	{
		Object objValue = objIDataSet.getValue(0x0028, 0x2110);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Retrieves the Lossy Image Compression Ratio.
	 * 
	 * @return String[] - the Lossy Image Compression Ratio
	 */
	public String[] getLossyImageCompressionRatio()
	{
		Object objValue = objIDataSet.getValue(0x0028, 0x2112);
		if(objValue != null)
			return (String[])objValue;
		return null;
	}

	/**
	 * Retrieves the Lossy Image Compression Method.
	 * 
	 * @return String[] - the Lossy Image Compression Method
	 */
	public String[] getLossyImageCompressionMethod()
	{
		Object objValue = objIDataSet.getValue(0x0028, 0x2114);
		if(objValue != null)
			return (String[])objValue;
		return null;
	}

	/**
	 * Retrieves the Presentation LUT shape.
	 * 
	 * @return String - the Presentation LUT shape
	 */
	public String getPresentationLUTShape()
	{
		Object objValue = objIDataSet.getValue(0x2050, 0x0020);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Retrieves the Instance number.
	 * 
	 * @return String - the instance number
	 */
	public String getInstanceNumber()
	{
		Object objValue = objIDataSet.getValue(0x0020, 0x0013);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Retrieves the Patient Orientation.
	 * 
	 * @return String[] - the Patient Orientation
	 */
	public String[] getPatientOrientation()
	{
		Object objValue = objIDataSet.getValue(0x0020, 0x0020);
		if(objValue != null)
			return (String[])objValue;
		return null;
	}

	/**
	 * Retrieves the Content Date.
	 * 
	 * @return String - the Content Date
	 */
	public String getContentDate()
	{
		Object objValue = objIDataSet.getValue(0x0008, 0x0023);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Retrieves the Content Time.
	 * 
	 * @return String - the Content Time
	 */
	public String getContentTime()
	{
		Object objValue = objIDataSet.getValue(0x0008, 0x0033);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Retrieves the Tmage Type.
	 * 
	 * @return String[] - the Image Type
	 */
	public String[] getImageType()
	{
		Object objValue = objIDataSet.getValue(0x0008, 0x0008);
		if(objValue != null)
			return (String[])objValue;
		return null;
	}

	/**
	 * Retrieves the Acquisition Number.
	 * 
	 * @return String - Acquisition Number
	 */
	public String getAcquisitionNumber()
	{
		Object objValue = objIDataSet.getValue(0x0020, 0x0012);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Retrieves the Date and Date of Acquisition.
	 * 
	 * @return String - the Date of Acquisition
	 */
	public String getAcquisitionDate()
	{
		Object objValue = objIDataSet.getValue(0x0008, 0x0022);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Retrieves the Date and Time of Acquisition.
	 * 
	 * @return String - the Time of Acquisition
	 */
	public String getAcquisitionTime()
	{
		Object objValue = objIDataSet.getValue(0x0008, 0x0032);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Retrieves the Date and Time of Acquisition.
	 * 
	 * @return String - returns the Date and Time of Acquisition
	 */
	public String getAcquisitionDatetime()
	{
		Object objValue = objIDataSet.getValue(0x0008, 0x002A);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Retrieves the Irradiation Event UID.
	 * Unique identification of the irradiation event(s) associated with the acquisition of this image.
	 * @return - returns the Irradiation Event UID
	 */
	public String getIrradiationEventUID()
	{
		Object objectValue = getValue(0x0008, 0x3010);
		if(objectValue!=null)
			return objectValue.toString();
		return null;
	}

	/**
	 * This method provides the pre-initialized object of Real World Value Mapping Sequence.
	 * 
	 * @return - object of Real World Value Mapping 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
	 */
	public RealWorldValueMappingSequence getRealWorldValueMappingSequence()
	{
		RealWorldValueMappingSequence objRealWorldValueMappingSequence = (RealWorldValueMappingSequence)getDicomValue(0x0040, 0x9096);
		if(objRealWorldValueMappingSequence == null)
		{
			/*
			 * If the sequence object is not present in the DataSet, a new sequence object is created and
			 * the TransferSyntax and DictionaryReader is set into it as it is set in the Module. This ensures that 
			 * the DataElements getting added in the DataSet follow the same TransferSyntax and use the same
			 * DictionaryReader object as that of the module.
			 */
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			objRealWorldValueMappingSequence = (RealWorldValueMappingSequence)objDicomV3Factory.createSequence(0x0040, 0x9096, objITransferSyntax, objIDictionaryReader);
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0040, 0x9096, DicomConstants.DCM_DT_SQ, objRealWorldValueMappingSequence.getValue());
		}
		return objRealWorldValueMappingSequence;
	}

	/**
	 * This method returns the custom collection containing the list of DataElements belonging to the CT
	 * Image Module specified by DICOM Standard.
	 * 
	 * @return ISingleCollection - custom collection containing the list of DataElements belonging to the CT Image Module
	 */
	public ISingleCollection<ITag> getVectorOfKeys()
	{
		return objSingleCollection;
	}
}
