/*******************************************************************************
 *  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.DicomV3Factory;
import cdac.medinfo.sdk.dcm30_04.baselibs.PerformedProcedureStepDiscontinuationReasonCodeSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ProcedureCodeSequence;
import cdac.medinfo.sdk.dcm30_04.baselibs.ReasonForPerformedProcedureCodeSequence;
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.EnumPerformedProcedureStepStatus;
import cdac.medinfo.sdk.dcm30_04.exceptions.InvalidModuleException;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConstants;
import cdac.medinfo.sdk.dcm30_04.utils.ISingleCollection;
import cdac.medinfo.sdk.dcm30_04.utils.SingleCollection;

// TODO: Auto-generated Javadoc
/**
 \* This module describes the attributes in Performed Procedure Step Information Module.
 */
public class PerformedProcedureStepInformationModule extends Module  
{

 
 /**
  * The obj single collection.
  */
 public static ISingleCollection<ITag> objSingleCollection = null;
	 

	/**
	 * CreatesPerformed Procedure Step Information Module with default initialization.
	 * 
	 * @param objIDataSet the obj i data set
	 */
	public PerformedProcedureStepInformationModule(IDataSet objIDataSet)
	{
		super(objIDataSet);
	}

	static
	{
		objSingleCollection = new SingleCollection<ITag>();
		objSingleCollection.add(new Tag(0x0040,0x0241));
		objSingleCollection.add(new Tag(0x0040,0x0242));
		objSingleCollection.add(new Tag(0x0040,0x0243));
		objSingleCollection.add(new Tag(0x0040,0x0244));
		objSingleCollection.add(new Tag(0x0040,0x0245));
		objSingleCollection.add(new Tag(0x0040,0x0253));
		objSingleCollection.add(new Tag(0x0040,0x0250));
		objSingleCollection.add(new Tag(0x0040,0x0251));
		objSingleCollection.add(new Tag(0x0040,0x0252));
		objSingleCollection.add(new Tag(0x0040,0x0254));
		objSingleCollection.add(new Tag(0x0040,0x0280));
		objSingleCollection.add(new Tag(0x0040,0x0255));
		objSingleCollection.add(new Tag(0x0008,0x1032));
		objSingleCollection.add(new Tag(0x0040,0x1012));
		objSingleCollection.add(new Tag(0x0040,0x0281));
	}

	/**
	 * This method validates each Attribute in the Module according to the Type
	 * of the Attribute.Attributes are of 5 types.
	 * Type 1,Type 2 are Mandatory:
	 * Mandatory Attributes have to present in the Module.
	 * Type 1C,2C are Conditional:
	 * Conditional Attributes' presence depend on a condition.
	 * If the condition is satisfied the Attribute has to be present.
	 * Type 3 are Optional
	 * Optional Attributes can be added as and when required.
	 * 
	 * @return - validation status as success or failure
	 * 
	 * @throws InvalidModuleException when the module is invalid
	 */
	public boolean validateModule() throws InvalidModuleException
	{
		//All Attributes are optional.
		return true;
	}
	
	/**
	 * This method returns the vector of keys representing the DataElements
	 * that belong to this module.
	 * 
	 * @return vector of Tags - returns the vector containing the collection of tags
	 */
	public ISingleCollection<ITag> getVectorOfKeys()
	{
		return objSingleCollection;
	}


	/**
	 * Sets attribute identifies AE title of the modality on which the Performed
	 * Procedure Step was performed.
	 * 
	 * @param StrPerformedStationAETitle - String AE title
	 */	
	public void setPerformedStationAETitle(String StrPerformedStationAETitle)
	{
		/*Accept AE title in String format of type AE.
		 * Read the Transfer Syntax and check to create ImplicitDE or ExplicitDE .
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Hash Map
		 */
		addDataElement(0x0040,0x0241, DicomConstants.DCM_DT_AE, StrPerformedStationAETitle);
	}

	/**
	 * Return attribute identifies AE title of the modality on which the Performed
	 * Procedure Step was performed.
	 * 
	 * @return String - String AE title
	 */
	public String getPerformedStationAETitle()
	{
		Object objValue = getValue(0x0040,0x0241);
		if(objValue != null)
			return objValue.toString();
		return null;
	}


	/**
	 * Sets attribute An institution defined name for the modality on which
	 * the Performed Procedure Step was performed.
	 * 
	 * @param StrPerformedStationName - String institution name.
	 */	
	public void setPerformedStationName(String StrPerformedStationName)
	{
		/*Accept Performed Station Name in String format of type SH.
		 * Read the Transfer Syntax and check to create ImplicitDE or ExplicitDE .
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Hash Map
		 */
		addDataElement(0x0040,0x0242, DicomConstants.DCM_DT_SH, StrPerformedStationName);
	}

