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

import cdac.medinfo.sdk.dcm30_04.baselibs.ContentSequenceItem;
import cdac.medinfo.sdk.dcm30_04.enums.EnumContinuityOfContent;
import cdac.medinfo.sdk.dcm30_04.srtree.SRTree;
import cdac.medinfo.sdk.dcm30_04.templates.cid.OBGYNDates_CID12003;
import cdac.medinfo.sdk.dcm30_04.templates.enums.EnumCodingSchemeDesignator;
import cdac.medinfo.sdk.dcm30_04.templates.enums.cm.EnumCM_OBGYNDates;
import cdac.medinfo.sdk.dcm30_04.templates.enums.cm.EnumCM_ObstetricHistory;
import cdac.medinfo.sdk.dcm30_04.templates.enums.cm.EnumCM_Unit;
import cdac.medinfo.sdk.dcm30_04.templates.enums.cv.EnumCV_ObstetricHistory;
import cdac.medinfo.sdk.dcm30_04.templates.enums.cv.EnumCV_Unit;
import cdac.medinfo.sdk.dcm30_04.templates.generaltemplates.Template;

/**
 * This class represents ObstetricHistory - TID9006
 */
public class ObstetricHistory_TID9006 extends Template
{

	/**
	 * Object of OB_GYNDates_CID12003
	 */
	private OBGYNDates_CID12003 objOBGYNDatesCID12003;
	
	/**
	 * Instantiates ObstetricHistory_TID9006 Template.
	 * @param objTree Object of SRTree.
	 */
	public ObstetricHistory_TID9006(SRTree objTree)
	{
		super(objTree);
	}

	/**
	 * Sets value for OBGYNDates.
	 * @param arrPosition Identifier which shows the position of the node in the SR Tree.
	 * @param enumOBGYNDates Enumerated value for OB-GYNDates.
	 * @param strValue 
	 */
	public void setOBGYNDates(int[] arrPosition, EnumCM_OBGYNDates enumOBGYNDates, String strValue)
	{

		/**
		 * Setting value for OBGYNDates
		 */
		if(null== this.objOBGYNDatesCID12003)
			this.objOBGYNDatesCID12003 = new OBGYNDates_CID12003();
		this.objOBGYNDatesCID12003.setOBGYNDates(enumOBGYNDates);

		String strCM = objOBGYNDatesCID12003.getCodeMeaning();
		String strCV = objOBGYNDatesCID12003.getCodeValue();
		String strCSD = objOBGYNDatesCID12003.getCodingSchemeDesignator();

		/**
		 * Creating a node of Value Type DATE and adding this node at specified identifier in the SR Tree.
		 */
		ContentSequenceItem objContentSequenceItem = getSRTree().createDateNode(arrPosition, strCSD, strValue,strCV,strCM);
		getSRTree().addChild(objContentSequenceItem);
	}
	
	/**
	 * Sets the value for Obstetric History.
	 * @param arrPosition Identifier which shows the position of the node in the SR Tree.
	 * @param enumContinuityOfContent Enumerated Value for ContinuityOfContent.
	 */
	public void setObstetricHistory(int[] arrPosition, EnumContinuityOfContent enumContinuityOfContent)
	{
		/**
		 * Retrieves the corresponding values of CodeMeaning,CodeValue and CodingSchemeDesignator.
		 */
		String strCodeMeaning = EnumCM_ObstetricHistory.OBSTETRIC_HISTORY.getValue();
		String strCodeValue = EnumCV_ObstetricHistory.OBSTETRIC_HISTORY_R_20658.getValue();
		String strCSD = EnumCodingSchemeDesignator.DCM.getValue();

		/**
		 * Creating a node of Value Type CONTAINER and adding this node at specified identifier in the SR Tree.
		 */
		ContentSequenceItem objContentSequenceItem = getSRTree().createContainer(arrPosition, strCodeMeaning, strCodeValue, strCSD, enumContinuityOfContent);
		getSRTree().addChild(objContentSequenceItem);
	}

	/**
	 * Sets the value for Gestational Age.
	 * @param arrPosition Identifier which shows the position of the node in the SR Tree.
	 * @param arrNumericValue String array for Numeric Value.
	 */
	public void setGestationalAge(int[] arrPosition,String[] arrNumericValue)
	{
		/**
		 * Retrieves the corresponding values of CodeMeaning,CodeValue and CodingSchemeDesignator.
		 */
		String strCMForUnit = EnumCM_Unit.DAYS.getValue();
		String strCVForUnit = EnumCV_Unit.DAYS.getValue();
		String strCSDForUnit = EnumCodingSchemeDesignator.UCUM.getValue();

		/**
		 * Retrieves the corresponding values of CodeMeaning,CodeValue and CodingSchemeDesignator.
		 */
		String strCodeMeaning = EnumCM_ObstetricHistory.GESTATIONAL_AGE.getValue();
		String strCodeValue = EnumCV_ObstetricHistory.GESTATIONAL_AGE_18185_9.getValue();
		String strCSD = EnumCodingSchemeDesignator.LN.getValue();

		ContentSequenceItem objContentSequenceItem = getSRTree().createNumNode(arrPosition,strCodeMeaning,strCodeValue,strCSD,arrNumericValue,strCVForUnit,strCSDForUnit,"",strCMForUnit,"","","","");
		getSRTree().addChild(objContentSequenceItem);
	}

	/**
	 * Sets the value for Comment.
	 * @param arrPosition Identifier which shows the position of the node in the SR Tree.
	 * @param strComment String value for Comment
	 */
	public void setComment(int[] arrPosition, String strComment)
	{
		/**
		 * Retrieves the corresponding values of CodeMeaning,CodeValue and CodingSchemeDesignator.
		 */
		String strCodeMeaning = EnumCM_ObstetricHistory.COMMENT.getValue();
		String strCodeValue = EnumCV_ObstetricHistory.COMMENT_121106.getValue();
		String strCSD = EnumCodingSchemeDesignator.DCM.getValue();

		/**
		 * Creating a node of Value Type TEXT and adding this node at specified identifier in the SR Tree.
		 */
		ContentSequenceItem objContentSequenceItem = getSRTree().createTextNode(arrPosition, strCodeMeaning, strCodeValue, strCSD, strComment);
		getSRTree().addChild(objContentSequenceItem);
	}
}
