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

/**
 * ADD - Addendum Segment. <p>
 * The ADD segment is used to define the continuation of the prior segment in a continuation message.
 * <p>Represents an HL7 ADD message segment. 
 * This segment has the following fields:</p><p>
 * ADD-1: Addendum Continuation Pointer (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 ADD extends Segment  
{
	

	/**
	 * Constructs the ADD segment.
	 */
	public ADD()
	{super(EnumSegments.HL7_SEG_ADD);
	}

	/**
	 * Retrieves the Addendum Continuation Pointer which defines the continuation of the prior segment in a continuation message
	 * @return ST - addendumContinuationPointer
	 */
	public ST getAddendumContinuationPointer() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(66);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ST)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Sets the Addendum Continuation Pointer which defines the continuation of the prior segment in a continuation message
	 * @param strAddendumContinuationPointer Contains the addendum continuation pointer. 
	 */
	public void setAddendumContinuationPointer(String strAddendumContinuationPointer)
	{
		ST addendumContinuationPointer  = (ST)getDataElement(66);
		addendumContinuationPointer.setValue(strAddendumContinuationPointer); 
		setAddendumContinuationPointer(addendumContinuationPointer);
	}

	/**
	 * Sets the Addendum Continuation Pointer which defines the continuation of the prior segment in a continuation message
	 * @param addendumContinuationPointer Contains the addendum continuation pointer. 
	 */
	public void setAddendumContinuationPointer(ST addendumContinuationPointer)
	{
		setDataType(66,addendumContinuationPointer);
	}

	/**
	 * 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.
	 */
	public boolean validate() throws InvalidSegmentException
	{
		//All fields are optional
		super.validate();
		return true;
	}
}