/*******************************************************************************
 *  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.srtree;

import cdac.medinfo.sdk.dcm30_04.baselibs.CodeMacro;
import cdac.medinfo.sdk.dcm30_04.baselibs.CodeSequenceMacro;
import cdac.medinfo.sdk.dcm30_04.baselibs.CodeSequenceMacroDependentItem;
import cdac.medinfo.sdk.dcm30_04.baselibs.CompositeObjectReferenceMacro;
import cdac.medinfo.sdk.dcm30_04.baselibs.ConceptCodeSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ConceptNameCodeSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ContentSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ContentSequenceItem;
import cdac.medinfo.sdk.dcm30_04.baselibs.DocumentContentMacro;
import cdac.medinfo.sdk.dcm30_04.baselibs.DocumentRelationshipMacro;
import cdac.medinfo.sdk.dcm30_04.baselibs.IconImageSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.IconImageSequenceItem;
import cdac.medinfo.sdk.dcm30_04.baselibs.ImagePixelMacro;
import cdac.medinfo.sdk.dcm30_04.baselibs.ImageReferenceMacro;
import cdac.medinfo.sdk.dcm30_04.baselibs.MeasuredValueSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.MeasuredValueSequenceItem;
import cdac.medinfo.sdk.dcm30_04.baselibs.MeasurementUnitsCodeSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.NumericMeasurementMacro;
import cdac.medinfo.sdk.dcm30_04.baselibs.NumericValueQualifierCodeSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ReferencedSOPSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ReferencedSOPSequenceItem;
import cdac.medinfo.sdk.dcm30_04.baselibs.SpatialCoordinatesMacro;
import cdac.medinfo.sdk.dcm30_04.baselibs.TemporalCoordinatesMacro;
import cdac.medinfo.sdk.dcm30_04.baselibs.WaveformReferenceMacro;
import cdac.medinfo.sdk.dcm30_04.enums.EnumContinuityOfContent;
import cdac.medinfo.sdk.dcm30_04.enums.EnumGraphicType;
import cdac.medinfo.sdk.dcm30_04.enums.EnumRelationshipType;
import cdac.medinfo.sdk.dcm30_04.enums.EnumTemporalRangeType;
import cdac.medinfo.sdk.dcm30_04.enums.EnumValueType;
import cdac.medinfo.sdk.dcm30_04.utils.ISingleCollection;
import cdac.medinfo.sdk.dcm30_04.utils.SingleCollection;
/**
 *	This class provides APIs for creating different NODEs of different Valu Types.
 */
public class SRNode 
{
	/**
	 * Objecr of ContentSequenceItem.
	 */
	private ContentSequenceItem objContentSequenceItem;

	/**
	 * Instantiate Object of SRNode.
	 * @param objContentSequenceItem Object of ContentSequenceItem.
	 */
	public SRNode(ContentSequenceItem objContentSequenceItem)
	{
		this.objContentSequenceItem = objContentSequenceItem;
	}

//	public ContentSequenceItem getContentSequenceItem() 
//	{
//		return this.objContentSequenceItem;
//	}
	
	/**
	 * Calculates the Referenced Content Item Identifier
	 * @return arrTargetIdentifier integer array of identifier
	 */
	@SuppressWarnings("unchecked")
	private int[] getTargetReferencedContentItemIdentifier()
	{
		// Retrieve the Item Identifier of node.
		int []arrSourceIdentifier = this.objContentSequenceItem.getReferencedContentItemIdentifier();
		int iLenght = arrSourceIdentifier.length;

		//To get Content Sequence of Source Content Sequence in which new item is to be added.
		ContentSequence objContentSequenceInSource = this.objContentSequenceItem.getDocumentRelationshipMacro().getContentSequence();
		ISingleCollection<ContentSequenceItem> objCollection = (ISingleCollection<ContentSequenceItem>)objContentSequenceInSource.getValue();
		//Number of items already present in Source Content Sequence.
		int iNoOfItemsPresent = objCollection.size();

		//Creating the Target Content Item Identifier
		int []arrTargetIdentifier = new int [iLenght + 1];
		for(int i = 0 ; i < iLenght; i++)
		{
			arrTargetIdentifier[i] = arrSourceIdentifier[i];
		}
		
		if(iNoOfItemsPresent == 0)		//NO items added previously.
		{
			arrTargetIdentifier[iLenght] = 1;
		}
		else if(iNoOfItemsPresent > 0)					//Items added previously.
		{
			arrTargetIdentifier[iLenght] = iNoOfItemsPresent + 1;
		}
		
		{
			getPosition1(arrTargetIdentifier);
		}
		
		return arrTargetIdentifier;
	}

	/**
	 * Adds the node of type PNAME.
	 * @param strCodeMeaning String value for Code Meaning.
	 * @param strCodeValue string for CodeValue.
	 * @param strCodeSchemeDesignator string value for CodeSchemeDesignator.
	 * @param strValue string value for node which will describ that node.
	 * 					 eg : if node which will be added ie of value type PANME, the strValue will define its name.
	 * @param enumRelationshipType Enum value for Relationship Type between the (enclosing) Source Content Item and the Target Content Item.
	 * @return objNode object of SRNode.
	 */
	public  SRNode addPnameNode(String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,String strValue,EnumRelationshipType enumRelationshipType)
	{
		//To get Referenced Content Item Identifier of Target Item
		int []arrTargetIdentifier = getTargetReferencedContentItemIdentifier();
		
		ContentSequenceItem objContentSequenceItem = createNode(arrTargetIdentifier,strCodeMeaning, strCodeValue, strCodeSchemeDesignator, EnumValueType.PNAME, strValue,enumRelationshipType);
		SRNode objNode = new SRNode(objContentSequenceItem);

		//To get Content Sequence of Source Content Sequence in which new item is to be added.
		ContentSequence objContentSequenceInSource = this.objContentSequenceItem.getDocumentRelationshipMacro().getContentSequence();
		objContentSequenceInSource.addItem(objContentSequenceItem);

		return objNode;
	}
	
	/**
	 * Creates a node of type TEXT,
	 * @param strCodeMeaning String value for Code Meaning.
	 * @param strCodeValue string for CodeValue.
	 * @param strCodeSchemeDesignator string value for CodeSchemeDesignator.
	 * @param strValue string value for node which will describ that node.
	 * 					 eg : if node which will be added ie of value type TEXT, the strValue will define its value.
	 * @param enumRelationshipType Enum value for Relationship Type between the (enclosing) Source Content Item and the Target Content Item.
	 * @return objNode object of SRNode.
	 */
	public  SRNode addTextNode(String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,String strValue,EnumRelationshipType enumRelationshipType)
	{
		//To get Referenced Content Item Identifier of Target Item
		int []arrTargetIdentifier = getTargetReferencedContentItemIdentifier();
		
		ContentSequenceItem objContentSequenceItem = createNode(arrTargetIdentifier,strCodeMeaning, strCodeValue, strCodeSchemeDesignator, EnumValueType.TEXT, strValue, enumRelationshipType);
		SRNode objNode = new SRNode(objContentSequenceItem);

		//To get Content Sequence of Source Content Sequence in which new item is to be added.
		ContentSequence objContentSequenceInSource = this.objContentSequenceItem.getDocumentRelationshipMacro().getContentSequence();
		objContentSequenceInSource.addItem(objContentSequenceItem);

		return objNode;
	}
	
	/**
	 * Creates a node of type TIME
	 * @param strCodeMeaning String value for Code Meaning.
	 * @param strCodeValue string for CodeValue.
	 * @param strCodeSchemeDesignator string value for CodeSchemeDesignator.
	 * @param strValue string value for node which will describ that node.
	 * 					 eg : if node which will be added ie of value type TIME, the strValue will define its value.
	 * @param enumRelationshipType Enum value for Relationship Type between the (enclosing) Source Content Item and the Target Content Item.
	 * @return objNode object of SRNode.
	 */
	public  SRNode addTimeNode(String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,String strValue,EnumRelationshipType enumRelationshipType)
	{
		//To get Referenced Content Item Identifier of Target Item
		int []arrTargetIdentifier = getTargetReferencedContentItemIdentifier();
		
		ContentSequenceItem objContentSequenceItem = createNode(arrTargetIdentifier,strCodeMeaning, strCodeValue, strCodeSchemeDesignator, EnumValueType.TIME, strValue, enumRelationshipType);
		SRNode objNode = new SRNode(objContentSequenceItem);

		//To get Content Sequence of Source Content Sequence in which new item is to be added.
		ContentSequence objContentSequenceInSource = this.objContentSequenceItem.getDocumentRelationshipMacro().getContentSequence();
		objContentSequenceInSource.addItem(objContentSequenceItem);

		return objNode;
	}
	
