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

import java.util.Locale;


import cdac.medinfo.sdk.dcm30_04.templates.enums.EnumCodingSchemeDesignator;
import cdac.medinfo.sdk.dcm30_04.templates.enums.cm.EnumCM_AcquisitionModality;
import cdac.medinfo.sdk.dcm30_04.templates.enums.cm.EnumCM_DICOMDevices;
import cdac.medinfo.sdk.dcm30_04.templates.enums.cv.EnumCV_DICOMDevices;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConfig;
import cdac.medinfo.sdk.dcm30_04.utils.DicomLogger;

import cdac.medinfo.sdk.dcm30_04.utils.ResourceBundleWrapper;

/**
 * This class represents DICOMDevices - CID30
 */
public class DICOMDevices_CID30 
{
	
	/**
	 * The Code Value for template.
	 */
	private String strCodeValue = null;
	
	/**
	 * The Code Meaning for template.
	 */
	private String strCodeMeaning = null;
	
	/**
	 * The Coding Scheme Designator for template.
	 */
	private String strCodingSchemeDesignator;
	
	/**
	 * Object of AcquisitionModality_CID29
	 */
	private AcquisitionModality_CID29 objAcquisitionModality_CID29;
	
	/**
	 * Instantiates a new DICOMDevices_CID30 Template.
	 */
	public DICOMDevices_CID30() 
	{
		
	}
	
	/**
	 * Retrieves the value for CodeMeaning
	 * @return strCodeMeaning String value for CodeMeaning
	 */
	public String getCodeMeaning() {
		return strCodeMeaning;
	}

	/**
	 * Retrieves the value for CodeValue
	 * @return strCodeValue String value for CodeValue
	 */
	public String getCodeValue() {
		return strCodeValue;
	}

	/**
	 * Retrieves the value for CodingSchemeDesignator
	 * @return strCodingSchemeDesignator String value for CodingSchemeDesignator
	 */
	public String getCodingSchemeDesignator() {
		return strCodingSchemeDesignator;
	}
	
	/**
	 * Sets the Code Value according to Code Meaning.
	 * @param enumDICOMDevices Object of EnumCM_DICOMDevices represents Code Meaning.
	 */
	private void setCodeValue(EnumCM_DICOMDevices enumDICOMDevices)
	{
		switch(enumDICOMDevices)
		{
		case ARCHIVE:
			this.strCodeValue = EnumCV_DICOMDevices.ARCHIVE_ARCHIVE.getValue();
			break;
		case COMPUTATION_SERVER:
			this.strCodeValue = EnumCV_DICOMDevices.COMPUTATION_SERVER_COMP.getValue();
			break;
		case COMPUTER_ASSISTED_DETECTION_DIAGNOSIS:
			this.strCodeValue = EnumCV_DICOMDevices.COMPUTER_ASSISTED_DETECTION_DIAGNOSIS_CAD.getValue();
			break;
		case DEPARTMENT_SYSTEM_SCHEDULER:
			this.strCodeValue = EnumCV_DICOMDevices.DEPARTMENT_SYSTEM_SCHEDULER_DSS.getValue();
			break;
		case FILM_DIGITIZER:
			this.strCodeValue = EnumCV_DICOMDevices.FILM_DIGITIZER_FILMD.getValue();
			break;
		case HARD_COPY_PRINT_SERVER:
			this.strCodeValue = EnumCV_DICOMDevices.HARD_COPY_PRINT_SERVER_PRINT.getValue();
			break;
		case IMAGE_CAPTURE:
			this.strCodeValue = EnumCV_DICOMDevices.IMAGE_CAPTURE_CAPTURE.getValue();
			break;
		case MEDIA_CREATION_DEVICE:
			this.strCodeValue = EnumCV_DICOMDevices.MEDIA_CREATION_DEVICE_MCD.getValue();
			break;
		case PROCEDURE_LOGGING:
			this.strCodeValue = EnumCV_DICOMDevices.PROCEDURE_LOGGING_LOG.getValue();
			break;
		case RADIATION_THERAPY_DEVICE:
			this.strCodeValue = EnumCV_DICOMDevices.RADIATION_THERAPY_DEVICE_RT.getValue();
			break;
		case WORKSTATION:
			this.strCodeValue = EnumCV_DICOMDevices.WORKSTATION_WSD.getValue();
			break;
		}
	}
	
	/**
	 * Sets the value for DICOMDevices
	 * @param enumValue This value can be one of the Enums - EnumCM_DICOMDevices, EnumAcquisitionModality
	 */
	public void setDICOMDevices(Enum enumValue)
	{
		if (enumValue instanceof EnumCM_DICOMDevices) 
		{
			/**
			 * Casting EnumValue to required Enum.
			 */
			EnumCM_DICOMDevices new_enumDICOMDevices = (EnumCM_DICOMDevices)enumValue;
			
			this.strCodeMeaning = new_enumDICOMDevices.getValue();
			this.strCodingSchemeDesignator = EnumCodingSchemeDesignator.SRT.getValue();
			setCodeValue(new_enumDICOMDevices);
		}
		else if(enumValue instanceof EnumCM_AcquisitionModality)
		{
			/**
			 * Casting EnumValue to required Enum.
			 */
			EnumCM_AcquisitionModality new_enumAcquisitionModality = (EnumCM_AcquisitionModality) enumValue;
			
			/**
			 * Creating object of require CID with respect to enum and setting value accordingly.
			 */
			if(null== this.objAcquisitionModality_CID29)
	this.objAcquisitionModality_CID29 = new AcquisitionModality_CID29();
			this.objAcquisitionModality_CID29.setAcquisitionModality(new_enumAcquisitionModality);
			
			/**
			 * Retrieving attributes and setting it to member variables. 
			 */
			this.strCodeMeaning = objAcquisitionModality_CID29.getCodeMeaning();
			this.strCodeValue = objAcquisitionModality_CID29.getCodeValue();
			this.strCodingSchemeDesignator = objAcquisitionModality_CID29.getCodingSchemeDesignator();
		}
		else
		{
			if(DicomConfig.createInstance().isLoggingOn())
			{
				DicomLogger objDicomLogger = DicomLogger.getLogger();
				objDicomLogger.log(ResourceBundleWrapper.getValue("warning","InvalidEnumeratedValue",new Locale(DicomConfig.createInstance().getLocale())));
			}
		}
	}
}
