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

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

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.ITransferSyntax;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.CalculatedDoseReferenceRecordModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.ClinicalTrialSeriesModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.CommonInstanceReferenceModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.GeneralEquipmentModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.GeneralStudyModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.MeasuredDoseReferenceRecordModule;
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.RTIonBeamsSessionRecordModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.RTGeneralTreatmentRecordModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.RTPatientSetupModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.RTSeriesModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.RTTreatmentMachineRecordModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.RTTreatmentSummaryRecordModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.SOPCommonModule;
import cdac.medinfo.sdk.dcm30_04.enums.EnumModuleNames;
import cdac.medinfo.sdk.dcm30_04.enums.EnumSOPClassUIDs;

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.ResourceBundleWrapper;
/**
 * The Radiotherapy Ion Beams Treatment Record IOD (RT Ion Beams Treatment Record IOD) addresses the requirements for transferof treatment session reports generated by a treatment verification system during a course of Ion beam treatment, with optional cumu-lative summary information. It may also be used for transfer of treatment information during delivery.
 * @author saloni
 *
 */
public class RTIonBeamsTreatmentRecordIOD extends NonImageIOD
{

	/**
	 * The Constant INVALID_RT_BEAMS_TREATMENT_RECORD_IOD.
	 */
	public static final String RT_ION_BEAMS_TREATMENT_RECORD_IOD = "RT Ion Beams Treatment Record 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 rt series module.
	 */
	RTSeriesModule objRTSeriesModule = null;
	/**
	 * The obj clinical trial series module.
	 */
	ClinicalTrialSeriesModule objClinicalTrialSeriesModule = null;
	/**
	 * The obj general equipment module.
	 */
	GeneralEquipmentModule objGeneralEquipmentModule = null;
	/**
	 * The obj rt general treatment record module.
	 */
	RTGeneralTreatmentRecordModule objRTGeneralTreatmentRecordModule = null;
	/**
	 * The obj rt patient setup module.
	 */
	RTPatientSetupModule objRTPatientSetupModule = null;
	/**
	 * The obj rt treatment machine record module.
	 */
	RTTreatmentMachineRecordModule objRTTreatmentMachineRecordModule = null;
	/**
	 * The obj measured dose reference record module.
	 */
	MeasuredDoseReferenceRecordModule objMeasuredDoseReferenceRecordModule = null;	
	/**
	 * The obj calculated dose reference record module.
	 */
	CalculatedDoseReferenceRecordModule objCalculatedDoseReferenceRecordModule = null;

	/**
	 * The obj RT Ion Beams Session Record module.
	 */
	RTIonBeamsSessionRecordModule objRTIonBeamsSessionRecordModule = null;
	/**
	 * The obj rt treatment summary record module.
	 */
	RTTreatmentSummaryRecordModule objRTTreatmentSummaryRecordModule = null;
	/**
	 * The obj sop common module.
	 */
	SOPCommonModule objSOPCommonModule = null;
	/**
	 * The obj Common Instance Reference module.
	 */
	CommonInstanceReferenceModule objCommonInstanceReferenceModule = null;


	/**
	 * Instantiates a new RTIonBeamsTreatmentRecordIOD
	 */
	public RTIonBeamsTreatmentRecordIOD()
	{
		super();
	}

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