	/**
	 * Creates a node of type DATETIME
	 * @param strCodeMeaning String value for Code Meaning.
	 * @param strCodeValue string for CodeValue.
	 * @param strCodeSchemeDesignator string value for CodeSchemeDesignator.
	 * @param strValue string value for node which will describ that node.
	 * 					 eg : if node which will be added ie of value type DATETIME, the strValue will define its value.
	 * @param enumRelationshipType Enum value for Relationship Type between the (enclosing) Source Content Item and the Target Content Item.
	 * @return objNode object of SRNode.
	 */
	public  SRNode addDateTimeNode(String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,String strValue,EnumRelationshipType enumRelationshipType)
	{
		//To get Referenced Content Item Identifier of Target Item
		int []arrTargetIdentifier = getTargetReferencedContentItemIdentifier();
		
		ContentSequenceItem objContentSequenceItem = createNode(arrTargetIdentifier,strCodeMeaning, strCodeValue, strCodeSchemeDesignator, EnumValueType.DATETIME, strValue, enumRelationshipType);
		SRNode objNode = new SRNode(objContentSequenceItem);

		//To get Content Sequence of Source Content Sequence in which new item is to be added.
		ContentSequence objContentSequenceInSource = this.objContentSequenceItem.getDocumentRelationshipMacro().getContentSequence();
		objContentSequenceInSource.addItem(objContentSequenceItem);

		return objNode;
	}
	
	/**
	 * Creates a node of type DATE
	 * @param strCodeMeaning String value for Code Meaning.
	 * @param strCodeValue string for CodeValue.
	 * @param strCodeSchemeDesignator string value for CodeSchemeDesignator.
	 * @param strValue string value for node which will describ that node.
	 * 					 eg : if node which will be added ie of value type DATE, the strValue will define its value.
	 * @param enumRelationshipType Enum value for Relationship Type between the (enclosing) Source Content Item and the Target Content Item.
	 * @return objNode object of SRNode.
	 */
	public  SRNode addDateNode(String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,String strValue,EnumRelationshipType enumRelationshipType)
	{
		//To get Referenced Content Item Identifier of Target Item
		int []arrTargetIdentifier = getTargetReferencedContentItemIdentifier();
		
		ContentSequenceItem objContentSequenceItem = createNode(arrTargetIdentifier,strCodeMeaning, strCodeValue, strCodeSchemeDesignator, EnumValueType.DATE, strValue, enumRelationshipType);
		SRNode objNode = new SRNode(objContentSequenceItem);

		//To get Content Sequence of Source Content Sequence in which new item is to be added.
		ContentSequence objContentSequenceInSource = this.objContentSequenceItem.getDocumentRelationshipMacro().getContentSequence();
		objContentSequenceInSource.addItem(objContentSequenceItem);

		return objNode;
	}
	
	/**
	 * Creates a node of type UIDREF
	 * @param strCodeMeaning String value for Code Meaning.
	 * @param strCodeValue string for CodeValue.
	 * @param strCodeSchemeDesignator string value for CodeSchemeDesignator.
	 * @param strValue string value for node which will describ that node.
	 * 					 eg : if node which will be added ie of value type UIDREF, the strValue will define its value.
	 * @param enumRelationshipType Enum value for Relationship Type between the (enclosing) Source Content Item and the Target Content Item.
	 * @return objNode object of SRNode.
	 */
	public  SRNode addUIDREFNode(String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,String strValue,EnumRelationshipType enumRelationshipType)
	{
		//To get Referenced Content Item Identifier of Target Item
		int []arrTargetIdentifier = getTargetReferencedContentItemIdentifier();
		
		ContentSequenceItem objContentSequenceItem = createNode(arrTargetIdentifier,strCodeMeaning, strCodeValue, strCodeSchemeDesignator, EnumValueType.UIDREF, strValue, enumRelationshipType);
		SRNode objNode = new SRNode(objContentSequenceItem);

		//To get Content Sequence of Source Content Sequence in which new item is to be added.
		ContentSequence objContentSequenceInSource = this.objContentSequenceItem.getDocumentRelationshipMacro().getContentSequence();
		objContentSequenceInSource.addItem(objContentSequenceItem);

		return objNode;
	}
	
	/**
	 * Adds the node of type CONTAINER
	 * @param strCodeMeaning String value for Code Meaning.
	 * @param strCodeValue string for CodeValue.
	 * @param strCodeSchemeDesignator string value for CodeSchemeDesignator.
	 * @param enumContinuityOfContent Enum value for ContinuityOfContent
	 * @param enumRelationshipType Enum value for Relationship Type between the (enclosing) Source Content Item and the Target Content Item.
	 * @return objNode object of SRNode.
	 */
	public  SRNode addContainerNode(String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,EnumContinuityOfContent enumContinuityOfContent ,EnumRelationshipType enumRelationshipType)
	{
		//To get Referenced Content Item Identifier of Target Item
		int []arrTargetIdentifier = getTargetReferencedContentItemIdentifier();
		
		ContentSequenceItem objContentSequenceItem = createContainer(arrTargetIdentifier, strCodeMeaning, strCodeValue, strCodeSchemeDesignator, enumContinuityOfContent, enumRelationshipType);
		SRNode objNode = new SRNode(objContentSequenceItem);

		//To get Content Sequence of Source Content Sequence in which new item is to be added.
		ContentSequence objContentSequenceInSource = this.objContentSequenceItem.getDocumentRelationshipMacro().getContentSequence();
		objContentSequenceInSource.addItem(objContentSequenceItem);

		return objNode;
	}
	
	/**
	 * Adds the node of type CODE
	 * @param strCodeMeaning Heading of Node of type CODE
	 * @param strCodeValue Code value of Node
	 * @param strCodeSchemeDesignator Code Scheme Designator of Node
	 * @param strCodeValueForCode Code Value for CodeSequenceMacro inside CodeMacro
	 * @param strCodeSchemeDesignatorForCode Code Scheme Designator for CodeSequenceMacro inside CodeMacro
	 * @param strCodingSchemeVersionForCode CodingSchemeVersion for CodeSequenceMacro inside CodeMacro
	 * @param strCodeMeaningForCode Code Meaning (Heading) for CodeSequenceMacro inside CodeMacro
	 * @param enumRelationshipType Enum value for Relationship Type between the (enclosing) Source Content Item and the Target Content Item.
	 * @return objNode object of SRNode.
	 */
	public  SRNode addCodeNode(String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,String strCodeValueForCode,String strCodeSchemeDesignatorForCode,String strCodingSchemeVersionForCode,String strCodeMeaningForCode,EnumRelationshipType enumRelationshipType)
	{
		//To get Referenced Content Item Identifier of Target Item
		int []arrTargetIdentifier = getTargetReferencedContentItemIdentifier();
		
		ContentSequenceItem objContentSequenceItem = createCodeNode(arrTargetIdentifier, strCodeMeaning, strCodeValue, strCodeSchemeDesignator, strCodeValueForCode, strCodeSchemeDesignatorForCode, strCodingSchemeVersionForCode, strCodeMeaningForCode, enumRelationshipType);
		SRNode objNode = new SRNode(objContentSequenceItem);

		//To get Content Sequence of Source Content Sequence in which new item is to be added.
		ContentSequence objContentSequenceInSource = this.objContentSequenceItem.getDocumentRelationshipMacro().getContentSequence();
		objContentSequenceInSource.addItem(objContentSequenceItem);

		return objNode;
	}
	 
	/**
	 * Adds the node of type NUM
	 * @param strCodeMeaning Heading of Node of type NUM
	 * @param strCodeValue Code value of Node
	 * @param strCodeSchemeDesignator Code Scheme Designator of Node
	 * @param arrNumericValue String array for Numeric Value..
	 * @param strCodeValueForUnitSQ String value for Code Value of MeasurementUnitsCodeSequence
	 * @param strCodeSchemeDesignatorForUnitSQ String value for CodeSchemeDesignator of MeasurementUnitsCodeSequence
	 * @param strCodingSchemeVersionForUnitSQ String value for CodingSchemeVersion of MeasurementUnitsCodeSequence
	 * @param strCodeMeaningForUnitSQ String value for Code Value of MeasurementUnitsCodeSequence
	 * @param strCMForNumValQuaCodeSQ String value for Code Meaning of NumericValueQualifierCodeSequence
	 * @param strCVForNumValQuaCodeSQ String value for Code Value of NumericValueQualifierCodeSequence
	 * @param strCSDForNumValQuaCodeSQ String value for CSD of NumericValueQualifierCodeSequence
	 * @param strCSVForNumValQuaCodeSQ String value for CSV of NumericValueQualifierCodeSequence
	 * @param enumRelationshipType Enum value for Relationship Type between the (enclosing) Source Content Item and the Target Content Item.
	 * @return objNode object of SRNode.
	 */
	public  SRNode addNumNode(String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,String[] arrNumericValue ,String strCodeValueForUnitSQ, String strCodeSchemeDesignatorForUnitSQ,String strCodingSchemeVersionForUnitSQ,String strCodeMeaningForUnitSQ,String strCMForNumValQuaCodeSQ,String strCVForNumValQuaCodeSQ,String strCSDForNumValQuaCodeSQ,String strCSVForNumValQuaCodeSQ, EnumRelationshipType enumRelationshipType)
	{
		//To get Referenced Content Item Identifier of Target Item
		int []arrTargetIdentifier = getTargetReferencedContentItemIdentifier();
		
		ContentSequenceItem objContentSequenceItem = createNumNode(arrTargetIdentifier, strCodeMeaning, strCodeValue, strCodeSchemeDesignator, arrNumericValue, strCodeValueForUnitSQ, strCodeSchemeDesignatorForUnitSQ, strCodingSchemeVersionForUnitSQ, strCodeMeaningForUnitSQ, strCMForNumValQuaCodeSQ, strCVForNumValQuaCodeSQ, strCSDForNumValQuaCodeSQ, strCSVForNumValQuaCodeSQ, enumRelationshipType);
		SRNode objNode = new SRNode(objContentSequenceItem);

		//To get Content Sequence of Source Content Sequence in which new item is to be added.
		ContentSequence objContentSequenceInSource = this.objContentSequenceItem.getDocumentRelationshipMacro().getContentSequence();
		objContentSequenceInSource.addItem(objContentSequenceItem);

		return objNode;
	}
	
