/*******************************************************************************
 *  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.
 *******************************************************************************/
/**
 * 
 * This class specifies Attributes that identify and describe general information about the Series within a Study.
 */
package cdac.medinfo.sdk.dcm30_04.dicommodel.modules;



import cdac.medinfo.sdk.dcm30_04.baselibs.DicomV3Factory;
import cdac.medinfo.sdk.dcm30_04.baselibs.OperatorIdentificationSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.PerformedProtocolCodeSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.PerformingPhysicianIdentificationSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ReferencedPerformedProcedureStepSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.RelatedSeriesSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.RequestAttributesSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.SeriesDescriptionCodeSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.Tag;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataSet;
import cdac.medinfo.sdk.dcm30_04.commoninterface.ITag;
import cdac.medinfo.sdk.dcm30_04.enums.EnumAnatomicalOrientationType;
import cdac.medinfo.sdk.dcm30_04.enums.EnumBodyPartExamined;
import cdac.medinfo.sdk.dcm30_04.enums.EnumLaterality;
import cdac.medinfo.sdk.dcm30_04.enums.EnumModality;
import cdac.medinfo.sdk.dcm30_04.enums.EnumPatientPosition;

import cdac.medinfo.sdk.dcm30_04.exceptions.ConditionFailedException;
import cdac.medinfo.sdk.dcm30_04.exceptions.InvalidModuleException;
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;
import cdac.medinfo.sdk.dcm30_04.utils.ISingleCollection;
import cdac.medinfo.sdk.dcm30_04.utils.SingleCollection;

//TODO: Auto-generated Javadoc
/*
 * The module holds its map of data in a collection wrapper called SingleCollection
 */
/**
 \* The class GeneralSeriesModule.
 */
public class GeneralSeriesModule extends Module  
{


	/**
	 * The obj single collection.
	 */
	public static ISingleCollection<ITag> objSingleCollection = null;


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

	static
	{
		objSingleCollection = new SingleCollection<ITag>();
		objSingleCollection.add(new Tag(0x0008,0x0021));
		objSingleCollection.add(new Tag(0x0008,0x0031));
		objSingleCollection.add(new Tag(0x0008,0x0060));
		objSingleCollection.add(new Tag(0x0008,0x103E));
		objSingleCollection.add(new Tag(0x0008,0x103F));
		objSingleCollection.add(new Tag(0x0008,0x1050));
		objSingleCollection.add(new Tag(0x0008,0x1052));
		objSingleCollection.add(new Tag(0x0008,0x1070));
		objSingleCollection.add(new Tag(0x0008,0x1072));
		objSingleCollection.add(new Tag(0x0008,0x1111));
		objSingleCollection.add(new Tag(0x0008,0x1250));
		objSingleCollection.add(new Tag(0x0018,0x0015));
		objSingleCollection.add(new Tag(0x0018,0x1030));
		objSingleCollection.add(new Tag(0x0018,0x5100));
		objSingleCollection.add(new Tag(0x0020,0x000E));
		objSingleCollection.add(new Tag(0x0020,0x0011));
		objSingleCollection.add(new Tag(0x0020,0x0060));
		objSingleCollection.add(new Tag(0x0028,0x0108));
		objSingleCollection.add(new Tag(0x0028,0x0109));
		objSingleCollection.add(new Tag(0x0040,0x0244));
		objSingleCollection.add(new Tag(0x0040,0x0245));
		objSingleCollection.add(new Tag(0x0040,0x0253));
		objSingleCollection.add(new Tag(0x0040,0x0254));
		objSingleCollection.add(new Tag(0x0040,0x0260));
		objSingleCollection.add(new Tag(0x0040,0x0275));
		objSingleCollection.add(new Tag(0x0040,0x0280));
		objSingleCollection.add(new Tag(0x0010,0x2210));
	}

