/*******************************************************************************
 *  Copyright 2017-2018 Centre for Development of Advanced Computing(C-DAC), Pune
 *  
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *  
 *   http://www.apache.org/licenses/LICENSE-2.0
 *  
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/
package cdac.medinfo.sdk.dcm30_04.services.print.printsourceimpl;

import java.io.IOException;
import java.sql.SQLException;
import java.util.Date;
import java.util.Locale;

import cdac.medinfo.sdk.dcm30_04.baselibs.AnnotationContentSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.AnnotationContentSequenceItem;
import cdac.medinfo.sdk.dcm30_04.baselibs.BasicGrayscaleImageSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.BasicGrayscaleImageSequenceItem;
import cdac.medinfo.sdk.dcm30_04.baselibs.DataSet;
import cdac.medinfo.sdk.dcm30_04.baselibs.DicomV3Factory;
import cdac.medinfo.sdk.dcm30_04.baselibs.FilmBoxContentSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.FilmBoxContentSequenceItem;
import cdac.medinfo.sdk.dcm30_04.baselibs.ImageBoxContentSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ImageBoxContentSequenceItem;
import cdac.medinfo.sdk.dcm30_04.baselibs.ImageOverlayBoxContentSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ImageOverlayBoxContentSequenceItem;
import cdac.medinfo.sdk.dcm30_04.baselibs.ImplicitDE;
import cdac.medinfo.sdk.dcm30_04.baselibs.OriginalImageSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.OriginalImageSequenceItem;
import cdac.medinfo.sdk.dcm30_04.baselibs.OverlayPixelDataSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.OverlayPixelDataSequenceItem;
import cdac.medinfo.sdk.dcm30_04.baselibs.PresentationLUTContentSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.PresentationLUTContentSequenceItem;
import cdac.medinfo.sdk.dcm30_04.baselibs.PresentationLUTSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.PresentationLUTSequenceItem;
import cdac.medinfo.sdk.dcm30_04.baselibs.PrintJobDescriptionSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.PrintJobDescriptionSequenceItem;
import cdac.medinfo.sdk.dcm30_04.baselibs.ProposedStudySequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ProposedStudySequenceItem;
import cdac.medinfo.sdk.dcm30_04.baselibs.ReferencedBasicAnnotationBoxSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ReferencedImageBoxSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ReferencedImageOverlayBoxSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ReferencedImageSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ReferencedImageSequenceItem;
import cdac.medinfo.sdk.dcm30_04.baselibs.ReferencedPresentationLUTSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ReferencedPrintJobSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ReferencedPrintJobSequenceItem;
import cdac.medinfo.sdk.dcm30_04.baselibs.ReferencedSequenceDependentItem;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataElement;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataSet;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataTypeSQ;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IItem;
import cdac.medinfo.sdk.dcm30_04.dicommodel.hardcopy.HardcopyGrayscaleImageIOD;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.AnnotationListModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.BasicAnnotationPresentationModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.BasicFilmSessionPresentationModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.BasicPrintImageOverlayBoxModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.FilmBoxModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.GeneralQueueModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.GeneralSeriesModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.GeneralStudyModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.HardcopyGrayscaleImageModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.ImageBoxListModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.ImageOverlayBoxListModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.PatientModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.PatientStudyModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.PresentationLUTListModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.PresentationLUTModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.PrintQueueModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.SOPCommonModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.print.PrintQueueIOD;
import cdac.medinfo.sdk.dcm30_04.dicommodel.print.StoredPrintIOD;
import cdac.medinfo.sdk.dcm30_04.enums.EnumBitsAllocated;
import cdac.medinfo.sdk.dcm30_04.enums.EnumBitsStored;
import cdac.medinfo.sdk.dcm30_04.enums.EnumCommandField;
import cdac.medinfo.sdk.dcm30_04.enums.EnumExecutionStatus;
import cdac.medinfo.sdk.dcm30_04.enums.EnumExecutionStatusInfo;
import cdac.medinfo.sdk.dcm30_04.enums.EnumHighBit;
import cdac.medinfo.sdk.dcm30_04.enums.EnumPhotometricInterpretation;
import cdac.medinfo.sdk.dcm30_04.enums.EnumPixelDataVRType;
import cdac.medinfo.sdk.dcm30_04.enums.EnumPixelRepresentation;
import cdac.medinfo.sdk.dcm30_04.enums.EnumPresentationLUTShape;
import cdac.medinfo.sdk.dcm30_04.enums.EnumQueueStatus;
import cdac.medinfo.sdk.dcm30_04.enums.EnumSOPClassUIDs;
import cdac.medinfo.sdk.dcm30_04.enums.EnumSamplesPerPixel;
import cdac.medinfo.sdk.dcm30_04.services.dicomnetcommons.EnumImplOpsStatus;
import cdac.medinfo.sdk.dcm30_04.services.dicomnetcommons.SourceException;
import cdac.medinfo.sdk.dcm30_04.services.dimsecommons.DicomMessage;
import cdac.medinfo.sdk.dcm30_04.services.print.dbhelper.Print_DBAgent;
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.IPairedCollection;
import cdac.medinfo.sdk.dcm30_04.utils.ISingleCollection;
import cdac.medinfo.sdk.dcm30_04.utils.PairedCollection;
import cdac.medinfo.sdk.dcm30_04.utils.ResourceBundleWrapper;
import cdac.medinfo.sdk.dcm30_04.utils.SingleCollection;
import cdac.medinfo.sdk.dcm30_04.utils.StandardMethods;

/**
 * This class process N-Action Request for Basic Flim Box IOD.
 */
public class BasicFilmBoxImpl 
{
	private IPairedCollection<String,IDataSet> objBasicAnnotatiobBoxCollection = new PairedCollection<String,IDataSet>();
	private IPairedCollection<String,IDataSet> objPresentationLUTCollection = new PairedCollection<String,IDataSet>();
	private IPairedCollection<String,IDataSet> objImageBoxCollection = new PairedCollection<String,IDataSet>();
	private IPairedCollection<String,IDataSet> objBasicImageOverlayBoxSequence = new PairedCollection<String,IDataSet>();
	private ISingleCollection<HardcopyGrayscaleImageModule> objHardCopyGrayscaleImageModuleCol = null;
	private String strSOPClassUID;
	private final String strPrintQueueSOPInstanceUID = DicomConstants.DCM_PRINT_QUEUE_MANAGEMENT_SOP_INSTANCE;
	private String strPrintJOBID = null;
	private IDataSet objBasicFilmSessionDataSet = null;
	private String strSOPInstanceUIDForPrintJob = null;

	/**
	 * This is default Constructor for BasicFilmBoxImpl.
	 */
	public BasicFilmBoxImpl() {
		super();
	}
	
