/*******************************************************************************
 *  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 cdac.medinfo.sdk.dcm30_04.templates.enums.EnumCodingSchemeDesignator;
import cdac.medinfo.sdk.dcm30_04.templates.enums.cm.EnumCM_FamilyMember;
import cdac.medinfo.sdk.dcm30_04.templates.enums.cm.EnumCM_OrganizationalRoles;
import cdac.medinfo.sdk.dcm30_04.templates.enums.cm.EnumCM_PersonRoles;
import cdac.medinfo.sdk.dcm30_04.templates.enums.cv.EnumCV_PersonRoles;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConfig;
import cdac.medinfo.sdk.dcm30_04.utils.DicomLogger;
import cdac.medinfo.sdk.dcm30_04.utils.ResourceBundleWrapper;

import java.util.Locale;

import cdac.medinfo.sdk.dcm30_04.templates.dicomsnomedmap.EnumDICOMSNOMEDMap;

/**
 * This class represents PersonRoles CID7450
 */
public class PersonRoles_CID7450 {

	/**
	 * The Code Value for template.
	 */
	private String strCodeValue = null;
	/**
	 * Object of FamilyMember_CID7451
	 */
	private FamilyMember_CID7451 objFamilyMemberCID7451;
	
	/**
	 * Object of OrganizationalRoles_CID7452
	 */
	private OrganizationalRoles_CID7452 objOrganizationalRolesCID7452;
	/**
	 * The Code Meaning for template.
	 */
	private String strCodeMeaning = null;

	/**
	 * The Coding Scheme Designator for template.
	 */
	private String strCodingSchemeDesignator;

	/**
	 * The SNOMED CT ID for template.
	 */
	private String strSNOMEDCTID = null;
	/**
	 * Instantiates a new PersonRoles_CID7450 Template 
	 */
	public PersonRoles_CID7450()
	{

	}

	/**
	 * Retrieves the value for Code Meaning.
	 * @return String value for Code Meaning.
	 */
	public String getCodeMeaning()
	{
		return strCodeMeaning;
	}

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

	/**
	 * Retrieves the value for Coding Scheme Designator.
	 * @return String value for Coding Scheme Designator.
	 */
	public String getCodingSchemeDesignator() 
	{
		return strCodingSchemeDesignator;
	}
	
	/**
	 * Retrieves the value for SNOMED-CT ID.
	 * @return String value for SNOMED-CT ID.
	 */
	public String getSNOMEDCTID() 
	{
		return strSNOMEDCTID;
	}
	/**
	 * Sets the Code Value according to Code Meaning.
	 * @param enumPersonRoles Object of EnumCM_PersonRoles represents Code Meaning.
	 */
	private void setCodeValue(EnumCM_PersonRoles enumPersonRoles)
	{
		switch(enumPersonRoles) 
		{
		case PATIENT: this.strCodeValue =EnumCV_PersonRoles.PATIENT_121025.getValue(); break;
		case HEALTHCARE_PROFESSIONAL: this.strCodeValue =EnumCV_PersonRoles.HEALTHCARE_PROFESSIONAL_J_00552.getValue(); break;
		case FRIEND: this.strCodeValue =EnumCV_PersonRoles.FRIEND_S_11090.getValue(); break;
		}
	}

	/**
	 * Sets the SNOMED-CT ID.
	 * @param enumPersonRoles Object of EnumCM_PersonRoles represents Code Meaning.
	 */
	private void setSNOMEDCTID(EnumCM_PersonRoles enumPersonRoles)
	{
		switch(enumPersonRoles)
		{
		case HEALTHCARE_PROFESSIONAL : this.strSNOMEDCTID =EnumDICOMSNOMEDMap.HEALTHCARE_PROFESSIONAL.getSNOMEDCTID(); break;
		case FRIEND : this.strSNOMEDCTID =EnumDICOMSNOMEDMap.FRIEND.getSNOMEDCTID(); break;
		}
	}

	/**
	 * Sets the value for PersonRoles
	 * @param enumPersonRoles Object of EnumCM_PersonRoles.
	 */
	public void setPersonRoles(Enum enumValue)
	{
		if (enumValue instanceof EnumCM_PersonRoles) 
	{
		/**
		 * Casting EnumValue to required Enum.
		 */
		EnumCM_PersonRoles new_enumPersonRoles = (EnumCM_PersonRoles)enumValue;
		
		this.strCodeMeaning = new_enumPersonRoles.getValue();
		if(this.strCodeMeaning.equalsIgnoreCase(EnumCM_PersonRoles.PATIENT.getValue()))
			this.strCodingSchemeDesignator = EnumCodingSchemeDesignator.DCM.getValue();
		else
			this.strCodingSchemeDesignator = EnumCodingSchemeDesignator.SRT.getValue();
		setCodeValue(new_enumPersonRoles);
		/**
		 * set SNOMED-CT ID
		 */
		setSNOMEDCTID(new_enumPersonRoles);
	}
	else if(enumValue instanceof EnumCM_FamilyMember)
	{
		/**
		 * Casting EnumValue to required Enum.
		 */
		EnumCM_FamilyMember new_enumFamilyMember = (EnumCM_FamilyMember) enumValue;
		
		/**
		 * Creating object of require CID with respect to enum and setting value accordingly.
		 */
		if(null== this.objFamilyMemberCID7451)
this.objFamilyMemberCID7451 = new FamilyMember_CID7451();
		this.objFamilyMemberCID7451.setFamilyMember(new_enumFamilyMember);
		
		/**
		 * Retrieving attributes and setting it to member variables. 
		 */
		this.strCodeMeaning = objFamilyMemberCID7451.getCodeMeaning();
		this.strCodeValue = objFamilyMemberCID7451.getCodeValue();
		this.strCodingSchemeDesignator = objFamilyMemberCID7451.getCodingSchemeDesignator();
		this.strSNOMEDCTID = objFamilyMemberCID7451.getSNOMEDCTID();
	}
	else if(enumValue instanceof EnumCM_OrganizationalRoles)
	{
		/**
		 * Casting EnumValue to required Enum.
		 */
		EnumCM_OrganizationalRoles new_enumOrganizationalRoles = (EnumCM_OrganizationalRoles) enumValue;
		
		/**
		 * Creating object of require CID with respect to enum and setting value accordingly.
		 */
		if(null== this.objOrganizationalRolesCID7452)
this.objOrganizationalRolesCID7452 = new OrganizationalRoles_CID7452();
		this.objOrganizationalRolesCID7452.setOrganizationalRoles(new_enumOrganizationalRoles);
		
		/**
		 * Retrieving attributes and setting it to member variables. 
		 */
		this.strCodeMeaning = objOrganizationalRolesCID7452.getCodeMeaning();
		this.strCodeValue = objOrganizationalRolesCID7452.getCodeValue();
		this.strCodingSchemeDesignator = objOrganizationalRolesCID7452.getCodingSchemeDesignator();
		this.strSNOMEDCTID = objOrganizationalRolesCID7452.getSNOMEDCTID();
		
	}
	else
	{
		if(DicomConfig.createInstance().isLoggingOn())
		{
			DicomLogger objDicomLogger = DicomLogger.getLogger();
			objDicomLogger.log(ResourceBundleWrapper.getValue("warning","InvalidEnumeratedValue",new Locale(DicomConfig.createInstance().getLocale())));
		}
	}
	}
}
