/*******************************************************************************
 *  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.Message;
import cdac.medinfo.sdk.hl7282.baselibs.segments.CTD;
import cdac.medinfo.sdk.hl7282.baselibs.segments.ERR;
import cdac.medinfo.sdk.hl7282.baselibs.segments.IVC;
import cdac.medinfo.sdk.hl7282.baselibs.segments.MSA;
import cdac.medinfo.sdk.hl7282.baselibs.segments.PID;
import cdac.medinfo.sdk.hl7282.baselibs.segments.PSG;
import cdac.medinfo.sdk.hl7282.baselibs.segments.PSL;
import cdac.medinfo.sdk.hl7282.baselibs.segments.PSS;
import cdac.medinfo.sdk.hl7282.baselibs.segments.RFI;
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;

/**
 * EHC_E13 - Additional Information Response (event E13).
 * This message is used by a Provider to immediately respond to an EHC_E12 Request for Additional Information, 
 * in other words an automated response.  
 * <p>Represents a EHC_E13 message structure (see chapter 16.3.8). 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: RFI (Request for Information)	 <b>SINGLE_COMPULSARY</b><br>
 * 6: CTD (Contact Data) <b>MULTIPLE_OPTIONAL</b><br>
 * 7: IVC (Invoice) <b>SINGLE_COMPULSARY</b><br>
 * 8: PSS (Product/Service Section) <b>SINGLE_COMPULSARY</b><br>
 * 9: PSG (Product/Service Group) <b>SINGLE_COMPULSARY</b><br>
 * 10: PID (Person Identification) <b>SINGLE_OPTIONAL</b><br>
 * 11: PSL (Product/Service Line Item) <b>MULTIPLE_OPTIONAL</b><br>
 * 12: REQUEST (Group of EHC_E12 event) <b>MULTIPLE_COMPULSARY</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>EHC_E13 objE13 = (EHC_E13)MessageFactory.createInstance().createSendSupportedMessage("EHC", "E13");</p>
 */
public final class EHC_E13 extends Message{

	/**
	 * Constructs the EHC_E13 message.
	 */
	EHC_E13(IMap objMessageMap)
	{
		super(objMessageMap, EnumMessageCode.EHC.getValue(), EnumTriggerEvent.E13.getValue(), EnumMessageStructure.EHC_E13.getValue());
	}