	/**
	 * Adds the node of value type COMPOSITE
	 * @param strCodeMeaning Heading of Node of type COMPOSITE
	 * @param strCodeValue Code value of Node
	 * @param strCodeSchemeDesignator Code Scheme Designator of Node
	 * @param strReferencedSOPClassUID Referenced SOP Class UID 
	 * @param strReferencedSOPInstanceUID ReferencedSOPInstanceUID
	 * @param enumRelationshipType Enum value for Relationship Type between the (enclosing) Source Content Item and the Target Content Item.
	 * @return objNode object of SRNode.
	 */
	public  SRNode addCompositeNode(String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator, String strReferencedSOPClassUID, String strReferencedSOPInstanceUID, EnumRelationshipType enumRelationshipType)
	{
		//To get Referenced Content Item Identifier of Target Item
		int []arrTargetIdentifier = getTargetReferencedContentItemIdentifier();
		
		ContentSequenceItem objContentSequenceItem = createCompositeNode(arrTargetIdentifier, strCodeMeaning, strCodeValue, strCodeSchemeDesignator, strReferencedSOPClassUID, strReferencedSOPInstanceUID, enumRelationshipType);
		SRNode objNode = new SRNode(objContentSequenceItem);

		//To get Content Sequence of Source Content Sequence in which new item is to be added.
		ContentSequence objContentSequenceInSource = this.objContentSequenceItem.getDocumentRelationshipMacro().getContentSequence();
		objContentSequenceInSource.addItem(objContentSequenceItem);

		return objNode;
	}
	
	/**
	 * Adds the node of value Type WAVEFORM
	 * @param strCodeMeaning Heading of Node of type WAVEFORM
	 * @param strCodeValue Code value of Node
	 * @param strCodeSchemeDesignator Code Scheme Designator of Node
	 * @param strRefSOPClassUID Referenced SOP Class UID. for CompositeObjectReferenceMacro
	 * @param strRefSOPInstanceUID Referenced SOP Instance UID. for CompositeObjectReferenceMacro
	 * @param arrShReferencedWaveformChannels Short Array for Referenced Waveform Channels
	 * @param enumRelationshipType Enum value for Relationship Type between the (enclosing) Source Content Item and the Target Content Item.
	 * @return objNode object of SRNode.
	 */
	public  SRNode addWaveformNode(String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator, String strRefSOPClassUID, String strRefSOPInstanceUID, short[] arrShReferencedWaveformChannels,EnumRelationshipType enumRelationshipType)
	{
		//To get Referenced Content Item Identifier of Target Item
		int []arrTargetIdentifier = getTargetReferencedContentItemIdentifier();
		
		ContentSequenceItem objContentSequenceItem = createWaveformNode(arrTargetIdentifier, strCodeMeaning, strCodeValue, strCodeSchemeDesignator, strRefSOPClassUID, strRefSOPInstanceUID, arrShReferencedWaveformChannels, enumRelationshipType);
		SRNode objNode = new SRNode(objContentSequenceItem);

		//To get Content Sequence of Source Content Sequence in which new item is to be added.
		ContentSequence objContentSequenceInSource = this.objContentSequenceItem.getDocumentRelationshipMacro().getContentSequence();
		objContentSequenceInSource.addItem(objContentSequenceItem);

		return objNode;
	}
	
	/**
	 * Adds the node of value type SCOORD.
	 * @param strCodeMeaning Heading of Node of type SCOORD
	 * @param strCodeValue Code value of Node
	 * @param strCodeSchemeDesignator Code Scheme Designator of Node
	 * @param arrFlGraphicData array of float values for Graphic Data.
	 * @param enumGraphicType Enum value for Graphic Type.
	 * @param enumRelationshipType Enum value for Relationship Type between the (enclosing) Source Content Item and the Target Content Item.
	 * @return objNode object of SRNode.
	 */
	public  SRNode addSCOORDNode(String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,float [] arrFlGraphicData,EnumGraphicType enumGraphicType, EnumRelationshipType enumRelationshipType)
	{
		//To get Referenced Content Item Identifier of Target Item
		int []arrTargetIdentifier = getTargetReferencedContentItemIdentifier();
		
		ContentSequenceItem objContentSequenceItem = createSCOORDNode(arrTargetIdentifier, strCodeMeaning, strCodeValue, strCodeSchemeDesignator, arrFlGraphicData, enumGraphicType, enumRelationshipType);
		SRNode objNode = new SRNode(objContentSequenceItem);

		//To get Content Sequence of Source Content Sequence in which new item is to be added.
		ContentSequence objContentSequenceInSource = this.objContentSequenceItem.getDocumentRelationshipMacro().getContentSequence();
		objContentSequenceInSource.addItem(objContentSequenceItem);

		return objNode;
	}
	
	/**
	 * Adds the node of value type TCOORD
	 * @param strCodeMeaning Heading of Node of type SCOORD
	 * @param strCodeValue Code value of Node
	 * @param strCodeSchemeDesignator Code Scheme Designator of Node
	 * @param arrStrReferencedDatetime String array for ReferencedDatetime
	 * @param lArrReferencedSamplePositions int array for ReferencedSamplePositions
	 * @param arrStrReferencedTimeOffsets String array for ReferencedTimeOffsets 
	 * @param enumTemporalRangeType Enum value for TemporalRangeType
	 * @param enumRelationshipType Enum value for Relationship Type between the (enclosing) Source Content Item and the Target Content Item.
	 * @return objNode object of SRNode.
	 */
	public  SRNode addTCOORDNode(String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,String []arrStrReferencedDatetime,int []lArrReferencedSamplePositions, String []arrStrReferencedTimeOffsets,EnumTemporalRangeType enumTemporalRangeType,EnumRelationshipType enumRelationshipType)
	{
		//To get Referenced Content Item Identifier of Target Item
		int []arrTargetIdentifier = getTargetReferencedContentItemIdentifier();
		
		ContentSequenceItem objContentSequenceItem = createTCOORDNode(arrTargetIdentifier, strCodeMeaning, strCodeValue, strCodeSchemeDesignator, arrStrReferencedDatetime, lArrReferencedSamplePositions, arrStrReferencedTimeOffsets, enumTemporalRangeType, enumRelationshipType);
		SRNode objNode = new SRNode(objContentSequenceItem);

		//To get Content Sequence of Source Content Sequence in which new item is to be added.
		ContentSequence objContentSequenceInSource = this.objContentSequenceItem.getDocumentRelationshipMacro().getContentSequence();
		objContentSequenceInSource.addItem(objContentSequenceItem);

		return objNode;
	}
	
	
	/**
	 * Adds the node of value type IMAGE
	 * @param strCodeMeaning Heading of Node of type IMAGE
	 * @param strCodeValue Code value of Node
	 * @param strCodeSchemeDesignator Code Scheme Designator of Node
	 * @param strRefSOPClassUIDForCORefMacro Referenced SOP Class UID for Composite Object Reference Macro
	 * @param strRefSOPInstanceUIDForCORefMacro Referenced SOP Instance UID for Composite Object Reference Macro
	 * @param arrStrReferencedFrameNumber String Array of Referenced Frame Number.
	 * @param strRefSOPClassUID Referenced SOP Class UID.
	 * @param strRefSOPInstanceUID Referenced SOP Instance UID.
	 * @param enumRelationshipType Enum value for Relationship Type between the (enclosing) Source Content Item and the Target Content Item.
	 * @return objImagePixelMacro Object of ImagePixelMacro
	 */
	@SuppressWarnings("unchecked")
	public  ImagePixelMacro addImageNode(String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator, 
			String strRefSOPClassUIDForCORefMacro,String strRefSOPInstanceUIDForCORefMacro,String[] arrStrReferencedFrameNumber,
			String strRefSOPClassUID, String strRefSOPInstanceUID,EnumRelationshipType enumRelationshipType)
	{
		//To get Referenced Content Item Identifier of Target Item
		int []arrTargetIdentifier = getTargetReferencedContentItemIdentifier();
		
		ContentSequenceItem objContentSequenceItem = createImageNode(arrTargetIdentifier, strCodeMeaning,  strCodeValue,  strCodeSchemeDesignator, 
				 strRefSOPClassUIDForCORefMacro, strRefSOPInstanceUIDForCORefMacro,arrStrReferencedFrameNumber,
				 strRefSOPClassUID,  strRefSOPInstanceUID, enumRelationshipType);
		
		@SuppressWarnings("unused")
		SRNode objNode = new SRNode(objContentSequenceItem);

		//To get Content Sequence of Source Content Sequence in which new item is to be added.
		ContentSequence objContentSequenceInSource = this.objContentSequenceItem.getDocumentRelationshipMacro().getContentSequence();
		objContentSequenceInSource.addItem(objContentSequenceItem);

		ImageReferenceMacro objImageReferenceMacro = objContentSequenceItem.getDocumentContentMacro().getImageReferenceMacro();
		IconImageSequence objIconImageSequence = objImageReferenceMacro.getIconImageSequence();
		
		ISingleCollection<IconImageSequenceItem> objColl = (SingleCollection<IconImageSequenceItem>)objIconImageSequence.getValue();
		IconImageSequenceItem objIconImageSequenceItem = objColl.elementAt(0);
		ImagePixelMacro objImagePixelMacro = objIconImageSequenceItem.getImagePixelMacro();
		return objImagePixelMacro;
	}
	
