/*******************************************************************************
 *  Copyright 2017 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.hl7282.baselibs.segments;

import cdac.medinfo.sdk.hl7282.baselibs.CNE;
import cdac.medinfo.sdk.hl7282.baselibs.NM;
import cdac.medinfo.sdk.hl7282.baselibs.NR;
import cdac.medinfo.sdk.hl7282.commoninterface.IDataType;
import cdac.medinfo.sdk.hl7282.commoninterface.ISingleCollection;
import cdac.medinfo.sdk.hl7282.utils.EnumSegments;


/**
 * DMI - Clinical Study Schedule Master Segment<p>
 * The Clinical Study Schedule Master (DMI) contains the information about the scheduled
 * time which points for study or phase-related treatment or evaluation events.  
 * <p>Represents an HL7 DMI message segment. 
 * This segment has the following fields:</p><p>
 * DMI-1: Diagnostic Related Group  (CNE)<b>Optional</b><br> 
 * DMI-2: Major Diagnostic Category (CNE)<b>Conditional</b><br> 
 * DMI-3: Lower and Upper Trim Points (NR)<b>Conditional</b><br> 
 * DMI-4: Average Length of Stay (NM)<b>Conditional</b><br>
 * DMI-5: Relative Weight (NM)<b>Conditional</b><br><p> 
 * This class provides mechanism to validate message against HL7 v 2.8.2 standard.
 * The class provides accessors & mutators for the elements mentioned above.
 * The class has validate method which validates Message against HL7 v 2.8.2 standard.
 *
 * <p>User can also create Segment through {@link SegmentFactory}
 */
public class DMI extends Segment   
{
	

	/**
	 * Constructs the DMI segment.
	 */
	public DMI()
	{super(EnumSegments.HL7_SEG_DMI);
	}
	