	/**
	 * This constructor initializes the  DictionaryReader
	 * in its superclass IOD.
	 * 
	 * @param objIDictionaryReader_ - specifies the DICOM Dictionary reader to be used .
	 */
	public RTIonBeamsTreatmentRecordIOD(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 RTIonBeamsTreatmentRecordIOD(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 RTIonBeamsTreatmentRecordIOD(ITransferSyntax objITransferSyntax_,IDictionaryReader objIDictionaryReader_)
	{
		super(objITransferSyntax_,objIDictionaryReader_);
	}

	/**
	 * Creates RTIonBeamsTreatmentRecordIOD IOD from a DICOM file containing RTIonBeamsTreatmentRecordIOD 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 RTIonBeamsTreatmentRecordIOD(String strFileName)throws IOException,InvalidIODException
	{
		super(strFileName);
		try
		{
			if(objIDataSet != null)
			{
				String strSOPClassUID = objIDataSet.getSOPClassUID();
				if(strSOPClassUID != null)
				{
					if(!strSOPClassUID.equals(EnumSOPClassUIDs.RTIONBEAMSTREATMENTRECORDIOD.getValue()))
					{
						throw new InvalidIODException(ResourceBundleWrapper.getValue("exceptions", "InvalidIOD.FileNotMatched", new Locale(DicomConfig.createInstance().getLocale())) + RT_ION_BEAMS_TREATMENT_RECORD_IOD);
					}
				}
				strSOPClassUID = null;
			}
		}
		catch(InvalidIODException iie)
		{
			if(DicomConfig.createInstance().isLoggingOn())
			{
				DicomLogger.getLogger().log(iie.getMessage());
			}
			throw iie;
		}
	}

	/**
	 * 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 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 Image Pixel 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 CommonInstanceReferenceModule}.
	 */
	public CommonInstanceReferenceModule getCommonInstanceReferenceModule()
	{
		if(objCommonInstanceReferenceModule == null)
		{
			objCommonInstanceReferenceModule = new CommonInstanceReferenceModule(objIDataSet);
			return objCommonInstanceReferenceModule;
		}
		return objCommonInstanceReferenceModule;
	}


	/**
	 * Retrieves pre-initialized instance of Calculated Dose Reference Record 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 CalculatedDoseReferenceRecordModule}.
	 */
	public CalculatedDoseReferenceRecordModule getCalculatedDoseReferenceRecordModule() 
	{
		if(objCalculatedDoseReferenceRecordModule == null)
		{
			objCalculatedDoseReferenceRecordModule = new CalculatedDoseReferenceRecordModule(objIDataSet);
			return objCalculatedDoseReferenceRecordModule;
		}
		return objCalculatedDoseReferenceRecordModule;
	}
	/**
	 * Retrieves pre-initialized instance of Measured Dose Reference Record 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 MeasuredDoseReferenceRecordModule}.
	 */
	public MeasuredDoseReferenceRecordModule getMeasuredDoseReferenceRecordModule() 
	{
		if(objMeasuredDoseReferenceRecordModule == null)
		{
			objMeasuredDoseReferenceRecordModule = new MeasuredDoseReferenceRecordModule(objIDataSet);
			return objMeasuredDoseReferenceRecordModule;
		}
		return objMeasuredDoseReferenceRecordModule;
	}


	/**
	 * Retrieves pre-initialized instance of RT Beams Session Record 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 RTIonBeamsSessionRecordModule}.
	 */
	public RTIonBeamsSessionRecordModule getRTIonBeamsSessionRecordModule()
	{
		if(objRTIonBeamsSessionRecordModule == null)
		{
			objRTIonBeamsSessionRecordModule = new RTIonBeamsSessionRecordModule(objIDataSet);
			return objRTIonBeamsSessionRecordModule;
		}
		return objRTIonBeamsSessionRecordModule;
	}

	/**
	 * Retrieves pre-initialized instance of RT General Treatment Record 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 RTGeneralTreatmentRecordModule}.
	 */
	public RTGeneralTreatmentRecordModule getRTGeneralTreatmentRecordModule()
	{
		if(objRTGeneralTreatmentRecordModule == null)
		{
			objRTGeneralTreatmentRecordModule = new RTGeneralTreatmentRecordModule(objIDataSet);
			return objRTGeneralTreatmentRecordModule;
		}
		return objRTGeneralTreatmentRecordModule;
	}

	/**
	 * Retrieves pre-initialized instance of RT Patient Setup 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 RTPatientSetupModule}.
	 */
	public RTPatientSetupModule getRTPatientSetupModule() {
		if(objRTPatientSetupModule == null)
		{
			objRTPatientSetupModule = new RTPatientSetupModule(objIDataSet);
			return objRTPatientSetupModule;
		}
		return objRTPatientSetupModule;
	}

	/**
	 * Retrieves pre-initialized instance of RT 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 RTSeriesModule}.
	 */
	public RTSeriesModule getRTSeriesModule() {
		if(objRTSeriesModule == null)
		{
			objRTSeriesModule = new RTSeriesModule(objIDataSet);
			return objRTSeriesModule;
		}
		return objRTSeriesModule;
	}

	/**
	 * Retrieves pre-initialized instance of RT Treatment Machine Record 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 RTTreatmentMachineRecordModule}.
	 */
	public RTTreatmentMachineRecordModule getRTTreatmentMachineRecordModule() 
	{
		if(objRTTreatmentMachineRecordModule == null)
		{
			objRTTreatmentMachineRecordModule = new RTTreatmentMachineRecordModule(objIDataSet);
			return objRTTreatmentMachineRecordModule;
		}
		return objRTTreatmentMachineRecordModule;
	}

	/**
	 * Retrieves pre-initialized instance of RT Treatment Summary Record 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 RTTreatmentSummaryRecordModule}.
	 */
	public RTTreatmentSummaryRecordModule getRTTreatmentSummaryRecordModule() 
	{
		if(objRTTreatmentSummaryRecordModule == null)
		{
			objRTTreatmentSummaryRecordModule = new RTTreatmentSummaryRecordModule(objIDataSet);
			return objRTTreatmentSummaryRecordModule;
		}
		return objRTTreatmentSummaryRecordModule;
	}

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

	/**
	 * This method validates RTIonBeamsTreatmentRecordIOD 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();
			getGeneralStudyModule().validateModule();
			getRTSeriesModule().validateModule();
			getGeneralEquipmentModule().validateModule();
			getRTGeneralTreatmentRecordModule().validateModule();
			getRTTreatmentMachineRecordModule().validateModule();
			getRTIonBeamsSessionRecordModule().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.
			 */
			if(isModulePresent(PatientStudyModule.objSingleCollection, objIDataSet))
			{
				getPatientStudyModule().validateModule();
			}
			if(isModulePresent(ClinicalTrialSeriesModule.objSingleCollection, objIDataSet))
			{
				getClinicalTrialSeriesModule().validateModule();
			}
			if(isModulePresent(RTPatientSetupModule.objSingleCollection, objIDataSet))
			{
				getRTPatientSetupModule().validateModule();
			}
			if(isModulePresent(MeasuredDoseReferenceRecordModule.objSingleCollection, objIDataSet))
			{
				getMeasuredDoseReferenceRecordModule().validateModule();
			}
			if(isModulePresent(CalculatedDoseReferenceRecordModule.objSingleCollection, objIDataSet))
			{
				getCalculatedDoseReferenceRecordModule().validateModule();
			}
			if(isModulePresent(RTTreatmentSummaryRecordModule.objSingleCollection, objIDataSet))
			{
				getRTTreatmentSummaryRecordModule().validateModule();
			}
			if(isModulePresent(CommonInstanceReferenceModule.objSingleCollection, objIDataSet))
			{
				getCommonInstanceReferenceModule().validateModule();
			}
		}
		catch(InvalidModuleException ime)
		{
			if(DicomConfig.createInstance().isLoggingOn())
				DicomLogger.getLogger().log(ime.getMessage());
			
			{
				String strMessage = RT_ION_BEAMS_TREATMENT_RECORD_IOD;
				throw new InvalidIODException(strMessage, ime);
			}
		}
		return true;
	}