	/**
	 * Creates the node of value type SCOORD
	 * @param arrPosition position at which node is to be added in the tree.
	 * @param strCodeMeaning Heading of Node of type SCOORD
	 * @param strCodeValue Code value of Node
	 * @param strCodeSchemeDesignator Code Scheme Designator of Node
	 * @param arrFlGraphicData array of float values for Graphic Data.
	 * @param enumGraphicType Enum value for Graphic Type.
	 * @param enumRelationshipType Enum value for Relationship Type between the (enclosing) Source Content Item and the Target Content Item.
	 * @return objContentSequenceItem object of ContentSequenceItem.
	 */
	private ContentSequenceItem createSCOORDNode(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,float [] arrFlGraphicData,EnumGraphicType enumGraphicType, EnumRelationshipType enumRelationshipType)
	{
		/**
		 * Get Content Sequence from DocumentRelationshipMacro of ContentSequenceItem
		 */
		ContentSequence objContentSequence = this.objContentSequenceItem.getDocumentRelationshipMacro().getContentSequence();

		ContentSequenceItem objContentSequenceItem = objContentSequence.getNewItem();

		objContentSequenceItem.setRelationshipType(enumRelationshipType);

		// identifier of a node
		int[] lArrReferencedContentItemIdentifier = arrPosition;
		objContentSequenceItem.setReferencedContentItemIdentifier(lArrReferencedContentItemIdentifier);

		/*
		 * creating DOCUMENT CONTENT MACRO
		 */
		DocumentContentMacro objDocumentContentMacro = objContentSequenceItem.getDocumentContentMacro();

		objDocumentContentMacro.setValueType(EnumValueType.SCOORD);

		//creating CONCEPT NAME CODE SEQUENCE
		ConceptNameCodeSequence objNameCodeSequence = objDocumentContentMacro.getConceptNameCodeSequence();
		CodeSequenceMacroDependentItem objCodeSequenceMacroDependentItem = objNameCodeSequence.getNewItem();
		CodeSequenceMacro objCodeSequenceMacro = objCodeSequenceMacroDependentItem.getCodeSequenceMacro();
		objCodeSequenceMacro.setCodeMeaning(strCodeMeaning);
		objCodeSequenceMacro.setCodeValue(strCodeValue);
		objCodeSequenceMacro.setCodeSchemeDesignator(strCodeSchemeDesignator);
		objNameCodeSequence.addItem(objCodeSequenceMacroDependentItem);

		//SPATIAL COORDINATE MACRO
		SpatialCoordinatesMacro objSpatialCoordinatesMacro = objDocumentContentMacro.getSpatialCoordinatesMacro();
		objSpatialCoordinatesMacro.setGraphicData(arrFlGraphicData);
		objSpatialCoordinatesMacro.setGraphicType(enumGraphicType);

		/*
		 * creating DOCUMENT RELATIONSHIP MACRO and Content Sequence in it.
		 */
		DocumentRelationshipMacro objDocumentRelationshipMacro = objContentSequenceItem.getDocumentRelationshipMacro();
		@SuppressWarnings("unused")
		ContentSequence objContentSequence2 = objDocumentRelationshipMacro.getContentSequence();
		//objDocumentRelationshipMacro.setObservationDateTime("11:45");

		return objContentSequenceItem;
	}
	
	/**
	 * Creates the node of value type TCOORD
	 * @param arrPosition position at which node is to be added in the tree.
	 * @param strCodeMeaning Heading of Node of type SCOORD
	 * @param strCodeValue Code value of Node
	 * @param strCodeSchemeDesignator Code Scheme Designator of Node
	 * @param arrStrReferencedDatetime String array for ReferencedDatetime
	 * @param lArrReferencedSamplePositions long array for ReferencedSamplePositions
	 * @param arrStrReferencedTimeOffsets String array for ReferencedTimeOffsets 
	 * @param enumTemporalRangeType Enum value for TemporalRangeType
	 * @param enumRelationshipType Enum value for Relationship Type between the (enclosing) Source Content Item and the Target Content Item.
	 * @return objContentSequenceItem object of ContentSequenceItem.
	 */
	private ContentSequenceItem createTCOORDNode(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,String []arrStrReferencedDatetime,int []lArrReferencedSamplePositions, String []arrStrReferencedTimeOffsets,EnumTemporalRangeType enumTemporalRangeType,EnumRelationshipType enumRelationshipType)
	{
		/**
		 * Get Content Sequence from DocumentRelationshipMacro of ContentSequenceItem
		 */
		ContentSequence objContentSequence = this.objContentSequenceItem.getDocumentRelationshipMacro().getContentSequence();

		ContentSequenceItem objContentSequenceItem = objContentSequence.getNewItem();

		objContentSequenceItem.setRelationshipType(enumRelationshipType);

		// identifier of a node
		int[] lArrReferencedContentItemIdentifier = arrPosition;
		objContentSequenceItem.setReferencedContentItemIdentifier(lArrReferencedContentItemIdentifier);

		/*
		 * creating DOCUMENT CONTENT MACRO
		 */
		DocumentContentMacro objDocumentContentMacro = objContentSequenceItem.getDocumentContentMacro();

		objDocumentContentMacro.setValueType(EnumValueType.TCOORD);

		//creating CONCEPT NAME CODE SEQUENCE
		ConceptNameCodeSequence objNameCodeSequence = objDocumentContentMacro.getConceptNameCodeSequence();
		CodeSequenceMacroDependentItem objCodeSequenceMacroDependentItem = objNameCodeSequence.getNewItem();
		CodeSequenceMacro objCodeSequenceMacro = objCodeSequenceMacroDependentItem.getCodeSequenceMacro();
		objCodeSequenceMacro.setCodeMeaning(strCodeMeaning);
		objCodeSequenceMacro.setCodeValue(strCodeValue);
		objCodeSequenceMacro.setCodeSchemeDesignator(strCodeSchemeDesignator);
		objNameCodeSequence.addItem(objCodeSequenceMacroDependentItem);

		//TEMPORAL COORDINATES MACRO
		TemporalCoordinatesMacro objTemporalCoordinatesMacro = objDocumentContentMacro.getTemporalCoordinatesMacro();
		objTemporalCoordinatesMacro.setReferencedDatetime(arrStrReferencedDatetime);
		objTemporalCoordinatesMacro.setReferencedSamplePositions(lArrReferencedSamplePositions);
		objTemporalCoordinatesMacro.setReferencedTimeOffsets(arrStrReferencedTimeOffsets);
		objTemporalCoordinatesMacro.setTemporalRangeType(enumTemporalRangeType);

		/*
		 * creating DOCUMENT RELATIONSHIP MACRO and Content Sequence in it.
		 */
		DocumentRelationshipMacro objDocumentRelationshipMacro = objContentSequenceItem.getDocumentRelationshipMacro();
		@SuppressWarnings("unused")
		ContentSequence objContentSequence2 = objDocumentRelationshipMacro.getContentSequence();
		//objDocumentRelationshipMacro.setObservationDateTime("11:45");

		return objContentSequenceItem;
	}