	@SuppressWarnings("unchecked")
	short retrieveBasicFilmBoxSOPInstance(Print_DBAgent objPrintDBAgent, DicomMessage objDicomMessage, ISingleCollection<IDataSet> objDataSetColl, String strValue) throws IOException, SQLException
	{
		EnumCommandField enumRequestType = objDicomMessage.getCommandType();
		switch(enumRequestType)
		{
		case N_ACTION_RQ :
		{

			String[] strArrBasicFilmSessionSOPInstance = objPrintDBAgent.getAllSOPInstance(EnumSOPClassUIDs.BASICFILMSESSIONIOD,EnumSOPClassUIDs.BASICFILMBOXIOD,strValue);
			if(strArrBasicFilmSessionSOPInstance != null && strArrBasicFilmSessionSOPInstance.length != 0)
			{
				objBasicFilmSessionDataSet = objPrintDBAgent.retrieveSOPInstance(EnumSOPClassUIDs.BASICFILMSESSIONIOD,null,strArrBasicFilmSessionSOPInstance[0]);
				if(DicomConfig.createInstance().isLoggingOn())
				{
					DicomLogger objDicomLogger = DicomLogger.getLogger();
					objDicomLogger.log(ResourceBundleWrapper.getValue("status", "Print.RetrievingBasicFilmSessionIOD", new Locale(DicomConfig.createInstance().getLocale())) + strArrBasicFilmSessionSOPInstance[0]);
				}
			}
			IDataSet objIDataSetBasicFilmBox = objPrintDBAgent.retrieveSOPInstance(EnumSOPClassUIDs.BASICFILMBOXIOD,null,strValue);
			if(objIDataSetBasicFilmBox != null)
			{
				if(DicomConfig.createInstance().isLoggingOn())
				{
					DicomLogger objDicomLogger = DicomLogger.getLogger();
					objDicomLogger.log(ResourceBundleWrapper.getValue("status", "Print.RetrievingBasicFilmBoxIOD", new Locale(DicomConfig.createInstance().getLocale())) +strValue);
				}
				IDataElement objIDataElement = objIDataSetBasicFilmBox.getDataForTag(0x2010, 0x0520);
				if(objIDataElement != null && objIDataElement.getDicomValue() != null)
				{
					ReferencedBasicAnnotationBoxSequence objReferencedBasicAnnotationBoxSequence = (ReferencedBasicAnnotationBoxSequence)objIDataElement.getDicomValue();
					ISingleCollection<ReferencedSequenceDependentItem> objReferenceSequenceDependentItemCol=(ISingleCollection<ReferencedSequenceDependentItem>) objReferencedBasicAnnotationBoxSequence.getValue();
					for(ReferencedSequenceDependentItem objReferencedSequenceDependentItem : objReferenceSequenceDependentItemCol)
					{
						String strReferencedSOPInstanceUID = objReferencedSequenceDependentItem.getReferencedSOPInstanceUID();
						IDataSet objBasicAnnotationDataSet = objPrintDBAgent.retrieveSOPInstance(EnumSOPClassUIDs.BASICANNOTATIONBOX, null, strReferencedSOPInstanceUID);
						if(objBasicAnnotationDataSet != null)
						{
							if(DicomConfig.createInstance().isLoggingOn())
							{
								DicomLogger objDicomLogger = DicomLogger.getLogger();
								objDicomLogger.log(ResourceBundleWrapper.getValue("status", "Print.RetrievingBasicAnnotationBox", new Locale(DicomConfig.createInstance().getLocale())) +strReferencedSOPInstanceUID);
							}
							objBasicAnnotatiobBoxCollection.put(strReferencedSOPInstanceUID,objBasicAnnotationDataSet);
						}
					}
				}

				if(objIDataSetBasicFilmBox.getDataForTag(0x2050, 0x0500) != null && objIDataSetBasicFilmBox.getDataForTag(0x2050, 0x0500).getDicomValue() != null)
				{
					ReferencedPresentationLUTSequence objReferencedPresentationLUTSequence = (ReferencedPresentationLUTSequence)objIDataSetBasicFilmBox.getDataForTag(0x2050, 0x0500).getDicomValue();
					ISingleCollection<ReferencedSequenceDependentItem> objobjReferencedPresentationLUTSequenceColl = (ISingleCollection<ReferencedSequenceDependentItem>)objReferencedPresentationLUTSequence.getValue();
					for(ReferencedSequenceDependentItem objReferencedSequenceDependentItem: objobjReferencedPresentationLUTSequenceColl)
					{
						String strReferencedSOPInstanceUID = objReferencedSequenceDependentItem.getReferencedSOPInstanceUID();
						IDataSet objPresentationLUTDataSet = objPrintDBAgent.retrieveSOPInstance(EnumSOPClassUIDs.PRESENTATIONLUTIOD, null, strReferencedSOPInstanceUID);
						if(objPresentationLUTDataSet != null)
						{
							if(DicomConfig.createInstance().isLoggingOn())
							{
								DicomLogger objDicomLogger = DicomLogger.getLogger();
								objDicomLogger.log(ResourceBundleWrapper.getValue("status", "Print.RetrievingPresentationLUT", new Locale(DicomConfig.createInstance().getLocale())) + strReferencedSOPInstanceUID);
							}
							objPresentationLUTCollection.put(strReferencedSOPInstanceUID,objPresentationLUTDataSet);
						}
					}
				}

				if(objIDataSetBasicFilmBox.getDataForTag(0x2010, 0x0510) != null && objIDataSetBasicFilmBox.getDataForTag(0x2010, 0x0510).getDicomValue() != null)
				{
					ReferencedImageBoxSequence objReferencedImageBoxSequence = (ReferencedImageBoxSequence)objIDataSetBasicFilmBox.getDataForTag(0x2010, 0x0510).getDicomValue();
					ISingleCollection<ReferencedSequenceDependentItem> objobjReferencedImageBoxSequenceColl = (ISingleCollection<ReferencedSequenceDependentItem>)objReferencedImageBoxSequence.getValue();
					for(ReferencedSequenceDependentItem objReferencedSequenceDependentItem: objobjReferencedImageBoxSequenceColl)
					{
						strSOPClassUID = objReferencedSequenceDependentItem.getReferencedSOPClassUID();
						String strReferencedSOPInstanceUID = objReferencedSequenceDependentItem.getReferencedSOPInstanceUID();
						IDataSet objBasicImageBoxDataSet = objPrintDBAgent.retrieveSOPInstance(EnumSOPClassUIDs.BASICGRAYSCALEIMAGEBOX, null, strReferencedSOPInstanceUID);
						if(objBasicImageBoxDataSet != null)
						{
							if(DicomConfig.createInstance().isLoggingOn())
							{
								DicomLogger objDicomLogger = DicomLogger.getLogger();
								objDicomLogger.log(ResourceBundleWrapper.getValue("status", "Print.RetrievingBasicGrayScaleImageBox", new Locale(DicomConfig.createInstance().getLocale())) + strReferencedSOPInstanceUID);
							}
							if(objBasicImageBoxDataSet.getDataForTag(0x2050, 0x0500) != null && objBasicImageBoxDataSet.getDataForTag(0x2050, 0x0500).getDicomValue() != null)
							{
								ReferencedPresentationLUTSequence objReferencedPresentationLUTSequence = (ReferencedPresentationLUTSequence)objBasicImageBoxDataSet.getDataForTag(0x2050, 0x0500).getDicomValue();
								ISingleCollection<ReferencedSequenceDependentItem> objobjReferencedPresentationLUTSequenceColl = (ISingleCollection<ReferencedSequenceDependentItem>)objReferencedPresentationLUTSequence.getValue();
								for(ReferencedSequenceDependentItem objReferencedSequenceDependentItemForPresentaiton: objobjReferencedPresentationLUTSequenceColl)
								{
									strReferencedSOPInstanceUID = objReferencedSequenceDependentItemForPresentaiton.getReferencedSOPInstanceUID();
									IDataSet objPresentationLUTDataSet = objPrintDBAgent.retrieveSOPInstance(EnumSOPClassUIDs.PRESENTATIONLUTIOD, null, strReferencedSOPInstanceUID);

									if(objPresentationLUTDataSet != null)
									{
										if(DicomConfig.createInstance().isLoggingOn())
										{
											DicomLogger objDicomLogger = DicomLogger.getLogger();
											objDicomLogger.log(ResourceBundleWrapper.getValue("status", "Print.RetrievingPresentationLUT", new Locale(DicomConfig.createInstance().getLocale())) + strReferencedSOPInstanceUID);
										}
										objPresentationLUTCollection.put(strReferencedSOPInstanceUID,objPresentationLUTDataSet);
									}
								}
							}

							if(objBasicImageBoxDataSet.getDataForTag(0x2020, 0x0130) != null && objBasicImageBoxDataSet.getDataForTag(0x2020, 0x0130).getDicomValue() != null)
							{
								ReferencedImageOverlayBoxSequence objReferencedImageOverlayBoxSequence = (ReferencedImageOverlayBoxSequence)objBasicImageBoxDataSet.getDataForTag(0x2020, 0x0130).getDicomValue();
								ISingleCollection<ReferencedSequenceDependentItem> objReferencedImageOverlayBoxSequenceColl = (ISingleCollection<ReferencedSequenceDependentItem>)objReferencedImageOverlayBoxSequence.getValue();
								for(ReferencedSequenceDependentItem objReferencedSequenceDependentItemForOvelay: objReferencedImageOverlayBoxSequenceColl)
								{
									strReferencedSOPInstanceUID = objReferencedSequenceDependentItemForOvelay.getReferencedSOPInstanceUID();
									IDataSet objPresentationLUTDataSet = objPrintDBAgent.retrieveSOPInstance(EnumSOPClassUIDs.BASICPRINTIMAGEOVERLAYBOXIOD, null, strReferencedSOPInstanceUID);
									if(objPresentationLUTDataSet != null)
									{
										if(DicomConfig.createInstance().isLoggingOn())
										{
											DicomLogger objDicomLogger = DicomLogger.getLogger();
											objDicomLogger.log(ResourceBundleWrapper.getValue("status", "Print.RetrievingBasicPrintImageOverlayBox", new Locale(DicomConfig.createInstance().getLocale()))+strReferencedSOPInstanceUID);
										}
										objBasicImageOverlayBoxSequence.put(strReferencedSOPInstanceUID,objPresentationLUTDataSet);
									}
								}
							}
							objImageBoxCollection.put(strReferencedSOPInstanceUID,objBasicImageBoxDataSet);
						}
					}
				}

				StoredPrintIOD objStoredPrintIOD = createStoredPrintIOD(EnumSOPClassUIDs.STOREDPRINTSTORAGE.getValue(),strValue);
				if(DicomConfig.createInstance().isLoggingOn())
				{
					DicomLogger objDicomLogger = DicomLogger.getLogger();
					objDicomLogger.log(ResourceBundleWrapper.getValue("status", "Print.CreatingStoredPrintIOD", new Locale(DicomConfig.createInstance().getLocale())));
				}
				objDataSetColl.add(objStoredPrintIOD.getDataSet());

				if(strSOPClassUID!= null && strSOPClassUID.equals(EnumSOPClassUIDs.BASICGRAYSCALEIMAGEBOX.getValue()))
				{
					ISingleCollection<HardcopyGrayscaleImageIOD> objHardcopyGrayscaleImageIODCol = createHardCopyGraysacleImageIOD(EnumSOPClassUIDs.HARDCOPYGRAYSCALEIMAGESTORAGE.getValue(),strValue);
					for(HardcopyGrayscaleImageIOD objHardcopyGrayscaleImageIOD : objHardcopyGrayscaleImageIODCol)
					{
						objDataSetColl.add(objHardcopyGrayscaleImageIOD.getDataSet());
						if(DicomConfig.createInstance().isLoggingOn())
						{
							DicomLogger objDicomLogger = DicomLogger.getLogger();
							objDicomLogger.log(ResourceBundleWrapper.getValue("status", "Print.CreatingHardCopyGrayScaleImageIOD", new Locale(DicomConfig.createInstance().getLocale())));
						}
					}
				}
				return EnumImplOpsStatus.SUCCESS.getValue();
			}
			else
			{
				if(DicomConfig.createInstance().isLoggingOn())
				{
					DicomLogger objDicomLogger =DicomLogger.getLogger();
					objDicomLogger.log(ResourceBundleWrapper.getValue("exceptions","Print.BasicFilmBoxDoesNotExist", new Locale(DicomConfig.createInstance().getLocale())) + strValue);
				}
				return EnumImplOpsStatus.FAILURE.getValue();
			}
		}
		default :
		{
			if(DicomConfig.createInstance().isLoggingOn())
			{
				DicomLogger objDicomLogger =DicomLogger.getLogger();
				objDicomLogger.log(ResourceBundleWrapper.getValue("exceptions","ServiceRequestNotSupported", new Locale(DicomConfig.createInstance().getLocale())) + enumRequestType);
			}
			return EnumImplOpsStatus.FAILURE.getValue();
		}
		}
		
	}

