/*******************************************************************************
 *  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 java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Locale;

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.DicomV3Factory;
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.commoninterface.IDataElement;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataSet;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDicomValue;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDictionaryReader;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IItem;
import cdac.medinfo.sdk.dcm30_04.commoninterface.ITransferSyntax;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.SRDocumentContentModule;
import cdac.medinfo.sdk.dcm30_04.dicomstreams.DicomFileStream;
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.exceptions.DuplicateIdentifierException;
import cdac.medinfo.sdk.dcm30_04.exceptions.InvalidSRDocumentException;
import cdac.medinfo.sdk.dcm30_04.exceptions.TreeStructureViolationException;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConfig;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConstants;
import cdac.medinfo.sdk.dcm30_04.utils.DicomLogger;
import cdac.medinfo.sdk.dcm30_04.utils.ICollectionIterator;
import cdac.medinfo.sdk.dcm30_04.utils.ISingleCollection;
import cdac.medinfo.sdk.dcm30_04.utils.ResourceBundleWrapper;
import cdac.medinfo.sdk.dcm30_04.utils.SingleCollection;
/**
 *	This class helps to create Root of SRTree. Also provides API for serializing Document in the form of 
 *	MS Word Document and XML document. APIs for creating different NODEs of different Valu Types.
 */
public class SRTree 
{
	/**
	 * The object of SRDocumentContentModule.
	 */
	private SRDocumentContentModule objSRDocumentContentModule = null;

	/**
	 * The object of ContentSequence.
	 */
	private ContentSequence objRootContentSequence= null;

	/**
	 * Collection of Identifiers at which specifies the position at which node is getting added.
	 */
	ISingleCollection<int[]> objCollectionPosition = null;

	/**
	 * Retrieve the value of collection for Identifiers
	 * @return objCollectionPosition ISingleCollection of Identifiers
	 */
	public ISingleCollection<int[]> getCollectionPosition()
	{
		return objCollectionPosition;
	}

	/**
	 * Retrieve the value of Root ContentSequence
	 * @return objRootContentSequence object of Content Sequence.
	 */
	public ContentSequence getRootContentSequence() 
	{
		return objRootContentSequence;
	}

	/**
	 * Retrieve the value of SRDocumentContentModule
	 * @return objSRDocumentContentModule Object of SRDocumentContentModule.
	 */
	public SRDocumentContentModule getSRDocumentContentModule() 
	{
		return objSRDocumentContentModule;
	}


	/**
	 * This constructor creates SRTree Item with specified objSRDocumentContentModule.
	 * @param objSRDocumentContentModule object of SRDocumentContentModule
	 */
	public SRTree(SRDocumentContentModule objSRDocumentContentModule)
	{
		this.objSRDocumentContentModule = objSRDocumentContentModule;
		objCollectionPosition = new SingleCollection<int[]>();
	}

	/**
	 * creates the object of contentSequence using DicomV3Factory.
	 * @return objContentSequence boject of ContentSequence.
	 */
	private ContentSequence getContentSequence()
	{
		ContentSequence objContentSequence = null;

		DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();

		// getting values for objTransferSyntax and objDictionaryReader.
		ITransferSyntax objTransferSyntax = objSRDocumentContentModule.getTransferSyntax();
		IDictionaryReader objDictionaryReader = objSRDocumentContentModule.getDictionaryReader();

		objContentSequence = (ContentSequence)objDicomV3Factory.createSequence(0x0040,0xA730, objTransferSyntax, objDictionaryReader);
		return objContentSequence;
	}

	/**
	 * creates the root node for SR Document tree with passed information filled in respective attributes 
	 * and with ReferencedContentItemIdentifier as 1.
	 * @param objDocumentContentModule object of SRDocumentContentModule.
	 * @param strCodeMeaning string for CodeMeaning which will be heading for the document
	 * @param strCodeValue string for CodeValue.
	 * @param strCodeSchemeDesignator string value for CodeSchemeDesignator.
	 * @param enumContinuityOfContent object of EnumContinuityOfContent
	 */
	public void createRoot(SRDocumentContentModule objDocumentContentModule,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,EnumContinuityOfContent enumContinuityOfContent)
	{
		this.objSRDocumentContentModule = objDocumentContentModule;

		//-----------  Get ContentSequenceMacro and add to DataSet since document suggests that
		//the SR Document Content Modue consists of A DocumentContentMacro and then a DocumentRelationshipMacro
		DocumentContentMacro objDocumentContentMacroRoot = objDocumentContentModule.getDocumentContentMacro();
		objDocumentContentMacroRoot.setValueType(EnumValueType.CONTAINER);
		ConceptNameCodeSequence objNameCodeSequence = objDocumentContentMacroRoot.getConceptNameCodeSequence();
		CodeSequenceMacroDependentItem objCodeSequenceMacroDependentItem = objNameCodeSequence.getNewItem();

		CodeSequenceMacro objCodeSequenceMacro = objCodeSequenceMacroDependentItem.getCodeSequenceMacro();
		objCodeSequenceMacro.setCodeMeaning(strCodeMeaning);
		objCodeSequenceMacro.setCodeValue(strCodeValue);
		objCodeSequenceMacro.setCodeSchemeDesignator(strCodeSchemeDesignator);
		objNameCodeSequence.addItem(objCodeSequenceMacroDependentItem);

		//----------Get Document Relationship Macro from module
		DocumentRelationshipMacro objDocumentRelationshipMacro = objDocumentContentModule.getDocumentRelationshipMacro();

		ContentSequence objContentSequenceRoot = objDocumentRelationshipMacro.getContentSequence();
		ContentSequenceItem objContentSequenceItem = objContentSequenceRoot.getNewItem();

		//-----------  Get ConteneSequenceMacro and add to root's Content Sequence Item
		objDocumentContentMacroRoot = objContentSequenceItem.getDocumentContentMacro();
		objDocumentContentMacroRoot.setValueType(EnumValueType.CONTAINER);
		objNameCodeSequence = objDocumentContentMacroRoot.getConceptNameCodeSequence();
		objCodeSequenceMacroDependentItem = objNameCodeSequence.getNewItem();

		objCodeSequenceMacro = objCodeSequenceMacroDependentItem.getCodeSequenceMacro();
		objCodeSequenceMacro.setCodeMeaning(strCodeMeaning);
		objCodeSequenceMacro.setCodeValue(strCodeValue);
		objCodeSequenceMacro.setCodeSchemeDesignator(strCodeSchemeDesignator);

		objNameCodeSequence.addItem(objCodeSequenceMacroDependentItem);
		objDocumentContentMacroRoot.setContinuityOfContent(enumContinuityOfContent);

		/*
		 * setting ReferencedContentItemIdentifier for ROOT node which will alwasy be 1.
		 */
		int[] lArrReferencedContentItemIdentifierForRoot = {1};
		objContentSequenceItem.setReferencedContentItemIdentifier(lArrReferencedContentItemIdentifierForRoot);

		DocumentRelationshipMacro objDocumentRelationshipMacroOfRoot = objContentSequenceItem.getDocumentRelationshipMacro();
		@SuppressWarnings("unused")
		ContentSequence objContentSequence = objDocumentRelationshipMacroOfRoot.getContentSequence();

		objContentSequenceRoot.addItem(objContentSequenceItem);

		//this.objRootContentSequenceItem = objContentSequenceItem;
		this.objRootContentSequence = objContentSequenceRoot;
	}

	/**
	 * checks whether two identifiers are same or not. 
	 * @param arrInColl Array of integers.Shows the identifier at which the node is already present.  
	 * @param arrCurrent Array of integers.Shows the identifier at which the node is to be added.
	 * @return ture or false.
	 */
	private boolean isSamePosition(int[] arrInColl, int[] arrCurrent)
	{
		if(arrInColl.length == arrCurrent.length)
		{
			for(int i=0; i<arrInColl.length; i++)
			{
				if(arrInColl[i] != arrCurrent[i])
					return false;
			}
			return true;
		}
		else
		{
			return false;
		}
	}

