/*******************************************************************************
 *  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.CWE;
import cdac.medinfo.sdk.hl7282.baselibs.EI;
import cdac.medinfo.sdk.hl7282.baselibs.ERL;
import cdac.medinfo.sdk.hl7282.baselibs.ID;
import cdac.medinfo.sdk.hl7282.baselibs.ST;
import cdac.medinfo.sdk.hl7282.baselibs.TX;
import cdac.medinfo.sdk.hl7282.baselibs.XTN;
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;

/**
 * ERR - error segment <p>
 * The ERR segment is used to add error comments to acknowledgment messages. 
 * <p>Represents an HL7 ERR message segment. 
 * This segment has the following fields:</p><p>
 * ERR-1: Error Code and Location (ELD)<b>Withdrawn</b><br> 
 * ERR-2: Error Location (ERL)<b>Optional</b><br> 
 * ERR-3: HL7 Error Code (CWE)<b>Required</b><br> 
 * ERR-4: Severity (ID)<b>Required</b><br> 
 * ERR-5: Application Error Code (CWE)<b>Optional</b><br> 
 * ERR-6: Application Error Parameter (ST)<b>Optional</b><br> 
 * ERR-7: Diagnostic Information (TX)<b>Optional</b><br> 
 * ERR-8: User Message (TX)<b>Optional</b><br> 
 * ERR-9: Inform Person Indicator (CWE)<b>Optional</b><br> 
 * ERR-10: Override Type (CWE)<b>Optional</b><br> 
 * ERR-11: Override Reason Code (CWE)<b>Optional</b><br> 
 * ERR-12: Help Desk Contact Point (XTN)<b>Optional</b><br><p>
 * 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 ERR extends Segment    
{
	

	/**
	 * Constructs the ERR segment. 
	 *
	 */
	public ERR()
	{super(EnumSegments.HL7_SEG_ERR);
	}
	//Integer values used in getter/setter is unique item id defined 
	//for each attribute.


	/**
	 * Retrieves the Application Error Code.
	 * This field contains Application specific code identifying the specific error that occurred. 
	 * @return CWE - applicationErrorCode
	 */
	public CWE getApplicationErrorCode() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1815);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (CWE)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Application Error Parameter.
	 * This field contains Additional information to be used, together with the Application Error
	 * Code, to understand a particular error condition/warning/etc. 
	 * @return ISingleCollection<ST> - applicationErrorParameter
	 */
	public ISingleCollection<ST> getApplicationErrorParameter() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1816);
		ISingleCollection<ST> objDataList = new SingleCollection<ST>();
		if(objDataCollection != null && objDataCollection.size() != 0)
		{
			for(IDataType objDataType : objDataCollection)
			{
				ST objST = (ST)objDataType;
				objDataList.add(objST);
			}
		}
		return objDataList;
	}

	/**
	 * Retrieves the Diagnostic Information.
	 * This field contains information that may be used by help desk or other support 
	 * personnel to diagnose a problem.
	 * @return TX - diagnosticInformation
	 */
	public TX getDiagnosticInformation() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1817);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (TX)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Error Location.
	 * This field identify the location in a message related to the identified error, warning or message. 
	 * @return ISingleCollection<ERL> - errorLocation
	 */
	public ISingleCollection<ERL> getErrorLocation() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1812);
		ISingleCollection<ERL> objDataList = new SingleCollection<ERL>(); 
		if(objDataCollection != null && objDataCollection.size() != 0)
		{
			for(IDataType objDataType : objDataCollection)
			{
				ERL objERL = (ERL)objDataType;
				objDataList.add(objERL);
			}
		}
		return objDataList;
	}

	/**
	 * Retrieves the Help Desk Contact Point.
	 * This field specify the lists of phone, e-mail, fax, and other relevant numbers for helpdesk support related to the 
	 * specified error.
	 * @return ISingleCollection<XTN> - helpDeskContactPoint
	 */
	public ISingleCollection<XTN> getHelpDeskContactPoint() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1822);
		ISingleCollection<XTN> objDataList = new SingleCollection<XTN>(); 
		if(objDataCollection != null && objDataCollection.size() != 0)
		{
			for(IDataType objDataType : objDataCollection)
			{
				XTN objXTN = (XTN)objDataType;
				objDataList.add(objXTN);
			}
		}
		return objDataList;
	}

	/**
	 * Retrieves the HL7 Error Code.
	 * This field identify the HL7 (communications) error code. 
	 * @return CWE - hL7ErrorCode
	 */
	public CWE getHL7ErrorCode() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1813);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (CWE)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Inform Person Indicator.
	 * This field specify the code to indicate who(if anyone) should be informed of the error. This 
	 * field may also be used to indicate that a particular person should NOT be informed of the error.
	 * @return ISingleCollection<CWE> - informPersonIndicator
	 */
	public ISingleCollection<CWE> getInformPersonIndicator() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1819);
		ISingleCollection<CWE> objDataList = new SingleCollection<CWE>(); 
		if(objDataCollection != null && objDataCollection.size() != 0)
		{
			for(IDataType objDataType : objDataCollection)
			{
				CWE objIS = (CWE)objDataType;
				objDataList.add(objIS);
			}
		}
		return objDataList;
	}

	/**
	 * Retrieves the Override Reason Code.
	 * This field specify the list of potential override codes that can be used to override enforcement of 
	 * the application rule that generated the error.
	 * @return ISingleCollection<CWE> - overrideReasonCode
	 */
	public ISingleCollection<CWE> getOverrideReasonCode() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1821);
		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;
	}

	/**
	 * Retrieves the Override Type.
	 * This field identify what type of override can be used to override the specific error identified. 
	 * @return CWE - overrideType
	 */
	public CWE getOverrideType() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1820);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (CWE)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Severity.
	 * This field identify the severity of an application error. 
	 * @return ID - severity
	 */
	public ID getSeverity() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1814);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ID)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the User Message.
	 * This field specify the text message to be displayed to the application user.
	 * @return TX - userMessage
	 */
	public TX getUserMessage() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1818);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (TX)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Set the Application Error Code.
	 * This field contains Application specific code identifying the specific error that occurred.
	* @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 infarction. 
	 * @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 setApplicationErrorCode(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 cwe  = (CWE)getDataElement(1815);
		cwe.setIdentifier(strIdentifier);
		cwe.setText(strText);
		cwe.setNameOfCodingSystem(strNameOfCodingSystem);
		cwe.setAlternateIdentifier(strAlternateIdentifier);
		cwe.setAlternateText(strAlternateText);
		cwe.setNameOfAlternateCodingSystem(strNameOfAlternateCodingSystem); 
		cwe.setCodingSystemVersionID(strCodingSystemVersionID);
		cwe.setAlternateCodingSystemVersionId(strAlternateCodingSystemVersionId);
		cwe.setOriginalText(strOriginalText);
		cwe.setSecondAlternateIdentifier(strSecondAlternateIdentifier);
		cwe.setSecondAlternateText(strSecondAlternateText);
		cwe.setNameofSecondAlternateCodingSystem(strNameofSecondAlternateCodingSystem);
		cwe.setSecondAlternateCodingSystemVersionID(strSecondAlternateCodingSystemVersionID);
		cwe.setCodingSystemOID(strCodingSystemOID);
		cwe.setValueSetOID(strValueSetOID);
		cwe.setValueSetVersionID(strValueSetVersionID);
		cwe.setAlternateCodingSystemOID(strAlternateCodingSystemOID);
		cwe.setAlternateValueSetOID(strAlternateValueSetOID);
		cwe.setAlternateValueSetVersionID(strAlternateValueSetVersionID);
		cwe.setSecondAlternateCodingSystemOID(strSecondAlternateCodingSystemOID);
		cwe.setSecondAlternateValueSetOID(strSecondAlternateValueSetOID);
		cwe.setSecondAlternateValueSetVersionID(strSecondAlternateValueSetVersionID);
		setApplicationErrorCode(cwe);
	}

	/**
	 * Set the Application Error Code.
	 * This field contains Application specific code identifying the specific error that occurred.
	 * @param applicationErrorCode Object of Application Error Code.
	 */
	public void setApplicationErrorCode(CWE applicationErrorCode)
	{
		setDataType(1815,applicationErrorCode);
	}

	/**
	 * Add the Application Error Parameter.
	 * This field contains Additional information to be used, together with the Application Error
	 * Code, to understand a particular error condition/warning/etc.
	 * @param strApplicationErrorParameter String which to set as Application Error Parameter 
	 */	
	public void addApplicationErrorParameter(String strApplicationErrorParameter)
	{
		ST ApplicationErrorParameter  = (ST)getDataElement(1816);
		ApplicationErrorParameter.setValue(strApplicationErrorParameter);
		addApplicationErrorParameter(ApplicationErrorParameter);
	}

	/**
	 * Add the Application Error Parameter.
	 * This field contains Additional information to be used, together with the Application Error
	 * Code, to understand a particular error condition/warning/etc.
	 * @param ApplicationErrorParameter Object of Application Error Parameter.
	 */
	public void addApplicationErrorParameter(ST ApplicationErrorParameter)
	{
		addDataType(1816,ApplicationErrorParameter);
	}

	/**
	 * Set the Application Error Parameter List.
	 * @param objErrorCodeandLocationList List of Application Error Parameter.
	 */	
	@SuppressWarnings("unchecked")
	public void setApplicationErrorParameter(ISingleCollection<ST> objApplicationErrorParameterList)
	{
		ISingleCollection<IDataType> objCollection = null;
		ISingleCollection<?> objUnknownCollection = (ISingleCollection<?>)objApplicationErrorParameterList;
		objCollection = (ISingleCollection<IDataType>)objUnknownCollection;
		setDataType(1816,objCollection);
	}
	/**
	 * Set the Diagnostic Information.
	 * This field contains information that may be used by help desk or other support 
	 * personnel to diagnose a problem.
	 * @param strDiagnosticInformation String which to set as Diagnostic Information 
	 */	
	public void setDiagnosticInformation(String strDiagnosticInformation)
	{
		TX diagnosticInformation  = (TX)getDataElement(1817);
		diagnosticInformation.setValue(strDiagnosticInformation);
		setDiagnosticInformation(diagnosticInformation);
	}

	/**
	 * Set the Diagnostic Information.
	 * This field contains information that may be used by help desk or other support 
	 * personnel to diagnose a problem.
	 * @param diagnosticInformation Object of Diagnostic Information.
	 */
	public void setDiagnosticInformation(TX diagnosticInformation)
	{
		setDataType(1817,diagnosticInformation);
	}


	/**
	 * Add the Error Location.
	 * This field identify the location in a message related to the identified error, warning or message. 
	 * @param strSegmentId Specifies the 3-letter name for the segment. 
	 * @param strSegmentSequence Specifies the segment occurrence within the message.
	 * @param strFieldPosition Specifies the number of the field within the segment. 
	 * @param strFieldRepetition Specifies the repetition number of the field. 
	 * @param strComponentNumber Specifies the number of the component within the field. 
	 * @param strSubComponentNumber Specifies the number of the sub-component within the component. 
	 */	
	public void addErrorLocation(String strSegmentId,String strSegmentSequence,String strFieldPosition,String strFieldRepetition
			,String strComponentNumber,String strSubComponentNumber)
	{
		ERL ErrorLocation  = (ERL)getDataElement(1812);
		ErrorLocation.setSegmentId(strSegmentId);
		ErrorLocation.setSegmentSequence(strSegmentSequence);
		ErrorLocation.setFieldPosition(strFieldPosition);
		ErrorLocation.setFieldRepetition(strFieldRepetition);
		ErrorLocation.setComponentNumber(strComponentNumber);
		ErrorLocation.setSubComponentNumber(strSubComponentNumber);
		addErrorLocation(ErrorLocation);
	}

	/**
	 * Add the Error Location.
	 * This field identify the location in a message related to the identified error, warning or message.
	 * @param ErrorLocation Object of Error Location.
	 */
	public void addErrorLocation(ERL ErrorLocation)
	{
		addDataType(1812,ErrorLocation);
	}

	/**
	 * Set the Error Location.
	 * @param objErrorCodeandLocationList List of Error Location.
	 */	
	@SuppressWarnings("unchecked")
	public void setErrorLocation(ISingleCollection<ERL> objErrorLocationList)
	{
		ISingleCollection<IDataType> objCollection = null;
		ISingleCollection<?> objUnknownCollection = (ISingleCollection<?>)objErrorLocationList;
		objCollection = (ISingleCollection<IDataType>)objUnknownCollection;
		setDataType(1812,objCollection);
	}

	/**
	 * Add the Help Desk Contact Point.
	 * This field specify the lists of phone, e-mail, fax, and other relevant numbers for helpdesk support related to the 
	 * specified error.
	 * @param strTeleCommunicationUseCode Specifies a code that represents a specific use of a telecommunication number.
	 										Suggested values are PRN,ORN,WPN,VHN,ASN,EMR,NET,BPN  [Refer table 0201.]
	 * @param strTeleCommunicationEquipmentType Specifies a code that represents the type of telecommunication equipment.
	 * 											  Suggested values are PH,FX,MD,CP,BP,Internet,X.400,TDD,TTY  [Refer table 0202.]
	 * @param strCommuinicationAddress Specifies Email address.
	 * @param strCountryCode Specifies the Country code.
	 * @param strAreaCityCode Specifies the area /City Code.
	 * @param strLocalNumber Specifies an Local Number.
	 * @param strExtension Specifies an Extension.
	 * @param strAnyText Contains comments with respect to the telephone number.
	 * @param strExtensionPrefix Specifies the characters established within a company's 
	 * 							   internal telephone system network used as a prefix to the Extension component for internal dialing. 
	 * @param strSpeedDialCode Specifies The characters established within a 
	 * 							 company's internal telephone system used in place of the (external) telephone number.
	 * @param strUnformattedTelephoneNumber Specifies an expression of the telephone number as an unparsible string.
	 * @param strEffectiveStartDate Specifies start date.
	 * @param strExpirationDate Specifies expiration date.
	 * @param objExpirationReason Specifies reason why this contact is marked as ended.
	 * @param objProtectionCode Specifies reason why this information is sensitive or protected.
	 * @param objSharedTelecommunicationIdentifier Specifies a unique phone number phone telephone number or email-id.
	 * @param strPreferenceOrder Specifies the preference order for an entity..
	 */
	public void addHelpDeskContactPoint(String strTeleCommunicationUseCode,String strTeleCommunicationEquipmentType
			,String strCommuinicationAddress,String strCountryCode,String strAreaCityCode,String strLocalNumber,String strExtension,String strAnyText,
			String strExtensionPrefix,String strSpeedDialCode,String strUnformattedTelephoneNumber, String strEffectiveStartDate, String strExpirationDate,
			CWE objExpirationReason, CWE objProtectionCode, EI objSharedTelecommunicationIdentifier, String strPreferenceOrder)
	{
		XTN xtn  = (XTN)getDataElement(1822);
//		xtn.setTelephoneNumber(strTelephoneNumber);
		xtn.setTelecommunicationUseCode(strTeleCommunicationUseCode);
		xtn.setTelecommunicationEquipmentType(strTeleCommunicationEquipmentType);
		xtn.setCommuinicationAddress(strCommuinicationAddress);
		xtn.setCountryCode(strCountryCode);
		xtn.setAreaCityCode(strAreaCityCode);
		xtn.setLocalNumber(strLocalNumber);
		xtn.setExtension(strExtension);
		xtn.setAnyText(strAnyText);
		xtn.setExtensionPrefix(strExtensionPrefix);
		xtn.setSpeedDialCode(strSpeedDialCode);
		xtn.setUnformattedTelephonenumber(strUnformattedTelephoneNumber); 
		xtn.setEffectiveStartDate(strEffectiveStartDate);
		xtn.setExpirationDate(strExpirationDate);
		xtn.setExpirationReason(objExpirationReason);
		xtn.setProtectionCode(objProtectionCode);
		xtn.setSharedTelecommunicationIdentifier(objSharedTelecommunicationIdentifier);
		xtn.setPreferenceOrder(strPreferenceOrder);
		addHelpDeskContactPoint(xtn);
	}

	/**
	 * Add the Help Desk Contact Point.
	 * This field specify the lists of phone, e-mail, fax, and other relevant numbers for helpdesk support related to the 
	 * specified error.
	 * @param HelpDeskContactPoint Object of Help Desk Contact Point.
	 */
	public void addHelpDeskContactPoint(XTN HelpDeskContactPoint)
	{
		addDataType(1822,HelpDeskContactPoint);
	}

	/**
	 * Set the Help Desk ContactPoint.
	 * @param objHelpDeskContactPointList List of Help Desk ContactPoint.
	 */	
	@SuppressWarnings("unchecked")
	public void setHelpDeskContactPoint(ISingleCollection<XTN> objHelpDeskContactPointList)
	{
		ISingleCollection<IDataType> objCollection = null;
		ISingleCollection<?> objUnknownCollection = (ISingleCollection<?>)objHelpDeskContactPointList;
		objCollection = (ISingleCollection<IDataType>)objUnknownCollection;
		setDataType(1822,objCollection);
	}
	/**
	 * Set the HL7 Error Code.
	 * This field identify the HL7 (communications) error code. 
	 * @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 infarction. 
	 * @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 setHL7ErrorCode(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 cwe  = (CWE)getDataElement(1813);
		cwe.setIdentifier(strIdentifier);
		cwe.setText(strText);
		cwe.setNameOfCodingSystem(strNameOfCodingSystem);
		cwe.setAlternateIdentifier(strAlternateIdentifier);
		cwe.setAlternateText(strAlternateText);
		cwe.setNameOfAlternateCodingSystem(strNameOfAlternateCodingSystem); 
		cwe.setCodingSystemVersionID(strCodingSystemVersionID);
		cwe.setAlternateCodingSystemVersionId(strAlternateCodingSystemVersionId);
		cwe.setOriginalText(strOriginalText);
		cwe.setSecondAlternateIdentifier(strSecondAlternateIdentifier);
		cwe.setSecondAlternateText(strSecondAlternateText);
		cwe.setNameofSecondAlternateCodingSystem(strNameofSecondAlternateCodingSystem);
		cwe.setSecondAlternateCodingSystemVersionID(strSecondAlternateCodingSystemVersionID);
		cwe.setCodingSystemOID(strCodingSystemOID);
		cwe.setValueSetOID(strValueSetOID);
		cwe.setValueSetVersionID(strValueSetVersionID);
		cwe.setAlternateCodingSystemOID(strAlternateCodingSystemOID);
		cwe.setAlternateValueSetOID(strAlternateValueSetOID);
		cwe.setAlternateValueSetVersionID(strAlternateValueSetVersionID);
		cwe.setSecondAlternateCodingSystemOID(strSecondAlternateCodingSystemOID);
		cwe.setSecondAlternateValueSetOID(strSecondAlternateValueSetOID);
		cwe.setSecondAlternateValueSetVersionID(strSecondAlternateValueSetVersionID);
		setHL7ErrorCode(cwe);
	}

	/**
	 * Set the HL7 Error Code.
	 * This field identify the HL7 (communications) error code.
	 * @param hL7ErrorCode Object of HL7 Error Code.
	 */
	public void setHL7ErrorCode(CWE hL7ErrorCode)
	{
		setDataType(1813,hL7ErrorCode);
	}

	/**
	 * Add the Inform Person Indicator.
	 * This field specify the code to indicate who(if anyone) should be informed of the error. This 
	 * field may also be used to indicate that a particular person should NOT be informed of the error. 
	 * @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 infarction. 
	 * @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 addInformPersonIndicator(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 cwe  = (CWE)getDataElement(1819);
		cwe.setIdentifier(strIdentifier);
		cwe.setText(strText);
		cwe.setNameOfCodingSystem(strNameOfCodingSystem);
		cwe.setAlternateIdentifier(strAlternateIdentifier);
		cwe.setAlternateText(strAlternateText);
		cwe.setNameOfAlternateCodingSystem(strNameOfAlternateCodingSystem); 
		cwe.setCodingSystemVersionID(strCodingSystemVersionID);
		cwe.setAlternateCodingSystemVersionId(strAlternateCodingSystemVersionId);
		cwe.setOriginalText(strOriginalText);
		cwe.setSecondAlternateIdentifier(strSecondAlternateIdentifier);
		cwe.setSecondAlternateText(strSecondAlternateText);
		cwe.setNameofSecondAlternateCodingSystem(strNameofSecondAlternateCodingSystem);
		cwe.setSecondAlternateCodingSystemVersionID(strSecondAlternateCodingSystemVersionID);
		cwe.setCodingSystemOID(strCodingSystemOID);
		cwe.setValueSetOID(strValueSetOID);
		cwe.setValueSetVersionID(strValueSetVersionID);
		cwe.setAlternateCodingSystemOID(strAlternateCodingSystemOID);
		cwe.setAlternateValueSetOID(strAlternateValueSetOID);
		cwe.setAlternateValueSetVersionID(strAlternateValueSetVersionID);
		cwe.setSecondAlternateCodingSystemOID(strSecondAlternateCodingSystemOID);
		cwe.setSecondAlternateValueSetOID(strSecondAlternateValueSetOID);
		cwe.setSecondAlternateValueSetVersionID(strSecondAlternateValueSetVersionID);
		addInformPersonIndicator(cwe);
	}

	/**
	 * Add the Inform Person Indicator.
	 * This field specify the code to indicate who(if anyone) should be informed of the error. This 
	 * field may also be used to indicate that a particular person should NOT be informed of the error.
	 * @param InformPersonIndicator Object of Inform Person Indicator.
	 */
	public void addInformPersonIndicator(CWE InformPersonIndicator)
	{
		addDataType(1819,InformPersonIndicator);
	}

	/**
	 * Set the Inform Person Indicator.
	 * @param objInformPersonIndicatorList List of Inform Person Indicator.
	 */	
	@SuppressWarnings("unchecked")
	public void setInformPersonIndicator(ISingleCollection<CWE> objInformPersonIndicatorList)
	{
		ISingleCollection<IDataType> objCollection = null;
		ISingleCollection<?> objUnknownCollection = (ISingleCollection<?>)objInformPersonIndicatorList;
		objCollection = (ISingleCollection<IDataType>)objUnknownCollection;
		setDataType(1819,objCollection);
	}

	/**
	 * Add the Override Reason Code.
	 * This field specify the list of potential override codes that can be used to override enforcement of 
	 * the application rule that generated the error.
	 * @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 infarction. 
	 * @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 addOverrideReasonCode(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 cwe  = (CWE)getDataElement(1821);
		cwe.setIdentifier(strIdentifier);
		cwe.setText(strText);
		cwe.setNameOfCodingSystem(strNameOfCodingSystem);
		cwe.setAlternateIdentifier(strAlternateIdentifier);
		cwe.setAlternateText(strAlternateText);
		cwe.setNameOfAlternateCodingSystem(strNameOfAlternateCodingSystem); 
		cwe.setCodingSystemVersionID(strCodingSystemVersionID);
		cwe.setAlternateCodingSystemVersionId(strAlternateCodingSystemVersionId);
		cwe.setOriginalText(strOriginalText);
		cwe.setSecondAlternateIdentifier(strSecondAlternateIdentifier);
		cwe.setSecondAlternateText(strSecondAlternateText);
		cwe.setNameofSecondAlternateCodingSystem(strNameofSecondAlternateCodingSystem);
		cwe.setSecondAlternateCodingSystemVersionID(strSecondAlternateCodingSystemVersionID);
		cwe.setCodingSystemOID(strCodingSystemOID);
		cwe.setValueSetOID(strValueSetOID);
		cwe.setValueSetVersionID(strValueSetVersionID);
		cwe.setAlternateCodingSystemOID(strAlternateCodingSystemOID);
		cwe.setAlternateValueSetOID(strAlternateValueSetOID);
		cwe.setAlternateValueSetVersionID(strAlternateValueSetVersionID);
		cwe.setSecondAlternateCodingSystemOID(strSecondAlternateCodingSystemOID);
		cwe.setSecondAlternateValueSetOID(strSecondAlternateValueSetOID);
		cwe.setSecondAlternateValueSetVersionID(strSecondAlternateValueSetVersionID);
		addOverrideReasonCode(cwe);
	}

	/**
	 * Add the Override Reason Code.
	 * This field specify the list of potential override codes that can be used to override enforcement of 
	 * the application rule that generated the error.
	 * @param OverrideReasonCode Object of Override Reason Code.
	 */
	public void addOverrideReasonCode(CWE OverrideReasonCode)
	{
		addDataType(1821,OverrideReasonCode);
	}

	/**
	 * Set the Override Reason Code.
	 * @param objOverrideReasonCodeList List of Override Reason Code.
	 */	
	@SuppressWarnings("unchecked")
	public void setOverrideReasonCode(ISingleCollection<CWE> objOverrideReasonCodeList)
	{
		ISingleCollection<IDataType> objCollection = null;
		ISingleCollection<?> objUnknownCollection = (ISingleCollection<?>)objOverrideReasonCodeList;
		objCollection = (ISingleCollection<IDataType>)objUnknownCollection;
		setDataType(1821,objCollection);
	}

	/**
	 * Set the Override Type.
	 * This field identify what type of override can be used to override the specific error identified. 
	 * @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 infarction. 
	 * @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 setOverrideType(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 cwe  = (CWE)getDataElement(1820);
		cwe.setIdentifier(strIdentifier);
		cwe.setText(strText);
		cwe.setNameOfCodingSystem(strNameOfCodingSystem);
		cwe.setAlternateIdentifier(strAlternateIdentifier);
		cwe.setAlternateText(strAlternateText);
		cwe.setNameOfAlternateCodingSystem(strNameOfAlternateCodingSystem); 
		cwe.setCodingSystemVersionID(strCodingSystemVersionID);
		cwe.setAlternateCodingSystemVersionId(strAlternateCodingSystemVersionId);
		cwe.setOriginalText(strOriginalText);
		cwe.setSecondAlternateIdentifier(strSecondAlternateIdentifier);
		cwe.setSecondAlternateText(strSecondAlternateText);
		cwe.setNameofSecondAlternateCodingSystem(strNameofSecondAlternateCodingSystem);
		cwe.setSecondAlternateCodingSystemVersionID(strSecondAlternateCodingSystemVersionID);
		cwe.setCodingSystemOID(strCodingSystemOID);
		cwe.setValueSetOID(strValueSetOID);
		cwe.setValueSetVersionID(strValueSetVersionID);
		cwe.setAlternateCodingSystemOID(strAlternateCodingSystemOID);
		cwe.setAlternateValueSetOID(strAlternateValueSetOID);
		cwe.setAlternateValueSetVersionID(strAlternateValueSetVersionID);
		cwe.setSecondAlternateCodingSystemOID(strSecondAlternateCodingSystemOID);
		cwe.setSecondAlternateValueSetOID(strSecondAlternateValueSetOID);
		cwe.setSecondAlternateValueSetVersionID(strSecondAlternateValueSetVersionID);
		setOverrideType(cwe);
	}

	/**
	 * Set the Override Type.
	 * This field identify what type of override can be used to override the specific error identified.
	 * @param overrideType Object of Override Type.
	 */
	public void setOverrideType(CWE overrideType)
	{
		setDataType(1820,overrideType);
	}

	/**
	 * Set the Severity.
	 * This field identify the severity of an application error.
	 * @param strSeverity String which to set as Severity 
	 */
	public void setSeverity(String strSeverity)
	{
		ID severity  = (ID)getDataElement(1814);
		severity.setValue(strSeverity);
		setSeverity(severity);
	}

	/**
	 * Set the Severity.
	 * This field identify the severity of an application error.
	 * @param severity Object of Severity.
	 */
	public void setSeverity(ID severity)
	{
		setDataType(1814,severity);
	}

	/**
	 * Set the User Message.
	 * This field specify the text message to be displayed to the application user.
	 * @param strUserMessage String which to set as User Message 
	 */	
	public void setUserMessage(String strUserMessage)
	{
		TX userMessage  = (TX)getDataElement(1818);
		userMessage.setValue(strUserMessage);
		setUserMessage(userMessage);
	}

	/**
	 * Set the User Message.
	 * This field specify the text message to be displayed to the application user.
	 * @param userMessage Object of User Message.
	 */
	public void setUserMessage(TX userMessage)
	{
		setDataType(1818,userMessage);
	}

	/**
	 * Validates HL7 Message objects .
	 * Validate method checks for validation each and every segments in side the Message object against specified message Structure. 
	 * Validation chcecks include optionality of segment or group.
	 * It also verifies the number of times segment or group is repeated in message.
	 * e.g 
	 * {PSH} while parsing PSH segment validate method will check for its mandatory presence.
	 * [PSH] in this case validate will throw exception if one tries to enter more than one PSH segment. 
	 * @return boolean - true or false.
	 * @throws InvalidSegmentException Thrown when Segment Validation Fails.
	 */
	public boolean validate() throws InvalidSegmentException
	{
		/*
		 * HL7 Error Code & Severity are required fields.
		 */
		try
		{
			super.validate();
			return true;
		}
		catch(FieldMissingException ex)
		{
			throw new InvalidSegmentException(enumSegments.getValue(),ex);
		}
	}
}