	/**
	 *  Dumps the Name of IOD,Module and corresponding Attributes 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(RT_ION_BEAMS_TREATMENT_RECORD_IOD + "\n");
		super.dumpDICOMInfo(objIDicomStream);

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

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

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

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

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

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

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

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

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

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

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

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

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

		objIDicomStream.writeString("\t" + getSOPCommonModule().getClass().getSimpleName() + "\n");
		getSOPCommonModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getCommonInstanceReferenceModule().getClass().getSimpleName() + "\n");
		getCommonInstanceReferenceModule().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.CALCULATED_DOSE_REFERENCE_RECORD_MODULE.getValue()) && isModulePresent(CalculatedDoseReferenceRecordModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.CLINICAL_TRIAL_SERIES_MODULE.getValue()) && isModulePresent(ClinicalTrialSeriesModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.GENERAL_EQUIPMENT_MODULE.getValue()) && isModulePresent(GeneralEquipmentModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.GENERAL_STUDY_MODULE.getValue()) && isModulePresent(GeneralStudyModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.MEASURED_DOSE_REFERENCE_RECORD_MODULE.getValue()) && isModulePresent(MeasuredDoseReferenceRecordModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.PATIENT_MODULE.getValue()) && isModulePresent(PatientModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.PATIENT_STUDY_MODULE.getValue()) && isModulePresent(PatientStudyModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.RT_ION_BEAMS_SESSION_RECORD_MODULE.getValue()) && isModulePresent(RTIonBeamsSessionRecordModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.RT_GENERAL_TREATMENT_RECORD_MODULE.getValue()) && isModulePresent(RTGeneralTreatmentRecordModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.RT_PATIENT_SETUP_MODULE.getValue()) && isModulePresent(RTPatientSetupModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.RT_SERIES_MODULE.getValue()) && isModulePresent(RTSeriesModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.RT_TREATMENT_MACHINE_RECORD_MODULE.getValue()) && isModulePresent(RTTreatmentMachineRecordModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.RT_TREATMENT_SUMMARY_RECORD_MODULE.getValue()) && isModulePresent(RTTreatmentSummaryRecordModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.SOP_COMMON_MODULE.getValue()) && isModulePresent(SOPCommonModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.COMMON_INSTANCE_REFERENCE_MODULE.getValue()) && isModulePresent(CommonInstanceReferenceModule.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;
	}
}
