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

import java.io.IOException;
import java.util.Locale;

import cdac.medinfo.sdk.dcm30_04.baselibs.ChannelDefinitionSequenceItem;
import cdac.medinfo.sdk.dcm30_04.baselibs.CodeSequenceMacro;
import cdac.medinfo.sdk.dcm30_04.baselibs.CodeSequenceMacroDependentItem;

import cdac.medinfo.sdk.dcm30_04.baselibs.WaveformAnnotationSequenceItem;
import cdac.medinfo.sdk.dcm30_04.baselibs.WaveformSequenceItem;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataSet;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDicomStream;
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.AcquisitionContextModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.ClinicalTrialSeriesModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.GeneralEquipmentModule;
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.NonImageIOD;
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.SOPCommonModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.SynchronizationModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.WaveformAnnotationModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.WaveformIdentificationModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.WaveformModule;
import cdac.medinfo.sdk.dcm30_04.enums.EnumModality;
import cdac.medinfo.sdk.dcm30_04.enums.EnumModuleNames;

import cdac.medinfo.sdk.dcm30_04.enums.EnumWaveformSampleInterpretation;
import cdac.medinfo.sdk.dcm30_04.exceptions.InvalidIODException;
import cdac.medinfo.sdk.dcm30_04.exceptions.InvalidModuleException;
import cdac.medinfo.sdk.dcm30_04.exceptions.ParseException;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConfig;
import cdac.medinfo.sdk.dcm30_04.utils.DicomLogger;

import cdac.medinfo.sdk.dcm30_04.utils.ICollectionIterator;
import cdac.medinfo.sdk.dcm30_04.utils.ResourceBundleWrapper;

/**
 * The Basic Cardiac IOD is the specification of digitized electrical signals from
 * the patient cardiac conduction system collected in the heart, which has been acquired by an EP
 * modality.
 */
public class BasicCardiacEPIOD extends NonImageIOD 
{
	

	/**
	 * The Constant BASIC_CARDIAC_EP_IOD.
	 */
	public static final String BASIC_CARDIAC_EP_IOD = "Basic Cardiac EP IOD";

	/**
	 * The obj patient module.
	 */
	PatientModule objPatientModule = null;

	/**
	 * The obj general study module.
	 */
	GeneralStudyModule objGeneralStudyModule = null;

	/**
	 * The obj patient study module.
	 */
	PatientStudyModule objPatientStudyModule = null;

	/**
	 * The obj general series module.
	 */
	GeneralSeriesModule objGeneralSeriesModule = null;

	/**
	 * The obj clinical trial series module.
	 */
	ClinicalTrialSeriesModule objClinicalTrialSeriesModule = null;

	/**
	 * The obj synchronization module.
	 */
	SynchronizationModule objSynchronizationModule = null;

	/**
	 * The obj general equipment module.
	 */
	GeneralEquipmentModule objGeneralEquipmentModule = null;

	/**
	 * The obj acquisition context module.
	 */
	AcquisitionContextModule objAcquisitionContextModule = null;

	/**
	 * The obj sop common module.
	 */
	SOPCommonModule objSOPCommonModule = null;

	/**
	 * The obj waveform identification module.
	 */
	WaveformIdentificationModule objWaveformIdentificationModule = null;

	/**
	 * The obj waveform annotation module.
	 */
	WaveformAnnotationModule objWaveformAnnotationModule = null;

	/**
	 * The obj waveform module.
	 */
	WaveformModule objWaveformModule = null;

	/**
	 * Instantiates a new basic cardiac epiod.
	 */
	public BasicCardiacEPIOD()
	{
		super();
	}

	/**
	 * This constructor initializes the TransferSyntax  in its superclass IOD.
	 * 
	 * @param objITransferSyntax_ - specifies the DICOM Standard defined TransfeSyntax.
	 */
	public BasicCardiacEPIOD(ITransferSyntax objITransferSyntax_)
	{
		super(objITransferSyntax_);
	}

	/**
	 * This constructor initializes the  DictionaryReader
	 * in its superclass IOD.
	 * 
	 * @param objIDictionaryReader_ - specifies the DICOM Dictionary reader to be used .
	 */
	public BasicCardiacEPIOD(IDictionaryReader objIDictionaryReader_)
	{
		super(objIDictionaryReader_);
	}

	/**
	 * This constructor accepts the DataSet from the user   in its superclass IOD.
	 * 
	 * @param objIDataSet_ - specifies the data set to be set in the IOD.
	 */
	public BasicCardiacEPIOD(IDataSet objIDataSet_)
	{
		super(objIDataSet_);
	}