	/**
	 * Gives the identifier which denotes the position at which the node will get added.
	 * @param arr Array of integers.
	 * @return String - Position.
	 */
	private String getPosition(int[] arr)
	{
		String strPosition = "[ ";
		for(int i=0 ; i< arr.length ; i++)
		{
			strPosition = strPosition + arr[i] + " ";
		}
		strPosition = strPosition + "]\n";

		return strPosition;
	}

	/**
	 * This will add a child node to the node of value type CONTAINER at specified position.
	 * @param objContentSequenceItemToBeAdded object of ContentSequenceItem that is to be added.
	 */
	@SuppressWarnings("unchecked")
	public void addChild(ContentSequenceItem objContentSequenceItemToBeAdded)throws InvalidSRDocumentException
	{
		//Get ContentSequence of ROOT
		ContentSequence objContentSequence = objSRDocumentContentModule.getDocumentRelationshipMacro().getContentSequence();

		int [] arrPositionNewNode = objContentSequenceItemToBeAdded.getReferencedContentItemIdentifier();

		//Get the Total Number of Levels to be traversed
		int iSize = arrPositionNewNode.length;


		// Collection of Child of a node
		ISingleCollection<int[]> objcollectionOfChild = new SingleCollection<int[]>();

		//First node to be added will get added at position {1,1} only
		if(this.objCollectionPosition.isEmpty())
		{
			int[] arrFirstPos = {1,1};
			if(!isSamePosition(arrFirstPos,arrPositionNewNode))
			{
				//System.out.println("exception for first node");
				TreeStructureViolationException objTreeStructureViolationException = new TreeStructureViolationException();
				if(DicomConfig.createInstance().isLoggingOn())
				{
					DicomLogger objDicomLogger = DicomLogger.getLogger();
					objDicomLogger.log(objTreeStructureViolationException);
				}
				//Throwing InvalidSRDocumentException with objTreeStructureViolationException as a cause of it.
				throw new InvalidSRDocumentException(ResourceBundleWrapper.getValue("exceptions","SRTree.InvalidSRDocument",new Locale(DicomConfig.createInstance().getLocale())),objTreeStructureViolationException);
			}
		}

		// Check whether item is already added to the same position
		ICollectionIterator<int[]> objIterator = this.objCollectionPosition.iterator();
		while(objIterator.hasNext())
		{
			// Current Position in the collection of Identifier.
			int[]arrCurrentPosition = objIterator.next();

			// check for duplicate position
			if(isSamePosition(arrPositionNewNode, arrCurrentPosition))
			{
				DuplicateIdentifierException objDuplicateIdentifierException = new DuplicateIdentifierException(getPosition(arrPositionNewNode));
				if(DicomConfig.createInstance().isLoggingOn())
				{
					DicomLogger objDicomLogger = DicomLogger.getLogger();
					objDicomLogger.log(objDuplicateIdentifierException);
				}
				//Throwing InvalidSRDocumentException with DuplicateIdentifierException as a cause of it.
				throw new InvalidSRDocumentException(ResourceBundleWrapper.getValue("exceptions","SRTree.InvalidSRDocument",new Locale(DicomConfig.createInstance().getLocale())), objDuplicateIdentifierException);
			}

			if(!this.objCollectionPosition.isEmpty())
			{
				if((arrCurrentPosition.length == arrPositionNewNode.length) && (arrCurrentPosition[arrCurrentPosition.length-2] == arrPositionNewNode[arrPositionNewNode.length -2]))
				{
					objcollectionOfChild.add(arrCurrentPosition);
				}
			}
		}

		//Iterate through child to find whether new child which is to be added has valid position or not.
		Boolean flag = false;
		ICollectionIterator<int[]> objcollectionIterator = objcollectionOfChild.iterator();
		// if is empty that is child to be added at new level then its last index of position should be one.
		if(objcollectionOfChild.isEmpty())
		{
			if(arrPositionNewNode[arrPositionNewNode.length-1] != 1)
			{
				TreeStructureViolationException objTreeStructureViolationException = new TreeStructureViolationException();
				if(DicomConfig.createInstance().isLoggingOn())
				{
					DicomLogger objDicomLogger = DicomLogger.getLogger();
					objDicomLogger.log(objTreeStructureViolationException);
				}
				//Throwing InvalidSRDocumentException with objTreeStructureViolationException as a cause of it.
				throw new InvalidSRDocumentException(ResourceBundleWrapper.getValue("exceptions","SRTree.InvalidSRDocument",new Locale(DicomConfig.createInstance().getLocale())),objTreeStructureViolationException);
			}
			flag = true;
		}
		else
		{
			while(objcollectionIterator.hasNext())
			{
				int[] arr = objcollectionIterator.next();

				int iLastValue = arr[arr.length-1];

				if(iLastValue == arrPositionNewNode[arrPositionNewNode.length-1]-1)
				{
					flag = true;
				}
			}
		}

		if(!flag)
		{
			//System.out.println("child before this is not added. Node is already added at this position || Node can not be added at this position.");
			TreeStructureViolationException objTreeStructureViolationException = new TreeStructureViolationException();
			if(DicomConfig.createInstance().isLoggingOn())
			{
				DicomLogger objDicomLogger = DicomLogger.getLogger();
				objDicomLogger.log(objTreeStructureViolationException);
			}
			//Throwing InvalidSRDocumentException with objTreeStructureViolationException as a cause of it.
			throw new InvalidSRDocumentException(ResourceBundleWrapper.getValue("exceptions","SRTree.InvalidSRDocument",new Locale(DicomConfig.createInstance().getLocale())),objTreeStructureViolationException);
		}
		else
		{
			ContentSequenceItem  item = null;
			int level = 0;//current level that is being traversed

			//Get Item of the ContentSequence of ROOT
			ISingleCollection<IItem> objSingleCollectionItems = (ISingleCollection<IItem>)objContentSequence.getValue();

			//Getting size of collection to check whether Root node is added or not.
			int size = objSingleCollectionItems.size();
			if(size != 0)
				item = (ContentSequenceItem)((ISingleCollection<IItem>)objContentSequence.getValue()).elementAt(0);
			else
			{
				//System.out.println("Plz ADD root Node....!");
				TreeStructureViolationException objTreeStructureViolationException = new TreeStructureViolationException();
				if(DicomConfig.createInstance().isLoggingOn())
				{
					DicomLogger objDicomLogger = DicomLogger.getLogger();
					objDicomLogger.log(objTreeStructureViolationException);
				}
				//Throwing InvalidSRDocumentException with objTreeStructureViolationException as a cause of it.
				throw new InvalidSRDocumentException(ResourceBundleWrapper.getValue("exceptions","SRTree.InvalidSRDocument",new Locale(DicomConfig.createInstance().getLocale())),objTreeStructureViolationException);
			}


			//For Each level do
			for(level = 1; level < iSize; level++)
			{ 
				// if it is container then only Content Sequence will be present and item can be added to sequence.
				// So that child will not get added to any non CONTAINER type of NODE.
				if(item.contains(0x0040, 0xA730))
				{
					//Get ContentSequence
					objContentSequence = (ContentSequence) item.getDataForTag(0x0040, 0xA730).getDicomValue();

					//Adding item directly to the root for first time or adding item as leaf node. 
					if(level == iSize - 1 )
					{
						//	If position at which the item is to be added is new then add that position to Collection.
						this.objCollectionPosition.add(arrPositionNewNode);

						objContentSequence.addItem(objContentSequenceItemToBeAdded);
					}
					else
					{
						//getting collection of items of a sequence for selecting correct sequence to which the new SQ item is to be added.
						ISingleCollection<IItem> itemCollec = (ISingleCollection<IItem>) objContentSequence.getValue();	

						//Since level denotes the current level being traversed,
						//value at (arrPositionNewNode[level]-1) tells you exactly which item to be selected
						item = (ContentSequenceItem)itemCollec.elementAt((arrPositionNewNode[level])-1);	
					}
				}
//				else
//				{
//				// If child is getting added in any non CONTAINER type of node, it will throw an exception.
//				InvalidPositionException objInvalidPositionException = new InvalidPositionException(getPosition(arrPositionNewNode));
//				if(DicomConfig.createInstance().isLoggingOn())
//				{
//				DicomLogger objDicomLogger = DicomLogger.getLogger();
//				objDicomLogger.log(objInvalidPositionException);
//				}
//				//Throwing InvalidSRDocumentException with DuplicateIdentifierException as a cause of it.
//				throw new InvalidSRDocumentException(ResourceBundleWrapper.getValue("exceptions","SRTree.InvalidSRDocument",new Locale(DicomConfig.createInstance().getLocale())),objInvalidPositionException);
//				}
			}
		}
	}

