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

import cdac.medinfo.sdk.dcm30_04.baselibs.Tag;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataSet;
import cdac.medinfo.sdk.dcm30_04.commoninterface.ITag;
import cdac.medinfo.sdk.dcm30_04.enums.EnumAttenuationCorrected;
import cdac.medinfo.sdk.dcm30_04.enums.EnumCountLossNormalizationCorrected;
import cdac.medinfo.sdk.dcm30_04.enums.EnumCountsSource;
import cdac.medinfo.sdk.dcm30_04.enums.EnumDeadTimeCorrected;
import cdac.medinfo.sdk.dcm30_04.enums.EnumDecayCorrected;
import cdac.medinfo.sdk.dcm30_04.enums.EnumDetectorNormalizationCorrection;
import cdac.medinfo.sdk.dcm30_04.enums.EnumGantryMotionCorrected;
import cdac.medinfo.sdk.dcm30_04.enums.EnumNonUniformRadialSamplingCorrected;
import cdac.medinfo.sdk.dcm30_04.enums.EnumPatientMotionCorrected;
import cdac.medinfo.sdk.dcm30_04.enums.EnumRandomsCorrected;
import cdac.medinfo.sdk.dcm30_04.enums.EnumRandomsCorrectionMethod;
import cdac.medinfo.sdk.dcm30_04.enums.EnumScatterCorrected;
import cdac.medinfo.sdk.dcm30_04.enums.EnumSensitivityCalibrated;

import cdac.medinfo.sdk.dcm30_04.exceptions.ConditionFailedException;
import cdac.medinfo.sdk.dcm30_04.exceptions.InvalidModuleException;
import cdac.medinfo.sdk.dcm30_04.exceptions.MandatoryMissingException;
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.ISingleCollection;
import cdac.medinfo.sdk.dcm30_04.utils.SingleCollection;
/**
\* This module is used for Enhanced PET Correction Module.
*/
public class EnhancedPETCorrectionsModule extends Module{
	/**
	 * The obj single collection.
	 */
	public static ISingleCollection<ITag> objSingleCollection = null;

	
	public EnhancedPETCorrectionsModule(IDataSet objIDataSet) {
		super(objIDataSet);
		
	}

	static
	{
		objSingleCollection = new SingleCollection<ITag>();
		objSingleCollection.add(new Tag(0x0054,0x1002));
		objSingleCollection.add(new Tag(0x0018,0x9758));
		objSingleCollection.add(new Tag(0x0018,0x9759)); 		
		objSingleCollection.add(new Tag(0x0018,0x9760));
		objSingleCollection.add(new Tag(0x0018,0x9761));
		objSingleCollection.add(new Tag(0x0018,0x9762));	
		objSingleCollection.add(new Tag(0x0018,0x9763));
		objSingleCollection.add(new Tag(0x0018,0x9764));
		objSingleCollection.add(new Tag(0x0018,0x9765));
		objSingleCollection.add(new Tag(0x0018,0x9766));
		objSingleCollection.add(new Tag(0x0018,0x9767));
		objSingleCollection.add(new Tag(0x0018,0x9768));	
		objSingleCollection.add(new Tag(0x0054,0x1100));
		objSingleCollection.add(new Tag(0x0018,0x9738));
		objSingleCollection.add(new Tag(0x0018,0x9770));
		objSingleCollection.add(new Tag(0x0054,0x1105));
		objSingleCollection.add(new Tag(0x0018,0x9701));
		
	}