	/**
	 * This constructor initializes the TransferSyntax and DictionaryReader in its super class IOD.
	 * 
	 * @param objITransferSyntax_ specifies the DICOM Standard defined TransfeSyntax.
	 * @param objIDictionaryReader_ specifies the DICOM Dictionary reader to be used .
	 */
	public BasicCardiacEPIOD(ITransferSyntax objITransferSyntax_,IDictionaryReader objIDictionaryReader_)
	{
		super(objITransferSyntax_,objIDictionaryReader_);
	}

	/**
	 * Creates BasicCardiacEPIOD IOD from a DICOM file containing BasicCardiacEPIOD DICOM data.
	 * @param strFileName DICOM File with absolute path.
	 * @throws IOException Exception caused due to wrong I/O operations. 
	 * @throws ParseException signals if some parse exceptions are occurred.
	 * @throws InvalidIODException signals if some IOD exceptions are occurred.
	 */
	public BasicCardiacEPIOD(String strFileName)throws IOException,InvalidIODException
	{
		super(strFileName);
	}


	/**
	 * Retrieves pre-initialized instance of Patient Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return - instance of {@link PatientModule}.
	 */
	public PatientModule getPatientModule()
	{
		if(objPatientModule == null)
		{
			objPatientModule = new PatientModule(objIDataSet);
			return objPatientModule;
		}
		return objPatientModule;
	}

	/**
	 * Retrieves pre-initialized instance of General Study Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return - instance of {@link GeneralStudyModule}.
	 */
	public GeneralStudyModule getGeneralStudyModule()
	{
		if(objGeneralStudyModule == null)
		{
			objGeneralStudyModule = new GeneralStudyModule(objIDataSet);
			return objGeneralStudyModule;
		}
		return objGeneralStudyModule;
	}

	/**
	 * Retrieves pre-initialized instance of Patient Study Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return - instance of {@link PatientStudyModule}.
	 */
	public PatientStudyModule getPatientStudyModule()
	{
		if(objPatientStudyModule == null)
		{
			objPatientStudyModule = new PatientStudyModule(objIDataSet);
			return objPatientStudyModule;
		}
		return objPatientStudyModule;
	}

	/**
	 * Retrieves pre-initialized instance of General Series Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return - instance of {@link GeneralSeriesModule}.
	 */
	public GeneralSeriesModule getGeneralSeriesModule()
	{
		if(objGeneralSeriesModule == null)
		{
			objGeneralSeriesModule = new GeneralSeriesModule(objIDataSet);
			return objGeneralSeriesModule;
		}
		return objGeneralSeriesModule;
	}

	/**
	 * Retrieves pre-initialized instance of Clinical Trial Series Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return - instance of {@link ClinicalTrialSeriesModule}.
	 */
	public ClinicalTrialSeriesModule getClinicalTrialSeriesModule()
	{
		if(objClinicalTrialSeriesModule == null)
		{
			objClinicalTrialSeriesModule = new ClinicalTrialSeriesModule(objIDataSet);
			return objClinicalTrialSeriesModule;
		}
		return objClinicalTrialSeriesModule;
	}

	/**
	 * Retrieves pre-initialized instance of SOP Common Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return - instance of {@link SOPCommonModule}.
	 */
	public SOPCommonModule getSOPCommonModule()
	{
		if(objSOPCommonModule == null)
		{
			objSOPCommonModule = new SOPCommonModule(objIDataSet);
			return objSOPCommonModule;
		}
		return objSOPCommonModule;
	}

	/**
	 * Retrieves pre-initialized instance of General Equipment Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return - instance of {@link GeneralEquipmentModule}.
	 */
	public GeneralEquipmentModule getGeneralEquipmentModule()
	{
		if(objGeneralEquipmentModule == null)
		{
			objGeneralEquipmentModule = new GeneralEquipmentModule(objIDataSet);
			return objGeneralEquipmentModule;
		}
		return objGeneralEquipmentModule;
	}

	/**
	 * Retrieves pre-initialized instance of Synchronization Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return - instance of {@link SynchronizationModule}.
	 */
	public SynchronizationModule getSynchronizationModule()
	{
		if(objSynchronizationModule == null)
		{
			objSynchronizationModule = new SynchronizationModule(objIDataSet);
			return objSynchronizationModule;
		}
		return objSynchronizationModule;
	}

