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

import cdac.medinfo.sdk.hl7282.baselibs.messages.Message;
import cdac.medinfo.sdk.hl7282.baselibs.segments.NTE;
import cdac.medinfo.sdk.hl7282.baselibs.segments.SCH;
import cdac.medinfo.sdk.hl7282.baselibs.segments.TQ1;
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.EnumSegments;
import cdac.medinfo.sdk.hl7282.utils.IMap;

/**
 * SIU_S12 - Schedule Information Unsolicited Message (event S12).
 * This event is use between filler applications and auxiliary applications.  
 * Transactions are initiated by the filler application, using the SIU message 
 * to notify auxiliary applications of modifications in a filler application's 
 * schedule(s). 
 * <p>Represents a SIU_S12 message structure (see chapter 10.4). This structure contains the 
 * following elements: </p>
 * 0: MSH (Message Header segment) <b>SINGLE_COMPULSARY</b><br>
 * 1: SCH (Schedule Activity Information) <b>SINGLE_COMPULSARY</b><br>
 * 2: TQ1 (Timing/Quantity) <b>MULTIPLE_OPTIONAL</b><br>
 * 3: NTE (Notes and Comments for the SCH) <b>MULTIPLE_OPTIONAL</b><br>
 * 4: PATIENT (a Group in SIU_S12 message) <b>MULTIPLE_OPTIONAL</b><br>
 * 5: RESOURCES(a Group in SIU_S12 message) <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. 
 */
public abstract class SIU_S12_Common extends Message
{
	/**
	 * Constructs the SIU_S12 message.
	 */
	SIU_S12_Common(IMap objMessageMap, String strTriggerEvent, String strMessageCode, String strMessageStructure)
	{
		super(objMessageMap, strTriggerEvent, strMessageCode, strMessageStructure);
	}

	/**
	 * Retrieves Schedule Activity Information (SCH) segment present in this message
	 * @return SCH - the Schedule Activity Information Segment present in this message or null if unavailable.
	 */
	public SCH getScheduleActivityInformation()
	{
		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_SCH);
		if(objSingleCollection != null)
			return (SCH)objSingleCollection.elementAt(0);
		return null;
	}
	/**
	 * Sets value of Schedule Activity Information segment for this message,overwrites if already present.
	 * @param objSCH Specified Schedule Activity Information Segment 
	 */
	public void setScheduleActivityInformation(SCH objSCH)
	{
		setSegment(EnumSegments.HL7_SEG_SCH,objSCH);
	}

	/**
	 * Retrieves Collection of Timing/Quantity Segments(TQ1) present in this message.
	 * @return ISingleCollection<TQ1> - Collection of Timing/Quantity Segments(TQ1) present in this message.
	 */
	@SuppressWarnings("unchecked")
	public ISingleCollection<TQ1> getTimingQuantitySegments()
	{
		ISingleCollection<?> objSegmentCollection = getSegment(EnumSegments.HL7_SEG_TQ1);
		return (ISingleCollection<TQ1>)objSegmentCollection;
	}

	/**
	 * Adds Timing/Quantity Segment(TQ1) to this message.
	 * @param objTQ1 Specified Timing/Quantity Segment(TQ1)to this message. 
	 */
	public void addTimingQuantitySegment(TQ1 objTQ1)
	{
		addSegment(EnumSegments.HL7_SEG_TQ1, objTQ1);
	}

	/**
	 * Adds collection of TimingQuantity Segment(TQ1) to this message.
	 * @param objTQ1SegmentCollection Collection of Timing/Quantity Segments to add in this message
	 */
	@SuppressWarnings("unchecked")
	public void addTimingQuantitySegments(ISingleCollection<TQ1>  objTQ1SegmentCollection)
	{
		ISingleCollection<?> objSegmentCollection =  objTQ1SegmentCollection;
		addSegment(EnumSegments.HL7_SEG_TQ1, (ISingleCollection<ISegment>)objSegmentCollection);
	}

	/**
	 * Retrieves Collection of Notes and Comments for the SCH Segments(NTE) present in this message.
	 * @return ISingleCollection<NTE> - Collection of Notes and Comments for the SCH 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 for the SCH Segment(NTE) to this message.
	 * @param objNTE Specified Notes and Comments for the SCH Segment(NTE)to this message. 
	 */
	public void addNotesandCommentsSegment(NTE objNTE)
	{
		addSegment(EnumSegments.HL7_SEG_NTE, objNTE);
	}

	/**
	 * Adds collection of Notes and Comments for the SCH Segment(NTE) to this message.
	 * @param objNTESegmentCollection Collection of Notes and Comments for the SCH segments to add in this message
	 */
	@SuppressWarnings("unchecked")
	public void addNotesandCommentsSegments(ISingleCollection<NTE>  objNTESegmentCollection)
	{
		ISingleCollection<?> objSegmentCollection =  objNTESegmentCollection;
		addSegment(EnumSegments.HL7_SEG_NTE, (ISingleCollection<ISegment>)objSegmentCollection);
	}

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

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

	/**
	 * Adds PATIENT GROUP to this message.
	 * @param objGroup Specified PATIENT GROUP. 
	 */
	public void addPatientGroup(IGroup objGroup)
	{
		addGroup(EnumSegments.HL7_GROUP_PATIENT , objGroup);
	}

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

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

	/**
	 * Adds RESOURCES GROUP to this message.
	 * @param objGroup Specified RESOURCES GROUP. 
	 */
	public void addResourcesGroup(IGroup objGroup)
	{
		addGroup(EnumSegments.HL7_GROUP_RESOURCES , objGroup);
	}
}
