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

import cdac.medinfo.sdk.hl7282.baselibs.CP;
import cdac.medinfo.sdk.hl7282.baselibs.CQ;
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.HD;
import cdac.medinfo.sdk.hl7282.baselibs.MO;
import cdac.medinfo.sdk.hl7282.baselibs.NM;
import cdac.medinfo.sdk.hl7282.baselibs.SI;
import cdac.medinfo.sdk.hl7282.baselibs.ST;
import cdac.medinfo.sdk.hl7282.baselibs.XON;
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;

/**
 * ADJ - Adjustment
 * This segment describes Provider and/or Payer adjustments to a Product/Service Line Item or Response Summary.
 * <p>Represents an HL7 ADJ message segment.
 * This segment has the following fields:</p><p>
 * ADJ-1   Provider Adjustment Number    (EI)<b>Required</b><br>
 * ADJ-2   Payer Adjustment Number    (EI)<b>Required</b><br>
 * ADJ-3   Adjustment Sequence Number    (SI)<b>Required</b><br>
 * ADJ-4   Adjustment Category    (CWE)<b>Required</b><br>
 * ADJ-5   Adjustment Amount    (CP)<b>Optional</b><br>
 * ADJ-6   Adjustment Quantity   (CQ)<b>Optional</b><br>
 * ADJ-7   Adjustment Reason PA   (CWE)<b>Conditional</b><br>
 * ADJ-8   Adjustment Description    (ST)<b>Optional</b><br>
 * ADJ-9   Original Value    (NM)<b>Optional</b><br>
 * ADJ-10   Substitute Value    (NM)<b>Optional</b><br>
 * ADJ-11   Adjustment Action    (CWE)<b>Optional</b><br>
 * ADJ-12   Provider Adjustment Number Cross Reference   (EI)<b>Optional</b><br>
 * ADJ-13   Provider Product/Service Line Item Number Cross Reference   (EI)<b>Optional</b><br>
 * ADJ-14   Adjustment Date   (DTM)<b>Required</b><br>
 * ADJ-15   Responsible Organization   (XON)<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 ADJ extends Segment{

	/**
	 * Constructs the ADJ segment.
	 */
	public ADJ()
	{
		super(EnumSegments.HL7_SEG_ADJ);
	}
	
	/**
	 * Retrieve Provider Adjustment Number (EI) 
	 * This field is Unique Adjustment Number assigned by the Provider Application.
	 * @return EI - object of Provider Adjustment Number.
	 */
	public EI getProviderAdjustmentNumber()
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(2003);
		if(objDataCollection != null) 
			return (EI)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Set  Retrieve Provider Adjustment Number (EI) 
	 * This field is Unique Adjustment Number assigned by the Provider Application.
	 * @param strEntityIdentifier - string of character use to identify the entity.
	 * @param strNamespaceID - Use to identify the name space id..
	 * @param strUniversalID - Use to identify the name space identity.
	 * @param strUniversalIDType - String of characters describe Universal Id Type. 
	 */ 
	public void setProviderAdjustmentNumber(String strEntityIdentifier,String strNamespaceID,String strUniversalID,String strUniversalIDType)
	{
		EI objProviderAdjustmentNumber = (EI)getDataElement(2003);
		objProviderAdjustmentNumber.setEntityIdentifier(strEntityIdentifier);
		objProviderAdjustmentNumber.setNamespaceId(strNamespaceID);
		objProviderAdjustmentNumber.setUniversalId(strUniversalID);
		objProviderAdjustmentNumber.setUniversalIdType(strUniversalIDType);
		setProviderAdjustmentNumber(objProviderAdjustmentNumber);
	}
	
	/**
	 * Set  Retrieve Provider Adjustment Number (EI) 
	 * This field is Unique Adjustment Number assigned by the Provider Application.
	 * @param EI - object of Provider Adjustment Number.
	 */ 
	public void setProviderAdjustmentNumber(EI objProviderAdjustmentNumber)
	{
		setDataType(2003, objProviderAdjustmentNumber);
	}
	
	/**
	 * Retrieve Payer Adjustment Number (EI) 
	 * This field is Unique Adjustment Number assigned by the Payer Application.
	 * @return EI - object of Payer Adjustment Number.
	 */
	public EI getPayerAdjustmentNumber()
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(2004);
		if(objDataCollection != null) 
			return (EI)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Set  Retrieve Payer Adjustment Number (EI) 
	 * This field is Unique Adjustment Number assigned by the Payer Application.
	 * @param strEntityIdentifier - string of character use to identify the entity.
	 * @param strNamespaceID - Use to identify the name space id..
	 * @param strUniversalID - Use to identify the name space identity.
	 * @param strUniversalIDType - String of characters describe Universal Id Type. 
	 */ 
	public void setPayerAdjustmentNumber(String strEntityIdentifier,String strNamespaceID,String strUniversalID,String strUniversalIDType)
	{
		EI objPayerAdjustmentNumber = (EI)getDataElement(2004);
		objPayerAdjustmentNumber.setEntityIdentifier(strEntityIdentifier);
		objPayerAdjustmentNumber.setNamespaceId(strNamespaceID);
		objPayerAdjustmentNumber.setUniversalId(strUniversalID);
		objPayerAdjustmentNumber.setUniversalIdType(strUniversalIDType);
		setPayerAdjustmentNumber(objPayerAdjustmentNumber);
	}
	
	/**
	 * Set  Retrieve Payer Adjustment Number (EI) 
	 * This field is Unique Adjustment Number assigned by the Payer Application.
	 * @param EI - object of Payer Adjustment Number.
	 */ 
	public void setPayerAdjustmentNumber(EI objPayerAdjustmentNumber)
	{
		setDataType(2004, objPayerAdjustmentNumber);
	}
	
	/**
	 * Retrieve Adjustment Sequence Number (SI) 
	 * Unique sequence number for this adjustment – starts with 1, then 2, etc., for each unique adjustment for the Product/Service Line Item.
	 * @return SI - object of Adjustment Sequence Number.
	 */
	public SI getAdjustmentSequenceNumber()
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(2005);
		if(objDataCollection != null) 
			return (SI)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Set  Retrieve Adjustment Sequence Number (SI) 
	 * Unique sequence number for this adjustment – starts with 1, then 2, etc., for each unique adjustment for the Product/Service Line Item.
	 * @param strAdjustmentSequenceNumber - string of Adjustment Sequence Number
	 */ 
	public void setAdjustmentSequenceNumber(String strAdjustmentSequenceNumber)
	{
		SI objAdjustmentSequenceNumber = (SI)getDataElement(2005);
		objAdjustmentSequenceNumber.setValue(strAdjustmentSequenceNumber);
		setAdjustmentSequenceNumber(objAdjustmentSequenceNumber);
	}
	
	/**
	 * Set  Retrieve Adjustment Sequence Number (SI) 
	 * Unique sequence number for this adjustment – starts with 1, then 2, etc., for each unique adjustment for the Product/Service Line Item.
	 * @param SI - object of Adjustment Sequence Number.
	 */ 
	public void setAdjustmentSequenceNumber(SI objAdjustmentSequenceNumber)
	{
		setDataType(2005, objAdjustmentSequenceNumber);
	}
	
	/**
	 * Retrieve Adjustment Category   (CWE)   
	 * This field is about Indicates the category of adjustment and is used to assist in determining which table is used for Adjustment Reason.  
	 * @return CWE - object of Adjustment Category.
	 */
	public CWE getAdjustmentCategory()
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(2006);
		if(objDataCollection != null) 
			return (CWE)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Set Adjustment Category   (CWE)   
	 * This field is about Indicates the category of adjustment and is used to assist in determining which table is used for Adjustment Reason.  
	 * @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 setAdjustmentCategory(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 objAdjustmentCategory  = (CWE)getDataElement(2006);
		objAdjustmentCategory.setIdentifier(strIdentifier);
		objAdjustmentCategory.setText(strText);
		objAdjustmentCategory.setNameOfCodingSystem(strNameOfCodingSystem);
		objAdjustmentCategory.setAlternateIdentifier(strAlternateIdentifier);
		objAdjustmentCategory.setAlternateText(strAlternateText);
		objAdjustmentCategory.setNameOfAlternateCodingSystem(strNameOfAlternateCodingSystem); 
		objAdjustmentCategory.setCodingSystemVersionID(strCodingSystemVersionID);
		objAdjustmentCategory.setAlternateCodingSystemVersionId(strAlternateCodingSystemVersionId);
		objAdjustmentCategory.setOriginalText(strOriginalText);
		objAdjustmentCategory.setSecondAlternateIdentifier(strSecondAlternateIdentifier);
		objAdjustmentCategory.setSecondAlternateText(strSecondAlternateText);
		objAdjustmentCategory.setNameofSecondAlternateCodingSystem(strNameofSecondAlternateCodingSystem);
		objAdjustmentCategory.setSecondAlternateCodingSystemVersionID(strSecondAlternateCodingSystemVersionID);
		objAdjustmentCategory.setCodingSystemOID(strCodingSystemOID);
		objAdjustmentCategory.setValueSetOID(strValueSetOID);
		objAdjustmentCategory.setValueSetVersionID(strValueSetVersionID);
		objAdjustmentCategory.setAlternateCodingSystemOID(strAlternateCodingSystemOID);
		objAdjustmentCategory.setAlternateValueSetOID(strAlternateValueSetOID);
		objAdjustmentCategory.setAlternateValueSetVersionID(strAlternateValueSetVersionID);
		objAdjustmentCategory.setSecondAlternateCodingSystemOID(strSecondAlternateCodingSystemOID);
		objAdjustmentCategory.setSecondAlternateValueSetOID(strSecondAlternateValueSetOID);
		objAdjustmentCategory.setSecondAlternateValueSetVersionID(strSecondAlternateValueSetVersionID); 
		setAdjustmentCategory(objAdjustmentCategory);
	}
	
	/**
	 * Set Adjustment Category   (CWE)   
	 * This field is about Indicates the category of adjustment and is used to assist in determining which table is used for Adjustment Reason.  
	 * @param objAdjustmentCategory - object of Adjustment Category.
	 */
	public void setAdjustmentCategory(CWE objAdjustmentCategory)
	{
		setDataType(2006, objAdjustmentCategory);
	}
	
	/**
	 * Retrieve Adjustment Amount    (CP)
	 * This field is about Adjustment amount, such as taxes, deductibles, previously paid amount.
	 * @return ISingleCollection<CP> - list of object of Adjustment Amount.
	 */
	public ISingleCollection<CP> getAdjustmentAmount()
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(2007);
		ISingleCollection<CP> objDataList = new SingleCollection<CP>();
		if(objDataCollection != null && objDataCollection.size() != 0)
		{
			for(IDataType objDataType : objDataCollection)
			{
				CP objCP = (CP)objDataType;
				objDataList.add(objCP);
			}
		}
		return objDataList;
	}
	
	/**
	 * Set Adjustment Amount    (CP)
	 * This field is about Adjustment amount, such as taxes, deductibles, previously paid amount.
	 * @param objPrice - Gives information about the Price.
	 * @param strPriceType - Gives information about Type of Price.
	 * @param strFormValue - Gives information about Form Value.
	 * @param strToValue - Tell about the To value.
	 * @param objRangeUnits - Specifies about the range of the units.
	 * @param strRangeType - Specifies obut the Type of range.
	 */
	public void addAdjustmentAmount(MO objPrice,String strPriceType,String strFormValue,String strToValue,CWE objRangeUnits,String strRangeType)
	{
		CP objAdjustmentAmount = (CP)getDataElement(2007);
		objAdjustmentAmount.setPrice(objPrice);
		objAdjustmentAmount.setPriceType(strPriceType);
		objAdjustmentAmount.setFromValue(strFormValue);
		objAdjustmentAmount.setToValue(strToValue);
		objAdjustmentAmount.setRangeType(strRangeType);
		objAdjustmentAmount.setRangeUnits(objRangeUnits);
		addAdjustmentAmount(objAdjustmentAmount);
	}
	
	/**
	 * Set Adjustment Amount    (CP)
	 * This field is about Adjustment amount, such as taxes, deductibles, previously paid amount.
	 * @param objAdjustmentAmount - object of Adjustment Amount.
	 */ 
	public void addAdjustmentAmount(CP objAdjustmentAmount)
	{
		setDataType(2007, objAdjustmentAmount);
	}
	
	/**
	 * Set Adjustment Amount    (CP)
	 * This field is about Adjustment amount, such as taxes, deductibles, previously paid amount.
	 * @param objAdjustmentAmount - list of object of Adjustment Amount.
	 */ 
	@SuppressWarnings("unchecked")
	public void setAdjustmentAmount(ISingleCollection<CP> objAdjustmentAmount)
	{
		ISingleCollection<IDataType> objCollection = null;
		ISingleCollection<?> objUnknownCollection = (ISingleCollection<?>)objAdjustmentAmount;
		objCollection = (ISingleCollection<IDataType>)objUnknownCollection;
		setDataType(2007,objCollection);
	}
	
	/**
	 * Retrieve Adjustment Quantity   (CQ)   
	 * This field is Adjustment Quantity. 
	 * @return CQ - object of Adjustment Quantity.
	 */
	public CQ getAdjustmentQuantity()
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(2008);
		if(objDataCollection != null) 
			return (CQ)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Set Adjustment Quantity   (CQ)   
	 * This field is Adjustment Quantity. 
	 * @param strQuantity - This component specifies the numeric quantity or amount of an entity.
	 * @param objUnits - This component species the units in which the quantity is expressed.  
	 */
	public void setAdjustmentQuantity(String strQuantity,CWE objUnits)
	{
		CQ objAdjustmentQuantity = (CQ)getDataElement(2008);
		objAdjustmentQuantity.setQuantity(strQuantity);
		objAdjustmentQuantity.setUnits(objUnits);
		setAdjustmentQuantity(objAdjustmentQuantity);
	}
	/**
	 * Set Adjustment Quantity   (CQ)   
	 * This field is Adjustment Quantity. 
	 * @param objAdjustmentQuantity - object of Adjustment Quantity.
	 */
	public void setAdjustmentQuantity(CQ objAdjustmentQuantity)
	{
		setDataType(2008, objAdjustmentQuantity);
	}
	
	/**
	 * Retrieve Adjustment Reason PA    (CWE)   
	 * This field is about Reason for this adjustment. Codes used to explain a Provider adjustment to a Product/Service Group or Product/Service Line Item by a Provider.   
	 * @return ISingleCollection<CWE> - list of object of Adjustment Reason PA .
	 */
	public ISingleCollection<CWE> getAdjustmentReasonPA ()
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(2009);
		ISingleCollection<CWE> objDataList = new SingleCollection<CWE>();
		if(objDataCollection != null && objDataCollection.size() != 0)
		{
			for(IDataType objDataType : objDataCollection)
			{
				CWE objCWE = (CWE)objDataType;
				objDataList.add(objCWE);
			}
		}
		return objDataList;
	}
	
	/**
	 * Set Adjustment Reason PA    (CWE)   
	 * This field is about Reason for this adjustment. Codes used to explain a Provider adjustment to a Product/Service Group or Product/Service Line Item by a Provider.   
	 * @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 addAdjustmentReasonPA (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 objAdjustmentReasonPA   = (CWE)getDataElement(2009);
		objAdjustmentReasonPA .setIdentifier(strIdentifier);
		objAdjustmentReasonPA .setText(strText);
		objAdjustmentReasonPA .setNameOfCodingSystem(strNameOfCodingSystem);
		objAdjustmentReasonPA .setAlternateIdentifier(strAlternateIdentifier);
		objAdjustmentReasonPA .setAlternateText(strAlternateText);
		objAdjustmentReasonPA .setNameOfAlternateCodingSystem(strNameOfAlternateCodingSystem); 
		objAdjustmentReasonPA .setCodingSystemVersionID(strCodingSystemVersionID);
		objAdjustmentReasonPA .setAlternateCodingSystemVersionId(strAlternateCodingSystemVersionId);
		objAdjustmentReasonPA .setOriginalText(strOriginalText);
		objAdjustmentReasonPA .setSecondAlternateIdentifier(strSecondAlternateIdentifier);
		objAdjustmentReasonPA .setSecondAlternateText(strSecondAlternateText);
		objAdjustmentReasonPA .setNameofSecondAlternateCodingSystem(strNameofSecondAlternateCodingSystem);
		objAdjustmentReasonPA .setSecondAlternateCodingSystemVersionID(strSecondAlternateCodingSystemVersionID);
		objAdjustmentReasonPA .setCodingSystemOID(strCodingSystemOID);
		objAdjustmentReasonPA .setValueSetOID(strValueSetOID);
		objAdjustmentReasonPA .setValueSetVersionID(strValueSetVersionID);
		objAdjustmentReasonPA .setAlternateCodingSystemOID(strAlternateCodingSystemOID);
		objAdjustmentReasonPA .setAlternateValueSetOID(strAlternateValueSetOID);
		objAdjustmentReasonPA .setAlternateValueSetVersionID(strAlternateValueSetVersionID);
		objAdjustmentReasonPA .setSecondAlternateCodingSystemOID(strSecondAlternateCodingSystemOID);
		objAdjustmentReasonPA .setSecondAlternateValueSetOID(strSecondAlternateValueSetOID);
		objAdjustmentReasonPA .setSecondAlternateValueSetVersionID(strSecondAlternateValueSetVersionID); 
		addAdjustmentReasonPA (objAdjustmentReasonPA );
	}
	
	/**
	 * Set Adjustment Reason PA    (CWE)   
	 * This field is about Reason for this adjustment. Codes used to explain a Provider adjustment to a Product/Service Group or Product/Service Line Item by a Provider.   
	 * @param objAdjustmentReasonPA  - object of Adjustment Reason PA .
	 */
	public void addAdjustmentReasonPA (CWE objAdjustmentReasonPA )
	{
		setDataType(2009, objAdjustmentReasonPA );
	}
	
	/**
	 * Set Adjustment Reason PA    (CWE)   
	 * This field is about Reason for this adjustment. Codes used to explain a Provider adjustment to a Product/Service Group or Product/Service Line Item by a Provider.   
	 * @param objAdjustmentReasonPA  - list of object of Adjustment Reason PA .
	 */
	@SuppressWarnings("unchecked")
	public void setAdjustmentReasonPA (ISingleCollection<CWE> objAdjustmentReasonPA )
	{
		ISingleCollection<IDataType> objCollection = null;
		ISingleCollection<?> objUnknownCollection = (ISingleCollection<?>)objAdjustmentReasonPA;
		objCollection = (ISingleCollection<IDataType>)objUnknownCollection;
		setDataType(2009,objCollection);
	}
	
	/**
	 * Retrieve Adjustment Description (ST)
	 * This field is about Description of adjustment, such as client instructions.
	 * @return ST - object of Adjustment Description.
	 */
	public ST getAdjustmentDescription()
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(2010);
		if(objDataCollection != null) 
			return (ST)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Retrieve Adjustment Description (ST)
	 * This field is about Description of adjustment, such as client instructions.
	 * @param strAdjustmentDescription - object of Adjustment Description.
	 */
	public void setAdjustmentDescription(String strAdjustmentDescription)
	{
		ST objAdjustmentDescription = (ST)getDataElement(2010);
		objAdjustmentDescription.setValue(strAdjustmentDescription);
		setAdjustmentDescription(objAdjustmentDescription);
	}
	
	/**
	 * Retrieve Adjustment Description (ST)
	 * This field is about Description of adjustment, such as client instructions.
	 * @param objAdjustmentDescription - object of Adjustment Description.
	 */
	public void setAdjustmentDescription(ST objAdjustmentDescription)
	{
		setDataType(2010, objAdjustmentDescription);
	}
	
	/**
	 * Retrieve Original Value  (NM)   
	 * This field is about Original value of data item noted in this adjustment.
	 * @return NM - object of Original Value.
	 */
	public NM getOriginalValue()
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(2011);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (NM)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Set Original Value  (NM)
	 * This field is about Original value of data item noted in this adjustment.
	 * @param strOriginalValue - string of Original Value.
	 */
	public void setOriginalValue(String strOriginalValue)
	{
		NM objOriginalValue = (NM)getDataElement(2011);
		objOriginalValue.setValue(strOriginalValue);
		setOriginalValue(objOriginalValue);
	}
	
	/**
	 * Set Original Value  (NM) 
	 * This field is about Original value of data item noted in this adjustment.
	 * @param objOriginalValue - object of Original Value.
	 */
	public void setOriginalValue(NM objOriginalValue)
	{
		setDataType(2011, objOriginalValue);
	}
	
	/**
	 * Retrieve Substitute Value  (NM)   
	 * This field is about Substitute value of data item noted in this adjustment.
	 * @return NM - object of Substitute Value.
	 */
	public NM getSubstituteValue()
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(2012);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (NM)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Set Substitute Value  (NM)
	 * This field is about Substitute value of data item noted in this adjustment.
	 * @param strSubstituteValue - string of Substitute Value.
	 */
	public void setSubstituteValue(String strSubstituteValue)
	{
		NM objSubstituteValue = (NM)getDataElement(2012);
		objSubstituteValue.setValue(strSubstituteValue);
		setSubstituteValue(objSubstituteValue);
	}
	
	/**
	 * Set Substitute Value  (NM) 
	 * This field is about Substitute value of data item noted in this adjustment.
	 * @param objSubstituteValue - object of Substitute Value.
	 */
	public void setSubstituteValue(NM objSubstituteValue)
	{
		setDataType(2012, objSubstituteValue);
	}
	
	/**
	 * Retrieve Adjustment Action   (CWE)   
	 * This field is about Action requested of party that receives this adjustment.      
	 * @return CWE - object of Adjustment Action.
	 */
	public CWE getAdjustmentAction()
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(2013);
		if(objDataCollection != null) 
			return (CWE)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Set Adjustment Action   (CWE)   
	 * This field is about Action requested of party that receives this adjustment.   
	 * @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 setAdjustmentAction(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 objAdjustmentAction  = (CWE)getDataElement(2013);
		objAdjustmentAction.setIdentifier(strIdentifier);
		objAdjustmentAction.setText(strText);
		objAdjustmentAction.setNameOfCodingSystem(strNameOfCodingSystem);
		objAdjustmentAction.setAlternateIdentifier(strAlternateIdentifier);
		objAdjustmentAction.setAlternateText(strAlternateText);
		objAdjustmentAction.setNameOfAlternateCodingSystem(strNameOfAlternateCodingSystem); 
		objAdjustmentAction.setCodingSystemVersionID(strCodingSystemVersionID);
		objAdjustmentAction.setAlternateCodingSystemVersionId(strAlternateCodingSystemVersionId);
		objAdjustmentAction.setOriginalText(strOriginalText);
		objAdjustmentAction.setSecondAlternateIdentifier(strSecondAlternateIdentifier);
		objAdjustmentAction.setSecondAlternateText(strSecondAlternateText);
		objAdjustmentAction.setNameofSecondAlternateCodingSystem(strNameofSecondAlternateCodingSystem);
		objAdjustmentAction.setSecondAlternateCodingSystemVersionID(strSecondAlternateCodingSystemVersionID);
		objAdjustmentAction.setCodingSystemOID(strCodingSystemOID);
		objAdjustmentAction.setValueSetOID(strValueSetOID);
		objAdjustmentAction.setValueSetVersionID(strValueSetVersionID);
		objAdjustmentAction.setAlternateCodingSystemOID(strAlternateCodingSystemOID);
		objAdjustmentAction.setAlternateValueSetOID(strAlternateValueSetOID);
		objAdjustmentAction.setAlternateValueSetVersionID(strAlternateValueSetVersionID);
		objAdjustmentAction.setSecondAlternateCodingSystemOID(strSecondAlternateCodingSystemOID);
		objAdjustmentAction.setSecondAlternateValueSetOID(strSecondAlternateValueSetOID);
		objAdjustmentAction.setSecondAlternateValueSetVersionID(strSecondAlternateValueSetVersionID); 
		setAdjustmentAction(objAdjustmentAction);
	}
	
	/**
	 * Set Adjustment Action   (CWE)   
	 * This field is about Action requested of party that receives this adjustment.      
	 * @param objAdjustmentAction - object of Adjustment Action.
	 */
	public void setAdjustmentAction(CWE objAdjustmentAction)
	{
		setDataType(2013, objAdjustmentAction);
	}
	
	/**
	 * Retrieve Provider Adjustment Number Cross Reference (EI) 
	 * This field is Unique Provider Adjustment Number assigned by the Provider Application that is referenced by this Payer Adjustment.
	 * @return EI - object of Provider Adjustment Number Cross Reference.
	 */
	public EI getProviderAdjustmentNumberCrossReference()
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(2014);
		if(objDataCollection != null) 
			return (EI)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Set  Retrieve Provider Adjustment Number Cross Reference (EI) 
	 * This field is Unique Provider Adjustment Number assigned by the Provider Application that is referenced by this Payer Adjustment.
	 * @param strEntityIdentifier - string of character use to identify the entity.
	 * @param strNamespaceID - Use to identify the name space id..
	 * @param strUniversalID - Use to identify the name space identity.
	 * @param strUniversalIDType - String of characters describe Universal Id Type. 
	 */ 
	public void setProviderAdjustmentNumberCrossReference(String strEntityIdentifier,String strNamespaceID,String strUniversalID,String strUniversalIDType)
	{
		EI objProviderAdjustmentNumberCrossReference = (EI)getDataElement(2014);
		objProviderAdjustmentNumberCrossReference.setEntityIdentifier(strEntityIdentifier);
		objProviderAdjustmentNumberCrossReference.setNamespaceId(strNamespaceID);
		objProviderAdjustmentNumberCrossReference.setUniversalId(strUniversalID);
		objProviderAdjustmentNumberCrossReference.setUniversalIdType(strUniversalIDType);
		setProviderAdjustmentNumberCrossReference(objProviderAdjustmentNumberCrossReference);
	}
	
	/**
	 * Set  Retrieve Provider Adjustment Number Cross Reference (EI) 
	 * This field is Unique Provider Adjustment Number assigned by the Provider Application that is referenced by this Payer Adjustment.
	 * @param objProviderAdjustmentNumberCrossReference - object of Provider Adjustment Number Cross Reference.
	 */ 
	public void setProviderAdjustmentNumberCrossReference(EI objProviderAdjustmentNumberCrossReference)
	{
		setDataType(2014, objProviderAdjustmentNumberCrossReference);
	}
	
	/**
	 * Retrieve Provider Product/Service Line Item Number Cross Reference (EI) 
	 * This field is : Unique Provider Product/Service Line Item Number assigned by the Provider Application that is referenced by this Payer Adjustment; used for 
	 * groups with multiple line items that need to be singled out by a Payer Adjustment.
	 * @return EI - object of Provider Product/Service Line Item Number Cross Reference.
	 */
	public EI getProviderProductOrServiceLineItemNumberCrossReference()
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(2015);
		if(objDataCollection != null) 
			return (EI)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Set  Retrieve Provider Product/Service Line Item Number Cross Reference (EI) 
	 * This field is : Unique Provider Product/Service Line Item Number assigned by the Provider Application that is referenced by this Payer Adjustment; used for 
	 * groups with multiple line items that need to be singled out by a Payer Adjustment.
	 * @param strEntityIdentifier - string of character use to identify the entity.
	 * @param strNamespaceID - Use to identify the name space id..
	 * @param strUniversalID - Use to identify the name space identity.
	 * @param strUniversalIDType - String of characters describe Universal Id Type. 
	 */ 
	public void setProviderProductOrServiceLineItemNumberCrossReference(String strEntityIdentifier,String strNamespaceID,String strUniversalID,String strUniversalIDType)
	{
		EI objProviderProductOrServiceLineItemNumberCrossReference = (EI)getDataElement(2015);
		objProviderProductOrServiceLineItemNumberCrossReference.setEntityIdentifier(strEntityIdentifier);
		objProviderProductOrServiceLineItemNumberCrossReference.setNamespaceId(strNamespaceID);
		objProviderProductOrServiceLineItemNumberCrossReference.setUniversalId(strUniversalID);
		objProviderProductOrServiceLineItemNumberCrossReference.setUniversalIdType(strUniversalIDType);
		setProviderProductOrServiceLineItemNumberCrossReference(objProviderProductOrServiceLineItemNumberCrossReference);
	}
	
	/**
	 * Set  Retrieve Provider Product/Service Line Item Number Cross Reference (EI) 
	 * This field is : Unique Provider Product/Service Line Item Number assigned by the Provider Application that is referenced by this Payer Adjustment; used for 
	 * groups with multiple line items that need to be singled out by a Payer Adjustment.
	 * @param objProviderProductOrServiceLineItemNumberCrossReference - object of Provider Product/Service Line Item Number Cross Reference.
	 */ 
	public void setProviderProductOrServiceLineItemNumberCrossReference(EI objProviderProductOrServiceLineItemNumberCrossReference)
	{
		setDataType(2015, objProviderProductOrServiceLineItemNumberCrossReference);
	}
	
	/**
	 * Retrieve Adjustment Date   (DTM)   
	 * This field is about Date/Time adjustment was made. May also be synonymous with Adjudication Date.
	 * @return DTM - object of Adjustment Date.
	 */
	public DTM getAdjustmentDate()
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(2016);
		if(objDataCollection != null) 
			return (DTM)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Set Adjustment Date   (DTM)   
	 * This field is about Date/Time adjustment was made. May also be synonymous with Adjudication Date.
	 * @param strAdjustmentDate - string of Adjustment Date.
	 */
	public void setAdjustmentDate(String strAdjustmentDate)
	{
		DTM objAdjustmentDate = (DTM)getDataElement(2016);
		objAdjustmentDate.setValue(strAdjustmentDate);
		setAdjustmentDate(objAdjustmentDate);
	}
	
	/**
	 * Set Adjustment Date   (DTM)   
	 * This field is about Date/Time adjustment was made. May also be synonymous with Adjudication Date.
	 * @param objAdjustmentDate - object of Adjustment Date.
	 */
	public void setAdjustmentDate(DTM objAdjustmentDate)
	{
		setDataType(2016, objAdjustmentDate);
	}
	
	/**
	 * Retrieve Responsible Organization   (XON)
	 * This field is about Business organization that is responsible for the adjustment .
	 * @return XON - object of Responsible Organization.
	 */
	public XON getResponsibleOrganization()
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(2017);
		if(objDataCollection != null) 
			return (XON)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Set Responsible Organization   (XON)
	 * This field is about Business organization that is responsible for the adjustment .
	 * @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 setResponsibleOrganization(String strOrganizationName, CWE objOrganizationNameTypeCode,HD objAssigningAuthority,String strIdentifierTypeCode,
			HD objAssigningFacility, String strNameRepresentationCode,String strOrganizationIdentifier)
	{
		XON objResponsibleOrganization  = (XON)getDataElement(2017);
		objResponsibleOrganization.setOrganizationName(strOrganizationName);
		objResponsibleOrganization.setOrganizationNameTypeCode(objOrganizationNameTypeCode);
		objResponsibleOrganization.setAssigningAuthority(objAssigningAuthority);
		objResponsibleOrganization.setIdentifierTypeCode(strIdentifierTypeCode);
		objResponsibleOrganization.setAssigningFacility(objAssigningFacility);
		objResponsibleOrganization.setNameRepresentationCode(strNameRepresentationCode);
		objResponsibleOrganization.setOrganizationIdentifier(strOrganizationIdentifier); 
		setResponsibleOrganization(objResponsibleOrganization);
	}
	
	/**
	 * Set Responsible Organization   (XON)
	 * This field is about Business organization that is responsible for the adjustment .
	 * @param objResponsibleOrganization - object of responsible organization.
	 */ 
	public void setResponsibleOrganization(XON objResponsibleOrganization)
	{
		setDataType(2017, objResponsibleOrganization);
	}
	
	/**
	 * 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 
	 * {ADJ} while parsing ADJ segment validate method will check for its mandatory presence.
	 * [ADJ] in this case validate will throw exception if one tries to enter more than one ADJ 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);
		}
	}
}
