/*******************************************************************************
 *  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.EnumVisitStatusID;
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 the patient's stay with the healthcare provider.

 */
public class VisitStatusModule extends Module  
{

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

	/**
	 * Instantiates a new visit status module.
	 * 
	 * @param objIDataSet the obj i data set
	 */
	public VisitStatusModule(IDataSet objIDataSet)
	{
		super(objIDataSet);
	}

	static
	{
		objSingleCollection = new SingleCollection<ITag>();
		objSingleCollection.add(new Tag(0x0038,0x0008));
		objSingleCollection.add(new Tag(0x0038,0x0300));
		objSingleCollection.add(new Tag(0x0038,0x0400));
		objSingleCollection.add(new Tag(0x0038,0x4000));
	}

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

	/**
	 * Identifies the state of the visit. Defined Terms: CREATED = Created but not yet schedule ,
	 * SCHEDULED = Scheduled but not yet admitted,
	 * ADMITTED = Patient admitted to institution
	 * DISCHARGED = Patient Discharged
	 * 
	 * @param enumVisitStatusID Enum value of Visit Status ID.
	 */
	public void setVisitStatusID(EnumVisitStatusID enumVisitStatusID)
	{
		/*Accept Visit Status ID 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 Hash Map
		 */
		String strVisitStatusID = enumVisitStatusID.getValue();
		addDataElement(0x0038,0x0008, DicomConstants.DCM_DT_CS, strVisitStatusID);
	}

	/**
	 * Describes the current known location of the patient.
	 * 
	 * @param strCurrentPatientLocation String value of Current Patient Location.
	 */
	public void setCurrentPatientLocation(String strCurrentPatientLocation)
	{
		/*Accept Current Patient Location 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 Hash Map
		 */
		addDataElement(0x0038, 0x0300, DicomConstants.DCM_DT_LO, strCurrentPatientLocation);
	}

	/**
	 * Primary location where patient resides (ward, floor,room, etc. or outpatient)
	 * 
	 * @param strPatientInstitutionResidence String value of Patients Institution Residence.
	 */
	public void setPatientInstitutionResidence(String strPatientInstitutionResidence)
	{
		/*Accept Patients Institution Residence 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 Hash Map
		 */
		addDataElement(0x0038, 0x0400, DicomConstants.DCM_DT_LO, strPatientInstitutionResidence);
	}

	/**
	 * User-defined comments about the visit.
	 * 
	 * @param strVisitComments String value of Visit Comments.
	 */
	public void setVisitComments(String strVisitComments)
	{
		/*Accept Visit Comments String format of type LT.
		 * 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(0x0038, 0x4000, DicomConstants.DCM_DT_LT, strVisitComments);
	}

	/**
	 * Retrieves the state of the visit.
	 * 
	 * @return String - String value of Visit Status ID
	 */
	public String getVisitStatusID()
	{Object objectValue = getValue(0x0038,0x0008);
		if(objectValue!=null)
			return objectValue.toString();
		return null;
	}

	/**
	 * Retrieves the current known location of the patient.
	 * 
	 * @return String - String value of Current Patient Location
	 */
	public String getCurrentPatientLocation()
	{Object objectValue = getValue(0x0038,0x0300);
		if(objectValue!=null)
			return objectValue.toString();
		return null;
	}

	/**
	 * Retrieves Primary location where patient resides(ward, floor,room, etc. or outpatient)
	 * 
	 * @return String - String value of Patients Institution Residence
	 */
	public String getPatientInstitutionResidence()
	{Object objectValue = getValue(0x0038,0x0400);
		if(objectValue!=null)
			return objectValue.toString();
		return null;
	}

	/**
	 * Retrieves User-defined comments about the visit.
	 * 
	 * @return String - String value of Visit Comments
	 */
	public String getVisitComments()
	{Object objectValue = getValue(0x0038,0x4000);
		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;
	}
}
