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

import cdac.medinfo.sdk.hl7282.baselibs.CQ;
import cdac.medinfo.sdk.hl7282.baselibs.CWE;
import cdac.medinfo.sdk.hl7282.baselibs.EI;
import cdac.medinfo.sdk.hl7282.baselibs.ID;
import cdac.medinfo.sdk.hl7282.baselibs.NM;
import cdac.medinfo.sdk.hl7282.baselibs.SI;
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.InvalidFieldException;
import cdac.medinfo.sdk.hl7282.exceptions.InvalidSegmentException;
import cdac.medinfo.sdk.hl7282.utils.EnumSegments;
import cdac.medinfo.sdk.hl7282.utils.HL7Config;
import cdac.medinfo.sdk.hl7282.utils.ResourceBundleWrapper;
import cdac.medinfo.sdk.hl7282.utils.SingleCollection;

/**
 * TQ2 - Timing/Quantity Relationship.<p>
 * The TQ2 segment is used to form a relationship between the service request
 * the TQ1/TQ2 segments are associated with, and other service requests.
 * The TQ2 segment will link the current service request with one or more other service requests.
 * <p>Represents an HL7 TQ2 message segment. 
 * This segment has the following fields:</p><p>
 * TQ2-1: Set ID - TQ2 (SI)<b>Optional</b><br> 
 * TQ2-2: Sequence/Results Flag (ID)<b>Optional</b><br> 
 * TQ2-3: Related Placer Number (EI)<b>Conditional</b><br> 
 * TQ2-4: Related Filler Number (EI)<b>Conditional</b><br> 
 * TQ2-5: Related Placer Group Number (EI)<b>Conditional</b><br> 
 * TQ2-6: Sequence Condition Code (ID)<b>Conditional</b><br> 
 * TQ2-7: Cyclic Entry/Exit Indicator (ID)<b>Conditional</b><br> 
 * TQ2-8: Sequence Condition Time Interval (CQ)<b>Optional</b><br> 
 * TQ2-9: Cyclic Group Maximum Number of Repeats (NM)<b>Optional</b><br> 
 * TQ2-10: Special Service Request Relationship (ID)<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 TQ2 extends Segment    
{
	

	/**
	 * Constructs the TQ2 segment.
	 */
	public TQ2()
	{super(EnumSegments.HL7_SEG_TQ2);
	}

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

	/**
	 * Retrieves the Set ID TQ2.
	 * This field specify the value for timing specification transmitted.
	 * @return SI - setID_TQ2
	 */
	public SI getSetID_TQ2() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1648);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (SI)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Sequence Results Flag.
	 * This field specify the sequencing relationship between the current service request,and the related service request(s) specified in this TQ2 segment.
	 * @return ID - sequenceResultsFlag
	 */
	public ID getSequenceResultsFlag() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1649);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ID)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Related Placer No.
	 * This field specify the placer numbers of the service request(s) to which this TQ2 segment links the current service request. 
	 * @return ISingleCollection<EI> - relatedPlacerNo
	 */
	public ISingleCollection<EI> getRelatedPlacerNo() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1650);
		ISingleCollection<EI> objDataList = new SingleCollection<EI>(); 
		if(objDataCollection != null && objDataCollection.size() != 0)
		{
			for(IDataType objDataType : objDataCollection)
			{
				EI objEI = (EI)objDataType;
				objDataList.add(objEI);
			}
		}
		return objDataList;
	}

	/**
	 * Retrieves the Related Filler No.
	 * This field specify the service request(s) to which this TQ2 segment links the current service request.
	 * @return ISingleCollection<EI> - relatedFillerNo
	 */
	public ISingleCollection<EI> getRelatedFillerNo() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1651);
		ISingleCollection<EI> objDataList = new SingleCollection<EI>(); 
		if(objDataCollection != null && objDataCollection.size() != 0)
		{
			for(IDataType objDataType : objDataCollection)
			{
				EI objEI = (EI)objDataType;
				objDataList.add(objEI);
			}
		}
		return objDataList;
	}

	/**
	 * Retrieves the Related Placer Group No.
	 * This field specify the service request(s) to which this TQ2 segment links the current service request.
	 * @return ISingleCollection<EI> - relatedPlacerGroupNo
	 */
	public ISingleCollection<EI> getRelatedPlacerGroupNo() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1652);
		ISingleCollection<EI> objDataList = new SingleCollection<EI>(); 
		if(objDataCollection != null && objDataCollection.size() != 0)
		{
			for(IDataType objDataType : objDataCollection)
			{
				EI objEI = (EI)objDataType;
				objDataList.add(objEI);
			}
		}
		return objDataList;
	}

	/**
	 * Retrieves the Sequence Condition Code.
	 * This field specify the start/end of the related service request(s) and the current service request.
	 * @return ID - sequenceConditionCode
	 */
	public ID getSequenceConditionCode() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1653);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ID)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Cyclic Entry Exit Indicator.
	 * This field specify the number of service request in a cyclic series of service requests.
	 * @return ID - cyclicEntryExitIndicator
	 */
	public ID getCyclicEntryExitIndicator() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1654);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ID)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Sequence Cond Time Interval.
	 * This field specify the interval of time between the start/end of the related service request(s) and the start/end of the current service request
	 * @return CQ - sequenceCondTimeInterval
	 */
	public CQ getSequenceCondTimeInterval() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1655);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (CQ)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Cyclic Group Max No Of Repeats.
	 * This field specify the maximum number of repeats for a cyclic group. 
	 * @return NM - cyclicGroupMaxNoOfRepeats
	 */
	public NM getCyclicGroupMaxNoOfRepeats() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1656);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (NM)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Special Service Request Relationship.
	 * This field specify an additional or alternate relationship between this service request and other service requests
	 * @return ID - specialServiceRequestRelationship
	 */
	public ID getSpecialServiceRequestRelationship() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1657);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ID)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Set the Cyclic Entry Exit Indicator.
	 * This field specify the number of service request in a cyclic series of service requests.
	 * @param strCyclicEntryExitIndicator String which to set as Cyclic Entry Exit Indicator 
	 */ 
	public void setCyclicEntryExitIndicator (String strCyclicEntryExitIndicator) 
	{
		ID cyclicEntryExitIndicator  = (ID)getDataElement(1654);
		cyclicEntryExitIndicator.setValue(strCyclicEntryExitIndicator); 
		setCyclicEntryExitIndicator(cyclicEntryExitIndicator);

	} 

	/** 
	 * Set the Cyclic Entry Exit Indicator.
	 * This field specify the number of service request in a cyclic series of service requests.
	 * @param objcyclicEntryExitIndicator Object of Cyclic Entry Exit Indicator.
	 */ 
	public void setCyclicEntryExitIndicator(ID objcyclicEntryExitIndicator)
	{
		setDataType(1654,objcyclicEntryExitIndicator);

	}

	/**
	 * Set the Cyclic Group Max No Of Repeats.
	 * This field specify the maximum number of repeats for a cyclic group. 
	 * @param strCyclicGroupMaxNoOfRepeats String which to set as Group Maximum Number Of Repeats 
	 */ 
	public void setCyclicGroupMaxNoOfRepeats (String strCyclicGroupMaxNoOfRepeats) 
	{
		NM cyclicGroupMaxNoOfRepeats  = (NM)getDataElement(1656);
		cyclicGroupMaxNoOfRepeats.setValue(strCyclicGroupMaxNoOfRepeats); 
		setCyclicGroupMaxNoOfRepeats(cyclicGroupMaxNoOfRepeats);

	} 

	/** 
	 * Set the Cyclic Group Max No Of Repeats.
	 * This field specify the maximum number of repeats for a cyclic group. 
	 * @param objcyclicGroupMaxNoOfRepeats Object of Cyclic Group Max No Of Repeats. 
	 */ 
	public void setCyclicGroupMaxNoOfRepeats(NM objcyclicGroupMaxNoOfRepeats)
	{
		setDataType(1656,objcyclicGroupMaxNoOfRepeats);

	}

	/**
	 * Add the Related Filler No.
	 * This field specify the service request(s) to which this TQ2 segment links the current service request. 
	 * @param strEntityIdentifier Specifies defined by a hierarchic designator, represented by components 2 through 4.
	 * 								[Reference Section 2.A.33, "HD - hierarchic designator".] 
	 * @param strNamespaceId Specifies  the HL7 identifier for the user-defined table of values for this component.
	 * 						   [Refer to User-defined Table 0363 - Assigning authority] 	 
	 * @param strUniversalId Specifies string formatted according to the scheme defined by the component, 
	 * 							<universal ID type> (UID type). 
	 * @param strUniversalIdType Specifies  the interpretation of the second component of the HD. 
	 */ 
	public void addRelatedFillerNo (String strEntityIdentifier,String strNamespaceId,String strUniversalId,
			String strUniversalIdType)
	{
		EI relatedFillerNo  = (EI)getDataElement(1651);
		relatedFillerNo.setEntityIdentifier(strEntityIdentifier);
		relatedFillerNo.setNamespaceId(strNamespaceId);
		relatedFillerNo.setUniversalId(strUniversalId);
		relatedFillerNo.setUniversalIdType(strUniversalIdType); 
		addRelatedFillerNo(relatedFillerNo);

	} 

	/** 
	 * Add the Related Filler No.
	 * This field specify the service request(s) to which this TQ2 segment links the current service request. 
	 * @param objrelatedFillerNo Object of Related Filler No.
	 */ 
	public void addRelatedFillerNo(EI objrelatedFillerNo)
	{
		addDataType(1651,objrelatedFillerNo);

	} 

	/** 
	 * Set the Related Filler No.
	 * This field specify the service request(s) to which this TQ2 segment links the current service request. 
	 * @param objrelatedFillerNoList List of Related Filler No.
	 */ 
	@SuppressWarnings("unchecked")
	public void setRelatedFillerNo(ISingleCollection<EI> objrelatedFillerNoList)
	{
		ISingleCollection<IDataType> objCollection = null;
		ISingleCollection<?> objUnknownCollection = (ISingleCollection<?>)objrelatedFillerNoList;
		objCollection = (ISingleCollection<IDataType>)objUnknownCollection;
		setDataType(1651,objCollection);
	}

	/**
	 * Add the Related Placer Group No.
	 * This field specify the service request(s) to which this TQ2 segment links the current service request. 
	 * @param strEntityIdentifier Specifies defined by a hierarchic designator, represented by components 2 through 4.
	 * 								[Reference Section 2.A.33, "HD - hierarchic designator".] 
	 * @param strNamespaceId Specifies  the HL7 identifier for the user-defined table of values for this component.
	 * 						   [Refer to User-defined Table 0363 - Assigning authority] 	 
	 * @param strUniversalId Specifies string formatted according to the scheme defined by the component, 
	 * 							<universal ID type> (UID type). 
	 * @param strUniversalIdType Specifies  the interpretation of the second component of the HD. 
	 */ 
	public void addRelatedPlacerGroupNo (String strEntityIdentifier,String strNamespaceId,String strUniversalId,
			String strUniversalIdType)
	{
		EI relatedPlacerGroupNo  = (EI)getDataElement(1652);
		relatedPlacerGroupNo.setEntityIdentifier(strEntityIdentifier);
		relatedPlacerGroupNo.setNamespaceId(strNamespaceId);
		relatedPlacerGroupNo.setUniversalId(strUniversalId);
		relatedPlacerGroupNo.setUniversalIdType(strUniversalIdType); 
		addRelatedPlacerGroupNo(relatedPlacerGroupNo);

	} 

	/** 
	 * Add the Related Placer Group No.
	 * This field specify the service request(s) to which this TQ2 segment links the current service request. 
	 * @param objrelatedPlacerGroupNo Object of Related Placer Group No. 
	 */ 
	public void addRelatedPlacerGroupNo(EI objrelatedPlacerGroupNo)
	{
		addDataType(1652,objrelatedPlacerGroupNo);

	} 

	/** 
	 * Set the Related Placer Group No.
	 * This field specify the service request(s) to which this TQ2 segment links the current service request. 
	 * @param objrelatedPlacerGroupNoList List of Related Placer Group No. 
	 */ 
	@SuppressWarnings("unchecked")
	public void setRelatedPlacerGroupNo(ISingleCollection<EI> objrelatedPlacerGroupNoList)
	{
		ISingleCollection<IDataType> objCollection = null;
		ISingleCollection<?> objUnknownCollection = (ISingleCollection<?>)objrelatedPlacerGroupNoList;
		objCollection = (ISingleCollection<IDataType>)objUnknownCollection;
		setDataType(1652,objCollection);
	}

	/**
	 * Add the Related Placer No.
	 * This field specify the placer numbers of the service request(s) to which this TQ2 segment links the current service request.
	 * @param strEntityIdentifier Specifies defined by a hierarchic designator, represented by components 2 through 4.
	 * 								[Reference Section 2.A.33, "HD - hierarchic designator".] 
	 * @param strNamespaceId Specifies  the HL7 identifier for the user-defined table of values for this component.
	 * 						   [Refer to User-defined Table 0363 - Assigning authority] 	 
	 * @param strUniversalId Specifies string formatted according to the scheme defined by the component, 
	 * 							<universal ID type> (UID type). 
	 * @param strUniversalIdType Specifies  the interpretation of the second component of the HD. 
	 */ 
	public void addRelatedPlacerNo (String strEntityIdentifier,String strNamespaceId,String strUniversalId,
			String strUniversalIdType)
	{
		EI relatedPlacerNo  = (EI)getDataElement(1650);
		relatedPlacerNo.setEntityIdentifier(strEntityIdentifier);
		relatedPlacerNo.setNamespaceId(strNamespaceId);
		relatedPlacerNo.setUniversalId(strUniversalId);
		relatedPlacerNo.setUniversalIdType(strUniversalIdType); 
		addRelatedPlacerNo(relatedPlacerNo);

	} 

	/** 
	 * Add the Related Placer No.
	 * This field specify the placer numbers of the service request(s) to which this TQ2 segment links the current service request.
	 * @param objrelatedPlacerNo Object of Related Placer No.
	 */ 
	public void addRelatedPlacerNo(EI objrelatedPlacerNo)
	{
		addDataType(1650,objrelatedPlacerNo);

	} 

	/** 
	 * Set the Related Placer No.
	 * This field specify the placer numbers of the service request(s) to which this TQ2 segment links the current service request.
	 * @param objrelatedPlacerNoList List of Related Placer No.
	 */ 
	@SuppressWarnings("unchecked")
	public void setRelatedPlacerNo(ISingleCollection<EI> objrelatedPlacerNoList)
	{
		ISingleCollection<IDataType> objCollection = null;
		ISingleCollection<?> objUnknownCollection = (ISingleCollection<?>)objrelatedPlacerNoList;
		objCollection = (ISingleCollection<IDataType>)objUnknownCollection;
		setDataType(1650,objCollection);
	}

	/**
	 * Set the Sequence Condition Code.
	 * This field specify the start/end of the related service request(s) and the current service request.
	 * @param strSequenceConditionCode String which to set as Sequence Condition Code. 
	 */ 
	public void setSequenceConditionCode (String strSequenceConditionCode) 
	{
		ID sequenceConditionCode  = (ID)getDataElement(1653);
		sequenceConditionCode.setValue(strSequenceConditionCode); 
		setSequenceConditionCode(sequenceConditionCode);

	} 

	/** 
	 * Set the Sequence Condition Code.
	 * This field specify the start/end of the related service request(s) and the current service request.
	 * @param objsequenceConditionCode Object of Sequence Condition Code.
	 */ 
	public void setSequenceConditionCode(ID objsequenceConditionCode)
	{
		setDataType(1653,objsequenceConditionCode);

	}

	/**
	 * Set the Sequence Condition Time Interval.
	 * This field specify the interval of time between the start/end of the related service request(s) and the start/end of the current service request
	 * @param strQuantity Specifies the numeric quantity or amount of an entity.
	 * @param objUnits Specifies the units in which the quantity is expressed. 
	 */ 
	public void setSequenceCondTimeInterval (String strQuantity,CWE objUnits) 
	{
		CQ sequenceCondTimeInterval  = (CQ)getDataElement(1655);
		sequenceCondTimeInterval.setQuantity(strQuantity);
		sequenceCondTimeInterval.setUnits(objUnits); 
		setSequenceCondTimeInterval(sequenceCondTimeInterval);

	} 

	/** 
	 * Set the Sequence Condition Time Interval.
	 * This field specify the interval of time between the start/end of the related service request(s) and the start/end of the current service request
	 * @param objsequenceCondTimeInterval Object of Sequence Condition Time Interval.
	 */ 
	public void setSequenceCondTimeInterval(CQ objsequenceCondTimeInterval)
	{
		setDataType(1655,objsequenceCondTimeInterval);

	}

	/**
	 * Set the Sequence Results Flag.
	 * This field specify the sequencing relationship between the current service request,and the related service request(s) specified in this TQ2 segment.
	 * @param strSequenceResultsFlag String which to set as Sequence Results Flag 
	 */ 
	public void setSequenceResultsFlag (String strSequenceResultsFlag) 
	{
		ID sequenceResultsFlag  = (ID)getDataElement(1649);
		sequenceResultsFlag.setValue(strSequenceResultsFlag); 
		setSequenceResultsFlag(sequenceResultsFlag);

	} 

	/** 
	 * Set the Sequence Results Flag.
	 * This field specify the sequencing relationship between the current service request,and the related service request(s) specified in this TQ2 segment.
	 * @param objsequenceResultsFlag Object of Sequence Results Flag.
	 */ 
	public void setSequenceResultsFlag(ID objsequenceResultsFlag)
	{
		setDataType(1649,objsequenceResultsFlag);

	}

	/**
	 * Set the Set ID TQ2.
	 * This field specify the value for timing specification transmitted.
	 * @param strSetID_TQ2 String which to set as SetID-TQ2
	 */ 
	public void setSetID_TQ2 (String strSetID_TQ2) 
	{
		SI setID_TQ2  = (SI)getDataElement(1648);
		setID_TQ2.setValue(strSetID_TQ2); 
		setSetID_TQ2(setID_TQ2);

	} 

	/** 
	 * Set the Set ID TQ2.
	 * This field specify the value for timing specification transmitted.
	 * @param objsetID_TQ2 Object of Set ID TQ2.
	 */ 
	public void setSetID_TQ2(SI objsetID_TQ2)
	{
		setDataType(1648,objsetID_TQ2);

	}

	/**
	 * Set the Special Service Request Relationship.
	 * This field specify an additional or alternate relationship between this service request and other service requests
	 * @param strSpecialServiceRequestRelationship String which to set as Special Service Request Relationship
	 */ 
	public void setSpecialServiceRequestRelationship (String strSpecialServiceRequestRelationship) 
	{
		ID specialServiceRequestRelationship  = (ID)getDataElement(1657);
		specialServiceRequestRelationship.setValue(strSpecialServiceRequestRelationship); 
		setSpecialServiceRequestRelationship(specialServiceRequestRelationship);

	} 

	/** 
	 * Set the Special Service Request Relationship.
	 * This field specify an additional or alternate relationship between this service request and other service requests
	 * @param objspecialServiceRequestRelationship Object of Special Service Request Relationship.
	 */ 
	public void setSpecialServiceRequestRelationship(ID objspecialServiceRequestRelationship)
	{
		setDataType(1657,objspecialServiceRequestRelationship);

	}

	/**
	 * 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 Throws when Segment Validation fails.
	 */
	public boolean validate() throws InvalidSegmentException
	{
		try
		{
			super.validate();
			/*
			 * At least one of TQ2-3(relatedPlacerNo), TQ2-4(relatedFillerNo),
			 *  TQ2-5(relatedPlacerGroupNo) must contain a value.
			 */
			ISingleCollection<EI> relatedPlacerNo = getRelatedPlacerNo();
			ISingleCollection<EI> relatedPlacerGroupNo = getRelatedPlacerGroupNo();
			ISingleCollection<EI> relatedFillerNo = getRelatedFillerNo();
			if(relatedPlacerNo == null && relatedPlacerGroupNo == null && relatedFillerNo == null)
			{
				String strMessage = objSegmentMap.getFieldName(1650) + ":" + objSegmentMap.getFieldName(1652) + ":" + objSegmentMap.getFieldName(1651) + ResourceBundleWrapper.getValue("exceptions", "SegmentCondition", new Locale(HL7Config.createInstance().getLocale()));
				
					throw new InvalidFieldException (strMessage);
			}

			/*
			 * Either TQ2-6 (sequenceConditionCode) or TQ2-10 (specialServiceRequestRelationship) must be present.
			 */
			ID sequenceConditionCode = getSequenceConditionCode();
			ID specialServiceRequestRelationship = getSpecialServiceRequestRelationship();
			if(sequenceConditionCode == null && specialServiceRequestRelationship == null)
			{
				String strMessage = objSegmentMap.getFieldName(1653) + ":" + objSegmentMap.getFieldName(1657) + ResourceBundleWrapper.getValue("exceptions", "SegmentCondition", new Locale(HL7Config.createInstance().getLocale()));
				
					throw new InvalidFieldException (strMessage);
			}

			/*
			 * TQ-7 (cyclicEntryExitIndicator) Should not be populated when TQ2-2 (Sequence/Results Flag) 
			 * is not equal to a 'C' (cyclic service request).
			 */
			ID cyclicEntryExitIndicator = getCyclicEntryExitIndicator();
			ID sequenceResultsFlag = getSequenceResultsFlag();
			if(cyclicEntryExitIndicator == null && sequenceResultsFlag != null )
			{
				if(sequenceResultsFlag.getValue().equals("C"))
				{
					String strMessage = objSegmentMap.getFieldName(1654) + ResourceBundleWrapper.getValue("exceptions", "SegmentCondition", new Locale(HL7Config.createInstance().getLocale()));
					
						throw new InvalidFieldException (strMessage);
				}
			}
			return true;
		}
		catch(FieldMissingException ex)
		{
			throw new InvalidSegmentException(enumSegments.getValue(),ex);
		}
	}
}