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

import cdac.medinfo.sdk.hl7282.baselibs.messages.Message;
import cdac.medinfo.sdk.hl7282.baselibs.segments.ARV;
import cdac.medinfo.sdk.hl7282.baselibs.segments.GT1;
import cdac.medinfo.sdk.hl7282.baselibs.segments.NK1;
import cdac.medinfo.sdk.hl7282.baselibs.segments.PD1;
import cdac.medinfo.sdk.hl7282.baselibs.segments.PID;
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;

/**
 * VXU_V04 - Unsolicited Vaccination Record Update (Event V04).
 * This event is use for Unsolicited Vaccination Update. When a provider wishes to update the
 * patient's vaccination record being held in a registry, he will transmit an unsolicited update of the record.
 * <p>Represents a VXU_V04 message structure (see chapter 4A.7.6 ) 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: PID (Patient Identification Segment) <b>SINGLE_COMPULSARY</b><br>
 * 4: PD1 (Patient Additional Demographic Segment) <b>SINGLE_OPTIONAL</b><br>
 * 5: NK1 (Next of Kin / Associated Parties Segment) <b>MULTIPLE_OPTIONAL</b><br>
 * 6. ARV (Access Restrictions) <b>MULTIPLE_OPTIONAL</b><br/>
 * 7: PATIENT (a Group in VXU_V04 message ) <b>SINGLE_OPTIONAL</b><br>
 * 8: GT1 (Guarantor Segment) <b>MULTIPLE_OPTIONAL</b><br>
 * 9: INSURANCE (a Group in VXU_V04 message) <b>MULTIPLE_OPTIONAL</b><br>
 * 10: PERSON OBSERVATION (a Group in VXU_V04 message) <b>MULTIPLE_OPTIONAL</b><br>
 * 11: ORDER (a Group in VXU_V04 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.
 *
 * <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>VXU_V04 objV04 = (VXU_V04)MessageFactory.createInstance().createSendSupportedMessage("VXU", "V04");</p>
 */
public final class VXU_V04 extends Message 
{
	/**
	 * Constructs the VXU_V04 message.
	 */
	VXU_V04(IMap objMessageMap)
	{
		super(objMessageMap, EnumMessageCode.VXU.getValue(), EnumTriggerEvent.V04.getValue(), EnumMessageStructure.VXU_V04.getValue());
	}

	/**
	 * 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 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 Additinal Demographics segment(PD1) present in this message.
	 * @return PD1 - the Additinal Demographics(PD1) Segment. present in this message or null if unavailable.
	 */
	public PD1 getAdditinalDemographicsSegment()
	{
		ISingleCollection<ISegment> objSingleCollection = getSegment(EnumSegments.HL7_SEG_PD1);
		if(objSingleCollection != null)
			return (PD1)objSingleCollection.elementAt(0);
		return null;
	}

	/**
	 * Sets value of Additinal Demographics segment(PD1) for this message,overwrites if already present.
	 * @param objPD1 Specified Additinal Demographics(PD1) Segment. 
	 */
	public void setAdditinalDemographicsSegment(PD1 objPD1)
	{
		setSegment(EnumSegments.HL7_SEG_PD1,objPD1);
	}

	/**
	 * Adds Next of Kin/ Associated Parties (NK1 ) to this message.
	 * @param objNK1 Specified Next of Kin/ Associated Parties(NK1) 
	 */
	public void addNextOfKinOrAssociatedPartiesSegment(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 addNextOfKinOrAssociatedPartiesSegments(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> getNextOfKinOrAssociatedPartiesSegments()
	{
		ISingleCollection<?> objSegmentCollection = getSegment(EnumSegments.HL7_SEG_NK1);
		return (ISingleCollection<NK1>)objSegmentCollection;
	}

	/**
	 * 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, 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, (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);
		return (ISingleCollection<ARV>)objSegmentCollection;
	}


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

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

	/**
	 * 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 Collection of Person Observation GROUP present in this message.
	 * @return ISingleCollection<Group> - Collection of Person Observation Group present 
	 */
	public ISingleCollection<IGroup> getPersonObservationGroups()
	{
		return getGroup(EnumSegments.HL7_GROUP_PERSON_OBSERVATION);
	}

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

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

	/**
	 * Retrieves Collection of ORDER GROUP present in this message.
	 * @return ISingleCollection<Group> - Collection of ORDER  Group present in this Message.
	 */
	public ISingleCollection<IGroup> getOrderGroups()
	{
		return getGroup(EnumSegments.HL7_GROUP_ORDER );
	}

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

	/**
	 * Adds ORDER GROUP to this message.
	 * @param objGroup Specified ORDER GROUP. 
	 */
	public void addOrderGroup(IGroup objGroup)
	{
		addGroup(EnumSegments.HL7_GROUP_ORDER , objGroup);
	}
}