	/**
	 * This will create any type of node at specified position.
	 * @param arrPosition position at which node is to be added in the tree.
	 * @param strCodeMeaning string for CodeMeaning which will be heading for that node
	 * @param strCodeValue string for CodeValue.
	 * @param strCodeSchemeDesignator string value for CodeSchemeDesignator.
	 * @param enumValueType object of EnumValueType - it will tell that what type of child node will be added.
	 * @param strValue - string value for node which will describ that node.
	 * 					 eg : if nodee which will be added ie of value type PANME, the strValue will define its name.
	 * @param enumRelationshipType Enum value for Relationship Type between the (enclosing) Source Content Item and the Target Content Item.
	 * @return objContentSequenceItem object of ContentSequenceItem.
	 */
	private ContentSequenceItem createNode(int []arrPosition,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,EnumValueType enumValueType ,String strValue,EnumRelationshipType enumRelationshipType)
	{
		//ContentSequence objContentSequence = getContentSequence();

		/**
		 * Get Content Sequence from DocumentRelationshipMacro of ContentSequenceItem
		 */
		ContentSequence objContentSequence = this.objContentSequenceItem.getDocumentRelationshipMacro().getContentSequence();

		ContentSequenceItem objContentSequenceItem = objContentSequence.getNewItem();

		//set Relationship type
		objContentSequenceItem.setRelationshipType(enumRelationshipType);

		// identifier of a node
		int[] lArrReferencedContentItemIdentifier = arrPosition;
		objContentSequenceItem.setReferencedContentItemIdentifier(lArrReferencedContentItemIdentifier);

		/*
		 * creating DOCUMENT CONTENT MACRO
		 */
		DocumentContentMacro objDocumentContentMacro = objContentSequenceItem.getDocumentContentMacro();

		//creating CONCEPT NAME CODE SEQUENCE
		ConceptNameCodeSequence objNameCodeSequence = objDocumentContentMacro.getConceptNameCodeSequence();
		CodeSequenceMacroDependentItem objCodeSequenceMacroDependentItem = objNameCodeSequence.getNewItem();
		CodeSequenceMacro objCodeSequenceMacro = objCodeSequenceMacroDependentItem.getCodeSequenceMacro();
		objCodeSequenceMacro.setCodeMeaning(strCodeMeaning);
		objCodeSequenceMacro.setCodeValue(strCodeValue);
		objCodeSequenceMacro.setCodeSchemeDesignator(strCodeSchemeDesignator);
		objNameCodeSequence.addItem(objCodeSequenceMacroDependentItem);

		//If node to be created is of value type PNAME then set the PNAME as value type and Person Name
		if(enumValueType.getValue().equalsIgnoreCase("PNAME"))
		{
			objDocumentContentMacro.setValueType(EnumValueType.PNAME);
			objDocumentContentMacro.setPersonName(strValue);
		}
		//If node to be created is of value type TEXT then set the TEXT as value type and TextValue
		else if(enumValueType.getValue().equalsIgnoreCase("TEXT"))
		{
			objDocumentContentMacro.setValueType(EnumValueType.TEXT);
			objDocumentContentMacro.setTextValue(strValue);
		}
		//If node to be created is of value type DATETIME then set the DATETIME as value type and DateTime value
		else if(enumValueType.getValue().equalsIgnoreCase("DATETIME"))
		{
			objDocumentContentMacro.setValueType(EnumValueType.DATETIME);
			objDocumentContentMacro.setDateTime(strValue);
		}
		//If node to be created is of value type DATE then set the DATE as value type and Date value
		else if(enumValueType.getValue().equalsIgnoreCase("DATE"))
		{
			objDocumentContentMacro.setValueType(EnumValueType.DATE);
			objDocumentContentMacro.setDate(strValue);
		}
		//If node to be created is of value type TIME then set the TIME as value type and TIME value
		else if(enumValueType.getValue().equalsIgnoreCase("TIME"))
		{
			objDocumentContentMacro.setValueType(EnumValueType.TIME);
			objDocumentContentMacro.setTime(strValue);
		}
		//If node to be created is of value type UIDREF then set the UIDREF as value type and UID value
		else if(enumValueType.getValue().equalsIgnoreCase("UIDREF"))
		{
			objDocumentContentMacro.setValueType(EnumValueType.UIDREF);
			objDocumentContentMacro.setUID(strValue);
		}

		/*
		 * creating DOCUMENT RELATIONSHIP MACRO and Content Sequence in it.
		 */
		DocumentRelationshipMacro objDocumentRelationshipMacro = objContentSequenceItem.getDocumentRelationshipMacro();
		@SuppressWarnings("unused")
		ContentSequence objContentSequence2 = objDocumentRelationshipMacro.getContentSequence();
		//objDocumentRelationshipMacro.setObservationDateTime("11:45");

		return objContentSequenceItem;
	}
	
	/**
	 * Returns the container ContentSequenceItem for CONTAINER value type .
	 * @param arrPosition position at which node is to be added in the tree.
	 * @param strCodeMeaning string for CodeMeaning which will be heading for that node
	 * @param strCodeValue string for CodeValue.
	 * @param strCodeSchemeDesignator string value for CodeSchemeDesignator.
	 * @param enumContinuityOfContent object of EnumContinuityOfContent
	 * @param enumRelationshipType Enum value for Relationship Type between the (enclosing) Source Content Item and the Target Content Item.
	 * @return objContentSequenceItemForCONTAINER object of ContentSequenceItem.
	 */
	private ContentSequenceItem createContainer(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator, EnumContinuityOfContent enumContinuityOfContent,EnumRelationshipType enumRelationshipType)
	{
		//ContentSequence objContentSequence = getContentSequence();
		
		/**
		 * Get Content Sequence from DocumentRelationshipMacro of ContentSequenceItem
		 */
		ContentSequence objContentSequence = this.objContentSequenceItem.getDocumentRelationshipMacro().getContentSequence();

		ContentSequenceItem objContentSequenceItemForCONTAINER = objContentSequence.getNewItem();

		//sets Relationship Type
		objContentSequenceItemForCONTAINER.setRelationshipType(enumRelationshipType);

		int[] lArrReferencedContentItemIdentifierForCONTAINER = arrPosition;
		objContentSequenceItemForCONTAINER.setReferencedContentItemIdentifier(lArrReferencedContentItemIdentifierForCONTAINER);

		DocumentContentMacro objDocumentContentMacroForCONTAINER = objContentSequenceItemForCONTAINER.getDocumentContentMacro();
		objDocumentContentMacroForCONTAINER.setValueType(EnumValueType.CONTAINER);

		ConceptNameCodeSequence objNameCodeSequenceCONTAINER = objDocumentContentMacroForCONTAINER.getConceptNameCodeSequence();
		CodeSequenceMacroDependentItem objCodeSequenceMacroDependentItemCONTAINER = objNameCodeSequenceCONTAINER.getNewItem();
		//objNameCodeSequenceCONTAINER.addItem(objCodeSequenceMacroDependentItemCONTAINER);
		CodeSequenceMacro objCodeSequenceMacroCONTAINER = objCodeSequenceMacroDependentItemCONTAINER.getCodeSequenceMacro();
		//container heading
		objCodeSequenceMacroCONTAINER.setCodeMeaning(strCodeMeaning);
		objCodeSequenceMacroCONTAINER.setCodeValue(strCodeValue);
		objCodeSequenceMacroCONTAINER.setCodeSchemeDesignator(strCodeSchemeDesignator);
		objNameCodeSequenceCONTAINER.addItem(objCodeSequenceMacroDependentItemCONTAINER);

		objDocumentContentMacroForCONTAINER.setContinuityOfContent(enumContinuityOfContent);

		DocumentRelationshipMacro objDocumentRelationshipMacroForCONTAINER = objContentSequenceItemForCONTAINER.getDocumentRelationshipMacro();
		//objDocumentRelationshipMacroForCONTAINER.setObservationDateTime("11:45");
		@SuppressWarnings("unused")
		ContentSequence objContentSequence2 = objDocumentRelationshipMacroForCONTAINER.getContentSequence();

		return objContentSequenceItemForCONTAINER;
	}
	
