package cdac.medinfo.sdk.hl7282.hl7model.messages.materialsmanagement;

import cdac.medinfo.sdk.hl7282.baselibs.messages.Message;
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;

/**
 * SDR_S31 - Request Anti-Microbial Device Data (Event S31).
 * This trigger event is sent by the placer application to the filler application to request 
 * anti-microbial device data created during the decontamination/sterilization of medical supplies.  
 * <p>Represents a SDR_S31 message structure (see chapter 17.5.4). 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) <b>SINGLE OPTIONAL</b><br/>
 * 3: ANTI-MICROBIAL_DEVICE_DATA (a Group of segments in SDR_S31 message) <b>MULTIPLE_COMPULSARY</b><br>
 * The class provides accessors & mutators for the elements mentioned above.
 * These elements can be easily populated & populated values can be easily retrieved.
 * 
 * <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>SDR_S31 objS31 = (SDR_S31)MessageFactory.createInstance().createSendSupportedMessage("SDR", "S31");</p>
 *
 */
public abstract class SDR_S31_Common extends Message
{
	/**
	 *  Constructs the SDR_S31 message.
	 */
	SDR_S31_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 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 User Authentication Credential(UAC) segment present in this message
	 * @return UAC - Specified UAC Segment
	 */
	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 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 Collection of ANTI-MICROBIAL_DEVICE_DATA present in this message.
	 * @return ISingleCollection<Group> - Collection of ANTI-MICROBIAL_DEVICE_DATA present in this Message.
	 */
	public ISingleCollection<IGroup> getAntiMicrobialDeviceDataGroups()
	{
		return getGroup(EnumSegments.HL7_GROUP_ANTI_MICROBIAL_DEVICE_DATA);
	}

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

	/**
	 * Adds ANTI-MICROBIAL_DEVICE_DATA to this message.
	 * @param objGroup Specified ANTI-MICROBIAL_DEVICE_DATA.
	 */
	public void addAntiMicrobialDeviceDataGroup(IGroup objGroup)
	{
		addGroup(EnumSegments.HL7_GROUP_ANTI_MICROBIAL_DEVICE_DATA, objGroup);
	}

}