	/**
	 * 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.
	 * @return object of ContentSequenceItem.
	 */
	private ContentSequenceItem createNode(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,EnumValueType enumValueType ,String strValue)
	{
		ContentSequence objContentSequence = getContentSequence();

		//ContentSequence objContentSequence = objDoc.getContentSequence();
		ContentSequenceItem objContentSequenceItem = objContentSequence.getNewItem();

		objContentSequenceItem.setRelationshipType(EnumRelationshipType.CONTAINS);

		// 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;
	}



	/**
	 * Creates a node of type PNAME
	 * @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 node which will be added ie of value type PANME, the strValue will define its name.
	 * @return object of ContentSequenceItem.
	 */
	public ContentSequenceItem createPnameNode(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,String strValue)
	{
		return(createNode(arrPosition,strCodeMeaning, strCodeValue, strCodeSchemeDesignator, EnumValueType.PNAME, strValue));
	}

	/**
	 * Creates a node of type TEXT
	 * @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 node which will be added ie of value type TEXT, the strValue will define contents under that node.
	 * @return object of ContentSequenceItem.
	 */
	public ContentSequenceItem createTextNode(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,String strValue)
	{
		return(createNode(arrPosition,strCodeMeaning, strCodeValue, strCodeSchemeDesignator, EnumValueType.TEXT, strValue));
	}

	/**
	 * Creates a node of type DATE
	 * @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 node which will be added ie of value type DATE, the strValue will define contents under that node.
	 * @return object of ContentSequenceItem.
	 */
	public ContentSequenceItem createDateNode(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,String strValue)
	{
		return(createNode(arrPosition,strCodeMeaning, strCodeValue, strCodeSchemeDesignator, EnumValueType.DATE, strValue));
	}

	/**
	 * Creates a node of type TIME
	 * @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 node which will be added ie of value type TIME, the strValue will define contents under that node.
	 * @return object of ContentSequenceItem.
	 */
	public ContentSequenceItem createTimeNode(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,String strValue)
	{
		return(createNode(arrPosition,strCodeMeaning, strCodeValue, strCodeSchemeDesignator, EnumValueType.TIME, strValue));
	}

	/**
	 * Creates a node of type DATETIME
	 * @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 node which will be added ie of value type DATETIME, the strValue will define contents under that node.
	 * @return object of ContentSequenceItem.
	 */
	public ContentSequenceItem createDateTimeNode(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,String strValue)
	{
		return(createNode(arrPosition,strCodeMeaning, strCodeValue, strCodeSchemeDesignator, EnumValueType.DATETIME, strValue));
	}

	/**
	 * Creates a node of type UIDREF
	 * @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 node which will be added ie of value type UIDREF, the strValue will define contents under that node.
	 * @return object of ContentSequenceItem.
	 */
	public ContentSequenceItem createUIDREFNode(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,String strValue)
	{
		return(createNode(arrPosition,strCodeMeaning, strCodeValue, strCodeSchemeDesignator, EnumValueType.UIDREF, strValue));
	}

	/**
	 * will return container ContentSequenceItem without its child ContentSequence. 
	 * @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
	 * @return object of ContentSequenceItem.
	 */
	public ContentSequenceItem createContainer(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strsetCodeSchemeDesignator, EnumContinuityOfContent enumContinuityOfContent)
	{
		ContentSequence objContentSequence = getContentSequence();

		ContentSequenceItem objContentSequenceItemForCONTAINER = objContentSequence.getNewItem();
		//objContentSequence.addItem(objContentSequenceItemForCONTAINER);
		objContentSequenceItemForCONTAINER.setRelationshipType(EnumRelationshipType.CONTAINS);

		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(strsetCodeSchemeDesignator);
		objNameCodeSequenceCONTAINER.addItem(objCodeSequenceMacroDependentItemCONTAINER);

		objDocumentContentMacroForCONTAINER.setContinuityOfContent(enumContinuityOfContent);

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

		return objContentSequenceItemForCONTAINER;
	}
	/**
	 * This will add SnomedCT CODE in already created node with specified attributes.
	 * @param arrPosition position at which the node will get added in the tree.
	 * @param strCodeMeaning Heading of Node of type CONTAINER
	 * @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 strSNOMEDCTID SNOMED CT for CodeSequenceMacro inside CodeMacro
	 * @return object of ContentSequenceItem.
	 */
	public ContentSequenceItem createContainer(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strsetCodeSchemeDesignator, EnumContinuityOfContent enumContinuityOfContent, String strSNOMEDCTID)
	{
	{
		//objContentSequenceItem1 holds the retrieved values from overloaded function createContainer().
		ContentSequenceItem objContentSequenceItem1= createContainer(arrPosition, strCodeMeaning, strCodeValue, strsetCodeSchemeDesignator, enumContinuityOfContent);
		
		DocumentContentMacro objDocumentContentMacro = objContentSequenceItem1.getDocumentContentMacro();
		CodeMacro objCodeMacro = objDocumentContentMacro.getCodeMacro();
		ConceptCodeSequence objConceptCodeSequence = objCodeMacro.getConceptCodeSequence();
		
		// create objSequenceMacroDependentItem to set only single value in code node other values assigned by overloaded function.
		//ICollectionIterator<IItem> itr = objConceptCodeSequence.iterator();
		for (IItem iItem : objConceptCodeSequence) {
			
			CodeSequenceMacroDependentItem objSequenceMacroDependentItem = (CodeSequenceMacroDependentItem)iItem;
			CodeSequenceMacro objSequenceMacro = objSequenceMacroDependentItem.getCodeSequenceMacro();
			
			//Set only SNOMED CT Value in Pre-created item.
			objSequenceMacro.setSNOMEDCTID(strSNOMEDCTID); 
		}
			return objContentSequenceItem1;
	}
	}
	/**
	 * 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
	 * @return object of ContentSequenceItem.
	 */
	public ContentSequenceItem createCodeNode(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,String strCodeValueForCode, String strCodeSchemeDesignatorForCode,String strCodingSchemeVersionForCode,String strCodeMeaningForCode)
	{
		ContentSequence objContentSequence = getContentSequence();

		ContentSequenceItem objContentSequenceItem = objContentSequence.getNewItem();

		objContentSequenceItem.setRelationshipType(EnumRelationshipType.CONTAINS);

		// 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;
	}

