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

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.AcquisitionContextModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.BreastViewModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.CardiacSynchronizationModule;
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.DeviceModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.EnhancedContrastBolusModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.EnhancedGeneralEquipmentModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.EnhancedXAOrXRFImageModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.FrameExtractionModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.FrameOfReferenceModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.ImageIOD;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.InterventionModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.MaskModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.MultiFrameDimensionModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.MultiFrameFunctionalGroupsModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.RespiratorySynchronizationModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.SOPCommonModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.SpecimenModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.SynchronizationModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.XAOrXRFAcquisitionModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.XAOrXRFMultiframePresentationModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.XAOrXRFSeriesModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.XRayDetectorModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.XRayFiltrationModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.XRayGridModule;
import cdac.medinfo.sdk.dcm30_04.dicommodel.modules.XRayImageIntensifierModule;
import cdac.medinfo.sdk.dcm30_04.enums.EnumCArmPositionerTabletopRelationship;
import cdac.medinfo.sdk.dcm30_04.enums.EnumImageType;
import cdac.medinfo.sdk.dcm30_04.enums.EnumModality;
import cdac.medinfo.sdk.dcm30_04.enums.EnumModuleNames;
import cdac.medinfo.sdk.dcm30_04.enums.EnumPositionerType;
import cdac.medinfo.sdk.dcm30_04.enums.EnumSOPClassUIDs;

import cdac.medinfo.sdk.dcm30_04.enums.EnumXRayReceptorType;
import cdac.medinfo.sdk.dcm30_04.exceptions.ConditionFailedException;
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;
/**
 * This class defines the enhanced Information Object for single plane X-Ray Angiographic Imaging that includes those data elements and information objects necessary for the interchange of digital X-Ray Angiographic data.
 * @author saloni
 *
 */
public class EnhancedXRayAngiographicImageIOD extends ImageIOD
{

	/**
	 * The Constant X_RAY_3D_CRANIOFACIAL_IMAGE_IOD.
	 */
	private static final String ENHANCED_XRAY_ANGIOGRAPHIC_IMAGE_IOD ="Enhanced X-Ray Angiographic Image IOD";
	/**
	 * The obj xa/xrf Series module.
	 */
	XAOrXRFSeriesModule objXAOrXRFSeriesModule = null;
	/**
	 * The obj clinical trial series module.
	 */
	ClinicalTrialSeriesModule objClinicalTrialSeriesModule = null;
	/**
	 * The obj Frame of Reference module.
	 */
	FrameOfReferenceModule objFrameOfReferenceModule = null;
	/**
	 * The obj Synchronization module.
	 */
	SynchronizationModule objSynchronizationModule= null;
	/**
	 * The obj Enhanced General Equipment module.
	 */
	EnhancedGeneralEquipmentModule objEnhancedGeneralEquipmentModule= null;
	/**
	 * The obj Enhanced Contrast/Bolus module.
	 */
	EnhancedContrastBolusModule objEnhancedContrastBolusModule = null;	
	/**
	 * The obj mask module.
	 */
	MaskModule objMaskModule = null;	
	/**
	 * The obj Device module.
	 */
	DeviceModule objDeviceModule = null;
	/**
	 * The obj Intervention module.
	 */
	InterventionModule objInterventionModule = null;
	/**
	 * The obj Acquisition Context module.
	 */
	AcquisitionContextModule objAcquisitionContextModule= null;
	/**
	 * The obj Multi-frame Functional Groups module.
	 */
	MultiFrameFunctionalGroupsModule objMultiFrameFunctionalGroupsModule = null;
	
	/**
	 * The obj Multi-frame Dimension module.
	 */
	MultiFrameDimensionModule objMultiFrameDimensionModule= null;
	
	/**
	 * The obj Cardiac Synchronization module.
	 */
	CardiacSynchronizationModule objCardiacSynchronizationModule = null;
	
