/*******************************************************************************
 *  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.EnumBeamType;
import cdac.medinfo.sdk.dcm30_04.enums.EnumHighDoseTechniqueType;
import cdac.medinfo.sdk.dcm30_04.enums.EnumRadiationType;
import cdac.medinfo.sdk.dcm30_04.enums.EnumTreatmentDeliveryType;
import cdac.medinfo.sdk.dcm30_04.enums.EnumTreatmentTerminationStatus;
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.utils.DicomConfig;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConstants;
import cdac.medinfo.sdk.dcm30_04.utils.DicomLogger;




/**
 * This introduces sequence of Beams administered during treatment session.
 * The sequence may contain one or more items.
 */
public class TreatmentSessionBeamSequenceItem extends Item  
{
	


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

	/**
	 * This constructor creates the item and internal code sequence macro with default TransferSyntax 
	 */
	TreatmentSessionBeamSequenceItem()
	{
		super();
	}

	/**
	 * This constructor creates the item and internal code sequence macro with default TransferSyntax 
	 * and default DictionaryReader
	 * @param objITransferSyntax specifies the DICOM Standard defined TransfeSyntax
	 */
	TreatmentSessionBeamSequenceItem(ITransferSyntax objITransferSyntax)
	{
		super(objITransferSyntax);
	}

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