	/**
	 * This will create CODE type of Node with specified attributes.
	 * @param arrPosition position at which the node will get added in the tree.
	 * @param strCodeMeaning Heading of Node of type CODE
	 * @param strCodeValue Code value of Node
	 * @param strCodeSchemeDesignator Code Scheme Designator of Node
	 * @param strCodeValueForCode Code Value for CodeSequenceMacro inside CodeMacro
	 * @param strCodeSchemeDesignatorForCode Code Scheme Designator for CodeSequenceMacro inside CodeMacro
	 * @param strCodingSchemeVersionForCode CodingSchemeVersion for CodeSequenceMacro inside CodeMacro
	 * @param strCodeMeaningForCode Code Meaning (Heading) for CodeSequenceMacro inside CodeMacro
	 * @param enumRelationshipType Enum value for Relationship Type between the (enclosing) Source Content Item and the Target Content Item.
	 * @return objContentSequenceItem object of ContentSequenceItem. 
	 */
	private ContentSequenceItem createCodeNode(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,String strCodeValueForCode, String strCodeSchemeDesignatorForCode,String strCodingSchemeVersionForCode,String strCodeMeaningForCode,EnumRelationshipType enumRelationshipType)
	{
		//ContentSequence objContentSequence = getContentSequence();
		/**
		 * Get Content Sequence from DocumentRelationshipMacro of ContentSequenceItem
		 */
		ContentSequence objContentSequence = this.objContentSequenceItem.getDocumentRelationshipMacro().getContentSequence();

		ContentSequenceItem objContentSequenceItem = objContentSequence.getNewItem();

		objContentSequenceItem.setRelationshipType(enumRelationshipType);

		// identifier of a node
		int[] lArrReferencedContentItemIdentifier = arrPosition;
		objContentSequenceItem.setReferencedContentItemIdentifier(lArrReferencedContentItemIdentifier);

		/*
		 * creating DOCUMENT CONTENT MACRO
		 */
		DocumentContentMacro objDocumentContentMacro = objContentSequenceItem.getDocumentContentMacro();

		objDocumentContentMacro.setValueType(EnumValueType.CODE);

		//creating CONCEPT NAME CODE SEQUENCE
		ConceptNameCodeSequence objNameCodeSequence = objDocumentContentMacro.getConceptNameCodeSequence();
		CodeSequenceMacroDependentItem objCodeSequenceMacroDependentItem = objNameCodeSequence.getNewItem();
		CodeSequenceMacro objCodeSequenceMacro = objCodeSequenceMacroDependentItem.getCodeSequenceMacro();
		objCodeSequenceMacro.setCodeMeaning(strCodeMeaning);
		objCodeSequenceMacro.setCodeValue(strCodeValue);
		objCodeSequenceMacro.setCodeSchemeDesignator(strCodeSchemeDesignator);
		objNameCodeSequence.addItem(objCodeSequenceMacroDependentItem);

		//CODE MACRO
		CodeMacro objCodeMacro = objDocumentContentMacro.getCodeMacro();
		ConceptCodeSequence objConceptCodeSequence = objCodeMacro.getConceptCodeSequence();
		CodeSequenceMacroDependentItem objSequenceMacroDependentItem = objConceptCodeSequence.getNewItem();

		CodeSequenceMacro objSequenceMacro = objSequenceMacroDependentItem.getCodeSequenceMacro();
		objSequenceMacro.setCodeValue(strCodeValueForCode);
		objSequenceMacro.setCodeSchemeDesignator(strCodeSchemeDesignatorForCode);
		objSequenceMacro.setCodingSchemeVersion(strCodingSchemeVersionForCode);
		objSequenceMacro.setCodeMeaning(strCodeMeaningForCode);

//		objSequenceMacro.setContextIdentifier(strContextIdentifierForCode);
//		objSequenceMacro.setMappingResource(strMappingResourceForCode);
//		objSequenceMacro.setContextGroupVersion(strContextGroupVersionForCode);
//		objSequenceMacro.setContextGroupExtensionFlag(strContextGroupExtensionFlagForCode);
//		objSequenceMacro.setContextGroupLocalVersion(strContextGroupLocalVersionForCode);
//		objSequenceMacro.setContextGroupExtensionCreatorUID(strContextGroupExtensionCreatorUIDForCode);
		objConceptCodeSequence.addItem(objSequenceMacroDependentItem);

		/*
		 * creating DOCUMENT RELATIONSHIP MACRO and Content Sequence in it.
		 */
		DocumentRelationshipMacro objDocumentRelationshipMacro = objContentSequenceItem.getDocumentRelationshipMacro();
		@SuppressWarnings("unused")
		ContentSequence objContentSequence2 = objDocumentRelationshipMacro.getContentSequence();
		//objDocumentRelationshipMacro.setObservationDateTime("11:45");

		return objContentSequenceItem;
	}
	
	/**
	 * creates the node of value type NUM.
	 * @param arrPosition integer array for  ReferencedContentItemIdentifier
	 * @param strCodeMeaning Heading of Node of type NUM
	 * @param strCodeValue Code value of Node
	 * @param strCodeSchemeDesignator Code Scheme Designator of Node
	 * @param arrNumericValue String array for Numeric Value..
	 * @param strCodeValueForUnitSQ String value for Code Value of MeasurementUnitsCodeSequence
	 * @param strCodeSchemeDesignatorForUnitSQ String value for CodeSchemeDesignator of MeasurementUnitsCodeSequence
	 * @param strCodingSchemeVersionForUnitSQ String value for CodingSchemeVersion of MeasurementUnitsCodeSequence
	 * @param strCodeMeaningForUnitSQ String value for Code Value of MeasurementUnitsCodeSequence
	 * @param strCMForNumValQuaCodeSQ String value for Code Meaning of NumericValueQualifierCodeSequence
	 * @param strCVForNumValQuaCodeSQ String value for Code Value of NumericValueQualifierCodeSequence
	 * @param strCSDForNumValQuaCodeSQ String value for CSD of NumericValueQualifierCodeSequence
	 * @param strCSVForNumValQuaCodeSQ String value for CSV of NumericValueQualifierCodeSequence
	 * @param enumRelationshipType Enum value for Relationship Type between the (enclosing) Source Content Item and the Target Content Item.
	 * @return objContentSequenceItem object of ContentSequenceItem. 
	 */
	private ContentSequenceItem createNumNode(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,String[] arrNumericValue ,String strCodeValueForUnitSQ, String strCodeSchemeDesignatorForUnitSQ,String strCodingSchemeVersionForUnitSQ,String strCodeMeaningForUnitSQ,String strCMForNumValQuaCodeSQ,String strCVForNumValQuaCodeSQ,String strCSDForNumValQuaCodeSQ,String strCSVForNumValQuaCodeSQ, EnumRelationshipType enumRelationshipType)
	{
		//ContentSequence objContentSequence = getContentSequence();
		/**
		 * Get Content Sequence from DocumentRelationshipMacro of ContentSequenceItem
		 */
		ContentSequence objContentSequence = this.objContentSequenceItem.getDocumentRelationshipMacro().getContentSequence();

		ContentSequenceItem objContentSequenceItem = objContentSequence.getNewItem();

		objContentSequenceItem.setRelationshipType(enumRelationshipType);

		// identifier of a node
		int[] lArrReferencedContentItemIdentifier = arrPosition;
		objContentSequenceItem.setReferencedContentItemIdentifier(lArrReferencedContentItemIdentifier);

		/*
		 * creating DOCUMENT CONTENT MACRO
		 */
		DocumentContentMacro objDocumentContentMacro = objContentSequenceItem.getDocumentContentMacro();

		objDocumentContentMacro.setValueType(EnumValueType.NUM);

		//creating CONCEPT NAME CODE SEQUENCE
		ConceptNameCodeSequence objNameCodeSequence = objDocumentContentMacro.getConceptNameCodeSequence();
		CodeSequenceMacroDependentItem objCodeSequenceMacroDependentItem = objNameCodeSequence.getNewItem();
		CodeSequenceMacro objCodeSequenceMacro = objCodeSequenceMacroDependentItem.getCodeSequenceMacro();
		objCodeSequenceMacro.setCodeMeaning(strCodeMeaning);
		objCodeSequenceMacro.setCodeValue(strCodeValue);
		objCodeSequenceMacro.setCodeSchemeDesignator(strCodeSchemeDesignator);
		objNameCodeSequence.addItem(objCodeSequenceMacroDependentItem);

		//NUMERIC MEASUREMENT MACRO

		NumericMeasurementMacro objNumericMeasurementMacro = objDocumentContentMacro.getNumericMeasurementMacro();

		//-----MeasuredValueSequence
		MeasuredValueSequence objMeasuredValueSequence = objNumericMeasurementMacro.getMeasuredValueSequence();
		MeasuredValueSequenceItem objMeasuredValueSequenceItem = objMeasuredValueSequence.getNewItem();
		objMeasuredValueSequenceItem.setNumericValue(arrNumericValue);

		//--------------------MeasurementUnitsCodeSequence
		MeasurementUnitsCodeSequence objMeasurementUnitsCodeSequence = objMeasuredValueSequenceItem.getMeasurementUnitsCodeSequence();
		CodeSequenceMacroDependentItem objSequenceMacroDependentItem = objMeasurementUnitsCodeSequence.getNewItem();
		CodeSequenceMacro objSequenceMacro = objSequenceMacroDependentItem.getCodeSequenceMacro();
		objSequenceMacro.setCodeValue(strCodeValueForUnitSQ);
		objSequenceMacro.setCodeSchemeDesignator(strCodeSchemeDesignatorForUnitSQ);
		objSequenceMacro.setCodingSchemeVersion(strCodingSchemeVersionForUnitSQ);
		objSequenceMacro.setCodeMeaning(strCodeMeaningForUnitSQ);

		objMeasurementUnitsCodeSequence.addItem(objSequenceMacroDependentItem);		
		objMeasuredValueSequence.addItem(objMeasuredValueSequenceItem);

		//-----NumericValueQualifierCodeSequence
		NumericValueQualifierCodeSequence objNumericValueQualifierCodeSequence = objNumericMeasurementMacro.getNumericValueQualifierCodeSequence();
		CodeSequenceMacroDependentItem objDependentItemForNumValQuaCodeSQ = objNumericValueQualifierCodeSequence.getNewItem();
		CodeSequenceMacro objSequenceMacroForNumValQuaCodeSQ = objDependentItemForNumValQuaCodeSQ.getCodeSequenceMacro();
		objSequenceMacroForNumValQuaCodeSQ.setCodeMeaning(strCMForNumValQuaCodeSQ);
		objSequenceMacroForNumValQuaCodeSQ.setCodeValue(strCVForNumValQuaCodeSQ);
		objSequenceMacroForNumValQuaCodeSQ.setCodeSchemeDesignator(strCSDForNumValQuaCodeSQ);
		objSequenceMacroForNumValQuaCodeSQ.setCodingSchemeVersion(strCSVForNumValQuaCodeSQ);
		objNumericValueQualifierCodeSequence.addItem(objDependentItemForNumValQuaCodeSQ);

		/*
		 * creating DOCUMENT RELATIONSHIP MACRO and Content Sequence in it.
		 */
		DocumentRelationshipMacro objDocumentRelationshipMacro = objContentSequenceItem.getDocumentRelationshipMacro();
		@SuppressWarnings("unused")
		ContentSequence objContentSequence2 = objDocumentRelationshipMacro.getContentSequence();
		//objDocumentRelationshipMacro.setObservationDateTime("11:45");

		return objContentSequenceItem;
	}
	