	/**
	 * The obj Respiratory Synchronization module.
	 */
	RespiratorySynchronizationModule objRespiratorySynchronizationModule = null;
	/**
	 * The obj Specimen module.
	 */
	SpecimenModule objSpecimenModule = null;

	/**
	 * The obj X-Ray Filtration module.
	 */
	XRayFiltrationModule objXRayFiltrationModule= null;

	/**
	 * The obj X-Ray Grid module.
	 */
	XRayGridModule objXRayGridModule= null;
	/**
	 * The obj Enhanced XA/XRF Image module.
	 */
	EnhancedXAOrXRFImageModule objEnhancedXAOrXRFImageModule= null;
	/**
	 * The obj XA/XRF Acquisition module.
	 */
	XAOrXRFAcquisitionModule objXAOrXRFAcquisitionModule= null;
	/**
	 * The obj X-Ray Image Intensifier module.
	 */
	XRayImageIntensifierModule objXRayImageIntensifierModule= null;
	/**
	 * The obj X-Ray Detector module.
	 */
	XRayDetectorModule objXRayDetectorModule= null;
	/**
	 * The obj XA/XRF Multi-frame Presentation module.
	 */
	XAOrXRFMultiframePresentationModule objXAOrXRFMultiframePresentationModule= null;
	/**
	 * The obj sop common module.
	 */
	SOPCommonModule objSOPCommonModule = null;
	
	/**
	 * The obj Common Instance Reference module.
	 */
	CommonInstanceReferenceModule objCommonInstanceReferenceModule = null;
	/**
	 * The obj Frame Extraction module.
	 */
	FrameExtractionModule objFrameExtractionModule = null;
	/**
	 * Instantiates a new EnhancedXRayAngiographicImageIOD.
	 */
	public EnhancedXRayAngiographicImageIOD()
	{
		super();
	}

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

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

