/*******************************************************************************
 *  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.APR;
import cdac.medinfo.sdk.hl7282.baselibs.segments.ARQ;
import cdac.medinfo.sdk.hl7282.baselibs.segments.NTE;
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;

/**
 * SRM_S01 - Schedule Request Message (Event S01).
 * The Schedule Request Messagw contains all the information necessary to communicate the desired action to the filler application.   
 * <p>Represents a SRM_S01 message structure (see chapter 10.3). This structure contains the 
 * following elements: </p>
 * 0: MSH (Message Header) <b>SINGLE_COMPULSARY</b><br>
 * 1: ARQ (Appointment Request) <b>SINGLE_COMPULSARY</b><br>
 * 2: APR (Appointment Preferences) <b>SINGLE_OPTIONAL</b><br>
 * 3: NTE (Notes and Comments) <b>MULTIPLE_OPTIONAL</b><br>
 * 4: PATIENT (a Group in SRM_S01 message) <b>MULTIPLE_OPTIONAL</b><br>
 * 5: RESOURCES (a Group in SRM_S01 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 SRM_S01_Common extends Message
{
	/**
	 * Constructs the SRM_S01 message.
	 */
	SRM_S01_Common(IMap objMessageMap, String strTriggerEvent, String strMessageCode, String strMessageStructure)
	{
		super(objMessageMap, strTriggerEvent, strMessageCode, strMessageStructure);
	}

	/**
	 * 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 UNKNOWN GROUP present in this message.
	 * @return ISingleCollection<Group> - Collection of UNKNOWN Group present in this Message.
	 */
	public ISingleCollection<IGroup> getUnknownGroups()
	{
		return getGroup(EnumSegments.HL7_GROUP_UNKNOWN);
	}
	
	/**
	 * Adds Collection of UNKNOWN GROUP to this message.
	 * @param objSingleCollection Specified  UNKNOWN GROUP Collection.
	 */
	public void addUnknownGroups(ISingleCollection<IGroup> objSingleCollection)
	{
		addGroup(EnumSegments.HL7_GROUP_UNKNOWN, objSingleCollection);
	}

	/**
	 * Adds UNKNOWN GROUP to this message.
	 * @param objGroup Specified PATIENT GROUP. 
	 */
	public void addUnknownGroup(IGroup objGroup)
	{
		addGroup(EnumSegments.HL7_GROUP_UNKNOWN , 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);
	}

	/**
	 * Retrieves Appointment Request (ARQ) segment present in this message
	 * @return APQ - the Appointment Request Segment present in this message or null if unavailable.
	 */
	public ARQ getAppointmentRequestSegment()
	{
		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_ARQ);
		if(objSingleCollection != null)
			return (ARQ)objSingleCollection.elementAt(0);
		return null;
	}
	/**
	 * Sets value of Appointment Request segment for this message,overwrites if already present.
	 * @param objARQ Specified Appointment Request Segment 
	 */
	public void setAppointmentRequestSegment(ARQ objARQ)
	{
		setSegment(EnumSegments.HL7_SEG_ARQ,objARQ);
	}

	/**
	 * Retrieves Appointment Preferences (APR) segment present in this message
	 * @return APR - the Appointment Preferences Segment present in this message or null if unavailable.
	 */
	public APR getAppointmentPreferencesSegment()
	{
		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_APR);
		if(objSingleCollection != null)
			return (APR)objSingleCollection.elementAt(0);
		return null;
	}

	/**
	 * Sets value of Appointment Preferences segment for this message,overwrites if already present.
	 * @param objAPR Specified Appointment Preferences Segment 
	 */
	public void setAppointmentPreferencesSegment(APR objAPR)
	{
		setSegment(EnumSegments.HL7_SEG_APR,objAPR);
	}
}