	/**
	 * This function creates the Stored Print IOD.
	 */
	private StoredPrintIOD createStoredPrintIOD(String strSOPClassUID, String strSOPInstanceUID)
	{
		StoredPrintIOD objStoredPrintIOD = new StoredPrintIOD();
		PatientModule objPatientModule = objStoredPrintIOD.getPatientModule();
		populatePatientModule(objPatientModule);
		GeneralStudyModule objGeneralStudyModule = objStoredPrintIOD.getGeneralStudyModule();
		populateGeneralStudyModule(objGeneralStudyModule);
		PatientStudyModule objPatientStudyModule = objStoredPrintIOD.getPatientStudyModule();
		populatePatientStudyModule(objPatientStudyModule);
		GeneralSeriesModule objGeneralSeriesModule = objStoredPrintIOD.getGeneralSeriesModule();
		populateGeneralSeriesModule(objGeneralSeriesModule);
		PresentationLUTListModule objPresentationLUTListModule = objStoredPrintIOD.getPresentationLUTListModule();
		populatePresentationLUTListModule(objPresentationLUTListModule);
		ImageOverlayBoxListModule objImageOverlayBoxListModule = objStoredPrintIOD.getImageOverlayBoxListModule();
		populateImageOverlayBoxListModule(objImageOverlayBoxListModule);
		FilmBoxModule objFilmBoxModule = objStoredPrintIOD.getFilmBoxModule();
		populateFilmBox(objFilmBoxModule);
		SOPCommonModule objSOPCommonModule = objStoredPrintIOD.getSOPCommonModule();
		populateSOPCommonModule(objSOPCommonModule, strSOPClassUID, strSOPInstanceUID);
		AnnotationListModule objAnnotationListModule = objStoredPrintIOD.getAnnotationListModule();
		populateAnnotationListModule(objAnnotationListModule);
		ImageBoxListModule objImageBoxListModule = objStoredPrintIOD.getImageBoxListModule();
		populateImageBoxListModule(objImageBoxListModule);
		return objStoredPrintIOD;
	}

	/**
	 * This function populates the Patient Module.
	 */
	@SuppressWarnings("unchecked")
	private void populatePatientModule(PatientModule objPatientModule)
	{
		if(objBasicFilmSessionDataSet != null && objBasicFilmSessionDataSet.getDataForTag(0x2130, 0x00A0) != null && objBasicFilmSessionDataSet.getDataForTag(0x2130, 0x00A0).getDicomValue() != null)
		{
			ProposedStudySequence objProposedStudySequence = (ProposedStudySequence)objBasicFilmSessionDataSet.getDataForTag(0x2130, 0x00A0).getDicomValue();
			if(objProposedStudySequence != null)
			{
				ISingleCollection<ProposedStudySequenceItem> objProposedStudySequenceItemCollection = (ISingleCollection<ProposedStudySequenceItem> )objProposedStudySequence.getValue();
				if(objProposedStudySequenceItemCollection != null && objProposedStudySequenceItemCollection.size() > 0)
				{
					ProposedStudySequenceItem objProposedStudySequenceItem  = objProposedStudySequenceItemCollection.get(0);
					{
						objPatientModule.setPatientName(objProposedStudySequenceItem.getPatientName());
						objPatientModule.setPatientID(objProposedStudySequenceItem.getPatientID());
						objPatientModule.setPatientBirthDate(objProposedStudySequenceItem.getPatientBirthDate());
						objPatientModule.setPatientSex(objProposedStudySequenceItem.getPatientSex());
						objPatientModule.setPatientBirthTime(objProposedStudySequenceItem.getPatientBirthTime());
						objPatientModule.setOtherPatientIDs(objProposedStudySequenceItem.getOtherPatientIDs());
						objPatientModule.setOtherPatientNames(objProposedStudySequenceItem.getOtherPatientNames());
						objPatientModule.setEthnicGroup(objProposedStudySequenceItem.getEthnicGroup());
						objPatientModule.setPatientComments(objProposedStudySequenceItem.getPatientComments());
					}
				}
			}
		}
	}

	/**
	 * This function populates the General Study Module.
	 */
	@SuppressWarnings("unchecked")
	private void populateGeneralStudyModule(GeneralStudyModule objGeneralStudyModule)
	{
		if(objBasicFilmSessionDataSet != null && objBasicFilmSessionDataSet.getDataForTag(0x2130, 0x00A0) != null)
		{
			ProposedStudySequence objProposedStudySequence = (ProposedStudySequence)objBasicFilmSessionDataSet.getDataForTag(0x2130, 0x00A0).getDicomValue();
			if(objProposedStudySequence != null)
			{
				ISingleCollection<ProposedStudySequenceItem> objProposedStudySequenceItemCollection = (ISingleCollection<ProposedStudySequenceItem> )objProposedStudySequence.getValue();
				if(objProposedStudySequenceItemCollection != null && objProposedStudySequenceItemCollection.size() > 0)
				{
					ProposedStudySequenceItem objProposedStudySequenceItem  = objProposedStudySequenceItemCollection.get(0);
					{
						objGeneralStudyModule.setStudyInstanceUID(objProposedStudySequenceItem.getStudyInstanceUID());
						objGeneralStudyModule.setStudyDate(objProposedStudySequenceItem.getStudyDate());
						objGeneralStudyModule.setStudyTime(objProposedStudySequenceItem.getStudyTime());
						objGeneralStudyModule.setReferringPhysicianName(objProposedStudySequenceItem.getReferringPhysicianName());
						objGeneralStudyModule.setStudyID(objProposedStudySequenceItem.getStudyID());
						objGeneralStudyModule.setAccessionNumber(objProposedStudySequenceItem.getAccessionNumber());
						objGeneralStudyModule.setStudyDescription(objProposedStudySequenceItem.getStudyDescription());
					}
				}
			}
		}
	}

	/**
	 * This function populates the Patient Study Module.
	 */
	@SuppressWarnings("unchecked")
	private void populatePatientStudyModule(PatientStudyModule objPatientStudyModule)
	{
		if(objBasicFilmSessionDataSet != null && objBasicFilmSessionDataSet.getDataForTag(0x2130, 0x00A0) != null && objBasicFilmSessionDataSet.getDataForTag(0x2130, 0x00A0).getDicomValue() != null)
		{
			ProposedStudySequence objProposedStudySequence = (ProposedStudySequence)objBasicFilmSessionDataSet.getDataForTag(0x2130, 0x00A0).getDicomValue();
			if(objProposedStudySequence != null)
			{
				ISingleCollection<ProposedStudySequenceItem> objProposedStudySequenceItemCollection = (ISingleCollection<ProposedStudySequenceItem> )objProposedStudySequence.getValue();
				if(objProposedStudySequenceItemCollection != null && objProposedStudySequenceItemCollection.size() > 0)
				{
					ProposedStudySequenceItem objProposedStudySequenceItem  = objProposedStudySequenceItemCollection.get(0);
					{
						objPatientStudyModule.setPatientAge(objProposedStudySequenceItem.getPatientAge());
						objPatientStudyModule.setPatientSize(objProposedStudySequenceItem.getPatientSize());
						objPatientStudyModule.setPatientWeight(objProposedStudySequenceItem.getPatientWeight());
						objPatientStudyModule.setOccupation(objProposedStudySequenceItem.getOccupation());
						objPatientStudyModule.setAdditionalPatientHistory(objProposedStudySequenceItem.getAdditionalPatientHistory());
						objPatientStudyModule.setAdmittingDiagnosesDescription(objProposedStudySequenceItem.getAdmittingDiagnosesDescription());
					}
				}
			}
		}
	}

