/*******************************************************************************
 *  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.ACC;
import cdac.medinfo.sdk.hl7282.baselibs.segments.AL1;
import cdac.medinfo.sdk.hl7282.baselibs.segments.DG1;
import cdac.medinfo.sdk.hl7282.baselibs.segments.DRG;
import cdac.medinfo.sdk.hl7282.baselibs.segments.GT1;
import cdac.medinfo.sdk.hl7282.baselibs.segments.NK1;
import cdac.medinfo.sdk.hl7282.baselibs.segments.NTE;
import cdac.medinfo.sdk.hl7282.baselibs.segments.PID;
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.EnumSegments;
import cdac.medinfo.sdk.hl7282.utils.IMap;

/**
 * REF_I12 - Patient Referral (Event I12).
 * This message is use for Patient Referral. 
 * <p>Represents a REF_I12 message structure (see chapter 11.5.2). 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: RF1 (Referral Information Segment) <b>SINGLE_OPTIONAL</b><br>
 * 4: AUTHORIZATION_CONTACT (a Group in REF_I12 message) <b>SINGLE_OPTIONAL</b><br>
 * 5: PROVIDER_CONTACT (a Group in REF_I12 message) <b>MULTIPLE_COMPULSARY</b><br>
 * 6: PID (Patient Identification Segment) <b>SINGLE_COMPULSARY</b><br>
 * 7: NK1 (Next of Kin / Associated Parties Segment) <b>MULTIPLE_OPTIONAL</b><br>
 * 8: GT1 (Guarantor) <b>MULTIPLE_OPTIONAL</b><br>
 * 9: INSURANCE (a Group in REF_I12 message Segment) <b>MULTIPLE_OPTIONAL</b><br>
 * 10: ACC (Accident Segment) <b>SINGLE_OPTIONAL</b><br>
 * 11: DG1 (Diagnosis Segment) <b>MULTIPLE_OPTIONAL</b><br>
 * 12: DRG (Diagnosis Related Group Segment) <b>MULTIPLE_OPTIONAL</b><br>
 * 13: AL1 (Patient Allergy Information Segment) <b>MULTIPLE_OPTIONAL</b><br>
 * 14: PROCEDURE (a Group in REF_I12 message) <b>MULTIPLE_OPTIONAL</b><br>
 * 15: OBSERVATION (a Group in REF_I12 message) <b>MULTIPLE_OPTIONAL</b><br>
 * 16: PATIENT_VISIT (a Group in REF_I12 message) <b>SINGLE_OPTIONAL</b><br>
 * 17: NTE (Notes and Comments Segment) <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 abstract class REF_I12_Common extends Message  
{



	/**
	 * Constructs the REF_I12 message.
	 */
	REF_I12_Common(IMap objMessageMap, String strTriggerEvent, String strMessageCode, String strMessageStructure)
	{
		super(objMessageMap, strTriggerEvent, strMessageCode, strMessageStructure);
	}

	/**
	 * 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 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 Authorization Contact Group present in this message.
	 * @return Group - Authorization Contact Group present in this message.
	 */
	public IGroup getAuthorizationContactGroup()
	{
		ISingleCollection<IGroup> objSingleCollection = getGroup(EnumSegments.HL7_GROUP_AUTHORIZATION_CONTACT);
		if(objSingleCollection != null)
			return objSingleCollection.elementAt(0);
		return null;
	}

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

	/**
	 * 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 Specified Provider Contact GROUP. 
	 */
	public void addProviderContactGroup(IGroup objGroup)
	{
		addGroup(EnumSegments.HL7_GROUP_PROVIDER_CONTACT, objGroup);
	}

	/**
	 * Retrieves Patient Identification(PID) segment present in this message.
	 * @return PID - the Patient Identification Segment present in this message or null if unavailable.
	 */
	public PID getPatientIdentificationSegment()
	{
		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_PID);
		if(objSingleCollection != null)
			return (PID)objSingleCollection.elementAt(0);
		return null;
	}

	/**
	 * Sets value of PID segment for this message,overwrites if already present.
	 * @param objPID Specified PID Segment 
	 */
	public void setPatientIdentificationSegment(PID objPID)
	{
		setSegment(EnumSegments.HL7_SEG_PID,objPID);
	}	

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

	/**
	 * Adds collection of Next of Kin/Associated Parties(NK1) to this message.
	 * @param objSegments Collection of Next of Kin/Associated Parties(NK1)
	 */
	@SuppressWarnings("unchecked")
	public void addNextOfKinSegments(ISingleCollection<NK1>  objSegments)
	{
		ISingleCollection<?> objSegmentCollection =  objSegments;
		addSegment(EnumSegments.HL7_SEG_NK1, (ISingleCollection<ISegment>)objSegmentCollection);
	}

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

	/**
	 * Adds Guarantor (global across all FT1s)(GT1 ) to this message.
	 * @param objGT1 Specified Guarantor(GT1) Segment.
	 */
	public void addGuarantorSegment(GT1 objGT1)
	{
		addSegment(EnumSegments.HL7_SEG_GT1, objGT1);
	}

	/**
	 * Adds collection of Guarantor (global across all FT1s)(GT1) to this message.
	 * @param objGT1SegmentCollection Collection of Diagnosis(GT1)
	 */
	@SuppressWarnings("unchecked")
	public void addGuarantorSegments(ISingleCollection<GT1>  objGT1SegmentCollection)
	{
		ISingleCollection<?> objSegmentCollection =  objGT1SegmentCollection;
		addSegment(EnumSegments.HL7_SEG_GT1, (ISingleCollection<ISegment>)objSegmentCollection);
	}

	/**
	 * Retrieves Collection of Guarantor (global across all FT1s)(GT1) present in this message.
	 * @return ISingleCollection<GT1> - Collection of Diagnosis(GT1) 
	 */
	@SuppressWarnings("unchecked")
	public ISingleCollection<GT1> getGuarantorSegments()
	{
		ISingleCollection<?> objSegmentCollection = getSegment(EnumSegments.HL7_SEG_GT1);
		return (ISingleCollection<GT1>)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 Accident Information(ACC) segment present in this message
	 * @return ACC - the Accident Information Segment present in this message or null if unavailable.
	 */
	public ACC getAccidentInformationSegment()
	{
		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_ACC);
		if(objSingleCollection != null)
			return (ACC)objSingleCollection.elementAt(0);
		return null;
	}

	/**
	 * Sets value of Accident Information segment for this message,overwrites if already present.
	 * @param objACC Specified Accident Information Segment 
	 */
	public void setAccidentInformationSegment(ACC objACC)
	{
		setSegment(EnumSegments.HL7_SEG_ACC,objACC);
	}

	/**
	 * Adds Diagnosis(DG1) to this message.
	 * @param objDG1 Specified Diagnosis(DG1) Segment. 
	 */
	public void addDiagnosisSegment(DG1 objDG1)
	{
		addSegment(EnumSegments.HL7_SEG_DG1, objDG1);
	}

	/**
	 * Adds collection of Diagnosis(DG1) to this message.
	 * @param objSegments Collection of Diagnosis(DG1)
	 */
	@SuppressWarnings("unchecked")
	public void addDiagnosisSegments(ISingleCollection<DG1>  objSegments)
	{
		ISingleCollection<?> objSegmentCollection =  objSegments;
		addSegment(EnumSegments.HL7_SEG_DG1, (ISingleCollection<ISegment>)objSegmentCollection);
	}

	/**
	 * Retrieves Collection of Diagnosis(DG1) present in this message.
	 * @return ISingleCollection<DG1> - Collection of Diagnosis(DG1) 
	 */
	@SuppressWarnings("unchecked")
	public ISingleCollection<DG1> getDiagnosisSegments()
	{
		ISingleCollection<?> objSegmentCollection = getSegment(EnumSegments.HL7_SEG_DG1);
		return (ISingleCollection<DG1>)objSegmentCollection;
	}

	/**
	 * Adds Diagnosis Related Group Segment(DRG) to this message.
	 * @param objDRG Specified Diagnosis Related Group Segment(DRG) 
	 */
	public void addDiagnosisRelatedGroupSegment(DRG objDRG)
	{
		addSegment(EnumSegments.HL7_SEG_DRG, objDRG);
	}

	/**
	 * Adds collection of Diagnosis Related Group Segment(DRG) to this message.
	 * @param objDRGSegmentCollection Collection of Diagnosis Related Group Segment(DRG)
	 */
	@SuppressWarnings("unchecked")
	public void addDiagnosisRelatedGroupSegments(ISingleCollection<DRG>  objDRGSegmentCollection)
	{
		ISingleCollection<?> objSegmentCollection =  objDRGSegmentCollection;
		addSegment(EnumSegments.HL7_SEG_DRG, (ISingleCollection<ISegment>)objSegmentCollection);
	}

	/**
	 * Retrieves Collection of Diagnosis Related Group Segment(DRG) present in this message.
	 * @return ISingleCollection<DRG> - Collection of Diagnosis Related Group Segment(DRG) 
	 */
	@SuppressWarnings("unchecked")
	public ISingleCollection<DRG> getDiagnosisRelatedGroupSegments()
	{
		ISingleCollection<?> objSegmentCollection = getSegment(EnumSegments.HL7_SEG_DRG);
		return (ISingleCollection<DRG>)objSegmentCollection;
	}
	

	/**
	 * Adds Allergy Information(AL1) to this message.
	 * @param objAL1 Specified Allergy Information(AL1) 
	 */
	public void addAllergyInformationSegment(AL1 objAL1)
	{
		addSegment(EnumSegments.HL7_SEG_AL1, objAL1);
	}

	/**
	 * Adds collection of Allergy Information(AL1) to this message.
	 * @param objAL1SegmentCollection Collection of Allergy Information(AL1)
	 */
	@SuppressWarnings("unchecked")
	public void addAllergyInformationSegments(ISingleCollection<AL1>  objAL1SegmentCollection)
	{
		ISingleCollection<?> objSegmentCollection =  objAL1SegmentCollection;
		addSegment(EnumSegments.HL7_SEG_AL1, (ISingleCollection<ISegment>)objSegmentCollection);
	}

	/**
	 * Retrieves Collection of Allergy Information(AL1) present in this message.
	 * @return ISingleCollection<AL1> - Collection of Allergy Information(AL1) 
	 */
	@SuppressWarnings("unchecked")
	public ISingleCollection<AL1> getAllergyInformationSegments()
	{
		ISingleCollection<?> objSegmentCollection = getSegment(EnumSegments.HL7_SEG_AL1);
		return (ISingleCollection<AL1>)objSegmentCollection;
	}

	/**
	 * Retrieves Collection of PROCEDURE GROUP present in this message.
	 * @return ISingleCollection<Group> - Collection of PROCEDURE Group present 
	 */
	public ISingleCollection<IGroup> getProcedureGroups()
	{
		return getGroup(EnumSegments.HL7_GROUP_PROCEDURE);
	}

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

	/**
	 * Adds Procedure GROUP to this message.
	 * @param objGroup Specified Procedure GROUP. 
	 */
	public void addProcedureGroup(IGroup objGroup)
	{
		addGroup(EnumSegments.HL7_GROUP_PROCEDURE, objGroup);
	}

	/**
	 * Retrieves Collection of OBSERVATION GROUP present in this message.
	 * @return ISingleCollection<Group> - Collection of OBSERVATION Group present 
	 */
	public ISingleCollection<IGroup> getObservationGroups()
	{
		return getGroup(EnumSegments.HL7_GROUP_OBSERVATION);
	}

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

	/**
	 * Adds Observation GROUP to this message.
	 * @param objGroup Specified Observation GROUP. 
	 */
	public void addObservationGroup(IGroup objGroup)
	{
		addGroup(EnumSegments.HL7_GROUP_OBSERVATION, objGroup);
	}

	/**
	 * Retrieves PatientVisit Group present in this message.
	 * @return Group - PatientVisit Group present in this message.
	 */
	public IGroup getPatientVisitGroup()
	{
		ISingleCollection<IGroup> objSingleCollection = getGroup(EnumSegments.HL7_GROUP_PATIENT_VISIT);
		if(objSingleCollection != null)
			return objSingleCollection.elementAt(0);
		return null;
	}

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

	/**
	 * 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 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 addNotesAndCommentsSegments(ISingleCollection<NTE>  objNTESegmentCollection)
	{
		ISingleCollection<?> objSegmentCollection =  objNTESegmentCollection;
		addSegment(EnumSegments.HL7_SEG_NTE, (ISingleCollection<ISegment>)objSegmentCollection);
	}
}