/*******************************************************************************
 *  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.IDictionaryReader;
import cdac.medinfo.sdk.dcm30_04.commoninterface.ITransferSyntax;
import cdac.medinfo.sdk.dcm30_04.enums.EnumBrachyAccessoryDeviceType;
import cdac.medinfo.sdk.dcm30_04.exceptions.InvalidItemException;
import cdac.medinfo.sdk.dcm30_04.exceptions.MandatoryMissingException;
import cdac.medinfo.sdk.dcm30_04.exceptions.ValidationException;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConfig;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConstants;
import cdac.medinfo.sdk.dcm30_04.utils.DicomLogger;



/**
* This item class contains methods to validate,set and get the attributes in {@link BrachyAccessoryDeviceSequence}.
 */
public class BrachyAccessoryDeviceSequenceItem extends Item  
{
	

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * This constructor creates the item and internal code sequence macro with default TransferSyntax 
	 */
	BrachyAccessoryDeviceSequenceItem()
	{
		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
	 */
	BrachyAccessoryDeviceSequenceItem(ITransferSyntax objITransferSyntax)
	{
		super(objITransferSyntax);
	}

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


	/**
	 * Validates all the attributes in BrachyAccessoryDeviceSequenceItem that are present in the DataSet
	 * @return boolean - Success -true, Failure - false
	 * @throws InvalidItemException throws InvalidItemException If Conditional element fails.
	 */
	public boolean validateForModule()  throws InvalidItemException
	{
		try
		{		
			if(!contains(0x300A,0x0264))
				throw new MandatoryMissingException("value of Element 0x300A,0x0264 required") ;		
		}
		catch( MandatoryMissingException me)
		{
			if(DicomConfig.createInstance().isLoggingOn())
			{
				DicomLogger.getLogger().log(me.getMessage());
			}
			throw new ValidationException(this.getClass().getSimpleName(),me);
		}
		return true;
	}

	/**
	 * Sets Brachy Accessory Device Number.Uniquely identifies Brachy Accessory Device Number(300A,0262) in Brachy Accessory Device Sequence(300A,0260) in RT BRACHY APPLICATION SETUPS MODULE of RT Plan IOD.
	 * @param strBrachyAccessoryDeviceNumber String value of Brachy Accessory Device Number.
	 */
	public void setBrachyAccessoryDeviceNumber(String strBrachyAccessoryDeviceNumber)
	{
		/*Accept the BrachyAccessoryDeviceNumber 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,0x0262, strBrachyAccessoryDeviceNumber,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x300A,0x0262,DicomConstants.DCM_DT_IS, strBrachyAccessoryDeviceNumber);

		addDataElement(objIDataElement);
	}
	/**
	 * Retrieves Brachy Accessory Device Number.
	 * @return String - value of Brachy Accessory Device Number.
	 */
	public String getBrachyAccessoryDeviceNumber()
	{
		Object objValue = getValue(0x300A,0x0262);
		if(objValue != null)
			return objValue.toString();
		return null;
	}


	/**
	 * Sets Brachy Accessory Device ID.Uniquely identifies Brachy Accessory Device ID(300A,0263) in Brachy Accessory Device Sequence(300A,0260) in RT BRACHY APPLICATION SETUPS MODULE of RT Plan IOD.
	 * @param strBrachyAccessoryDeviceID String value of Brachy Accessory Device ID.
	 */
	public void setBrachyAccessoryDeviceID(String strBrachyAccessoryDeviceID)
	{
		/*Accept the BrachyAccessoryDeviceID 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(0x300A,0x0263, strBrachyAccessoryDeviceID,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x300A,0x0263,DicomConstants.DCM_DT_SH, strBrachyAccessoryDeviceID);

		addDataElement(objIDataElement);
	}
	/**
	 * Retrieves Brachy Accessory Device ID.
	 * @return String - value of Brachy Accessory Device ID.
	 */
	public String getBrachyAccessoryDeviceID()
	{
		Object objValue = getValue(0x300A,0x0263);
		if(objValue != null)
			return objValue.toString();
		return null;
	}


	/**
	 * Sets Brachy Accessory Device Type.Uniquely identifies Brachy Accessory Device Type(300A,0264) in Brachy Accessory Device Sequence(300A,0260) in RT BRACHY APPLICATION SETUPS MODULE of RT Plan IOD.
	 * @param enumBrachyAccessoryDeviceType Enum value of Brachy Accessory Device Type.
	 */
	public void setBrachyAccessoryDeviceType(EnumBrachyAccessoryDeviceType enumBrachyAccessoryDeviceType)
	{
		/*Accept the BrachyAccessoryDeviceType 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,0x0264, enumBrachyAccessoryDeviceType.getValue(),getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x300A,0x0264,DicomConstants.DCM_DT_CS, enumBrachyAccessoryDeviceType.getValue());

		addDataElement(objIDataElement);
	}
	/**
	 * Retrieves Brachy Accessory Device Type.
	 * @return String - value of Brachy Accessory Device Type.
	 */
	public String getBrachyAccessoryDeviceType()
	{
		Object objValue = getValue(0x300A,0x0264);
		if(objValue != null)
			return objValue.toString();
		return null;
	}


	/**
	 * Sets Brachy Accessory Device Name.Uniquely identifies Brachy Accessory Device Name(300A,0266) in Brachy Accessory Device Sequence(300A,0260) in RT BRACHY APPLICATION SETUPS MODULE of RT Plan IOD.
	 * @param strBrachyAccessoryDeviceName String value of Brachy Accessory Device Name.
	 */
	public void setBrachyAccessoryDeviceName(String strBrachyAccessoryDeviceName)
	{
		/*Accept the BrachyAccessoryDeviceName 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,0x0266, strBrachyAccessoryDeviceName,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x300A,0x0266,DicomConstants.DCM_DT_CS, strBrachyAccessoryDeviceName);

		addDataElement(objIDataElement);
	}
	/**
	 * Retrieves Brachy Accessory Device Name.
	 * @return String - value of Brachy Accessory Device Name.
	 */
	public String getBrachyAccessoryDeviceName()
	{
		Object objValue = getValue(0x300A,0x0266);
		if(objValue != null)
			return objValue.toString();
		return null;
	}


	/**
	 * Sets Material ID.Uniquely identifies Material ID(300A,00E1) in Brachy Accessory Device Sequence(300A,0260) in RT BRACHY APPLICATION SETUPS MODULE of RT Plan IOD.
	 * @param strMaterialID String value of Material ID.
	 */
	public void setMaterialID(String strMaterialID)
	{
		/*Accept the MaterialID 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(0x300A,0x00E1, strMaterialID,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x300A,0x00E1,DicomConstants.DCM_DT_SH, strMaterialID);

		addDataElement(objIDataElement);
	}
	/**
	 * Retrieves Material ID.
	 * @return String - value of Material ID.
	 */
	public String getMaterialID()
	{
		Object objValue = getValue(0x300A,0x00E1);
		if(objValue != null)
			return objValue.toString();
		return null;
	}


	/**
	 * Sets Brachy Accessory Device Nominal Thickness.Uniquely identifies Brachy Accessory Device Nominal Thickness(300A,026A) in Brachy Accessory Device Sequence(300A,0260) in RT BRACHY APPLICATION SETUPS MODULE of RT Plan IOD.
	 * @param strBrachyAccessoryDeviceNominalThickness String value of Brachy Accessory Device Nominal Thickness.
	 */
	public void setBrachyAccessoryDeviceNominalThickness(String strBrachyAccessoryDeviceNominalThickness)
	{
		/*Accept the BrachyAccessoryDeviceNominalThickness 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,0x026A, strBrachyAccessoryDeviceNominalThickness,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x300A,0x026A,DicomConstants.DCM_DT_DS, strBrachyAccessoryDeviceNominalThickness);

		addDataElement(objIDataElement);
	}
	/**
	 * Retrieves Brachy Accessory Device Nominal Thickness.
	 * @return String - value of Brachy Accessory Device Nominal Thickness.
	 */
	public String getBrachyAccessoryDeviceNominalThickness()
	{
		Object objValue = getValue(0x300A,0x026A);
		if(objValue != null)
			return objValue.toString();
		return null;
	}


	/**
	 * Sets Brachy Accessory Device Nominal Transmission.Uniquely identifies Brachy Accessory Device Nominal Transmission(300A,026C) in Brachy Accessory Device Sequence(300A,0260) in RT BRACHY APPLICATION SETUPS MODULE of RT Plan IOD.
	 * @param strBrachyAccessoryDeviceNominalTransmission String value of Brachy Accessory Device Nominal Transmission.
	 */
	public void setBrachyAccessoryDeviceNominalTransmission(String strBrachyAccessoryDeviceNominalTransmission)
	{
		/*Accept the BrachyAccessoryDeviceNominalTransmission 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,0x026C, strBrachyAccessoryDeviceNominalTransmission,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x300A,0x026C,DicomConstants.DCM_DT_DS, strBrachyAccessoryDeviceNominalTransmission);

		addDataElement(objIDataElement);
	}
	/**
	 * Retrieves Brachy Accessory Device Nominal Transmission.
	 * @return String - value of Brachy Accessory Device Nominal Transmission.
	 */
	public String getBrachyAccessoryDeviceNominalTransmission()
	{
		Object objValue = getValue(0x300A,0x026C);
		if(objValue != null)
			return objValue.toString();
		return null;
	}


	/**
	 * Sets Referenced ROI Number.Uniquely identifies Referenced ROI Number(3006,0084) in Brachy Accessory Device Sequence(300A,0260) in RT BRACHY APPLICATION SETUPS MODULE of RT Plan IOD.
	 * @param strReferencedROINumber String value of Referenced ROI Number.
	 */
	public void setReferencedROINumber(String strReferencedROINumber)
	{
		/*Accept the ReferencedROINumber 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(0x3006,0x0084, strReferencedROINumber,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x3006,0x0084,DicomConstants.DCM_DT_IS, strReferencedROINumber);

		addDataElement(objIDataElement);
	}
	/**
	 * Retrieves Referenced ROI Number.
	 * @return String - value of Referenced ROI Number.
	 */
	public String getReferencedROINumber()
	{
		Object objValue = getValue(0x3006,0x0084);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
}

