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

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

/**
 * ADT_A60 - Update Adverse Reaction Information (Event A60).
 * This event is use when person/patient allergy information has changed.
 * <p>Represents a ADT_A60 message structure (see chapter 3.2.60). 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: EVN (Event Type Segment) <b>SINGLE_COMPULSARY</b><br>
 * 4: PID (Patient Identification Segment) <b>SINGLE_COMPULSARY</b><br>
 * 5: ARV (Access Restrictions) <b>MULTIPLE_OPTIONAL</b><br/> 
 * 6: PV1 (Patient Visit Segment) <b>SINGLE_OPTIONAL</b><br>
 * 7: PV2 (Patient Visit - Additional Information Segment) <b>SINGLE_OPTIONAL</b><br>
 * 8: ARV (Access Restrictions) <b>MULTIPLE_OPTIONAL</b><br/> 
 * 9: IAM (Patient Adverse Reaction Information 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. 
 *
 * <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>ADT_A60 objA60 = (ADT_A60)MessageFactory.createInstance().createSendSupportedMessage("ADT", "A60");</p>
 */
public final class ADT_A60 extends Message 
{
	/**
	 * Constructs the A60 message.
	 */
	ADT_A60(IMap objMessageMap)
	{
		super(objMessageMap, EnumMessageCode.ADT.getValue(), EnumTriggerEvent.A60.getValue(), EnumMessageStructure.ADT_A60.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 Event Type(EVN) segment present in this message
	 * @return EVN - EVN Segment
	 */
	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 - Patient Identification Segment
	 */
	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 Access Restrictions(ARV) to this message.
	 * @param objARV Specified Access Restrictions Segment to be added in message.
	 */
	public void addPatientIdentificationAccessRestrictionsSegment(ARV objARV)
	{
		addSegment(EnumSegments.HL7_SEG_ARV_PATIENT_IDENTIFICATION, objARV);
	}

	/**
	 * Adds collection of Access Restrictions(ARV) to this message.
	 * @param objARVSegmentCollection Collection of Access Restrictions(ARV) to add in this message
	 */
	@SuppressWarnings("unchecked")
	public void addPatientIdentificationAccessRestrictionsSegment(ISingleCollection<ARV>  objARVSegmentCollection)
	{
		ISingleCollection<?> objSegmentCollection =  objARVSegmentCollection;
		addSegment(EnumSegments.HL7_SEG_ARV_PATIENT_IDENTIFICATION, (ISingleCollection<ISegment>)objSegmentCollection);
	}

	/**
	 * Retrieves Collection of Access Restrictions(ARV) present in this message.
	 * @return ISingleCollection<ARV> - Collection of Access Restrictions(ARV) present in this message.
	 */
	@SuppressWarnings("unchecked")
	public ISingleCollection<ARV> getPatientIdentificationAccessRestrictionsSegments()
	{
		ISingleCollection<?> objSegmentCollection = getSegment(EnumSegments.HL7_SEG_ARV_PATIENT_IDENTIFICATION);
		return (ISingleCollection<ARV>)objSegmentCollection;
	}


	/**
	 * Retrieves Patient Visit(PV1) segment present in this message
	 * @return PV1 - PV1 Segment
	 */
	public PV1 getPatientVisitSegment()
	{
		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_PV1);
		if(objSingleCollection != null)
			return (PV1)objSingleCollection.elementAt(0);
		return null;
	}

	/**
	 * Sets value of Patient Visit segment for this message,overwrites if already present.
	 * @param objPV1 Specified PV1 Segment
	 */
	public void setPatientVisitSegment(PV1 objPV1)
	{
		setSegment(EnumSegments.HL7_SEG_PV1,objPV1);
	}

	/**
	 * Retrieves Patient Visit Additional Info(PV2) segment present in this message.
	 * @return PV2 - Patient Visit Additional Info(PV2) Segment
	 */
	public PV2 getPatientVisitAdditionalInfoSegment()
	{
		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_PV2);
		if(objSingleCollection != null)
			return (PV2)objSingleCollection.elementAt(0);
		return null;
	}
	/**
	 * Sets value of Patient Visit Additional Info(PV2) segment for this message,overwrites if already present.
	 * @param objPV2 Specified PV2 Segment
	 */
	public void setPatientVisitAdditionalInfoSegment(PV2 objPV2)
	{
		setSegment(EnumSegments.HL7_SEG_PV2,objPV2);
	}

	/**
	 * Adds Access Restrictions(ARV) to this message.
	 * @param objARV Specified Access Restrictions Segment to be added in message.
	 */
	public void addPatientVisitAccessRestrictionsSegment(ARV objARV)
	{
		addSegment(EnumSegments.HL7_SEG_ARV_PATIENT_VISIT, objARV);
	}

	/**
	 * Adds collection of Access Restrictions(ARV) to this message.
	 * @param objARVSegmentCollection Collection of Access Restrictions(ARV) to add in this message
	 */
	@SuppressWarnings("unchecked")
	public void addPatientVisitAccessRestrictionsSegments(ISingleCollection<ARV>  objARVSegmentCollection)
	{
		ISingleCollection<?> objSegmentCollection =  objARVSegmentCollection;
		addSegment(EnumSegments.HL7_SEG_ARV_PATIENT_VISIT, (ISingleCollection<ISegment>)objSegmentCollection);
	}

	/**
	 * Retrieves Collection of Access Restrictions(ARV) present in this message.
	 * @return ISingleCollection<ARV> - Collection of Access Restrictions(ARV) present in this message.
	 */
	@SuppressWarnings("unchecked")
	public ISingleCollection<ARV> getPatientVisitAccessRestrictionsSegments()
	{
		ISingleCollection<?> objSegmentCollection = getSegment(EnumSegments.HL7_SEG_ARV_PATIENT_VISIT);
		return (ISingleCollection<ARV>)objSegmentCollection;
	}
	
	/**
	 *  Retrieves Collection of ADVERSE REACTION GROUP present in this message.
	 *  @return ISingleCollection<Group> - Collection of ADVERSE REACTION GROUP present in this message.
	 */
	public ISingleCollection<IGroup> getAdverseReactionGroups()
	{
		return getGroup(EnumSegments.HL7_GROUP_ADVERSE_REACTION);
	}
	/**
	 * Adds Collection of ADVERSE REACTION GROUP to this message.
	 * @param objSingleCollection - Specified ADVERSE REACTION GROUP Collection.
	 */
	public void addAdverseReactionGroups(ISingleCollection<IGroup> objSingleCollection)
	{
		addGroup(EnumSegments.HL7_GROUP_ADVERSE_REACTION, objSingleCollection);
	}
	/**
	 * Adds  ADVERSE REACTION to this message.
	 * @param objGroup Specified  ADVERSE REACTION .
	 */
	public void addAdverseReactionGroup(IGroup objGroup)
	{
		addGroup(EnumSegments.HL7_GROUP_ADVERSE_REACTION, objGroup);
	}
}