	/**
	 * This will create COMPOSITE type of Node with specified attributes.
	 * @param arrPosition position at which the node will get added in the tree.
	 * @param strCodeMeaning Heading of Node of type COMPOSITE
	 * @param strCodeValue Code value of Node
	 * @param strCodeSchemeDesignator Code Scheme Designator of Node
	 * @param strReferencedSOPClassUID Referenced SOP Class UID 
	 * @param strReferencedSOPInstanceUID ReferencedSOPInstanceUID
	 * @param enumRelationshipType Enum value for Relationship Type between the (enclosing) Source Content Item and the Target Content Item.
	 * @return objContentSequenceItem object of ContentSequenceItem. 
	 */
	private ContentSequenceItem createCompositeNode(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator, String strReferencedSOPClassUID, String strReferencedSOPInstanceUID, EnumRelationshipType enumRelationshipType)
	{
		//ContentSequence objContentSequence = getContentSequence();
		/**
		 * Get Content Sequence from DocumentRelationshipMacro of ContentSequenceItem
		 */
		ContentSequence objContentSequence = this.objContentSequenceItem.getDocumentRelationshipMacro().getContentSequence();
		
		ContentSequenceItem objContentSequenceItem = objContentSequence.getNewItem();

		objContentSequenceItem.setRelationshipType(enumRelationshipType);

		// identifier of a node
		int[] lArrReferencedContentItemIdentifier = arrPosition;
		objContentSequenceItem.setReferencedContentItemIdentifier(lArrReferencedContentItemIdentifier);

		/*
		 * creating DOCUMENT CONTENT MACRO
		 */
		DocumentContentMacro objDocumentContentMacro = objContentSequenceItem.getDocumentContentMacro();

		objDocumentContentMacro.setValueType(EnumValueType.COMPOSITE);

		//creating CONCEPT NAME CODE SEQUENCE
		ConceptNameCodeSequence objNameCodeSequence = objDocumentContentMacro.getConceptNameCodeSequence();
		CodeSequenceMacroDependentItem objCodeSequenceMacroDependentItem = objNameCodeSequence.getNewItem();
		CodeSequenceMacro objCodeSequenceMacro = objCodeSequenceMacroDependentItem.getCodeSequenceMacro();
		objCodeSequenceMacro.setCodeMeaning(strCodeMeaning);
		objCodeSequenceMacro.setCodeValue(strCodeValue);
		objCodeSequenceMacro.setCodeSchemeDesignator(strCodeSchemeDesignator);
		objNameCodeSequence.addItem(objCodeSequenceMacroDependentItem);

		//Setting two attributes of COMPOSITE OBJECT REFERENCE MACRO
		setCompositeObjectReferenceMacroAttributes(objDocumentContentMacro, strReferencedSOPClassUID, strReferencedSOPInstanceUID);

		/*
		 * creating DOCUMENT RELATIONSHIP MACRO and Content Sequence in it.
		 */
		DocumentRelationshipMacro objDocumentRelationshipMacro = objContentSequenceItem.getDocumentRelationshipMacro();
		@SuppressWarnings("unused")
		ContentSequence objContentSequence2 = objDocumentRelationshipMacro.getContentSequence();
		//objDocumentRelationshipMacro.setObservationDateTime("11:45");

		return objContentSequenceItem;
	}
	
	/**
	 * sets the attribute of CompositeObjectReferenceMacro
	 * @param objDocumentContentMacro DocumentContentMacro from which we can get this macro
	 * @param strReferencedSOPClassUID First attribute to be set in ReferencedSOPSequenceItem of CompositeObjectReferenceMacro
	 * @param strReferencedSOPInstanceUID Second attribute to be set in ReferencedSOPSequenceItem of CompositeObjectReferenceMacro
	 */
	private void setCompositeObjectReferenceMacroAttributes(DocumentContentMacro objDocumentContentMacro,String strReferencedSOPClassUID, String strReferencedSOPInstanceUID)
	{
		CompositeObjectReferenceMacro objCompositeObjectReferenceMacro = objDocumentContentMacro.getCompositeObjectReferenceMacro();
		ReferencedSOPSequence objReferencedSOPSequence = objCompositeObjectReferenceMacro.getReferencedSOPSequence();
		ReferencedSOPSequenceItem objReferencedSOPSequenceItem = objReferencedSOPSequence.getNewItem();
		objReferencedSOPSequenceItem.getSOPInstanceReferenceMacro().setReferencedSOPClassUID(strReferencedSOPClassUID);
		objReferencedSOPSequenceItem.getSOPInstanceReferenceMacro().setReferencedSOPInstanceUID(strReferencedSOPInstanceUID);
		objReferencedSOPSequence.addItem(objReferencedSOPSequenceItem);
	}
	
	/**
	 * Creates WAVWFORM type of Node with specified attributes.
	 * @param arrPosition position at which the node will get added in the tree.
	 * @param strCodeMeaning Heading of Node of type WAVEFORM
	 * @param strCodeValue Code value of Node
	 * @param strCodeSchemeDesignator Code Scheme Designator of Node
	 * @param strRefSOPClassUID Referenced SOP Class UID.
	 * @param strRefSOPInstanceUID Referenced SOP Instance UID.
	 * @param arrShReferencedWaveformChannels Short Array for Referenced Waveform Channels
	 * @param enumRelationshipType Enum value for Relationship Type between the (enclosing) Source Content Item and the Target Content Item.
	 * @return objContentSequenceItem object of ContentSequenceItem. 
	 */
	private ContentSequenceItem createWaveformNode(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator, String strRefSOPClassUID, String strRefSOPInstanceUID, short[] arrShReferencedWaveformChannels,EnumRelationshipType enumRelationshipType)
	{
		//ContentSequence objContentSequence = getContentSequence();
		/**
		 * Get Content Sequence from DocumentRelationshipMacro of ContentSequenceItem
		 */
		ContentSequence objContentSequence = this.objContentSequenceItem.getDocumentRelationshipMacro().getContentSequence();
		
		ContentSequenceItem objContentSequenceItem = objContentSequence.getNewItem();

		objContentSequenceItem.setRelationshipType(enumRelationshipType);

		// identifier of a node
		int[] lArrReferencedContentItemIdentifier = arrPosition;
		objContentSequenceItem.setReferencedContentItemIdentifier(lArrReferencedContentItemIdentifier);

		/*
		 * creating DOCUMENT CONTENT MACRO
		 */
		DocumentContentMacro objDocumentContentMacro = objContentSequenceItem.getDocumentContentMacro();

		objDocumentContentMacro.setValueType(EnumValueType.WAVEFORM);

		//creating CONCEPT NAME CODE SEQUENCE
		ConceptNameCodeSequence objNameCodeSequence = objDocumentContentMacro.getConceptNameCodeSequence();
		CodeSequenceMacroDependentItem objCodeSequenceMacroDependentItem = objNameCodeSequence.getNewItem();
		CodeSequenceMacro objCodeSequenceMacro = objCodeSequenceMacroDependentItem.getCodeSequenceMacro();
		objCodeSequenceMacro.setCodeMeaning(strCodeMeaning);
		objCodeSequenceMacro.setCodeValue(strCodeValue);
		objCodeSequenceMacro.setCodeSchemeDesignator(strCodeSchemeDesignator);
		objNameCodeSequence.addItem(objCodeSequenceMacroDependentItem);

		//Waveform Referenced Macro.
		WaveformReferenceMacro objWaveformReferenceMacro = objDocumentContentMacro.getWaveformReferenceMacro();
		CompositeObjectReferenceMacro objCompositeObjectReferenceMacro = objWaveformReferenceMacro.getCompositeObjectReferenceMacro();
		ReferencedSOPSequence objReferencedSOPSequence = objCompositeObjectReferenceMacro.getReferencedSOPSequence();
		ReferencedSOPSequenceItem objReferencedSOPSequenceItem = objReferencedSOPSequence.getNewItem();
		objReferencedSOPSequenceItem.getSOPInstanceReferenceMacro().setReferencedSOPClassUID(strRefSOPClassUID);
		objReferencedSOPSequenceItem.getSOPInstanceReferenceMacro().setReferencedSOPInstanceUID(strRefSOPInstanceUID);
		objReferencedSOPSequence.addItem(objReferencedSOPSequenceItem);

		objWaveformReferenceMacro.setReferencedWaveformChannels(arrShReferencedWaveformChannels);

		/*
		 * creating DOCUMENT RELATIONSHIP MACRO and Content Sequence in it.
		 */
		DocumentRelationshipMacro objDocumentRelationshipMacro = objContentSequenceItem.getDocumentRelationshipMacro();
		@SuppressWarnings("unused")
		ContentSequence objContentSequence2 = objDocumentRelationshipMacro.getContentSequence();
		//objDocumentRelationshipMacro.setObservationDateTime("11:45");

		return objContentSequenceItem;
	}
	
