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

import cdac.medinfo.sdk.hl7282.baselibs.messages.AbstractQuery;
import cdac.medinfo.sdk.hl7282.baselibs.segments.DSC;
import cdac.medinfo.sdk.hl7282.baselibs.segments.SFT;
import cdac.medinfo.sdk.hl7282.commoninterface.ISegment;
import cdac.medinfo.sdk.hl7282.commoninterface.ISingleCollection;
import cdac.medinfo.sdk.hl7282.utils.EnumSegments;
import cdac.medinfo.sdk.hl7282.utils.IMap;

/**
 * QRY_Q26 - Pharmacy/Treatment Order Response (Event Q26).
 * This event is use for Pharmacy/Treatment Order Response.
 * <p>Represents a QRY_Q26 message structure . This structure contains the 
 * following elements: </p>
 * 0: MSH (Message Header segment) <b>SINGLE_COMPULSARY</b><br>
 * 1: SFT (Software Segment) <b>MULTIPLE_OPTIONAL</b><br>
 * 2: QRD (Original-Style Query Definition Segment) <b>SINGLE_COMPULSARY</b><br>
 * 3: QRF (Original style query filter Segment) <b>SINGLE_OPTIONAL</b><br>
 * 4: DSC (Continuation Pointer Segment) <b>SINGLE_OPTIONAL</b><br>
 * This class provides mechanism to validate message against HL7 v 2.5 standard.
 * The class provides accessors & mutators for the elements mentioned above.
 * These elements can be easily populated & populated values can be easily retrieved.
 * The class has validate method which validates Message against HL7 v 2.5 standard.
 */
public abstract class QRY_Q26_Common extends AbstractQuery
{
	/**
	 * Constructs the QRY_Q26 message.
	 */
	QRY_Q26_Common(IMap objMessageMap, String strTriggerEvent, String strMessageCode, String strMessageStructure)
	{
		super(objMessageMap, strTriggerEvent, strMessageCode, strMessageStructure);
	}
	
	/**
	 * Veifies whether message is Query.
	 * @return boolean
	 */
	public boolean isQuery()
	{
		return true;
	}
	
	/**
	 * Retrieves Collection of Software Segments(SFT) present in this message.
	 * @return ISingleCollection<SFT> - Collection of Software Segments(SFT) present in this message.
	 */
	@SuppressWarnings("unchecked")
	public ISingleCollection<SFT> getSoftwareSegments()
	{
		ISingleCollection<?> objSegmentCollection = getSegment(EnumSegments.HL7_SEG_SFT);
		return (ISingleCollection<SFT>)objSegmentCollection;
	}

	/**
	 * Adds Software Segment(SFT) to this message.
	 * @param objSFT Specified Software Segment(SFT) to be added in this messageto this message.
	 */
	public void addSoftwareSegment(SFT objSFT)
	{
		addSegment(EnumSegments.HL7_SEG_SFT, objSFT);
	}

	/**
	 * Adds collection of Software Segment(SFT) to this message.
	 * @param objSFTSegmentCollection Collection of Software Segments to add in this message
	 */
	@SuppressWarnings("unchecked")
	public void addSoftwareSegment(ISingleCollection<SFT>  objSFTSegmentCollection)
	{
		ISingleCollection<?> objSegmentCollection =  objSFTSegmentCollection;
		addSegment(EnumSegments.HL7_SEG_SFT, (ISingleCollection<ISegment>)objSegmentCollection);
	}

//	/**
//	 * Retrieves Query Definition(QRD) segment present in this message
//	 * @return QRD - the Query Definition Segment present in this message or null if unavailable.
//	 */
//	public QRD getQueryDefinitionSegment()
//	{
//		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_QRD);
//		if(objSingleCollection != null)
//			return (QRD)objSingleCollection.elementAt(0);
//		return null;
//	}
//	
//	/**
//	 * Sets value of Query Definition segment for this message,overwrites if already present.
//	 * @param objQRD Specified Query Definition Segment 
//	 */
//	public void setQueryDefinitionSegment(QRD objQRD)
//	{
//		setSegment(EnumSegments.HL7_SEG_QRD,objQRD);
//	}
//
//	/**
//	 * Retrieves Query Filter (QRF) segment present in this message
//	 * @return QRF - the Query Filter Segment present in this message or null if unavailable.
//	 */
//	public QRF getQueryFilterSegment()
//	{
//		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_QRF);
//		if(objSingleCollection != null)
//			return (QRF)objSingleCollection.elementAt(0);
//		return null;
//	}
//	
//	/**
//	 * Sets value of Query Filter segment for this message,overwrites if already present.
//	 * @param objQRF Specified Query Filter Segment 
//	 */
//	public void setQueryFilterSegment(QRF objQRF)
//	{
//		setSegment(EnumSegments.HL7_SEG_QRF,objQRF);
//	}

	/**
	 * Retrieves Continuation Pointer(DSC) segment present in this message
	 * @return DSC - the Continuation Pointer Segment present in this message or null if unavailable.
	 */
	public DSC getContinuationPointerSegment()
	{
		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_DSC);
		if(objSingleCollection != null)
			return (DSC)objSingleCollection.elementAt(0);
		return null;
	}
	
	/**
	 * Sets value of Continuation Pointer segment for this message,overwrites if already present.
	 * @param objDSC Specified Continuation Pointer Segment 
	 */
	public void setContinuationPointerSegment(DSC objDSC)
	{
		setSegment(EnumSegments.HL7_SEG_DSC,objDSC);
	}
}
