/*******************************************************************************
 *  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.ComponentAssemblySequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ComponentTypesSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.DerivationImplantAssemblyTemplateSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.DicomV3Factory;
import cdac.medinfo.sdk.dcm30_04.baselibs.ImplantAssemblyTemplateTargetAnatomySequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.OriginalImplantAssemblyTemplateSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ProcedureTypeCodeSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ReplacedImplantAssemblyTemplateSequence;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataSet;
import cdac.medinfo.sdk.dcm30_04.enums.EnumImplantAssemblyTemplateType;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConstants;
import cdac.medinfo.sdk.dcm30_04.utils.ISingleCollection;

/**
 *  This class contains the Attributes required for Query Model. Also contains methods to populate and fill data set of Query Model.
 */
public class ImplantAssemblyTemplateAttributes 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 Assembly Template  Name.
	 * @param strImplantAssemblyTemplateName String value of Implant Assembly Template  Name
	 */
	public void setImplantAssemblyTemplateName(String strImplantAssemblyTemplateName)
	{
		/* Accept the Implant Template 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(0x0076, 0x0001,DicomConstants.DCM_DT_LO,strImplantAssemblyTemplateName);
	}

	/**
	 * Return Implant Assembly Template  Name
	 * @return String - value of Implant Assembly Template  Name
	 */
	public String getImplantAssemblyTemplateName()
	{
		Object objValue = getValue(0x0076, 0x0001);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	/**
	 * Sets Implant Assembly Template Issuer
	 * @param strImplantAssemblyTemplateIssuer String value of Implant Assembly Template Issuer
	 */
	public void setImplantAssemblyTemplateIssuer(String strImplantAssemblyTemplateIssuer)
	{
		/* Accept the Implant Assembly Template 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(0x0076, 0x0003,DicomConstants.DCM_DT_LO,strImplantAssemblyTemplateIssuer);
	}

	/**
	 * Return Implant Assembly Template Issuer
	 * @return String - value of Implant Assembly Template Issuer
	 */
	public String getImplantAssemblyTemplateIssuer()
	{
		Object objValue = getValue(0x0076, 0x0003);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	/**
	 * Sets Implant Assembly TemplateVersion
	 * @param strImplantAssemblyTemplateVersion String value of Implant Assembly Template Version
	 */
	public void setImplantAssemblyTemplateVersion(String strImplantAssemblyTemplateVersion)
	{
		/* Accept the Implant Assembly TemplateVersion 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(0x0076, 0x0006,DicomConstants.DCM_DT_LO,strImplantAssemblyTemplateVersion);
	}

	/**
	 * Return Implant Implant Assembly TemplateVersion
	 * @return String - value of Implant Assembly TemplateVersion
	 */
	public String getImplantAssemblyTemplateVersion()
	{
		Object objValue = getValue(0x0076, 0x0006);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	/**
	 * Sets whether the Implant Assembly Template is derived from another Instance.
	 *Enumerated Values:
	 *ORIGINAL
	 *DERIVED
	 * @param enumImplantAssemblyTemplateType  enum value of Implant Assembly Template Type .
	 */
	public void setImplantAssemblyTemplateType (EnumImplantAssemblyTemplateType enumImplantAssemblyTemplateType)
	{
		/* Accept the Implant Assembly Template 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(0x0076, 0x000A,DicomConstants.DCM_DT_CS,enumImplantAssemblyTemplateType);
	}
	/**
	 * Return Implant Assembly Template Type . 
	 * @return String - value of Implant Assembly Template Type.
	 */
	public String getImplantAssemblyTemplateType ()
	{
		Object objValue = getValue(0x0076,0x000A);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	/**
	 * Sets Surgical Technique
	 * @param strSurgicalTechnique String value of Surgical Technique
	 */
	public void setSurgicalTechnique(String strSurgicalTechnique)
	{
		/* Accept the Surgical Technique 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(0x0076, 0x0030,DicomConstants.DCM_DT_LO,strSurgicalTechnique);
	}
	/**
	 * Return Surgical Technique
	 * @return String - value of Surgical Technique
	 */
	public String getSurgicalTechnique()
	{
		Object objValue = getValue(0x0076, 0x0030);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	/**
	 * Sets MIME Type of EncapsulatedDocument
	 * @param strMIMETypeOfEncapsulatedDocument String value of MIME Type of EncapsulatedDocument
	 */
	public void setMIMETypeOfEncapsulatedDocument(String strMIMETypeOfEncapsulatedDocument)
	{
		/* Accept the MIME Type of EncapsulatedDocument 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(0x0042, 0x0012,DicomConstants.DCM_DT_LO,strMIMETypeOfEncapsulatedDocument);
	}
	/**
	 * Return MIME Type of EncapsulatedDocument
	 * @return String - value of MIME Type of EncapsulatedDocument
	 */
	public String getMIMETypeOfEncapsulatedDocument()
	{
		Object objValue = getValue(0x0042, 0x0012);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	/**
	 * Sets Encapsulated Document stream, containing a documente coded according to the MIME Type.
	 * @param vectEncapsulatedDocument collection of byte array of Encapsulated Document
	 */
	public void setEncapsulatedDocument(ISingleCollection<byte[]> vectEncapsulatedDocument)
	{
		/*Accept the EncapsulatedDocument in vector of byte array format of type OB.
		 * 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(0x0042, 0x0011,DicomConstants.DCM_DT_OB,vectEncapsulatedDocument);
	}

	/**
	 * Retrieves Encapsulated Document stream, containing a document coded according to the MIME Type.
	 * @return ISingleCollection<byte[]> - collection of byte array of Encapsulated Document
	 */
	@SuppressWarnings("unchecked")
	public ISingleCollection<byte[]> getEncapsulatedDocument()
	{
		Object objValue = getValue(0x0042, 0x0011);
		if(objValue != null)
			return (ISingleCollection<byte[]>)objValue;
		return null;
	}

	/**
	 * Retrieves pre-initialized object of Replaced Implant AssemblyTemplate 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 ReplacedImplantAssemblyTemplateSequence - Replaced Implant AssemblyTemplate Sequence.
	 */
	public ReplacedImplantAssemblyTemplateSequence getReplacedImplantAssemblyTemplateSequence()
	{
		ReplacedImplantAssemblyTemplateSequence objReplacedImplantAssemblyTemplateSequence = (ReplacedImplantAssemblyTemplateSequence)getDicomValue(0x0076, 0x0008);
		if(objReplacedImplantAssemblyTemplateSequence == 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();
			objReplacedImplantAssemblyTemplateSequence = (ReplacedImplantAssemblyTemplateSequence)objDicomV3Factory.createSequence(0x0076, 0x0008, getDataSet().getTransferSyntax(), getDataSet().getDictionaryReader());
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0076, 0x0008, DicomConstants.DCM_DT_SQ, objReplacedImplantAssemblyTemplateSequence.getValue());
		}
		return objReplacedImplantAssemblyTemplateSequence;
	}
	/**
	 * Retrieves pre-initialized object of Original Implant AssemblyTemplate 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 OriginalImplantAssemblyTemplateSequence - Original Implant AssemblyTemplate Sequence.
	 */
	public OriginalImplantAssemblyTemplateSequence getOriginalImplantAssemblyTemplateSequence()
	{
		OriginalImplantAssemblyTemplateSequence objOriginalImplantAssemblyTemplateSequence = (OriginalImplantAssemblyTemplateSequence)getDicomValue(0x0076,0x000C);
		if(objOriginalImplantAssemblyTemplateSequence == 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();
			objOriginalImplantAssemblyTemplateSequence = (OriginalImplantAssemblyTemplateSequence)objDicomV3Factory.createSequence(0x0076,0x000C, getDataSet().getTransferSyntax(), getDataSet().getDictionaryReader());
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0076,0x000C, DicomConstants.DCM_DT_SQ, objOriginalImplantAssemblyTemplateSequence.getValue());
		}
		return objOriginalImplantAssemblyTemplateSequence;
	}
	
	/**
	 * Retrieves pre-initialized object of Derivation Implant AssemblyTemplate 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 DerivationImplantAssemblyTemplateSequence - Derivation Implant AssemblyTemplate Sequence.
	 */
	public DerivationImplantAssemblyTemplateSequence getDerivationImplantAssemblyTemplateSequence()
	{
		DerivationImplantAssemblyTemplateSequence objDerivationImplantAssemblyTemplateSequence = (DerivationImplantAssemblyTemplateSequence)getDicomValue(0x0076, 0x000E);
		if(objDerivationImplantAssemblyTemplateSequence == 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();
			objDerivationImplantAssemblyTemplateSequence = (DerivationImplantAssemblyTemplateSequence)objDicomV3Factory.createSequence(0x0076, 0x000E, getDataSet().getTransferSyntax(), getDataSet().getDictionaryReader());
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0076, 0x000E, DicomConstants.DCM_DT_SQ, objDerivationImplantAssemblyTemplateSequence.getValue());
		}
		return objDerivationImplantAssemblyTemplateSequence;
	}	
	/**
	 * Retrieves pre-initialized object of Implant Assembly Template TargetAnatomy 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 ImplantAssemblyTemplateTargetAnatomySequence - Implant Assembly Template TargetAnatomy Sequence
	 */
	public ImplantAssemblyTemplateTargetAnatomySequence getImplantAssemblyTemplateTargetAnatomySequence()
	{
		ImplantAssemblyTemplateTargetAnatomySequence objImplantAssemblyTemplateTargetAnatomySequence = (ImplantAssemblyTemplateTargetAnatomySequence)getDicomValue(0x0076, 0x0010);
		if(objImplantAssemblyTemplateTargetAnatomySequence == 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();
			objImplantAssemblyTemplateTargetAnatomySequence = (ImplantAssemblyTemplateTargetAnatomySequence)objDicomV3Factory.createSequence(0x0076, 0x0010, getDataSet().getTransferSyntax(), getDataSet().getDictionaryReader());
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0076, 0x0010, DicomConstants.DCM_DT_SQ, objImplantAssemblyTemplateTargetAnatomySequence.getValue());
		}
		return objImplantAssemblyTemplateTargetAnatomySequence;
	}
	
	/**
	 * Retrieves pre-initialized object of Procedure Type 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 ProcedureTypeCodeSequence - Procedure Type Code Sequence
	 */
	public ProcedureTypeCodeSequence getProcedureTypeCodeSequence()
	{
		ProcedureTypeCodeSequence objProcedureTypeCodeSequence = (ProcedureTypeCodeSequence)getDicomValue(0x0076, 0x0020);
		if(objProcedureTypeCodeSequence == 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();
			objProcedureTypeCodeSequence = (ProcedureTypeCodeSequence)objDicomV3Factory.createSequence(0x0076, 0x0020, getDataSet().getTransferSyntax(), getDataSet().getDictionaryReader());
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0076, 0x0020, DicomConstants.DCM_DT_SQ, objProcedureTypeCodeSequence.getValue());
		}
		return objProcedureTypeCodeSequence;	
	}
	/**
	 * Retrieves pre-initialized object of Component Types 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 ComponentTypesSequence - Component Types Sequence
	 */
	public ComponentTypesSequence getComponentTypesSequence()
	{
		ComponentTypesSequence objComponentTypesSequence = (ComponentTypesSequence)getDicomValue(0x0076, 0x0032);
		if(objComponentTypesSequence == 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();
			objComponentTypesSequence = (ComponentTypesSequence)objDicomV3Factory.createSequence(0x0076, 0x0032, getDataSet().getTransferSyntax(), getDataSet().getDictionaryReader());
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0076, 0x0032, DicomConstants.DCM_DT_SQ, objComponentTypesSequence.getValue());
		}
		return objComponentTypesSequence;	
	}
	/**
	 * Retrieves pre-initialized object of Component Assembly 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 ComponentAssemblySequence - Component Assembly Sequence
	 */
	public ComponentAssemblySequence getComponentAssemblySequence()
	{
		ComponentAssemblySequence objComponentAssemblySequence = (ComponentAssemblySequence)getDicomValue(0x0076, 0x0060);
		if(objComponentAssemblySequence == 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();
			objComponentAssemblySequence = (ComponentAssemblySequence)objDicomV3Factory.createSequence(0x0076, 0x0060, getDataSet().getTransferSyntax(), getDataSet().getDictionaryReader());
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0076, 0x0060, DicomConstants.DCM_DT_SQ, objComponentAssemblySequence.getValue());
		}
		return objComponentAssemblySequence;	
	}
	/**
	 * 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);
	}
	
}