	/**
	 * Creates IMAGE type of Node with specified attributes.
	 * @param arrPosition position at which the node will get added in the tree.
	 * @param strCodeMeaning Heading of Node of type IMAGE
	 * @param strCodeValue Code value of Node
	 * @param strCodeSchemeDesignator Code Scheme Designator of Node
	 * @param strRefSOPClassUIDForCORefMacro Referenced SOP Class UID for Composite Object Reference Macro
	 * @param strRefSOPInstanceUIDForCORefMacro Referenced SOP Instance UID for Composite Object Reference Macro
	 * @param arrStrReferencedFrameNumber String Array of Referenced Frame Number.
	 * @param strRefSOPClassUID Referenced SOP Class UID.
	 * @param strRefSOPInstanceUID Referenced SOP Instance UID.
	 * @param enumRelationshipType Enum value for Relationship Type between the (enclosing) Source Content Item and the Target Content Item.
	 * @return objContentSequenceItem object of ContentSequenceItem. 
	 */
	private ContentSequenceItem createImageNode(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator, 
			String strRefSOPClassUIDForCORefMacro,String strRefSOPInstanceUIDForCORefMacro,String[] arrStrReferencedFrameNumber,
			String strRefSOPClassUID, String strRefSOPInstanceUID,EnumRelationshipType enumRelationshipType/*,
			short shSamplesperPixel, String strPhotometricInterpretation, short shRows, short shColumns, short shBitsAllocated,
			short shBitsStored, short shHighBit,short shPixelRepresentation, ISingleCollection<byte[]> objCollectionOfPixelData,
			EnumPixelDataVRType enumPixelDataVRType, Boolean isUndefined, short shPlanarConfiguration, short[] shPixelAspectRatio,
			short shSmallestImagePixelValue, short shLargestImagePixelValue, short []shRedPaletteColorLookupTableDescriptor,
			short []shGreenPaletteColorLookupTableDescriptor, short []shBluePaletteColorLookupTableDescriptor,
			ISingleCollection<byte[]> collRedPaletteColLookupTableData, ISingleCollection<byte[]> collGreenPaletteColLookupTableData,
			ISingleCollection<byte[]> collBluePaletteColLookupTableData*/)
	{
		//ContentSequence objContentSequence = getContentSequence();
		/**
		 * Get Content Sequence from DocumentRelationshipMacro of ContentSequenceItem
		 */
		ContentSequence objContentSequence = this.objContentSequenceItem.getDocumentRelationshipMacro().getContentSequence();
		

		ContentSequenceItem objContentSequenceItem = objContentSequence.getNewItem();

		objContentSequenceItem.setRelationshipType(enumRelationshipType);

		// identifier of a node
		int[] lArrReferencedContentItemIdentifier = arrPosition;
		objContentSequenceItem.setReferencedContentItemIdentifier(lArrReferencedContentItemIdentifier);

		/*
		 * creating DOCUMENT CONTENT MACRO
		 */
		DocumentContentMacro objDocumentContentMacro = objContentSequenceItem.getDocumentContentMacro();

		objDocumentContentMacro.setValueType(EnumValueType.IMAGE);

		//creating CONCEPT NAME CODE SEQUENCE
		ConceptNameCodeSequence objNameCodeSequence = objDocumentContentMacro.getConceptNameCodeSequence();
		CodeSequenceMacroDependentItem objCodeSequenceMacroDependentItem = objNameCodeSequence.getNewItem();
		CodeSequenceMacro objCodeSequenceMacro = objCodeSequenceMacroDependentItem.getCodeSequenceMacro();
		objCodeSequenceMacro.setCodeMeaning(strCodeMeaning);
		objCodeSequenceMacro.setCodeValue(strCodeValue);
		objCodeSequenceMacro.setCodeSchemeDesignator(strCodeSchemeDesignator);
		objNameCodeSequence.addItem(objCodeSequenceMacroDependentItem);

		//IMAGE REFERENCED MACRO
		ImageReferenceMacro objImageReferenceMacro = objDocumentContentMacro.getImageReferenceMacro();

		//CompositeObjectReferenceMacro
		//setCompositeObjectReferenceMacroAttributes(objDocumentContentMacro, strRefSOPClassUIDForCORefMacro, strRefSOPClassUIDForCORefMacro);
		CompositeObjectReferenceMacro objCompositeObjectReferenceMacro = objImageReferenceMacro.getCompositeObjectReferenceMacro();
		ReferencedSOPSequence objReferencedSOPSequenceinCRM = objCompositeObjectReferenceMacro.getReferencedSOPSequence();
		ReferencedSOPSequenceItem objReferencedSOPSequenceIteminCRM = objReferencedSOPSequenceinCRM.getNewItem();
		objReferencedSOPSequenceIteminCRM.getSOPInstanceReferenceMacro().setReferencedSOPClassUID(strRefSOPClassUID);
		objReferencedSOPSequenceIteminCRM.getSOPInstanceReferenceMacro().setReferencedSOPInstanceUID(strRefSOPInstanceUID);
		objReferencedSOPSequenceinCRM.addItem(objReferencedSOPSequenceIteminCRM);

		objImageReferenceMacro.setReferencedFrameNumber(arrStrReferencedFrameNumber);

		// REFERENCED SOP SEQUENCE
		ReferencedSOPSequence objReferencedSOPSequence = objImageReferenceMacro.getReferencedSOPSequence();
		ReferencedSOPSequenceItem objReferencedSOPSequenceItem = objReferencedSOPSequence.getNewItem();
		objReferencedSOPSequenceItem.getSOPInstanceReferenceMacro().setReferencedSOPClassUID(strRefSOPClassUID);
		objReferencedSOPSequenceItem.getSOPInstanceReferenceMacro().setReferencedSOPInstanceUID(strRefSOPInstanceUID);

		//Icon Image Sequence
		IconImageSequence objIconImageSequence = objImageReferenceMacro.getIconImageSequence();
		IconImageSequenceItem objIconImageSequenceItem = objIconImageSequence.getNewItem();

		@SuppressWarnings("unused")
		ImagePixelMacro objImagePixelMacro = objIconImageSequenceItem.getImagePixelMacro();
		/*objImagePixelMacro.setSamplesperPixel(shSamplesperPixel);
		objImagePixelMacro.setPhotometricInterpretation(strPhotometricInterpretation);
		objImagePixelMacro.setRows(shRows);
		objImagePixelMacro.setColumns(shColumns);
		objImagePixelMacro.setBitsAllocated(shBitsAllocated);
		objImagePixelMacro.setBitsStored(shBitsStored);
		objImagePixelMacro.setHighBit(shHighBit);
		objImagePixelMacro.setPixelRepresentation(shPixelRepresentation);
		objImagePixelMacro.setPixelData(objCollectionOfPixelData, enumPixelDataVRType, isUndefined);
		objImagePixelMacro.setPlanarConfiguration(shPlanarConfiguration);
		objImagePixelMacro.setPixelAspectRatio(shPixelAspectRatio);
		objImagePixelMacro.setSmallestImagePixelValue(shSmallestImagePixelValue);
		objImagePixelMacro.setLargestImagePixelValue(shLargestImagePixelValue);
		objImagePixelMacro.setRedPaletteColorLookupTableDescriptor(shRedPaletteColorLookupTableDescriptor);
		objImagePixelMacro.setGreenPaletteColorLookupTableDescriptor(shGreenPaletteColorLookupTableDescriptor);
		objImagePixelMacro.setBluePaletteColorLookupTableDescriptor(shBluePaletteColorLookupTableDescriptor);
		objImagePixelMacro.setRedPaletteColorLookupTableData(collRedPaletteColLookupTableData);
		objImagePixelMacro.setGreenPaletteColorLookupTableData(collGreenPaletteColLookupTableData);
		objImagePixelMacro.setBluePaletteColorLookupTableData(collBluePaletteColLookupTableData);*/
		objIconImageSequence.addItem(objIconImageSequenceItem);
		
		/*
		 * creating DOCUMENT RELATIONSHIP MACRO and Content Sequence in it.
		 */
		DocumentRelationshipMacro objDocumentRelationshipMacro = objContentSequenceItem.getDocumentRelationshipMacro();
		@SuppressWarnings("unused")
		ContentSequence objContentSequence2 = objDocumentRelationshipMacro.getContentSequence();
		//objDocumentRelationshipMacro.setObservationDateTime("11:45");

		return objContentSequenceItem;
	}

	
	private void getPosition1(int[] arr)
	{
		String strPosition = "[ ";
		for(int i=0 ; i< arr.length ; i++)
		{
			strPosition = strPosition + arr[i] + " ";
		}
		strPosition = strPosition + "]\n";

		System.out.println(strPosition);
	}
}