	@Override
	public boolean validateModule() {
		try
		{			
			if(!isPresent(0x0054,0x1002))
				throw new MandatoryMissingException("0054,1002");
			if(!isPresent(0x0018,0x9758))
				throw new MandatoryMissingException("0018,9758");
			if(!isPresent(0x0018,0x9759))
				throw new MandatoryMissingException("0018,9759");			
			if(!isPresent(0x0018,0x9760))
				throw new MandatoryMissingException("0018,9760");
			if(!isPresent(0x0018,0x9761))
				throw new MandatoryMissingException("0018,9761");
			if(!isPresent(0x0018,0x9762))
				throw new MandatoryMissingException("0018,9762");			
			if(!isPresent(0x0018,0x9763))
				throw new MandatoryMissingException("0018,9763");
			if(!isPresent(0x0018,0x9764))
				throw new MandatoryMissingException("0018,9764");
			if(!isPresent(0x0018,0x9765))
				throw new MandatoryMissingException("0018,9765");		
			if(!isPresent(0x0018,0x9766))
				throw new MandatoryMissingException("0018,9766");
			if(!isPresent(0x0018,0x9767))
				throw new MandatoryMissingException("0018,9767");
			if(!isPresent(0x0018,0x9768))
				throw new MandatoryMissingException("0018,9768");
			/*if(contains(0x0054,0x1100) && getDataForTag(0x0018, 0x9765).getValue().equals(EnumRandomsCorrected.))
				if(!contains(0x0070,0x0256))
					throw new ConditionFailedException("0x0070,0x0256") ;*/
			
			
		}
		catch(MandatoryMissingException mme)
		{
			if(DicomConfig.createInstance().isLoggingOn())
				DicomLogger.getLogger().log(mme.getMessage());

			
				throw new InvalidModuleException(this.getClass().getSimpleName(),mme);

		}
		catch(ConditionFailedException cfe)
		{
			if(DicomConfig.createInstance().isLoggingOn())
				DicomLogger.getLogger().log(cfe.getMessage());

			
				throw new InvalidModuleException(this.getClass().getSimpleName(),cfe);

		}
		return true;
	}
	
	
	/**
	 * Sets the Value Type Defined in Terms of TEXT,NUMERIC,CODE,DATE,TIME,PNAME
	 * @param strValueType Specifies type of the value encoded in this Item
	 */
	public void setCountsSource(EnumCountsSource enumCountsSource)
	{
		/*Accept the Value Type in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */

		addDataElement(0x0054,0x1002,DicomConstants.DCM_DT_CS, enumCountsSource);
	}
	/**
	 * Retrieves type of the value encoded in this Item
	 * @return String - Type of the value encoded in this Item
	 */
	public String getValueType()
	{
		Object objValue = getValue(0x0054,0x1002);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets the Value Type Defined in Terms of TEXT,NUMERIC,CODE,DATE,TIME,PNAME
	 * @param strValueType Specifies type of the value encoded in this Item
	 */
	public void setDecayCorrected(EnumDecayCorrected enumDecayCorrected)
	{
		/*Accept the Value Type in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */

		addDataElement(0x0018,0x9758,DicomConstants.DCM_DT_CS, enumDecayCorrected);
	}
	/**
	 * Retrieves type of the value encoded in this Item
	 * @return String - Type of the value encoded in this Item
	 */
	public String getDecayCorrected()
	{
		Object objValue = getValue(0x0018,0x9758);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Sets the Value Type Defined in Terms of TEXT,NUMERIC,CODE,DATE,TIME,PNAME
	 * @param strValueType Specifies type of the value encoded in this Item
	 */
	public void setAttenuationCorrected(EnumAttenuationCorrected enumAttenuationCorrected)
	{
		/*Accept the Value Type in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */

		addDataElement(0x0018,0x9759,DicomConstants.DCM_DT_CS, enumAttenuationCorrected);
	}
	/**
	 * Retrieves type of the value encoded in this Item
	 * @return String - Type of the value encoded in this Item
	 */
	public String getAttenuationCorrected()
	{
		Object objValue = getValue(0x0018,0x9759);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Sets the Value Type Defined in Terms of TEXT,NUMERIC,CODE,DATE,TIME,PNAME
	 * @param strValueType Specifies type of the value encoded in this Item
	 */
	public void setScatterCorrected(EnumScatterCorrected enumScatterCorrected)
	{
		/*Accept the Value Type in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */

		addDataElement(0x0018,0x9760,DicomConstants.DCM_DT_CS, enumScatterCorrected);
	}
	/**
	 * Retrieves type of the value encoded in this Item
	 * @return String - Type of the value encoded in this Item
	 */
	public String getScatterCorrected()
	{
		Object objValue = getValue(0x0018,0x9760);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	
	/**
	 * Sets the Value Type Defined in Terms of TEXT,NUMERIC,CODE,DATE,TIME,PNAME
	 * @param enumDeadTimeCorrected Specifies type of the value encoded in this Item
	 */
	public void setDeadTimeCorrected(EnumDeadTimeCorrected enumDeadTimeCorrected)
	{
		/*Accept the Value Type in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */

		addDataElement(0x0018,0x9761,DicomConstants.DCM_DT_CS, enumDeadTimeCorrected);
	}
	/**
	 * Retrieves type of the value encoded in this Item
	 * @return String - Type of the value encoded in this Item
	 */
	public String getDeadTimeCorrected()
	{
		Object objValue = getValue(0x0018,0x9761);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Sets the Value Type Defined in Terms of TEXT,NUMERIC,CODE,DATE,TIME,PNAME
	 * @param enumGantryMotionCorrected Specifies type of the value encoded in this Item
	 */
	public void setGantryMotionCorrected(EnumGantryMotionCorrected enumGantryMotionCorrected)
	{
		/*Accept the Value Type in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */

		addDataElement(0x0018,0x9762,DicomConstants.DCM_DT_CS, enumGantryMotionCorrected);
	}
	/**
	 * Retrieves type of the value encoded in this Item
	 * @return String - Type of the value encoded in this Item
	 */
	public String getGantryMotionCorrected()
	{
		Object objValue = getValue(0x0018,0x9762);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Sets the Value Type Defined in Terms of TEXT,NUMERIC,CODE,DATE,TIME,PNAME
	 * @param enumPatientMotionCorrected Specifies type of the value encoded in this Item
	 */
	public void setPatientMotionCorrected(EnumPatientMotionCorrected enumPatientMotionCorrected)
	{
		/*Accept the Value Type in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */

		addDataElement(0x0018,0x9763,DicomConstants.DCM_DT_CS, enumPatientMotionCorrected);
	}
	/**
	 * Retrieves type of the value encoded in this Item
	 * @return String - Type of the value encoded in this Item
	 */
	public String getPatientMotionCorrected()
	{
		Object objValue = getValue(0x0018,0x9763);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Sets the Value Type Defined in Terms of TEXT,NUMERIC,CODE,DATE,TIME,PNAME
	 * @param enumCountLossNormalizationCorrected Specifies type of the value encoded in this Item
	 */
	public void setCountLossNormalizationCorrected(EnumCountLossNormalizationCorrected enumCountLossNormalizationCorrected)
	{
		/*Accept the Value Type in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */

		addDataElement(0x0018,0x9764,DicomConstants.DCM_DT_CS, enumCountLossNormalizationCorrected);
	}
	/**
	 * Retrieves type of the value encoded in this Item
	 * @return String - Type of the value encoded in this Item
	 */
	public String getCountLossNormalizationCorrected()
	{
		Object objValue = getValue(0x0018,0x9764);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Sets the Value Type Defined in Terms of TEXT,NUMERIC,CODE,DATE,TIME,PNAME
	 * @param enumRandomsCorrected Specifies type of the value encoded in this Item
	 */
	public void setRandomsCorrected(EnumRandomsCorrected enumRandomsCorrected)
	{
		/*Accept the Value Type in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */

		addDataElement(0x0018,0x9765,DicomConstants.DCM_DT_CS, enumRandomsCorrected);
	}
	/**
	 * Retrieves type of the value encoded in this Item
	 * @return String - Type of the value encoded in this Item
	 */
	public String getRandomsCorrected()
	{
		Object objValue = getValue(0x0018,0x9765);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Sets the Value Type Defined in Terms of TEXT,NUMERIC,CODE,DATE,TIME,PNAME
	 * @param enumNonUniformRadialSamplingCorrected Specifies type of the value encoded in this Item
	 */
	public void setNonUniformRadialSamplingCorrected(EnumNonUniformRadialSamplingCorrected enumNonUniformRadialSamplingCorrected)
	{
		/*Accept the Value Type in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */

		addDataElement(0x0018,0x9766,DicomConstants.DCM_DT_CS, enumNonUniformRadialSamplingCorrected);
	}
	/**
	 * Retrieves type of the value encoded in this Item
	 * @return String - Type of the value encoded in this Item
	 */
	public String getNonUniformRadialSamplingCorrected()
	{
		Object objValue = getValue(0x0018,0x9766);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Sets the Value Type Defined in Terms of TEXT,NUMERIC,CODE,DATE,TIME,PNAME
	 * @param enumSensitivityCalibrated Specifies type of the value encoded in this Item
	 */
	public void setSensitivityCalibrated(EnumSensitivityCalibrated enumSensitivityCalibrated)
	{
		/*Accept the Value Type in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */

		addDataElement(0x0018,0x9767,DicomConstants.DCM_DT_CS, enumSensitivityCalibrated);
	}
	/**
	 * Retrieves type of the value encoded in this Item
	 * @return String - Type of the value encoded in this Item
	 */
	public String getSensitivityCalibrated()
	{
		Object objValue = getValue(0x0018,0x9767);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Sets the Value Type Defined in Terms of TEXT,NUMERIC,CODE,DATE,TIME,PNAME
	 * @param enumDetectorNormalizationCorrection Specifies type of the value encoded in this Item
	 */
	public void setDetectorNormalizationCorrection(EnumDetectorNormalizationCorrection enumDetectorNormalizationCorrection)
	{
		/*Accept the Value Type in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */

		addDataElement(0x0018,0x9768,DicomConstants.DCM_DT_CS, enumDetectorNormalizationCorrection);
	}
	/**
	 * Retrieves type of the value encoded in this Item
	 * @return String - Type of the value encoded in this Item
	 */
	public String getDetectorNormalizationCorrection()
	{
		Object objValue = getValue(0x0018,0x9768);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Sets the Value Type Defined in Terms of TEXT,NUMERIC,CODE,DATE,TIME,PNAME
	 * @param enumDetectorNormalizationCorrection Specifies type of the value encoded in this Item
	 */
	public void setRandomsCorrectionMethod(EnumRandomsCorrectionMethod enumRandomsCorrectionMethod)
	{
		/*Accept the Value Type in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */

		addDataElement(0x0054,0x1100,DicomConstants.DCM_DT_CS, enumRandomsCorrectionMethod);
	}
	/**
	 * Retrieves type of the value encoded in this Item
	 * @return String - Type of the value encoded in this Item
	 */
	public String getRandomsCorrectionMethod()
	{
		Object objValue = getValue(0x0054,0x1100);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Sets the Value Type Defined in Terms of TEXT,NUMERIC,CODE,DATE,TIME,PNAME
	 * @param enumDetectorNormalizationCorrection Specifies type of the value encoded in this Item
	 */
	public void setAttenuationCorrectionSource(String strAttenuationCorrectionSource)
	{
		/*Accept the Value Type in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */

		addDataElement(0x0018,0x9738,DicomConstants.DCM_DT_CS, strAttenuationCorrectionSource);
	}
	/**
	 * Retrieves type of the value encoded in this Item
	 * @return String - Type of the value encoded in this Item
	 */
	public String getAttenuationCorrectionSource()
	{
		Object objValue = getValue(0x0018,0x9738);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Sets the Value Type Defined in Terms of TEXT,NUMERIC,CODE,DATE,TIME,PNAME
	 * @param strAttenuationCorrectionTemporalRelationship Specifies type of the value encoded in this Item
	 */
	public void setAttenuationCorrectionTemporalRelationship(String strAttenuationCorrectionTemporalRelationship)
	{
		/*Accept the Value Type in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */

		addDataElement(0x0018,0x9770,DicomConstants.DCM_DT_CS, strAttenuationCorrectionTemporalRelationship);
	}
	/**
	 * Retrieves type of the value encoded in this Item
	 * @return String - Type of the value encoded in this Item
	 */
	public String getAttenuationCorrectionTemporalRelationship()
	{
		Object objValue = getValue(0x0018,0x9770);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Sets strScatterCorrectionMethod Type.
	 * @param strScatterCorrectionMethod String value of Rescale Type.
	 */
	public void setScatterCorrectionMethod(String strScatterCorrectionMethod)
	{
		/* Accept the Rescale Type in String format of type LO.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */

		addDataElement(0x0054,0x1105,DicomConstants.DCM_DT_LO, strScatterCorrectionMethod);
	}

	/**
	 * Return user-defined label identifier for Rescale Type.
	 * @return String - value of Rescale Type.
	 */
	public String getScatterCorrectionMethod()
	{
		Object objValue = getValue(0x0054,0x1105);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Sets Date and Time of verification by the Verifying Observer Name (0040,A075).
	 * @param strDecayCorrectionDateTime String value of Verification DateTime
	 */
	public void setDecayCorrectionDateTime(String strDecayCorrectionDateTime)
	{
		/* Accept the Verification DateTime of type DT.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */

		addDataElement(0x0018,0x9701,DicomConstants.DCM_DT_DT, strDecayCorrectionDateTime);
	}

	/**
	 * Retrieves Verification DateTime
	 * @return String - value of Verification DateTime
	 */
	public String getDecayCorrectionDateTime()
	{
		Object objValue = getValue(0x0018,0x9701);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	

}