	/**
	 * This will create NUM 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 NUMS
	 * @param strCodeValue Code value of Node
	 * @param strCodeSchemeDesignator Code Scheme Designator of Node
	 * @param arrNumericValue String array for Numeric Value..
	 * @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 argstrCodeMeaningForCode Code Meaning (Heading) for CodeSequenceMacro inside CodeMacro
	 * @return object of ContentSequenceItem.
	 */
	public 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)
	{
		ContentSequence objContentSequence = getContentSequence();

		ContentSequenceItem objContentSequenceItem = objContentSequence.getNewItem();

		objContentSequenceItem.setRelationshipType(EnumRelationshipType.CONTAINS);

		// 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.setCodingSchemeVersion(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
	 * @return object of ContentSequenceItem.
	 */
	public ContentSequenceItem createCompositeNode(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator, String strReferencedSOPClassUID, String strReferencedSOPInstanceUID)
	{
		ContentSequence objContentSequence = getContentSequence();

		ContentSequenceItem objContentSequenceItem = objContentSequence.getNewItem();

		objContentSequenceItem.setRelationshipType(EnumRelationshipType.CONTAINS);

		// 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 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 COMPOSITE
	 * @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 string String Array of Referenced Frame Number.
	 * @param strRefSOPClassUID Referenced SOP Class UID.
	 * @param strRefSOPInstanceUID Referenced SOP Instance UID.
	 * @return objContentSequenceItem - Object of ContentSequenceItem
	 */
	public ContentSequenceItem createImageNode(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator, String strRefSOPClassUIDForCORefMacro,String strRefSOPInstanceUIDForCORefMacro,String[] string,String strRefSOPClassUID, String strRefSOPInstanceUID)
	{
		ContentSequence objContentSequence = getContentSequence();

		ContentSequenceItem objContentSequenceItem = objContentSequence.getNewItem();

		objContentSequenceItem.setRelationshipType(EnumRelationshipType.CONTAINS);

		// 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);

		objImageReferenceMacro.setReferencedFrameNumber(string);

		// 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.set

		/*
		 * 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 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 COMPOSITE
	 * @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
	 * @return object of ContentSequenceItem.
	 */
	public ContentSequenceItem createWaveformNode(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator, String strRefSOPClassUID, String strRefSOPInstanceUID, short[] arrShReferencedWaveformChannels)
	{
		ContentSequence objContentSequence = getContentSequence();

		ContentSequenceItem objContentSequenceItem = objContentSequence.getNewItem();

		objContentSequenceItem.setRelationshipType(EnumRelationshipType.CONTAINS);

		// 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 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.
	 */
	@SuppressWarnings("unused")
	public ContentSequenceItem createSCOORDNode(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,float [] arrFlGraphicData,EnumGraphicType enumGraphicType)
	{
		ContentSequence objContentSequence = getContentSequence();

		ContentSequenceItem objContentSequenceItem = objContentSequence.getNewItem();

		objContentSequenceItem.setRelationshipType(EnumRelationshipType.CONTAINS);

		// 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();
		
		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.
	 */
	@SuppressWarnings("unused")
	public ContentSequenceItem createTCOORDNode(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,String []arrStrReferencedDatetime,int []lArrReferencedSamplePositions, String []arrStrReferencedTimeOffsets,EnumTemporalRangeType enumTemporalRangeType)
	{
		ContentSequence objContentSequence = getContentSequence();
		
		ContentSequenceItem objContentSequenceItem = objContentSequence.getNewItem();

		objContentSequenceItem.setRelationshipType(EnumRelationshipType.CONTAINS);

		// 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;
	}

	/**
	 * creates the SR document in the form of doc file.
	 * @param objIDataSet Object of IDataSet.
	 * @param path  path where SR document will be kept.
	 * @return boolean value i. e. true or false.
	 */
	@SuppressWarnings("unchecked")
	public boolean serializeSRDoc(IDataSet objIDataSet, String strPath)
	{
		try
		{
			// Fetching StudyInstanceUID for giving name to the SR document.
			String strStudyInstanceUID = objIDataSet.getValue(0x0020,0x000D).toString();

			File objFile = null;

			//If user dont provide its own path for storage take that path otherwise use default storage path. 
			if(strPath == null)				
				strPath = DicomConstants.DICOM_CSTORE_STORAGE_PATH;

			objFile = new File(strPath );
			objFile.mkdirs();

			if(!strPath.endsWith("/"));
			String strDocumentName = strPath + "/" + strStudyInstanceUID+".doc";

			objFile = new File(strDocumentName);

			// creating FileOutputStream object and setting it to the DicomFileStream.
			FileOutputStream objFileOutputStream = new FileOutputStream(objFile);
			DicomFileStream objDicomFileStream = new DicomFileStream();
			objDicomFileStream.setOutputStream(objFileOutputStream);

			/**
			 * Fatching Concept Name Code Sequence from DataSet.
			 */
			IDataElement objIDataElement1 = objIDataSet.getDataForTag(0x0040, 0xA043);
			IDicomValue objIDicomValue1 = objIDataElement1.getDicomValue();
			ConceptNameCodeSequence objConceptNameCodeSequence1= (ConceptNameCodeSequence)objIDicomValue1;

			/**
			 * getValue mathod will return Single Collection of Items of a sequence.
			 */			
			ISingleCollection<IItem> objSingleCollectionConceptNameCodeSequenceItem1 = (ISingleCollection<IItem>)objConceptNameCodeSequence1.getValue();

			/**
			 * Writting Heading of a SR Document, fetching value of Code Meaning from CodeSequenceMacroDependentItem.
			 * There will be single ConceptNameCodeSequenceItem will be present in ConceptNameCodeSequence.
			 */
			if(objSingleCollectionConceptNameCodeSequenceItem1 != null)
			{
				CodeSequenceMacroDependentItem objCodeSequenceMacroDependentItem1 = (CodeSequenceMacroDependentItem)objSingleCollectionConceptNameCodeSequenceItem1.elementAt(0);
				if(objCodeSequenceMacroDependentItem1.contains(0x0008,0x0104))
				{
					//System.out.println(objCodeSequenceMacroDependentItem1.getValue(0x0008,0x0104).toString() + "\n");
					String objStrToWrite = "\t\t\t\t\t" + objCodeSequenceMacroDependentItem1.getValue(0x0008,0x0104).toString() + "\n";
					byte[] b_array = objStrToWrite.getBytes();
					objFileOutputStream.write(b_array);
				}
			}

			/**
			 * Fetching ContentSequence from DataSet.
			 */
			IDataElement objIDataElement = objIDataSet.getDataForTag(0x0040, 0xA730);
			IDicomValue objIDicomValue = objIDataElement.getDicomValue();
			ContentSequence objContentSequence = (ContentSequence)objIDicomValue;

			if(objContentSequence != null)
			{
				/**
				 *  Iterator for items of Content Sequence.
				 */
				ICollectionIterator<IItem> objContentSequenceIterator = objContentSequence.iterator();

				ContentSequenceItem objContentSequenceItem = null;

				/**
				 * String value of EnumValueType.
				 * It can be : 
				 * 1.  PNAME
				 * 2.  TEXT
				 * 3.  CONTAINER
				 * 4.  CODE
				 * 5.  COMPOSITE
				 * 6.  DATETIME
				 * 7.  DATE
				 * 8.  IMAGE
				 * 9.  NUM
				 * 10. TIME
				 * 11. UIDREF
				 * 12. WAVEFORM
				 */
				String strValueType = null;

				while(objContentSequenceIterator.hasNext())
				{
					objContentSequenceItem = (ContentSequenceItem)objContentSequenceIterator.next();

					/**
					 * Fetching DocumentContentMacro and DocumentRelationshipMacro from objContentSequenceItem.
					 */
					DocumentContentMacro objDocumentContentMacro = objContentSequenceItem.getDocumentContentMacro();
					DocumentRelationshipMacro objDocumentRelationshipMacro = objContentSequenceItem.getDocumentRelationshipMacro();

					/**
					 * Fetching ValueType and ConceptNameCodeSequence from DocumentContentMacro.
					 */
					strValueType = objDocumentContentMacro.getValueType();
					ConceptNameCodeSequence objConceptNameCodeSequence = objDocumentContentMacro.getConceptNameCodeSequence();

					/**
					 *  Getting Item Collection of ConceptNameCodeSequence.
					 *  According to attribute information of DocumentContentMacro of SRDocumentContent this sequence will have single item.
					 */
					ISingleCollection<IItem> objSingleCollectionConceptNameCodeSequenceItem = (ISingleCollection<IItem>)objConceptNameCodeSequence.getValue();

					if(objSingleCollectionConceptNameCodeSequenceItem != null)
					{
						CodeSequenceMacroDependentItem objCodeSequenceMacroDependentItem = (CodeSequenceMacroDependentItem)objSingleCollectionConceptNameCodeSequenceItem.elementAt(0);

						/**
						 * if strValueType is CONTAINER
						 */
						if(EnumValueType.CONTAINER.getValue().equals(strValueType))
						{
							Display(objDicomFileStream, objCodeSequenceMacroDependentItem, objDocumentRelationshipMacro);
							objDicomFileStream.close();
						}
					}
				}
			}
			return true;
		}
		catch(IOException ie)
		{
			if(DicomConfig.createInstance().isLoggingOn() )
			{
				DicomLogger objDicomLogger = DicomLogger.getLogger();
				objDicomLogger.log(ie.getMessage());
			}			
			return false;
		}
	}

	/**
	 * Writes the contents of CONTAINER to the SRDoc by traversing through its ContentSequence.
	 * @param objDicomFileStream Object of DicomFileStream Object of CodeSequenceMacroDependentItem
	 * @param objCodeSequenceMacroDependentItem Object of DocumentRelationshipMacro
	 * @param objDocumentRelationshipMacro
	 * @throws IOException
	 */
	@SuppressWarnings("unchecked")
	private void Display(DicomFileStream objDicomFileStream , CodeSequenceMacroDependentItem objCodeSequenceMacroDependentItem, DocumentRelationshipMacro objDocumentRelationshipMacro)throws IOException
	{
		String objStrToWrite = null;
		byte[] b_array = null;

		if(objCodeSequenceMacroDependentItem.contains(0x0008,0x0104))
		{
//			/**
//			* writting Container heading.
//			*/
//			//System.out.println(objCodeSequenceMacroDependentItem.getValue(0x0008,0x0104).toString() + "\n");
//			objStrToWrite =  "\n\n" + objCodeSequenceMacroDependentItem.getValue(0x0008,0x0104).toString();
//			b_array = objStrToWrite.getBytes();
//			objDicomFileStream.writeChars(b_array);

			/**
			 * Container will have one or more ContentSequence Item.
			 */
			ContentSequence objContentSequenceForInnerSQ = null;
			if(objDocumentRelationshipMacro.contains(0x0040,0xA730))	// ContentSequence.
			{
				IDataElement objDataElement = objDocumentRelationshipMacro.getDataElement(0x0040,0xA730);
				IDicomValue objIDicomValueForInnerSQ = objDataElement.getDicomValue();
				objContentSequenceForInnerSQ = (ContentSequence)objIDicomValueForInnerSQ;

			}
			{	// TRIAL CODE
				//ISingleCollection<IItem> objContentSequenceItemColl = (ISingleCollection<IItem>)objContentSequenceForInnesSQ.getValue();

				{
					//System.out.println(objContentSequenceItemColl.size());
				}
			}
			/**
			 * Iteratoe over ContentSequenceItems of ContentSequence for Container
			 */
			ICollectionIterator<IItem> objCollectionIteratorForInnerItems = objContentSequenceForInnerSQ.iterator();

			ContentSequenceItem objContentSequenceItemForInner=null;

			while(objCollectionIteratorForInnerItems.hasNext())
			{
				/**
				 * Fetching item of a ContentSequence.
				 */
				objContentSequenceItemForInner = (ContentSequenceItem)objCollectionIteratorForInnerItems.next();

				/**
				 * Fetching DocumentContentMacro from ContentSequenceItem to write information like Heading
				 */
				DocumentContentMacro objDocumentContentMacro = objContentSequenceItemForInner.getDocumentContentMacro();
				
				
				int []arrIdentifier = objContentSequenceItemForInner.getReferencedContentItemIdentifier();
				int ilen = arrIdentifier.length;
				for(int i = 0; i<ilen; i++)
				{
					objStrToWrite = "\t";
					b_array = objStrToWrite.getBytes();
					objDicomFileStream.writeChars(b_array);
				}
				
				if(objDocumentContentMacro != null)
				{
					CodeSequenceMacroDependentItem objCodeSequenceMacroDependentItemForInner = null;
					if(objDocumentContentMacro.contains(0x0040, 0xA043))	//ConceptNameCodeSequence
					{
						ConceptNameCodeSequence objConceptNameCodeSequenceForInner = objDocumentContentMacro.getConceptNameCodeSequence();
						ISingleCollection<IItem> objSingleCollectionConceptNameCodeSequenceItemForInner = (ISingleCollection<IItem>)objConceptNameCodeSequenceForInner.getValue();
						objCodeSequenceMacroDependentItemForInner = (CodeSequenceMacroDependentItem)objSingleCollectionConceptNameCodeSequenceItemForInner.elementAt(0);

						if(objCodeSequenceMacroDependentItemForInner.contains(0x0008,0x0104))
						{
							/**
							 * writting Heading for Inner Node(Child Node).
							 */
							//System.out.println(objCodeSequenceMacroDependentItem.getValue(0x0008,0x0104).toString() + " : " + objDocumentContentMacro.getPersonName().toString() + "\n");
							objStrToWrite = objCodeSequenceMacroDependentItemForInner.getValue(0x0008,0x0104).toString() + " : " ;
							b_array = objStrToWrite.getBytes();
							objDicomFileStream.writeChars(b_array);
						}
					}
					if(objDocumentContentMacro.contains(0x0040, 0xA040))	//ValueType
					{
						/**
						 * If valueType is PNAME for InnerItem(Child Node).
						 */
						if(objDocumentContentMacro.getValueType().equalsIgnoreCase(EnumValueType.PNAME.getValue()))
						{
							objStrToWrite = " " + objDocumentContentMacro.getPersonName().toString() + "\n";
							b_array = objStrToWrite.getBytes();
							objDicomFileStream.writeChars(b_array);
						}
						/**
						 * If valueType is TEXT for InnerItem(Child Node).
						 */
						else if(objDocumentContentMacro.getValueType().equalsIgnoreCase(EnumValueType.TEXT.getValue()))
						{
							objStrToWrite = "\n" + objDocumentContentMacro.getTextValue().toString() + "\n";
							b_array = objStrToWrite.getBytes();
							objDicomFileStream.writeChars(b_array);
						}
						else if(objDocumentContentMacro.getValueType().equalsIgnoreCase(EnumValueType.DATETIME.getValue()))
						{
							objStrToWrite = "\n" + objDocumentContentMacro.getDateTime() + "\n";
							b_array = objStrToWrite.getBytes();
							objDicomFileStream.writeChars(b_array);
						}
						else if(objDocumentContentMacro.getValueType().equalsIgnoreCase(EnumValueType.DATE.getValue()))
						{
							objStrToWrite = "\n" + objDocumentContentMacro.getDate() + "\n";
							b_array = objStrToWrite.getBytes();
							objDicomFileStream.writeChars(b_array);
						}
						else if(objDocumentContentMacro.getValueType().equalsIgnoreCase(EnumValueType.TIME.getValue()))
						{
							objStrToWrite = "\n" + objDocumentContentMacro.getTime() + "\n";
							b_array = objStrToWrite.getBytes();
							objDicomFileStream.writeChars(b_array);
						}
						else if(objDocumentContentMacro.getValueType().equalsIgnoreCase(EnumValueType.UIDREF.getValue()))
						{
							objStrToWrite = "\n" + objDocumentContentMacro.getUID() + "\n";
							b_array = objStrToWrite.getBytes();
							objDicomFileStream.writeChars(b_array);
						}
						/**
						 * If valueType is CODE for InnerItem(Child Node).
						 */
						else if(objDocumentContentMacro.getValueType().equalsIgnoreCase(EnumValueType.CODE.getValue()))
						{
							CodeMacro objCodeMacro = objDocumentContentMacro.getCodeMacro();

							ConceptCodeSequence objConceptCodeSequence = objCodeMacro.getConceptCodeSequence();

							ISingleCollection<CodeSequenceMacroDependentItem> objCollection = (ISingleCollection<CodeSequenceMacroDependentItem>)objConceptCodeSequence.getValue();

							ICollectionIterator<CodeSequenceMacroDependentItem> objCollectionIterator = objCollection.iterator();
							while(objCollectionIterator.hasNext())
							{
								CodeSequenceMacroDependentItem objCodeSequenceMacroDependentItem2 = objCollectionIterator.next();
								CodeSequenceMacro objCodeSequenceMacro = objCodeSequenceMacroDependentItem2.getCodeSequenceMacro();
								objStrToWrite = "\n" +objCodeSequenceMacro.getCodeMeaning();
								b_array = objStrToWrite.getBytes();
								objDicomFileStream.writeChars(b_array);
								objStrToWrite = "\n" + " Code Scheme Designator - " +objCodeSequenceMacro.getCodeSchemeDesignator() + "\n";
								b_array = objStrToWrite.getBytes();
								objDicomFileStream.writeChars(b_array);
							}
						}
						else if(objDocumentContentMacro.getValueType().equalsIgnoreCase(EnumValueType.COMPOSITE.getValue()))
						{
							CompositeObjectReferenceMacro objCompositeObjectReferenceMacro = objDocumentContentMacro.getCompositeObjectReferenceMacro();
							ReferencedSOPSequence objReferencedSOPSequence = objCompositeObjectReferenceMacro.getReferencedSOPSequence();
							ISingleCollection<ReferencedSOPSequenceItem> objSingleCollection = (ISingleCollection<ReferencedSOPSequenceItem>)objReferencedSOPSequence.getValue();

							for (ReferencedSOPSequenceItem item : objSingleCollection) 
							{
								objStrToWrite = "\n Referenced SOP Class UID : " + item.getSOPInstanceReferenceMacro().getReferencedSOPClassUID();
								b_array = objStrToWrite.getBytes();
								objDicomFileStream.writeChars(b_array);

								objStrToWrite = "\n Referenced SOP Instance UID : " + item.getSOPInstanceReferenceMacro().getReferencedSOPInstanceUID() + "\n";
								b_array = objStrToWrite.getBytes();
								objDicomFileStream.writeChars(b_array);
							}
						}
						else if(objDocumentContentMacro.getValueType().equalsIgnoreCase(EnumValueType.NUM.getValue()))
						{
							NumericMeasurementMacro objNumericMeasurementMacro = objDocumentContentMacro.getNumericMeasurementMacro();
							MeasuredValueSequence objMeasuredValueSequence = objNumericMeasurementMacro.getMeasuredValueSequence();
							ISingleCollection<MeasuredValueSequenceItem> objSingleCollection = (ISingleCollection<MeasuredValueSequenceItem>)objMeasuredValueSequence.getValue();

							for (MeasuredValueSequenceItem item : objSingleCollection) 
							{
								String [] arrStrToWrite = item.getNumericValue();
								int ilength = arrStrToWrite.length;



								//Retrieves MeasurementUnitsCodeSequence
								MeasurementUnitsCodeSequence objMeasurementUnitsCodeSequence = item.getMeasurementUnitsCodeSequence();
								ISingleCollection<CodeSequenceMacroDependentItem> objCollection = (ISingleCollection<CodeSequenceMacroDependentItem>)objMeasurementUnitsCodeSequence.getValue();

								for(CodeSequenceMacroDependentItem itemCSMDI : objCollection)
								{
									CodeSequenceMacro objCodeSequenceMacro = itemCSMDI.getCodeSequenceMacro();

//									objStrToWrite = "\n" + objCodeSequenceMacro.getCodeMeaning();
//									b_array = objStrToWrite.getBytes();
//									objDicomFileStream.writeChars(b_array);

//									objStrToWrite = "\n" + objCodeSequenceMacro.getCodeValue();
//									b_array = objStrToWrite.getBytes();
//									objDicomFileStream.writeChars(b_array);

									for(int i=0; i < ilength ;i++)
									{
										objStrToWrite = "\n" + arrStrToWrite[i] + objCodeSequenceMacro.getCodeMeaning() + "\n";
										b_array = objStrToWrite.getBytes();
										objDicomFileStream.writeChars(b_array);
									}
								}

								//Retrieves Numeric Value Qualifier Code Sequence
								NumericValueQualifierCodeSequence objNumericValueQualifierCodeSequence = objNumericMeasurementMacro.getNumericValueQualifierCodeSequence();
								ISingleCollection<CodeSequenceMacroDependentItem> objCollection2 = (ISingleCollection<CodeSequenceMacroDependentItem>)objNumericValueQualifierCodeSequence.getValue();

								for(CodeSequenceMacroDependentItem itemCSMDI : objCollection2)
								{
									CodeSequenceMacro objCodeSequenceMacro = itemCSMDI.getCodeSequenceMacro();

									objStrToWrite = "\n" + objCodeSequenceMacro.getCodeMeaning();
									b_array = objStrToWrite.getBytes();
									objDicomFileStream.writeChars(b_array);

									objStrToWrite = "\n" + objCodeSequenceMacro.getCodeValue() + "\n";
									b_array = objStrToWrite.getBytes();
									objDicomFileStream.writeChars(b_array);
								}
							}
						}
						else if(objDocumentContentMacro.getValueType().equalsIgnoreCase(EnumValueType.WAVEFORM.getValue()))
						{
							WaveformReferenceMacro objWaveformReferenceMacro = objDocumentContentMacro.getWaveformReferenceMacro();
							CompositeObjectReferenceMacro objCompositeObjectReferenceMacro = objWaveformReferenceMacro.getCompositeObjectReferenceMacro();

							ReferencedSOPSequence objReferencedSOPSequence = objCompositeObjectReferenceMacro.getReferencedSOPSequence();
							ISingleCollection<ReferencedSOPSequenceItem> objSingleCollection = (ISingleCollection<ReferencedSOPSequenceItem>)objReferencedSOPSequence.getValue();

							for (ReferencedSOPSequenceItem item : objSingleCollection) 
							{
								objStrToWrite = "\n Referenced SOP Class UID - " + item.getSOPInstanceReferenceMacro().getReferencedSOPClassUID();
								b_array = objStrToWrite.getBytes();
								objDicomFileStream.writeChars(b_array);

								objStrToWrite = "\n Referenced SOP Instance UID - " + item.getSOPInstanceReferenceMacro().getReferencedSOPInstanceUID();
								b_array = objStrToWrite.getBytes();
								objDicomFileStream.writeChars(b_array);
							}

							// Retrieveing value for Referenced Waveform Channels
							short [] sharrWRMC = objWaveformReferenceMacro.getReferencedWaveformChannels();
							int ilenght = sharrWRMC.length;
							String strVal = "\n Referenced Waveform Channels - ";
							b_array = strVal.getBytes();
							objDicomFileStream.writeChars(b_array);
							for(int i=0; i < ilenght; i++)
							{
								short shValue = sharrWRMC[i];
								strVal = " " + shValue;

								if(i < ilenght -1)
									strVal = strVal + ",\t" ;
								else
									strVal = strVal + "." + "\n";

								b_array = strVal.getBytes();
								objDicomFileStream.writeChars(b_array);
								//objDicomFileStream.writeShort(shValue);
							}
						}
						else if(objDocumentContentMacro.getValueType().equalsIgnoreCase(EnumValueType.SCOORD.getValue()))
						{
							SpatialCoordinatesMacro objSpatialCoordinatesMacro = objDocumentContentMacro.getSpatialCoordinatesMacro();
							
							float []arrflGraphicData = objSpatialCoordinatesMacro.getGraphicData();
							
							int ilenght = arrflGraphicData.length;
							String strVal = "\n Graphic Data - ";
							b_array = strVal.getBytes();
							objDicomFileStream.writeChars(b_array);
							
							for(int i=0; i < ilenght; i++)
							{
								float fValue = arrflGraphicData[i];
								strVal = " " + fValue;

								if(i < ilenght -1)
									strVal = strVal + ",\t" ;
								else
									strVal = strVal + "." ;

								b_array = strVal.getBytes();
								objDicomFileStream.writeChars(b_array);
								//objDicomFileStream.writeShort(shValue);
							}
							
							strVal = "\n Graphic Type - " + objSpatialCoordinatesMacro.getGraphicType() + "\n";
							b_array = strVal.getBytes();
							objDicomFileStream.writeChars(b_array);
						}
						else if(objDocumentContentMacro.getValueType().equalsIgnoreCase(EnumValueType.TCOORD.getValue()))
						{
							TemporalCoordinatesMacro objTemporalCoordinatesMacro = objDocumentContentMacro.getTemporalCoordinatesMacro();
							
							//Get Referenced Date Time 
							String []arr = objTemporalCoordinatesMacro.getReferencedDatetime();
							
							int ilenght = arr.length;
							String strVal = "\n Referenced Datetime - ";
							b_array = strVal.getBytes();
							objDicomFileStream.writeChars(b_array);
							
							for(int i=0; i < ilenght; i++)
							{
								String fValue = arr[i];
								strVal = " " + fValue;

								if(i < ilenght -1)
									strVal = strVal + ",\t" ;
								else
									strVal = strVal + ".";

								b_array = strVal.getBytes();
								objDicomFileStream.writeChars(b_array);
							}
							
							//Get Referenced Sample Position.
							int[] larr = objTemporalCoordinatesMacro.getReferencedSamplePositions();
							
							ilenght = arr.length;
							strVal = "\n Referenced Sample Positions - ";
							b_array = strVal.getBytes();
							objDicomFileStream.writeChars(b_array);
							
							for(int i=0; i < ilenght; i++)
							{
								int iValue = larr[i];
								strVal = " " + iValue;

								if(i < ilenght -1)
									strVal = strVal + ",\t" ;
								else
									strVal = strVal + ".";

								b_array = strVal.getBytes();
								objDicomFileStream.writeChars(b_array);
							}
							
							
							//Get Referenced Date Time 
							arr = objTemporalCoordinatesMacro.getReferencedTimeOffsets();
							
							ilenght = arr.length;
							strVal = "\n Referenced Time Offset - ";
							b_array = strVal.getBytes();
							objDicomFileStream.writeChars(b_array);
							
							for(int i=0; i < ilenght; i++)
							{
								String fValue = arr[i];
								strVal = " " + fValue;

								if(i < ilenght -1)
									strVal = strVal + ",\t" ;
								else
									strVal = strVal + ".";

								b_array = strVal.getBytes();
								objDicomFileStream.writeChars(b_array);
							}
							
							//Get Temporal Range Type
							strVal = "\n Temporal Range Type - " + objTemporalCoordinatesMacro.getTemporalRangeType();
							b_array = strVal.getBytes();
							objDicomFileStream.writeChars(b_array);
						}
						else if(objDocumentContentMacro.getValueType().equalsIgnoreCase(EnumValueType.IMAGE.getValue()))
						{
							ImageReferenceMacro objImageReferenceMacro = objDocumentContentMacro.getImageReferenceMacro();
							
							//ReferencedSOPSequence in CompositeObjectReferenceMacro
							CompositeObjectReferenceMacro objCompositeObjectReferenceMacro = objImageReferenceMacro.getCompositeObjectReferenceMacro();
							ReferencedSOPSequence objReferencedSOPSequence = objCompositeObjectReferenceMacro.getReferencedSOPSequence();
							ISingleCollection<ReferencedSOPSequenceItem> objSingleCollection = (ISingleCollection<ReferencedSOPSequenceItem>)objReferencedSOPSequence.getValue();

							for (ReferencedSOPSequenceItem item : objSingleCollection) 
							{
								objStrToWrite = "\n Referenced SOP Class UID - " + item.getSOPInstanceReferenceMacro().getReferencedSOPClassUID();
								b_array = objStrToWrite.getBytes();
								objDicomFileStream.writeChars(b_array);

								objStrToWrite = "\n Referenced SOP Instance UID - " + item.getSOPInstanceReferenceMacro().getReferencedSOPInstanceUID();
								b_array = objStrToWrite.getBytes();
								objDicomFileStream.writeChars(b_array);
							}

							// Referenced Fame Number
							String [] strarrRefFramNo = objImageReferenceMacro.getReferencedFrameNumber();
							int ilenght = strarrRefFramNo.length;
							String strVal = "\n Referenced Frame Number - ";
							b_array = strVal.getBytes();
							objDicomFileStream.writeChars(b_array);

							for(int i=0; i < ilenght; i++)
							{
								String fValue = strarrRefFramNo[i];
								strVal = " " + fValue;

								if(i < ilenght -1)
									strVal = strVal + ",\t" ;
								else
									strVal = strVal + ".";

								b_array = strVal.getBytes();
								objDicomFileStream.writeChars(b_array);
							}
							
							//ReferencedSOPSequence in Image Referenced Macro
							ReferencedSOPSequence objReferencedSOPSequence1 = objImageReferenceMacro.getReferencedSOPSequence();
							ISingleCollection<ReferencedSOPSequenceItem> objSingleCollection1 = (ISingleCollection<ReferencedSOPSequenceItem>)objReferencedSOPSequence1.getValue();

							for (ReferencedSOPSequenceItem item : objSingleCollection1) 
							{
								objStrToWrite = "\n Referenced SOP Class UID - " + item.getSOPInstanceReferenceMacro().getReferencedSOPClassUID();
								b_array = objStrToWrite.getBytes();
								objDicomFileStream.writeChars(b_array);

								objStrToWrite = "\n Referenced SOP Instance UID - " + item.getSOPInstanceReferenceMacro().getReferencedSOPInstanceUID();
								b_array = objStrToWrite.getBytes();
								objDicomFileStream.writeChars(b_array);
							}
							
							//Get IconImageSequence
							IconImageSequence objIconImageSequence = objImageReferenceMacro.getIconImageSequence();
							ISingleCollection<IconImageSequenceItem> objcollIIS = (SingleCollection<IconImageSequenceItem>)objIconImageSequence.getValue();
							for(IconImageSequenceItem item : objcollIIS)
							{
								ImagePixelMacro objImagePixelMacro = item.getImagePixelMacro();
								short shBitsAllocated = objImagePixelMacro.getBitsAllocated();
								objStrToWrite = "\n Bits Allocated - " + shBitsAllocated;
								b_array = objStrToWrite.getBytes();
								objDicomFileStream.writeChars(b_array);
							}
						}
						/**
						 * If valueType is CONTAINER for InnerItem(Child Node).
						 */
//						else if(objDocumentContentMacro.getValueType().equalsIgnoreCase("CONTAINER"))
//						{
//						/**
//						* writting Container heading.
//						*/
//						ConceptNameCodeSequence objConceptNameCodeSequenceForInner = objDocumentContentMacro.getConceptNameCodeSequence();
//						ISingleCollection<IItem> objSingleCollectionConceptNameCodeSequenceItemForInner = (ISingleCollection<IItem>)objConceptNameCodeSequenceForInner.getValue();
//						objCodeSequenceMacroDependentItemForInner = (CodeSequenceMacroDependentItem)objSingleCollectionConceptNameCodeSequenceItemForInner.elementAt(0);

//						if(objCodeSequenceMacroDependentItemForInner.contains(0x0008,0x0104))
//						{
//						/**
//						* writting Heading for Node.
//						*/
//						//System.out.println(objCodeSequenceMacroDependentItem.getValue(0x0008,0x0104).toString() + " : " + objDocumentContentMacro.getPersonName().toString() + "\n");
//						objStrToWrite = "\n\n" + objCodeSequenceMacroDependentItemForInner.getValue(0x0008,0x0104).toString() + " : " ;
//						b_array = objStrToWrite.getBytes();
//						objDicomFileStream.writeChars(b_array);
//						}
//						}

						/**
						 * This part of code retrieves the Document Relationship macro, if the Content Sequence present in 
						 * Doc Relationshipm Macro for this ContentSequenceItem has another ContentSequence Item in it, 
						 * then it will again call Display method to serialize that Item too.
						 * For eg. If CODE type of node itself contains another say, PNAME type of node, then it will serialize
						 * that PNAME type of npde.
						 */
						DocumentRelationshipMacro objDocumentRelationshipMacroToGetInnerContentSQ = objContentSequenceItemForInner.getDocumentRelationshipMacro();
						Display(objDicomFileStream, objCodeSequenceMacroDependentItemForInner, objDocumentRelationshipMacroToGetInnerContentSQ);
					}
				}
			}
		}
	}
	
	
	/**
	 * This will add SnomedCT CODE in already created 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 strSNOMEDCTID SNOMED CT for CodeSequenceMacro inside CodeMacro
	 * @return object of ContentSequenceItem.
	 */
	public ContentSequenceItem createCodeNode(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,String strCodeValueForCode, String strCodeSchemeDesignatorForCode,String strCodingSchemeVersionForCode,String strCodeMeaningForCode,String strSNOMEDCTID)
	{
		//objContentSequenceItem1 holds the retrieved values from overloaded function createCodeNode().
		ContentSequenceItem objContentSequenceItem1= createCodeNode(arrPosition,strCodeMeaning,strCodeValue,strCodeSchemeDesignator,strCodeValueForCode,strCodeSchemeDesignatorForCode,strCodingSchemeVersionForCode,strCodeMeaningForCode);
		
		DocumentContentMacro objDocumentContentMacro = objContentSequenceItem1.getDocumentContentMacro();
		CodeMacro objCodeMacro = objDocumentContentMacro.getCodeMacro();
		ConceptCodeSequence objConceptCodeSequence = objCodeMacro.getConceptCodeSequence();
		
		// create objSequenceMacroDependentItem to set only single value in code node other values assigned by overloaded function.
		//ICollectionIterator<IItem> itr = objConceptCodeSequence.iterator();
		for (IItem iItem : objConceptCodeSequence) {
			
			CodeSequenceMacroDependentItem objSequenceMacroDependentItem = (CodeSequenceMacroDependentItem)iItem;
			CodeSequenceMacro objSequenceMacro = objSequenceMacroDependentItem.getCodeSequenceMacro();
			
			//Set only SNOMED CT Value in Pre-created item.
			objSequenceMacro.setSNOMEDCTID(strSNOMEDCTID); 
		}
			return objContentSequenceItem1;
	}
	
	/**
	 * This will add SnomedCT CODE in already created Num 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 strSNOMEDCTID SNOMED CT for CodeSequenceMacro inside CodeMacro
	 * @return object of ContentSequenceItem.
	 */
	public 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,String strSNOMEDCTID)
	{
		//objContentSequenceItem1 holds the retrieved values from overloaded function createNumNode().
		ContentSequenceItem objContentSequenceItem1= createNumNode(arrPosition,strCodeMeaning,strCodeValue,strCodeSchemeDesignator,arrNumericValue ,strCodeValueForUnitSQ,strCodeSchemeDesignatorForUnitSQ,strCodingSchemeVersionForUnitSQ,strCodeMeaningForUnitSQ,strCMForNumValQuaCodeSQ,strCVForNumValQuaCodeSQ,strCSDForNumValQuaCodeSQ,strCSVForNumValQuaCodeSQ);
		
		DocumentContentMacro objDocumentContentMacro = objContentSequenceItem1.getDocumentContentMacro();
		CodeMacro objCodeMacro = objDocumentContentMacro.getCodeMacro();
		ConceptCodeSequence objConceptCodeSequence = objCodeMacro.getConceptCodeSequence();
		
		// create objSequenceMacroDependentItem to set only single value in code node other values assigned by overloaded function.
		for (IItem iItem : objConceptCodeSequence) {
			
			CodeSequenceMacroDependentItem objSequenceMacroDependentItem = (CodeSequenceMacroDependentItem)iItem;
			CodeSequenceMacro objSequenceMacro = objSequenceMacroDependentItem.getCodeSequenceMacro();
			
			//Set only SNOMED CT Value in Pre-created item.
			objSequenceMacro.setSNOMEDCTID(strSNOMEDCTID); 
		}
		
		return objContentSequenceItem1;
		
	}
	/**
	 * This will add SnomedCT CODE in already created node with specified attributes.
	 * @param arrPosition position at which the node will get added in the tree.
	 * @param strCodeMeaning Heading of Node of type Pname
	 * @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 strSNOMEDCTID SNOMED CT for CodeSequenceMacro inside CodeMacro
	 * @param strValue 
	 * @return object of ContentSequenceItem.
	 */
	public ContentSequenceItem createPnameNode(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,String strCodeValueForCode, String strCodeSchemeDesignatorForCode,String strCodingSchemeVersionForCode,String strCodeMeaningForCode,String strSNOMEDCTID, String strValue)
	{
		//objContentSequenceItem1 holds the retrieved values from overloaded function createPnameNode().
		ContentSequenceItem objContentSequenceItem1= createPnameNode(arrPosition, strCodeMeaning, strCodeValue, strCodeSchemeDesignator, strValue);
		
		DocumentContentMacro objDocumentContentMacro = objContentSequenceItem1.getDocumentContentMacro();
		CodeMacro objCodeMacro = objDocumentContentMacro.getCodeMacro();
		ConceptCodeSequence objConceptCodeSequence = objCodeMacro.getConceptCodeSequence();
		
		// create objSequenceMacroDependentItem to set only single value in code node other values assigned by overloaded function.
		//ICollectionIterator<IItem> itr = objConceptCodeSequence.iterator();
		for (IItem iItem : objConceptCodeSequence) {
			
			CodeSequenceMacroDependentItem objSequenceMacroDependentItem = (CodeSequenceMacroDependentItem)iItem;
			CodeSequenceMacro objSequenceMacro = objSequenceMacroDependentItem.getCodeSequenceMacro();
			
			//Set only SNOMED CT Value in Pre-created item.
			objSequenceMacro.setSNOMEDCTID(strSNOMEDCTID); 
		}
			return objContentSequenceItem1;
	}
	/**
	 * This will add SnomedCT CODE in already created node with specified attributes.
	 * @param arrPosition position at which the node will get 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 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 strSNOMEDCTID SNOMED CT for CodeSequenceMacro inside CodeMacro
	 * @param enumGraphicType 
	 * @param strValue 
	 * @return object of ContentSequenceItem.
	 */
	public ContentSequenceItem createSCOORDNode(int[] arrPosition,String strCodeMeaning, String strCodeValue, String strCodeSchemeDesignator,float [] arrFlGraphicData,EnumGraphicType enumGraphicTypeString, String strSNOMEDCTID, EnumGraphicType enumGraphicType)
	{
		//objContentSequenceItem1 holds the retrieved values from overloaded function createSCOORDNode().
		ContentSequenceItem objContentSequenceItem1= createSCOORDNode(arrPosition, strCodeMeaning, strCodeValue, strCodeSchemeDesignator, arrFlGraphicData, enumGraphicType);
		
		DocumentContentMacro objDocumentContentMacro = objContentSequenceItem1.getDocumentContentMacro();
		CodeMacro objCodeMacro = objDocumentContentMacro.getCodeMacro();
		ConceptCodeSequence objConceptCodeSequence = objCodeMacro.getConceptCodeSequence();
		
		// create objSequenceMacroDependentItem to set only single value in code node other values assigned by overloaded function.
		//ICollectionIterator<IItem> itr = objConceptCodeSequence.iterator();
		for (IItem iItem : objConceptCodeSequence) {
			
			CodeSequenceMacroDependentItem objSequenceMacroDependentItem = (CodeSequenceMacroDependentItem)iItem;
			CodeSequenceMacro objSequenceMacro = objSequenceMacroDependentItem.getCodeSequenceMacro();
			
			//Set only SNOMED CT Value in Pre-created item.
			objSequenceMacro.setSNOMEDCTID(strSNOMEDCTID); 
		}
			return objContentSequenceItem1;
	}

}