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

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

/**
 * OUL_R23 - Unsolicited Specimen Container Oriented Observation Message - (Event R23).
 * This message is used to designed for accommodate specimen oriented testing. It
 * should be applicable to laboratory automation systems requiring container.
 * <p>Represents a OUL_R23 message structure (see chapter 7.3.9). 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>SINGLE_OPTIONAL</b><br>
 * 4: PATIENT (a Group of segments in OUL_R23 message) <b>SINGLE_OPTIONAL</b><br>
 * 5: NK1 (Next of Kin  Segment) <b>MULTIPLE_OPTIONAL</b><br>
 * 6: SPECIMEN (a Group of segments in OUL_R23 message) <b>SINGLE_OPTIONAL</b><br>
 * 7: DSC (Continuation Pointer Segment) <b>SINGLE_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.
 *
 * <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>OUL_R23 objR23 = (OUL_R23)MessageFactory.createInstance().createSendSupportedMessage("OUL", "R23");</p>
 */
public final class OUL_R23 extends Message 
{



	/**
	 * Constructs the OUL_R23 message.
	 */
	OUL_R23(IMap objMessageMap)
	{
		super(objMessageMap, EnumMessageCode.OUL.getValue(), EnumTriggerEvent.R23.getValue(), EnumMessageStructure.OUL_R23.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 Notes And Comments(NTE) segment present in this message
	 * @return NTE - the Notes And Comments Segment present in this message or null if unavailable.
	 */
	public NTE getNotesAndCommentsSegment()
	{
		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_NTE);
		if(objSingleCollection != null)
			return (NTE)objSingleCollection.elementAt(0);
		return null;
	}

	/**
	 * Sets value of Notes And Comments segment for this message,overwrites if already present.
	 * @param objNTE Specified Notes And Comments Segment 
	 */
	public void setNotesAndCommentsSegment(NTE objNTE)
	{
		setSegment(EnumSegments.HL7_SEG_NTE,objNTE);
	}

	/**
	 * Retrieves Patient Group present in this message.
	 * @return Group - Patient Group present in this message.
	 */
	public IGroup getPatientGroup()
	{
		ISingleCollection<IGroup> objGroupCollection = getGroup(EnumSegments.HL7_GROUP_PATIENT);
		if(objGroupCollection != null)
			return objGroupCollection.elementAt(0);
		return null;
	}

	/**
	 * Sets value of Patient Group for this message,overwrites if already present.
	 * @param objGroup Specified Patient Group 
	 */
	public void setPatientGroup(IGroup objGroup)
	{
		setGroup(EnumSegments.HL7_GROUP_PATIENT,objGroup);
	}

	/**
	 * Adds Next of Kin Segment(NK1) to this message.
	 * @param objNK1 Specified Next of Kin Segment(NK1) to add in message.
	 */
	public void addNextOfKinSegment(NK1 objNK1)
	{
		addSegment(EnumSegments.HL7_SEG_NK1, objNK1);
	}

	/**
	 * Adds collection of Next of Kin Segments(NK1) to this message.
	 * @param objNK1SegmentCollection Collection of Next of Kin Segment(NK1) to add in this message
	 */
	@SuppressWarnings("unchecked")
	public void addNextOfKinSegment(ISingleCollection<NK1>  objNK1SegmentCollection)
	{
		ISingleCollection<?> objSegmentCollection =  objNK1SegmentCollection;
		addSegment(EnumSegments.HL7_SEG_NK1, (ISingleCollection<ISegment>)objSegmentCollection);
	}

	/**
	 * Retrieves Collection of Next of Kin Segment(NK1) present in this message.
	 * @return ISingleCollection<NK1> - Collection of Next of Kin Segment(NK1) present in this message.
	 */
	@SuppressWarnings("unchecked")
	public ISingleCollection<NK1> getNextOfKinSegments()
	{
		ISingleCollection<?> objSegmentCollection = getSegment(EnumSegments.HL7_SEG_NK1);
		return (ISingleCollection<NK1>)objSegmentCollection;
	}

	/**
	 * Retrieves Collection of SPECIMEN GROUP present in this message.
	 * @return ISingleCollection<Group> - Collection of SPECIMEN  Group present in this Message.
	 */
	public ISingleCollection<IGroup> getSpecimenGroups()
	{
		return getGroup(EnumSegments.HL7_GROUP_SPECIMEN );
	}

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

	/**
	 * Adds SPECIMEN GROUP to this message.
	 * @param objGroup Specified SPECIMEN GROUP. 
	 */
	public void addSpecimenGroup(IGroup objGroup)
	{
		addGroup(EnumSegments.HL7_GROUP_SPECIMEN , objGroup);
	}

	/**
	 * Retrieves Continuation Pointer(DSC) segment present in this message
	 * @return DSC - the Continuation Pointer Segment present in this message or null if unavailable.
	 */
	public DSC getContinuationPointerSegment()
	{
		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_DSC);
		if(objSingleCollection != null)
			return (DSC)objSingleCollection.elementAt(0);
		return null;
	}
	/**
	 * Sets value of Continuation Pointer segment for this message,overwrites if already present.
	 * @param objDSC Specified Continuation Pointer Segment 
	 */
	public void setContinuationPointerSegment(DSC objDSC)
	{
		setSegment(EnumSegments.HL7_SEG_DSC,objDSC);
	}
}