/*******************************************************************************
 *  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.DTM;
import cdac.medinfo.sdk.hl7282.baselibs.EI;
import cdac.medinfo.sdk.hl7282.baselibs.HD;
import cdac.medinfo.sdk.hl7282.baselibs.PL;
import cdac.medinfo.sdk.hl7282.baselibs.SAD;
import cdac.medinfo.sdk.hl7282.baselibs.ST;
import cdac.medinfo.sdk.hl7282.baselibs.XAD;
import cdac.medinfo.sdk.hl7282.baselibs.XON;
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;

/**
 * LOC - Location Identification Segment.<p>
 * The LOC segment can identify any patient location referenced by information systems. 
 * This segment gives physical set up information about the location.  
 * <p>Represents an HL7 LOC message segment. 
 * This segment has the following fields:</p><p>
 * LOC-1: Primary Key Value - LOC (PL)<b>Required</b><br> 
 * LOC-2: Location Description (ST)<b>Optional</b><br> 
 * LOC-3: Location Type - LOC (CWE)<b>Required</b><br> 
 * LOC-4: Organization Name - LOC (XON)<b>Optional</b><br> 
 * LOC-5: Location Address (XAD)<b>Optional</b><br> 
 * LOC-6: Location Phone (XTN)<b>Optional</b><br> 
 * LOC-7: License Number (CWE)<b>Optional</b><br> 
 * LOC-8: Location Equipment (CWE)<b>Optional</b><br> 
 * LOC-9: Location Service Code (CWE)<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 LOC extends Segment   
{
	

	/**
	 * Constructs the LOC segment.
	 */
	public LOC()
	{super(EnumSegments.HL7_SEG_LOC);
	}

	//Integer values used in getter/setter is unique item id defined 
	//for each attribute.

	/**
	 * Retrieves the License Number.
	 * This field contains the multiple license numbers for the facility. 
	 * @return ISingleCollection<CWE> - licenseNumber
	 */
	public ISingleCollection<CWE> getLicenseNumber() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(951);
		ISingleCollection<CWE> objDataList = new SingleCollection<CWE>(); 
		if(objDataCollection != null && objDataCollection.size() != 0)
		{
			for(IDataType objDataType : objDataCollection)
			{
				CWE objCE = (CWE)objDataType;
				objDataList.add(objCE);
			}
		}
		return objDataList;
	}

	/**
	 * Retrieves the Location Address.
	 * This field contains the address of the patient location, especially for use for
	 *  outpatient clinic or office locations.
	 * @return ISingleCollection<XAD> - locationAddress
	 */
	public ISingleCollection<XAD> getLocationAddress() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(948);
		ISingleCollection<XAD> objDataList = new SingleCollection<XAD>(); 
		if(objDataCollection != null && objDataCollection.size() != 0)
		{
			for(IDataType objDataType : objDataCollection)
			{
				XAD objXAD = (XAD)objDataType;
				objDataList.add(objXAD);
			}
		}
		return objDataList;
	}

	/**
	 * Retrieves the Location Description.
	 * This field contains the optional free text description of the 
	 * location, to elaborate upon LOC primary key value.
	 * @return ST - locationDescription
	 */
	public ST getLocationDescription() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(944);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ST)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Location Equipment.
	 * This field indicates what types of equipment are built in.  
	 * @return ISingleCollection<CWE> - locationEquipment
	 */
	public ISingleCollection<CWE> getLocationEquipment() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(953);
		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 Location Phone.
	 * This field contains the phone number within the patient location, 
	 * if any.  For example, the room or bed phone for use by the patient. 
	 * @return ISingleCollection<XTN> - locationPhone
	 */
	public ISingleCollection<XTN> getLocationPhone() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(949);
		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 Location Service Code.
	 * This field categorizes the types of services provided by the location.  
	 * @return CWE - locationServiceCode
	 */
	public CWE getLocationServiceCode() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1583);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (CWE)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Location Type LOC.
	 * This field contains the code identifying what type of location this is.  
	 * @return ISingleCollection<CWE> - locationTypeLOC
	 */
	public ISingleCollection<CWE> getLocationTypeLOC() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(945);
		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 field contains the organization(s) of which this location is a part. 
	 * @return ISingleCollection<XON> - organizationNameLOC
	 */
	public ISingleCollection<XON> getOrganizationNameLOC() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(947);
		ISingleCollection<XON> objDataList = new SingleCollection<XON>(); 
		if(objDataCollection != null && objDataCollection.size() != 0)
		{
			for(IDataType objDataType : objDataCollection)
			{
				XON objXON = (XON)objDataType;
				objDataList.add(objXON);
			}
		}
		return objDataList;
	}

	/**
	 * Retrieves the field contains the institution's identification code for the location.  
	 * @return PL - primaryKeyValueLoc
	 */
	public PL getPrimaryKeyValueLoc() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1307);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (PL)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Add the License Number.
	 * This field contains the multiple license numbers for the facility. 
	 * @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 addLicenseNumber(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(951);
		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);
		addLicenseNumber(cwe);
	}

	/**
	 * Add the License Number.
	 * This field contains the multiple license numbers for the facility. 
	 * @param objlicenseNumber Object of License Number.
	 */
	public void addLicenseNumber(CWE objlicenseNumber)
	{
		addDataType(951,objlicenseNumber);
	}

	/**
	 * Set the License Number.
	 * This field contains the multiple license numbers for the facility. 
	 * @param objlicenseNumberList List of License Number.
	 */
	@SuppressWarnings("unchecked")
	public void setLicenseNumber(ISingleCollection<CWE> objlicenseNumberList)
	{
		ISingleCollection<IDataType> objCollection = null;
		ISingleCollection<?> objUnknownCollection = (ISingleCollection<?>)objlicenseNumberList;
		objCollection = (ISingleCollection<IDataType>)objUnknownCollection;
		setDataType(951,objCollection);
	}

	/**
	 * Add the Location Address.
	 * This field contains the address of the patient location, especially for use for
	 *  outpatient clinic or office locations.
	 * @param objStreetAddress Specifies the street address.
	 * @param strOtherDesignation Specifies the Second line of address. 
	 * @param strCity The city, or district or place where the addressee is located. 
	 * @param strStateOrProvince Specifies the state or province where the addressee is located.
	 * @param strZipOrPostalCode Specifies the zip or postal code where the addressee is located. 
	 * @param strCountry Specifies the country where the addressee is located.
	 * @param strAddressType Specifies the kind or type of address.
	 * @param strOtherGeographicDesignation Specifies any other geographic designation. 
	 * @param objCountyParishCode Specifies a code that represents the county in which the specified address resides. 
	 * @param objCensusTract Specifies a code that represents the census tract in which the specified address resides. 
	 * @param strAddressRepresentationCode Specifies representations of the same name/address Suggested values are I,A,P [Refer table 0465]
	 * @param objEffectiveDate It is The first date, if known, on which the address is valid and active.
	 * @param objExpirationDate It is The last date, if known, on which the address is valid and active.
	 * @param objExpirationReason indicates why this address was marked as ended.
	 * @param strTemporaryIndicator indicates whether address is considered temporary .
	 * @param strBadAddressIndicator indicates whether it is possible to contact the owning entity.
	 * @param strAddressUsage indicates how the address is intended to be used.
	 * @param strAddressee indicates the name of the person whose address is intended to be used.
	 * @param strComment indicated descriptive information
	 * @param strPreferenceOrder preference order
	 * @param objProtectionCode indicates that an address need to be protected
	 * @param objAdressIdentifier indicates a unique identifier for address
	 */
	public void addLocationAddress (SAD objStreetAddress,String strOtherDesignation,String strCity,
			String strStateOrProvince,String strZipOrPostalCode,String strCountry,String strAddressType,
			String strOtherGeographicDesignation,CWE objCountyParishCode,CWE objCensusTract,
			String strAddressRepresentationCode,DTM objEffectiveDate,
			DTM objExpirationDate, CWE objEXpirationReason, String strTemporaryIndicator,
			String strBadAddressIndicator, String strAddressUsage, String strAddressee, String strComment,
			String strPreferenceOrder, CWE objProtectionCode, EI objAddressIdentifier)
	{
		XAD xad = (XAD)getDataElement(948);
		xad.setStreetAddress(objStreetAddress);
		xad.setOtherDesignation(strOtherDesignation);
		xad.setCity(strCity);
		xad.setStateOrProvince(strStateOrProvince);
		xad.setZipOrPostalCode(strZipOrPostalCode);
		xad.setCountry(strCountry);
		xad.setAddressType(strAddressType);
		xad.setOtherGeographicDesignation(strOtherGeographicDesignation);
		xad.setCountyParishCode(objCountyParishCode);
		xad.setCensusTract(objCensusTract);
		xad.setAddressRepresentationCode(strAddressRepresentationCode);
 
		xad.setEffectiveDate(objEffectiveDate);
		xad.setExpirationDate(objExpirationDate); 
		xad.setExpirationReason(objEXpirationReason);
		xad.setTemporaryIndicator(strTemporaryIndicator);
		xad.setBadAddressIndicator(strBadAddressIndicator);
		xad.setAddressUsage(strAddressUsage);
		xad.setAddressee(strAddressee);
		xad.setComment(strComment);
		xad.setPreferenceOrder(strPreferenceOrder);
		xad.setProtectionCode(objProtectionCode);
		xad.setAddressIdentifier(objAddressIdentifier); 
		addLocationAddress(xad);
	}

	/**
	 * Add the Location Address.
	 * This field contains the address of the patient location, especially for use for
	 * outpatient clinic or office locations.
	 * @param objlocationAddress Object of Location Address. 
	 */
	public void addLocationAddress(XAD objlocationAddress)
	{
		addDataType(948,objlocationAddress);
	}

	/**
	 * Set the Location Address.
	 * This field contains the address of the patient location, especially for use for
	 * outpatient clinic or office locations.
	 * @param objlocationAddressList List of Location Address. 
	 */
	@SuppressWarnings("unchecked")
	public void setLocationAddress(ISingleCollection<XAD> objlocationAddressList)
	{
		ISingleCollection<IDataType> objCollection = null;
		ISingleCollection<?> objUnknownCollection = (ISingleCollection<?>)objlocationAddressList;
		objCollection = (ISingleCollection<IDataType>)objUnknownCollection;
		setDataType(948,objCollection);
	}

	/**
	 * Set the Location Description.
	 * This field contains the optional free text description of the 
	 * location, to elaborate upon LOC primary key value.
	 * @param strTitleofStudy String which to set as Title of Study
	 */ 
	public void setLocationDescription (String strTitleofStudy) 
	{
		ST locationDescription  = (ST)getDataElement(944);
		locationDescription.setValue(strTitleofStudy); 
		setLocationDescription(locationDescription);

	} 

	/** 
	 * Set the Location Description.
	 * This field contains the optional free text description of the 
	 * location, to elaborate upon LOC primary key value.
	 * @param objlocationDescription Object of Location Description.
	 */ 
	public void setLocationDescription(ST objlocationDescription)
	{
		setDataType(944,objlocationDescription);

	}

	/**
	 * Add the Location Equipment.
	 * This field indicates what types of equipment are built in.  
	 * @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 addLocationEquipment(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(953);
		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); 
		addLocationEquipment(cwe);
	}

	/**
	 * Add the Location Equipment.
	 * This field indicates what types of equipment are built in.
	 * @param objlocationEquipment Object of Location Equipment.
	 */
	public void addLocationEquipment(CWE objlocationEquipment)
	{
		addDataType(953,objlocationEquipment);
	}

	/**
	 * Set the Location Equipment.
	 * This field indicates what types of equipment are built in.
	 * @param objlocationEquipmentList List of Location Equipment.
	 */
	@SuppressWarnings("unchecked")
	public void setLocationEquipment(ISingleCollection<CWE> objlocationEquipmentList)
	{
		ISingleCollection<IDataType> objCollection = null;
		ISingleCollection<?> objUnknownCollection = (ISingleCollection<?>)objlocationEquipmentList;
		objCollection = (ISingleCollection<IDataType>)objUnknownCollection;
		setDataType(953,objCollection);
	}

	/**
	 * Add the Location Phone.
	 * This field contains the phone number within the patient location, 
	 * if any.  For example, the room or bed phone for use by the patient. 
	 * @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 addLocationPhone(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(949);
//		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); 
		addLocationPhone(xtn);
	}

	/**
	 * Add the Location Phone.
	 * This field contains the phone number within the patient location, 
	 * if any.  For example, the room or bed phone for use by the patient. 
	 * @param objlocationPhone Object of Location Phone.
	 */
	public void addLocationPhone(XTN objlocationPhone)
	{
		addDataType(949,objlocationPhone);
	}

	/**
	 * Set the Location Phone.
	 * This field contains the phone number within the patient location, 
	 * if any.  For example, the room or bed phone for use by the patient. 
	 * @param objlocationPhoneList List of Location Phone.
	 */
	@SuppressWarnings("unchecked")
	public void setLocationPhone(ISingleCollection<XTN> objlocationPhoneList)
	{
		ISingleCollection<IDataType> objCollection = null;
		ISingleCollection<?> objUnknownCollection = (ISingleCollection<?>)objlocationPhoneList;
		objCollection = (ISingleCollection<IDataType>)objUnknownCollection;
		setDataType(949,objCollection);
	}

	/**
	 * Set the Location Service Code.
	 * This field categorizes the types of services provided by the location.
	 * @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 setLocationServiceCode (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(1583);
		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);
		setLocationServiceCode(cwe);

	} 

	/** 
	 * Set the Location Service Code.
	 * This field categorizes the types of services provided by the location.
	 * @param objlocationServiceCode Object of Location Service Code.
	 */ 
	public void setLocationServiceCode(CWE objlocationServiceCode)
	{
		setDataType(1583,objlocationServiceCode);

	}

	/**
	 * Add the Location Type LOC.
	 * This field contains the code identifying what type of location this is.  
	 * @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 addLocationTypeLOC(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(945);
		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);
		addLocationTypeLOC(cwe);
	}

	/**
	 * Add the Location Type LOC.
	 * This field contains the code identifying what type of location this is.
	 * @param objlocationTypeLOC Object of Location Type LOC.
	 */
	public void addLocationTypeLOC(CWE objlocationTypeLOC)
	{
		addDataType(945,objlocationTypeLOC);
	}

	/**
	 * Set the Location Type LOC.
	 * This field contains the code identifying what type of location this is.
	 * @param objlocationTypeLOCList List of Location Type LOC.
	 */
	@SuppressWarnings("unchecked")
	public void setLocationTypeLOC(ISingleCollection<CWE> objlocationTypeLOCList)
	{
		ISingleCollection<IDataType> objCollection = null;
		ISingleCollection<?> objUnknownCollection = (ISingleCollection<?>)objlocationTypeLOCList;
		objCollection = (ISingleCollection<IDataType>)objUnknownCollection;
		setDataType(945,objCollection);
	}

	/**
	 * Add the field which contains the organization(s) of which this location is a part. 
	 * @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.5.
	 */ 		
	public void addOrganizationNameLOC(String strOrganizationName, CWE objOrganizationNameTypeCode,
			 HD objAssigningAuthority,
			String strIdentifierTypeCode, HD objAssigningFacility, String strNameRepresentationCode,
			String strOrganizationIdentifier)
	{
		XON xon  = (XON)getDataElement(947);
		xon.setOrganizationName(strOrganizationName);
		xon.setOrganizationNameTypeCode(objOrganizationNameTypeCode);
		xon.setAssigningAuthority(objAssigningAuthority);
		xon.setIdentifierTypeCode(strIdentifierTypeCode);
		xon.setAssigningFacility(objAssigningFacility);
		xon.setNameRepresentationCode(strNameRepresentationCode);
		xon.setOrganizationIdentifier(strOrganizationIdentifier); 
		addOrganizationNameLOC(xon);
	}

	/**
	 * Add the field which contains the organization(s) of which this location is a part. 
	 * @param objorganizationNameLOC Object of Organization Name LOC.
	 */
	public void addOrganizationNameLOC(XON objorganizationNameLOC)
	{
		addDataType(947,objorganizationNameLOC);
	}

	/**
	 * Set the field which contains the organization(s) of which this location is a part. 
	 * @param objorganizationNameLOCList List of Organization Name LOC.
	 */
	@SuppressWarnings("unchecked")
	public void setOrganizationNameLOC(ISingleCollection<XON> objorganizationNameLOCList)
	{
		ISingleCollection<IDataType> objCollection = null;
		ISingleCollection<?> objUnknownCollection = (ISingleCollection<?>)objorganizationNameLOCList;
		objCollection = (ISingleCollection<IDataType>)objUnknownCollection;
		setDataType(947,objCollection);
	}

	/**
	 * Set the field which contains the institution's identification code for the location.  
	 * @param strPointOfCare Specifies the code for the point where patient care is administered.
	 * @param strRoom Specifies the code for the patient's room. 
	 * @param strBed Specifies the code for the patient's bed. 
	 * @param objFacility Specifies to site interpretation but generally describes 
	 * 							the highest level physical designation of an institution, 
	 * 							medical center or enterprise. 
	 * @param strLocationStatus Specifies the code for the status or availability of the location. 
	 * @param strPersonLocationType Specifies the categorization of the person's location defined by 
	 * 									facility, building, floor, point of care, room or bed. 
	 * @param strBuilding Specifies code for the building where the person is located. 
	 * @param strFloor Specifies the code for the floor where the person is located.
	 * @param strLocationDescription Specifies describes the location in free text.
	 * @param objComprehensiveLocationIdentifier Specifies represents the physical location as 
	 *													a whole without regard for the individual components. 
	 * @param objAssigningAuthorityForLocation Specifies the entity that creates the data for the individual physical location components. 
	 */ 
	public void setPrimaryKeyValueLoc  (HD objPointOfCare,HD objRoom,HD objBed,HD objFacility,
			String strLocationStatus,String strPersonLocationType,String strBuilding,String strFloor,
			String strLocationDescription,EI objComprehensiveLocationIdentifier,HD objAssigningAuthorityForLocation)
	{
		PL primaryKeyValueLoc  = (PL)getDataElement(1307);
		primaryKeyValueLoc.setPointOfCare(objPointOfCare);
		primaryKeyValueLoc.setRoom(objRoom);
		primaryKeyValueLoc.setBed(objBed);
		primaryKeyValueLoc.setFacility(objFacility);
		primaryKeyValueLoc.setLocationStatus(strLocationStatus);
		primaryKeyValueLoc.setPersonLocationType(strPersonLocationType);
		primaryKeyValueLoc.setBuilding(strBuilding);
		primaryKeyValueLoc.setFloor(strFloor);
		primaryKeyValueLoc.setLocationDescription(strLocationDescription);
		primaryKeyValueLoc.setComprehensiveLocationIdentifier(objComprehensiveLocationIdentifier);
		primaryKeyValueLoc.setAssigningAuthorityForLocation(objAssigningAuthorityForLocation); 
		setPrimaryKeyValueLoc (primaryKeyValueLoc);

	} 

	/** 
	 * Set the field which contains the institution's identification code for the location.  
	 * @param objprimaryKeyValueLoc Object of Primary Key Value Loc.
	 */ 
	public void setPrimaryKeyValueLoc(PL objprimaryKeyValueLoc)
	{
		setDataType(1307,objprimaryKeyValueLoc);

	}

	/**
	 * 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 Throws when Segment Validation fails
	 */	
	@Override
	public boolean validate() throws InvalidSegmentException 
	{
		/*
		 * Primary Key Value - LOC and Location Type - LOC  are required fields.
		 */
		try 
		{
			super.validate();

			return true;
		}
		catch(FieldMissingException ex)
		{
			throw new InvalidSegmentException(enumSegments.getValue(),ex);
		}
	}
}