/*******************************************************************************
 *  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.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 identifying a study.
 */
public class StudyIdentificationModule extends Module  
{

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

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

	static
	{
		objSingleCollection = new SingleCollection<ITag>();
		objSingleCollection.add(new Tag(0x0020, 0x0010));
		objSingleCollection.add(new Tag(0x0032, 0x0012));
		objSingleCollection.add(new Tag(0x0020, 0x1070));
	}

	/* (non-Javadoc)
	 * @see cdac.medinfo.sdk.dcm30_04.dicommodel.modules.Module#validateModule()
	 */
	public boolean validateModule()
	{
		return true;
	}

	/**
	 * Sets User or equipment generated Study identifier.
	 * 
	 * @param strStudyID String value of Study ID.
	 */
	public void setStudyID(String strStudyID)
	{
		/*Accept User or equipment generated Study identifier in String format of type SH.
		 * 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
		 * 0x0008, 0x1062
		 */
		addDataElement(0x0020, 0x0010, DicomConstants.DCM_DT_SH, strStudyID);
	}

	/**
	 * Sets Name of healthcare provider that issued the Study ID.
	 * 
	 * @param strStudyIDIssuer String value of Study ID Issuer.
	 */
	public void setStudyIDIssuer(String strStudyIDIssuer)
	{
		/*Accept User or equipment generated Study ID Issuer in String format of type SH.
		 * 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, 0x0012, DicomConstants.DCM_DT_LO, strStudyIDIssuer);
	}

	/**
	 * Other identifiers assigned to study by institution.
	 * 
	 * @param arrStrOtherStudyNumbers String array of Other Study Numbers.
	 */
	public void setOtherStudyNumbers(String[] arrStrOtherStudyNumbers)
	{
		/*Accept Other Study Numbers in String Array format of type IS.
		 * 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(0x0020, 0x1070, DicomConstants.DCM_DT_IS, arrStrOtherStudyNumbers);
	}

	/**
	 * Retrieves User or equipment generated Study identifier.
	 * 
	 * @return String - String value of Study ID.
	 */
	public String getStudyID()
	{
		Object objectValue = getValue(0x0020, 0x0010);
		if(objectValue!=null)
			return objectValue.toString();
		return null;
	}

	/**
	 * Retrieves Name of healthcare provider that issued the Study ID.
	 * 
	 * @return String - String value of Study ID Issuer.
	 */
	public String getStudyIDIssuer()
	{
		Object objectValue = getValue(0x0032, 0x0012);
		if(objectValue!=null)
			return objectValue.toString();
		return null;
	}

	/**
	 * Retrieves Other identifiers assigned to study by institution.
	 * 
	 * @return String[] - String array of Other Study Numbers.
	 */
	public String[] getOtherStudyNumbers()
	{
		Object objectValue = getValue(0x0020, 0x1070);
		if(objectValue!=null)
			return (String[])objectValue;
		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;
	}
}