	/**
	 * This function populates the General Series Module.
	 */
	@SuppressWarnings("unchecked")
	private void populateGeneralSeriesModule(GeneralSeriesModule objGeneralSeriesModule)
	{
		if(objImageBoxCollection != null && objImageBoxCollection.size() > 0)
		{
			String[] strArr = convertToStringArray(objImageBoxCollection.getKeys());
			if(strArr != null && strArr.length >0)
			{
				IDataSet objImageBoxDataSet = objImageBoxCollection.get(strArr[0]);
				if(objImageBoxDataSet != null)
				{
					if(objImageBoxDataSet.isPresent(0x2130, 0x00A0) && objImageBoxDataSet.getDataForTag(0x2130, 0x00A0).getDicomValue() != null)
					{
						OriginalImageSequence objOriginalImageSequence = (OriginalImageSequence)objImageBoxDataSet.getDataForTag(0x2130, 0x00A0).getDicomValue();
						if(objOriginalImageSequence!= null)
						{
							ISingleCollection<OriginalImageSequenceItem> objOriginalImageSequenceItemCollection = (ISingleCollection<OriginalImageSequenceItem> )objOriginalImageSequence.getValue();
							if(objOriginalImageSequenceItemCollection.size() >0)
							{
								OriginalImageSequenceItem objOriginalImageSequenceItem = objOriginalImageSequenceItemCollection.get(0);
								{
									objGeneralSeriesModule.setSeriesInstanceUID(objOriginalImageSequenceItem.getSeriesInstanceUID());
								}
							}
						}
					}
				}
			}
		}
	}

	/**
	 * This function populates the Presentation LUT Module.
	 */
	@SuppressWarnings("unchecked")
	private void populatePresentationLUTListModule(PresentationLUTListModule objPresentationLUTListModule)
	{
		if(objPresentationLUTCollection != null)
		{
			String[] strPresentationLUTSOPInstance = convertToStringArray(objPresentationLUTCollection.getKeys());
			if(strPresentationLUTSOPInstance != null)
			{
				PresentationLUTContentSequence objPresentationLUTContentSequence = objPresentationLUTListModule.getPresentationLUTContentSequence();
				for(String strSOPInstance : strPresentationLUTSOPInstance)
				{
					PresentationLUTContentSequenceItem objPresentationLUTContentSequenceItem = objPresentationLUTContentSequence.getNewItem();
					IDataSet objIDataSet = objPresentationLUTCollection.get(strSOPInstance);
					if(objIDataSet != null)
					{
						PresentationLUTModule objPresentationLUTModule = new PresentationLUTModule(objIDataSet);
						objPresentationLUTContentSequenceItem.setPresentationLUTShape(getPresentationLUTShape(objPresentationLUTModule.getPresentationLUTShape()));
						objPresentationLUTContentSequenceItem.setSOPInstanceUID(strSOPInstance);
						PresentationLUTSequence objPresentationLUTSequence = objPresentationLUTContentSequenceItem.getPresentationLUTSequence();
						PresentationLUTSequence objTempPresentationLUTSequence = objPresentationLUTModule.getPresentationLUTSequence();
						ISingleCollection<PresentationLUTSequenceItem> objPresentationLUTCollection = (ISingleCollection<PresentationLUTSequenceItem>)objTempPresentationLUTSequence.getValue();
						for(PresentationLUTSequenceItem objPresentationLUTSequenceItem : objPresentationLUTCollection)
						{
							objPresentationLUTSequence.addItem(objPresentationLUTSequenceItem);
						}
					}
					objPresentationLUTContentSequence.addItem(objPresentationLUTContentSequenceItem);
				}
			}
		}
	}

	/**
	 * This function converts the Object Array to String Array.
	 */
	private String[] convertToStringArray(Object[] objArray)
	{
		String[] strValue = new String[objArray.length];
		int i =0;
		for(Object strSOPInstance : objArray)
		{
			strValue[i] = (String)strSOPInstance;
			i++;
		}
		return strValue;
	}

	/**
	 * This function populates the Image Overlay List Module.
	 */
	@SuppressWarnings("unchecked")
	private void populateImageOverlayBoxListModule(ImageOverlayBoxListModule objImageOverlayBoxListModule)
	{
		if(objImageBoxCollection != null)
		{
			String[] strPresentationLUTSOPInstance = convertToStringArray(objImageBoxCollection.getKeys());
			if(strPresentationLUTSOPInstance!= null)
			{
				ImageOverlayBoxContentSequence objImageOverlayBoxContentSequence = objImageOverlayBoxListModule.getImageOverlayBoxContentSequence();

				for(String strSOPInstance : strPresentationLUTSOPInstance)
				{
					ImageOverlayBoxContentSequenceItem objImageOverlayBoxContentSequenceItem = objImageOverlayBoxContentSequence.getNewItem();
					IDataSet objIDataSet = objImageBoxCollection.get(strSOPInstance);
					if(objIDataSet != null)
					{
						BasicPrintImageOverlayBoxModule objBasicPrintImageOverlayBoxModule = new BasicPrintImageOverlayBoxModule(objIDataSet);
						objImageOverlayBoxContentSequenceItem.setSOPInstanceUID(strSOPInstance);
						IDataElement objIDataElement = new ImplicitDE(0x2040,0x0072,objBasicPrintImageOverlayBoxModule.getOverlayOrImageMagnification(),objImageOverlayBoxListModule.getTransferSyntax(),objImageOverlayBoxListModule.getDictionaryReader());
						objImageOverlayBoxContentSequenceItem.addDataElement(objIDataElement);
						objImageOverlayBoxContentSequenceItem.setMagnifyToNumberOfColumns(objBasicPrintImageOverlayBoxModule.getMagnifyToNumberOfColumns());
						objIDataElement = new ImplicitDE(0x2040,0x0060,objBasicPrintImageOverlayBoxModule.getOverlayMagnificationType(),objImageOverlayBoxListModule.getTransferSyntax(),objImageOverlayBoxListModule.getDictionaryReader());
						objImageOverlayBoxContentSequenceItem.addDataElement(objIDataElement);
						objImageOverlayBoxContentSequenceItem.setOverlaySmoothingType(objBasicPrintImageOverlayBoxModule.getOverlaySmoothingType());
						objIDataElement = new ImplicitDE(0x2040,0x0080,objBasicPrintImageOverlayBoxModule.getOverlayForegroundDensity(),objImageOverlayBoxListModule.getTransferSyntax(),objImageOverlayBoxListModule.getDictionaryReader());
						objImageOverlayBoxContentSequenceItem.addDataElement(objIDataElement);
						objIDataElement = new ImplicitDE(0x2040,0x0082,objBasicPrintImageOverlayBoxModule.getOverlayBackgroundDensity(),objImageOverlayBoxListModule.getTransferSyntax(),objImageOverlayBoxListModule.getDictionaryReader());
						objImageOverlayBoxContentSequenceItem.addDataElement(objIDataElement);
						OverlayPixelDataSequence objOverlayPixelDataSequence = objImageOverlayBoxContentSequenceItem.getOverlayPixelDataSequence();

						OverlayPixelDataSequence objTempOverlayPixelDataSequence = objBasicPrintImageOverlayBoxModule.getOverlayPixelDataSequence();
						ISingleCollection<OverlayPixelDataSequenceItem> objOverlayPixelDataCollection = (ISingleCollection<OverlayPixelDataSequenceItem>)objTempOverlayPixelDataSequence.getValue();
						for(OverlayPixelDataSequenceItem objOverlayPixelDataSequenceItem : objOverlayPixelDataCollection)
						{
							objOverlayPixelDataSequence.addItem(objOverlayPixelDataSequenceItem);
						}
						objImageOverlayBoxContentSequence.addItem(objImageOverlayBoxContentSequenceItem);
					}
				}
			}
		}
	}

	/**
	 * This function populates the Annotation List Module.
	 */
	private void populateAnnotationListModule(AnnotationListModule objAnnotationListModule)
	{
		if(objBasicAnnotatiobBoxCollection != null)
		{
			String[] strAnnotationListSOPInstance = convertToStringArray(objBasicAnnotatiobBoxCollection.getKeys());
			if(strAnnotationListSOPInstance != null)
			{
				AnnotationContentSequence objAnnotationContentSequence = objAnnotationListModule.getAnnotationContentSequence();

				for(String strSOPInstance : strAnnotationListSOPInstance)
				{
					IDataSet objIDataSet = objBasicAnnotatiobBoxCollection.get(strSOPInstance);
					if(objIDataSet != null)
					{
						AnnotationContentSequenceItem objAnnotationContentSequenceItem = objAnnotationContentSequence.getNewItem();
						BasicAnnotationPresentationModule objBasicAnnotationPresentationModule = new BasicAnnotationPresentationModule(objIDataSet);
						objAnnotationContentSequenceItem.setAnnotationPosition(objBasicAnnotationPresentationModule.getAnnotationPosition());
						objAnnotationContentSequenceItem.setSOPInstanceUID(strSOPInstance);
						objAnnotationContentSequenceItem.setTextString(objBasicAnnotationPresentationModule.getTextString());
						objAnnotationContentSequence.addItem(objAnnotationContentSequenceItem);
					}
				}
			}
		}
	}

