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

/**
 * NST - Application Control-Level Statistics Segment<p>
 * The NST segment allows application control-level statistical information to be passed
 * between the various systems on the network.
 * <p>Represents an HL7 NST message segment. 
 * This segment has the following fields:</p><p>
 * NST-1: Statistics Available (ID)<b>Required</b><br> 
 * NST-2: Source Identifier (ST)<b>Optional</b><br> 
 * NST-3: Source Type (ID)<b>Optional</b><br> 
 * NST-4: Statistics Start (DTM)<b>Optional</b><br> 
 * NST-5: Statistics End (DTM)<b>Optional</b><br> 
 * NST-6: Receive Character Count (NM)<b>Optional</b><br> 
 * NST-7: Send Character Count (NM)<b>Optional</b><br> 
 * NST-8: Messages Received (NM)<b>Optional</b><br> 
 * NST-9: Messages Sent (NM)<b>Optional</b><br> 
 * NST-10: Checksum Errors Received (NM)<b>Optional</b><br> 
 * NST-11: Length Errors Received (NM)<b>Optional</b><br> 
 * NST-12: Other Errors Received (NM)<b>Optional</b><br> 
 * NST-13: Connect Timeouts (NM)<b>Optional</b><br> 
 * NST-14: Receive Timeouts (NM)<b>Optional</b><br> 
 * NST-15: Application control-level Errors (NM)<b></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 NST extends Segment   
{
	


	/**
	 *  Constructs the NST segment.
	 */
	public NST()
	{super(EnumSegments.HL7_SEG_NST);
	}

	/**
	 * Retrieves the Application control level Errors.
	 * This field contains the number of application control-level errors in response to an initiated message. 
	 * @return NM - applicationcontrollevelErrors
	 */
	public NM getApplicationcontrollevelErrors() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1187);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (NM)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Checksum Errors Received.
	 * This field contains the number of messages received with checksum errors.
	 * @return NM - checksumErrorsReceived
	 */
	public NM getChecksumErrorsReceived() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1182);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (NM)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Connect Timeouts.
	 * This field contains the number of connect timeout errors.
	 * @return NM - connectTimeouts
	 */
	public NM getConnectTimeouts() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1185);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (NM)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Length Errors Received.
	 * This field contains the number of messages received with length errors.
	 * @return NM - lengthErrorsReceived
	 */
	public NM getLengthErrorsReceived() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1183);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (NM)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Messages Received.
	 * This field contains the number of messages received.
	 * @return NM - messagesReceived
	 */
	public NM getMessagesReceived() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1180);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (NM)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Messages Sent.
	 * This field contains the number of messages sent.
	 * @return NM - messagesSent
	 */
	public NM getMessagesSent() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1181);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (NM)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Other Errors Received.
	 * This field contains the number of "other" invalid messages received (excluding length and checksum errors). 
	 * @return NM - otherErrorsReceived
	 */
	public NM getOtherErrorsReceived() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1184);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (NM)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Receive Character Count.
	 * This field contains the number of characters received.
	 * @return NM - receiveCharacterCount
	 */
	public NM getReceiveCharacterCount() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1178);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (NM)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Receive Timeouts.
	 * This field contains the number of timeouts while waiting for a response to an initiated message.
	 * @return NM - receiveTimeouts
	 */
	public NM getReceiveTimeouts() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1186);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (NM)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Send Character Count.
	 * This field contains the number of characters sent.
	 * @return NM - sendCharacterCount
	 */
	public NM getSendCharacterCount() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1179);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (NM)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Source Identifier.
	 * This field identify a particular lower level link.
	 * @return ST - sourceIdentifier
	 */
	public ST getSourceIdentifier() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1174);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ST)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Source Type.
	 * This field identify (in certain systems) whether a lower level source identifier is an initiate or accept type.
	 * @return ID - sourceType
	 */
	public ID getSourceType() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1175);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ID)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Statistics Available.
	 * This field indicates the availability of statistics.
	 * @return ID - statisticsAvailable
	 */
	public ID getStatisticsAvailable() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1173);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ID)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Statistics End.
	 * This field contains the date/time stamp of the end of the statistics collection period.
	 * @return DTM - statisticsEnd
	 */
	public DTM getStatisticsEnd() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1177);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (DTM)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Statistics Start.
	 * This field contains the date/time stamp of the start of the collection of the statistics reported in fields 6 15 of this segment.  
	 * @return DTM - statisticsStart
	 */
	public DTM getStatisticsStart() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1176);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (DTM)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Set the Statistics Available.
	 * This field indicates the availability of statistics.
	 * @param strStatisticsAvailable Used as StatisticsAvailable.
	 */ 
	public void setStatisticsAvailable (String strStatisticsAvailable) 
	{
		ID statisticsAvailable  = (ID)getDataElement(1173);
		statisticsAvailable.setValue(strStatisticsAvailable); 
		setStatisticsAvailable(statisticsAvailable);

	} 

	/** Set the Statistics Available.
	 * This field indicates the availability of statistics.
	 * @param objstatisticsAvailable Used as StatisticsAvailable.
	 */ 
	public void setStatisticsAvailable(ID objstatisticsAvailable)
	{
		setDataType(1173,objstatisticsAvailable);

	}

	/**
	 * Set the Source Identifier.
	 * This field identify a particular lower level link.
	 * @param strSourceIdentifier The name of the party.
	 */ 
	public void setSourceIdentifier (String strSourceIdentifier) 
	{
		ST sourceIdentifier  = (ST)getDataElement(1174);
		sourceIdentifier.setValue(strSourceIdentifier); 
		setSourceIdentifier(sourceIdentifier);

	} 

	/** Set the Source Identifier.
	 * This field identify a particular lower level link.
	 * @param objsourceIdentifier The name of the party.
	 */ 
	public void setSourceIdentifier(ST objsourceIdentifier)
	{
		setDataType(1174,objsourceIdentifier);

	}

	/**
	 * Set the Source Type.
	 * This field identify (in certain systems) whether a lower level source identifier is an initiate or accept type.
	 * @param strSourceType used as SourceType.
	 */ 
	public void setSourceType (String strSourceType) 
	{
		ID sourceType  = (ID)getDataElement(1175);
		sourceType.setValue(strSourceType); 
		setSourceType(sourceType);

	} 

	/** Set the Source Type.
	 * This field identify (in certain systems) whether a lower level source identifier is an initiate or accept type.
	 * @param objsourceType used as SourceType.
	 */ 
	public void setSourceType(ID objsourceType)
	{
		setDataType(1175,objsourceType);

	}

	/**
	 * Set the Statistics Start.
	 * This field contains the date/time stamp of the start of the collection of the statistics reported in fields 6 15 of this segment. 
	 * @param strDate Specifies a point in time using a 24-hour clock notation. 
	 */ 
	public void setStatisticsStart (String strDate) 
	{
		DTM statisticsStart  = (DTM)getDataElement(1176);
		statisticsStart.setValue(strDate);		 
		setStatisticsStart(statisticsStart);

	} 

	/**
	 * Set the Statistics Start.
	 * This field contains the date/time stamp of the start of the collection of the statistics reported in fields 6 15 of this segment. 
	 * @param objstatisticsStart Statistics Start
	 */ 
	public void setStatisticsStart(DTM objstatisticsStart)
	{
		setDataType(1176,objstatisticsStart);

	}

	/**
	 * Set the Statistics End.
	 * This field contains the date/time stamp of the end of the statistics collection period. 
	 * @param strDate Specifies a point in time using a 24-hour clock notation. 
	 */ 
	public void setStatisticsEnd (String strDate) 
	{
		DTM statisticsEnd  = (DTM)getDataElement(1177);
		statisticsEnd.setValue(strDate);		 
		setStatisticsEnd(statisticsEnd);

	} 

	/**
	 * Set the Statistics End.
	 * This field contains the date/time stamp of the end of the statistics collection period. 
	 * @param objstatisticsEnd Statistics End
	 */  
	public void setStatisticsEnd(DTM objstatisticsEnd)
	{
		setDataType(1177,objstatisticsEnd);

	}

	/**
	 * Set the Receive Character Count.
	 * This field contains the number of characters received.
	 * @param strReceiveCharacterCount Specifies Transaction Quantity
	 */ 
	public void setReceiveCharacterCount (String strReceiveCharacterCount) 
	{
		NM receiveCharacterCount  = (NM)getDataElement(1178);
		receiveCharacterCount.setValue(strReceiveCharacterCount); 
		setReceiveCharacterCount(receiveCharacterCount);

	} 

	/** Set the Receive Character Count.
	 * This field contains the number of characters received.
	 * @param objreceiveCharacterCount Specifies Transaction Quantity
	 */ 
	public void setReceiveCharacterCount(NM objreceiveCharacterCount)
	{
		setDataType(1178,objreceiveCharacterCount);

	}

	/**
	 * Set the Send Character Count.
	 * This field contains the number of characters sent.
	 * @param strSendCharacterCount Specifies Transaction Quantity.
	 */ 
	public void setSendCharacterCount (String strSendCharacterCount) 
	{
		NM sendCharacterCount  = (NM)getDataElement(1179);
		sendCharacterCount.setValue(strSendCharacterCount); 
		setSendCharacterCount(sendCharacterCount);

	} 

	/** Set the Send Character Count.
	 * This field contains the number of characters sent.
	 * @param objsendCharacterCount Specifies Transaction Quantity.
	 */ 
	public void setSendCharacterCount(NM objsendCharacterCount)
	{
		setDataType(1179,objsendCharacterCount);

	}

	/**
	 * Set the Messages Received.
	 * This field contains the number of messages received.
	 * @param strMessagesReceived Specifies Transaction Quantity
	 */ 
	public void setMessagesReceived (String strMessagesReceived) 
	{
		NM messagesReceived  = (NM)getDataElement(1180);
		messagesReceived.setValue(strMessagesReceived); 
		setMessagesReceived(messagesReceived);

	} 

	/** Set the Messages Received.
	 * This field contains the number of messages received.
	 * @param objmessagesReceived Specifies Transaction Quantity
	 */ 
	public void setMessagesReceived(NM objmessagesReceived)
	{
		setDataType(1180,objmessagesReceived);

	}

	/**
	 * Set the Messages Sent.
	 * This field contains the number of messages sent.
	 * @param strMessagesSent Specifies Transaction Quantity.
	 */ 
	public void setMessagesSent (String strMessagesSent) 
	{
		NM messagesSent  = (NM)getDataElement(1181);
		messagesSent.setValue(strMessagesSent); 
		setMessagesSent(messagesSent);

	} 

	/** Set the Messages Sent.
	 * This field contains the number of messages sent.
	 * @param objmessagesSent Specifies Transaction Quantity.
	 */ 
	public void setMessagesSent(NM objmessagesSent)
	{
		setDataType(1181,objmessagesSent);

	}

	/**
	 * Set the Checksum Errors Received.
	 * This field contains the number of messages received with checksum errors.
	 * @param strChecksumErrorsReceived Specifies Transaction Quantity
	 */ 
	public void setChecksumErrorsReceived (String strChecksumErrorsReceived) 
	{
		NM checksumErrorsReceived  = (NM)getDataElement(1182);
		checksumErrorsReceived.setValue(strChecksumErrorsReceived); 
		setChecksumErrorsReceived(checksumErrorsReceived);

	} 

	/** Set the Checksum Errors Received.
	 * This field contains the number of messages received with checksum errors.
	 * @param objchecksumErrorsReceived Specifies Transaction Quantity
	 */ 
	public void setChecksumErrorsReceived(NM objchecksumErrorsReceived)
	{
		setDataType(1182,objchecksumErrorsReceived);

	}

	/**
	 * Set the Length Errors Received.
	 * This field contains the number of messages received with length errors.
	 * @param strLengthErrorsReceived Specifies Transaction Quantity
	 */ 
	public void setLengthErrorsReceived (String strLengthErrorsReceived) 
	{
		NM lengthErrorsReceived  = (NM)getDataElement(1183);
		lengthErrorsReceived.setValue(strLengthErrorsReceived); 
		setLengthErrorsReceived(lengthErrorsReceived);

	} 

	/** Set the Length Errors Received.
	 * This field contains the number of messages received with length errors.
	 * @param objlengthErrorsReceived Specifies Transaction Quantity
	 */ 
	public void setLengthErrorsReceived(NM objlengthErrorsReceived)
	{
		setDataType(1183,objlengthErrorsReceived);

	}

	/**
	 * Set the Other Errors Received.
	 * This field contains the number of "other" invalid messages received (excluding length and checksum errors). 
	 * @param strOtherErrorsReceived Specifies Transaction Quantity.
	 */ 
	public void setOtherErrorsReceived (String strOtherErrorsReceived) 
	{
		NM otherErrorsReceived  = (NM)getDataElement(1184);
		otherErrorsReceived.setValue(strOtherErrorsReceived); 
		setOtherErrorsReceived(otherErrorsReceived);

	} 

	/** Set the Other Errors Received.
	 * This field contains the number of "other" invalid messages received (excluding length and checksum errors). 
	 * @param objotherErrorsReceived Specifies Transaction Quantity.
	 */ 
	public void setOtherErrorsReceived(NM objotherErrorsReceived)
	{
		setDataType(1184,objotherErrorsReceived);

	}

	/**
	 * Set the Connect Timeouts.
	 * This field contains the number of connect timeout errors.
	 * @param strConnectTimeouts Specifies Transaction Quantity.
	 */ 
	public void setConnectTimeouts (String strConnectTimeouts) 
	{
		NM connectTimeouts  = (NM)getDataElement(1185);
		connectTimeouts.setValue(strConnectTimeouts); 
		setConnectTimeouts(connectTimeouts);

	} 

	/** Set the Connect Timeouts.
	 * This field contains the number of connect timeout errors.
	 * @param objconnectTimeouts Specifies Transaction Quantity.
	 */ 
	public void setConnectTimeouts(NM objconnectTimeouts)
	{
		setDataType(1185,objconnectTimeouts);

	}

	/**
	 * Set the Receive Timeouts.
	 * This field contains the number of timeouts while waiting for a response to an initiated message.
	 * @param strReceiveTimeouts Specifies Transaction Quantity.
	 */ 
	public void setReceiveTimeouts (String strReceiveTimeouts) 
	{
		NM receiveTimeouts  = (NM)getDataElement(1186);
		receiveTimeouts.setValue(strReceiveTimeouts); 
		setReceiveTimeouts(receiveTimeouts);

	} 

	/** Set the Receive Timeouts.
	 * This field contains the number of timeouts while waiting for a response to an initiated message.
	 * @param objreceiveTimeouts Specifies Transaction Quantity.
	 */ 
	public void setReceiveTimeouts(NM objreceiveTimeouts)
	{
		setDataType(1186,objreceiveTimeouts);

	}

	/**
	 * Set the Application control level Errors.
	 * This field contains the number of application control-level errors in response to an initiated message. 
	 * @param strApplicationcontrollevelErrors Specifies Transaction Quantity.
	 */ 
	public void setApplicationcontrollevelErrors (String strApplicationcontrollevelErrors) 
	{
		NM applicationcontrollevelErrors  = (NM)getDataElement(1187);
		applicationcontrollevelErrors.setValue(strApplicationcontrollevelErrors); 
		setApplicationcontrollevelErrors(applicationcontrollevelErrors);

	} 

	/** Set the Application control level Errors.
	 * This field contains the number of application control-level errors in response to an initiated message. 
	 * @param objapplicationcontrollevelErrors Specifies Transaction Quantity.
	 */ 
	public void setApplicationcontrollevelErrors(NM objapplicationcontrollevelErrors)
	{
		setDataType(1187,objapplicationcontrollevelErrors);

	}

	/**
	 * Validates HL7 Message objects .
	 * Validate method checks for validation each and every segments in side the Message object against specified message Structure. 
	 * Validation chcecks 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 Throws when Segment Validation fails
	 */
	public boolean validate() throws InvalidSegmentException
	{
		try
		{
			super.validate();

			return true;
		}
		catch(FieldMissingException ex)
		{
			throw new InvalidSegmentException(enumSegments.getValue(),ex);
		}
	}
}