	/**
	 * 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 Request for Information(RFI) segment present in this message.
	 * @return RFI - Specified Request for Information Segment
	 */
	public RFI getRequestForInformationSegment()
	{
		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_RFI);
		if(objSingleCollection != null)
			return (RFI)objSingleCollection.elementAt(0);
		return null;
	}
	/**
	 * Sets value of RFI segment for this message,overwrites if already present.
	 * @param objRFI Specified RFI Segment
	 */
	public void setRequestForInformationSegment(RFI objRFI)
	{
		setSegment(EnumSegments.HL7_SEG_RFI,objRFI);
	}
	
	/**
	 * Retrieves Collection of Contact Data Segments(CTD) present in this message.
	 * @return ISingleCollection<CTD> - Collection of Contact Data Segments(CTD) present in this message.
	 */
	@SuppressWarnings("unchecked")
	public ISingleCollection<CTD> getContactDataSegments()
	{
		ISingleCollection<?> objSegmentCollection = getSegment(EnumSegments.HL7_SEG_CTD);
		return (ISingleCollection<CTD>)objSegmentCollection;
	}

	/**
	 * Adds Contact Data Segment(CTD) to this message.
	 * @param objCTD Specified Contact Data Segment(CTD) to be added in this message to this message.
	 */
	public void addContactDataSegment(CTD objCTD)
	{
		addSegment(EnumSegments.HL7_SEG_CTD, objCTD);
	}

	/**
	 * Adds collection of Contact Data Segment(CTD) to this message.
	 * @param objCTDSegmentCollection Collection of Contact Data Segments to add in this message
	 */
	@SuppressWarnings("unchecked")
	public void addContactDataSegment(ISingleCollection<CTD> objCTDSegmentCollection)
	{
		ISingleCollection<?> objSegmentCollection = objCTDSegmentCollection;
		addSegment(EnumSegments.HL7_SEG_CTD, (ISingleCollection<ISegment>)objSegmentCollection);
	}
	
	/**
	 * Retrieves Invoice(IVC) segment present in this message.
	 * @return IVC - Specified Invoice Segment
	 */
	public IVC getInVoiceSegment()
	{
		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_IVC);
		if(objSingleCollection != null)
			return (IVC)objSingleCollection.elementAt(0);
		return null;
	}
	/**
	 * Sets value of IVC segment for this message,overwrites if already present.
	 * @param objIVC Specified IVC Segment
	 */
	public void setInVoiceSegment(IVC objIVC)
	{
		setSegment(EnumSegments.HL7_SEG_IVC,objIVC);
	}
	
	/**
	 * Retrieves Product/Service Section(PSS) segment present in this message.
	 * @return PSS - Specified Product/Service Section Segment
	 */
	public PSS getProductOrServiceSectionSegment()
	{
		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_PSS);
		if(objSingleCollection != null)
			return (PSS)objSingleCollection.elementAt(0);
		return null;
	}
	/**
	 * Sets value of PSS segment for this message,overwrites if already present.
	 * @param objPSS Specified PSS Segment
	 */
	public void setProductOrServiceSectionSegment(PSS objPSS)
	{
		setSegment(EnumSegments.HL7_SEG_PSS,objPSS);
	}
	
	/**
	 * Retrieves Product/Service Group(PSG) segment present in this message.
	 * @return PSG - Specified Product/Service Group Segment
	 */
	public PSG getProductOrServiceGroupSegment()
	{
		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_PSG);
		if(objSingleCollection != null)
			return (PSG)objSingleCollection.elementAt(0);
		return null;
	}
	/**
	 * Sets value of PSG segment for this message,overwrites if already present.
	 * @param objPSG Specified PSG Segment
	 */
	public void setProductOrServiceGroupSegment(PSG objPSG)
	{
		setSegment(EnumSegments.HL7_SEG_PSG,objPSG);
	}
	
	/**
	 * Retrieves Person Identification(PID) segment present in this message.
	 * @return PID - Specified Person Identification Segment
	 */
	public PID getPersonIdentificationSegment()
	{
		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_PID);
		if(objSingleCollection != null)
			return (PID)objSingleCollection.elementAt(0);
		return null;
	}
	/**
	 * Sets value of PID segment for this message,overwrites if already present.
	 * @param objPID Specified PID Segment
	 */
	public void setPersonIdentificationSegment(PID objPID)
	{
		setSegment(EnumSegments.HL7_SEG_PID,objPID);
	}
	
	/**
	 * Retrieves Collection of Product/Service Line Item(PSL) present in this message.
	 * @return ISingleCollection<PSL> - Collection of Product/Service Line Item(PSL) present in this message.
	 */
	@SuppressWarnings("unchecked")
	public ISingleCollection<PSL> getProductOrServiceLineItemSegments()
	{
		ISingleCollection<?> objSegmentCollection = getSegment(EnumSegments.HL7_SEG_PSL);
		return (ISingleCollection<PSL>)objSegmentCollection;
	}

	/**
	 * Adds Product/Service Line Item Segment(PSL) to this message.
	 * @param objPSL Specified Product/Service Line Item Segment(PSL) to be added in this message to this message.
	 */
	public void addProductOrServiceLineItemSegment(PSL objPSL)
	{
		addSegment(EnumSegments.HL7_SEG_PSL, objPSL);
	}

	/**
	 * Adds collection of Product/Service Line Item Segment(PSL) to this message.
	 * @param objPSLSegmentCollection Collection of Product/Service Line Item to add in this message
	 */
	@SuppressWarnings("unchecked")
	public void addProductOrServiceLineItemSegment(ISingleCollection<PSL> objPSLSegmentCollection)
	{
		ISingleCollection<?> objSegmentCollection = objPSLSegmentCollection;
		addSegment(EnumSegments.HL7_SEG_PSL, (ISingleCollection<ISegment>)objSegmentCollection);
	}
	
	/**
	 * Retrieves Collection of REQUEST present in this message.
	 * @return ISingleCollection<Group> - Collection of REQUEST present in this Message.
	 */
	public ISingleCollection<IGroup> getRequestGroups()
	{
		return getGroup(EnumSegments.HL7_GROUP_REQUEST);
	}

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

	/**
	 * Adds REQUEST to this message.
	 * @param objGroup Specified REQUEST.
	 */
	public void addRequestGroup(IGroup objGroup)
	{
		addGroup(EnumSegments.HL7_GROUP_REQUEST, objGroup);
	}
}