	/**
	 * Retrieves the Diagnostic Related Group .
	 * This field contains the DRG for the transaction.  Interim DRG's could be determined for an encounter.     
	 * @return CNE - cne
	 */
	public CNE getDiagnosticRelatedGroup () 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(382 );
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (CNE)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Set the Diagnostic Related Group .
	 * This field contains the DRG for the transaction.  Interim DRG's could be determined for an encounter.   
	 * @param strIdentifier Specifies sequence of characters (the code) that uniquely identifies
	 * 						 the item being referenced by the CNE.
	 * @param strText Specifies descriptive or textual name of the identifier, e.g., myocardial infarction 
	 * @param strNameOfCodingSystem Specifies the coding scheme being used in the identifier component. 
	 * @param strAlternateIdentifier Specifies the local or user seen code as described. 
	 * @param strAlternateText Specifies descriptive or textual name of the alternate identifier.  
	 * @param strNameOfAlternateCodingSystem Specifies the coding scheme being used in the alternate identifier 
	 * 											component.  
	 * @param strCodingSystemVersionID Specifies the version ID for the coding system. 
	 * @param strAlternateCodingSystemVersionID Specifies the version ID for the coding system .
	 * @param strOriginalText Specifies the original text that was available to an automated process or a human 
	 * 							before a specific code was assigned.
	 * @param strSecondAlternateIdentifier Specifies a sequence of characters that uniquely identifies the second alternate code
	 * @param strSecondAlternateText Specifies a the textual information of the second alternate code
	 * @param strNameOfSecondAltenateCodingSystem Specifies the second coding scheme being used in the identifier component.
	 * @param strSecondAlternateCodingSystemVersionID Specifies version ID of Second alternative coding system.
	 * @param strCodingSystemOID contains the ISO Object identifier for the coding system.
	 * @param strValueSetOID contains the value set from which CNE-1 is obtained 
	 * @param strValueSetVersionID contains the version of the value set identified by CNE-15. 
	 * @param strAlternateCodingSystemOID contains the ISO Object identifier for the alternate coding system
	 * @param strAlternateValueSetOID contains the value set from which CNE-4 is obtained
	 * @param strAlternateValueSetVersionID contains the version of the value set identified by CNE-18. 
	 * @param strSecondAlternateCodingSystemOID contains the value set from which CNE-12 is obtained
	 * @param strSecondAlternateValueSetOID contains the value set from which CNE-10 is obtained
	 * @param strSecondAlternateValueSetVersionID contains the version of the value set identified by CNE-21. 
	 */ 
	public void setDiagnosticRelatedGroup  (String strIdentifier,String strText,String strNameOfCodingSystem,String strAlternateIdentifier,
			String strAlternateText,String strNameOfAlternateCodingSystem,String strCodingSystemVersionID,
			String strAlternateCodingSystemVersionID,String strOriginalText, String strSecondAlternateIdentifier, String strSecondAlternateText,
			String strNameOfSecondAltenateCodingSystem, String strSecondAlternateCodingSystemVersionID, String strCodingSystemOID, 
			String strValueSetOID, String strValueSetVersionID, String strAlternateCodingSystemOID, String strAlternateValueSetOID,
			String strAlternateValueSetVersionID, String strSecondAlternateCodingSystemOID, String strSecondAlternateValueSetOID,
			String strSecondAlternateValueSetVersionID)
	{
		CNE cne  = (CNE)getDataElement(382);
		cne.setIdentifier(strIdentifier);
		cne.setText(strText);
		cne.setNameOfCodingSystem(strNameOfCodingSystem);
		cne.setAlternateIdentifier(strAlternateIdentifier);
		cne.setAlternateText(strAlternateText);
		cne.setNameOfAlternateCodingSystem(strNameOfAlternateCodingSystem);
		cne.setCodingSystemVersionID(strCodingSystemVersionID);
		cne.setAlternateCodingSystemVersionID(strAlternateCodingSystemVersionID);
		cne.setOriginalText(strOriginalText); 
		cne.setSecondAlternateIdentifier(strSecondAlternateIdentifier);
		cne.setSecondAlternateText(strSecondAlternateText);
		cne.setNameofSecondAlternateCodingSystem(strNameOfSecondAltenateCodingSystem);
		cne.setSecondAlternateCodingSystemVersionID(strSecondAlternateCodingSystemVersionID);
		cne.setCodingSystemOID(strCodingSystemOID);
		cne.setValueSetOID(strValueSetOID);
		cne.setValueSetVersionID(strValueSetVersionID);
		cne.setAlternateCodingSystemOID(strAlternateCodingSystemOID);
		cne.setAlternateValueSetOID(strAlternateValueSetOID);
		cne.setAlternateValueSetVersionID(strAlternateValueSetVersionID);
		cne.setSecondAlternateCodingSystemOID(strSecondAlternateCodingSystemOID);
		cne.setSecondAlternateValueSetOID(strSecondAlternateValueSetOID);
		cne.setSecondAlternateValueSetVersionID(strSecondAlternateValueSetVersionID);
		setDiagnosticRelatedGroup (cne);

	} 

	
	/** Set the Diagnostic Related Group .
	 * This field contains the DRG for the transaction.  Interim DRG's could be determined for an encounter.   
	 * @param objcne object of Diagnostic Related Group .
	 */ 
	public void setDiagnosticRelatedGroup (CNE objcne)
	{
		setDataType(382,objcne);
	}
	
	/** Get the Major Diagnostic Category.
	 * This field indicates the determined Major Diagnostic Category (MDC) value. 
	 * @param objcne object of Major Diagnostic Category.
	 */ 
	
