/*******************************************************************************
 *  Copyright 2017 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.ian.iansinkimpl;

import cdac.medinfo.sdk.dcm30_04.baselibs.CodingSchemeIdentificationSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ContributingEquipmentSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.DicomV3Factory;
import cdac.medinfo.sdk.dcm30_04.baselibs.EncryptedAttributesSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ReferencedPerformedProcedureStepSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ReferencedSeriesSequence;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataSet;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDictionaryReader;
import cdac.medinfo.sdk.dcm30_04.commoninterface.ITransferSyntax;
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 NCreateIANAttribute extends Attributes
{
	/**
	 * Sets Specific Character Set of File-set DEscriptor File. 
	 * @param strSpecificCharacterSetOfFileSetDEscriptorFile String value of Specific Character Set of File-set DEscriptor File.
	 */
	public void setSpecificCharacterSetOfFileSetDEscriptorFile(String strSpecificCharacterSetOfFileSetDEscriptorFile)
	{
		/*Accept Specific Character Set of File-set DEscriptor File 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 DataSet
		 */
		addDataElement(0x0004, 0x1142, DicomConstants.DCM_DT_CS, strSpecificCharacterSetOfFileSetDEscriptorFile);
	}
	
	/**
	 * Retrieves  ID of a File (in the same File-set) used for user comments related to the File-set .
	 * @return String[] - String array of File-Set DEscriptor File ID.
	 */
	public String[] getFileSetDEscriptorFileID()
	{
		Object objValue = getValue(0x0004,0x1141);
		if(objValue != null)
			return (String[])objValue;
		return null;
	}
	
	/**
	 * The method is used to set Unique identifier the SOP Class.
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This DE is then added to the Module DataSet.
	 * 
	 * @param strSOPClassUID the str sop class uid
	 */
	public void setSOPClassUID(String strSOPClassUID)
	{
		/*Accept Unique identifier the SOP Class in String format of type UI.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create.
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		addDataElement(0x0008,0x0016, DicomConstants.DCM_DT_UI, strSOPClassUID);
	}

	/**
	 * The method is used to set Unique identifier the SOP Instance.
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This DE is then added to the Module DataSet
	 * 
	 * @param strSOPInstanceUID  Unique identifier the SOP Instance.
	 */
	public void setSOPInstanceUID(String strSOPInstanceUID)
	{
		/*Accept Unique identifier the SOP Instance in String format of type UI.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create.
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		addDataElement(0x0008,0x0018, DicomConstants.DCM_DT_UI, strSOPInstanceUID);
	}

	/**
	 * This method is used to set Character Set that expands or replaces the Basic Graphic Set.
	 * The function accepts a String Value and creates the
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This DE is then added to the Module DataSet
	 * 
	 * @param arrStrSpecificCharacterSet  Character Set that expands or replaces the Basic Graphic Set.
	 */	
	public void setSpecificCharacterSet(String[] arrStrSpecificCharacterSet)
	{
		/*Accept  Character Set that expands or replaces the Basic Graphic Set
		 *  String Array format of type CS.
		 * Read the Transfer Syntax and check to create ImplicitDE or ExplicitDE .
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		addDataElement(0x0008, 0x0005, DicomConstants.DCM_DT_CS, arrStrSpecificCharacterSet);
	}

	/**
	 * The method is used to set Date the SOP Instance was created.
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This DE is then added to the Module DataSet
	 * 
	 * @param strInstanceCreationDate  Date the SOP Instance was created.
	 */
	public void setInstanceCreationDate(String strInstanceCreationDate)
	{
		/*Accept Date the SOP Instance was created in String format of type DA.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create.
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		addDataElement(0x0008,0x0012, DicomConstants.DCM_DT_DA, strInstanceCreationDate);
	}

	/**
	 * The method is used to set Time the SOP Instance was created.
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This DE is then added to the Module DataSet
	 * 
	 * @param strInstanceCreationTime  Time the SOP Instance was created.
	 */
	public void setInstanceCreationTime(String strInstanceCreationTime)
	{
		/*Accept Time the SOP Instance was created in String format of type TM.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create.
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		addDataElement(0x0008,0x0013, DicomConstants.DCM_DT_TM, strInstanceCreationTime);
	}

	/**
	 * The method is used to set Uniquely identifies device which created the SOP Instance.
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This DE is then added to the Module DataSet
	 * 
	 * @param strInstanceCreatorUID Uniquely identifies device which created the SOP Instance.
	 */
	public void setInstanceCreatorUID(String strInstanceCreatorUID)
	{
		/*Accept Uniquely identifies device which created the SOP Instance in String format of type UI.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create.
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		addDataElement(0x0008,0x0014, DicomConstants.DCM_DT_UI, strInstanceCreatorUID);
	}

	/**
	 * This method is used to set Uniquely identifies a Related General SOP Class
	 * for the SOP Class of this Instance.
	 * The function accepts a String Value and creates the
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This DE is then added to the Module DataSet
	 * 
	 * @param arrStrRelatedGeneralSOPClassUID  Uniquely identifies a Related General SOP Class
	 * for the SOP Class of this Instance.
	 */	
	public void setRelatedGeneralSOPClassUID(String[] arrStrRelatedGeneralSOPClassUID)
	{
		/*Accept  Uniquely identifies a Related General SOP Class 
		 * for the SOP Class of this Instance. 
		 * in String Array format of type UI.
		 * Read the Transfer Syntax and check to create ImplicitDE or ExplicitDE .
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		addDataElement(0x0008, 0x001A, DicomConstants.DCM_DT_UI, arrStrRelatedGeneralSOPClassUID);
	}

	/**
	 * The method is used to set The SOP Class in which the Instance was originally encoded,
	 * but which has been replaced during a fall-back conversion to the current Related General SOP Class.
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This DE is then added to the Module DataSet
	 * 
	 * @param strOriginalSpecializedSOPClassUID  Unique identifier of Original Specialized SOP Class.
	 */
	public void setOriginalSpecializedSOPClassUID(String strOriginalSpecializedSOPClassUID)
	{
		/*Accept The SOP Class in which the Instance was originally encoded, 
		 * 	but which has been replaced during a fall-back conversion to the current Related General SOP Class
		 * in String format of type UI.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create.
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		addDataElement(0x0008,0x001B, DicomConstants.DCM_DT_UI, strOriginalSpecializedSOPClassUID);
	}

	/**
	 * The method is used to set Contains the offset from UTC to the
	 * time zone for all DA and TM Attributes present in this SOP Instance.
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This DE is then added to the Module DataSet
	 * 
	 * @param strTimezoneOffsetFromUTC  Contains the offset from UTC to the time zone for all DA and TM Attributes present in this SOP Instance.
	 */
	public void setTimezoneOffsetFromUTC(String strTimezoneOffsetFromUTC)
	{
		/*Accept Contains the offset from UTC to the
		 * time zone for all DA and TM Attributes present in this SOP Instance  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
		 */
		addDataElement(0x0008,0x0201, DicomConstants.DCM_DT_SH, strTimezoneOffsetFromUTC);
	}

	/**
	 * The method is used to set A number that identifies this Composite object instance.
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This DE is then added to the Module DataSet
	 * 
	 * @param strInstanceNumber A number that identifies this Composite object instance.
	 */
	public void setInstanceNumber(String strInstanceNumber)
	{
		/*Accept Instance Number 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
		 */
		addDataElement(0x0020, 0x0013, DicomConstants.DCM_DT_IS, strInstanceNumber);
	}

	/**
	 * The method is used to set A flag that indicates the storage status of the SOP Instance.
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This DE is then added to the Module DataSet
	 * 
	 * @param strSOPInstanceStatus  A flag that indicates the storage status of the SOP Instance.
	 */
	public void setSOPInstanceStatus(String strSOPInstanceStatus)
	{
		/*Accept A flag that indicates the storage status of the SOP Instance 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(0x0100,0x0410, DicomConstants.DCM_DT_CS, strSOPInstanceStatus);
	}

	/**
	 * The method is used to set The date and time when the SOP Instance
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This DE is then added to the Module DataSet
	 * 
	 * @param strSOPAuthorizationDateandTime  The date and time when the SOP Instance
	 */
	public void setSOPAuthorizationDateandTime(String strSOPAuthorizationDateandTime)
	{
		/*Accept The date and time when the SOP Instance in String format 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(0x0100,0x0420, DicomConstants.DCM_DT_DT, strSOPAuthorizationDateandTime);
	}

	/**
	 * The method is used to set Any comments associated with the setting of the SOP Instance Status
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This DE is then added to the Module DataSet
	 * 
	 * @param strSOPAuthorizationComment  Any comments associated with the setting of the SOP Instance Status
	 */
	public void setSOPAuthorizationComment(String strSOPAuthorizationComment)
	{
		/*Accept Any comments associated with the setting of the SOP Instance Status in String format of type LT.
		 * 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(0x0100,0x0424, DicomConstants.DCM_DT_LT, strSOPAuthorizationComment);
	}

	/**
	 * The method is used to set The certification number issued to the
	 * Application Entity that set the SOP Instance Status.
	 * DE based on the transfer syntax and populates the DE with right values.
	 * This DE is then added to the Module DataSet
	 * 
	 * @param strAuthorizationEquipmentCertificationNumber  The certification number issued to the
	 * Application Entity that set the SOP Instance Status.
	 * 
	 * 
	 */
	public void setAuthorizationEquipmentCertificationNumber(String strAuthorizationEquipmentCertificationNumber)
	{
		/*Accept The certification number issued to the Application Entity that set 
		 * the SOP Instance Status 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(0x0100,0x0426, DicomConstants.DCM_DT_LO, strAuthorizationEquipmentCertificationNumber);
	}

	/**
	 * Retrieves the UID of SOP Class.
	 * 
	 * @return String - returns the UID of SOP Class
	 */
	public String getSOPClassUID()
	{
		Object objValue = getValue(0x0008,0x0016);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Retrieves the UID of SOP Instance.
	 * 
	 * @return String - returns the SOP Instance UID
	 */
	public String getSOPInstanceUID()
	{
		Object objValue = getValue(0x0008,0x0018);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Retrieves the Specific Character Set.
	 * 
	 * @return String[] - returns the Specific Character Set
	 */
	public String[] getSpecificCharacterSet()
	{
		Object objValue = getValue(0x0008, 0x0005);
		if(objValue != null)
			return (String[])objValue;
		return null;
	}

	/**
	 * Retrieves the Instance Creation Date.
	 * 
	 * @return String - returns the Date of Instance Creation
	 */
	public String getInstanceCreationDate()
	{
		Object objValue = getValue(0x0008,0x0012);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Retrieves the Instance Creation Time.
	 * 
	 * @return String - returns the Time of Instance Creation
	 */
	public String getInstanceCreationTime()
	{
		Object objValue = getValue(0x0008,0x0013);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Retrieves the UID of Instance Creator.
	 * 
	 * @return String - return the Instance Creator UID
	 */
	public String getInstanceCreatorUID()
	{
		Object objValue = getValue(0x0008,0x0014);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Retrieves the UID of Related General SOP Class.
	 * 
	 * @return String - returns Related General SOP Class UID
	 */
	public String[] getRelatedGeneralSOPClassUID()
	{
		Object objValue = getValue(0x0008, 0x001A);
		if(objValue != null)
			return (String[])objValue;
		return null;
	}

	/**
	 * Retrieves the Original Specialized SOP Class UID.
	 * 
	 * @return String - returns the UID of Original Specialized SOP Class
	 */
	public String getOriginalSpecializedSOPClassUID()
	{
		Object objValue = getValue(0x0008,0x001B);
		if(objValue != null)
			return (String)objValue;
		return null;
	}

	/**
	 * Retrieves the Time zone Offset From UTC.
	 * 
	 * @return String - returns Time zone Offset From UTC
	 */
	public String getTimezoneOffsetFromUTC()
	{
		Object objValue = getValue(0x0008,0x0201);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * This method provides the pre-initialized object of Contributing Equipment Sequence.
	 * 
	 * @return objContributingEquipmentSequence - object of Contributing Equipment Sequence. If the module contains the sequence object
	 * it returns the same otherwise it creates the sequence adds to the module with proper initialization
	 * and then returns the object of sequence
	 */
	public ContributingEquipmentSequence getContributingEquipmentSequence()
	{
		ContributingEquipmentSequence objContributingEquipmentSequence = (ContributingEquipmentSequence)getDicomValue(0x0018, 0xA001);
		if(objContributingEquipmentSequence == 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.
			 */
			ITransferSyntax objITransferSyntax = getDataSet().getTransferSyntax();
			IDictionaryReader objIDictionaryReader = getDataSet().getDictionaryReader();
			
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			objContributingEquipmentSequence = (ContributingEquipmentSequence)objDicomV3Factory.createSequence(0x0018, 0xA001, objITransferSyntax, objIDictionaryReader);
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0018, 0xA001, DicomConstants.DCM_DT_SQ, objContributingEquipmentSequence.getValue());
		}
		return objContributingEquipmentSequence;
	}

	/**
	 * This method provides the pre-initialized object of Contributing Equipment Sequence.
	 * 
	 * @return objCodingSchemeIdentificationSequence - object of Contributing Equipment Sequence. If the module contains the sequence object
	 * it returns the same otherwise it creates the sequence adds to the module with proper initialization
	 * and then returns the object of sequence
	 */
	public CodingSchemeIdentificationSequence getCodingSchemeIdentificationSequence()
	{
		CodingSchemeIdentificationSequence objCodingSchemeIdentificationSequence = (CodingSchemeIdentificationSequence)getDicomValue(0x0008, 0x0110);
		if(objCodingSchemeIdentificationSequence == 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.
			 */
			ITransferSyntax objITransferSyntax = getDataSet().getTransferSyntax();
			IDictionaryReader objIDictionaryReader = getDataSet().getDictionaryReader();
			
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			objCodingSchemeIdentificationSequence = (CodingSchemeIdentificationSequence)objDicomV3Factory.createSequence(0x0008, 0x0110, objITransferSyntax, objIDictionaryReader);
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0008, 0x0110, DicomConstants.DCM_DT_SQ, objCodingSchemeIdentificationSequence.getValue());
		}
		return objCodingSchemeIdentificationSequence;
	}

	/**
	 * This method provides the pre-initialized object of Contributing Equipment Sequence.
	 * 
	 * @return objEncryptedAttributesSequence - object of Contributing Equipment Sequence. If the module contains the sequence object
	 * it returns the same otherwise it creates the sequence adds to the module with proper initialization
	 * and then returns the object of sequence
	 */
	public EncryptedAttributesSequence getEncryptedAttributesSequence()
	{
		EncryptedAttributesSequence objEncryptedAttributesSequence = (EncryptedAttributesSequence)getDicomValue(0x0400, 0x0500);
		if(objEncryptedAttributesSequence == 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.
			 */
			ITransferSyntax objITransferSyntax = getDataSet().getTransferSyntax();
			IDictionaryReader objIDictionaryReader = getDataSet().getDictionaryReader();
			
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			objEncryptedAttributesSequence = (EncryptedAttributesSequence)objDicomV3Factory.createSequence(0x0400, 0x0500, objITransferSyntax, objIDictionaryReader);
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0400, 0x0500, DicomConstants.DCM_DT_SQ, objEncryptedAttributesSequence.getValue());
		}
		return objEncryptedAttributesSequence;
	}

	/**
	 * Retrieves the Instance Number.
	 * 
	 * @return String - returns  Instance Number
	 */
	public String getInstanceNumber()
	{
		Object objValue = getValue(0x0020,0x0013);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Retrieves the status of SOPInstance.
	 * 
	 * @return String - returns SOP Instance Status
	 */
	public String getSOPInstanceStatus()
	{
		Object objValue = getValue(0x0100,0x0410);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Retrieves the SOP Authorization Date and Time.
	 * 
	 * @return String - returns SOP Authorization Date and Time
	 */
	public String getSOPAuthorizationDateandTime()
	{
		Object objValue = getValue(0x0100,0x0420);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Retrieves the comment for SOP Authorization.
	 * 
	 * @return String - returns SOP Authorization Comment
	 */
	public String getSOPAuthorizationComment()
	{
		Object objValue = getValue(0x0100,0x0424);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Retrieves Authorization Equipment Certification Number.
	 * 
	 * @return String - the number of Authorization Equipment Certification
	 */
	public String getAuthorizationEquipmentCertificationNumber()
	{
		Object objValue = getValue(0x0100,0x0426);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Returns provides the pre-initialized object of Referenced Performed Procedure Step Sequence.If the module contains the sequence object
	 * it returns the same otherwise it creates the sequence adds to the module with proper initialization
	 * and then returns the object of sequence
	 * 
	 * @return - object of Referenced Performed Procedure Step Sequence.
	 */
	public ReferencedPerformedProcedureStepSequence getReferencedPerformedProcedureStepSequence()
	{
		ReferencedPerformedProcedureStepSequence objReferencedPerformedProcedureStepSequence = (ReferencedPerformedProcedureStepSequence)getDicomValue(0x0008, 0x1111);
		if(objReferencedPerformedProcedureStepSequence == null)
		{
			/*
			 * If the sequence object is not present in the DataSet, a new sequence object is created and
			 * the TransferSyntax and DictionaryReader is set into it as it is set in the Module. This ensures that 
			 * the DataElements getting added in the DataSet follow the same TransferSyntax and use the same
			 * DictionaryReader object as that of the module.
			 */
			ITransferSyntax objITransferSyntax = getDataSet().getTransferSyntax();
			IDictionaryReader objIDictionaryReader = getDataSet().getDictionaryReader();
			
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			objReferencedPerformedProcedureStepSequence = (ReferencedPerformedProcedureStepSequence)objDicomV3Factory.createSequence(0x0008, 0x1111, objITransferSyntax, objIDictionaryReader);
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0008, 0x1111, DicomConstants.DCM_DT_SQ, objReferencedPerformedProcedureStepSequence.getValue());
		}
		return objReferencedPerformedProcedureStepSequence;
	}
	
	/**
	 * Sets Unique Study identification that shall be used for the created Composite SOP Instances resulting from this General Purpose Scheduled Procedure Step.
	 * 
	 * @param strStudyInstanceUID Unique identifier for the Study.
	 */
	public void setStudyInstanceUID(String strStudyInstanceUID)
	{
		/*Accept Unique identifier for the Study in String format of type UI.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create.
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Hash Map
		 */
		addDataElement(0x0020, 0x000D, DicomConstants.DCM_DT_UI, strStudyInstanceUID);
	}
	
	/**
	 * Retrieves Unique Study identification that shall be used for the created Composite SOP Instances resulting from this General Purpose Scheduled Procedure Step.
	 * 
	 * @return String - String value of Study Instance UID
	 */
	public String getStudyInstanceUID()
	{
		Object objValue = getValue(0x0020,0x000D);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Retrieves pre-initialized object of ReferencedSeriesSequence.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 ReferencedSeriesSequence - instance of Referenced Series Sequence
	 */
	public ReferencedSeriesSequence getReferencedSeriesSequence()
	{
		ReferencedSeriesSequence objReferencedSeriesSequence = (ReferencedSeriesSequence)getDicomValue(0x0008,0x1115);
		if(objReferencedSeriesSequence == 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.
			 */
			ITransferSyntax objITransferSyntax = getDataSet().getTransferSyntax();
			IDictionaryReader objIDictionaryReader = getDataSet().getDictionaryReader();
			
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			objReferencedSeriesSequence = (ReferencedSeriesSequence)objDicomV3Factory.createSequence(0x0008,0x1115, objITransferSyntax, objIDictionaryReader);
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0008,0x1115, DicomConstants.DCM_DT_SQ, objReferencedSeriesSequence.getValue());
		}
		return objReferencedSeriesSequence;
	}
	
	/**
	 * 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);
	}
}
