/*******************************************************************************
 *  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.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 defines the Attributes relevant to acquiring a study.
 */
public class StudyAcquisitionModule extends Module  
{

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

	/**
	 * Instantiates a new study acquisition module.
	 * 
	 * @param objIDataSet the obj i data set
	 */
	public StudyAcquisitionModule(IDataSet objIDataSet)
	{
		super(objIDataSet);
	}

	static
	{
		objSingleCollection = new SingleCollection<ITag>();
		objSingleCollection.add(new Tag(0x0008,0x0020));
		objSingleCollection.add(new Tag(0x0008,0x0030));
		objSingleCollection.add(new Tag(0x0008,0x0061));
		objSingleCollection.add(new Tag(0x0020,0x1000));
		objSingleCollection.add(new Tag(0x0020,0x1004));
		objSingleCollection.add(new Tag(0x0032,0x0032));
		objSingleCollection.add(new Tag(0x0032,0x0033));
		objSingleCollection.add(new Tag(0x0032,0x1040));
		objSingleCollection.add(new Tag(0x0032,0x1041));
		objSingleCollection.add(new Tag(0x0032,0x1050));
		objSingleCollection.add(new Tag(0x0032,0x1051));
	}

	/* (non-Javadoc)
	 * @see cdac.medinfo.sdk.dcm30_04.dicommodel.modules.Module#validateModule()
	 */
	public boolean validateModule() throws InvalidModuleException
	{
		/*
		 * Study Acquisition Module does not define type of its attributes
		 */
		return true;
	}

	/**
	 * Sets Date that patient arrived at study check-in location.
	 * 
	 * @param strStudyArrivalDate String value of Study Arrival Date.
	 */
	public void setStudyArrivalDate(String strStudyArrivalDate)
	{
		/*Accept User or equipment generated Study Arrival Date in String format of type DA.
		 * 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 Hash Map
		 */
		addDataElement(0x0032,0x1040, DicomConstants.DCM_DT_DA, strStudyArrivalDate	);
	}

	/**
	 * Sets Time at which patient arrived at study check-in location.
	 * 
	 * @param strStudyArrivalTime  String value of Study Arrival Time.
	 */
	public void setStudyArrivalTime(String strStudyArrivalTime)
	{
		/*Accept User or equipment generated Study Arrival Time in String format of type TM.
		 * 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 Hash Map
		 */
		addDataElement(0x0032,0x1041, DicomConstants.DCM_DT_TM, strStudyArrivalTime);
	}

	/**
	 * Sets Date on which the acquisition of the study information was started.
	 * 
	 * @param strStudyDate String value of Study Date.
	 */
	public void setStudyDate(String strStudyDate)
	{
		/*Accept Date on which the Study started in String format of type DA.
		 * 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 Hash Map
		 */
		addDataElement(0x0008, 0x0020, DicomConstants.DCM_DT_DA, strStudyDate);
	}

	/**
	 * Sets Time at which the acquisition of the study information was started.
	 * 
	 * @param strStudyTime String value of Study time.
	 */
	public void setStudyTime(String strStudyTime)
	{
		/*Accept Time on which the Study started in String format of type TM.
		 * 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 Hash Map
		 */
		addDataElement(0x0008, 0x0030, DicomConstants.DCM_DT_TM, strStudyTime);
	}

	/**
	 * Sets Date on which the acquisition of study information was completed.
	 * 
	 * @param strStudyCompletionDate String value of Study Completion Date.
	 */
	public void setStudyCompletionDate(String strStudyCompletionDate)
	{
		/*Accept User or equipment generated Study Completion Date in String format of type DA.
		 * 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 Hash Map
		 */
		addDataElement(0x0032,0x1050, DicomConstants.DCM_DT_DA, strStudyCompletionDate);
	}

	/**
	 * Sets Time at which the acquisition of study information was completed.
	 * 
	 * @param strStudyCompletionTime String value of Study Completion Time.
	 */
	public void setStudyCompletionTime(String strStudyCompletionTime)
	{
		/*Accept User or equipment generated Study Completion Time in String format of type DA.
		 * 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 Hash Map
		 */
		addDataElement(0x0032,0x1051, DicomConstants.DCM_DT_TM, strStudyCompletionTime	);
	}

	/**
	 * Date on which the image quality for the patient examination was verified.
	 * 
	 * @param strStudyVerifiedDate String value of Study Verified Date.
	 */
	public void setStudyVerifiedDate(String strStudyVerifiedDate)
	{
		/*Accept User or equipment generated Study Verified Date in String format of type DA.
		 * 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 Hash Map
		 */
		addDataElement(0x0032,0x0032, DicomConstants.DCM_DT_DA, strStudyVerifiedDate);
	}

	/**
	 * Time at which the image quality for the patient examination was verified.
	 * 
	 * @param strStudyVerifiedTime String value of Study Verified Time.
	 */
	public void setStudyVerifiedTime(String strStudyVerifiedTime)
	{
		/*Accept User or equipment generated Study Verified Time in String format of type DA.
		 * 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 Hash Map
		 */
		addDataElement(0x0032,0x0033, DicomConstants.DCM_DT_TM, strStudyVerifiedTime	);
	}