	/**
	 * Retrieves pre-initialized instance of Acquisition Context Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return - instance of {@link AcquisitionContextModule}.
	 */
	public AcquisitionContextModule getAcquisitionContextModule()
	{
		if(objAcquisitionContextModule == null)
		{
			objAcquisitionContextModule = new AcquisitionContextModule(objIDataSet);
			return objAcquisitionContextModule;
		}
		return objAcquisitionContextModule;
	}

	/**
	 * Retrieves pre-initialized instance of Waveform Annotation Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return - instance of {@link WaveformAnnotationModule}.
	 */
	public WaveformAnnotationModule getWaveformAnnotationModule()
	{
		if(objWaveformAnnotationModule == null)
		{
			objWaveformAnnotationModule = new WaveformAnnotationModule(objIDataSet);
			return objWaveformAnnotationModule;
		}
		return objWaveformAnnotationModule;
	}

	/**
	 * Retrieves pre-initialized instance of Waveform Identification Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return - instance of {@link WaveformIdentificationModule}.
	 */
	public WaveformIdentificationModule getWaveformIdentificationModule()
	{
		if(objWaveformIdentificationModule == null)
		{
			objWaveformIdentificationModule = new WaveformIdentificationModule(objIDataSet);
			return objWaveformIdentificationModule;
		}
		return objWaveformIdentificationModule;
	}

	/**
	 * Retrieves pre-initialized instance of Waveform Module. Creates a new instance
	 * if no pre-existing module instance is available.If previously created instance is
	 * present then returns the same module instance.
	 * 
	 * @return - instance of {@link WaveformModule}.
	 */
	public WaveformModule getWaveformModule()
	{
		if(objWaveformModule == null)
		{
			objWaveformModule = new WaveformModule(objIDataSet);
			return objWaveformModule;
		}
		return objWaveformModule;
	}

