/*******************************************************************************
 *  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.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.InvalidSegmentException;
import cdac.medinfo.sdk.hl7282.utils.EnumSegments;

/**
 * FTS - File trailer segment  <p>
 * The FTS segment defines the end of a File.
 * <p>Represents an HL7 FTS message segment. 
 * This segment has the following fields:</p><p>
 * FTS-1: File Batch Count (NM)<b>Optional</b><br> 
 * FTS-2: File Trailer Comment (ST)<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 FTS extends Segment    
{
	

	/**
	 * Constructs FTS segment
	 */
	public FTS()
	{super(EnumSegments.HL7_SEG_FTS);
	}
	//Integer values used in getter/setter is unique item id defined 
	//for each attribute.

	/**
	 * Set the File Batch Count
	 * This field contains the count of the individual batches contained within the File
	 * @param strFileBatchCount - String value of FileBatchCount
	 */ 
	public void setFileBatchCount(String strFileBatchCount)
	{
		NM fileBatchCount  = (NM)getDataElement(79);
		fileBatchCount.setValue(strFileBatchCount); 
		setFileBatchCount(fileBatchCount);
	} 

	/** Set the File Batch Count
	 * This field contains the count of the individual batches contained within the File
	 * @param objfileBatchCount object of FileBatchCount
	 */ 
	public void setFileBatchCount(NM objfileBatchCount)
	{
		setDataType(79,objfileBatchCount);
	}
	/**
	 * Retrieves the File Batch Count.
	 * @return NM - FileBatchCount
	 */
	public NM getFileBatchCount() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(79);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (NM)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Set the File Trailer Comment.
	 * This field is a comment field that is not further defined in the HL7 protocol.
	 * @param strFileTrailerComment - String value of Batch Comment
	 */ 
	public void setFileTrailerComment(String strFileTrailerComment)
	{
		ST fileTrailerComment  = (ST)getDataElement(80);
		fileTrailerComment.setValue(strFileTrailerComment); 
		setFileTrailerComment(fileTrailerComment);
	} 

	/** Set the File Trailer Comment.
	 * This field is a comment field that is not further defined in the HL7 protocol.
	 * @param objfileTrailerCommentobject of File Trailer Comment.
	 */ 
	public void setFileTrailerComment(ST objfileTrailerComment)
	{
		setDataType(80,objfileTrailerComment);
	}
	/**
	 * Retrieves the Batch Comment.
	 * @return ST - FileTrailerComment
	 */
	public ST getFileTrailerComment() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(80);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ST)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 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 Thrown when Segment Validation Fails.
	 */
	@Override
	public boolean validate() throws InvalidSegmentException
	{
		//All fields are optional
		super.validate();
		return true;
	}
}