	/**
	 * Return attribute An institution defined name for the modality on which
	 * the Performed Procedure Step was performed.
	 * 
	 * @return String - String institution name.
	 */
	public String getPerformedStationName()
	{
		Object objValue = getValue(0x0040,0x0242);
		if(objValue != null)
			return objValue.toString();
		return null;
	}


	/**
	 * Sets attribute identifies Description of the location at which the Performed
	 * Procedure Step was performed.
	 * 
	 * @param StrPerformedLocation - String identifies Description of the location
	 */	
	public void setPerformedLocation(String StrPerformedLocation)
	{
		/*Accept Description of the location in String format of type SH.
		 * Read the Transfer Syntax and check to create ImplicitDE or ExplicitDE .
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Hash Map
		 */
		addDataElement(0x0040,0x0243, DicomConstants.DCM_DT_SH, StrPerformedLocation);
	}

	/**
	 * Return  attribute identifies Description of the location at which the Performed
	 * Procedure Step was performed.
	 * 
	 * @return String - String Description of the location
	 */
	public String getPerformedLocation()
	{
		Object objValue = getValue(0x0040,0x0243);
		if(objValue != null)
			return objValue.toString();
		return null;
	}


	/**
	 * Sets attribute identifies Date on which the Performed Procedure Step started.
	 * 
	 * @param StrPerformedProcedureStepStartDate - String identifies Date on which the Performed Procedure Step started.
	 */	
	public void setPerformedProcedureStepStartDate(String StrPerformedProcedureStepStartDate)
	{
		/*Accept Image identification characteristics in String Array format of type CS.
		 * Read the Transfer Syntax and check to create ImplicitDE or ExplicitDE .
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Hash Map
		 */
		addDataElement(0x0040,0x0244, DicomConstants.DCM_DT_DA, StrPerformedProcedureStepStartDate);
	}