	/**
	 * This method validates Twelve Lead ECG IOD according to the Module Table given in The DICOM Standard.
	 * The validate method fails if one of the mandatory modules are absent or any of the
	 * modules are invalid.The validate method also checks for conditional modules.
	 * 
	 * @return - function status indicating success or failure.
	 * 
	 * @throws InvalidIODException the invalid iod exception
	 */
	public boolean validate() throws InvalidIODException
	{
		try
		{
			super.validate();	
			/*
			 * This condition checks for mandatory modules validation
			 */
			getPatientModule().validateModule();
			getGeneralSeriesModule().validateModule();
			getGeneralStudyModule().validateModule();
			getGeneralEquipmentModule().validateModule();
			getWaveformIdentificationModule().validateModule();
			getWaveformModule().validateModule();
			getAcquisitionContextModule().validateModule();
			getSOPCommonModule().validateModule();

			/*
			 * This condition checks for User Optional/Conditional modules validation
			 * For conditional modules, first the presence of the modules should be checked. Because
			 * absence of optional modules is not a problem whereas presence but invalid status of the
			 * optional module is a problem.
			 */

			/*
			 * Waveform Annotation C required if annotation is present. How to find annotation is Present.
			 */
			if(isModulePresent(ClinicalTrialSeriesModule.objSingleCollection, objIDataSet))
				getClinicalTrialSeriesModule().validateModule();
			if(isModulePresent(PatientStudyModule.objSingleCollection, objIDataSet))
				getPatientStudyModule().validateModule();
			if(isModulePresent(SynchronizationModule.objSingleCollection, objIDataSet))
				getSynchronizationModule().validateModule();
			if(isModulePresent(WaveformAnnotationModule.objSingleCollection, objIDataSet))
				getWaveformAnnotationModule().validateModule();

			String strModality = getGeneralSeriesModule().getModality();
			if(!strModality.equalsIgnoreCase(EnumModality.CARDIAC_ELECTROPHYSIOLOGY.getValue()))
				throw new InvalidIODException("The value of Modality shall be " + EnumModality.CARDIAC_ELECTROPHYSIOLOGY.getValue());

			ICollectionIterator<IItem> objWaveformSequenceIterator = getWaveformModule().getWaveformSequence().iterator();
			int iNoOfItem = 0;
			WaveformSequenceItem objWaveformSequenceItem = null;
			while(objWaveformSequenceIterator.hasNext())
			{
				objWaveformSequenceItem = (WaveformSequenceItem)objWaveformSequenceIterator.next();
				iNoOfItem++;

				int iSamplingFrequency = Integer.parseInt(objWaveformSequenceItem.getSamplingFrequency());
				if(iSamplingFrequency > 2000)
					throw new InvalidIODException("The value of the Sampling Frequency (003A,001A) in each Waveform Sequence Item shall be less than or equal to 2000");

				String strWaveformSampleInterpretation = objWaveformSequenceItem.getWaveformSampleInterpretation();
				if(!strWaveformSampleInterpretation.equalsIgnoreCase(EnumWaveformSampleInterpretation.SIGNED_SIXTEEN_BIT_LINEAR.getValue()))
					throw new InvalidIODException("The value of the Waveform Sample Interpretation (5400,1006) in each Waveform Sequence Item shall be " + EnumWaveformSampleInterpretation.SIGNED_SIXTEEN_BIT_LINEAR.getValue());

				ICollectionIterator<IItem> objChannelDefinitionSequenceIterator = objWaveformSequenceItem.getChannelDefinitionSequence().iterator();
				ChannelDefinitionSequenceItem objChannelDefinitionSequenceItem = null;
				while(objChannelDefinitionSequenceIterator.hasNext())
				{
					objChannelDefinitionSequenceItem = (ChannelDefinitionSequenceItem)objChannelDefinitionSequenceIterator.next();
					ICollectionIterator<IItem> objChannelSourceSequenceIterator = objChannelDefinitionSequenceItem.getChannelSourceSequence().iterator();
					CodeSequenceMacroDependentItem objCodeSequenceMacroDependentItem = null;
					while(objChannelSourceSequenceIterator.hasNext())
					{
						objCodeSequenceMacroDependentItem = (CodeSequenceMacroDependentItem)objChannelSourceSequenceIterator.next();
						CodeSequenceMacro objCodeSequenceMacro = objCodeSequenceMacroDependentItem.getCodeSequenceMacro();
						if(objCodeSequenceMacro != null)
						{
							String strContextID = objCodeSequenceMacro.getContextIdentifier();
							if(strContextID != null)
							{
								if(!strContextID.equalsIgnoreCase("CID 3011"))
									throw new InvalidIODException("Context ID for the Channel Source Sequence (003A,0208) in each Channel Definition Sequence Item shall be CID 3011");
							}
						}
					}
				}
			}

			ICollectionIterator<IItem> objWaveformAnnotationSequenceIterator =getWaveformAnnotationModule().getWaveformAnnotationSequence().iterator();
			WaveformAnnotationSequenceItem objWaveformAnnotationSequenceItem = null;
			while(objWaveformAnnotationSequenceIterator.hasNext())
			{
				objWaveformAnnotationSequenceItem = (WaveformAnnotationSequenceItem)objWaveformAnnotationSequenceIterator.next();
				ICollectionIterator<IItem> objConceptNameCodeSequenceIterator = objWaveformAnnotationSequenceItem.getConceptNameCodeSequence().iterator();
				CodeSequenceMacroDependentItem objCodeSequenceMacroDependentItem = null;
				while(objConceptNameCodeSequenceIterator.hasNext())
				{
					objCodeSequenceMacroDependentItem = (CodeSequenceMacroDependentItem)objConceptNameCodeSequenceIterator.next();
					CodeSequenceMacro objCodeSequenceMacro = objCodeSequenceMacroDependentItem.getCodeSequenceMacro();
					if(objCodeSequenceMacro != null)
					{
						String strContextID = objCodeSequenceMacro.getContextIdentifier();
						if(strContextID != null)
						{
							if(!strContextID.equalsIgnoreCase("CID 3339"))
								throw new InvalidIODException("Context ID Concept Name Code Sequence (0040,A043) in the Waveform Annotation Sequence (0040,B020) shall be CID 3339");
						}
					}
				}
			}

			if(iNoOfItem < 1 && iNoOfItem >4)
				throw new InvalidIODException("The number of Waveform Sequence (5400,0100) Items shall be between 1 and 4");

			/*
			 * IOD Constraints
			 * Acquisition Context Module 
			 * The Defined Template for Acquisition Context Sequence (0040,0555) is TID 3450.
			 * please refer chapter 3 page No 166.
			 */
		}
		catch(InvalidModuleException ime)
		{
			if(DicomConfig.createInstance().isLoggingOn())
				DicomLogger.getLogger().log(ime.getMessage());
			
			{
				String strMessage = BASIC_CARDIAC_EP_IOD;
				throw new InvalidIODException(strMessage, ime);
			}
		}
		return true;
	}