	/**
	 * This Attribute may take one or more of the values defined for Modality (0008,0060).
	 * 
	 * @param arrStrModalitiesInStudy String array of Modalities In Study.
	 */
	public void setModalitiesInStudy(String[] arrStrModalitiesInStudy)
	{
		/*Accept Scheduled Name of Physician(s) Reading Study in String Array 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 Data Set
		 */
		addDataElement(0x0008, 0x0061, DicomConstants.DCM_DT_CS, arrStrModalitiesInStudy);
	}

	/**
	 * Number of series in the study.
	 * 
	 * @param strSeriesInStudy String value of Series In Study.
	 */
	public void setSeriesInStudy(String strSeriesInStudy)
	{
		/*Accept User or equipment generated Series in Study in String format of type IS.
		 * 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 Hash Map
		 */
		addDataElement(0x0020,0x1000, DicomConstants.DCM_DT_IS, strSeriesInStudy	);
	}

	/**
	 * Number of image data acquisitions used in performing the study.
	 * 
	 * @param strAcquisitionsInStudy String value of Acquisition in study.
	 */
	public void setAcquisitionsInStudy(String strAcquisitionsInStudy)
	{
		/*Accept User or equipment generated Acquisitions in Study in String format of type IS.
		 * 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 Hash Map
		 */
		addDataElement(0x0020,0x1004, DicomConstants.DCM_DT_IS, strAcquisitionsInStudy	);
	}

	/**
	 * Retrieves Date that patient arrived at study check-in location.
	 * 
	 * @return String - String value of Study Arrival Date
	 */
	public String getStudyArrivalDate()
	{Object objectValue = getValue(0x0032,0x1040);
		if(objectValue!=null)
			return objectValue.toString();
		return null;
	}

	/**
	 * Retrieves Time at which patient arrived at study check-in location.
	 * 
	 * @return String - String value of Study Arrival Time
	 */
	public String getStudyArrivalTime()
	{Object objectValue = getValue(0x0032,0x1041);
		if(objectValue!=null)
			return objectValue.toString();
		return null;
	}

	/**
	 * Retrieves Date on which the acquisition of the study information was started.
	 * 
	 * @return String - String value of Study Date
	 */
	public String getStudyDate()
	{Object objectValue = getValue(0x0008,0x0020);
		if(objectValue!=null)
			return objectValue.toString();
		return null;
	}

	/**
	 * Retrieves Time at which the acquisition of the study information was started.
	 * 
	 * @return String - String value of Study Time
	 */
	public String getStudyTime()
	{Object objectValue = getValue(0x0008,0x0030);
		if(objectValue!=null)
			return objectValue.toString();
		return null;
	}

	/**
	 * Retrieves Date on which the acquisition of study information was completed.
	 * 
	 * @return String - String value of Study Completion Date
	 */
	public String getStudyCompletionDate()
	{Object objectValue = getValue(0x0032,0x1050);
		if(objectValue!=null)
			return objectValue.toString();
		return null;
	}

	/**
	 * Retrieves Time at which the acquisition of study information was completed.
	 * 
	 * @return String - String value of Study Completion Time
	 */
	public String getStudyCompletionTime()
	{Object objectValue = getValue(0x0032,0x1051);
		if(objectValue!=null)
			return objectValue.toString();
		return null;
	}

	/**
	 * Retrieves Date on which the image quality for the patient examination was verified.
	 * 
	 * @return String - String value of Study Verified Date
	 */
	public String getStudyVerifiedDate()
	{Object objectValue = getValue(0x0032,0x0032);
		if(objectValue!=null)
			return objectValue.toString();
		return null;
	}

	/**
	 * Retrieves Time at which the image quality for the patient examination was verified.
	 * 
	 * @return String - String value of Study Verified Time.
	 */
	public String getStudyVerifiedTime()
	{Object objectValue = getValue(0x0032,0x0033);
		if(objectValue!=null)
			return objectValue.toString();
		return null;
	}

	/**
	 * Retrieves This Attribute may take one or more of the values defined for Modality (0008,0060).
	 * 
	 * @return String[] - String array of Modalities In Study.
	 */
	public String[] getModalitiesInStudy()
	{Object objectValue = getValue(0x0008,0x0061);
		if(objectValue!=null)
			return (String[])objectValue;
		return null;
	}

	/**
	 * Retrieves Number of series in the study.
	 * 
	 * @return String - String value of Acquisitions In Study.
	 */
	public String getAcquisitionsInStudy()
	{Object objectValue = getValue(0x0020,0x1004);
		if(objectValue!=null)
			return objectValue.toString();
		return null;
	}

	/**
	 * Retrieves Number of image data acquisitions used in performing the study.
	 * 
	 * @return String - String value of Series In Study.
	 */
	public String getSeriesInStudy()
	{Object objectValue = getValue(0x0020,0x1000);
		if(objectValue!=null)
			return objectValue.toString();
		return null;
	}

	/* 
	 * I have modified the collection type from vector to custom class
	 * This method is used by the Module Iterator to iterate through the DataSet and return only
	 * those elements that belong to the respective Module class whose getVectorOfKeys is called.
	 */
	/**
	 * 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;
	}
}
