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

import cdac.medinfo.sdk.hl7282.baselibs.messages.Message;
import cdac.medinfo.sdk.hl7282.baselibs.segments.ERR;
import cdac.medinfo.sdk.hl7282.baselibs.segments.MSA;
import cdac.medinfo.sdk.hl7282.baselibs.segments.NK1;
import cdac.medinfo.sdk.hl7282.baselibs.segments.REL;
import cdac.medinfo.sdk.hl7282.baselibs.segments.RF1;
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;

/**
 * CQU_I19 – Collaborative Care Query Update (Event I19).
 * The meaning of the Collaborative Care Query Update message is identical to the meaning of 
 * the Asynchronous Collaborative Care Update message.
 * <p>Represents a CQU_I19 message structure (see chapter 11.7.1). 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: MSA (Message Acknowledgment Segment) <b>SINGLE_COMPULSARY</b><br>
 * 4: ERR (Error Segment) <b>MULTIPLE_OPTIONAL</b><br>
 * 5: RF1 (Referral Information) <b>SINGLE_COMPULSARY</b><br>
 * 6: PROVIDER_CONTACT (a Group in CCU_I20 message) <b>MULTIPLE_OPTIONAL</b><br>
 * 7: PATIENT (a Group of segments in CCu_I120 message) <b>MULTIPLE_OPTIONAL</b><br>
 * 8: NK1 (Next of Kin / Associated Parties Segment) <b>MULTIPLE_OPTIONAL</b><br>
 * 9: INSURANCE (a Group of segments in CCu_I20 message) <b>MULTIPLE_OPTIONAL</b><br>
 * 10: APPOINTMENT HISTORY (a Group of segments in CCU_I20 message) <b>MULTIPLE_OPTIONAL</b><br>
 * 11: CLINICAL HISTORY (a Group of segments in CCU_I20 message) <b>MULTIPLE_OPTIONAL</b><br>
 * 12: PATIENT_VISIT (a Group in CCM_I21 message) <b>MULTIPLE_COMPULSARY</b><br>
 * 13: MEDICATION HISTORY (a Group of segments in CCM_I21 message) <b>MULTIPLE_OPTIONAL</b><br>
 * 14: PROBLEM (a Group of segments in CCM_I21 message) <b>MULTIPLE_OPTIONAL</b><br>
 * 15: GOAL (a Group of segments in CCM_I21 message) <b>MULTIPLE_OPTIONAL</b><br>
 * 16: PATHWAY (a Group of segments in CCM_I21 message) <b>MULTIPLE_OPTIONAL</b><br>
 * 17: REL (Relationship) <b>MULTIPLE_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. 
 */
public final class CQU_I19 extends Message{

	/**
	 * Constructs the CQU_I19 message.
	 */
	public CQU_I19(IMap objMessageMap) {
		super(objMessageMap, EnumMessageCode.CQU.getValue(), EnumTriggerEvent.I19.getValue(), EnumMessageStructure.CQU_I19.getValue());
	}
	
