/*******************************************************************************
 *  Copyright 2017 Center 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.baselibs.segments;

import cdac.medinfo.sdk.hl7282.baselibs.CWE;
import cdac.medinfo.sdk.hl7282.baselibs.DTM;
import cdac.medinfo.sdk.hl7282.baselibs.EI;
import cdac.medinfo.sdk.hl7282.baselibs.FN;
import cdac.medinfo.sdk.hl7282.baselibs.HD;
import cdac.medinfo.sdk.hl7282.baselibs.SAD;
import cdac.medinfo.sdk.hl7282.baselibs.SI;
import cdac.medinfo.sdk.hl7282.baselibs.XAD;
import cdac.medinfo.sdk.hl7282.baselibs.XON;
import cdac.medinfo.sdk.hl7282.baselibs.XPN;
import cdac.medinfo.sdk.hl7282.commoninterface.IDataType;
import cdac.medinfo.sdk.hl7282.commoninterface.ISingleCollection;
import cdac.medinfo.sdk.hl7282.exceptions.FieldMissingException;
import cdac.medinfo.sdk.hl7282.exceptions.InvalidSegmentException;
import cdac.medinfo.sdk.hl7282.utils.EnumSegments;
import cdac.medinfo.sdk.hl7282.utils.SingleCollection;

/**
 * PYE - Payee Information Segment
 * <p>Represents an HL7 PYE message segment.
 * This segment has the following fields:</p><p>
 * PYE-1 :  Set ID - PYE   (SI)<b>Required</b><br> 
 * PYE-2 :  Payee Type   (CWE)<b>Required</b><br>  
 * PYE-3 :  Payee Relationship to Invoice (Patient)   (CWE) <b>Conditional</b><br>
 * PYE-4 :  Payee Identification List   (XON)  <b>Conditional</b><br> 
 * PYE-5 :  Payee Person Name   (XPN)   <b>Conditional</b><br>
 * PYE-6 :  Payee Address   (XAD)   <b>Conditional</b><br>
 * PYE-7 :  Payment Method   (CWE)  <b>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.
 * The class has validate method which validates Message against HL7 v 2.8.2 standard.
 * 
 * <p>User can also create Segment through {@link SegmentFactory}  
 */
public class PYE extends Segment{

	/**
	 * Constructs the PYE segment.
	 */
	public PYE()
	{
		super(EnumSegments.HL7_SEG_PYE);
	}
	
