/*******************************************************************************
 *  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.services.implanttemplate.sourceimpl;

import cdac.medinfo.sdk.dcm30_04.baselibs.DicomV3Factory;
import cdac.medinfo.sdk.dcm30_04.baselibs.ReplacedImplantTemplateGroupSequence;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataSet;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConstants;
/**
 *  This class contains the Attributes required for Query Model. Also contains methods to populate and fill data set of Query Model.
 */
public class ImplantTemplateGroupAttributes extends Attributes
{
	/**
	 * Sets Effective DateTime
	 * @param strEffectiveDateTime String value of Effective DateTime
	 */
	public void setEffectiveDateTime(String strEffectiveDateTime)
	{
		/* Accept the Effective DateTime of type DT.
		 * 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(0x0068, 0x6226,DicomConstants.DCM_DT_DT,strEffectiveDateTime);
	}

	/**
	 * Retrieves Effective DateTime
	 * @return String - value of Effective DateTime
	 */
	public String getEffectiveDateTime()
	{
		Object objValue = getValue(0x0068, 0x6226);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	/**
	 * Sets Implant Template Group Name.
	 * @param strImplantTemplateGroupName String value of Implant Template Group Name.
	 */
	public void setImplantTemplateGroupName(String strImplantTemplateGroupName)
	{
		/* Accept the Implant Template Group Name 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
		 */
		addDataElement(0x0078, 0x0001,DicomConstants.DCM_DT_LO,strImplantTemplateGroupName);
	}

	/**
	 * Return Implant Template Group Name
	 * @return String - value of Implant Template Group Name
	 */
	public String getImplantTemplateGroupName()
	{
		Object objValue = getValue(0x0078, 0x0001);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	/**
	 * Sets Implant Template Group Description
	 * @param strImplantTemplateGroupDescription String value of Implant Template Group Description
	 */
	public void setImplantTemplateGroupDescription(String strImplantTemplateGroupDescription)
	{
		/*Accept the ImplantTemplateGroupDescription 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
		 */
		addDataElement(0x0078, 0x0010,DicomConstants.DCM_DT_ST,strImplantTemplateGroupDescription);
	}

	/**
	 * Retrieves Implant Template Group Description
	 * @return String value of Implant Template Group Description
	 */
	public String getImplantTemplateGroupDescription()
	{
		Object objValue = getValue(0x0078, 0x0010);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	/**
	 * Sets Implant Template Group Issuer
	 * @param strImplantTemplateGroupIssuer String value of Implant Template Group Issuer
	 */
	public void setImplantTemplateGroupIssuer(String strImplantTemplateGroupIssuer)
	{
		/* Accept the Implant Template Group Issuer 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
		 */
		addDataElement(0x0078, 0x0020,DicomConstants.DCM_DT_LO,strImplantTemplateGroupIssuer);
	}

	/**
	 * Return Implant Template Group Issuer
	 * @return String - value of Implant Template Group Issuer
	 */
	public String getImplantTemplateGroupIssuer()
	{
		Object objValue = getValue(0x0078, 0x0020);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Sets Implant Template Group Version
	 * @param strImplantTemplateGroupVersion String value of Implant Template Group Version
	 */
	public void setImplantTemplateGroupVersion(String strImplantTemplateGroupVersion)
	{
		/* Accept the Implant Template Group Issuer 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
		 */
		addDataElement(0x0078, 0x0024,DicomConstants.DCM_DT_LO,strImplantTemplateGroupVersion);
	}

	/**
	 * Return Implant Template Group Version
	 * @return String - value of Implant Template Group Version
	 */
	public String getImplantTemplateGroupVersion()
	{
		Object objValue = getValue(0x0078, 0x0024);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Retrieves pre-initialized object of Replaced Implant Template GroupSequence. 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 ReplacedImplantTemplateGroupSequence - Replaced Implant Template GroupSequence.
	 */
	public ReplacedImplantTemplateGroupSequence getReplacedImplantTemplateGroupSequence()
	{
		ReplacedImplantTemplateGroupSequence objReplacedImplantTemplateGroupSequence = (ReplacedImplantTemplateGroupSequence)getDicomValue(0x0078, 0x0026);
		if(objReplacedImplantTemplateGroupSequence == 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();
			objReplacedImplantTemplateGroupSequence = (ReplacedImplantTemplateGroupSequence)objDicomV3Factory.createSequence(0x0078, 0x0026, getDataSet().getTransferSyntax(), getDataSet().getDictionaryReader());
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0078, 0x0026, DicomConstants.DCM_DT_SQ, objReplacedImplantTemplateGroupSequence.getValue());
		}
		return objReplacedImplantTemplateGroupSequence;
	}
	/**
	 * Populates the query Model using filled data set.
	 */
	public void populate(IDataSet objIDataSet)
	{
		super.populate(objIDataSet);
	}	
	
	/**
	 * Fills the data set using already populated Query Model.
	 */
	public void fill(IDataSet objIDataSet)
	{
		super.fill(objIDataSet);
	}

}