	/**
	 * This function populates the Image Box List Module.
	 */
	@SuppressWarnings("unchecked")
	private void populateImageBoxListModule(ImageBoxListModule objImageBoxListModule)
	{
		if(objImageBoxCollection != null)
		{
			String[] strImageBoxSOPInstance = convertToStringArray(objImageBoxCollection.getKeys());
			if(strImageBoxSOPInstance != null)
			{
				ImageBoxContentSequence objImageBoxContentSequence = objImageBoxListModule.getImageBoxContentSequence();
				for(String strSOPInstance : strImageBoxSOPInstance)
				{
					IDataElement objIDataElement = null;
					IDataSet objIDataSet = objImageBoxCollection.get(strSOPInstance);
					if(objIDataSet != null)
					{
						ImageBoxContentSequenceItem objImageBoxContentSequenceItem = objImageBoxContentSequence.getNewItem();
						objImageBoxContentSequenceItem.setSOPInstanceUID(strSOPInstance);
						if(objIDataSet.isPresent(0x2020,0x0010))
						{
							objIDataElement = new ImplicitDE(0x2020,0x0010,objIDataSet.getValue(0x2020,0x0010),objImageBoxListModule.getTransferSyntax(),objImageBoxListModule.getDictionaryReader());
							objImageBoxContentSequenceItem.addDataElement(objIDataElement);
						}
						if(objIDataSet.isPresent(0x2020,0x0020))
						{
							objIDataElement = new ImplicitDE(0x2020,0x0020,objIDataSet.getValue(0x2020,0x0020),objImageBoxListModule.getTransferSyntax(),objImageBoxListModule.getDictionaryReader());
							objImageBoxContentSequenceItem.addDataElement(objIDataElement);
						}
						if(objIDataSet.isPresent(0x2010,0x0060))
						{
							objIDataElement = new ImplicitDE(0x2010,0x0060,objIDataSet.getValue(0x2010,0x0060),objImageBoxListModule.getTransferSyntax(),objImageBoxListModule.getDictionaryReader());
							objImageBoxContentSequenceItem.addDataElement(objIDataElement);
						}
						if(objIDataSet.isPresent(0x2010,0x0150))
						{
							objIDataElement = new ImplicitDE(0x2010,0x0150,objIDataSet.getValue(0x2010,0x0150),objImageBoxListModule.getTransferSyntax(),objImageBoxListModule.getDictionaryReader());
							objImageBoxContentSequenceItem.addDataElement(objIDataElement);
						}
						if(objIDataSet.isPresent(0x2010,0x0080))
						{
							objIDataElement = new ImplicitDE(0x2010,0x0080,objIDataSet.getValue(0x2010,0x0080),objImageBoxListModule.getTransferSyntax(),objImageBoxListModule.getDictionaryReader());
							objImageBoxContentSequenceItem.addDataElement(objIDataElement);
						}
						if(objIDataSet.isPresent(0x2020,0x0030))
						{
							objIDataElement = new ImplicitDE(0x2020,0x0030,objIDataSet.getValue(0x2020,0x0030),objImageBoxListModule.getTransferSyntax(),objImageBoxListModule.getDictionaryReader());
							objImageBoxContentSequenceItem.addDataElement(objIDataElement);
						}
						if(objIDataSet.isPresent(0x2020,0x0040))
						{
							objIDataElement = new ImplicitDE(0x2020,0x0040,objIDataSet.getValue(0x2020,0x0040),objImageBoxListModule.getTransferSyntax(),objImageBoxListModule.getDictionaryReader());
							objImageBoxContentSequenceItem.addDataElement(objIDataElement);
						}
						if(objIDataSet.isPresent(0x2020,0x0130))
						{
							objIDataElement = new ImplicitDE(0x2020,0x0130,objIDataSet.getValue(0x2020,0x0130),objImageBoxListModule.getTransferSyntax(),objImageBoxListModule.getDictionaryReader());
							objImageBoxContentSequenceItem.addDataElement(objIDataElement);
						}
						if(objIDataSet.isPresent(0x2020,0x500))
						{
							objIDataElement = new ImplicitDE(0x2020,0x0500,objIDataSet.getValue(0x2020,0x0500),objImageBoxListModule.getTransferSyntax(),objImageBoxListModule.getDictionaryReader());
							objImageBoxContentSequenceItem.addDataElement(objIDataElement);
						}
						ReferencedImageSequence objReferencedImageSequence = objImageBoxContentSequenceItem.getReferencedImageSequence();
						ReferencedImageSequenceItem objImageSequenceDependentItem = objReferencedImageSequence.getNewItem();
						if(objIDataSet.isPresent(0x2130, 0x00C0))
						{
							OriginalImageSequence objOriginalImageSequence = (OriginalImageSequence)objIDataSet.getDataForTag(0x2130, 0x00C0).getDicomValue();
							if(objOriginalImageSequence != null)
							{
								ISingleCollection<OriginalImageSequenceItem> objOriginalImageSequenceItemCol =(ISingleCollection<OriginalImageSequenceItem>)objOriginalImageSequence.getValue();
								if(objOriginalImageSequenceItemCol.size() >0)
								{
									OriginalImageSequenceItem objOriginalImageSequenceItem = objOriginalImageSequenceItemCol.get(0);
									if(objOriginalImageSequenceItem.contains(0x0020, 0x000D))
									{
										objIDataElement = new ImplicitDE(0x0020,0x000D,objIDataSet.getValue(0x0020,0x000D),objImageBoxListModule.getTransferSyntax(),objImageBoxListModule.getDictionaryReader());
										objImageSequenceDependentItem.addDataElement(objIDataElement);
									}
									if(objOriginalImageSequenceItem.contains(0x0020, 0x000E))
									{
										objIDataElement = new ImplicitDE(0x0020,0x000E,objIDataSet.getValue(0x0020,0x000E),objImageBoxListModule.getTransferSyntax(),objImageBoxListModule.getDictionaryReader());
										objImageSequenceDependentItem.addDataElement(objIDataElement);
									}
									if(objOriginalImageSequenceItem.contains(0x0010, 0x0020))
									{
										objIDataElement = new ImplicitDE(0x0010,0x0020,objIDataSet.getValue(0x0010,0x0020),objImageBoxListModule.getTransferSyntax(),objImageBoxListModule.getDictionaryReader());
										objImageSequenceDependentItem.addDataElement(objIDataElement);
									}
									if(objOriginalImageSequenceItem.contains(0x0008, 0x1150))
									{
										objIDataElement = new ImplicitDE(0x0008,0x1150,objIDataSet.getValue(0x0008,0x1150),objImageBoxListModule.getTransferSyntax(),objImageBoxListModule.getDictionaryReader());
										objImageSequenceDependentItem.addDataElement(objIDataElement);
									}
									if(objOriginalImageSequenceItem.contains(0x0008, 0x1155))
									{
										objIDataElement = new ImplicitDE(0x0008,0x1155,objIDataSet.getValue(0x0008,0x1155),objImageBoxListModule.getTransferSyntax(),objImageBoxListModule.getDictionaryReader());
										objImageSequenceDependentItem.addDataElement(objIDataElement);
									}
									if(objOriginalImageSequenceItem.contains(0x0008, 0x1160))
									{
										objIDataElement = new ImplicitDE(0x0008,0x1160,objIDataSet.getValue(0x0008,0x1160),objImageBoxListModule.getTransferSyntax(),objImageBoxListModule.getDictionaryReader());
										objImageSequenceDependentItem.addDataElement(objIDataElement);
									}
									if(objOriginalImageSequenceItem.contains(0x0020, 0x0013))
									{
										objIDataElement = new ImplicitDE(0x0020,0x0013,objIDataSet.getValue(0x0020,0x0013),objImageBoxListModule.getTransferSyntax(),objImageBoxListModule.getDictionaryReader());
										objImageSequenceDependentItem.addDataElement(objIDataElement);
									}
								}
							}
							objReferencedImageSequence.addItem(objImageSequenceDependentItem);
						}
						objImageBoxContentSequence.addItem(objImageBoxContentSequenceItem);
					}
				}
			}
		}
	}