	/**
	 * Creates EnhancedXRayAngiographicImageIOD IOD from a DICOM file containing EnhancedXRayAngiographicImageIOD 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 EnhancedXRayAngiographicImageIOD(String strFileName)throws IOException,InvalidIODException
	{
		super(strFileName);
		try
		{
			if(objIDataSet != null)
			{
				String strSOPClassUID = objIDataSet.getSOPClassUID();
				if(strSOPClassUID != null)
				{
					if(!strSOPClassUID.equals(EnumSOPClassUIDs.ENHANCEDXAIMAGEIOD.getValue()))
					{
						throw new InvalidIODException(ResourceBundleWrapper.getValue("exceptions", "InvalidIOD.FileNotMatched", new Locale(DicomConfig.createInstance().getLocale())) + ENHANCED_XRAY_ANGIOGRAPHIC_IMAGE_IOD);
					}
				}
				strSOPClassUID = null;
			}
		}
		catch(InvalidIODException iie)
		{
			if(DicomConfig.createInstance().isLoggingOn())
			{
				DicomLogger.getLogger().log(iie.getMessage());
			}
			throw iie;
		}
	}
	/**
	 * Retrieves pre-initialized instance of XAOrXRFSeriesModule. 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 XAOrXRFSeriesModule - instance of {@link XAOrXRFSeriesModule}.
	 */
	public XAOrXRFSeriesModule getXAOrXRFSeriesModule()
	{
		if(objXAOrXRFSeriesModule == null)
		{
			objXAOrXRFSeriesModule = new XAOrXRFSeriesModule(objIDataSet);
			return objXAOrXRFSeriesModule;
		}
		return objXAOrXRFSeriesModule;
	}
	/**
	 * Retrieves pre-initialized instance of ClinicalTrialSeriesModule. 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 ClinicalTrialSeriesModule - instance of {@link ClinicalTrialSeriesModule}.
	 */
	public ClinicalTrialSeriesModule getClinicalTrialSeriesModule() 
	{
		if(objClinicalTrialSeriesModule == null)
		{
			objClinicalTrialSeriesModule = new ClinicalTrialSeriesModule(objIDataSet);
			return objClinicalTrialSeriesModule;
		}
		return objClinicalTrialSeriesModule;
	}
	/**
	 * Retrieves pre-initialized instance of Frame of Reference 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 FrameOfReferenceModule - instance of {@link FrameOfReferenceModule}.
	 */
	public FrameOfReferenceModule getFrameOfReferenceModule()
	{
		if(objFrameOfReferenceModule == null)
		{
			objFrameOfReferenceModule = new FrameOfReferenceModule(objIDataSet);
			return objFrameOfReferenceModule;
		}
		return objFrameOfReferenceModule;
	}
	/**
	 * Retrieves pre-initialized instance of SynchronizationModule. 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 SynchronizationModule - instance of {@link SynchronizationModule}.
	 */
	public SynchronizationModule getSynchronizationModule()
	{
		if(objSynchronizationModule == null)
		{
			objSynchronizationModule = new SynchronizationModule(objIDataSet);
			return objSynchronizationModule;
		}
		return objSynchronizationModule;
	}
	/**
	 * Retrieves pre-initialized instance of Enhanced 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 EnhancedGeneralEquipmentModule - instance of {@link EnhancedGeneralEquipmentModule}.
	 */
	public EnhancedGeneralEquipmentModule getEnhancedGeneralEquipmentModule()
	{
		if(objEnhancedGeneralEquipmentModule == null)
		{
			objEnhancedGeneralEquipmentModule = new EnhancedGeneralEquipmentModule(objIDataSet);
			return objEnhancedGeneralEquipmentModule;
		}
		return objEnhancedGeneralEquipmentModule;
	}
	/**
	 * Retrieves pre-initialized instance of EnhancedContrastBolusModule. 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 EnhancedContrastBolusModule - instance of {@link EnhancedContrastBolusModule}.
	 */
	public EnhancedContrastBolusModule getEnhancedContrastBolusModule()
	{
		if(objEnhancedContrastBolusModule == null)
		{
			objEnhancedContrastBolusModule = new EnhancedContrastBolusModule(objIDataSet);
			return objEnhancedContrastBolusModule;
		}
		return objEnhancedContrastBolusModule;
	}
	/**
	 * Retrieves pre-initialized instance of MaskModule. 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 MaskModule - instance of {@link MaskModule}.
	 */
	public MaskModule getMaskModule()
	{
		if(objMaskModule == null)
		{
			objMaskModule = new MaskModule(objIDataSet);
			return objMaskModule;
		}
		return objMaskModule;
	}
	/**
	 * Retrieves pre-initialized instance of Device 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 DeviceModule - instance of {@link DeviceModule}.
	 */
	public DeviceModule getDeviceModule()
	{
		if(objDeviceModule == null)
		{
			objDeviceModule = new DeviceModule(objIDataSet);
			return objDeviceModule;
		}
		return objDeviceModule;
	}
	/**
	 * Retrieves pre-initialized instance of Intervention 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 InterventionModule - instance of {@link InterventionModule}.
	 */
	public InterventionModule getInterventionModule()
	{
		if(objInterventionModule == null)
		{
			objInterventionModule = new InterventionModule(objIDataSet);
			return objInterventionModule;
		}
		return objInterventionModule;
	}
	/**
	 * 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 AcquisitionContextModule - instance of {@link AcquisitionContextModule}.
	 */
	public AcquisitionContextModule getAcquisitionContextModule()
	{
		if(objAcquisitionContextModule == null)
		{
			objAcquisitionContextModule = new AcquisitionContextModule(objIDataSet);
			return objAcquisitionContextModule;
		}
		return objAcquisitionContextModule;
	}
	/**
	 * Retrieves pre-initialized instance of Multi-frame Functional Groups 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 MultiFrameFunctionalGroupsModule - instance of {@link MultiFrameFunctionalGroupsModule}.
	 */
	public MultiFrameFunctionalGroupsModule getMultiFrameFunctionalGroupsModule()
	{
		if(objMultiFrameFunctionalGroupsModule== null)
		{
			objMultiFrameFunctionalGroupsModule = new MultiFrameFunctionalGroupsModule(objIDataSet);
			return objMultiFrameFunctionalGroupsModule;
		}
		return objMultiFrameFunctionalGroupsModule;
	}	
	/**
	 * Retrieves pre-initialized instance of Multi-frame Dimension Groups 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 MultiFrameDimensionModule - instance of {@link MultiFrameDimensionModule}.
	 */
	public MultiFrameDimensionModule getMultiFrameDimensionModule()
	{
		if(objMultiFrameDimensionModule== null)
		{
			objMultiFrameDimensionModule = new MultiFrameDimensionModule(objIDataSet);
			return objMultiFrameDimensionModule;
		}
		return objMultiFrameDimensionModule;
	}
	/**
	 * Retrieves pre-initialized instance of Cardiac 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 CardiacSynchronizationModule - instance of {@link CardiacSynchronizationModule}.
	 */
	public CardiacSynchronizationModule getCardiacSynchronizationModule()
	{
		if(objCardiacSynchronizationModule== null)
		{
			objCardiacSynchronizationModule = new CardiacSynchronizationModule(objIDataSet);
			return objCardiacSynchronizationModule;
		}
		return objCardiacSynchronizationModule;
	}
	/**
	 * Retrieves pre-initialized instance of Respiratory 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 RespiratorySynchronizationModule - instance of {@link RespiratorySynchronizationModule}.
	 */
	public RespiratorySynchronizationModule getRespiratorySynchronizationModule()
	{
		if(objRespiratorySynchronizationModule== null)
		{
			objRespiratorySynchronizationModule = new RespiratorySynchronizationModule(objIDataSet);
			return objRespiratorySynchronizationModule;
		}
		return objRespiratorySynchronizationModule;
	}
	/**
	 * Retrieves pre-initialized instance of Specimen 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 SpecimenModule - instance of {@link SpecimenModule}.
	 */
	public SpecimenModule getSpecimenModule()
	{
		if(objSpecimenModule== null)
		{
			objSpecimenModule = new SpecimenModule(objIDataSet);
			return objSpecimenModule;
		}
		return objSpecimenModule;
	}
	/**
	 * Retrieves pre-initialized instance of XRayFiltrationModule. 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 XRayFiltrationModule - instance of {@link XRayFiltrationModule}.
	 */
	public XRayFiltrationModule getXRayFiltrationModule()
	{
		if(objXRayFiltrationModule== null)
		{
			objXRayFiltrationModule = new XRayFiltrationModule(objIDataSet);
			return objXRayFiltrationModule;
		}
		return objXRayFiltrationModule;
	}
	/**
	 * Retrieves pre-initialized instance of XRayGridModule. 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 XRayGridModule - instance of {@link XRayGridModule}.
	 */
	public XRayGridModule getXRayGridModule()
	{
		if(objXRayGridModule== null)
		{
			objXRayGridModule = new XRayGridModule(objIDataSet);
			return objXRayGridModule;
		}
		return objXRayGridModule;
	}
	/**
	 * Retrieves pre-initialized instance of EnhancedXAOrXRFImageModule. 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 EnhancedXAOrXRFImageModule - instance of {@link EnhancedXAOrXRFImageModule}.
	 */
	public EnhancedXAOrXRFImageModule getEnhancedXAOrXRFImageModule()
	{
		if(objEnhancedXAOrXRFImageModule== null)
		{
			objEnhancedXAOrXRFImageModule = new EnhancedXAOrXRFImageModule(objIDataSet);
			return objEnhancedXAOrXRFImageModule;
		}
		return objEnhancedXAOrXRFImageModule;
	}
	/**
	 * Retrieves pre-initialized instance of XAOrXRFAcquisitionModule. 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 XAOrXRFAcquisitionModule - instance of {@link XAOrXRFAcquisitionModule}.
	 */
	public XAOrXRFAcquisitionModule getXAOrXRFAcquisitionModule()
	{
		if(objXAOrXRFAcquisitionModule== null)
		{
			objXAOrXRFAcquisitionModule = new XAOrXRFAcquisitionModule(objIDataSet);
			return objXAOrXRFAcquisitionModule;
		}
		return objXAOrXRFAcquisitionModule;
	}
	/**
	 * Retrieves pre-initialized instance of XRayImageIntensifierModule. 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 XRayImageIntensifierModule - instance of {@link XRayImageIntensifierModule}.
	 */
	public XRayImageIntensifierModule getXRayImageIntensifierModule()
	{
		if(objXRayImageIntensifierModule== null)
		{
			objXRayImageIntensifierModule = new XRayImageIntensifierModule(objIDataSet);
			return objXRayImageIntensifierModule;
		}
		return objXRayImageIntensifierModule;
	}
	/**
	 * Retrieves pre-initialized instance of XRayDetectorModule. 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 XRayDetectorModule - instance of {@link XRayDetectorModule}.
	 */
	public XRayDetectorModule getXRayDetectorModule()
	{
		if(objXRayDetectorModule== null)
		{
			objXRayDetectorModule = new XRayDetectorModule(objIDataSet);
			return objXRayDetectorModule;
		}
		return objXRayDetectorModule;
	}
	/**
	 * Retrieves pre-initialized instance of XAOrXRFMultiframePresentationModule. 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 XAOrXRFMultiframePresentationModule - instance of {@link XAOrXRFMultiframePresentationModule}.
	 */
	public XAOrXRFMultiframePresentationModule getXAOrXRFMultiframePresentationModule()
	{
		if(objXAOrXRFMultiframePresentationModule== null)
		{
			objXAOrXRFMultiframePresentationModule = new XAOrXRFMultiframePresentationModule(objIDataSet);
			return objXAOrXRFMultiframePresentationModule;
		}
		return objXAOrXRFMultiframePresentationModule;
	}
	/**
	 * 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 objSOPCommonModule - instance of {@link objSOPCommonModule}.
	 */
	public SOPCommonModule getSOPCommonModule()
	{
		if(objSOPCommonModule == null)
		{
			objSOPCommonModule = new SOPCommonModule(objIDataSet);
			return objSOPCommonModule;
		}
		return objSOPCommonModule;
	}
	/**
	 * Retrieves pre-initialized instance of Common Instance Reference 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 objSOPCommonModule - instance of {@link CommonInstanceReferenceModule}.
	 */
	public CommonInstanceReferenceModule getCommonInstanceReferenceModule()
	{
		if(objCommonInstanceReferenceModule == null)
		{
			objCommonInstanceReferenceModule = new CommonInstanceReferenceModule(objIDataSet);
			return objCommonInstanceReferenceModule;
		}
		return objCommonInstanceReferenceModule;
	}
	/**
	 * Retrieves pre-initialized instance of Frame Extraction 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 objFrameExtractionModule - instance of {@link FrameExtractionModule}.
	 */
	public FrameExtractionModule getFrameExtractionModule()
	{
		if(objFrameExtractionModule == null)
		{
			objFrameExtractionModule = new FrameExtractionModule(objIDataSet);
			return objFrameExtractionModule;
		}
		return objFrameExtractionModule;
	}
	/**
	 * This method validates EnhancedXRayAngiographicImageIOD Modules 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 boolean - function status indicating success or failure.
	 * 
	 * @throws InvalidIODException - throws when IOD is invalid.
	 */
	public boolean validate() throws InvalidIODException
	{
		/*
		 * This condition calls ImageIOD class's validation which checks for common modules validation
		 */
		super.validate();

		/*
		 * This condition checks for EnhancedXRayAngiographicImageIOD Modules mandatory modules validation
		 */
		try
		{
			getXAOrXRFSeriesModule().validateModule();			
			getEnhancedGeneralEquipmentModule().validateModule();
			getMultiFrameFunctionalGroupsModule().validateModule();			
			getAcquisitionContextModule().validateModule();
			getEnhancedXAOrXRFImageModule().validateModule();
			getSOPCommonModule().validateModule();
			/*
			 * Condition for Synchronization,Enhanced Contrast/Bolus,Cardiac Synchronization ,Respiratory Synchronization and Frame Extraction is not clear
			 */
			if(isModulePresent(ClinicalTrialSeriesModule.objSingleCollection, objIDataSet))
			{
				getClinicalTrialSeriesModule().validateModule();
			}
			XAOrXRFAcquisitionModule objXAOrXRFAcquisitionModule= new XAOrXRFAcquisitionModule(objIDataSet);;
			String strCArmPositionerTabletopRelationship=objXAOrXRFAcquisitionModule.getCArmPositionerTabletopRelationship();

			if(EnumCArmPositionerTabletopRelationship.YES.getValue().equalsIgnoreCase(strCArmPositionerTabletopRelationship))
				if(isModulePresent(FrameOfReferenceModule.objSingleCollection, objIDataSet))
				throw new ConditionFailedException("Frame of reference should be present if C-arm Positioner TabletopRelationship (0018,9474) equals YES.");
		
			if(EnumCArmPositionerTabletopRelationship.YES.getValue().equalsIgnoreCase(strCArmPositionerTabletopRelationship))
				if(isModulePresent(SynchronizationModule.objSingleCollection, objIDataSet))
				throw new ConditionFailedException("Synchronization should be present if C-arm Positioner TabletopRelationship (0018,9474) equals YES.");
		
			if(isModulePresent(EnhancedContrastBolusModule.objSingleCollection, objIDataSet))
			{
				getEnhancedContrastBolusModule().validateModule();
			}
			if(isModulePresent(MaskModule.objSingleCollection, objIDataSet))
			{
				getMaskModule().validateModule();
			}
			if(isModulePresent(DeviceModule.objSingleCollection, objIDataSet))
			{
				getDeviceModule().validateModule();
			}
			if(isModulePresent(InterventionModule.objSingleCollection, objIDataSet))
			{
				getInterventionModule().validateModule();
			}		
			if(isModulePresent(MultiFrameDimensionModule.objSingleCollection, objIDataSet))
			{
				getMultiFrameDimensionModule().validateModule();
			}
			if(isModulePresent(CardiacSynchronizationModule.objSingleCollection, objIDataSet))
			{
				getCardiacSynchronizationModule().validateModule();
			}
			if(isModulePresent(RespiratorySynchronizationModule.objSingleCollection, objIDataSet))
			{
				getRespiratorySynchronizationModule().validateModule();
			}	
			if(isModulePresent(SpecimenModule.objSingleCollection, objIDataSet))
			{
				getSpecimenModule().validateModule();
			}
			if(isModulePresent(XRayFiltrationModule.objSingleCollection, objIDataSet))
			{
				getXRayFiltrationModule().validateModule();
			}
			if(isModulePresent(XRayGridModule.objSingleCollection, objIDataSet))
			{
				getXRayGridModule().validateModule();
			}
			BreastViewModule objBreastViewModule=new BreastViewModule(objIDataSet);
			String strImageType=objBreastViewModule.getImageType().toString();
			if(EnumImageType.Value1.ORIGINAL.getValue().equalsIgnoreCase(strImageType))
				if(isModulePresent(XAOrXRFAcquisitionModule.objSingleCollection, objIDataSet))
				throw new ConditionFailedException("XA/XRF Acquisition should be present if Image Type (0008,0008) Value1 equals ORIGINAL.");
		
			String strXAXRFAcquisitionModule=getXAOrXRFAcquisitionModule().getXRayReceptorType();
			if(EnumXRayReceptorType.IMG_INTENSIFIER.getValue().equalsIgnoreCase(strXAXRFAcquisitionModule))
				if(isModulePresent(XRayImageIntensifierModule.objSingleCollection, objIDataSet))
				throw new ConditionFailedException("X-Ray Image Intensifiershould be present if X-Ray Receptor Type(0018,9420) is present and equalsIMG_INTENSIFIER.");
		
			if(EnumXRayReceptorType.DIGITAL_DETECTOR.getValue().equalsIgnoreCase(strXAXRFAcquisitionModule))
				if(isModulePresent(XRayDetectorModule.objSingleCollection, objIDataSet))
				throw new ConditionFailedException("X-Ray Detector should be present if X-Ray Receptor Type(0018,9420) is present and equals DIGITAL_DETECTOR.");
		
			if(isModulePresent(XAOrXRFMultiframePresentationModule.objSingleCollection, objIDataSet))
			{
				getXAOrXRFMultiframePresentationModule().validateModule();
			}
			
			if(isModulePresent(CommonInstanceReferenceModule.objSingleCollection, objIDataSet))
			{
				getCommonInstanceReferenceModule().validateModule();
			}
			if(isModulePresent(FrameExtractionModule.objSingleCollection, objIDataSet))
			{
				getFrameExtractionModule().validateModule();
			}
			String strModality = getGeneralSeriesModule().getModality();
			if(!strModality.equalsIgnoreCase(EnumModality.XRAY_ANGIOGRAPHY.getValue()))
				throw new InvalidIODException("Modality Type attribute (0008,0060) shall have the value XA.");
			
			String strPositionerType=getXAOrXRFAcquisitionModule().getPositionerType();
			if((!strPositionerType.equalsIgnoreCase(EnumPositionerType.CARM.getValue()))&&(isModulePresent(XAOrXRFAcquisitionModule.objSingleCollection, objIDataSet)))
				throw new InvalidIODException("Positioner Type (0018,1508) shall have the value CARM if the XA/XRF Acquisition Module is present.");
		}
		catch(ConditionFailedException cfe)
		{
			if(DicomConfig.createInstance().isLoggingOn())
				DicomLogger.getLogger().log(cfe.getMessage());
			throw new InvalidIODException(ENHANCED_XRAY_ANGIOGRAPHIC_IMAGE_IOD,cfe);
		}
		catch(InvalidModuleException ime)
		{
			if(DicomConfig.createInstance().isLoggingOn())
				DicomLogger.getLogger().log(ime.getMessage());
			
				throw new InvalidIODException(ENHANCED_XRAY_ANGIOGRAPHIC_IMAGE_IOD,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(ENHANCED_XRAY_ANGIOGRAPHIC_IMAGE_IOD + "\n");
		super.dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getXAOrXRFSeriesModule().getClass().getSimpleName() + "\n");
		getXAOrXRFSeriesModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getFrameOfReferenceModule().getClass().getSimpleName() + "\n");
		getFrameOfReferenceModule().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" + getEnhancedGeneralEquipmentModule().getClass().getSimpleName() + "\n");
		getEnhancedGeneralEquipmentModule().dumpDICOMInfo(objIDicomStream);

		objIDicomStream.writeString("\t" + getEnhancedContrastBolusModule().getClass().getSimpleName() + "\n");
		getEnhancedContrastBolusModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getMaskModule().getClass().getSimpleName() + "\n");
		getMaskModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getDeviceModule().getClass().getSimpleName() + "\n");
		getDeviceModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getInterventionModule().getClass().getSimpleName() + "\n");
		getInterventionModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getAcquisitionContextModule().getClass().getSimpleName() + "\n");
		getAcquisitionContextModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getMultiFrameDimensionModule().getClass().getSimpleName() + "\n");
		getMultiFrameDimensionModule().dumpDICOMInfo(objIDicomStream);

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

		objIDicomStream.writeString("\t" + getRespiratorySynchronizationModule().getClass().getSimpleName() + "\n");
		getRespiratorySynchronizationModule().dumpDICOMInfo(objIDicomStream);		
		
		objIDicomStream.writeString("\t" + getSpecimenModule().getClass().getSimpleName() + "\n");
		getSpecimenModule().dumpDICOMInfo(objIDicomStream);			
		
		objIDicomStream.writeString("\t" + getXRayFiltrationModule().getClass().getSimpleName() + "\n");
		getXRayFiltrationModule().dumpDICOMInfo(objIDicomStream);	
		
		objIDicomStream.writeString("\t" + getXRayGridModule().getClass().getSimpleName() + "\n");
		getXRayGridModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getEnhancedXAOrXRFImageModule().getClass().getSimpleName() + "\n");
		getEnhancedXAOrXRFImageModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getXAOrXRFAcquisitionModule().getClass().getSimpleName() + "\n");
		getXAOrXRFAcquisitionModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getXRayImageIntensifierModule().getClass().getSimpleName() + "\n");
		getXRayImageIntensifierModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getXRayDetectorModule().getClass().getSimpleName() + "\n");
		getXRayDetectorModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getXAOrXRFMultiframePresentationModule().getClass().getSimpleName() + "\n");
		getXAOrXRFMultiframePresentationModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getSOPCommonModule().getClass().getSimpleName() + "\n");
		getSOPCommonModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getCommonInstanceReferenceModule().getClass().getSimpleName() + "\n");
		getCommonInstanceReferenceModule().dumpDICOMInfo(objIDicomStream);
		
		objIDicomStream.writeString("\t" + getFrameExtractionModule().getClass().getSimpleName() + "\n");
		getFrameExtractionModule().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.XAXRF_SERIES_MODULE.getValue()) && isModulePresent(XAOrXRFSeriesModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.FRAME_OF_REFERENCE_MODULE.getValue()) && isModulePresent(FrameOfReferenceModule.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.ENHANCED_GENERAL_EQUIPMENT_MODULE.getValue()) && isModulePresent(EnhancedGeneralEquipmentModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.ENHANCED_CONTRAST_BOLUS_MODULE.getValue()) && isModulePresent(EnhancedContrastBolusModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.MASK_MODULE.getValue()) && isModulePresent(MaskModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.DEVICE_MODULE.getValue()) && isModulePresent(DeviceModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.INTERVENTION_MODULE.getValue()) && isModulePresent(InterventionModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.ACQUISITION_CONTEXT_MODULE.getValue()) && isModulePresent(AcquisitionContextModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.MULTI_FRAME_FUNCTIONAL_GROUPS_MODULE.getValue()) && isModulePresent(MultiFrameFunctionalGroupsModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.MULTI_FRAME_DIMENSION_MODULE.getValue()) && isModulePresent(MultiFrameDimensionModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.CARDIAC_SYNCHRONIZATION_MODULE.getValue()) && isModulePresent(CardiacSynchronizationModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.RESPIRATORY_SYNCHRONIZATION_MODULE.getValue()) && isModulePresent(RespiratorySynchronizationModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.SPECIMEN_MODULE.getValue()) && isModulePresent(SpecimenModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.X_RAY_FILTRATION_MODULE.getValue()) && isModulePresent(XRayFiltrationModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.X_RAY_GRID_MODULE.getValue()) && isModulePresent(XRayGridModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.ENHANCED_XAXRF_IMAGE_MODULE_TABLE.getValue()) && isModulePresent(EnhancedXAOrXRFImageModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.XAXRF_ACQUISITION_MODULE.getValue()) && isModulePresent(XAOrXRFAcquisitionModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.X_RAY_IMAGE_INTENSIFIER_MODULE.getValue()) && isModulePresent(XRayImageIntensifierModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.X_RAY_DETECTOR_MODULE.getValue()) && isModulePresent(XRayDetectorModule.objSingleCollection))
				return true;
			else if(strModuleName.equalsIgnoreCase(EnumModuleNames.XAXRF_MULTI_FRAME_PRESENTATION_MODULE.getValue()) && isModulePresent(XAOrXRFMultiframePresentationModule.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(strModuleName.equalsIgnoreCase(EnumModuleNames.FRAME_EXTRACTION_MODULE.getValue()) && isModulePresent(FrameExtractionModule.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;
	}
}
