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

import cdac.medinfo.sdk.hl7282.baselibs.messages.AbstractQuery;
import cdac.medinfo.sdk.hl7282.baselibs.segments.ERR;
import cdac.medinfo.sdk.hl7282.baselibs.segments.MSA;
import cdac.medinfo.sdk.hl7282.baselibs.segments.SFT;
import cdac.medinfo.sdk.hl7282.baselibs.segments.UAC;
import cdac.medinfo.sdk.hl7282.commoninterface.IGroup;
import cdac.medinfo.sdk.hl7282.commoninterface.ISegment;
import cdac.medinfo.sdk.hl7282.commoninterface.ISingleCollection;
import cdac.medinfo.sdk.hl7282.utils.EnumMessageCode;
import cdac.medinfo.sdk.hl7282.utils.EnumMessageStructure;
import cdac.medinfo.sdk.hl7282.utils.EnumSegments;
import cdac.medinfo.sdk.hl7282.utils.EnumTriggerEvent;
import cdac.medinfo.sdk.hl7282.utils.IMap;

/**
 * RSP_E03 - Get Person Demographics and Response (RSP) (Events E03).
 * This message is used to respond to a QPB_E03 - Query HealthCare Services Invoice. It provides Invoice and 
 * invoice processing information to a Provider.
 * <p>Represents a RSP_E03 message structure (see chapter 16.3.4). This structure contains the 
 * following elements: </p>
 * 0: MSH (Message Header) <b>SINGLE_COMPULSARY</b><br>
 * 1: SFT (Software Segment) <b>MULTIPLE_OPTIONAL</b><br>
 * 2: UAC (User Authentication Credential) <b>MULTIPLE_OPTIONAL</b><br>
 * 3: MSA (Message Acknowledgment) <b>SINGLE_COMPULSARY</b><br>
 * 4: ERR (Error) <b>MULTIPLE_OPTIONAL</b><br>
 * 5: QUERY_ACK_IPR (a Group of RSP_E03) <b></b><br>
 * This class provides mechanism to validate message against HL7 v 2.8.2 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.8.2 standard.
 *
 * <p>Following is the step to create message<br>
 * Before that, respective Message Source and Message Recipient to be set on Message Factory.</p>
 * <p>RSP_E03 objE03 = (RSP_E03)MessageFactory.createInstance().createSendSupportedMessage("RSP", "E03");</p>
 */
public final class RSP_E03 extends AbstractQuery{

	/**
	 * Constructs the RSP_E03 message.
	 */
	RSP_E03(IMap objMessageMap)
	{
		super(objMessageMap, EnumMessageCode.RSP.getValue(), EnumTriggerEvent.E03.getValue(), EnumMessageStructure.RSP_E03.getValue());
	}
	
	/**
	 * Veifies whether message is Response.
	 * @return boolean
	 */
	public boolean isResponse()
	{
		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 message to 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 Collection of User Authentication Credential Segments(UAC) present in this message.
	 * @return ISingleCollection<UAC> - Collection of User Authentication Credential Segments(UAC) present in this message.
	 */
	@SuppressWarnings("unchecked")
	public ISingleCollection<UAC> getUserAuthenticationCredentialSegments()
	{
		ISingleCollection<?> objSegmentCollection = getSegment(EnumSegments.HL7_SEG_UAC);
		return (ISingleCollection<UAC>)objSegmentCollection;
	}

	/**
	 * Adds User Authentication Credential Segment(UAC) to this message.
	 * @param objUAC Specified User Authentication Credential Segment(UAC) to be added in this message to this message.
	 */
	public void addUserAuthenticationCredentialSegment(UAC objUAC)
	{
		addSegment(EnumSegments.HL7_SEG_UAC, objUAC);
	}

	/**
	 * Adds collection of User Authentication Credential Segment(UAC) to this message.
	 * @param objUACSegmentCollection Collection of User Authentication Credential Segments to add in this message
	 */
	@SuppressWarnings("unchecked")
	public void addUserAuthenticationCredentialSegment(ISingleCollection<UAC> objUACSegmentCollection)
	{
		ISingleCollection<?> objSegmentCollection = objUACSegmentCollection;
		addSegment(EnumSegments.HL7_SEG_UAC, (ISingleCollection<ISegment>)objSegmentCollection);
	}
	
	/**
	 * Retrieves Message Acknowledgment(MSA) segment present in this message
	 * @return MSA - the Message Acknowledgment Segment present in this message or null if unavailable.
	 */
	public MSA getMessageAcknowledgmentSegment()
	{
		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_MSA);
		if(objSingleCollection != null)
			return (MSA)objSingleCollection.elementAt(0);
		return null;
	}
	/**
	 * Sets value of Message Acknowledgment segment for this message,overwrites if already present.
	 * @param objMSA Specified Message Acknowledgment Segment 
	 */
	public void setMessageAcknowledgmentSegment(MSA objMSA)
	{
		setSegment(EnumSegments.HL7_SEG_MSA,objMSA);
	}
	
	/**
	 * Retrieves Collection of Error Segments(ERR) present in this message.
	 * @return ISingleCollection<ERR> - Collection of Error Segments(ERR) present in this message.
	 */
	@SuppressWarnings("unchecked")
	public ISingleCollection<ERR> getErrorSegments()
	{
		ISingleCollection<?> objSegmentCollection = getSegment(EnumSegments.HL7_SEG_ERR);
		return (ISingleCollection<ERR>)objSegmentCollection;
	}

	/**
	 * Adds Error Segment(ERR) to this message.
	 * @param objERR Specified Error Segment(ERR) to be added in this message to this message.
	 */
	public void addErrorSegment(ERR objERR)
	{
		addSegment(EnumSegments.HL7_SEG_ERR, objERR);
	}

	/**
	 * Adds collection of Error Segment(ERR) to this message.
	 * @param objERRSegmentCollection Collection of Error Segments to add in this message
	 */
	@SuppressWarnings("unchecked")
	public void addErrorSegment(ISingleCollection<ERR> objERRSegmentCollection)
	{
		ISingleCollection<?> objSegmentCollection = objERRSegmentCollection;
		addSegment(EnumSegments.HL7_SEG_ERR, (ISingleCollection<ISegment>)objSegmentCollection);
	}
	
	/**
	 * Retrieves Collection of QUERY_ACK_IPR present in this message.
	 * @return ISingleCollection<Group> - Collection of QUERY_ACK_IPR present in this Message.
	 */
	public ISingleCollection<IGroup> getQueryACKIPRGroups()
	{
		return getGroup(EnumSegments.HL7_GROUP_QUERY_ACK_IPR);
	}

	/**
	 * Adds Collection of QUERY_ACK_IPR to this message.
	 * @param objSingleCollection - Specified QUERY_ACK_IPR Collection.
	 */
	public void addQueryACKIPRGroups(ISingleCollection<IGroup> objSingleCollection)
	{
		addGroup(EnumSegments.HL7_GROUP_QUERY_ACK_IPR, objSingleCollection);
	}

	/**
	 * Adds QUERY_ACK_IPR to this message.
	 * @param objGroup Specified QUERY_ACK_IPR.
	 */
	public void addQueryACKIPRGroup(IGroup objGroup)
	{
		addGroup(EnumSegments.HL7_GROUP_QUERY_ACK_IPR, objGroup);
	}
}
