gt: 			recordID = new Integer(Connection.getValueAt(2)).intValue();
context: //#############################################################################
  //#                                                                           #
  //#  Copyright (C) <2015>  <IMS MAXIMS>                                       #
  //#                                                                           #
  //#  This program is free software: you can redistribute it and/or modify     #
  //#  it under the terms of the GNU Affero General Public License as           #
  //#  published by the Free Software Foundation, either version 3 of the       #
  //#  License, or (at your option) any later version.                          # 
  //#                                                                           #
  //#  This program is distributed in the hope that it will be useful,          #
  //#  but WITHOUT ANY WARRANTY; without even the implied warranty of           #
  //#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            #
  //#  GNU Affero General Public License for more details.                      #
  //#                                                                           #
  //#  You should have received a copy of the GNU Affero General Public License #
  //#  along with this program.  If not, see <http://www.gnu.org/licenses/>.    #
  //#                                                                           #
  //#  IMS MAXIMS provides absolutely NO GUARANTEE OF THE CLINICAL SAFTEY of    #
  //#  this program.  Users of this software do so entirely at their own risk.  #
  //#  IMS MAXIMS only ensures the Clinical Safety of unaltered run-time        #
  //#  software that it builds, deploys and maintains.                          #
  //#                                                                           #
  //#############################################################################
  //#EOH
  // Template ver. 1.0.9 - Last modified on 20/09/2004 11:20 by Marius Mihalec
  
  package ims.dto.client;
  
  public final class Onc_chdet implements ims.vo.ImsCloneable
  {
  	private Onc_chdetFilter lastGetFilter = null;
  	private final String serviceName = "ONC_CHDET";
  	private boolean listInProgress = false;
  	/**
  	 * Represents the Data Transfer Object Connection used for this client object.
  	 */ 
  	public ims.dto.Connection Connection = null;
  	/**
  	 * Represents the filter used by the current Data Transfer Object.
  	 */ 
  	public Onc_chdetFilter Filter = new Onc_chdetFilter();			
  	/**
  	 * Represents the filter used by the current Data Transfer Object to Insert/Update data.
  	 */ 
  	public Onc_chdetEditFilter EditFilter = new Onc_chdetEditFilter();
  	/**
  	 * Contains the data records for the current Data Transfer Object
  	 */ 
  	public Onc_chdetCollection DataCollection = new Onc_chdetCollection();
  
  	/**
  	 * Creates a new Onc_chdet Data Transfer Object.
  	 */ 
  	public Onc_chdet(ims.dto.Connection connection)
  	{	
  		this.Connection = connection;
  	}
  	/**
  	 * Creates a new copy of the current Data Transfer Object
  	 */
  	public Object clone()
  	{
  		return cloneObject();
  	}
  	/**
  	 * Creates a new typed copy of the current Data Transfer Object
  	 */
  	public Onc_chdet cloneObject()
  	{
  		Onc_chdet cloneObject = new Onc_chdet(Connection);
  			
  		if(Filter != null)
  			cloneObject.Filter = Filter.cloneObject();			
  					
  		if(lastGetFilter != null)
  			cloneObject.lastGetFilter = lastGetFilter.cloneObject();
  		else
  			cloneObject.lastGetFilter = null;
  				
  		for(int x = 0; x < DataCollection.count(); x++)
  		{
  			int index = cloneObject.DataCollection.add();
  			
  			cloneObject.DataCollection.get(index).Unid = DataCollection.get(x).Unid;
  			cloneObject.DataCollection.get(index).Pkey = DataCollection.get(x).Pkey;
  			cloneObject.DataCollection.get(index).Chplid = DataCollection.get(x).Chplid;
  			cloneObject.DataCollection.get(index).Rdat = DataCollection.get(x).Rdat;
  			cloneObject.DataCollection.get(index).Rtim = DataCollection.get(x).Rtim;
  			cloneObject.DataCollection.get(index).Rhcp = DataCollection.get(x).Rhcp;
  			cloneObject.DataCollection.get(index).Rusr = DataCollection.get(x).Rusr;
  			cloneObject.DataCollection.get(index).Udat = DataCollection.get(x).Udat;
  			cloneObject.DataCollection.get(index).Utim = DataCollection.get(x).Utim;
  			cloneObject.DataCollection.get(index).Uhcp = DataCollection.get(x).Uhcp;
  			cloneObject.DataCollection.get(index).Uusr = DataCollection.get(x).Uusr;
  			cloneObject.DataCollection.get(index).Cdat = DataCollection.get(x).Cdat;
  			cloneObject.DataCollection.get(index).Ctim = DataCollection.get(x).Ctim;
  			cloneObject.DataCollection.get(index).Modu = DataCollection.get(x).Modu;
  			cloneObject.DataCollection.get(index).Tstp = DataCollection.get(x).Tstp;
  			cloneObject.DataCollection.get(index).Ccs_epid = DataCollection.get(x).Ccs_epid;
  			cloneObject.DataCollection.get(index).Cyclesno = DataCollection.get(x).Cyclesno;
  			cloneObject.DataCollection.get(index).Cydate = DataCollection.get(x).Cydate;
  			cloneObject.DataCollection.get(index).Perfstat = DataCollection.get(x).Perfstat;
  			cloneObject.DataCollection.get(index).Response = DataCollection.get(x).Response;
  			cloneObject.DataCollection.get(index).Active = DataCollection.get(x).Active;
  			cloneObject.DataCollection.get(index).Cycdur = DataCollection.get(x).Cycdur;
  							
  			
  			for(int iSeqno = 0; iSeqno < DataCollection.get(x).SeqnoCollection.count(); iSeqno++)
  			{
  				int rIndex = cloneObject.DataCollection.get(index).SeqnoCollection.add();
  					
  				cloneObject.DataCollection.get(index).SeqnoCollection.get(rIndex).Seqno = DataCollection.get(x).SeqnoCollection.get(iSeqno).Seqno;
  				cloneObject.DataCollection.get(index).SeqnoCollection.get(rIndex).Dosedate = DataCollection.get(x).SeqnoCollection.get(iSeqno).Dosedate;
  				cloneObject.DataCollection.get(index).SeqnoCollection.get(rIndex).Dayno = DataCollection.get(x).SeqnoCollection.get(iSeqno).Dayno;
  				cloneObject.DataCollection.get(index).SeqnoCollection.get(rIndex).Drug = DataCollection.get(x).SeqnoCollection.get(iSeqno).Drug;
  				cloneObject.DataCollection.get(index).SeqnoCollection.get(rIndex).Adose = DataCollection.get(x).SeqnoCollection.get(iSeqno).Adose;
  				cloneObject.DataCollection.get(index).SeqnoCollection.get(rIndex).Aunitid = DataCollection.get(x).SeqnoCollection.get(iSeqno).Aunitid;
  				cloneObject.DataCollection.get(index).SeqnoCollection.get(rIndex).Aunitxt = DataCollection.get(x).SeqnoCollection.get(iSeqno).Aunitxt;
  				cloneObject.DataCollection.get(index).SeqnoCollection.get(rIndex).Ano = DataCollection.get(x).SeqnoCollection.get(iSeqno).Ano;
  				cloneObject.DataCollection.get(index).SeqnoCollection.get(rIndex).Stat = DataCollection.get(x).SeqnoCollection.get(iSeqno).Stat;
  				cloneObject.DataCollection.get(index).SeqnoCollection.get(rIndex).Med_id = DataCollection.get(x).SeqnoCollection.get(iSeqno).Med_id;
  										
  			}
  			
  		}
  		
  		return cloneObject;
  	}
  	/**
  	 * Returns the Imx version
  	 */	
  	public String getImxVersion()
  	{
  		return "$Revision: 1.1 $";
  	}
  	/**
  	 * Returns the Imx name
  	 */	
  	public String getImxName()
  	{
  		return "Onc_chdet.imx".toLowerCase();
  	}
  	/**
  	 * Returns the number of records using the specified filter. This method always returns a non null result. The ID field holds the count result (when greater or equal to zero) or the error number (when less than zero).
  	 */
  	public ims.dto.Result count()
  	{
  		ims.dto.Result reLoginResult = Connection.reLogin();
  		if(reLoginResult != null)
  			return new ims.dto.Result(reLoginResult.getMessage(), "DTO.Client.Onc_chdet.Count");
  			
  		int result = Connection.count(serviceName, encodeNASFilter());
  		if(result >= 0)
  			return new ims.dto.Result(result, "No error detected. The count result is held in the ID field", "DTO.Client.Onc_chdet.Count");
  				
  		return Connection.getLastError();				
  	}		
  	/**
  	 * Returns the list of records using the specified filter. Use maxRecords to limit the number of records returned. If the result returned is not null an error occured.
  	 */
  	public ims.dto.Result list(int maxRecords)
  	{
  		if(maxRecords <= 0)
  			return list();		
  				
  		return list(false, maxRecords);
  	}	
  	/**
  	* Returns the list of records using the specified filter. If the result returned is not null an error occured.
  	*/
  	public ims.dto.Result list()
  	{	
  		return list(true, 0);
  	}				
  	/**
  	* Returns one record using the specified filter. If the result returned is not null an error occured.
  	*/
  	public ims.dto.Result get()
  	{	
  		DataCollection.clear();
  			
  		ims.dto.Result reLoginResult = Connection.reLogin();
  		if(reLoginResult != null)
  			return new ims.dto.Result(reLoginResult.getMessage(), "DTO.Client.Onc_chdet.Get");
  			
  		ims.dto.Result result = Connection.get(serviceName, encodeNASFilter());
  		if(result != null)
  			return result;
  			
  		lastGetFilter = Filter.cloneObject();						
  		decodeNASMessageWithRepeatingGroups();		
  			
  		return null;
  	}	
  	/**
  	* Returns one record using the specified filter. If the result returned is not null an error occured.
  	*/
  	public ims.dto.Result getLast()
  	{	
  		DataCollection.clear();
  			
  		ims.dto.Result reLoginResult = Connection.reLogin();
  		if(reLoginResult != null)
  			return new ims.dto.Result(reLoginResult.getMessage(), "DTO.Client.Onc_chdet.Get");
  			
  		ims.dto.Result result = Connection.getLast(serviceName, encodeNASFilter());
  		if(result != null)
  			return result;
  			
  		lastGetFilter = Filter.cloneObject();						
  		decodeNASMessageWithRepeatingGroups();	
  			
  		return null;
  	}					
  	/**
  	* Performs data validation prior to update. If the result returned is not null an error occured.
  	*/
  	public ims.dto.Result getForUpdate()
  	{						
  		ims.dto.Result reLoginResult = Connection.reLogin();
  		if(reLoginResult != null)
  			return new ims.dto.Result(reLoginResult.getMessage(), "DTO.Client.Onc_chdet.GetForUpdate");
  							
  		if(lastGetFilter == null)	
  			return new ims.dto.Result("Last get method failed or not called", "DTO.Client.Onc_chdet.GetForUpdate");
  			
  		ims.dto.Result result = Connection.getForUpdate(serviceName, encodeNASFilter(lastGetFilter));
  		if(result != null)
  			return result;
  			
  		if(Connection.countResponseItems(Connection.getValueAt(6)) == 0)
  			return null;
  			
  		DataCollection.clear();	
  		decodeNASMessageWithRepeatingGroups();
  				
  		return new ims.dto.Result("The data was changed by another user", "DTO.Client.Onc_chdet.GetForUpdate");
  	}		
  	/**
  	* Inserts a new record. This method always returns a non null result. The ID field holds the Unique ID for the inserted record (when greater than zero) or the error number (when less than zero). If the ID is zero, the record was inserted but the server did not returned the Unique ID.
  	*/
  	public ims.dto.Result insert()
  	{
  		ims.dto.Result reLoginResult = Connection.reLogin();
  		if(reLoginResult != null)
  			return new ims.dto.Result(reLoginResult.getMessage(), "DTO.Client.Onc_chdet.Insert");
  					
  		if(DataCollection.count() == 0)
  			return new ims.dto.Result("No data to insert", "DTO.Client.Onc_chdet.Insert");
  			
  		if(DataCollection.count() > 1)
  			return new ims.dto.Result("Multiple object insert not allowed", "DTO.Client.Onc_chdet.Insert");
  			
  		ims.dto.Result result = Connection.insert(serviceName, encodeNASMessage());
  		if(result != null)
  			return result;
  					
  		int recordID = 0;
  					
  		try
  		{
  