	/**
	 * Sets the modality.
	 * 
	 * @param enumModality the enum modality
	 * 
	 * 
	 * This method is used to set the Modality in General Series Module.
	 * The function accepts a String Value as the Modality 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
	 */	
	public void setModality(EnumModality enumModality)
	{
		/*Accept the Modality value 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(0x0008, 0x0060, DicomConstants.DCM_DT_CS, enumModality.getValue());
	}

	/**
	 * Retrieves Modality.
	 * 
	 * @return String - String value of Modality.
	 */
	public String getModality()
	{
		Object objValue = objIDataSet.getValue(0x0008, 0x0060);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * This method is used to set the Series Instance UID in General Series Module.
	 * The function accepts a String Value as the Series Instance UID 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 strSeriesInstanceUID : Unique identifier of the Series.
	 */	
	public void setSeriesInstanceUID(String strSeriesInstanceUID)
	{
		/*Accept the Series Instance UID value 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(0x0020, 0x000E, DicomConstants.DCM_DT_UI, strSeriesInstanceUID);
	}

	/**
	 * Retrieves Series Instance UID.
	 * 
	 * @return String - String value of SeriesInstanceUID.
	 */
	public String getSeriesInstanceUID()
	{
		Object objValue = objIDataSet.getValue(0x0020, 0x000E);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets the series number.
	 * 
	 * @param strSeriesNumber : Series Number
	 * 
	 * This method is used to set the Series Number in General Series Module.
	 * The function accepts a String Value as the Series Number 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
	 */	
	public void setSeriesNumber(String strSeriesNumber)
	{
		/*Accept the Series Number value 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, 0x0011, DicomConstants.DCM_DT_IS, strSeriesNumber);
	}

	/**
	 * Retrieves Series Number.
	 * 
	 * @return String - String value of SeriesNumber.
	 */
	public String getSeriesNumber()
	{
		Object objValue = objIDataSet.getValue(0x0020, 0x0011);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets the laterality.
	 * 
	 * @param enumLaterality :Laterality of (paired) body part examined.
	 * Required if the body part examined is a paired structure
	 * and Image Laterality (0020,0062) or Frame Laterality
	 * (0020,9072) are not sent. Enumerated Values:R = right L = left
	 * 
	 * 
	 * This method is used to set the Laterality in General Series Module.
	 * The function accepts a String Value as the Laterality 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
	 */	
	public void setLaterality(EnumLaterality enumLaterality)
	{
		/*Accept the Series Number value 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, 0x0060, DicomConstants.DCM_DT_CS, enumLaterality.getValue());
	}	

	/**
	 * Retrieves Laterality.
	 * 
	 * @return String - String value of Laterality
	 */
	public String getLaterality()
	{
		Object objValue = objIDataSet.getValue(0x0020, 0x0060);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets the series date.
	 * 
	 * @param strSeriesDate : Date the Series started.
	 * 
	 * 
	 * This method is used to set the Series Date in General Series Module.
	 * The function accepts a String Value as the Series Date 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
	 */	
	public void setSeriesDate(String strSeriesDate)
	{
		/*Accept the Series Date value 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, 0x0021, DicomConstants.DCM_DT_DA, strSeriesDate);
	}

	/**
	 * Retrieves Series Date.
	 * 
	 * @return String - String value of SeriesDate
	 */
	public String getSeriesDate()
	{
		Object objValue = objIDataSet.getValue(0x0008, 0x0021);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets the series time.
	 * 
	 * @param strSeriesTime : Time the Series started.
	 * 
	 * 
	 * This method is used to set the Series Time in General Series Module.
	 * The function accepts a String Value as the Series Time 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
	 */	
	public void setSeriesTime(String strSeriesTime)
	{
		/*Accept the Series Time value 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, 0x0031, DicomConstants.DCM_DT_TM, strSeriesTime);
	}

	/**
	 * Retrieves Series Time.
	 * 
	 * @return String - String value of Series Time.
	 */
	public String getSeriesTime()
	{
		Object objValue = objIDataSet.getValue(0x0008, 0x0031);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets the performing physician names.
	 * 
	 * @param arrStrPerformingPhysicianNames : Name of the physician(s) administering the
	 * Series.
	 * 
	 * 
	 * This method is used to set the Performing Physicians' Names in General Series Module.
	 * The function accepts a String Array Value as the Series Time 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
	 */	
	public void setPerformingPhysicianNames(String[] arrStrPerformingPhysicianNames)
	{
		/*Accept the Performing Physician Names value in String Array format of type PN.
		 * 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, 0x1050, DicomConstants.DCM_DT_PN, arrStrPerformingPhysicianNames);
	}

	/**
	 * Retrieves Performing Physician Names.
	 * 
	 * @return String[] - String array of PerformingPhysicianNames.
	 */
	public String[] getPerformingPhysicianNames()
	{
		Object objValue = objIDataSet.getValue(0x0008, 0x1050);
		if(objValue != null)
			return (String[]) objValue;
		return null;
	}

	/**
	 * Sets the protocol name.
	 * 
	 * @param strProtocolName : User-defined description of the conditions
	 * under which the Series was performed.
	 * 
	 * 
	 * This method is used to set the Protocol Name in General Series Module.
	 * The function accepts a String Value as the Protocol Name 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
	 */
	public void setProtocolName(String strProtocolName)
	{
		/*Accept the Protocol Name value in String format of type LO.
		 * 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 Module Hash Map
		 */
		addDataElement(0x0018, 0x1030, DicomConstants.DCM_DT_LO, strProtocolName);
	}

	/**
	 * Retrieves Protocol Name.
	 * 
	 * @return String - String value of Protocol Name.
	 */
	public String getProtocolName()
	{
		Object objValue = objIDataSet.getValue(0x0018, 0x1030);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets the series description.
	 * 
	 * @param strSeriesDescription : User provided description of the Series
	 * 
	 * 
	 * This method is used to set the Series Description in General Series Module.
	 * 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
	 */
	public void setSeriesDescription(String strSeriesDescription)
	{
		/*Accept the Series Description value in String format of type LO.
		 * 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 Module Hash Map
		 */
		addDataElement(0x0008, 0x103E, DicomConstants.DCM_DT_LO, strSeriesDescription);
	}

	/**
	 * Retrieves Series Description.
	 * 
	 * @return String - String value of SeriesDescription.
	 */
	public String getSeriesDescription()
	{
		Object objValue = objIDataSet.getValue(0x0008, 0x103E);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * This method provides the pre-initialized object of Series Description Code Sequence.
	 * 
	 * @return - object of Series Description 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
	 */
	public SeriesDescriptionCodeSequence getSeriesDescriptionCodeSequence()
	{
		SeriesDescriptionCodeSequence objSeriesDescriptionCodeSequence = (SeriesDescriptionCodeSequence)getDicomValue(0x0008, 0x103F);
		if(objSeriesDescriptionCodeSequence == 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();
			objSeriesDescriptionCodeSequence = (SeriesDescriptionCodeSequence)objDicomV3Factory.createSequence(0x0008, 0x103F, objITransferSyntax, objIDictionaryReader);
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0008, 0x103F, DicomConstants.DCM_DT_SQ, objSeriesDescriptionCodeSequence.getValue());
		}
		return objSeriesDescriptionCodeSequence;
	}

	/**
	 * Sets the operator names.
	 * 
	 * @param arrStrOperatorNames : Name(s) of the operator(s) supporting the Series.
	 * 
	 * 
	 * This method is used to set the Operator Names in General Series Module.
	 * The function accepts a String Array Value as the Series Time 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.
	 */	
	public void setOperatorNames(String[] arrStrOperatorNames)
	{
		/*Accept the Operator Names value in String Array format of type PN.
		 * 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, 0x1070, DicomConstants.DCM_DT_PN, arrStrOperatorNames);
	}

	/**
	 * Retrieves Operator Names.
	 * @return String[] - String array of OperatorNames.
	 */
	public String[] getOperatorNames()
	{
		Object objValue = objIDataSet.getValue(0x0008, 0x1070);
		if(objValue != null)
			return (String[])objValue;
		return null;
	}

	/**
	 * Sets the body part examined.
	 * 
	 * @param enumBodyPartExamined : Text description of the part of the body examined.
	 * Defined Terms:SKULL, CSPINE, TSPINE, LSPINE,SSPINE, COCCYX,
	 * CHEST, CLAVICLE,BREAST,ABDOMEN,PELVIS, HIP,SHOULDER, ELBOW,
	 * KNEE, ANKLE,HAND,FOOT, EXTREMITY, HEAD,HEART, NECK, LEG, ARM, JAW.
	 * 
	 * 
	 * setBodyPartExamined method is used to set the Body Part Examined in General Series Module.
	 * The function accepts a String Value as the Body Part Examined 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
	 */	
	public void setBodyPartExamined(EnumBodyPartExamined enumBodyPartExamined)
	{
		/*Accept the Body Part Examined value 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(0x0018, 0x0015, DicomConstants.DCM_DT_CS, enumBodyPartExamined.getValue());
	}

	/**
	 * Retrieves Body Part Examined.
	 * 
	 * @return String - String value of Body part Examined.
	 */
	public String getBodyPartExamined()
	{
		Object objValue = objIDataSet.getValue(0x0018, 0x0015);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets the patient position.
	 * 
	 * @param enumPatientPosition the enum patient position
	 * 
	 * 
	 * setPatientPosition method is used to set the Patient Position in General Series Module.
	 * The function accepts a String Value as the Patient Position 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
	 */	
	public void setPatientPosition(EnumPatientPosition enumPatientPosition)
	{
		/*Accept the Patient Position value 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(0x0018, 0x5100, DicomConstants.DCM_DT_CS, enumPatientPosition.getValue());
	}

	/**
	 * Retrieves Patient Position.
	 * 
	 * @return String - String value of Patient Position.
	 */
	public String getPatientPosition()
	{
		Object objValue = objIDataSet.getValue(0x0018, 0x5100);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets the smallest pixel value in series.
	 * 
	 * @param shSmallestPixelValueInSeries : The minimum value of all images in this
	 * Series.
	 * 
	 * setSmallestPixelValueInSeries method is used to set the Smallest Pixel Value In Series in General Series Module.
	 * The function accepts a String Value as the Smallest Pixel Value In Series 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
	 */	
	public void setSmallestPixelValueInSeries(short shSmallestPixelValueInSeries)
	{
		/*Accept the Smallest Pixel Value in Series value 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 Hash Map
		 */
		addDataElement(0x0028, 0x0108, DicomConstants.DCM_DT_SS, shSmallestPixelValueInSeries);
	}

	/**
	 * Retrieves Smallest Pixel Value InSeries.
	 * 
	 * @return short - short value of SmallestPixelValueInSeries.
	 */
	public short getSmallestPixelValueInSeries()
	{
		Object objValue = objIDataSet.getValue(0x0028, 0x0108);
		if(objValue != null)
			Short.parseShort(objValue.toString());
		return DicomConstants.DCM_NO_VALUE;
	}

	/**
	 * Sets the largest pixel value in series.
	 * 
	 * @param shLargestPixelValueInSeries : The maximum value of all images in this
	 * Series.
	 * 
	 * 
	 * setLargestPixelValueInSeries method is used to set the Smallest Pixel Value In Series in General Series Module.
	 * The function accepts a String Value as the Largest Pixel Value In Series 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
	 */	
	public void setLargestPixelValueInSeries(short shLargestPixelValueInSeries)
	{
		/*Accept the Largest Pixel Value in Series value 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 Hash Map
		 */
		addDataElement(0x0028, 0x0109, DicomConstants.DCM_DT_SS, shLargestPixelValueInSeries);
	}

	/**
	 * Retrieves Largest Pixel Value In Series.
	 * 
	 * @return short - short value of LargestPixelValueInSeries.
	 */
	public short getLargestPixelValueInSeries()
	{
		Object objValue = objIDataSet.getValue(0x0028, 0x0109);
		if(objValue != null)
			return Short.parseShort(objValue.toString());
		return  DicomConstants.DCM_NO_VALUE;
	}

	/**
	 * Sets the performed procedure step id.
	 * 
	 * @param strPerformedProcedureStepID : User or equipment generated identifier of
	 * that part of a Procedure that has been
	 * carried out within this step.
	 * 
	 * 
	 * setPerformedProcedureStepID method is used to set the Performed Procedure Step ID in General Series Module.
	 * The function accepts a String Value as the Performed Procedure Step ID 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
	 */	
	public void setPerformedProcedureStepID(String strPerformedProcedureStepID)
	{
		/*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(0x0040,0x0253, DicomConstants.DCM_DT_SH, strPerformedProcedureStepID);
	}

	/**
	 * Retrieves Performed Procedure Step ID.
	 * 
	 * @return String - String value of Performed Procedure Step ID.
	 */
	public String getPerformedProcedureStepID()
	{
		Object value = objIDataSet.getValue(0x0040, 0x0253);
		if(value != null)
			return value.toString();
		return null;
	}

	/**
	 * Sets the performed procedure step start date.
	 * 
	 * @param strPerformedProcedureStepStartDate : Date on which the Performed Procedure
	 * Step started.
	 * 
	 * setPerformedProcedureStepStartDate method is used to set the Performed Procedure Step Start Date in General Series Module.
	 * The function accepts a String Value as the Performed Procedure Step Start Date 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
	 */	
	public void setPerformedProcedureStepStartDate(String strPerformedProcedureStepStartDate)
	{
		/*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(0x0040,0x0244, DicomConstants.DCM_DT_DA, strPerformedProcedureStepStartDate);
	}

	/**
	 * Retrieves Performed Procedure Step Start Date.
	 * 
	 * @return String - String value of Performed Procedure Step Start Date.
	 */
	public String getPerformedProcedureStepStartDate()
	{
		Object objValue = objIDataSet.getValue(0x0040, 0x0244);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets the performed procedure step start time.
	 * 
	 * @param strPerformedProcedureStepStartTime : Time on which the Performed Procedure
	 * Step started.
	 * 
	 * setPerformedProcedureStepStartTime method is used to set the Performed Procedure Step Start Time in General Series Module.
	 * The function accepts a String Value as the Performed Procedure Step Start Time 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.
	 */	
	public void setPerformedProcedureStepStartTime(String strPerformedProcedureStepStartTime)
	{
		/*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(0x0040,0x0245, DicomConstants.DCM_DT_TM, strPerformedProcedureStepStartTime);
	}

	/**
	 * Retrieves Performed Procedure Step Start Time.
	 * 
	 * @return String - String value of Performed Procedure Step Start Time.
	 */
	public String getPerformedProcedureStepStartTime()
	{
		Object objValue = objIDataSet.getValue(0x0040, 0x0245);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets the performed procedure step description.
	 * 
	 * @param strPerformedProcedureStepDescription : Institution-generated description or
	 * classification of the Procedure Step that
	 * was performed.
	 * 
	 * 
	 * setPerformedProcedureStepDescription method is used to set the Performed Procedure Step Description
	 * in General Series Module.
	 * The function accepts a String Value as the Performed Procedure Step Description 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.
	 */	
	public void setPerformedProcedureStepDescription(String strPerformedProcedureStepDescription)
	{
		/*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(0x0040,0x0254, DicomConstants.DCM_DT_LO, strPerformedProcedureStepDescription);
	}

	/**
	 * Retrieves Performed Procedure Step Description.
	 * 
	 * @return String - String value of Performed Procedure Step Description.
	 */
	public String getPerformedProcedureStepDescription()
	{
		Object objValue = objIDataSet.getValue(0x0040, 0x0254);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets the comments on the performed procedure step.
	 * 
	 * @param strCommentsonthePerformedProcedureStep the str performed procedure step description
	 * 
	 * 
	 * Set User-defined comments on the Performed Procedure Step in General Series Module.
	 * The function accepts a String Value as the Comments On The Performed Procedure Step 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.
	 */	
	public void setCommentsOnThePerformedProcedureStep(String strCommentsonthePerformedProcedureStep)
	{
		/*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(0x0040,0x0280, DicomConstants.DCM_DT_ST, strCommentsonthePerformedProcedureStep);
	}

	/**
	 * Retrieves User-defined comments on the Performed Procedure Step in General Series Module..
	 * 
	 * @return String - User-defined comments on the Performed Procedure Step in General Series Module.
	 */
	public String getCommentsOnThePerformedProcedureStep()
	{
		Object objValue = objIDataSet.getValue(0x0040, 0x0280);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * This method Returns provides the pre-initialized object of Performing Physician Identification Sequence
	 * return PerformingPhysicianIdentificationSequence - object of Performing Physician Identification 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 the performing physician identification sequence
	 */
	public PerformingPhysicianIdentificationSequence getPerformingPhysicianIdentificationSequence()
	{
		PerformingPhysicianIdentificationSequence objPerformingPhysicianIdentificationSequence = (PerformingPhysicianIdentificationSequence)getDicomValue(0x0008, 0x1052);
		if(objPerformingPhysicianIdentificationSequence == 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();
			objPerformingPhysicianIdentificationSequence = (PerformingPhysicianIdentificationSequence)objDicomV3Factory.createSequence(0x0008, 0x1052, objITransferSyntax, objIDictionaryReader);
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0008, 0x1052, DicomConstants.DCM_DT_SQ, objPerformingPhysicianIdentificationSequence.getValue());
		}
		return objPerformingPhysicianIdentificationSequence;
	}

	/**
	 * This method Returns provides the pre-initialized object of Operator Identification Sequence
	 * return OperatorIdentificationSequence - object of Operator Identification 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 the operator identification sequence
	 */
	public OperatorIdentificationSequence getOperatorIdentificationSequence()
	{
		OperatorIdentificationSequence objOperatorIdentificationSequence = (OperatorIdentificationSequence)getDicomValue(0x0008, 0x1072);
		if(objOperatorIdentificationSequence == 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();
			objOperatorIdentificationSequence = (OperatorIdentificationSequence)objDicomV3Factory.createSequence(0x0008, 0x1072, objITransferSyntax, objIDictionaryReader);
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0008, 0x1072, DicomConstants.DCM_DT_SQ, objOperatorIdentificationSequence.getValue());
		}
		return objOperatorIdentificationSequence;
	}

	/**
	 * This method Returns provides the pre-initialized object of Referenced Performed Procedure Step Sequence
	 * return ReferencedPerformedProcedureStepSequence - object of Referenced Performed Procedure Step 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 the referenced performed procedure step sequence
	 */
	public ReferencedPerformedProcedureStepSequence getReferencedPerformedProcedureStepSequence()
	{
		ReferencedPerformedProcedureStepSequence objReferencedPerformedProcedureStepSequence = (ReferencedPerformedProcedureStepSequence)getDicomValue(0x0008, 0x1111);
		if(objReferencedPerformedProcedureStepSequence == 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();
			objReferencedPerformedProcedureStepSequence = (ReferencedPerformedProcedureStepSequence)objDicomV3Factory.createSequence(0x0008, 0x1111, objITransferSyntax, objIDictionaryReader);
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0008, 0x1111, DicomConstants.DCM_DT_SQ, objReferencedPerformedProcedureStepSequence.getValue());
		}
		return objReferencedPerformedProcedureStepSequence;
	}

	/**
	 * This method Returns provides the pre-initialized object of Related Series Sequence
	 * return RelatedSeriesSequence - object of Related Series 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 the related series sequence
	 */
	public RelatedSeriesSequence getRelatedSeriesSequence()
	{
		RelatedSeriesSequence objRelatedSeriesSequence = (RelatedSeriesSequence)getDicomValue(0x0008, 0x1250);
		if(objRelatedSeriesSequence == 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();
			objRelatedSeriesSequence = (RelatedSeriesSequence)objDicomV3Factory.createSequence(0x0008, 0x1250, objITransferSyntax, objIDictionaryReader);
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0008, 0x1250, DicomConstants.DCM_DT_SQ, objRelatedSeriesSequence.getValue());
		}
		return objRelatedSeriesSequence;
	}

	/**
	 * This method Returns provides the pre-initialized object of Request Attributes Sequence
	 * return RequestAttributesSequence - object of Performed Protocol 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 the request attributes sequence
	 */
	public RequestAttributesSequence getRequestAttributesSequence()
	{
		RequestAttributesSequence objRequestAttributesSequence = (RequestAttributesSequence)getDicomValue(0x0040, 0x0275);
		if(objRequestAttributesSequence == 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();
			objRequestAttributesSequence = (RequestAttributesSequence)objDicomV3Factory.createSequence(0x0040, 0x0275, objITransferSyntax, objIDictionaryReader);
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0040, 0x0275, DicomConstants.DCM_DT_SQ, objRequestAttributesSequence.getValue());
		}
		return objRequestAttributesSequence;
	}

	/**
	 * This method Returns provides the pre-initialized object of Performed Protocol Code Sequence
	 * return PerformedProtocolCodeSequence - object of Performed Protocol 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 the performed protocol code sequence
	 */
	public PerformedProtocolCodeSequence getPerformedProtocolCodeSequence()
	{
		PerformedProtocolCodeSequence objPerformedProtocolCodeSequence = (PerformedProtocolCodeSequence)getDicomValue(0x0040, 0x0260);
		if(objPerformedProtocolCodeSequence == 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();
			objPerformedProtocolCodeSequence = (PerformedProtocolCodeSequence)objDicomV3Factory.createSequence(0x0040, 0x0260, objITransferSyntax, objIDictionaryReader);
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0040, 0x0260, DicomConstants.DCM_DT_SQ, objPerformedProtocolCodeSequence.getValue());
		}
		return objPerformedProtocolCodeSequence;
	}

	/**
	 * Sets Anatomical Orientation Type.
	 * The anatomical orientation type used in instances generated by equipment.
	 * Enumerated Values:
	 * 1) BIPED 
	 * 2) QUADRUPED 
	 * 
	 * @param enumAnatomicalOrientationType the enum Anatomical Orientation Type
	 */
	public void setAnatomicalOrientationType(EnumAnatomicalOrientationType  enumAnatomicalOrientationType)
	{
		/* Accept Anatomical Orientation 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
		 */
		addDataElement(0x0010, 0x2210, DicomConstants.DCM_DT_CS, enumAnatomicalOrientationType.getValue());
	}

	/**
	 * Retrieves Anatomical Orientation Type.
	 * The anatomical orientation type used in instances generated by equipment.
	 * @return String - String value of Anatomical Orientation Type.
	 */ 
	public String getAnatomicalOrientationType()
	{
		Object objValue = getValue(0x0010,0x2210);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * 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 Boolean - status indicating success or failure
	 * 
	 * @throws InvalidModuleException the invalid module exception
	 */
	public  boolean validateModule() throws InvalidModuleException
	{

		try
		{			//Check for the Type 1,2 Mandatory Attributes.
			if(!isPresent(0x0008,0x0060))
				throw new MandatoryMissingException("0008,0060");
			if(!isPresent(0x0020,0x000E))
				throw new MandatoryMissingException("0020,000E");
			if(!isPresent(0x0020,0x0011))
				throw new MandatoryMissingException("0020,0011");

			/*
			 * Dependency check is done for 0x0020,0x0060
			 *  Here the explanation says that 
			 * 	Laterality of (paired) body part examined(0x0018,0x0015).
			 *  Required if the body part examined is a
			 *  paired structure and Image Laterality
			 *  (0020,0062) or Frame Laterality
			 *  (0020,9072) are not sent.
			 *  The multiplicity of Body Part Examined Tag is 1 in the dictionary, so how can it have a paired structure?
			 *  So presently only the presence is checked.
			 */
			// the code is commented because decision has to be taken on the above condition.
			//				if((isPresent(0x0018, 0x0015) && (!isPresent(0x0020,0x0062) || !isPresent(0x0020, 0x9072))) && !isPresent(0x0020, 0x0060))
			//				throw new ConditionFailedException("Condition Failed for DataElement 0020,0060");

			if(isPresent(0x0054, 0x0410) && isPresent(0x0018, 0x5100))
				throw new ConditionFailedException("(0054,0410) should not be present if DataElement 0018,5100 is present");

			/*
			 * Why the value check is done in module level presence/absence validation?????
			 */
			if( getPatientPosition() != null)
			{
				String strPatientPosition = getPatientPosition().trim();
				if(strPatientPosition != null)
				{
					//(0018,5100) should contain one these values
					if(!
							(
									EnumPatientPosition.HEAD_FIRSTPRONE.getValue().equalsIgnoreCase(strPatientPosition)||
									EnumPatientPosition.HEAD_FIRSTSUPINE.getValue().equalsIgnoreCase(strPatientPosition)||
									EnumPatientPosition.HEAD_FIRSTDECUBITUS_RIGHT.getValue().equalsIgnoreCase(strPatientPosition)||
									EnumPatientPosition.HEAD_FIRSTDECUBITUS_LEFT.getValue().equalsIgnoreCase(strPatientPosition)||
									EnumPatientPosition.FEET_FIRSTDECUBITUS_RIGHT.getValue().equalsIgnoreCase(strPatientPosition)||
									EnumPatientPosition.FEET_FIRSTDECUBITUS_LEFT.getValue().equalsIgnoreCase(strPatientPosition)||
									EnumPatientPosition.FEET_FIRSTPRONE.getValue().equalsIgnoreCase(strPatientPosition)||
									EnumPatientPosition.FEET_FIRSTSUPINE.getValue().equalsIgnoreCase(strPatientPosition)
							)
					)
					{
						/*
						 *  Log:
						 *  Only one these values must be present
						 *  HFP = Head First-Prone HFS = Head First-Supine
						HFDR = Head First-Decubitus Right HFDL = Head First-Decubitus Left
						FFDR = Feet First-Decubitus Right FFDL = Feet First-Decubitus Left
						FFP	= Feet First-Prone FFS = Feet First-Supine
						 * 
						 */
						throw new ConditionFailedException("Invalid Value for DataElement 0018,5100");
					}
				}
			}
			if(isPresent(0x0008,0x1052))
				getPerformingPhysicianIdentificationSequence().validateForModule();
			if(isPresent(0x0008,0x1072))
				getOperatorIdentificationSequence().validateForModule();
			if(isPresent(0x0008,0x1111))
				getReferencedPerformedProcedureStepSequence().validateForModule();
			if(isPresent(0x0008,0x1250))
				getRelatedSeriesSequence().validateForModule();
			if(isPresent(0x0040,0x0275))
				getRequestAttributesSequence().validateForModule();
			if(isPresent(0x0040,0x0260))
				getPerformedProtocolCodeSequence().validateForModule();


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

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

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

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

		}
		catch(ValidationException ve)
		{
			if(DicomConfig.createInstance().isLoggingOn())
				DicomLogger.getLogger().log(ve.getMessage());

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

		}
		return true;
	}

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