/*******************************************************************************
 *  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.HD;
import cdac.medinfo.sdk.hl7282.baselibs.ST;
import cdac.medinfo.sdk.hl7282.baselibs.TX;
import cdac.medinfo.sdk.hl7282.baselibs.XON;
import cdac.medinfo.sdk.hl7282.commoninterface.IDataType;
import cdac.medinfo.sdk.hl7282.commoninterface.ISingleCollection;
import cdac.medinfo.sdk.hl7282.exceptions.FieldMissingException;
import cdac.medinfo.sdk.hl7282.exceptions.InvalidSegmentException;
import cdac.medinfo.sdk.hl7282.utils.EnumSegments;

/**
 * SFT - software segment.<p>
 * This segment provides additionalation. 
 * The primary purpose of this segment is for diagnostic use. 
 * There may be additional uses per site-specific agreements.
 * <p>Represents an HL7 SFT message segment. 
 * This segment has the following fields:</p><p>
 * SFT-1: Software Vendor Organization (XON)<b>Required</b><br> 
 * SFT-2: Software Certified Version or Release Number (ST)<b>Required</b><br> 
 * SFT-3: Software Product Name (ST)<b>Required</b><br> 
 * SFT-4: Software Binary ID (ST)<b>Required</b><br> 
 * SFT-5: Software Product Information (TX)<b>Optional</b><br> 
 * SFT-6: Software Install Date (DTM)<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 SFT extends Segment   
{
	

	/**
	 * Constructs the SFT segment.
	 */
	public SFT()
	{super(EnumSegments.HL7_SEG_SFT);
	}

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

	/**
	 * Retrieves the Software Binary Id.
	 * This field specify the unique software version instance to distinguish between like versions of the same software.
	 * @return ST - appointmentDuration
	 */
	public ST getSoftwareBinaryId() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1837);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ST)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Software Certified Version Or Release NO.
	 * This field specify the latest software version number of the sending system that has been compliance tested and accepted. 
	 * @return ST - softwareCertifiedVersionOrReleaseNO
	 */
	public ST getSoftwareCertifiedVersionOrReleaseNO()
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1835);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ST)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Software Install Date. 
	 * @return DTM - softwareInstallDate
	 */
	public DTM getSoftwareInstallDate() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1839);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (DTM)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Software Product Information.  
	 * @return TX - softwareProductInformation
	 */
	public TX getSoftwareProductInformation() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1838);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (TX)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Software Product Name.
	 * @return ST - softwareProductName
	 */
	public ST getSoftwareProductName() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1836);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ST)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Software Vendor Organization.  
	 * @return XON - softwareVendorOrganization
	 */
	public XON getSoftwareVendorOrganization()
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1834);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (XON)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Set the Software Vendor Organization.   
	 * @param strOrganizationName Specifies name of the specified organization.
	 * @param objOrganizationNameTypeCode 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 setSoftwareVendorOrganization(String strOrganizationName, CWE objOrganizationNameTypeCode,
			 HD objAssigningAuthority,
			String strIdentifierTypeCode, HD objAssigningFacility, String strNameRepresentationCode,
			String strOrganizationIdentifier)
	{
		XON xon  = (XON)getDataElement(1834);
		xon.setOrganizationName(strOrganizationName);
		xon.setOrganizationNameTypeCode(objOrganizationNameTypeCode);
		xon.setAssigningAuthority(objAssigningAuthority);
		xon.setIdentifierTypeCode(strIdentifierTypeCode);
		xon.setAssigningFacility(objAssigningFacility);
		xon.setNameRepresentationCode(strNameRepresentationCode);
		xon.setOrganizationIdentifier(strOrganizationIdentifier);
		setSoftwareVendorOrganization(xon);

	} 

	/**
	 * Set the Software Vendor Organization.   
	 * @param objsoftwareVendorOrganization
	 */ 
	public void setSoftwareVendorOrganization(XON objsoftwareVendorOrganization)
	{
		setDataType(1834,objsoftwareVendorOrganization);

	}

	/**
	 * Set the Software Certified Version Or Release NO.
	 * This field specify the latest software version number of the sending system that has been compliance tested and accepted.
	 * @param strSoftwareCertifiedVersionOrReleaseNO Use as SoftwareCertifiedVersionOrReleaseNO.
	 */ 
	public void setSoftwareCertifiedVersionOrReleaseNO (String strSoftwareCertifiedVersionOrReleaseNO) 
	{
		ST softwareCertifiedVersionOrReleaseN  = (ST)getDataElement(1835);
		softwareCertifiedVersionOrReleaseN.setValue(strSoftwareCertifiedVersionOrReleaseNO); 
		setSoftwareCertifiedVersionOrReleaseNO(softwareCertifiedVersionOrReleaseN);

	} 

	/** Set the Software Certified Version Or Release NO.
	 * This field specify the latest software version number of the sending system that has been compliance tested and accepted.
	 * @param objsoftwareCertifiedVersionOrReleaseN Use as SoftwareCertifiedVersionOrReleaseNO.
	 */ 
	public void setSoftwareCertifiedVersionOrReleaseNO(ST objsoftwareCertifiedVersionOrReleaseN)
	{
		setDataType(1835,objsoftwareCertifiedVersionOrReleaseN);

	}

	/**
	 * Set the Software Product Name.
	 * @param strSoftwareProductName Use as SoftwareProductName.
	 */ 
	public void setSoftwareProductName (String  strSoftwareProductName) 
	{
		ST softwareProductName  = (ST)getDataElement(1836);
		softwareProductName.setValue(strSoftwareProductName); 
		setSoftwareProductName(softwareProductName);

	} 

	/** Set the Software Product Name.
	 * @param objsoftwareProductName Use as SoftwareProductName.
	 */ 
	public void setSoftwareProductName(ST objsoftwareProductName)
	{
		setDataType(1836,objsoftwareProductName);

	}

	/**
	 * Set the Software Binary Id.
	 * Thish field specify the unique software version instance to distinguish between like versions of the same software. 
	 * @param strSoftwareBinaryId Use as SoftwareBinaryId.
	 */ 
	public void setSoftwareBinaryId (String strSoftwareBinaryId) 
	{
		ST softwareBinaryId  = (ST)getDataElement(1837);
		softwareBinaryId.setValue(strSoftwareBinaryId); 
		setSoftwareBinaryId(softwareBinaryId);

	} 

	/** Set the Software Binary Id.
	 * Thish field specify the unique software version instance to distinguish between like versions of the same software. 
	 * @param objsoftwareBinaryId Use as SoftwareBinaryId.
	 */ 
	public void setSoftwareBinaryId(ST objsoftwareBinaryId)
	{
		setDataType(1837,objsoftwareBinaryId);

	}

	/**
	 * Set the Software Product Information.
	 * @param strSoftwareProductInformation Use as SoftwareProductInformation
	 */ 
	public void setSoftwareProductInformation (String strSoftwareProductInformation) 
	{
		TX softwareProductInformation  = (TX)getDataElement(1838);
		softwareProductInformation.setValue(strSoftwareProductInformation); 
		setSoftwareProductInformation(softwareProductInformation);

	} 

	/** Set the Software Product Information.
	 * @param objsoftwareProductInformation Use as SoftwareProductInformation
	 */ 
	public void setSoftwareProductInformation(TX objsoftwareProductInformation)
	{
		setDataType(1838,objsoftwareProductInformation);

	}

	/**
	 * Set the Software Install Date.
	 * @param strTime Use as Time
	 */ 
	public void setSoftwareInstallDate (String strTime) 
	{
		DTM softwareInstallDate  = (DTM)getDataElement(1839);
		softwareInstallDate.setValue(strTime);
		setSoftwareInstallDate(softwareInstallDate);
	} 

	/** Set the Software Install Date.
	 * @param objsoftwareInstallDate
	 */ 
	public void setSoftwareInstallDate(DTM objsoftwareInstallDate)
	{
		setDataType(1839,objsoftwareInstallDate);

	}

	/**
	 * Validates HL7 Message objects .
	 * Validate method checks for validation each and every segments in side the Message object against specified message Structure. 
	 * Validation checks include optionality of segment or group.
	 * It also verifies the number of times segment or group is repeated in message.
	 * e.g 
	 * {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.
	 */
	public boolean validate() throws InvalidSegmentException
	{
		try
		{
			super.validate();
			return true;
		}
		catch(FieldMissingException ex)
		{
			throw new InvalidSegmentException(enumSegments.getValue(),ex);
		}
	}
}