	/**
	 *  Dumps the Name of IOD,Module and corresponding Attributs of Module.
	 *  @param objIDicomStream - the Stream on which the Data is to be written.
	 *  @throws IOException - Exception is thrown indicating runtime failure of writing operation.
	 */
	public void dumpDICOMInfo(IDicomStream objIDicomStream) throws IOException
	{
		objIDicomStream.writeString(BASIC_CARDIAC_EP_IOD + "\n");
		super.dumpDICOMInfo(objIDicomStream);

		objIDicomStream.writeString("\t" + getPatientModule().getClass().getSimpleName() + "\n");
		getPatientModule().dumpDICOMInfo(objIDicomStream);

		objIDicomStream.writeString("\t" + getGeneralStudyModule().getClass().getSimpleName() + "\n");
		getGeneralStudyModule().dumpDICOMInfo(objIDicomStream);

		objIDicomStream.writeString("\t" + getPatientStudyModule().getClass().getSimpleName() + "\n");
		getPatientStudyModule().dumpDICOMInfo(objIDicomStream);

		objIDicomStream.writeString("\t" + getGeneralSeriesModule().getClass().getSimpleName() + "\n");
		getGeneralSeriesModule().dumpDICOMInfo(objIDicomStream);

		objIDicomStream.writeString("\t" + getClinicalTrialSeriesModule().getClass().getSimpleName() + "\n");
		getClinicalTrialSeriesModule().dumpDICOMInfo(objIDicomStream);

		objIDicomStream.writeString("\t" + getSynchronizationModule().getClass().getSimpleName() + "\n");
		getSynchronizationModule().dumpDICOMInfo(objIDicomStream);

		objIDicomStream.writeString("\t" + getGeneralEquipmentModule().getClass().getSimpleName() + "\n");
		getGeneralEquipmentModule().dumpDICOMInfo(objIDicomStream);

		objIDicomStream.writeString("\t" + getWaveformIdentificationModule().getClass().getSimpleName() + "\n");
		getWaveformIdentificationModule().dumpDICOMInfo(objIDicomStream);

		objIDicomStream.writeString("\t" + getWaveformModule().getClass().getSimpleName() + "\n");
		getWaveformModule().dumpDICOMInfo(objIDicomStream);

		objIDicomStream.writeString("\t" + getAcquisitionContextModule().getClass().getSimpleName() + "\n");
		getAcquisitionContextModule().dumpDICOMInfo(objIDicomStream);

		objIDicomStream.writeString("\t" + getWaveformAnnotationModule().getClass().getSimpleName() + "\n");
		getWaveformAnnotationModule().dumpDICOMInfo(objIDicomStream);

		objIDicomStream.writeString("\t" + getSOPCommonModule().getClass().getSimpleName() + "\n");
		getSOPCommonModule().dumpDICOMInfo(objIDicomStream);
	}

	/**
	 * Checks whether the Module is present in the IOD or not.
	 * @param strModuleName String value of module name 
	 * @return boolean - true if the module is present in the IOD, else false is returned.
	 */
	public boolean isModulePresent(String strModuleName)
	{
		if(!super.isModulePresent(strModuleName))
		{
			if(strModuleName == null || strModuleName.equals(""))
				return false;
			if(strModuleName.equalsIgnoreCase(EnumModuleNames.PATIENT_MODULE.getValue()) && isModulePresent(PatientModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.GENERAL_STUDY_MODULE.getValue()) && isModulePresent(GeneralStudyModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.PATIENT_STUDY_MODULE.getValue()) && isModulePresent(PatientStudyModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.GENERAL_SERIES_MODULE.getValue()) && isModulePresent(GeneralSeriesModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.CLINICAL_TRIAL_SERIES_MODULE.getValue()) && isModulePresent(ClinicalTrialSeriesModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.SYNCHRONIZATION_MODULE.getValue()) && isModulePresent(SynchronizationModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.GENERAL_EQUIPMENT_MODULE.getValue()) && isModulePresent(GeneralEquipmentModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.ACQUISITION_CONTEXT_MODULE.getValue()) && isModulePresent(AcquisitionContextModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.WAVEFORM_ANNOTATION_MODULE.getValue()) && isModulePresent(WaveformAnnotationModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.WAVEFORM_MODULE.getValue()) && isModulePresent(WaveformModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.SOP_COMMON_MODULE.getValue()) && isModulePresent(SOPCommonModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.WAVEFORM_IDENTIFICATION_MODULE.getValue()) && isModulePresent(WaveformIdentificationModule.objSingleCollection))
				return true;
			else
			{
				if(DicomConfig.createInstance().isLoggingOn())
				{
					DicomLogger objDicomLogger = DicomLogger.getLogger();
					objDicomLogger.log(this.getClass().getName() + " : " +ResourceBundleWrapper.getValue("status","ModuleNotPresent",new Locale(DicomConfig.createInstance().getLocale())) + strModuleName);
				}
				return false;
			}
		}
		return true;
	}
}