	/**
	 * This function populates the Film Box Module..
	 */
	private void populateFilmBox(FilmBoxModule objFilmBoxModule)
	{
		if(objImageBoxCollection != null)
		{
			String[] strImageBoxSOPInstance = convertToStringArray(objImageBoxCollection.getKeys());
			if(strImageBoxSOPInstance != null)
			{
				FilmBoxContentSequence objFilmBoxContentSequence = objFilmBoxModule.getFilmBoxContentSequence();
				for(String strSOPInstance : strImageBoxSOPInstance)
				{
					IDataElement objIDataElement = null;
					IDataSet objIDataSet = objImageBoxCollection.get(strSOPInstance);
					if(objIDataSet != null)
					{
						FilmBoxContentSequenceItem objFilmBoxContentSequenceItem = objFilmBoxContentSequence.getNewItem();

						if(objIDataSet.isPresent(0x2010,0x0010))
						{
							objIDataElement = new ImplicitDE(0x2010,0x0010,objIDataSet.getValue(0x2010,0x0010),objFilmBoxModule.getTransferSyntax(),objFilmBoxModule.getDictionaryReader());
							objFilmBoxContentSequenceItem.addDataElement(objIDataElement);
						}
						if(objIDataSet.isPresent(0x2010,0x0030))
						{
							objIDataElement = new ImplicitDE(0x2010,0x0030,objIDataSet.getValue(0x2010,0x0030),objFilmBoxModule.getTransferSyntax(),objFilmBoxModule.getDictionaryReader());
							objFilmBoxContentSequenceItem.addDataElement(objIDataElement);
						}
						if(objIDataSet.isPresent(0x2010,0x0040))
						{
							objIDataElement = new ImplicitDE(0x2010,0x0040,objIDataSet.getValue(0x2010,0x0040),objFilmBoxModule.getTransferSyntax(),objFilmBoxModule.getDictionaryReader());
							objFilmBoxContentSequenceItem.addDataElement(objIDataElement);
						}
						if(objIDataSet.isPresent(0x2010,0x0050))
						{
							objIDataElement = new ImplicitDE(0x2010,0x0050,objIDataSet.getValue(0x2010,0x0050),objFilmBoxModule.getTransferSyntax(),objFilmBoxModule.getDictionaryReader());
							objFilmBoxContentSequenceItem.addDataElement(objIDataElement);
						}
						if(objIDataSet.isPresent(0x2010,0x0060))
						{
							objIDataElement = new ImplicitDE(0x2010,0x0060,objIDataSet.getValue(0x2010,0x0060),objFilmBoxModule.getTransferSyntax(),objFilmBoxModule.getDictionaryReader());
							objFilmBoxContentSequenceItem.addDataElement(objIDataElement);
						}
						if(objIDataSet.isPresent(0x2010,0x0080))
						{
							objIDataElement = new ImplicitDE(0x2010,0x0080,objIDataSet.getValue(0x2020,0x0080),objFilmBoxModule.getTransferSyntax(),objFilmBoxModule.getDictionaryReader());
							objFilmBoxContentSequenceItem.addDataElement(objIDataElement);
						}
						if(objIDataSet.isPresent(0x2010,0x0100))
						{
							objIDataElement = new ImplicitDE(0x2010,0x0100,objIDataSet.getValue(0x2010,0x0100),objFilmBoxModule.getTransferSyntax(),objFilmBoxModule.getDictionaryReader());
							objFilmBoxContentSequenceItem.addDataElement(objIDataElement);
						}
						if(objIDataSet.isPresent(0x2010,0x0110))
						{
							objIDataElement = new ImplicitDE(0x2010,0x0110,objIDataSet.getValue(0x2010,0x0110),objFilmBoxModule.getTransferSyntax(),objFilmBoxModule.getDictionaryReader());
							objFilmBoxContentSequenceItem.addDataElement(objIDataElement);
						}
						if(objIDataSet.isPresent(0x2010,0x0120))
						{
							objIDataElement = new ImplicitDE(0x2010,0x0120,objIDataSet.getValue(0x2010,0x0120),objFilmBoxModule.getTransferSyntax(),objFilmBoxModule.getDictionaryReader());
							objFilmBoxContentSequenceItem.addDataElement(objIDataElement);
						}
						if(objIDataSet.isPresent(0x2010,0x0130))
						{
							objIDataElement = new ImplicitDE(0x2010,0x0130,objIDataSet.getValue(0x2010,0x0130),objFilmBoxModule.getTransferSyntax(),objFilmBoxModule.getDictionaryReader());
							objFilmBoxContentSequenceItem.addDataElement(objIDataElement);
						}
						if(objIDataSet.isPresent(0x2010,0x0140))
						{
							objIDataElement = new ImplicitDE(0x2010,0x0140,objIDataSet.getValue(0x2010,0x0140),objFilmBoxModule.getTransferSyntax(),objFilmBoxModule.getDictionaryReader());
							objFilmBoxContentSequenceItem.addDataElement(objIDataElement);
						}
						if(objIDataSet.isPresent(0x2010,0x0150))
						{
							objIDataElement = new ImplicitDE(0x2010,0x0150,objIDataSet.getValue(0x2010,0x0150),objFilmBoxModule.getTransferSyntax(),objFilmBoxModule.getDictionaryReader());
							objFilmBoxContentSequenceItem.addDataElement(objIDataElement);
						}
						if(objIDataSet.isPresent(0x2010,0x015E))
						{
							objIDataElement = new ImplicitDE(0x2010,0x015E,objIDataSet.getValue(0x2010,0x015E),objFilmBoxModule.getTransferSyntax(),objFilmBoxModule.getDictionaryReader());
							objFilmBoxContentSequenceItem.addDataElement(objIDataElement);
						}
						if(objIDataSet.isPresent(0x2010,0x0160))
						{
							objIDataElement = new ImplicitDE(0x2010,0x0160,objIDataSet.getValue(0x2010,0x0160),objFilmBoxModule.getTransferSyntax(),objFilmBoxModule.getDictionaryReader());
							objFilmBoxContentSequenceItem.addDataElement(objIDataElement);
						}
						if(objIDataSet.isPresent(0x2020,0x0050))
						{
							objIDataElement = new ImplicitDE(0x2020,0x0050,objIDataSet.getValue(0x2020,0x0050),objFilmBoxModule.getTransferSyntax(),objFilmBoxModule.getDictionaryReader());
							objFilmBoxContentSequenceItem.addDataElement(objIDataElement);
						}
						if(objIDataSet.isPresent(0x2050,0x0500))
						{
							objIDataElement = new ImplicitDE(0x2050,0x0500,objIDataSet.getValue(0x2050,0x0500),objFilmBoxModule.getTransferSyntax(),objFilmBoxModule.getDictionaryReader());
							objFilmBoxContentSequenceItem.addDataElement(objIDataElement);
						}
						objFilmBoxContentSequence.addItem(objFilmBoxContentSequenceItem);
					}
				}
			}
		}
	}

	/**
	 * This function populates the SOP Common module.
	 */
	private void populateSOPCommonModule(SOPCommonModule objSCommonModule, String strSOPClassUID, String strSOPInstanceUID)
	{
		objSCommonModule.setSOPClassUID(strSOPClassUID);
		objSCommonModule.setSOPInstanceUID(strSOPInstanceUID);
	}

	/**
	 * This function created the HardCopy GraySclae Image IOD.
	 */
	private ISingleCollection<HardcopyGrayscaleImageIOD> createHardCopyGraysacleImageIOD(String strSOPClassUID, String strSOPInstanceUID)
	{
		populateAllHardCopyGrayScaleImage();
		ISingleCollection<HardcopyGrayscaleImageIOD> objHardcopyGrayscaleImageIODCol = new SingleCollection<HardcopyGrayscaleImageIOD>();
		for(HardcopyGrayscaleImageModule objHardcopyGrayscaleImageModule : objHardCopyGrayscaleImageModuleCol)
		{
			HardcopyGrayscaleImageIOD objHardcopyGrayscaleImageIOD = new HardcopyGrayscaleImageIOD();
			PatientModule objPatientModule = objHardcopyGrayscaleImageIOD.getPatientModule();
			populatePatientModule(objPatientModule);
			GeneralStudyModule objGeneralStudyModule = objHardcopyGrayscaleImageIOD.getGeneralStudyModule();
			populateGeneralStudyModule(objGeneralStudyModule);
			PatientStudyModule objPatientStudyModule = objHardcopyGrayscaleImageIOD.getPatientStudyModule();
			populatePatientStudyModule(objPatientStudyModule);
			GeneralSeriesModule objGeneralSeriesModule = objHardcopyGrayscaleImageIOD.getGeneralSeriesModule();
			populateGeneralSeriesModule(objGeneralSeriesModule);

			HardcopyGrayscaleImageModule objHardcopyGrayscaleImageModuleTemp = objHardcopyGrayscaleImageIOD.getHardcopyGrayscaleImageModule();
			copy(objHardcopyGrayscaleImageModule ,objHardcopyGrayscaleImageModuleTemp );

			SOPCommonModule objSOPCommonModule = objHardcopyGrayscaleImageIOD.getSOPCommonModule();
			populateSOPCommonModule(objSOPCommonModule, strSOPClassUID, strSOPInstanceUID);
			objHardcopyGrayscaleImageIODCol.add(objHardcopyGrayscaleImageIOD);
		}
		return objHardcopyGrayscaleImageIODCol;
	}
	/**
	 * This function copy values.
	 */
	private void copy(HardcopyGrayscaleImageModule objHardcopyGrayscaleImageModule, HardcopyGrayscaleImageModule objHardcopyGrayscaleImageModuleTemp)
	{
		objHardcopyGrayscaleImageModuleTemp.setBitsAllocated(getEnumValueOfBitsAllocated(objHardcopyGrayscaleImageModule.getBitsAllocated()));
		objHardcopyGrayscaleImageModuleTemp.setBitsStored(getEnumValueOfBitsStored(objHardcopyGrayscaleImageModule.getBitsStored()));
		objHardcopyGrayscaleImageModuleTemp.setColumns(objHardcopyGrayscaleImageModule.getColumns());
		objHardcopyGrayscaleImageModuleTemp.setHighBit(getEnumValueOfHighBit(objHardcopyGrayscaleImageModule.getHighBit()));
		objHardcopyGrayscaleImageModuleTemp.setPhotometricInterpretation(getEnumValueOfPhotometricInterpretation(objHardcopyGrayscaleImageModule.getPhotometricInterpretation()));
		objHardcopyGrayscaleImageModuleTemp.setPixelAspectRatio(objHardcopyGrayscaleImageModule.getPixelAspectRatio());
		objHardcopyGrayscaleImageModuleTemp.setPixelData(objHardcopyGrayscaleImageModule.getPixelData(),EnumPixelDataVRType.OB,true);
		objHardcopyGrayscaleImageModuleTemp.setPixelRepresentation(getEnumValueOfPixelRepresentation(objHardcopyGrayscaleImageModule.getPixelRepresentation()));
		objHardcopyGrayscaleImageModuleTemp.setRows(objHardcopyGrayscaleImageModule.getRows());
		objHardcopyGrayscaleImageModuleTemp.setSamplesPerPixel(getEnumValueOfSamplesPerPixel(objHardcopyGrayscaleImageModule.getSamplesPerPixel()));
	}
	/**
	 * Retrieves the Enum Value Of Bits Stored
	 * @param shValue short values 
	 * @return enum value of Bits Stored
	 */
	private EnumBitsStored getEnumValueOfBitsStored(short shValue)
	{
		EnumBitsStored[] arrEnumBitsStoredVal = EnumBitsStored.values();
		for(EnumBitsStored enumBitsStored : arrEnumBitsStoredVal)
		{
			if(shValue == enumBitsStored.getValue())
				return enumBitsStored;
		}
		return null;
	}
	/**
	 * Retrieves the Enum Value Of Bits Allocated
	 * @param shValue short values 
	 * @return enum value of Bits Allocated
	 */
	private EnumBitsAllocated getEnumValueOfBitsAllocated(short shValue)
	{
		EnumBitsAllocated[] arrEnumBitsAllocatedVal = EnumBitsAllocated.values();
		for(EnumBitsAllocated enumEnumBitsAllocated : arrEnumBitsAllocatedVal)
		{
			if(shValue == enumEnumBitsAllocated.getValue())
				return enumEnumBitsAllocated;
		}
		return null;
	}
	/**
	 * Retrieves the Enum Value Of High Bit
	 * @param shValue short values 
	 * @return enum value of HighBit
	 */
	private EnumHighBit getEnumValueOfHighBit(short shValue)
	{
		EnumHighBit[] arrEnumBitsAllocatedVal = EnumHighBit.values();
		for(EnumHighBit enumEnumHighBit : arrEnumBitsAllocatedVal)
		{
			if(shValue == enumEnumHighBit.getValue())
				return enumEnumHighBit;
		}
		return null;
	}