	/**
	 * Sets References Beam specified by Beam Number (300A,00C0) in Beam Sequence (300A,00B0) in RT Beams Module within referenced RT Plan.
	 * @param strReferencedBeamNumber String value of Referenced Beam Number.

	 */
	public void setReferencedBeamNumber(String strReferencedBeamNumber)
	{
		/*Accept the Value Type 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(0x300C,0x0006, strReferencedBeamNumber,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x300C,0x0006,DicomConstants.DCM_DT_IS, strReferencedBeamNumber);

		addDataElement(objIDataElement);


	}

	/**
	 * Retrieves Referenced Beam Number.
	 * @return String - value of Referenced Beam Number
	 */
	public String getReferencedBeamNumber()
	{
		Object objValue = getValue(0x300C,0x0006);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets User-defined name for delivered Beam.
	 * @param strBeamName String value of Beam Name.

	 */
	public void setBeamName(String strBeamName)
	{
		/*Accept the Value Type 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 Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x300A,0x00C2,strBeamName,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x300A,0x00C2,DicomConstants.DCM_DT_LO, strBeamName);

		addDataElement(objIDataElement);


	}

	/**
	 * Retrieves User-defined name for delivered Beam.
	 * @return String - value Beam Name.
	 */
	public String getBeamName()
	{
		Object objValue = getValue(0x300A,0x00C2);
		if(objValue != null)
			return objValue.toString();
		return null;
	}


	/**
	 * Sets User-defined description for delivered Beam.
	 * @param strBeamDescription String value of Beam Description.

	 */
	public void setBeamDescription(String strBeamDescription)
	{
		/*Accept the Value Type 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 Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x300A,0x00C3,strBeamDescription,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x300A,0x00C3,DicomConstants.DCM_DT_ST, strBeamDescription);

		addDataElement(objIDataElement);


	}

	/**
	 * Retrieves User-defined description for delivered Beam.
	 * @return String - value Beam Description.
	 */
	public String getBeamDescription()
	{
		Object objValue = getValue(0x300A,0x00C3);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets Motion characteristic of delivered Beam.
	 * Enumerated Values:
	 * STATIC = all beam parameters remain unchanged during delivery
	 * DYNAMIC = one or more beam parameters changes during delivery
	 * @param enumBeamType Enum value of Beam Description.

	 */
	public void setBeamType(EnumBeamType enumBeamType)
	{
		/*Accept the Value 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(0x300A,0x00C4,enumBeamType.getValue(),getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x300A,0x00C4,DicomConstants.DCM_DT_CS, enumBeamType.getValue());

		addDataElement(objIDataElement);


	}

	/**
	 * Retrieves Motion characteristic of delivered Beam.
	 * @return String - value Beam Type.
	 */
	public String getBeamType()
	{
		Object objValue = getValue(0x300A,0x00C4);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets Particle type of delivered Beam.
	 * Defined Terms :
	 * PHOTON, ELECTRON, NEUTRON,PROTON.
	 * @param enumRadiationType Enum value of Radiation Type.
	 */
	public void setRadiationType(EnumRadiationType enumRadiationType)
	{
		/*Accept the Value 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(0x300A,0x00C6,enumRadiationType.getValue(),getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x300A,0x00C6,DicomConstants.DCM_DT_CS, enumRadiationType.getValue());

		addDataElement(objIDataElement);


	}

	/**
	 * Retrieves Particle type of delivered Beam.
	 * @return String - value Radiation Type.
	 */
	public String getRadiationType()
	{
		Object objValue = getValue(0x300A,0x00C6);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets Type of high-dose treatment technique.
	 * Defined Terms :
	 * NORMAL = Standard treatment
	 * TBI = Total Body Irradiation
	 * HDR = High Dose Rate
	 * @param enumHighDoseTechniqueType Enum value of high-dose treatment technique Type.
	 */
	public void setHighDoseTechniqueType(EnumHighDoseTechniqueType enumHighDoseTechniqueType)
	{
		/*Accept the Value 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(0x300A,0x00C7,enumHighDoseTechniqueType.getValue(),getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x300A,0x00C7,DicomConstants.DCM_DT_CS, enumHighDoseTechniqueType.getValue());

		addDataElement(objIDataElement);


	}

	/**
	 * Retrieves Type of high-dose treatment technique.
	 * @return String - value high-dose treatment technique Type.
	 */
	public String getHighDoseTechniqueType()
	{
		Object objValue = getValue(0x300A,0x00C7);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Retrieves pre-initialized object of Referenced Verification 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 ReferencedVerificationImageSequence - instance of Referenced Verification Image Sequence. 
	 */
	public ReferencedVerificationImageSequence getReferencedVerificationImageSequence()
	{
		ReferencedVerificationImageSequence objReferencedVerificationImageSequence = null;
		IDataElement objIDataElement =  getDataForTag(0x300C,0x0040);
		if(objIDataElement != null)
		{
			IDicomValue objIDicomValue = objIDataElement.getDicomValue();
			if(objIDicomValue != null)
				objReferencedVerificationImageSequence = (ReferencedVerificationImageSequence)objIDicomValue;
		}
		else
		{
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			int iVRTransferSyntax = objITransferSyntax.getVRTransferSyntax();
			objIDataElement = null;
			objReferencedVerificationImageSequence = (ReferencedVerificationImageSequence)objDicomV3Factory.createSequence(0x300C,0x0040, objITransferSyntax, objIDictionaryReader);

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

	/**
	 * Retrieves pre-initialized object of Referenced Measured Dose Reference 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 ReferencedMeasuredDoseReferenceSequence - instance of Referenced Measured Dose Reference Sequence. 
	 */
	public ReferencedMeasuredDoseReferenceSequence getReferencedMeasuredDoseReferenceSequence()
	{
		ReferencedMeasuredDoseReferenceSequence objReferencedMeasuredDoseReferenceSequence = null;
		IDataElement objIDataElement =  getDataForTag(0x3008,0x0080);
		if(objIDataElement != null)
		{
			IDicomValue objIDicomValue = objIDataElement.getDicomValue();
			if(objIDicomValue != null)
				objReferencedMeasuredDoseReferenceSequence = (ReferencedMeasuredDoseReferenceSequence)objIDicomValue;
		}
		else
		{
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			int iVRTransferSyntax = objITransferSyntax.getVRTransferSyntax();
			objIDataElement = null;
			objReferencedMeasuredDoseReferenceSequence = (ReferencedMeasuredDoseReferenceSequence)objDicomV3Factory.createSequence(0x3008,0x0080, objITransferSyntax, objIDictionaryReader);

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

	/**
	 * Retrieves pre-initialized object of Referenced Calculated Dose Reference 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 ReferencedCalculatedDoseReferenceSequence - instance of Referenced Calculated Dose Reference Sequence. 
	 */
	public ReferencedCalculatedDoseReferenceSequence getReferencedCalculatedDoseReferenceSequence()
	{
		ReferencedCalculatedDoseReferenceSequence objReferencedCalculatedDoseReferenceSequence = null;
		IDataElement objIDataElement =  getDataForTag(0x3008,0x0090);
		if(objIDataElement != null)
		{
			IDicomValue objIDicomValue = objIDataElement.getDicomValue();
			if(objIDicomValue != null)
				objReferencedCalculatedDoseReferenceSequence = (ReferencedCalculatedDoseReferenceSequence)objIDicomValue;
		}
		else
		{
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			int iVRTransferSyntax = objITransferSyntax.getVRTransferSyntax();
			objIDataElement = null;
			objReferencedCalculatedDoseReferenceSequence = (ReferencedCalculatedDoseReferenceSequence)objDicomV3Factory.createSequence(0x3008,0x0090, objITransferSyntax, objIDictionaryReader);

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

	/**
	 * Sets Source Axis Distance . Radiation source to gantry rotation axis distance of the equipment that was used for beam delivery(mm).
	 * @param strSourceAxisDistance String value of Source Axis Distance.
	 */
	public void setSourceAxisDistance(String strSourceAxisDistance)
	{
		/*Accept the Value Type 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(0x300A,0x00B4,strSourceAxisDistance,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x300A,0x00B4,DicomConstants.DCM_DT_DS, strSourceAxisDistance);

		addDataElement(objIDataElement);


	}

	/**
	 * Retrieves Source Axis Distance. Radiation source to gantry rotation axis distance of the equipment that was used for beam delivery(mm).
	 * @return String - value of Source Axis Distance.
	 */
	public String getSourceAxisDistance()
	{
		Object objValue = getValue(0x300A,0x00B4);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Retrieves pre-initialized object of Beam Limiting Device Leaf Pairs 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 BeamLimitingDeviceLeafPairsSequence - instance of Beam Limiting Device Leaf Pairs Sequence. 
	 */
	public BeamLimitingDeviceLeafPairsSequence getBeamLimitingDeviceLeafPairsSequence()
	{
		BeamLimitingDeviceLeafPairsSequence objBeamLimitingDeviceLeafPairsSequence = null;
		IDataElement objIDataElement =  getDataForTag(0x3008,0x00A0);
		if(objIDataElement != null)
		{
			IDicomValue objIDicomValue = objIDataElement.getDicomValue();
			if(objIDicomValue != null)
				objBeamLimitingDeviceLeafPairsSequence = (BeamLimitingDeviceLeafPairsSequence)objIDicomValue;
		}
		else
		{
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			int iVRTransferSyntax = objITransferSyntax.getVRTransferSyntax();
			objIDataElement = null;
			objBeamLimitingDeviceLeafPairsSequence = (BeamLimitingDeviceLeafPairsSequence)objDicomV3Factory.createSequence(0x3008,0x00A0, objITransferSyntax, objIDictionaryReader);

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

	/**
	 * Sets Referenced Patient Setup Number. Uniquely identifies Patient Setup used within current beam, specified by Patient Setup Number (300A, 0182) within Patient Setup Sequence (300A, 0180) of RT Treatment Record.
	 * @param strReferencedPatientSetupNumber String value of Referenced Patient Setup Number.
	 */
	public void setReferencedPatientSetupNumber(String strReferencedPatientSetupNumber)
	{
		/*Accept the Value Type 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(0x300C,0x006A,strReferencedPatientSetupNumber,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x300C,0x006A,DicomConstants.DCM_DT_IS, strReferencedPatientSetupNumber);

		addDataElement(objIDataElement);


	}

	/**
	 * Retrieves Referenced Patient Setup Number. 
	 * @return String - value of Referenced Patient Setup Number.
	 */
	public String getReferencedPatientSeupNumber()
	{
		Object objValue = getValue(0x300C,0x006A);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets Number of Wedges associated with current delivered Beam.
	 * @param strNumberofWedges String value of Number of Wedges.
	 */
	public void setNumberofWedges(String strNumberofWedges)
	{
		/*Accept the Value Type 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(0x300A,0x00D0,strNumberofWedges,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x300A,0x00D0,DicomConstants.DCM_DT_IS, strNumberofWedges);

		addDataElement(objIDataElement);


	}

	/**
	 * Retrieves Number of Wedges. 
	 * @return String - value of Number of Wedges.
	 */
	public String getNumberofWedges()
	{
		Object objValue = getValue(0x300A,0x00D0);
		if(objValue != null)
			return objValue.toString();
		return null;
	}


	/**
	 * Retrieves pre-initialized object of Recorded Wedge 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 RecordedWedgeSequence - instance of Recorded Wedge Sequence. 
	 */
	public RecordedWedgeSequence getRecordedWedgeSequence()
	{
		RecordedWedgeSequence objRecordedWedgeSequence = null;
		IDataElement objIDataElement =  getDataForTag(0x3008,0x00B0);
		if(objIDataElement != null)
		{
			IDicomValue objIDicomValue = objIDataElement.getDicomValue();
			if(objIDicomValue != null)
				objRecordedWedgeSequence = (RecordedWedgeSequence)objIDicomValue;
		}
		else
		{
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			int iVRTransferSyntax = objITransferSyntax.getVRTransferSyntax();
			objIDataElement = null;
			objRecordedWedgeSequence = (RecordedWedgeSequence)objDicomV3Factory.createSequence(0x3008,0x00B0, objITransferSyntax, objIDictionaryReader);

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

	/**
	 * Sets Number of Compensators associated with current delivered Beam.
	 * @param strNumberofCompensators String value of Number of Compensators.
	 */
	public void setNumberofCompensators(String strNumberofCompensators)
	{
		/*Accept the Value Type 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(0x300A,0x00E0,strNumberofCompensators,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x300A,0x00E0,DicomConstants.DCM_DT_IS, strNumberofCompensators);

		addDataElement(objIDataElement);


	}

	/**
	 * RetrievesNumber of Compensators associated with current delivered Beam.
	 * @return String - value of  Number of Compensators.
	 */
	public String getNumberofCompensators()
	{
		Object objValue = getValue(0x300A,0x00E0);
		if(objValue != null)
			return objValue.toString();
		return null;
	}


	/**
	 * Retrieves pre-initialized object of Recorded Compensator 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 RecordedCompensatorSequence - instance of Recorded Compensator Sequence. 
	 */
	public RecordedCompensatorSequence getRecordedCompensatorSequence()
	{
		RecordedCompensatorSequence objRecordedCompensatorSequence = null;
		IDataElement objIDataElement =  getDataForTag(0x3008,0x00C0);
		if(objIDataElement != null)
		{
			IDicomValue objIDicomValue = objIDataElement.getDicomValue();
			if(objIDicomValue != null)
				objRecordedCompensatorSequence = (RecordedCompensatorSequence)objIDicomValue;
		}
		else
		{
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			int iVRTransferSyntax = objITransferSyntax.getVRTransferSyntax();
			objIDataElement = null;
			objRecordedCompensatorSequence = (RecordedCompensatorSequence)objDicomV3Factory.createSequence(0x3008,0x00C0, objITransferSyntax, objIDictionaryReader);

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

	/**
	 * Sets Number of Boli used with current  Beam.
	 * @param strNumberOfBoli String value of Number of Boli.
	 */
	public void setNumberOfBoli(String strNumberOfBoli)
	{
		/*Accept the Value Type 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(0x300A,0x00ED,strNumberOfBoli,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x300A,0x00ED,DicomConstants.DCM_DT_IS, strNumberOfBoli);

		addDataElement(objIDataElement);


	}

	/**
	 * Retrieves Number of Boli used with current  Beam.
	 * @return String - value of  Number of Boli
	 */
	public String getNumberOfBoli()
	{
		Object objValue = getValue(0x300A,0x00ED);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Retrieves pre-initialized object of Referenced Bolus 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 ReferencedBolusSequence - instance of Referenced Bolus Sequence. 
	 */
	public ReferencedBolusSequence getReferencedBolusSequence()
	{
		ReferencedBolusSequence objReferencedBolusSequence = null;
		IDataElement objIDataElement =  getDataForTag(0x300C,0x00B0);
		if(objIDataElement != null)
		{
			IDicomValue objIDicomValue = objIDataElement.getDicomValue();
			if(objIDicomValue != null)
				objReferencedBolusSequence = (ReferencedBolusSequence)objIDicomValue;
		}
		else
		{
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			int iVRTransferSyntax = objITransferSyntax.getVRTransferSyntax();
			objIDataElement = null;
			objReferencedBolusSequence = (ReferencedBolusSequence)objDicomV3Factory.createSequence(0x300C,0x00B0, objITransferSyntax, objIDictionaryReader);

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

	/**
	 * Sets Number of Blocks or Electron Electron Inserts associated with Beam. 
	 * @param strNumberOfBlocks String value of Number of Blocks.

	 */
	public void setNumberOfBlocks(String strNumberOfBlocks)
	{
		/*Accept the Value Type 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(0x300A,0x00F0,strNumberOfBlocks,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x300A,0x00F0,DicomConstants.DCM_DT_IS, strNumberOfBlocks);

		addDataElement(objIDataElement);


	}

	/**
	 * Retrieves Number of Blocks or Electron Electron Inserts associated with Beam.
	 * @return String - value of  Number of Blocks
	 */
	public String getNumberOfBlocks()
	{
		Object objValue = getValue(0x300A,0x00F0);
		if(objValue != null)
			return objValue.toString();
		return null;
	}


	/**
	 * Retrieves pre-initialized object of Recorded Block 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 RecordedBlockSequence - instance of Recorded Block Sequence. 
	 */
	public RecordedBlockSequence getRecordedBlockSequence()
	{
		RecordedBlockSequence objRecordedBlockSequence = null;
		IDataElement objIDataElement =  getDataForTag(0x3008,0x00D0);
		if(objIDataElement != null)
		{
			IDicomValue objIDicomValue = objIDataElement.getDicomValue();
			if(objIDicomValue != null)
				objRecordedBlockSequence = (RecordedBlockSequence)objIDicomValue;
		}
		else
		{
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			int iVRTransferSyntax = objITransferSyntax.getVRTransferSyntax();
			objIDataElement = null;
			objRecordedBlockSequence = (RecordedBlockSequence)objDicomV3Factory.createSequence(0x3008,0x00D0, objITransferSyntax, objIDictionaryReader);

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


	/**
	 * Retrieves pre-initialized object of Applicator 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 ApplicatorSequence - instance of Applicator Sequence. 
	 */
	public ApplicatorSequence getApplicatorSequence()
	{
		ApplicatorSequence objApplicatorSequence = null;
		IDataElement objIDataElement =  getDataForTag(0x300A,0x0107);
		if(objIDataElement != null)
		{
			IDicomValue objIDicomValue = objIDataElement.getDicomValue();
			if(objIDicomValue != null)
				objApplicatorSequence = (ApplicatorSequence)objIDicomValue;
		}
		else
		{
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			int iVRTransferSyntax = objITransferSyntax.getVRTransferSyntax();
			objIDataElement = null;
			objApplicatorSequence = (ApplicatorSequence)objDicomV3Factory.createSequence(0x300A,0x0107, objITransferSyntax, objIDictionaryReader);

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

	/**
	 * Sets Current Fraction Number. Fraction number for this beam. 
	 * @param strCurrentFractionNumber String value of Current Fraction Number.

	 */
	public void setCurrentFractionNumber(String strCurrentFractionNumber)
	{
		/*Accept the Value Type 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(0x3008, 0x0022,strCurrentFractionNumber,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x3008, 0x0022,DicomConstants.DCM_DT_IS, strCurrentFractionNumber);

		addDataElement(objIDataElement);


	}

	/**
	 * Retrieves Current Fraction Number.
	 * @return String - value of  Current Fraction Number
	 */
	public String getCurrentFractionNumber()
	{
		Object objValue = getValue(0x3008, 0x0022);
		if(objValue != null)
			return objValue.toString();
		return null;
	}


	/**
	 * Sets Treatment Delivery Type.
	 * Defined Terms:
	 * TREATMENT = normal patient treatment
	 * OPEN_PORTFILM = portal image acquisition with open field
	 * TRMT_PORTFILM = portal image acquisition with treatment port
	 * CONTINUATION = continuation of interrupted treatment.
	 * @param enumTreatmentDeliveryType Enum value of Treatment Delivery Type.
	 */
	public void setTreatmentDeliveryType(EnumTreatmentDeliveryType enumTreatmentDeliveryType)
	{
		/*Accept the Value 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(0x300A,0x00CE,enumTreatmentDeliveryType.getValue(),getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x300A,0x00CE,DicomConstants.DCM_DT_CS, enumTreatmentDeliveryType.getValue());

		addDataElement(objIDataElement);


	}

	/**
	 * Retrieves Treatment Delivery Type.
	 * @return String - value Treatment Delivery Type.
	 */
	public String getTreatmentDeliveryType()
	{
		Object objValue = getValue(0x300A,0x00CE);
		if(objValue != null)
			return objValue.toString();
		return null;
	}


	/**
	 * Sets Conditions under which treatment was terminated.
	 * Enumerated Values:
	 * NORMAL = treatment terminated normally.
	 * OPERATOR = operator terminated treatment.
	 * MACHINE = machine terminated treatment.
	 * UNKNOWN = status at termination unknown.
	 * @param enumTreatmentTerminationStatus Enum value of Treatment Termination Status.
	 */
	public void setTreatmentTerminationStatus(EnumTreatmentTerminationStatus enumTreatmentTerminationStatus)
	{
		/*Accept the Value 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(0x300A,0x002A,enumTreatmentTerminationStatus.getValue(),getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x300A,0x002A,DicomConstants.DCM_DT_CS, enumTreatmentTerminationStatus.getValue());

		addDataElement(objIDataElement);


	}

	/**
	 * Retrieves Conditions under which treatment was terminated.
	 * @return String - value of Treatment Termination Status.
	 */
	public String getTreatmentTerminationStatus()
	{
		Object objValue = getValue(0x300A,0x002A);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets Treatment machine Termination Code. This  code is dependent upon the particular application and equipment.
	 * @param strTreatmentTerminationCode String value of Treatment Termination Code.
	 */
	public void setTreatmentTerminationCode(String strTreatmentTerminationCode)
	{
		/*Accept the Value Type 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(0x3008,0x002B,strTreatmentTerminationCode,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x3008,0x002B,DicomConstants.DCM_DT_SH, strTreatmentTerminationCode);

		addDataElement(objIDataElement);


	}

	/**
	 * Retrieves Treatment machine Termination Code
	 * @return String - value of  Treatment Termination Code
	 */
	public String getTreatmentTerminationCode()
	{
		Object objValue = getValue(0x3008,0x002B);
		if(objValue != null)
			return objValue.toString();
		return null;
	}


	/**
	 * Sets Conditions under which treatment was verified by a verification system..
	 * Enumerated Values:
	 * VERIFIED = treatment verified
	 * VERIFIED_OVR = treatment verified with at least one out-of-range value overridden
	 * NOT_VERIFIED = treatment verified manually.
	 * @param enumTreatmentVerificationStatus Enum value of Treatment Verification Status.
	 */
	public void setTreatmentVerificationStatus(EnumTreatmentTerminationStatus enumTreatmentVerificationStatus)
	{
		/*Accept the Value 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(0x300A,0x002C,enumTreatmentVerificationStatus.getValue(),getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x300A,0x002C,DicomConstants.DCM_DT_CS, enumTreatmentVerificationStatus.getValue());

		addDataElement(objIDataElement);


	}

	/**
	 * Retrieves Conditions under which treatment was verified by a verification system.
	 * @return String - value of Treatment Verification Status.
	 */
	public String getTreatmentVerificationStatus()
	{
		Object objValue = getValue(0x300A,0x002C);
		if(objValue != null)
			return objValue.toString();
		return null;
	}


	/**
	 * Sets Desired machine setting of primary meterset.
	 * @param strSpecifiedPrimaryMeterset String value of Specified Primary Meterset.
	 */
	public void setSpecifiedPrimaryMeterset(String strSpecifiedPrimaryMeterset)
	{
		/*Accept the Value Type 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(0x3008,0x0032,strSpecifiedPrimaryMeterset,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x3008,0x0032,DicomConstants.DCM_DT_DS, strSpecifiedPrimaryMeterset);

		addDataElement(objIDataElement);


	}

	/**
	 * Retrieves  Desired machine setting of primary meterset.
	 * @return String - value of Specified Primary Meterset.
	 */
	public String getSpecifiedPrimaryMeterset()
	{
		Object objValue = getValue(0x3008,0x0032);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets Desired machine setting of Secondary meterset.
	 * @param strSpecifiedSecondaryMeterset String value of Specified Secondary Meterset.
	 */
	public void setSpecifiedSecondaryMeterset(String strSpecifiedSecondaryMeterset)
	{
		/*Accept the Value Type 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(0x3008,0x0033,strSpecifiedSecondaryMeterset,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x3008,0x0033,DicomConstants.DCM_DT_DS, strSpecifiedSecondaryMeterset);

		addDataElement(objIDataElement);


	}

	/**
	 * Retrieves  Desired machine setting of Secondary meterset.
	 * @return String - value of Specified Secondary Meterset.
	 */
	public String getSpecifiedSecondaryMeterset()
	{
		Object objValue = getValue(0x3008,0x0033);
		if(objValue != null)
			return objValue.toString();
		return null;
	}


	/**
	 * Sets Machine setting actually delivered as recorded by primary meterset.
	 * @param strDeliveredPrimaryMeterset String value of Delivered Primary Meterset.
	 */
	public void setDeliveredPrimaryMeterset(String strDeliveredPrimaryMeterset)
	{
		/*Accept the Value Type 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(0x3008,0x0036,strDeliveredPrimaryMeterset,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x3008,0x0036,DicomConstants.DCM_DT_DS, strDeliveredPrimaryMeterset);

		addDataElement(objIDataElement);


	}

	/**
	 * Retrieves  Machine setting actually delivered as recorded by primary meterset
	 * @return String - value of Delivered Primary Meterset.
	 */
	public String getDeliveredPrimaryMeterset()
	{
		Object objValue = getValue(0x3008,0x0036);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets Machine setting actually delivered as recorded by Secondary meterset.
	 * @param strDeliveredSecondaryMeterset String value of Delivered Secondary Meterset.
	 */
	public void setDeliveredSecondaryMeterset(String strDeliveredSecondaryMeterset)
	{
		/*Accept the Value Type 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(0x3008,0x0037,strDeliveredSecondaryMeterset,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x3008,0x0037,DicomConstants.DCM_DT_DS, strDeliveredSecondaryMeterset);

		addDataElement(objIDataElement);


	}

	/**
	 * Retrieves  Machine setting actually delivered as recorded by Secondary meterset
	 * @return String - value of Delivered Secondary Meterset.
	 */
	public String getDeliveredSecondaryMeterset()
	{
		Object objValue = getValue(0x3008,0x0037);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets Treatment Time  (sec)..
	 * @param strSpecifiedTreatmentTime String value of Specified Treatment Time.
	 */
	public void setSpecifiedTreatmentTime(String strSpecifiedTreatmentTime)
	{
		/*Accept the Value Type 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(0x3008,0x003A,strSpecifiedTreatmentTime,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x3008,0x003A,DicomConstants.DCM_DT_DS, strSpecifiedTreatmentTime);

		addDataElement(objIDataElement);


	}

	/**
	 * Retrieves  Treatment Time .
	 * @return String - value of Specified Treatment Time.
	 */
	public String getSpecifiedTreatmentTime()
	{
		Object objValue = getValue(0x3008,0x003A);
		if(objValue != null)
			return objValue.toString();
		return null;
	}


	/**
	 * Sets Treatment Time actually delivered.
	 * @param strDeliveredTreatmentTime String value of Delivered Treatment Time.

	 */
	public void setDeliveredTreatmentTime(String strDeliveredTreatmentTime)
	{
		/*Accept the Value Type 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(0x3008,0x003B,strDeliveredTreatmentTime,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x3008,0x003B,DicomConstants.DCM_DT_DS, strDeliveredTreatmentTime);

		addDataElement(objIDataElement);


	}

	/**
	 * Retrieves  Treatment Time actually delivered .
	 * @return String - value of Delivered Treatment Time.
	 */
	public String getDeliveredTreatmentTime()
	{
		Object objValue = getValue(0x3008,0x003B);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets Number of control points delivered.
	 * @param strNumberOfControlPoints String value of Number Of Control Points.
	 */
	public void setNumberOfControlPoints(String strNumberOfControlPoints)
	{
		/*Accept the Value Type 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(0x300A,0x0110,strNumberOfControlPoints,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x300A,0x0110,DicomConstants.DCM_DT_IS, strNumberOfControlPoints);

		addDataElement(objIDataElement);


	}

	/**
	 * Retrieves  Number of control points delivered .
	 * @return String - value of Number Of Control Points.
	 */
	public String getNumberOfControlPoints()
	{
		Object objValue = getValue(0x300A,0x0110);
		if(objValue != null)
			return objValue.toString();
		return null;
	}


	/**
	 * Retrieves pre-initialized object of Control Point Delivery 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 ControlPointDeliverySequence - instance of Control Point Delivery Sequence. 
	 */
	public ControlPointDeliverySequence getControlPointDeliverySequence()
	{
		ControlPointDeliverySequence objControlPointDeliverySequence = null;
		IDataElement objIDataElement =  getDataForTag(0x3008,0x0040);
		if(objIDataElement != null)
		{
			IDicomValue objIDicomValue = objIDataElement.getDicomValue();
			if(objIDicomValue != null)
				objControlPointDeliverySequence = (ControlPointDeliverySequence)objIDicomValue;
		}
		else
		{
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			int iVRTransferSyntax = objITransferSyntax.getVRTransferSyntax();
			objIDataElement = null;
			objControlPointDeliverySequence = (ControlPointDeliverySequence)objDicomV3Factory.createSequence(0x3008,0x0040, objITransferSyntax, objIDictionaryReader);

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

	/**
	 * Validates all the attributes in TreatmentSessionBeamSequenceItem that are present in the DataSet
	 * @return int - Success -true, Failure - false
	 * @throws InvalidItemException throws InvalidItemException If Mandatory or Conditional element fails.
	 */

	public boolean validateForModule()  throws InvalidItemException
	{
		try
		{
			String strValueOfNumberOfWedge = "0";
			String strNumberOfWedges = getNumberofWedges();

			if(!contains(0x300A,0x00C4))
				throw new MandatoryMissingException("300A,00C4");			
			if(!contains(0x300A,0x00C6))
				throw new MandatoryMissingException("300A,00C6");
			if(!contains(0x3008,0x00A0))
				throw new MandatoryMissingException("3008,00A0");
			if(!contains(0x300A,0x00D0))
				throw new MandatoryMissingException("300A,00D0");
			if(!(strNumberOfWedges.equals(strValueOfNumberOfWedge)) && (!contains(0x3008,0x00B0)))
				throw new ConditionFailedException("0x3008,0x00B0 is required if Number of wedges is non zero");
			if(!contains(0x300A,0x00E0))
				throw new MandatoryMissingException("300A,00E0");
			if(!contains(0x300A,0x00ED))
				throw new MandatoryMissingException("300A,00ED");
			if(!contains(0x300A,0x00F0))
				throw new MandatoryMissingException("300A,00F0");
			if(!contains(0x3008,0x0022))
				throw new MandatoryMissingException("3008,0022");
			if(!contains(0x300A,0x00CE))
				throw new MandatoryMissingException("300A,00CE");
			if(!contains(0x3008,0x002A))
				throw new MandatoryMissingException("3008,002A");
			if(!contains(0x3008,0x002C))
				throw new MandatoryMissingException("3008,002C");
			if(!contains(0x300A,0x0110))
				throw new MandatoryMissingException("300A,0110");
			if(!contains(0x3008,0x0040))
				throw new MandatoryMissingException("3008,0040");
			/*
			 * High-Dose Technique Type 300A,00C7.
			 * Required if treatment technique requires a dose that would normally require overriding of treatment machine safety controls.
			 * Condition is not understood.
			 */

		}
		catch( ConditionFailedException ce)
		{
			if(DicomConfig.createInstance().isLoggingOn())
			{
				DicomLogger.getLogger().log(ce.getMessage());
			}
			throw new InvalidItemException(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;
	}
	/**
	 * Retrieves pre-initialized object of Primary Fluence Mode 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 PrimaryFluenceModeSequence - instance of PrimaryFluenceModeSequence. 
	 */
	public PrimaryFluenceModeSequence getPrimaryFluenceModeSequence()
	{
		PrimaryFluenceModeSequence objPrimaryFluenceModeSequence = null;
		IDataElement objIDataElement =  getDataForTag(0x3002, 0x0050);
		if(objIDataElement != null)
		{
			IDicomValue objIDicomValue = objIDataElement.getDicomValue();
			if(objIDicomValue != null)
				objPrimaryFluenceModeSequence = (PrimaryFluenceModeSequence)objIDicomValue;
		}
		else
		{
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			int iVRTransferSyntax = objITransferSyntax.getVRTransferSyntax();
			objIDataElement = null;
			objPrimaryFluenceModeSequence = (PrimaryFluenceModeSequence)objDicomV3Factory.createSequence(0x3002, 0x0050, objITransferSyntax, objIDictionaryReader);

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


}