	/**
	 * Retrieve Set ID - PYE   (SI)   
	 * This field is about Sequence Number.
	 * @return SI - object of sequence number.
	 */
	public SI getSetID_PYE()
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1939);
		if(objDataCollection != null) 
			return (SI)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Set Set ID - PYE   (SI)   
	 * This field is about Sequence Number.
	 * @param strSetID_Pye - stirng of sequence number.
	 */
	public void setSetID_PYE(String strSetID_Pye)
	{
		SI objSetID_Pye = (SI)getDataElement(1939);
		objSetID_Pye.setValue(strSetID_Pye);
		setSetID_PYE(objSetID_Pye);
	}

	/**
	 * Set Set ID - PYE   (SI)   
	 * This field is about Sequence Number.
	 * @param strSetID_Pye - stirng of sequence number.
	 */
	public void setSetID_PYE(SI obiSetID_Pye)
	{
		setDataType(1939, obiSetID_Pye);
	}
	
	/**
	 * Retrieve Payee Type   (CWE)   
	 * This field is about Type of Payee.
	 * @return CWE - object of Payee Type.
	 */
	public CWE getPayeeType()
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1940);
		if(objDataCollection != null) 
			return (CWE)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Set Payee Type   (CWE)   
	 * This field is about Type of Payee.
	 * @param strIdentifier Specifies of characters (the code) that uniquely identifies the item being referenced. 
	 * @param strText Specifies The descriptive or textual name of the identifier, e.g., myocardial infection. 
	 * @param strNameOfCodingSystem Identifies the coding scheme being used in the identifier component.
	 * @param strAlternateIdentifier Specifies an alternate sequence of characters (the code) that uniquely identifies the item being referenced.
	 * @param strAlternateText Specifies the descriptive or textual name of the alternate identifier. See usage note in section introduction.
	 * @param strNameOfAlternateCodingSystem Identifies the coding scheme being used in the alternate identifier component. 
	 * @param strCodingSystemVersionID A sequence of characters that uniquely identifies a second alternate code.
	 * @param strAlternateCodingSystemVersionId This component carries the version for the coding system identified by components 4-6.
	 * @param strOriginalText The text as seen and/or selected by the user who entered the data.
	 * @param strSecondAlternateIdentifier A sequence of characters that uniquely identifies a second alternate code.
	 * @param strSecondAlternateText The descriptive or textual name of the alternate identifier.
	 * @param strNameofSecondAlternateCodingSystem Identifies the coding scheme being used in the alternate identifier component.
	 * @param strSecondAlternateCodingSystemVersionID This component carries the version for the coding system identified by components 10-12.
	 * @param strCodingSystemOID This component contains the ISO Object Identifier (OID) for the coding system or value set named in CWE.3.
	 * @param strValueSetOID This component contains the ISO Object Identifier (OID) to allow identification of the value set from which the value in CWE.1 is obtained.
	 * @param strValueSetVersionID This component carries the version for the value set identified by CWE.15. The version is a date. The date is the date/time that the value set being used was published.
	 * @param strAlternateCodingSystemOID This component contains the ISO Object Identifier (OID) for the coding system or value set named in CWE.6.
	 * @param strAlternateValueSetOID This component contains the ISO Object Identifier (OID) to allow identification of the value set from which the value in CWE.4 is obtained.
	 * @param strAlternateValueSetVersionID This component carries the version for the value set identified by CWE.18. The version is a date.
	 * @param strSecondAlternateCodingSystemOID This component contains the ISO Object Identifier (OID) for the coding system or value set named in CWE.12.
	 * @param strSecondAlternateValueSetOID This component contains the ISO Object Identifier (OID) to allow identification of the value set from which the value in CWE.10 is obtained.
	 * @param strSecondAlternateValueSetVersionID This component carries the version for the value set identified by CWE.21. The version is a date.
	 */ 
	public void setPayeeType(String strIdentifier,String strText,String strNameOfCodingSystem,String strAlternateIdentifier,String strAlternateText,
			String strNameOfAlternateCodingSystem, String strCodingSystemVersionID, String strAlternateCodingSystemVersionId,String strOriginalText,
			String  strSecondAlternateIdentifier, String strSecondAlternateText,String strNameofSecondAlternateCodingSystem, String strSecondAlternateCodingSystemVersionID,
			String strCodingSystemOID, String strValueSetOID,String strValueSetVersionID, String strAlternateCodingSystemOID, String strAlternateValueSetOID,
			String strAlternateValueSetVersionID,String  strSecondAlternateCodingSystemOID, String strSecondAlternateValueSetOID, String strSecondAlternateValueSetVersionID)
	{
		CWE objPayeeType  = (CWE)getDataElement(1940);
		objPayeeType.setIdentifier(strIdentifier);
		objPayeeType.setText(strText);
		objPayeeType.setNameOfCodingSystem(strNameOfCodingSystem);
		objPayeeType.setAlternateIdentifier(strAlternateIdentifier);
		objPayeeType.setAlternateText(strAlternateText);
		objPayeeType.setNameOfAlternateCodingSystem(strNameOfAlternateCodingSystem); 
		objPayeeType.setCodingSystemVersionID(strCodingSystemVersionID);
		objPayeeType.setAlternateCodingSystemVersionId(strAlternateCodingSystemVersionId);
		objPayeeType.setOriginalText(strOriginalText);
		objPayeeType.setSecondAlternateIdentifier(strSecondAlternateIdentifier);
		objPayeeType.setSecondAlternateText(strSecondAlternateText);
		objPayeeType.setNameofSecondAlternateCodingSystem(strNameofSecondAlternateCodingSystem);
		objPayeeType.setSecondAlternateCodingSystemVersionID(strSecondAlternateCodingSystemVersionID);
		objPayeeType.setCodingSystemOID(strCodingSystemOID);
		objPayeeType.setValueSetOID(strValueSetOID);
		objPayeeType.setValueSetVersionID(strValueSetVersionID);
		objPayeeType.setAlternateCodingSystemOID(strAlternateCodingSystemOID);
		objPayeeType.setAlternateValueSetOID(strAlternateValueSetOID);
		objPayeeType.setAlternateValueSetVersionID(strAlternateValueSetVersionID);
		objPayeeType.setSecondAlternateCodingSystemOID(strSecondAlternateCodingSystemOID);
		objPayeeType.setSecondAlternateValueSetOID(strSecondAlternateValueSetOID);
		objPayeeType.setSecondAlternateValueSetVersionID(strSecondAlternateValueSetVersionID); 
		setPayeeType(objPayeeType);
	}
	
	/**
	 * Set Payee Type   (CWE)   
	 * This field is about Type of Payee.
	 * @param CWE - Object of Payee Type.
	 */ 
	public void setPayeeType(CWE objPayeeType)
	{
		setDataType(1940, objPayeeType);
	}
	
	/**
	 * Retrieve Payee Relationship to Invoice (Patient)   (CWE)   
	 * This field is about Conditional or empty: if Payee Type in list ("PERS", "PPER"), then Required, else Not Permitted.
	* @return CWE - object of Payee Relationship to Invoice .
	 */
	public CWE getPayeeRelationshipToInvoice()
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1941);
		if(objDataCollection != null) 
			return (CWE)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Set Payee Relationship to Invoice (Patient)   (CWE)   
	 * This field is about For Person Payee Types, the relationship to Invoice.
	 * @param strIdentifier Specifies of characters (the code) that uniquely identifies the item being referenced. 
	 * @param strText Specifies The descriptive or textual name of the identifier, e.g., myocardial infection. 
	 * @param strNameOfCodingSystem Identifies the coding scheme being used in the identifier component.
	 * @param strAlternateIdentifier Specifies an alternate sequence of characters (the code) that uniquely identifies the item being referenced.
	 * @param strAlternateText Specifies the descriptive or textual name of the alternate identifier. See usage note in section introduction.
	 * @param strNameOfAlternateCodingSystem Identifies the coding scheme being used in the alternate identifier component. 
	 * @param strCodingSystemVersionID A sequence of characters that uniquely identifies a second alternate code.
	 * @param strAlternateCodingSystemVersionId This component carries the version for the coding system identified by components 4-6.
	 * @param strOriginalText The text as seen and/or selected by the user who entered the data.
	 * @param strSecondAlternateIdentifier A sequence of characters that uniquely identifies a second alternate code.
	 * @param strSecondAlternateText The descriptive or textual name of the alternate identifier.
	 * @param strNameofSecondAlternateCodingSystem Identifies the coding scheme being used in the alternate identifier component.
	 * @param strSecondAlternateCodingSystemVersionID This component carries the version for the coding system identified by components 10-12.
	 * @param strCodingSystemOID This component contains the ISO Object Identifier (OID) for the coding system or value set named in CWE.3.
	 * @param strValueSetOID This component contains the ISO Object Identifier (OID) to allow identification of the value set from which the value in CWE.1 is obtained.
	 * @param strValueSetVersionID This component carries the version for the value set identified by CWE.15. The version is a date. The date is the date/time that the value set being used was published.
	 * @param strAlternateCodingSystemOID This component contains the ISO Object Identifier (OID) for the coding system or value set named in CWE.6.
	 * @param strAlternateValueSetOID This component contains the ISO Object Identifier (OID) to allow identification of the value set from which the value in CWE.4 is obtained.
	 * @param strAlternateValueSetVersionID This component carries the version for the value set identified by CWE.18. The version is a date.
	 * @param strSecondAlternateCodingSystemOID This component contains the ISO Object Identifier (OID) for the coding system or value set named in CWE.12.
	 * @param strSecondAlternateValueSetOID This component contains the ISO Object Identifier (OID) to allow identification of the value set from which the value in CWE.10 is obtained.
	 * @param strSecondAlternateValueSetVersionID This component carries the version for the value set identified by CWE.21. The version is a date.
	 */ 
	public void setPayeeRelationshipToInvoice(String strIdentifier,String strText,String strNameOfCodingSystem,String strAlternateIdentifier,String strAlternateText,
			String strNameOfAlternateCodingSystem, String strCodingSystemVersionID, String strAlternateCodingSystemVersionId,String strOriginalText,
			String  strSecondAlternateIdentifier, String strSecondAlternateText,String strNameofSecondAlternateCodingSystem, String strSecondAlternateCodingSystemVersionID,
			String strCodingSystemOID, String strValueSetOID,String strValueSetVersionID, String strAlternateCodingSystemOID, String strAlternateValueSetOID,
			String strAlternateValueSetVersionID,String  strSecondAlternateCodingSystemOID, String strSecondAlternateValueSetOID, String strSecondAlternateValueSetVersionID)
	{
		CWE objPayeeRelationshipToInvoice  = (CWE)getDataElement(1941);
		objPayeeRelationshipToInvoice.setIdentifier(strIdentifier);
		objPayeeRelationshipToInvoice.setText(strText);
		objPayeeRelationshipToInvoice.setNameOfCodingSystem(strNameOfCodingSystem);
		objPayeeRelationshipToInvoice.setAlternateIdentifier(strAlternateIdentifier);
		objPayeeRelationshipToInvoice.setAlternateText(strAlternateText);
		objPayeeRelationshipToInvoice.setNameOfAlternateCodingSystem(strNameOfAlternateCodingSystem); 
		objPayeeRelationshipToInvoice.setCodingSystemVersionID(strCodingSystemVersionID);
		objPayeeRelationshipToInvoice.setAlternateCodingSystemVersionId(strAlternateCodingSystemVersionId);
		objPayeeRelationshipToInvoice.setOriginalText(strOriginalText);
		objPayeeRelationshipToInvoice.setSecondAlternateIdentifier(strSecondAlternateIdentifier);
		objPayeeRelationshipToInvoice.setSecondAlternateText(strSecondAlternateText);
		objPayeeRelationshipToInvoice.setNameofSecondAlternateCodingSystem(strNameofSecondAlternateCodingSystem);
		objPayeeRelationshipToInvoice.setSecondAlternateCodingSystemVersionID(strSecondAlternateCodingSystemVersionID);
		objPayeeRelationshipToInvoice.setCodingSystemOID(strCodingSystemOID);
		objPayeeRelationshipToInvoice.setValueSetOID(strValueSetOID);
		objPayeeRelationshipToInvoice.setValueSetVersionID(strValueSetVersionID);
		objPayeeRelationshipToInvoice.setAlternateCodingSystemOID(strAlternateCodingSystemOID);
		objPayeeRelationshipToInvoice.setAlternateValueSetOID(strAlternateValueSetOID);
		objPayeeRelationshipToInvoice.setAlternateValueSetVersionID(strAlternateValueSetVersionID);
		objPayeeRelationshipToInvoice.setSecondAlternateCodingSystemOID(strSecondAlternateCodingSystemOID);
		objPayeeRelationshipToInvoice.setSecondAlternateValueSetOID(strSecondAlternateValueSetOID);
		objPayeeRelationshipToInvoice.setSecondAlternateValueSetVersionID(strSecondAlternateValueSetVersionID); 
		setPayeeRelationshipToInvoice(objPayeeRelationshipToInvoice);
	}
	
	/**
	 * Set Payee Relationship to Invoice (Patient)   (CWE)   
	 * This field is about For Person Payee Types, the relationship to Invoice.
	 * @param CWE - Object of Payee Relationship to Invoice (Patient).
	 */ 
	public void setPayeeRelationshipToInvoice(CWE objPayeeRelationshipToInvoice)
	{
		setDataType(1941, objPayeeRelationshipToInvoice);
	}
	
	/**
	 * Retrieve Payee Identification List   (XON)
	 * This field is about Payee or Business Arrangement identification information.
	 * @return ISingleCollection<XON> - List of object of payee identification list.
	 */
	public ISingleCollection<XON> getPayeeIdentificationList()
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1942);
		ISingleCollection<XON> objDataList = new SingleCollection<XON>();
		if(objDataCollection != null && objDataCollection.size() != 0)
		{
			for(IDataType objDataType : objDataCollection)
			{
				XON objXON = (XON)objDataType;
				objDataList.add(objXON);
			}
		}
		return objDataList;
	}
	
	/**
	 * Set Payee Identification List   (XON)
	 * This field is about Payee or Business Arrangement identification information.
	 * @param strOrganizationName Specifies name of the specified organization.
	 * @param strOrganizationNameTypeCode Specifies a code that represents the type of name i.e., legal name, display name.
	 * 										Suggested Values A,L,D,SL.[Refer to table No.0204]  
	 * @param objAssigningAuthority Specifies The assigning authority is a unique identifier of the system 
	 * 									(or organization or agency or department) that creates the data. 
	 * @param strIdentifierTypeCode Specifies a code corresponding to the type of identifier. 
	 * @param objAssigningFacility Specifies The place or location identifier where the identifier was first assigned to the person. 
	 * @param strNameRepresentationCode Specifies representations of the same name/address Suggested values are I,A,P [Refer table 0465] 
	 * @param strOrganizationIdentifier This component contains the sequence of characters (the code) that uniquely 
	 * 									  identifies the item being referenced by XON.1 Organization Name. 
	 * 									  This component replaces XON.3 ID Number as of v 2.8.2.
	 */ 
	public void addPayeeIdentificationList(String strOrganizationName, CWE objOrganizationNameTypeCode,HD objAssigningAuthority,String strIdentifierTypeCode,
			HD objAssigningFacility, String strNameRepresentationCode,String strOrganizationIdentifier)
	{
		XON objPayeeIdentificationList  = (XON)getDataElement(1942);
		objPayeeIdentificationList.setOrganizationName(strOrganizationName);
		objPayeeIdentificationList.setOrganizationNameTypeCode(objOrganizationNameTypeCode);
		objPayeeIdentificationList.setAssigningAuthority(objAssigningAuthority);
		objPayeeIdentificationList.setIdentifierTypeCode(strIdentifierTypeCode);
		objPayeeIdentificationList.setAssigningFacility(objAssigningFacility);
		objPayeeIdentificationList.setNameRepresentationCode(strNameRepresentationCode);
		objPayeeIdentificationList.setOrganizationIdentifier(strOrganizationIdentifier); 
		addPayeeIdentificationList(objPayeeIdentificationList);
	}
	
	/**
	 * Set Payee Identification List   (XON)
	 * This field is about Payee or Business Arrangement identification information.
	 * @param objVATRatesAppliedList - object of payee identification list.
	 */
	public void addPayeeIdentificationList(XON objPayeeIdentificationList)
	{
		setDataType(1942, objPayeeIdentificationList);
	}
	
	/**
	 * Set Payee Identification List   (XON)
	 * This field is about Payee or Business Arrangement identification information.
	 * @param objVATRatesAppliedList - list of object of payee identification list.
	 */
	@SuppressWarnings("unchecked")
	public void setPayeeIdentificationList(ISingleCollection<XON> objPayeeIdentificationList)
	{
		ISingleCollection<IDataType> objCollection = null;
		ISingleCollection<?> objUnknownCollection = (ISingleCollection<?>)objPayeeIdentificationList;
		objCollection = (ISingleCollection<IDataType>)objUnknownCollection;
		setDataType(1942,objCollection);
	}
	
	/**
	 * Retrieve Payee Person Name   (XPN)   
	 * Individual's name; may be a patient's name or other individual.
	 * @return ISingleCollection<XPN> - List of object of payee person name.
	 */
	public ISingleCollection<XPN> getPayeePersonName()
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1943);
		ISingleCollection<XPN> objDataList = new SingleCollection<XPN>();
		if(objDataCollection != null && objDataCollection.size() != 0)
		{
			for(IDataType objDataType : objDataCollection)
			{
				XPN objXPN = (XPN)objDataType;
				objDataList.add(objXPN);
			}
		}
		return objDataList;
	}
	
	/**
	 * Set Payee Person Name   (XPN)   
	 * Individual's name; may be a patient's name or other individual.
	 * @param objFamilyName Specifies the surname of a person. 
	 * @param strGivenName Specifies First name.
	 * @param strSecondAndFurtherGivenNamesOrInitialsThereof Specifies multiple middle names that may be included by separating them with spaces.
	 * @param strSuffix Used to specify a name suffix (e.g., Jr. or III).
	 * @param strPrefix sed to specify a name prefix (e.g., Dr.).
	 * @param strNameTypeCode Specifies a code that represents the type of name. Suggested values are A,B,C,D,I,L,M,N,P,R,S,T,U...[Refer table 0200.]
	 * @param strNameRepresentationCode Specifies representations of the same name/address Suggested values are I,A,P [Refer table 0465] 
	 * @param objNameContext Designates the context in which a name is used. [Refer User-defined Table 0448 ]
	 * @param strNameAssemblyOrder Specifies a code that represents the preferred display order of the components of this person name. Suggested values are G,F[Refer table 0444.]
	 * @param objEffectiveDate Specifies the first date, if known, on which the address is valid and active.
	 * @param objExpirationDate Specifies the last date, if known, on which the address is valid and active.
	 * @param strProfessionalSuffix Used to specify an abbreviation, or a string of abbreviations, denoting qualifications that support the person's profession, (e.g., licenses). 
	 * @param strCalledBy Used to specify the called name.
	 */
	public void addPayeePersonName(FN objFamilyName, String strGivenName, String strSecondAndFurtherGivenNamesOrInitialsThereof, 
			String strSuffix, String strPrefix, String strNameTypeCode, String strNameRepresentationCode, 
			CWE objNameContext, String strNameAssemblyOrder, DTM objEffectiveDate,
			DTM objExpirationDate, String strProfessionalSuffix, String strCalledBy)
	{
		XPN objPayeePersonName = (XPN)getDataElement(1943);
		objPayeePersonName.setFamilyName(objFamilyName);
		objPayeePersonName.setGivenName(strGivenName);
		objPayeePersonName.setSecondNameOrInitials(strSecondAndFurtherGivenNamesOrInitialsThereof);
		objPayeePersonName.setSuffix(strSuffix);
		objPayeePersonName.setPrefix(strPrefix);
		objPayeePersonName.setNameTypeCode(strNameTypeCode);
		objPayeePersonName.setNameRepresentationCode(strNameRepresentationCode);
		objPayeePersonName.setNameContext(objNameContext);
		objPayeePersonName.setNameAssemblyOrder(strNameAssemblyOrder);
		objPayeePersonName.setEffectiveDate(objEffectiveDate);
		objPayeePersonName.setExpirationDate(objExpirationDate);
		objPayeePersonName.setProfessionalSuffix(strProfessionalSuffix); 
		objPayeePersonName.setCalledBy(strCalledBy);
		addPayeePersonName(objPayeePersonName);
	}
	
	/**
	 * Set Payee Person Name   (XPN)   
	 * Individual's name; may be a patient's name or other individual.
	 * @param XPN - object of Payee Person Name.
	 */ 
	public void addPayeePersonName(XPN objPayeePersonName)
	{
		setDataType(1943, objPayeePersonName);
	}
	
	/**
	 * Set Payee Person Name   (XPN)   
	 * Individual's name; may be a patient's name or other individual.
	 * @param XPN - object of Payee Person Name.
	 */ 
	@SuppressWarnings("unchecked")
	public void setPayeePersonName(ISingleCollection<XPN> objPayeePersonName)
	{
		ISingleCollection<IDataType> objCollection = null;
		ISingleCollection<?> objUnknownCollection = (ISingleCollection<?>)objPayeePersonName;
		objCollection = (ISingleCollection<IDataType>)objUnknownCollection;
		setDataType(1943,objCollection);
	}
	
	/**
	 * Retrieve PYE-6   Payee Address   (XAD)    
	 * Address for payee. If not specified, then Payer will use address on file for this Payee, if applicable. If Payee is an individual, then this address can be used to send a check.
	 * @return ISingleCollection<XAD> - List of object of payee Address.
	 */
	public ISingleCollection<XAD> getPayeeAddress()
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1944);
		ISingleCollection<XAD> objDataList = new SingleCollection<XAD>();
		if(objDataCollection != null && objDataCollection.size() != 0)
		{
			for(IDataType objDataType : objDataCollection)
			{
				XAD objXAD = (XAD)objDataType;
				objDataList.add(objXAD);
			}
		}
		return objDataList;
	}
	
	/**
	 * Set Payee Address   (XAD) 
	 * Address for payee. If not specified, then Payer will use address on file for this Payee, if applicable. If Payee is an individual, then this address can be used to send a check.
	 *  @param objStreetAddress Specifies the street address.
	 * @param strOtherDesignation Specifies the Second line of address. 
	 * @param strCity The city, or district or place where the addressee is located. 
	 * @param strStateOrProvince Specifies the state or province where the addressee is located.
	 * @param strZipOrPostalCode Specifies the zip or postal code where the addressee is located. 
	 * @param strCountry Specifies the country where the addressee is located.
	 * @param strAddressType Specifies the kind or type of address.
	 * @param strOtherGeographicDesignation Specifies any other geographic designation. 
	 * @param objCountyParishCode Specifies a code that represents the county in which the specified address resides. 
	 * @param objCensusTract Specifies a code that represents the census tract in which the specified address resides. 
	 * @param strAddressRepresentationCode Specifies representations of the same name/address Suggested values are I,A,P [Refer table 0465]
	 * @param objEffectiveDate It is The first date, if known, on which the address is valid and active.
	 * @param objExpirationDate It is The last date, if known, on which the address is valid and active.
	 * @param objExpirationReason indicates why this address was marked as ended.
	 * @param strTemporaryIndicator indicates whether address is considered temporary .
	 * @param strBadAddressIndicator indicates whether it is possible to contact the owning entity.
	 * @param strAddressUsage indicates how the address is intended to be used.
	 * @param strAddressee indicates the name of the person whose address is intended to be used.
	 * @param strComment indicated descriptive information
	 * @param strPreferenceOrder preference order
	 * @param objProtectionCode indicates that an address need to be protected
	 * @param objAddressIdentifier indicates a unique identifier for address
	 */
	public void addPayeeAddress(SAD objStreetAddress,String strOtherDesignation,String strCity,
			String strStateOrProvince,String strZipOrPostalCode,String strCountry,String strAddressType,
			String strOtherGeographicDesignation,CWE objCountyParishCode,CWE objCensusTract,
			String strAddressRepresentationCode,DTM objEffectiveDate,
			DTM objExpirationDate, CWE objEXpirationReason, String strTemporaryIndicator,
			String strBadAddressIndicator, String strAddressUsage, String strAddressee, String strComment,
			String strPreferenceOrder, CWE objProtectionCode, EI objAddressIdentifier)
	{
		XAD objPayeeAddress = (XAD)getDataElement(1944);
		objPayeeAddress.setStreetAddress(objStreetAddress);
		objPayeeAddress.setOtherDesignation(strOtherDesignation);
		objPayeeAddress.setCity(strCity);
		objPayeeAddress.setStateOrProvince(strStateOrProvince);
		objPayeeAddress.setZipOrPostalCode(strZipOrPostalCode);
		objPayeeAddress.setCountry(strCountry);
		objPayeeAddress.setAddressType(strAddressType);
		objPayeeAddress.setOtherGeographicDesignation(strOtherGeographicDesignation);
		objPayeeAddress.setCountyParishCode(objCountyParishCode);
		objPayeeAddress.setCensusTract(objCensusTract);
		objPayeeAddress.setAddressRepresentationCode(strAddressRepresentationCode);
		objPayeeAddress.setEffectiveDate(objEffectiveDate);
		objPayeeAddress.setExpirationDate(objExpirationDate); 
		objPayeeAddress.setExpirationReason(objEXpirationReason);
		objPayeeAddress.setTemporaryIndicator(strTemporaryIndicator);
		objPayeeAddress.setBadAddressIndicator(strBadAddressIndicator);
		objPayeeAddress.setAddressUsage(strAddressUsage);
		objPayeeAddress.setAddressee(strAddressee);
		objPayeeAddress.setComment(strComment);
		objPayeeAddress.setPreferenceOrder(strPreferenceOrder);
		objPayeeAddress.setProtectionCode(objProtectionCode);
		objPayeeAddress.setAddressIdentifier(objAddressIdentifier);
		addPayeeAddress(objPayeeAddress);
	}
	
	/**
	 * Set PYE-6   Payee Address   (XAD)  
	 * Address for payee. If not specified, then Payer will use address on file for this Payee, if applicable. If Payee is an individual, then this address can be used to send a check.
	 * @param XAD - object of Payee Address.
	 */ 
	public void addPayeeAddress(XAD objPayeeAddress)
	{
		setDataType(1944, objPayeeAddress);
	}
	
	/**
	 * Set PYE-6   Payee Address   (XAD) 
	 * Address for payee. If not specified, then Payer will use address on file for this Payee, if applicable. If Payee is an individual, then this address can be used to send a check.
	 * @param XAD - object of Payee Address.
	 */ 
	@SuppressWarnings("unchecked")
	public void setPayeeAddress(ISingleCollection<XAD> objPayeeAddress)
	{
		ISingleCollection<IDataType> objCollection = null;
		ISingleCollection<?> objUnknownCollection = (ISingleCollection<?>)objPayeeAddress;
		objCollection = (ISingleCollection<IDataType>)objUnknownCollection;
		setDataType(1944,objCollection);
	}
	
	/**
	 * Retrieve Payment Method   (CWE)   
	 * For Payee organizations that have more than one payment method.
	* @return CWE - object of Payment Method.
	 */
	public CWE getPaymentMethod()
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1945);
		if(objDataCollection != null) 
			return (CWE)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Set Payment Method   (CWE)   
	 * This field is about For Payee organizations that have more than one payment method.
	 * @param strIdentifier Specifies of characters (the code) that uniquely identifies the item being referenced. 
	 * @param strText Specifies The descriptive or textual name of the identifier, e.g., myocardial infection. 
	 * @param strNameOfCodingSystem Identifies the coding scheme being used in the identifier component.
	 * @param strAlternateIdentifier Specifies an alternate sequence of characters (the code) that uniquely identifies the item being referenced.
	 * @param strAlternateText Specifies the descriptive or textual name of the alternate identifier. See usage note in section introduction.
	 * @param strNameOfAlternateCodingSystem Identifies the coding scheme being used in the alternate identifier component. 
	 * @param strCodingSystemVersionID A sequence of characters that uniquely identifies a second alternate code.
	 * @param strAlternateCodingSystemVersionId This component carries the version for the coding system identified by components 4-6.
	 * @param strOriginalText The text as seen and/or selected by the user who entered the data.
	 * @param strSecondAlternateIdentifier A sequence of characters that uniquely identifies a second alternate code.
	 * @param strSecondAlternateText The descriptive or textual name of the alternate identifier.
	 * @param strNameofSecondAlternateCodingSystem Identifies the coding scheme being used in the alternate identifier component.
	 * @param strSecondAlternateCodingSystemVersionID This component carries the version for the coding system identified by components 10-12.
	 * @param strCodingSystemOID This component contains the ISO Object Identifier (OID) for the coding system or value set named in CWE.3.
	 * @param strValueSetOID This component contains the ISO Object Identifier (OID) to allow identification of the value set from which the value in CWE.1 is obtained.
	 * @param strValueSetVersionID This component carries the version for the value set identified by CWE.15. The version is a date. The date is the date/time that the value set being used was published.
	 * @param strAlternateCodingSystemOID This component contains the ISO Object Identifier (OID) for the coding system or value set named in CWE.6.
	 * @param strAlternateValueSetOID This component contains the ISO Object Identifier (OID) to allow identification of the value set from which the value in CWE.4 is obtained.
	 * @param strAlternateValueSetVersionID This component carries the version for the value set identified by CWE.18. The version is a date.
	 * @param strSecondAlternateCodingSystemOID This component contains the ISO Object Identifier (OID) for the coding system or value set named in CWE.12.
	 * @param strSecondAlternateValueSetOID This component contains the ISO Object Identifier (OID) to allow identification of the value set from which the value in CWE.10 is obtained.
	 * @param strSecondAlternateValueSetVersionID This component carries the version for the value set identified by CWE.21. The version is a date.
	 */ 
	public void setPaymentMethod(String strIdentifier,String strText,String strNameOfCodingSystem,String strAlternateIdentifier,String strAlternateText,
			String strNameOfAlternateCodingSystem, String strCodingSystemVersionID, String strAlternateCodingSystemVersionId,String strOriginalText,
			String  strSecondAlternateIdentifier, String strSecondAlternateText,String strNameofSecondAlternateCodingSystem, String strSecondAlternateCodingSystemVersionID,
			String strCodingSystemOID, String strValueSetOID,String strValueSetVersionID, String strAlternateCodingSystemOID, String strAlternateValueSetOID,
			String strAlternateValueSetVersionID,String  strSecondAlternateCodingSystemOID, String strSecondAlternateValueSetOID, String strSecondAlternateValueSetVersionID)
	{
		CWE objPaymentMethod  = (CWE)getDataElement(1945);
		objPaymentMethod.setIdentifier(strIdentifier);
		objPaymentMethod.setText(strText);
		objPaymentMethod.setNameOfCodingSystem(strNameOfCodingSystem);
		objPaymentMethod.setAlternateIdentifier(strAlternateIdentifier);
		objPaymentMethod.setAlternateText(strAlternateText);
		objPaymentMethod.setNameOfAlternateCodingSystem(strNameOfAlternateCodingSystem); 
		objPaymentMethod.setCodingSystemVersionID(strCodingSystemVersionID);
		objPaymentMethod.setAlternateCodingSystemVersionId(strAlternateCodingSystemVersionId);
		objPaymentMethod.setOriginalText(strOriginalText);
		objPaymentMethod.setSecondAlternateIdentifier(strSecondAlternateIdentifier);
		objPaymentMethod.setSecondAlternateText(strSecondAlternateText);
		objPaymentMethod.setNameofSecondAlternateCodingSystem(strNameofSecondAlternateCodingSystem);
		objPaymentMethod.setSecondAlternateCodingSystemVersionID(strSecondAlternateCodingSystemVersionID);
		objPaymentMethod.setCodingSystemOID(strCodingSystemOID);
		objPaymentMethod.setValueSetOID(strValueSetOID);
		objPaymentMethod.setValueSetVersionID(strValueSetVersionID);
		objPaymentMethod.setAlternateCodingSystemOID(strAlternateCodingSystemOID);
		objPaymentMethod.setAlternateValueSetOID(strAlternateValueSetOID);
		objPaymentMethod.setAlternateValueSetVersionID(strAlternateValueSetVersionID);
		objPaymentMethod.setSecondAlternateCodingSystemOID(strSecondAlternateCodingSystemOID);
		objPaymentMethod.setSecondAlternateValueSetOID(strSecondAlternateValueSetOID);
		objPaymentMethod.setSecondAlternateValueSetVersionID(strSecondAlternateValueSetVersionID); 
		setPaymentMethod(objPaymentMethod);
	}
	
	/**
	 * Set Payment Method   (CWE)
	 * This field is about For Payee organizations that have more than one payment method.
	 * @param CWE - Object of Payment Method.
	 */ 
	public void setPaymentMethod(CWE objPaymentMethod)
	{
		setDataType(1945, objPaymentMethod);
	}
	
	/**
	 * Validates HL7 Message objects .
	 * Validate method checks for validation each and every segments in side the Message object against specified message Structure. 
	 * Validation checks include optionality of segment or group.
	 * It also verifies the number of times segment or group is repeated in message.
	 * e.g 
	 * {PYE} while parsing PYE segment validate method will check for its mandatory presence.
	 * [PYE] in this case validate will throw exception if one tries to enter more than one PYE   segment.
	 * @return boolean - true or false.
	 * @throws InvalidSegmentException Throws when Segment Validation fails.
	 */
	public boolean validate() throws InvalidSegmentException
	{
		try
		{
			super.validate();
			return true;
		}
		catch(FieldMissingException ex)
		{
			throw new InvalidSegmentException(enumSegments.getValue(),ex);
		}
	}
}
