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

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


/**
 * OPL_O37- Imaging Order Message (Event O37).
 * This message supports the use-case for submission of field level specimen and order data to diagnostic laboratories. 
 * <p>Represents a OPL_O37 message structure (see chapter 4.4.12 ) 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: NTE (Notes and Comments Segment) <b>MULTIPLE_OPTIONAL</b><br>
 * 3: PRT (Participation) <b>MULTIPLE_COMPULSARY</b><br>
 * 4: GUARANTOR (a Group in OPL_O37 message) <b>SINGLE_OPTIONAL</b><br>
 * 5: PATIENT (a Group in OPL_O37 message) <b>SINGLE_OPTIONAL</b><br>
 * 6: ORDER (a Group in OPL_O37 message) <b>MULTIPLE_COMPULSARY</b><br>
 * This class provides mechanism to validate message against HL7 v 2.5 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.5 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>OPL_O37 objO37 = (OPL_O37)MessageFactory.createInstance().createSendSupportedMessage("OPL", "O37");</p>
 */
public final class OPL_O37 extends Message
{
	/**
	 * Constructs the OPL_O37 message.
	 */
	OPL_O37(IMap objMessageMap)
	{
		super(objMessageMap, EnumMessageCode.OPL.getValue(), EnumTriggerEvent.O37.getValue(), EnumMessageStructure.OPL_O37.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 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 Notes and Comments  Segments(NTE) present in this message.
	 * @return ISingleCollection<NTE> - Collection of Notes and Comments  Segments(NTE) present in this message.
	 */
	@SuppressWarnings("unchecked")
	public ISingleCollection<NTE> getNotesAndCommentsSegments()
	{
		ISingleCollection<?> objSegmentCollection = getSegment(EnumSegments.HL7_SEG_NTE);
		return (ISingleCollection<NTE>)objSegmentCollection;
	}

	/**
	 * Adds Notes and Comments  Segment(NTE) to this message.
	 * @param objNTE Specified Notes and Comments  Segment(NTE)to add in this message.
	 */
	public void addNotesAndCommentsSegment(NTE objNTE)
	{
		addSegment(EnumSegments.HL7_SEG_NTE, objNTE);
	}

	/**
	 * Adds collection of Notes and Comments  Segment(NTE) to this message.
	 * @param objNTESegmentCollection Collection of Notes and Comments  Segments to add in this message
	 */
	@SuppressWarnings("unchecked")
	public void addNotesAndCommentsSegment(ISingleCollection<NTE>  objNTESegmentCollection)
	{
		ISingleCollection<?> objSegmentCollection =  objNTESegmentCollection;
		addSegment(EnumSegments.HL7_SEG_NTE, (ISingleCollection<ISegment>)objSegmentCollection);
	}
	
	/**
	 * Retrieves Collection of Participation Segments(ERR) present in this message.
	 * @return ISingleCollection<ERR> - Collection of Participation Segments(ERR) present in this message.
	 */
	@SuppressWarnings("unchecked")
	public ISingleCollection<PRT> getParticipationSegments()
	{
		ISingleCollection<?> objSegmentCollection = getSegment(EnumSegments.HL7_SEG_PRT);
		return (ISingleCollection<PRT>)objSegmentCollection;
	}

	/**
	 * Adds Participation Segment(PRT) to this message.
	 * @param objPRT Specified Participation Segment(PRT)to this message. 
	 */
	public void addParticipationSegment(PRT objPRT)
	{
		addSegment(EnumSegments.HL7_SEG_PRT, objPRT);		
	}

	/**
	 * Adds collection of Participation Segment(PRT) to this message.
	 * @param objPRTSegmentCollection Collection of Software Segments to add in this message
	 */
	@SuppressWarnings("unchecked")
	public void addParticipationSegments(ISingleCollection<PRT>  objPRTSegmentCollection)
	{
		ISingleCollection<?> objSegmentCollection =  objPRTSegmentCollection;
		addSegment(EnumSegments.HL7_SEG_PRT, (ISingleCollection<ISegment>)objSegmentCollection);
	}
	
	/**
	 * Retrieves GUARANTOR Group present in this message.
	 * @return Group - GUARANTOR Group present in this message.
	 */
	public IGroup getGuarantorGroup()
	{
		ISingleCollection<IGroup> objGroupCollection = getGroup(EnumSegments.HL7_GROUP_GUARANTOR);
		if(objGroupCollection != null)
			return objGroupCollection.elementAt(0);
		return null;
	}

	/**
	 * Sets value of GUARANTOR Group for this message,overwrites if already present.
	 * @param objGroup Specified GUARANTOR Group 
	 */
	public void setGuarantorGroup(IGroup objGroup)
	{
		setGroup(EnumSegments.HL7_GROUP_GUARANTOR,objGroup);
	}
	
	/**
	 * Retrieves Collection of ORDER GROUP present in this message.
	 * @return ISingleCollection<Group> - Collection of ORDER  Group present in this Message.
	 */
	public ISingleCollection<IGroup> getOrderGroups()
	{
		return getGroup(EnumSegments.HL7_GROUP_ORDER );
	}

	/**
	 * Adds Collection of ORDER GROUP to this message.
	 * @param objSingleCollection Specified  ORDER  GROUP Collection.
	 */
	public void addOrderGroups(ISingleCollection<IGroup> objSingleCollection)
	{
		addGroup(EnumSegments.HL7_GROUP_ORDER, objSingleCollection);
	}

	/**
	 * Adds ORDER GROUP to this message.
	 * @param objGroup Specified ORDER GROUP. 
	 */
	public void addOrderGroup(IGroup objGroup)
	{
		addGroup(EnumSegments.HL7_GROUP_ORDER , objGroup);
	}

}
