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

import cdac.medinfo.sdk.hl7282.baselibs.messages.Message;
import cdac.medinfo.sdk.hl7282.baselibs.segments.DG1;
import cdac.medinfo.sdk.hl7282.baselibs.segments.EVN;
import cdac.medinfo.sdk.hl7282.baselibs.segments.GP1;
import cdac.medinfo.sdk.hl7282.baselibs.segments.PID;
import cdac.medinfo.sdk.hl7282.baselibs.segments.PV1;
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;

/**
 * BAR_P10- Transmit Ambulatory Payment Classification (APC) Groups (Event P10).
 * This event is used to communicate Ambulatory Payment Classification (APC) grouping.
 * <p>Represents a BAR_P10 message structure (see chapter 6.4.7). This structure contains the 
 * following elements: </p>
 * 0: MSH (Message Header segment) <b></b><br>
 * 1: SFT (Software Segment) <b>MULTIPLE_OPTIONAL</b><br>
 * 2: UAC (User Authentication Credential segment) <b>SINGLE_OPTIONAL</b><br>
 * 3: EVN (Event Type segment) <b>SINGLE_COMPULSARY</b><br>
 * 4: PID (Patient Identification segment) <b>SINGLE_COMPULSARY</b><br>
 * 5: PV1 (Patient Visit segment) <b>SINGLE_COMPULSARY</b><br>
 * 6: DG1 (Diagnosis segment) <b>MULTIPLE_OPTIONAL</b><br>
 * 7: GP1 (Grouping/Reimbursement - Visit segment) <b>SINGLE_COMPULSARY</b><br>
 * 8: PROCEDURE (a Group of segments in BAR_P10 message) <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.
 *
 * <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>BAR_P10 objP10 = (BAR_P10)MessageFactory.createInstance().createSendSupportedMessage("BAR", "P10");</p>
 */
public final class BAR_P10 extends Message 
{

	/**
	 * Constructs the BAR_P10 message.
	 */
	BAR_P10(IMap objMessageMap)
	{
		super(objMessageMap, EnumMessageCode.BAR.getValue(), EnumTriggerEvent.P10.getValue(), EnumMessageStructure.BAR_P10.getValue());
	}

	/**
	 * Adds Software Segment(SFT) to this message.
	 * @param objSFT Specified Software Segment(SFT) to be added in 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
	 */
	@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) 
	 */
	@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 - the User Authentication Credential Segment present in this message or null if unavailable. 
	 */
	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(UAC) 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 Event Type(EVN) segment present in this message
	 * @return EVN - the EVN Segment present in this message or null if unavailable.
	 */
	public EVN getEventTypeSegment()
	{
		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_EVN);
		if(objSingleCollection != null)
			return (EVN)objSingleCollection.elementAt(0);
		return null;
	}

	/**
	 * Sets value of Event Type segment for this message,overwrites if already present.
	 * @param objEVN Specified EVN Segment 
	 */
	public void setEventTypeSegment(EVN objEVN)
	{
		setSegment(EnumSegments.HL7_SEG_EVN,objEVN);
	}

	/**
	 * 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);
	}

	/**
	 * Retrieves Patient Visit(PV1) segment present in this message.
	 * @return PV1  - Patient Visit Segment present in this message or null if unavailable.
	 */
	public PV1 getPatientVisitSegmentSegment()
	{
		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_PV1);
		if(objSingleCollection != null)
			return (PV1)objSingleCollection.elementAt(0);
		return null;
	}
	/**
	 * Sets value of PV1  segment for this message,overwrites if already present.
	 * @param objPV1  Specified PV1  Segment
	 */
	public void setPatientVisitSegment(PV1  objPV1)
	{
		setSegment(EnumSegments.HL7_SEG_PV1, objPV1);
	}

	/**
	 * Adds Diagnosis Segment(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 objDG1SegmentCollection Collection of Diagnosis(DG1)
	 */
	@SuppressWarnings("unchecked")
	public void addDiagnosisSegments(ISingleCollection<DG1> objDG1SegmentCollection)
	{
		ISingleCollection<?> objSegmentCollection = objDG1SegmentCollection;
		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;

	}

	/**
	 * Retrieves Grouping/Reimbursement - Visit segment present in this message.
	 * @return GP1  - Grouping/Reimbursement - Visit Segment present in this message or null if unavailable.
	 */
	public GP1 getGroupingReimbursementVisitSegment()
	{
		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_GP1);
		if(objSingleCollection != null)
			return (GP1)objSingleCollection.elementAt(0);
		return null;
	}

	/**
	 * Sets value of Grouping/Reimbursement - Visit  segment for this message,overwrites if already present.
	 * @param objGP1 Specified GP1 Segment
	 */
	public void setGroupingReimbursementVisitSegment(GP1  objGP1)
	{
		setSegment(EnumSegments.HL7_SEG_GP1, objGP1);
	}

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

	/**
	 * Adds collection of Procedure Group to this message.
	 * @param objSegments Collection of Software Groups
	 */
	public void addProcedureGroups(ISingleCollection<IGroup> objSingleCollection)
	{
		addGroup(EnumSegments.HL7_GROUP_PROCEDURE, objSingleCollection);
	}

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