/*******************************************************************************
 *  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.CWE;
import cdac.medinfo.sdk.hl7282.baselibs.DTM;
import cdac.medinfo.sdk.hl7282.baselibs.NM;
import cdac.medinfo.sdk.hl7282.commoninterface.IDataType;
import cdac.medinfo.sdk.hl7282.commoninterface.ISingleCollection;
import cdac.medinfo.sdk.hl7282.exceptions.InvalidSegmentException;
import cdac.medinfo.sdk.hl7282.utils.EnumSegments;

/**
 * CNS - Clear Notification Segment  <p>
 * The clear equipment notification segment contains the data necessary to allow the
 * receiving equipment to clear any associated notifications.
 * <p>Represents an HL7 CNS message segment. 
 * This segment has the following fields:</p><p>
 * CNS-1: Starting Notification Reference Number (NM)<b>Optional</b><br> 
 * CNS-2: Ending Notification Reference Number (NM)<b>Optional</b><br> 
 * CNS-3: Starting Notification Date/Time (DTM)<b>Optional</b><br> 
 * CNS-4: Ending Notification Date/Time (DTM)<b>Optional</b><br> 
 * CNS-5: Starting Notification Code (CWE)<b>Optional</b><br> 
 * CNS-6: Ending Notification Code (CWE)<b>Optional</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 CNS extends Segment    
{
	

	/**
	 *  Constructs the CNS segment.
	 */
	public CNS()
	{super(EnumSegments.HL7_SEG_CNS);
	}

	//Integer values used in getter/setter is unique item id defined 
	//for each attribute.

	/**
	 * Set the Starting Notification Reference Number.
	 * This field contains the starting notification reference number that is to be clear.
	 * @param strStartingNotificationReferenceNumber The quantity of the specified resource or resource type identified in either or both of the preceding two fields.  
	 */
	public void setStartingNotificationReferenceNumber(String strStartingNotificationReferenceNumber ) 
	{
		NM startingNotificationReferenceNumber  = (NM)getDataElement(1402);
		startingNotificationReferenceNumber.setValue(strStartingNotificationReferenceNumber);
		setStartingNotificationReferenceNumber(startingNotificationReferenceNumber);
	}

	/**
	 * Set the Starting Notification Reference Number.
	 * This field contains the starting notification reference number that is to be clear.
	 * @param objStartingNotificationReferenceNumber Object of Starting Notification Reference Number.
	 */
	public void setStartingNotificationReferenceNumber(NM objStartingNotificationReferenceNumber)
	{
		setDataType(1402,objStartingNotificationReferenceNumber);
	}

	/**
	 * Set the Ending Notification Reference Number.
	 * This field contains the ending notification reference number that is to be clear.
	 * @param strEndingNotificationReferenceNumber The quantity of the specified resource or resource type identified in either or both of the preceding two fields.  
	 */
	public void setEndingNotificationReferenceNumber(String strEndingNotificationReferenceNumber ) 
	{
		NM endingNotificationReferenceNumber  = (NM)getDataElement(1403);
		endingNotificationReferenceNumber.setValue(strEndingNotificationReferenceNumber);
		setEndingNotificationReferenceNumber(endingNotificationReferenceNumber);
	}

	/**
	 * Set the Ending Notification Reference Number.
	 * This field contains the ending notification reference number that is to be clear.
	 * @param objEndingNotificationReferenceNumber Object of Ending Notification Reference Number.
	 */
	public void setEndingNotificationReferenceNumber(NM objEndingNotificationReferenceNumber)
	{
		setDataType(1403,objEndingNotificationReferenceNumber);
	}

	/**
	 * Set the Starting Notification Date Time.
	 * This field specify the starting date/time of the notifications to be clear.
	 * @param strDate Specifies a point in time using a 24-hour clock notation. 
	 */	
	public void setStartingNotificationDate_Time(String strDate) 
	{
		DTM startingNotificationDate_Time  = (DTM)getDataElement(1404);
		startingNotificationDate_Time.setValue(strDate);
		setStartingNotificationDate_Time(startingNotificationDate_Time);
	}

	/**
	 * Set the Starting Notification Date Time.
	 * This field specify the starting date/time of the notifications to be clear.
	 * @param objStartingNotificationDate_Time Object of Starting Notification Date Time.
	 */	
	public void setStartingNotificationDate_Time(DTM objStartingNotificationDate_Time)
	{
		setDataType(1404,objStartingNotificationDate_Time);
	}

	/**
	 * Set the Ending Notification Date Time.
	 * This field specify the ending date/time of the notifications to be clear.
	 * @param strDate Specifies a point in time using a 24-hour clock notation. 
	 */	
	public void setEndingNotificationDate_Time(String strDate) 
	{
		DTM endingNotificationDate_Time  = (DTM)getDataElement(1405);
		endingNotificationDate_Time.setValue(strDate);
		setEndingNotificationDate_Time(endingNotificationDate_Time);
	}

	/**
	 * Set the Ending Notification Date Time.
	 * This field specify the ending date/time of the notifications to be clear.
	 * @param objEndingNotificationDate_Time Object of Ending Notification Date Time.
	 */	
	public void setEndingNotificationDate_Time(DTM objEndingNotificationDate_Time)
	{
		setDataType(1405,objEndingNotificationDate_Time);
	}

	/**
	 * Set the Starting Notification Code.
	 * This field specify the starting notification code that is to be clear.
	 * @param strIdentifier Specifies of characters (the code) that uniquely identifies the item being referenced. 
	 * @param strText Specifies The descriptive or textual name of the identifier, e.g., myocardial infarction. 
	 * @param strNameOfCodingSystem Identifies the coding scheme being used in the identifier component.
	 * @param strAlternateIdentifier Specifies an alternate sequence of characters (the code) that uniquely identifies the item being referenced.
	 * @param strAlternateText Specifies the descriptive or textual name of the alternate identifier. See usage note in section introduction.
	 * @param strNameOfAlternateCodingSystem Identifies the coding scheme being used in the alternate identifier component. 
	 * @param strCodingSystemVersionID A sequence of characters that uniquely identifies a second alternate code.
	 * @param strAlternateCodingSystemVersionId This component carries the version for the coding system identified by components 4-6.
	 * @param strOriginalText The text as seen and/or selected by the user who entered the data.
	 * @param strSecondAlternateIdentifier A sequence of characters that uniquely identifies a second alternate code.
	 * @param strSecondAlternateText The descriptive or textual name of the alternate identifier.
	 * @param strNameofSecondAlternateCodingSystem Identifies the coding scheme being used in the alternate identifier component.
	 * @param strSecondAlternateCodingSystemVersionID This component carries the version for the coding system identified by components 10-12.
	 * @param strCodingSystemOID This component contains the ISO Object Identifier (OID) for the coding system or value set named in CWE.3.
	 * @param strValueSetOID This component contains the ISO Object Identifier (OID) to allow identification of the value set from which the value in CWE.1 is obtained.
	 * @param strValueSetVersionID This component carries the version for the value set identified by CWE.15. The version is a date. The date is the date/time that the value set being used was published.
	 * @param strAlternateCodingSystemOID This component contains the ISO Object Identifier (OID) for the coding system or value set named in CWE.6.
	 * @param strAlternateValueSetOID This component contains the ISO Object Identifier (OID) to allow identification of the value set from which the value in CWE.4 is obtained.
	 * @param strAlternateValueSetVersionID This component carries the version for the value set identified by CWE.18. The version is a date.
	 * @param strSecondAlternateCodingSystemOID This component contains the ISO Object Identifier (OID) for the coding system or value set named in CWE.12.
	 * @param strSecondAlternateValueSetOID This component contains the ISO Object Identifier (OID) to allow identification of the value set from which the value in CWE.10 is obtained.
	 * @param strSecondAlternateValueSetVersionID This component carries the version for the value set identified by CWE.21. The version is a date.
	 */
	public void setStartingNotificationCode(String strIdentifier,String strText,String strNameOfCodingSystem,
			String strAlternateIdentifier,String strAlternateText,String strNameOfAlternateCodingSystem, String strCodingSystemVersionID, String 				strAlternateCodingSystemVersionId,
			String strOriginalText, String  strSecondAlternateIdentifier, String strSecondAlternateText, 
			String strNameofSecondAlternateCodingSystem, String strSecondAlternateCodingSystemVersionID, String strCodingSystemOID, String strValueSetOID,
			String strValueSetVersionID, String strAlternateCodingSystemOID, String strAlternateValueSetOID, String strAlternateValueSetVersionID,
			String  strSecondAlternateCodingSystemOID, String strSecondAlternateValueSetOID, String strSecondAlternateValueSetVersionID)
	{
		CWE cwe  = (CWE)getDataElement(1406);
		cwe.setIdentifier(strIdentifier);
		cwe.setText(strText);
		cwe.setNameOfCodingSystem(strNameOfCodingSystem);
		cwe.setAlternateIdentifier(strAlternateIdentifier);
		cwe.setAlternateText(strAlternateText);
		cwe.setNameOfAlternateCodingSystem(strNameOfAlternateCodingSystem); 
		cwe.setCodingSystemVersionID(strCodingSystemVersionID);
		cwe.setAlternateCodingSystemVersionId(strAlternateCodingSystemVersionId);
		cwe.setOriginalText(strOriginalText);
		cwe.setSecondAlternateIdentifier(strSecondAlternateIdentifier);
		cwe.setSecondAlternateText(strSecondAlternateText);
		cwe.setNameofSecondAlternateCodingSystem(strNameofSecondAlternateCodingSystem);
		cwe.setSecondAlternateCodingSystemVersionID(strSecondAlternateCodingSystemVersionID);
		cwe.setCodingSystemOID(strCodingSystemOID);
		cwe.setValueSetOID(strValueSetOID);
		cwe.setValueSetVersionID(strValueSetVersionID);
		cwe.setAlternateCodingSystemOID(strAlternateCodingSystemOID);
		cwe.setAlternateValueSetOID(strAlternateValueSetOID);
		cwe.setAlternateValueSetVersionID(strAlternateValueSetVersionID);
		cwe.setSecondAlternateCodingSystemOID(strSecondAlternateCodingSystemOID);
		cwe.setSecondAlternateValueSetOID(strSecondAlternateValueSetOID);
		cwe.setSecondAlternateValueSetVersionID(strSecondAlternateValueSetVersionID);
		setStartingNotificationCode(cwe);
	}

	/**
	 * Set the Starting Notification Code.
	 * This field specify the starting notification code that is to be clear.
	 * @param objStartingNotificationCode Object of Starting Notification Code.
	 */
	public void setStartingNotificationCode(CWE objStartingNotificationCode)
	{
		setDataType(1406,objStartingNotificationCode);
	}

	/**
	 * Set the Ending Notification Code.
	 * @param strIdentifier Specifies of characters (the code) that uniquely identifies the item being referenced. 
	 * @param strText Specifies The descriptive or textual name of the identifier, e.g., myocardial infarction. 
	 * @param strNameOfCodingSystem Identifies the coding scheme being used in the identifier component.
	 * @param strAlternateIdentifier Specifies an alternate sequence of characters (the code) that uniquely identifies the item being referenced.
	 * @param strAlternateText Specifies the descriptive or textual name of the alternate identifier. See usage note in section introduction.
	 * @param strNameOfAlternateCodingSystem Identifies the coding scheme being used in the alternate identifier component. 
	 * @param strCodingSystemVersionID A sequence of characters that uniquely identifies a second alternate code.
	 * @param strAlternateCodingSystemVersionId This component carries the version for the coding system identified by components 4-6.
	 * @param strOriginalText The text as seen and/or selected by the user who entered the data.
	 * @param strSecondAlternateIdentifier A sequence of characters that uniquely identifies a second alternate code.
	 * @param strSecondAlternateText The descriptive or textual name of the alternate identifier.
	 * @param strNameofSecondAlternateCodingSystem Identifies the coding scheme being used in the alternate identifier component.
	 * @param strSecondAlternateCodingSystemVersionID This component carries the version for the coding system identified by components 10-12.
	 * @param strCodingSystemOID This component contains the ISO Object Identifier (OID) for the coding system or value set named in CWE.3.
	 * @param strValueSetOID This component contains the ISO Object Identifier (OID) to allow identification of the value set from which the value in CWE.1 is obtained.
	 * @param strValueSetVersionID This component carries the version for the value set identified by CWE.15. The version is a date. The date is the date/time that the value set being used was published.
	 * @param strAlternateCodingSystemOID This component contains the ISO Object Identifier (OID) for the coding system or value set named in CWE.6.
	 * @param strAlternateValueSetOID This component contains the ISO Object Identifier (OID) to allow identification of the value set from which the value in CWE.4 is obtained.
	 * @param strAlternateValueSetVersionID This component carries the version for the value set identified by CWE.18. The version is a date.
	 * @param strSecondAlternateCodingSystemOID This component contains the ISO Object Identifier (OID) for the coding system or value set named in CWE.12.
	 * @param strSecondAlternateValueSetOID This component contains the ISO Object Identifier (OID) to allow identification of the value set from which the value in CWE.10 is obtained.
	 * @param strSecondAlternateValueSetVersionID This component carries the version for the value set identified by CWE.21. The version is a date.
	 */
	public void setEndingNotificationCode(String strIdentifier,String strText,String strNameOfCodingSystem,
			String strAlternateIdentifier,String strAlternateText,String strNameOfAlternateCodingSystem, String strCodingSystemVersionID, String 				strAlternateCodingSystemVersionId,
			String strOriginalText, String  strSecondAlternateIdentifier, String strSecondAlternateText, 
			String strNameofSecondAlternateCodingSystem, String strSecondAlternateCodingSystemVersionID, String strCodingSystemOID, String strValueSetOID,
			String strValueSetVersionID, String strAlternateCodingSystemOID, String strAlternateValueSetOID, String strAlternateValueSetVersionID,
			String  strSecondAlternateCodingSystemOID, String strSecondAlternateValueSetOID, String strSecondAlternateValueSetVersionID)
	{
		CWE cwe  = (CWE)getDataElement(1407);
		cwe.setIdentifier(strIdentifier);
		cwe.setText(strText);
		cwe.setNameOfCodingSystem(strNameOfCodingSystem);
		cwe.setAlternateIdentifier(strAlternateIdentifier);
		cwe.setAlternateText(strAlternateText);
		cwe.setNameOfAlternateCodingSystem(strNameOfAlternateCodingSystem); 
		cwe.setCodingSystemVersionID(strCodingSystemVersionID);
		cwe.setAlternateCodingSystemVersionId(strAlternateCodingSystemVersionId);
		cwe.setOriginalText(strOriginalText);
		cwe.setSecondAlternateIdentifier(strSecondAlternateIdentifier);
		cwe.setSecondAlternateText(strSecondAlternateText);
		cwe.setNameofSecondAlternateCodingSystem(strNameofSecondAlternateCodingSystem);
		cwe.setSecondAlternateCodingSystemVersionID(strSecondAlternateCodingSystemVersionID);
		cwe.setCodingSystemOID(strCodingSystemOID);
		cwe.setValueSetOID(strValueSetOID);
		cwe.setValueSetVersionID(strValueSetVersionID);
		cwe.setAlternateCodingSystemOID(strAlternateCodingSystemOID);
		cwe.setAlternateValueSetOID(strAlternateValueSetOID);
		cwe.setAlternateValueSetVersionID(strAlternateValueSetVersionID);
		cwe.setSecondAlternateCodingSystemOID(strSecondAlternateCodingSystemOID);
		cwe.setSecondAlternateValueSetOID(strSecondAlternateValueSetOID);
		cwe.setSecondAlternateValueSetVersionID(strSecondAlternateValueSetVersionID);
		setEndingNotificationCode(cwe);
	}

	/**
	 * Set the Ending Notification Code.
	 * @param objEndingNotificationCode Object of Ending Notification Code.
	 */
	public void setEndingNotificationCode(CWE objEndingNotificationCode)
	{
		setDataType(1407,objEndingNotificationCode);
	}

	/**
	 * Retrieves the Ending Notification Code.
	 * @return CWE - endingNotificationCode
	 */
	public CWE getEndingNotificationCode() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1407);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (CWE)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Ending Notification Date Time.
	 * This field specify the ending date/time of the notifications to be clear.
	 * @return DTM - endingNotificationDate_Time
	 */
	public DTM getEndingNotificationDate_Time() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1405);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (DTM)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Ending Notification Reference Number.
	 * This field contains the ending notification reference number that is to be clear.
	 * @return String - endingNotificationReferenceNumber
	 */
	public NM getEndingNotificationReferenceNumber() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1403);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (NM)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Starting Notification Code.
	 * This field specify the starting notification code that is to be clear. 
	 * @return CWE - startingNotificationCode
	 */
	public CWE getStartingNotificationCode() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1406);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (CWE)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Starting Notification Date Time.
	 * This field specify the starting date/time of the notifications to be clear.
	 * @return DTM - startingNotificationDate_Time
	 */
	public DTM getStartingNotificationDate_Time() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1404);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (DTM)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Starting Notification Reference Number.
	 * This field contains the starting notification reference number that is to be clear.
	 * @return String - startingNotificationReferenceNumber
	 */
	public NM getStartingNotificationReferenceNumber() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1402);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (NM)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Validates HL7 Message objects .
	 * Validate method checks for validation each and every segments in side the Message object against specified message Structure. 
	 * Validation checks include optionality of segment or group.
	 * It also verifies the number of times segment or group is repeated in message.
	 * e.g 
	 * {PSH} while parsing PSH segment validate method will check for its mandatory presence.
	 * [PSH] in this case validate will throw exception if one tries to enter more than one PSH segment.
	 * @return boolean - true or false.
	 * @throws InvalidSegmentException Thrown when Segment Validation Fails.
	 */
	public boolean validate() throws InvalidSegmentException
	{
		super.validate();

		return true;
	}
}