/*******************************************************************************
 *  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.HD;
import cdac.medinfo.sdk.hl7282.baselibs.ST;
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;

/***
 * NSC - Application Status Change Segment.<p>
 * The NSC segment is used to inform (NMR query response) or announce (NMD unsolicited update) the start up,
 * shut down, and/or migration (to a different cpu or file server/file system) of a particular application.
 * <p>Represents an HL7 NSC message segment. 
 * This segment has the following fields:</p><p>
 * NSC-1: Application Change Type (CWE)<b>Required</b><br> 
 * NSC-2: Current CPU (ST)<b>Optional</b><br> 
 * NSC-3: Current Fileserver (ST)<b>Optional</b><br> 
 * NSC-4: Current Application (HD)<b>Optional</b><br> 
 * NSC-5: Current Facility (HD)<b>Optional</b><br> 
 * NSC-6: New CPU (ST)<b>Optional</b><br> 
 * NSC-7: New Fileserver (ST)<b>Optional</b><br> 
 * NSC-8: New Application (HD)<b>Optional</b><br> 
 * NSC-9: New Facility (HD)<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 NSC extends Segment   
{
	

	/**
	 *  Constructs the NSC segment.
	 */
	public NSC()
	{super(EnumSegments.HL7_SEG_NSC);
	}

	/**
	 * Retrieves the Application Change Type.
	 * This field contains the type of change being requested (if NMR query) or announced (if NMD unsolicited update).  
	 * @return CWE - ApplicationChangeType
	 */
	public CWE getApplicationChangeType() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1188);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (CWE)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**IS
	 * Set the Application Change Type.
	 * This field contains the type of change being requested (if NMR query) or announced (if NMD unsolicited update).  
	 * @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 setApplicationChangeType (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(1188);
		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); 
		setApplicationChangeType(cwe);

	} 

	/** Set the Application Change Type.
	 * This field contains the type of change being requested (if NMR query) or announced (if NMD unsolicited update).  
	 * @param objapplicationChangeType value of ApplicationChangeType
	 */ 
	public void setApplicationChangeType(CWE objapplicationChangeType)
	{
		setDataType(1188,objapplicationChangeType);

	}

	/**
	 * Retrieves the Current Application.
	 * This field contains a site-specific name used to identify the "current" application process for interfacing with lower level protocols.
	 * @return HD - currentApplication
	 */
	public HD getCurrentApplication() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1191);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (HD)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Set the Current Application.
	 * This field contains a site-specific name used to identify the "current" application process for interfacing with lower level protocols.
	 * @param strNamespaceID Specifies Specifies  the HL7 identifier for the user-defined table of values for this component.[Refer Table No.300]
	 * @param strUniversalID Specifies a string formatted according to the scheme defined by the component, <universal ID type> (UID type). 
	 * @param strUniversalIDType Governs the interpretation of the strUniversalId. 
	 */ 
	public void setCurrentApplication (String strNamespaceID,String strUniversalID,String strUniversalIDType) 
	{
		HD currentApplication  = (HD)getDataElement(1191);
		currentApplication.setNamespaceId(strNamespaceID);
		currentApplication.setUniversalId(strUniversalID);
		currentApplication.setUniversalIdType(strUniversalIDType); 
		setCurrentApplication(currentApplication);

	} 

	/** Set the Current Application.
	 * This field contains a site-specific name used to identify the "current" application process for interfacing with lower level protocols.
	 * @param objcurrentApplication  Current Application
	 */ 
	public void setCurrentApplication(HD objcurrentApplication)
	{
		setDataType(1191,objcurrentApplication);

	}

	/**
	 * Retrieves the Current CPU.
	 * This field contains a site-specific name for the current CPU.
	 * @return ST - currentCPU
	 */
	public ST getCurrentCPU() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1189);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ST)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Set the Current CPU.
	 * This field contains a site-specific name for the current CPU.
	 * @param strCurrentCPU The name of the party.
	 */ 
	public void setCurrentCPU (String strCurrentCPU) 
	{
		ST currentCPU  = (ST)getDataElement(1189);
		currentCPU.setValue(strCurrentCPU); 
		setCurrentCPU(currentCPU);

	} 

	/** Set the Current CPU.
	 * This field contains a site-specific name for the current CPU.
	 * @param objcurrentCPU The name of the party.
	 */ 
	public void setCurrentCPU(ST objcurrentCPU)
	{
		setDataType(1189,objcurrentCPU);

	}

	/**
	 * Retrieves the Current Facility.
	 * This field contains a site-specific name for the current facility used by this application.
	 * @return HD - currentFacility
	 */
	public HD getCurrentFacility() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1192);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (HD)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Set the Current Facility.
	 * This field contains a site-specific name for the current facility used by this application.
	 * @param strNamespaceID Specifies Specifies  the HL7 identifier for the user-defined table of values for this component.[Refer Table No.300]
	 * @param strUniversalID Specifies a string formatted according to the scheme defined by the component, <universal ID type> (UID type). 
	 * @param strUniversalIDType Governs the interpretation of the strUniversalId. 
	 */ 
	public void setCurrentFacility (String strNamespaceID,String strUniversalID,String strUniversalIDType) 
	{
		HD currentFacility  = (HD)getDataElement(1192);
		currentFacility.setNamespaceId(strNamespaceID);
		currentFacility.setUniversalId(strUniversalID);
		currentFacility.setUniversalIdType(strUniversalIDType); 
		setCurrentFacility(currentFacility);

	} 

	/** Set the Current Facility.
	 * This field contains a site-specific name for the current facility used by this application.
	 * @param objcurrentFacility Current Facility
	 */ 
	public void setCurrentFacility(HD objcurrentFacility)
	{
		setDataType(1192,objcurrentFacility);

	}

	/**
	 * Retrieves the Current Fileserver.
	 * This field contains a site specific name for the current fileserver or file system used by this application.  
	 * @return ST - currentFileserver
	 */
	public ST getCurrentFileserver() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1190);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ST)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Set the Current Fileserver.
	 * This field contains a site specific name for the current fileserver or file system used by this application. 
	 * @param strCurrentFileserver The name of the party.
	 */ 
	public void setCurrentFileserver (String strCurrentFileserver) 
	{
		ST currentFileserver  = (ST)getDataElement(1190);
		currentFileserver.setValue(strCurrentFileserver); 
		setCurrentFileserver(currentFileserver);

	} 

	/** Set the Current Fileserver.
	 * This field contains a site specific name for the current fileserver or file system used by this application. 
	 * @param objcurrentFileserver The name of the party.
	 */ 
	public void setCurrentFileserver(ST objcurrentFileserver)
	{
		setDataType(1190,objcurrentFileserver);

	}

	/**
	 * Retrieves the New Application.
	 * This field contains a site-specific name used to identify "new" application processes for interfacing with lower level protocols
	 * for interfacing with lower level protocols. 
	 * @return HD - newApplication
	 */
	public HD getNewApplication() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1195);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (HD)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Set the New Application.
	 * This field contains a site-specific name used to identify "new" application processes for interfacing with lower level protocols
	 * for interfacing with lower level protocols.
	 * @param strNamespaceID Specifies Specifies  the HL7 identifier for the user-defined table of values for this component.[Refer Table No.300]
	 * @param strUniversalID Specifies a string formatted according to the scheme defined by the component, <universal ID type> (UID type). 
	 * @param strUniversalIDType Governs the interpretation of the strUniversalId. 
	 */ 
	public void setNewApplication (String strNamespaceID,String strUniversalID,String strUniversalIDType) 
	{
		HD newApplication  = (HD)getDataElement(1195);
		newApplication.setNamespaceId(strNamespaceID);
		newApplication.setUniversalId(strUniversalID);
		newApplication.setUniversalIdType(strUniversalIDType); 
		setNewApplication(newApplication);

	} 

	/** Set the New Application.
	 * This field contains a site-specific name used to identify "new" application processes for interfacing with lower level protocols
	 * for interfacing with lower level protocols.
	 * @param objnewApplication New Application
	 */ 
	public void setNewApplication(HD objnewApplication)
	{
		setDataType(1195,objnewApplication);

	}

	/**
	 * Retrieves the New CPU.
	 * This field contains a site-specific name for the new CPU.
	 * @return ST - newCPU
	 */
	public ST getNewCPU() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1193);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ST)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Set the New CPU.
	 * This field contains a site-specific name for the new CPU.
	 * @param strNewCPU The name of the party.
	 */ 
	public void setNewCPU (String strNewCPU) 
	{
		ST newCPU  = (ST)getDataElement(1193);
		newCPU.setValue(strNewCPU); 
		setNewCPU(newCPU);

	} 

	/** Set the New CPU.
	 * This field contains a site-specific name for the new CPU.
	 * @param objnewCPU The name of the party.
	 */ 
	public void setNewCPU(ST objnewCPU)
	{
		setDataType(1193,objnewCPU);

	}

	/**
	 * Retrieves the New Facility.
	 * This field contains a site-specific name for the new facility used by this application.
	 * @return HD - newFacility
	 */
	public HD getNewFacility() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1196);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (HD)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Set the New Facility.
	 * This field contains a site-specific name for the new facility used by this application.
	 * @param strNamespaceID Specifies Specifies  the HL7 identifier for the user-defined table of values for this component.[Refer Table No.300]
	 * @param strUniversalID Specifies a string formatted according to the scheme defined by the component, <universal ID type> (UID type). 
	 * @param strUniversalIDType Governs the interpretation of the strUniversalId. 
	 */ 
	public void setNewFacility (String strNamespaceID,String strUniversalID,String strUniversalIDType) 
	{
		HD newFacility  = (HD)getDataElement(1196);
		newFacility.setNamespaceId(strNamespaceID);
		newFacility.setUniversalId(strUniversalID);
		newFacility.setUniversalIdType(strUniversalIDType); 
		setNewFacility(newFacility);

	} 

	/** Set the New Facility.
	 * This field contains a site-specific name for the new facility used by this application.
	 * @param objnewFacility New Facility
	 */ 
	public void setNewFacility(HD objnewFacility)
	{
		setDataType(1196,objnewFacility);

	}

	/**
	 * Retrieves the New Fileserver.
	 * This field contains a site-specific name for the new fileserver or file system used by this application. 
	 * @return ST - newFileserver
	 */
	public ST getNewFileserver() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1194);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ST)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Set the New Fileserver.
	 * This field contains a site-specific name for the new fileserver or file system used by this application. 
	 * @param strNewFileserver The name of the party.
	 */ 
	public void setNewFileserver (String strNewFileserver) 
	{
		ST newFileserver  = (ST)getDataElement(1194);
		newFileserver.setValue(strNewFileserver); 
		setNewFileserver(newFileserver);

	} 

	/** Set the New Fileserver.
	 * This field contains a site-specific name for the new fileserver or file system used by this application. 
	 * @param objnewFileserver The name of the party.
	 */ 
	public void setNewFileserver(ST objnewFileserver)
	{
		setDataType(1194,objnewFileserver);

	}

	/**
	 * 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
	 */
	public boolean validate() throws InvalidSegmentException
	{
		try
		{
			super.validate();

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