	/**
	 * Adds Software Segment(SFT) to this message.
	 * @param objSFT Specified Software Segment(SFT)to be added in 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 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;
	}
	
	/**
	 * 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 Message Acknowledgment(MSA) segment present in this message
	 * @return MSA - the Message Acknowledgment Segment present in this message or null if unavailable.
	 */
	public MSA getMessageAcknowledgmentSegment()
	{
		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_MSA);
		if(objSingleCollection != null)
			return (MSA)objSingleCollection.elementAt(0);
		return null;
	}

	/**
	 * Sets value of Message Acknowledgment segment for this message,overwrites if already present.
	 * @param objMSA Specified Message Acknowledgment Segment 
	 */
	public void setMessageAcknowledgmentSegment(MSA objMSA)
	{
		setSegment(EnumSegments.HL7_SEG_MSA,objMSA);
	}

	/**
	 * Retrieves Collection of Error Segments(ERR) present in this message.
	 * @return ISingleCollection<ERR> - Collection of Error Segments(ERR) present in this message.
	 */
	@SuppressWarnings("unchecked")
	public ISingleCollection<ERR> getErrorSegments()
	{
		ISingleCollection<?> objSegmentCollection = getSegment(EnumSegments.HL7_SEG_ERR);
		return (ISingleCollection<ERR>)objSegmentCollection;
	}

	/**
	 * Adds Error Segment(ERR) to this message.
	 * @param objERR Specified Error Segment(ERR)to this message. 
	 */
	public void addErrorSegment(ERR objERR)
	{
		addSegment(EnumSegments.HL7_SEG_ERR, objERR);
	}

	/**
	 * Adds collection of Error Segment(ERR) to this message.
	 * @param objERRSegmentCollection Collection of Software Segments to add in this message
	 */
	@SuppressWarnings("unchecked")
	public void addErrorSegments(ISingleCollection<ERR>  objERRSegmentCollection)
	{
		ISingleCollection<?> objSegmentCollection =  objERRSegmentCollection;
		addSegment(EnumSegments.HL7_SEG_ERR, (ISingleCollection<ISegment>)objSegmentCollection);
	}
	
	/**
	 *  Retrieves Referral Information(RF1) segment present in this message
	 * @return RFI - the Referral Information Segment present in this message or null if unavailable.
	 */
	public RF1 getReferralInformationSegment()
	{
		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_RF1);
		if(objSingleCollection != null)
			return (RF1)objSingleCollection.elementAt(0);
		return null;
	}

	/**
	 * Sets value of Referral Information segment for this message,overwrites if already present.
	 * @param objRF1 Specified Referral Information Segment 
	 */
	public void setReferralInformationSegment(RF1 objRF1)
	{
		setSegment(EnumSegments.HL7_SEG_RF1,objRF1);
	}	
	
	/**
	 * Retrieves Collection of Provider Contact GROUP present in this message.
	 * @return ISingleCollection<Group> - Collection of Provider Contact Group present 
	 */
	public ISingleCollection<IGroup> getProviderContactGroups()
	{
		return getGroup(EnumSegments.HL7_GROUP_PROVIDER_CONTACT);
	}

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

	/**
	 * Adds Provider Contact GROUP to this message.
	 * @param objGroup Provider Contact GROUP. 
	 */
	public void addProviderContactGroup(IGroup objGroup)
	{
		addGroup(EnumSegments.HL7_GROUP_PROVIDER_CONTACT, objGroup);
	}
	
	/**
	 * 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);
	}
	
	/**
	 * Adds Next of Kin/Associated Parties Segment(NK1) to this message.
	 * @param objNK1 Specified Next of Kin/Associated Parties Segment(NK1) to add in message.
	 */
	public void addNextOfKinOrAssociatedPartiesSegment(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/Associated Parties Segment(NK1) to add in this message
	 */
	@SuppressWarnings("unchecked")
	public void addNextOfKinOrAssociatedPartiesSegment(ISingleCollection<NK1>  objNK1SegmentCollection)
	{
		ISingleCollection<?> objSegmentCollection =  objNK1SegmentCollection;
		addSegment(EnumSegments.HL7_SEG_NK1, (ISingleCollection<ISegment>)objSegmentCollection);
	}

	/**
	 * Retrieves Collection of Next of Kin/Associated Parties Segment(NK1) present in this message.
	 * @return ISingleCollection<NK1> - Collection of Next of Kin/Associated Parties Segment(NK1) present in this message.
	 */
	@SuppressWarnings("unchecked")
	public ISingleCollection<NK1> getNextOfKinOrAssociatedPartiesSegments()
	{
		ISingleCollection<?> objSegmentCollection = getSegment(EnumSegments.HL7_SEG_NK1);
		return (ISingleCollection<NK1>)objSegmentCollection;
	}
	
	/**
	 * Retrieves Collection of Insurance GROUP present in this message.
	 * @return ISingleCollection<Group> - Collection of Insurance Group present 
	 */
	public ISingleCollection<IGroup> getInsuranceGroups()
	{
		return getGroup(EnumSegments.HL7_GROUP_INSURANCE);
	}

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

	/**
	 * Adds Insurance GROUP to this message.
	 * @param objGroup Specified Insurance GROUP. 
	 */
	public void addInsuranceGroup(IGroup objGroup)
	{
		addGroup(EnumSegments.HL7_GROUP_INSURANCE, objGroup);
	}
	
	/**
	 * Retrieves Collection of Appointment History GROUP present in this message.
	 * @return ISingleCollection<Group> - Collection of Appointment History Group present 
	 */
	public ISingleCollection<IGroup> getAppointmentHistoryGroups()
	{
		return getGroup(EnumSegments.HL7_GROUP_APPOINTMENT_HISTORY);
	}

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

	/**
	 * Adds Appointment History GROUP to this message.
	 * @param objGroup Specified Appointment History GROUP. 
	 */
	public void addAppointmentHistoryGroup(IGroup objGroup)
	{
		addGroup(EnumSegments.HL7_GROUP_APPOINTMENT_HISTORY, objGroup);
	}
	
	/**
	 * Retrieves Collection of Clinical History GROUP present in this message.
	 * @return ISingleCollection<Group> - Collection of Clinical History Group present 
	 */
	public ISingleCollection<IGroup> getClinicalHistoryGroups()
	{
		return getGroup(EnumSegments.HL7_GROUP_CLINICAL_HISTORY);
	}

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

	/**
	 * Adds Clinical History GROUP to this message.
	 * @param objGroup Specified Clinical History GROUP. 
	 */
	public void addClinicalHistoryGroup(IGroup objGroup)
	{
		addGroup(EnumSegments.HL7_GROUP_CLINICAL_HISTORY, objGroup);
	}
	
	/**
	 * Retrieves Collection of Patient Visit GROUP present in this message.
	 * @return ISingleCollection<Group> - Collection of Patient Visit Group present 
	 */
	public ISingleCollection<IGroup> getPatientVisitGroups()
	{
		return getGroup(EnumSegments.HL7_GROUP_PATIENT_VISIT);
	}

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

	/**
	 * Adds Patient Visit GROUP to this message.
	 * @param objGroup Patient Visit GROUP. 
	 */
	public void addPatientVisitGroup(IGroup objGroup)
	{
		addGroup(EnumSegments.HL7_GROUP_PATIENT_VISIT, objGroup);
	}
	
	/**
	 * Retrieves Collection of Medication History GROUP present in this message.
	 * @return ISingleCollection<Group> - Collection of Medication History Group present 
	 */
	public ISingleCollection<IGroup> getMedicationHistoryGroups()
	{
		return getGroup(EnumSegments.HL7_GROUP_MEDICATION_HISTORY);
	}

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

	/**
	 * Adds Medication History GROUP to this message.
	 * @param objGroup Specified Medicationl History GROUP. 
	 */
	public void addMedicationHistoryGroup(IGroup objGroup)
	{
		addGroup(EnumSegments.HL7_GROUP_MEDICATION_HISTORY, objGroup);
	}
	
	/**
	 * Retrieves Collection of Problem GROUP present in this message.
	 * @return ISingleCollection<Group> - Collection of Problem Group present 
	 */
	public ISingleCollection<IGroup> getProblemGroups()
	{
		return getGroup(EnumSegments.HL7_GROUP_PROBLEM);
	}

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

	/**
	 * Adds Problem GROUP to this message.
	 * @param objGroup Specified Problem GROUP. 
	 */
	public void addProblemGroup(IGroup objGroup)
	{
		addGroup(EnumSegments.HL7_GROUP_PROBLEM, objGroup);
	}
	
	/**
	 * Retrieves Collection of Goal GROUP present in this message.
	 * @return ISingleCollection<Group> - Collection of Goal Group present 
	 */
	public ISingleCollection<IGroup> getGoalGroups()
	{
		return getGroup(EnumSegments.HL7_GROUP_GOAL);
	}

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

	/**
	 * Adds Goal GROUP to this message.
	 * @param objGroup Specified Goal GROUP. 
	 */
	public void addGoalGroup(IGroup objGroup)
	{
		addGroup(EnumSegments.HL7_GROUP_GOAL, objGroup);
	}
	
	/**
	 * Retrieves Collection of Pathway GROUP present in this message.
	 * @return ISingleCollection<Group> - Collection of Pathway Group present 
	 */
	public ISingleCollection<IGroup> getPathwayGroups()
	{
		return getGroup(EnumSegments.HL7_GROUP_PATHWAY);
	}

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

	/**
	 * Adds Pathway GROUP to this message.
	 * @param objGroup Specified Pathway GROUP. 
	 */
	public void addPathwayGroup(IGroup objGroup)
	{
		addGroup(EnumSegments.HL7_GROUP_PATHWAY, objGroup);
	}
	
	/**
	 * Adds Relationship Segment(REL) to this message.
	 * @param objREL Specified Relationship Segment(REL)to be added in message.
	 */
	public void addRelationshipSegment(REL objREL)
	{
		addSegment(EnumSegments.HL7_SEG_REL, objREL);
	}


	/**
	 * Adds collection of Relationship Segment(REL) to this message.
	 * @param objRELSegmentCollection Collection of Relationship Segments to add in this message
	 */
	@SuppressWarnings("unchecked")
	public void addRelationshipSegment(ISingleCollection<REL>  objRELSegmentCollection)
	{
		ISingleCollection<?> objSegmentCollection =  objRELSegmentCollection;
		addSegment(EnumSegments.HL7_SEG_REL, (ISingleCollection<ISegment>)objSegmentCollection);
	}
	
	/**
	 * Retrieves Collection of Relationship Segments(REL) present in this message.
	 * @return ISingleCollection<REL> - Collection of Relationship Segments(REL) present in this message.
	 */
	@SuppressWarnings("unchecked")
	public ISingleCollection<REL> getRelationshipSegments()
	{
		ISingleCollection<?> objSegmentCollection = getSegment(EnumSegments.HL7_SEG_REL);
		return (ISingleCollection<REL>)objSegmentCollection;
	}
}