	/**
	 * Retrieves the Enum Value Of Photometric Interpretation
	 * @param shValue short values 
	 * @return enum value of PhotometricInterpretation
	 */
	private EnumPhotometricInterpretation getEnumValueOfPhotometricInterpretation(String shValue)
	{
		EnumPhotometricInterpretation[] arrEnumPhotometricInterpretationVal = EnumPhotometricInterpretation.values();
		for(EnumPhotometricInterpretation enumPhotometricInterpretation : arrEnumPhotometricInterpretationVal)
		{
			if(shValue.equals(enumPhotometricInterpretation.getValue()))
				return enumPhotometricInterpretation;
		}
		return null;
	}

	/**
	 * Retrieves the Enum Value Of Pixel Representation
	 * @param shValue short values 
	 * @return enum value of PixelRepresentation
	 */
	private EnumPixelRepresentation getEnumValueOfPixelRepresentation(short shValue)
	{
		EnumPixelRepresentation[] arrEnumPixelRepresentationVal = EnumPixelRepresentation.values();
		for(EnumPixelRepresentation enumPixelRepresentation : arrEnumPixelRepresentationVal)
		{
			if(shValue == enumPixelRepresentation.getValue())
				return enumPixelRepresentation;
		}
		return null;
	}

	/**
	 * Retrieves the Enum Value Of Samples Per Pixel
	 * @param shValue short values 
	 * @return enum value of SamplesPerPixel
	 */
	private EnumSamplesPerPixel getEnumValueOfSamplesPerPixel(short shValue)
	{
		EnumSamplesPerPixel[] arrEnumSamplesPerPixelVal = EnumSamplesPerPixel.values();
		for(EnumSamplesPerPixel enumSamplesPerPixel : arrEnumSamplesPerPixelVal)
		{
			if(shValue == enumSamplesPerPixel.getValue())
				return enumSamplesPerPixel;
		}
		return null;
	}

	/**
	 * This function populates all the Hard Copy Grayscale image Module for all the Image Box provided.
	 */
	@SuppressWarnings("unchecked")
	private void populateAllHardCopyGrayScaleImage()
	{
		objHardCopyGrayscaleImageModuleCol = new SingleCollection<HardcopyGrayscaleImageModule>();
		String[] strImageBoxSOPInstance = convertToStringArray(objImageBoxCollection.getKeys());
		if(strImageBoxSOPInstance != null)
		{
			for(String strSOPInstance : strImageBoxSOPInstance)
			{
				IDataSet objHardcopyGrayscaleImageDataSet = new DataSet();
				HardcopyGrayscaleImageModule objHardcopyGrayscaleImageModule = new HardcopyGrayscaleImageModule(objHardcopyGrayscaleImageDataSet);

				if(objImageBoxCollection != null)
				{
					IDataSet objIDataSet = objImageBoxCollection.get(strSOPInstance);
					if(objIDataSet != null)
					{
						if(objIDataSet.getDataForTag(0x2020, 0x0110) != null && objIDataSet.getDataForTag(0x2020, 0x0110).getDicomValue() != null)
						{
							BasicGrayscaleImageSequence objBasicGrayscaleImageSequence = (BasicGrayscaleImageSequence)objIDataSet.getDataForTag(0x2020, 0x0110).getDicomValue();
							if(objBasicGrayscaleImageSequence != null)
							{
								ISingleCollection<BasicGrayscaleImageSequenceItem> objBasicGraysacleImageSeqCol = (ISingleCollection<BasicGrayscaleImageSequenceItem>)objBasicGrayscaleImageSequence.getValue();
								if(objBasicGraysacleImageSeqCol.size() >0)
								{
									BasicGrayscaleImageSequenceItem objBasicGrayscaleImageSequenceItem = objBasicGraysacleImageSeqCol.get(0);
									IDataElement objIDataElement = new ImplicitDE(0x0028,0x0002,objBasicGrayscaleImageSequenceItem.getValue(0x0028,0x0002),objBasicGrayscaleImageSequenceItem.getTransferSyntax(),objBasicGrayscaleImageSequenceItem.getDictionaryReader());
									objHardcopyGrayscaleImageDataSet.addDataElement(objIDataElement);
									objIDataElement = new ImplicitDE(0x0028,0x0004,objBasicGrayscaleImageSequenceItem.getValue(0x0028,0x0004),objBasicGrayscaleImageSequenceItem.getTransferSyntax(),objBasicGrayscaleImageSequenceItem.getDictionaryReader());
									objHardcopyGrayscaleImageDataSet.addDataElement(objIDataElement);
									objIDataElement = new ImplicitDE(0x0028,0x0010,objBasicGrayscaleImageSequenceItem.getValue(0x0028,0x0010),objBasicGrayscaleImageSequenceItem.getTransferSyntax(),objBasicGrayscaleImageSequenceItem.getDictionaryReader());
									objHardcopyGrayscaleImageDataSet.addDataElement(objIDataElement);
									objIDataElement = new ImplicitDE(0x0028,0x0011,objBasicGrayscaleImageSequenceItem.getValue(0x0028,0x0011),objBasicGrayscaleImageSequenceItem.getTransferSyntax(),objBasicGrayscaleImageSequenceItem.getDictionaryReader());
									objHardcopyGrayscaleImageDataSet.addDataElement(objIDataElement);
									objIDataElement = new ImplicitDE(0x0028,0x0034,objBasicGrayscaleImageSequenceItem.getValue(0x0028,0x0034),objBasicGrayscaleImageSequenceItem.getTransferSyntax(),objBasicGrayscaleImageSequenceItem.getDictionaryReader());
									objHardcopyGrayscaleImageDataSet.addDataElement(objIDataElement);
									objIDataElement = new ImplicitDE(0x0028,0x0100,objBasicGrayscaleImageSequenceItem.getValue(0x0028,0x0100),objBasicGrayscaleImageSequenceItem.getTransferSyntax(),objBasicGrayscaleImageSequenceItem.getDictionaryReader());
									objHardcopyGrayscaleImageDataSet.addDataElement(objIDataElement);
									objIDataElement = new ImplicitDE(0x0028,0x0101,objBasicGrayscaleImageSequenceItem.getValue(0x0028,0x0101),objBasicGrayscaleImageSequenceItem.getTransferSyntax(),objBasicGrayscaleImageSequenceItem.getDictionaryReader());
									objHardcopyGrayscaleImageDataSet.addDataElement(objIDataElement);
									objIDataElement = new ImplicitDE(0x0028,0x0102,objBasicGrayscaleImageSequenceItem.getValue(0x0028,0x0102),objBasicGrayscaleImageSequenceItem.getTransferSyntax(),objBasicGrayscaleImageSequenceItem.getDictionaryReader());
									objHardcopyGrayscaleImageDataSet.addDataElement(objIDataElement);
									objIDataElement = new ImplicitDE(0x0028,0x0103,objBasicGrayscaleImageSequenceItem.getValue(0x0028,0x0103),objBasicGrayscaleImageSequenceItem.getTransferSyntax(),objBasicGrayscaleImageSequenceItem.getDictionaryReader());
									objHardcopyGrayscaleImageDataSet.addDataElement(objIDataElement);
									objIDataElement = new ImplicitDE(0x7FE0,0x0010,objBasicGrayscaleImageSequenceItem.getValue(0x7FE0,0x0010),objBasicGrayscaleImageSequenceItem.getTransferSyntax(),objBasicGrayscaleImageSequenceItem.getDictionaryReader());
									objHardcopyGrayscaleImageDataSet.addDataElement(objIDataElement);
									objHardCopyGrayscaleImageModuleCol.add(objHardcopyGrayscaleImageModule);
								}
							}
						}
					}
				}
			}
		}
	}

