package cdac.medinfo.sdk.hl7282.hl7net.commons;

import java.io.FileOutputStream;
import java.io.IOException;

import javax.xml.stream.XMLEventFactory;
import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.StartDocument;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;

import cdac.medinfo.sdk.hl7282.baselibs.messages.Message;
import cdac.medinfo.sdk.hl7282.baselibs.segments.BHS;
import cdac.medinfo.sdk.hl7282.baselibs.segments.BTS;
import cdac.medinfo.sdk.hl7282.baselibs.segments.QPD;
import cdac.medinfo.sdk.hl7282.baselibs.segments.RCP;
import cdac.medinfo.sdk.hl7282.commoninterface.IHL7Stream;
import cdac.medinfo.sdk.hl7282.commoninterface.ISingleCollection;
import cdac.medinfo.sdk.hl7282.exceptions.BatchException;
import cdac.medinfo.sdk.hl7282.utils.HL7Constants;





/**
 * The IHL7Batch interface should be implemented by HL7 Batch class. 
 */
public interface IHL7Batch 
{
	/**
	 * Sets the message collection.
	 * @param objMessageCollection the new message collection
	 */
	public void setMessageCollection(ISingleCollection<Message> objMessageCollection); 
	
	/**
	 * Gets the message collection.
	 * @return the message collection
	 */
	public ISingleCollection<Message> getMessageCollection() ;
	
		
	/**
	 * Gets the BatchControlID.
	 * @return the BatchControlID.
	 */
	public String getBatchControlID();
	
	/**
	 * Sets query segments required to form Enhanced mode Query Batch.
	 * @param objQPD Specified Query Parameter definition Segment.
	 * @param objRCP Specified Response control parameter segment.
	 */
	public void setQuerySegments(QPD objQPD,RCP objRCP);
	
	/**
	 * Gets the QueryIdentifier.
	 * @return the QueryIdentifier.
	 */
	public String getQueryIdentifier();
	
	/**
	 * Checks the Response Batch for Deferred.
	 * @return true - if Deferred.
	 */
	public boolean isDeferred();
	
	
	/**
	 * Gets the batch header.
	 * @return the batch header
	 */
	public BHS getBatchHeader() ;
	
	/**
	 * Sets the batch header.
	 * @param objBatchHeader the new batch header
	 */
	public void setBatchHeader(BHS objBatchHeader) ;
	
	/**
	 * Gets the batch trailer.
	 * @return the batch trailer
	 */
	public BTS getBatchTrailer() ;
	
	/**
	 * Sets the batch trailer.
	 * @param objBatchTrailer the new batch trailer
	 */
	public void setBatchTrailer(BTS objBatchTrailer) ;
	
	/**
	 * Checks if is response batch.
	 * @return true - if is response batch
	 * 		   false - otherwise
	 */
	public boolean isResponseBatch();
	
	/**
	 * Validates HL7 Batch objects.
	 * @return true - if successful
	 * 		   false - otherwise
	 * @throws BatchException Thrown when Batch validation fails.
	 */
	public boolean validate()throws BatchException ;// should throw InvalidBatchException Actually

	/**
	 * Gets QueryParameterDefinitionSegment
	 * @return
	 */
	public QPD getQueryParameterDefinitionSegment() ;

	/**
	 * Gets ResponseControlParameterSegment
	 * @return
	 */
	public RCP getResponseControlParameterSegment();
	
	/**
	 * Serializes Batch Information in the form of XML.
	 * @return String - Returns Batch in XML format 
	 * @throws IOException
	 * @throws XMLStreamException
	 */
	public String writeBatchToXML_v2() throws IOException, XMLStreamException;
	
	/**
	 * Serializes Batch Information in the form of XML.
	 * @param strFilePath Destination file path
	 * @throws IOException
	 * @throws XMLStreamException
	 */
	public void writeBatchToXML_v2(String strFilePath) throws IOException, XMLStreamException;
	

}
