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

import cdac.medinfo.sdk.hl7282.baselibs.messages.Message;
import cdac.medinfo.sdk.hl7282.baselibs.segments.ERR;
import cdac.medinfo.sdk.hl7282.baselibs.segments.MFA;
import cdac.medinfo.sdk.hl7282.baselibs.segments.MFI;
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.ISegment;
import cdac.medinfo.sdk.hl7282.commoninterface.ISingleCollection;
import cdac.medinfo.sdk.hl7282.utils.EnumSegments;
import cdac.medinfo.sdk.hl7282.utils.IMap;

/**
 * MFK_M01_Common - Master File Application Acknowledgment(Event M02,04,05,06,07,08,09,10,11,12,13,14,15,16,17).
 * <p>Represents a MFK_M01 message structure (see chapter 8.4.1). 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: UAC (User Authentication Credential Segment) <b>SINGLE_OPTIONAL</b><br>
 * 3: MSA (Message Acknowledgment Segment) <b>SINGLE_COMPULSARY</b><br>
 * 4: ERR (Error Segment) <b>MULTIPLE_OPTIONAL</b><br>
 * 5: MFI (Master File Identification Segment) <b>SINGLE_COMPULSARY</b><br>
 * 6: MFA (Master File Acknowledgment Segment) <b>MULTIPLE_OPTIONAL</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. 
 */
public abstract class MFK_M01_Common extends Message
{
	/**
	 * Constructs the MFK_M01 message.
	 */
	MFK_M01_Common(IMap objMessageMap, String strTriggerEvent, String strMessageCode, String strMessageStructure)
	{
		super(objMessageMap, strTriggerEvent, strMessageCode, strMessageStructure);
	}
	
	/**
	 * 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.
	 */
	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 User Authentication Credential(UAC) segment present in this message
	 * @return UAC - the User Authentication Credential Segment present in this message or null if unavailable. 
	 */
	public UAC getUserAuthenticationCredentialSegment()
	{
		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_UAC);
		if(objSingleCollection != null)
			return (UAC)objSingleCollection.elementAt(0);
		return null;
	}
	
	/**
	 * Sets value of User Authentication Credential(UAC) segment  for this message, overwrites if already present.
	 * @param objUAC Specified UAC Segment
	 */
	public void setUserAuthenticationCredentialSegment(UAC objUAC)
	{
		setSegment(EnumSegments.HL7_SEG_UAC,objUAC);
	}

	
	/**
	 * 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 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 Software Segments to add in this message
	 */
	@SuppressWarnings("unchecked")
	public void addErrorSegments(ISingleCollection<ERR>  objERRSegmentCollection)
	{
		ISingleCollection<?> objSegmentCollection =  objERRSegmentCollection;
		addSegment(EnumSegments.HL7_SEG_ERR, (ISingleCollection<ISegment>)objSegmentCollection);
	}

	/**
	 * Retrieves Master File Identification (MFI) segment present in this message
	 * @return MFI - the Message Acknowledgment Segment present in this message or null if unavailable.
	 */
	public MFI getMasterFileIdentificationSegment()
	{
		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_MFI);
		if(objSingleCollection != null)
			return (MFI)objSingleCollection.elementAt(0);
		return null;
	}

	/**
	 * Sets value of Master File Identification segment for this message,overwrites if already present.
	 * @param objMFI Specified Master File Identification Segment 
	 */
	public void setMasterFileIdentificationSegment(MFI objMFI)
	{
		setSegment(EnumSegments.HL7_SEG_MFI,objMFI);
	}

	/**
	 * Retrieves Collection of Master File ACK segment(MFA) present in this message.
	 * @return ISingleCollection<MFA> - Collection of Master File ACK Segments(MFA) present in this message.
	 */
	@SuppressWarnings("unchecked")
	public ISingleCollection<MFA> getMasterFileACKSegments()
	{
		ISingleCollection<?> objSegmentCollection = getSegment(EnumSegments.HL7_SEG_MFA);
		return (ISingleCollection<MFA>)objSegmentCollection;
	}

	/**
	 * Adds Master File ACK Segment(MFA) to this message.
	 * @param objMFA Specified Master File ACK Segment(MFA)to this message. 
	 */
	public void addMasterFileACKSegment(MFA objMFA)
	{
		addSegment(EnumSegments.HL7_SEG_MFA, objMFA);
	}

	/**
	 * Adds collection of Master File ACK Segment(MFA) to this message.
	 * @param objMFASegments Collection of Master File ACK Segments to add in this message
	 */
	@SuppressWarnings("unchecked")
	public void addMasterFileACKSegments(ISingleCollection<MFA>  objMFASegments)
	{
		ISingleCollection<?> objSegmentCollection =  objMFASegments;
		addSegment(EnumSegments.HL7_SEG_MFA, (ISingleCollection<ISegment>)objSegmentCollection);
	}
}