	/**
	 * This function return the Enum Value of Presentation LUT Shape corresponding to the String value of]
	 * Presention LUT Shape Provided.
	 */
	private EnumPresentationLUTShape getPresentationLUTShape(String strPresentationLUTShape)
	{
		if(strPresentationLUTShape != null)
		{
			if(strPresentationLUTShape.equals(EnumPresentationLUTShape.IDENTITY.getValue()))
				return EnumPresentationLUTShape.IDENTITY;
			if(strPresentationLUTShape.equals(EnumPresentationLUTShape.INVERSE.getValue()))
				return EnumPresentationLUTShape.INVERSE;
			if(strPresentationLUTShape.equals(EnumPresentationLUTShape.LIN_OD.getValue()))
				return EnumPresentationLUTShape.LIN_OD;
		}
		return null;
	}

	/**
	 * This function creates the Print Job.
	 */
	IDataSet createPrintJob(Print_DBAgent objPrintDBAgent, String strSOPInstanceUID, PrinterConfiguration objPrinterConfiguration) throws IOException,SQLException
	{
		PrintQueueIOD objPrintQueueIOD = null;

		IDataSet objIDataSet = objPrintDBAgent.retrieveSOPInstance(EnumSOPClassUIDs.PRINTQUEUEMANAGEMENTIOD,null,strPrintQueueSOPInstanceUID);
		if(objIDataSet != null)
		{
			objPrintQueueIOD = new PrintQueueIOD(objIDataSet);
			PrintQueueModule objPrintQueueModule = objPrintQueueIOD.getPrintQueueModule();
			PrintJobDescriptionSequence objPrintJobDescriptionSequence = objPrintQueueModule.getPrintJobDescriptionSequence();

			PrintJobDescriptionSequenceItem objPrintJobDescriptionSequenceItem = objPrintJobDescriptionSequence.getNewItem();
			populatePrintJobDescriptionSequenceItem(objPrintJobDescriptionSequenceItem,objPrinterConfiguration);
			objPrintJobDescriptionSequence.addItem(objPrintJobDescriptionSequenceItem);
		}
		else
		{
			objPrintQueueIOD = new PrintQueueIOD();
			GeneralQueueModule objGeneralQueueModule = objPrintQueueIOD.getGeneralQueueModule();
			populateGeneralQueueModule(objGeneralQueueModule,objPrinterConfiguration);

			PrintQueueModule objPrintQueueModule = objPrintQueueIOD.getPrintQueueModule();
			populatePrintQueueModule(objPrintQueueModule,objPrinterConfiguration);

			SOPCommonModule objSOPCommonModule = objPrintQueueIOD.getSOPCommonModule();
			populateSOPCommonModule(objSOPCommonModule, EnumSOPClassUIDs.PRINTQUEUEMANAGEMENTIOD.getValue(), strPrintQueueSOPInstanceUID);
			objIDataSet = objPrintQueueIOD.getDataSet();

		}
		objPrintDBAgent.createSOPInstance(EnumSOPClassUIDs.PRINTQUEUEMANAGEMENTIOD, objIDataSet, strSOPInstanceUID);
		IDataSet objTempIDataSet = new DataSet();
		IDataTypeSQ objSQ = DicomV3Factory.createInstance().createSequence(0x2100, 0x500, objTempIDataSet.getTransferSyntax());
		IItem objItem = objSQ.getNewItem();
		IDataElement objIDataElement = new ImplicitDE(0x2100,0x0010, strPrintJOBID, objIDataSet.getTransferSyntax(), objIDataSet.getDictionaryReader());
		objItem.addDataElement(objIDataElement);
		objIDataElement = new ImplicitDE(0x0008,0x1155, strSOPInstanceUIDForPrintJob, objIDataSet.getTransferSyntax(), objIDataSet.getDictionaryReader());
		objItem.addDataElement(objIDataElement);
		objIDataElement = new ImplicitDE(0x0008,0x1150, EnumSOPClassUIDs.PRINTJOBIOD.getValue(), objIDataSet.getTransferSyntax(), objIDataSet.getDictionaryReader());
		objItem.addDataElement(objIDataElement);
		objSQ.addItem(objItem);

		objIDataElement = new ImplicitDE(0x2100, 0x500, objSQ, objIDataSet.getTransferSyntax(), objIDataSet.getDictionaryReader());
		objTempIDataSet.addDataElement(objIDataElement);
		return objTempIDataSet;
	}

	/**
	 * This function populates the Print Job Description Sequence Item.
	 */
	@SuppressWarnings("deprecation")
	private void populatePrintJobDescriptionSequenceItem(PrintJobDescriptionSequenceItem objPrintJobDescriptionSequenceItem, PrinterConfiguration objPrinterConfiguration)
	{
		if(objBasicFilmSessionDataSet != null)
		{
			BasicFilmSessionPresentationModule objBasicFilmSessionPresentationModule = new BasicFilmSessionPresentationModule(objBasicFilmSessionDataSet);
			objPrintJobDescriptionSequenceItem.setPrintPriority(objBasicFilmSessionPresentationModule.getPrintPriority());
			objPrintJobDescriptionSequenceItem.setFilmDestination(objBasicFilmSessionPresentationModule.getFilmDestination());
			objPrintJobDescriptionSequenceItem.setFilmSessionLabel(objBasicFilmSessionPresentationModule.getFilmSessionLabel());
			objPrintJobDescriptionSequenceItem.setMediumType(objBasicFilmSessionPresentationModule.getMediumType());
			objPrintJobDescriptionSequenceItem.setOwnerID(objBasicFilmSessionPresentationModule.getOwnerID());
			Date objDate = new Date();
			int iDate = objDate.getDate();
			long iTime = objDate.getTime();
			objPrintJobDescriptionSequenceItem.setCreationDate(""+iDate);
			objPrintJobDescriptionSequenceItem.setCreationDate(""+iTime);
			objPrintJobDescriptionSequenceItem.setExecutionStatus(EnumExecutionStatus.PENDING);;
			objPrintJobDescriptionSequenceItem.setExecutionStatusInfo(EnumExecutionStatusInfo.EXECUTION_STATUS_DONE_OR_PRINTING);
			ReferencedPrintJobSequence objReferencedPrintJobSequence = objPrintJobDescriptionSequenceItem.getReferencedPrintJobSequence();
			ReferencedPrintJobSequenceItem objReferencedPrintJobSequenceItem = objReferencedPrintJobSequence.getNewItem();
			objReferencedPrintJobSequenceItem.setReferencedSOPClassUID(EnumSOPClassUIDs.PRINTJOBIOD.getValue());
			strSOPInstanceUIDForPrintJob = createSOPInstanceUID(EnumSOPClassUIDs.PRINTJOBIOD.getValue());
			objReferencedPrintJobSequenceItem.setReferencedSOPInstanceUID(strSOPInstanceUIDForPrintJob);
			objReferencedPrintJobSequence.addItem(objReferencedPrintJobSequenceItem);

			strPrintJOBID = StandardMethods.generateUUID();
			objPrintJobDescriptionSequenceItem.setPrintJobID(strPrintJOBID);
			if(objPrinterConfiguration != null && objPrinterConfiguration.getPrinterIOD() != null)
			{
				String strPrinterName = objPrinterConfiguration.getPrinterIOD().getPrinterModule().getPrinterName();
				objPrintJobDescriptionSequenceItem.setPrinterName(strPrinterName);
			}
		}
		else
		{
			DicomLogger objDicomLogger = DicomLogger.getLogger();
			objDicomLogger.log(ResourceBundleWrapper.getValue("exceptions", "PrintJobCreationFailure", new Locale(DicomConfig.createInstance().getLocale())));
			throw new SourceException();
		}
	}

	/**
	 * This function populates the General Queue Module.
	 */
	private void populateGeneralQueueModule(GeneralQueueModule objGeneralQueueModule,PrinterConfiguration objPrinterConfiguration)
	{
		if(objPrinterConfiguration != null && objPrinterConfiguration.getQueueStatus() != null)
			objGeneralQueueModule.setQueueStatus(objPrinterConfiguration.getQueueStatus());
		else
			objGeneralQueueModule.setQueueStatus(EnumQueueStatus.NORMAL);
	}

	/**
	 * This function populates the Print Queue Module.
	 */
	private void populatePrintQueueModule(PrintQueueModule objPrintQueueModule, PrinterConfiguration objPrinterConfiguration)
	{
		PrintJobDescriptionSequence objPrintJobDescriptionSequence = objPrintQueueModule.getPrintJobDescriptionSequence();
		PrintJobDescriptionSequenceItem objPrintJobDescriptionSequenceItem = objPrintJobDescriptionSequence.getNewItem();
		populatePrintJobDescriptionSequenceItem(objPrintJobDescriptionSequenceItem,objPrinterConfiguration);
		objPrintJobDescriptionSequence.addItem(objPrintJobDescriptionSequenceItem);
	}

	/**
	 * This method generates the SOP Instance UID.
	 */
	private String createSOPInstanceUID(String strAffectedSOPClassUID)
	{
		String strSOPInstanceUID = strAffectedSOPClassUID +"."+ ((new Date()).getTime());
		return strSOPInstanceUID;
	}
}