	public CNE getMajorDiagnosticCategoryGroup () 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(381 );
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (CNE)objDataCollection.elementAt(0);
		else
			return null;
	}
	/**
	 * Set the Major Diagnostic Category.
	 * This field indicates the determined Major Diagnostic Category (MDC) value. 
	 * @param strIdentifier Specifies sequence of characters (the code) that uniquely identifies
	 * 						 the item being referenced by the CNE.
	 * @param strText Specifies descriptive or textual name of the identifier, e.g., myocardial infarction 
	 * @param strNameOfCodingSystem Specifies the coding scheme being used in the identifier component. 
	 * @param strAlternateIdentifier Specifies the local or user seen code as described. 
	 * @param strAlternateText Specifies descriptive or textual name of the alternate identifier.  
	 * @param strNameOfAlternateCodingSystem Specifies the coding scheme being used in the alternate identifier 
	 * 											component.  
	 * @param strCodingSystemVersionID Specifies the version ID for the coding system. 
	 * @param strAlternateCodingSystemVersionID Specifies the version ID for the coding system .
	 * @param strOriginalText Specifies the original text that was available to an automated process or a human 
	 * 							before a specific code was assigned.
	 * @param strSecondAlternateIdentifier Specifies a sequence of characters that uniquely identifies the second alternate code
	 * @param strSecondAlternateText Specifies a the textual information of the second alternate code
	 * @param strNameOfSecondAltenateCodingSystem Specifies the second coding scheme being used in the identifier component.
	 * @param strSecondAlternateCodingSystemVersionID Specifies version ID of Second alternative coding system.
	 * @param strCodingSystemOID contains the ISO Object identifier for the coding system.
	 * @param strValueSetOID contains the value set from which CNE-1 is obtained 
	 * @param strValueSetVersionID contains the version of the value set identified by CNE-15. 
	 * @param strAlternateCodingSystemOID contains the ISO Object identifier for the alternate coding system
	 * @param strAlternateValueSetOID contains the value set from which CNE-4 is obtained
	 * @param strAlternateValueSetVersionID contains the version of the value set identified by CNE-18. 
	 * @param strSecondAlternateCodingSystemOID contains the value set from which CNE-12 is obtained
	 * @param strSecondAlternateValueSetOID contains the value set from which CNE-10 is obtained
	 * @param strSecondAlternateValueSetVersionID contains the version of the value set identified by CNE-21. 
	 */ 
	public void setMajorDiagnosticCategory (String strIdentifier,String strText,String strNameOfCodingSystem,String strAlternateIdentifier,
			String strAlternateText,String strNameOfAlternateCodingSystem,String strCodingSystemVersionID,
			String strAlternateCodingSystemVersionID,String strOriginalText, String strSecondAlternateIdentifier, String strSecondAlternateText,
			String strNameOfSecondAltenateCodingSystem, String strSecondAlternateCodingSystemVersionID, String strCodingSystemOID, 
			String strValueSetOID, String strValueSetVersionID, String strAlternateCodingSystemOID, String strAlternateValueSetOID,
			String strAlternateValueSetVersionID, String strSecondAlternateCodingSystemOID, String strSecondAlternateValueSetOID,
			String strSecondAlternateValueSetVersionID)
	{
		CNE cne  = (CNE)getDataElement(381);
		cne.setIdentifier(strIdentifier);
		cne.setText(strText);
		cne.setNameOfCodingSystem(strNameOfCodingSystem);
		cne.setAlternateIdentifier(strAlternateIdentifier);
		cne.setAlternateText(strAlternateText);
		cne.setNameOfAlternateCodingSystem(strNameOfAlternateCodingSystem);
		cne.setCodingSystemVersionID(strCodingSystemVersionID);
		cne.setAlternateCodingSystemVersionID(strAlternateCodingSystemVersionID);
		cne.setOriginalText(strOriginalText); 
		cne.setSecondAlternateIdentifier(strSecondAlternateIdentifier);
		cne.setSecondAlternateText(strSecondAlternateText);
		cne.setNameofSecondAlternateCodingSystem(strNameOfSecondAltenateCodingSystem);
		cne.setSecondAlternateCodingSystemVersionID(strSecondAlternateCodingSystemVersionID);
		cne.setCodingSystemOID(strCodingSystemOID);
		cne.setValueSetOID(strValueSetOID);
		cne.setValueSetVersionID(strValueSetVersionID);
		cne.setAlternateCodingSystemOID(strAlternateCodingSystemOID);
		cne.setAlternateValueSetOID(strAlternateValueSetOID);
		cne.setAlternateValueSetVersionID(strAlternateValueSetVersionID);
		cne.setSecondAlternateCodingSystemOID(strSecondAlternateCodingSystemOID);
		cne.setSecondAlternateValueSetOID(strSecondAlternateValueSetOID);
		cne.setSecondAlternateValueSetVersionID(strSecondAlternateValueSetVersionID);
		setMajorDiagnosticCategory(cne);

	} 

	/** Set the Major Diagnostic Category.
	 * This field indicates the determined Major Diagnostic Category (MDC) value. 
	 * @param objcne object of Major Diagnostic Category.
	 */ 
	public void setMajorDiagnosticCategory(CNE objcne)
	{
		setDataType(381,objcne);
	}
	
	/**
	 * Retrieves the Lower and Upper Trim Points.
	 * This field contains the lower and upper trim points as calculated for this DRG.
	 * @return String - LowerAndUpperTrimPoints
	 */
	public NR getLowerAndUpperTrimPoints() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(2231);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (NR)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Set the Lower and Upper Trim Points.
	 * This field contains the lower and upper trim points as calculated for this DRG.
     * @param objLowValue Specifies Low value
	 * @param objHighValue Specifies High Value. 
	 */ 
	public void setLowerAndUpperTrimPoints(NM objLowValue,NM objHighValue) 
	{
		NR nr  = (NR)getDataElement(2231);
		nr.setLowValue(objLowValue);
		nr.setHighValue(objHighValue);
		setLowerAndUpperTrimPoints(nr);

	} 

	/** Set the Lower and Upper Trim Points.
	 * This field contains the lower and upper trim points as calculated for this DRG.
	 * @param objLowerAndUpperTrimPoints object of Lower and Upper Trim Points. 
	 */ 
	public void setLowerAndUpperTrimPoints(NR objLowerAndUpperTrimPoints)
	{
		setDataType(2231,objLowerAndUpperTrimPoints);
	}
	
	/**
	 * Retrieves the Average Length of Stay.
	 * This field contains the average length of stay in days, calculated as the geometric mean value, allocated to the determined DRG.
	 * @return NM - RelativeWeight
	 */
	public NM getAverageLengthOfStay() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(2232);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (NM)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Set the Average Length of Stay.
	 * This field contains the average length of stay in days, calculated as the geometric mean value, allocated to the determined DRG.
	 * @param strAverageLengthOfStay String to be passed as Average Length of Stay
	 */ 
	public void setAverageLengthOfStay (String strAverageLengthOfStay) 
	{
		NM RelativeWeight  = (NM)getDataElement(2232);
		RelativeWeight.setValue(strAverageLengthOfStay); 
		setAverageLengthOfStay(RelativeWeight);

	} 

	/** 
	 * Set the Average Length of Stay.
	 * This field contains the average length of stay in days, calculated as the geometric mean value, allocated to the determined DRG.
	 * @param objRelativeWeight Object of Average Length of Stay.
	 */ 
	public void setAverageLengthOfStay(NM objRelativeWeight)
	{
		setDataType(2232,objRelativeWeight);

	}
	
	/**
	 * Retrieves the Relative Weight.
	 * Each DRG has its own relative weight (cost weight) which is calculated (defined) by official institutions. This value is the basis for calculating other values, e.g., the effective weight.
	 * @return NM - RelativeWeight
	 */
	public NM getRelativeWeight() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(2233);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (NM)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Set the Relative Weight.
	 * Each DRG has its own relative weight (cost weight) which is calculated (defined) by official institutions. This value is the basis for calculating other values, e.g., the effective weight.
	 * @param strRelativeWeight String to be passed as Relative Weight
	 */ 
	public void setRelativeWeight (String strRelativeWeight) 
	{
		NM RelativeWeight  = (NM)getDataElement(2233);
		RelativeWeight.setValue(strRelativeWeight); 
		setRelativeWeight(RelativeWeight);

	} 

	/** 
	 * Set the Relative Weight.
	 * Each DRG has its own relative weight (cost weight) which is calculated (defined) by official institutions. This value is the basis for calculating other values, e.g., the effective weight.
	 * @param objRelativeWeight Object of Relative Weight.
	 */ 
	public void setRelativeWeight(NM objRelativeWeight)
	{
		setDataType(2233,objRelativeWeight);

	}

}