	/**
	 * Return Date on which the Performed Procedure Step started.
	 * 
	 * @return String - String Date on which the Performed Procedure Step started.
	 */
	public String getPerformedProcedureStepStartDate()
	{
		Object objValue = getValue(0x0040,0x0244);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets attribute identifies Time at which the Performed Procedure Step started.
	 * 
	 * @param strPerformedProcedureStepStartTime - String Time at which the Performed Procedure Step started.
	 */	
	public void setPerformedProcedureStepStartTime(String strPerformedProcedureStepStartTime)
	{
		/*Accept Image identification characteristics in String Array format of type CS.
		 * Read the Transfer Syntax and check to create ImplicitDE or ExplicitDE .
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Hash Map
		 */
		addDataElement(0x0040,0x0245, DicomConstants.DCM_DT_TM, strPerformedProcedureStepStartTime);
	}

	/**
	 * Return Time at which the Performed Procedure Step started.
	 * 
	 * @return String - String identifies Time at which the Performed Procedure Step started.
	 */
	public String getPerformedProcedureStepStartTime()
	{
		Object objValue = getValue(0x0040,0x0245);
		if(objValue != null)
			return objValue.toString();
		return null;
	}


	/**
	 * Sets attribute User or equipment generated identifier of that part of
	 * a Procedure that has been carried out within this step.
	 * 
	 * @param StrPerformedProcedureStepID - String User or equipment generated identifier
	 */	
	public void setPerformedProcedureStepID(String StrPerformedProcedureStepID)
	{
		/*Accept Image identification characteristics in String Array format of type CS.
		 * Read the Transfer Syntax and check to create ImplicitDE or ExplicitDE .
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Hash Map
		 */
		addDataElement(0x0040,0x0253, DicomConstants.DCM_DT_SH, StrPerformedProcedureStepID);
	}

	/**
	 * Return attribute User or equipment generated identifier of that part of
	 * a Procedure that has been carried out within this step.
	 * 
	 * @return String - String User or equipment generated identifier
	 */
	public String getPerformedProcedureStepID()
	{
		Object objValue = getValue(0x0040,0x0253);
		if(objValue != null)
			return objValue.toString();
		return null;
	}


	/**
	 * Sets attribute Date on which the Performed Procedure Step ended.
	 * 
	 * @param strPerformedProcedureStepEndDate - String identifies Date on which the Performed Procedure Step ended.
	 */	
	public void setPerformedProcedureStepEndDate(String strPerformedProcedureStepEndDate)
	{
		/*Accept Image identification characteristics in String Array format of type CS.
		 * Read the Transfer Syntax and check to create ImplicitDE or ExplicitDE .
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Hash Map
		 */
		addDataElement(0x0040,0x0250, DicomConstants.DCM_DT_DA, strPerformedProcedureStepEndDate);
	}

	/**
	 * Return Date on which the Performed Procedure Step ended.
	 * 
	 * @return String - String Date on which the Performed Procedure Step ended.
	 */
	public String getPerformedProcedureStepEndDate()
	{
		Object objValue = getValue(0x0040,0x0250);
		if(objValue != null)
			return objValue.toString();
		return null;
	}


	/**
	 * Sets attribute Time at which the Performed Procedure Step ended.
	 * 
	 * @param strPerformedProcedureStepEndTime - String Time at which the Performed Procedure Step ended.
	 */	
	public void setPerformedProcedureStepEndTime(String strPerformedProcedureStepEndTime)
	{
		/*Accept Image identification characteristics in String Array format of type CS.
		 * Read the Transfer Syntax and check to create ImplicitDE or ExplicitDE .
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Hash Map
		 */
		addDataElement(0x0040,0x0251, DicomConstants.DCM_DT_TM, strPerformedProcedureStepEndTime);
	}

	/**
	 * Return Time at which the Performed Procedure Step ended.
	 * 
	 * @return String - String identifies Time at which the Performed Procedure Step ended.
	 */
	public String getPerformedProcedureStepEndTime()
	{
		Object objValue = getValue(0x0040,0x0251);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets Contains the state of the Performed Procedure Step.
	 * 
	 * @param enumPerformedProcedureStepStatus - Enum value of state of the Performed Procedure Step
	 */
	public void setPerformedProcedureStepStatus(EnumPerformedProcedureStepStatus enumPerformedProcedureStepStatus)
	{
		/* Accept Performed Procedure Step 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(0x0040,0x0252, DicomConstants.DCM_DT_CS, enumPerformedProcedureStepStatus.getValue());
	}

	/**
	 * Retrieves state of the Performed Procedure Step.
	 * 
	 * @return the performed procedure step status
	 */
	public String getPerformedProcedureStepStatus()
	{
		Object objValue = getValue(0x0040,0x0252);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets attribute identifies Institution-generated description or classification of
	 * the Procedure Step that was performed.
	 * 
	 * @param strPerformedProcedureStepDescription - String Institution-generated description
	 */	
	public void setPerformedProcedureStepDescription(String strPerformedProcedureStepDescription)
	{
		/*Accept Image identification characteristics in String Array format of type CS.
		 * Read the Transfer Syntax and check to create ImplicitDE or ExplicitDE .
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Hash Map
		 */
		addDataElement(0x0040,0x0254, DicomConstants.DCM_DT_LO, strPerformedProcedureStepDescription);
	}

	/**
	 * Return attribute identifies Institution-generated description or classification of
	 * the Procedure Step that was performed.
	 * 
	 * @return String - String Institution-generated description
	 */
	public String getPerformedProcedureStepDescription()
	{
		Object objValue = getValue(0x0040,0x0254);
		if(objValue != null)
			return objValue.toString();
		return null;
	}


	/**
	 * Sets User-defined comments on the Performed Procedure Step.
	 * 
	 * @param strCommentsonthePerformedProcedureStep - String User-defined comments
	 */	
	public void setCommentsonthePerformedProcedureStep(String strCommentsonthePerformedProcedureStep)
	{
		/*Accept Image identification characteristics in String Array format of type CS.
		 * Read the Transfer Syntax and check to create ImplicitDE or ExplicitDE .
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Hash Map
		 */
		addDataElement(0x0040,0x0280, DicomConstants.DCM_DT_ST, strCommentsonthePerformedProcedureStep);
	}

	/**
	 * Return User-defined comments on the Performed Procedure Step.
	 * 
	 * @return String - String User-defined comments
	 */
	public String getCommentsonthePerformedProcedureStep()
	{
		Object objValue = getValue(0x0040,0x0280);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets the description of the type of procedure performed.
	 * 
	 * @param StrPerformedProcedureTypeDescription - String description of the type of procedure performed.
	 */	
	public void setPerformedProcedureTypeDescription(String StrPerformedProcedureTypeDescription)
	{
		/*Accept description of the type of procedure performed in String format of type LO.
		 * Read the Transfer Syntax and check to create ImplicitDE or ExplicitDE .
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Hash Map
		 */
		addDataElement(0x0040,0x0255, DicomConstants.DCM_DT_LO, StrPerformedProcedureTypeDescription);
	}

	/**
	 * Return the description of the type of procedure performed.
	 * 
	 * @return String - String description of the type of procedure performed.
	 */
	public String getPerformedProcedureTypeDescription()
	{
		Object objValue = getValue(0x0040,0x0255);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Retrieves pre-initialized object of ProcedureCodeSequence.If the module contains the sequence object
	 * it returns the same otherwise it creates the sequence adds to the module with proper initialization
	 * and then returns the object of sequence
	 * 
	 * @return ProcedureCodeSequence - instance of Referenced Procedure Code Sequence
	 */
	public ProcedureCodeSequence getProcedureCodeSequence()
	{
		ProcedureCodeSequence objProcedureCodeSequence = (ProcedureCodeSequence)getDicomValue(0x0008, 0x1032);
		if(objProcedureCodeSequence == null)
		{
			/*
			 * If the sequence object is not present in the DataSet, a new sequence object is created and
			 * the TransferSyntax and DictionaryReader is set into it as it is set in the Module. This ensures that 
			 * the DataElements getting added in the DataSet follow the same TransferSyntax and use the same
			 * DictionaryReader object as that of the module.
			 */
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			objProcedureCodeSequence = (ProcedureCodeSequence)objDicomV3Factory.createSequence(0x0008, 0x1032, objITransferSyntax, objIDictionaryReader);
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0008, 0x1032, DicomConstants.DCM_DT_SQ, objProcedureCodeSequence.getValue());
		}
		return objProcedureCodeSequence;
	}

	/**
	 * Retrieves pre-initialized object of ReasonForPerformedProcedureCodeSequence.If the module contains the sequence object
	 * it returns the same otherwise it creates the sequence adds to the module with proper initialization
	 * and then returns the object of sequence
	 * 
	 * @return ReasonForPerformedProcedureCodeSequence - instance of ReasonForPerformedProcedureCodeSequence.
	 */
	public ReasonForPerformedProcedureCodeSequence getReasonForPerformedProcedureCodeSequence()
	{
		ReasonForPerformedProcedureCodeSequence objReasonForPerformedProcedureCodeSequence = (ReasonForPerformedProcedureCodeSequence)getDicomValue(0x0040,0x1012);
		if(objReasonForPerformedProcedureCodeSequence == null)
		{
			/*
			 * If the sequence object is not present in the DataSet, a new sequence object is created and
			 * the TransferSyntax and DictionaryReader is set into it as it is set in the Module. This ensures that 
			 * the DataElements getting added in the DataSet follow the same TransferSyntax and use the same
			 * DictionaryReader object as that of the module.
			 */
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			objReasonForPerformedProcedureCodeSequence = (ReasonForPerformedProcedureCodeSequence)objDicomV3Factory.createSequence(0x0040,0x1012, objITransferSyntax, objIDictionaryReader);
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0040,0x1012, DicomConstants.DCM_DT_SQ, objReasonForPerformedProcedureCodeSequence.getValue());
		}
		return objReasonForPerformedProcedureCodeSequence;	
	}
	
	/**
	 * Retrieves pre-initialized object of PerformedProcedureStepDiscontinuationReasonCodeSequence.If the module contains the sequence object
	 * it returns the same otherwise it creates the sequence adds to the module with proper initialization
	 * and then returns the object of sequence
	 * 
	 * @return PerformedProcedureStepDiscontinuationReasonCodeSequence - instance of Referenced Reference Image Sequence.
	 */
	public PerformedProcedureStepDiscontinuationReasonCodeSequence getPerformedProcedureStepDiscontinuationReasonCodeSequence()
	{
		PerformedProcedureStepDiscontinuationReasonCodeSequence objPerformedProcedureStepDiscontinuationReasonCodeSequence = (PerformedProcedureStepDiscontinuationReasonCodeSequence)getDicomValue(0x0040,0x0281);
		if(objPerformedProcedureStepDiscontinuationReasonCodeSequence == null)
		{
			/*
			 * If the sequence object is not present in the DataSet, a new sequence object is created and
			 * the TransferSyntax and DictionaryReader is set into it as it is set in the Module. This ensures that 
			 * the DataElements getting added in the DataSet follow the same TransferSyntax and use the same
			 * DictionaryReader object as that of the module.
			 */
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			objPerformedProcedureStepDiscontinuationReasonCodeSequence = (PerformedProcedureStepDiscontinuationReasonCodeSequence)objDicomV3Factory.createSequence(0x0040,0x0281, objITransferSyntax, objIDictionaryReader);
			
			// This will add Data Element of SQ to the DataSet.
			addDataElement(0x0040,0x0281, DicomConstants.DCM_DT_SQ, objPerformedProcedureStepDiscontinuationReasonCodeSequence.getValue());
		}
		return objPerformedProcedureStepDiscontinuationReasonCodeSequence;	
	}
}
