gt: 		if (mos != null)
context: //#############################################################################
  //#                                                                           #
  //#  Copyright (C) <2014>  <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/>.    #
  //#                                                                           #
  //#############################################################################
  //#EOH
  // This code was generated by Florin Blindu using IMS Development Environment (version 1.80 build 4680.16533)
  // Copyright (C) 1995-2012 IMS MAXIMS. All rights reserved.
  
  package ims.clinical.forms.urinalysiscc;
  
  import java.util.ArrayList;
  
  import ims.clinical.forms.urinalysiscc.GenForm.grpAscorbicEnumeration;
  import ims.clinical.forms.urinalysiscc.GenForm.grpBilEnumeration;
  import ims.clinical.forms.urinalysiscc.GenForm.grpBloodEnumeration;
  import ims.clinical.forms.urinalysiscc.GenForm.grpGluEnumeration;
  import ims.clinical.forms.urinalysiscc.GenForm.grpKetonesEnumeration;
  import ims.clinical.forms.urinalysiscc.GenForm.grpLeucocytesEnumeration;
  import ims.clinical.forms.urinalysiscc.GenForm.grpNitrateEnumeration;
  import ims.clinical.forms.urinalysiscc.GenForm.grpProteinEnumeration;
  import ims.clinical.forms.urinalysiscc.GenForm.grpUbgEnumeration;
  import ims.core.vo.MemberOfStaffLiteVo;
  import ims.core.vo.RecordingUserInformationVo;
  import ims.core.vo.Urinalysis;
  import ims.core.vo.UrinalysisCollection;
  import ims.core.vo.lookups.UrinalysisResults;
  import ims.domain.exceptions.StaleObjectException;
  import ims.emergency.vo.enums.EdAssessment_CustomControlsEvents;
  import ims.framework.enumerations.FormMode;
  import ims.framework.exceptions.PresentationLogicException;
  import ims.framework.utils.DateTime;
  
  public class Logic extends BaseLogic
  {
  	private static final long serialVersionUID = 1L;
  
  	@Override
  	protected void onFormModeChanged()
  	{
  		updateControlState();
  	}
  
  	@Override
  	protected void onChkNoAbnormalityValueChanged() throws ims.framework.exceptions.PresentationLogicException
  	{
  		form.chkNoSample().setValue(false);
  		form.chkInactive().setValue(false);
  		form.cmbPH().setValue(null);
  		form.decSpecificGravity().setValue(null);
  		// disable inactive chk
  		form.chkInactive().setEnabled(false);
  
  		setRadioGroupDefaults();
  
  		updateControlState();
  	}
  
  	@Override
  	protected void onChkNoSampleValueChanged() throws PresentationLogicException
  	{
  		clearUrinalysis();
  		updateControlState();
  	}
  
  	private void updateControlState()
  	{
  		boolean bEnabled = form.getMode().equals(FormMode.EDIT);
  		boolean noSample = form.chkNoSample().getValue();
  		boolean noAbnormality = form.chkNoAbnormality().getValue();
  
  		form.customControlAuthoringInfo().setEnabledAuthoringHCP(bEnabled && form.getLocalContext().getSelectedUrinalysis() == null);
  		form.customControlAuthoringInfo().setEnabledDateTime(bEnabled && form.getLocalContext().getSelectedUrinalysis() == null);
  
  		form.chkNoSample().setEnabled(bEnabled);
  
  		form.grpLeucocytes().setEnabled(bEnabled && !noSample && !noAbnormality);
  		form.grpProtein().setEnabled(bEnabled && !noSample && !noAbnormality);
  		form.grpBlood().setEnabled(bEnabled && !noSample && !noAbnormality);
  		form.grpKetones().setEnabled(bEnabled && !noSample && !noAbnormality);
  		form.grpGlu().setEnabled(bEnabled && !noSample && !noAbnormality);
  		form.grpAscorbic().setEnabled(bEnabled && !noSample && !noAbnormality);
  		form.grpBil().setEnabled(bEnabled && !noSample && !noAbnormality);
  		form.grpUbg().setEnabled(bEnabled && !noSample && !noAbnormality);
  		form.grpNitrate().setEnabled(bEnabled && !noSample && !noAbnormality);
  
  		form.cmbPH().setEnabled(bEnabled && !noSample);
  		form.decSpecificGravity().setEnabled(bEnabled && !noSample);
  		form.chkInactive().setEnabled(bEnabled && !noSample);
  		form.chkNoAbnormality().setEnabled(bEnabled && !noSample);
  
  		form.btnNew().setVisible(!bEnabled);
  		form.btnNew().setEnabled(!bEnabled && Boolean.TRUE.equals(form.getLocalContext().getisEnabled()));
  
  		form.btnEdit().setVisible(!bEnabled && form.recbrAllRecords().getValue() != null);
  		form.btnEdit().setEnabled(!bEnabled && form.recbrAllRecords().getValue() != null && Boolean.TRUE.equals(form.getLocalContext().getisEnabled()));
  	}
  
  	@Override
  	protected void onFormOpen(Object[] args) throws PresentationLogicException
  	{
  		open();
  	}
  
  	public void initialize()
  	{
  		form.customControlAuthoringInfo().setIsRequiredPropertyToControls(Boolean.TRUE);
  		form.grpFilterBy().setValue(GenForm.grpFilterByEnumeration.rdoActive);
  
  		open();
  	}
  
  	private void open()
  	{
  		populateScreenFromData();
  		form.setMode(FormMode.VIEW);
  	}
  
  	private void populateScreenFromData()
  	{
  		populateRecordBrowser();
  		populateInstanceControlsFromData(form.getLocalContext().getSelectedUrinalysis());
  	}
  
  	private void populateRecordBrowser()
  	{
  		form.recbrAllRecords().clear();
  
  		if (form.getGlobalContext().Core.getCurrentCareContext() == null)
  			return;
  
  		UrinalysisCollection collUrinalysis = domain.listUrinalysisByCareContext(form.getGlobalContext().Core.getCurrentCareContext(), form.grpFilterBy().getValue().equals(GenForm.grpFilterByEnumeration.rdoActive) ? true : false);
  
  		if (collUrinalysis == null || collUrinalysis.size()==0)
  		{
  			form.getLocalContext().setSelectedUrinalysis(null);
  			return;
  		}
  
  		for (int i = 0; i < collUrinalysis.size(); i++)
  		{
  			Urinalysis urinalysis = collUrinalysis.get(i);
  
  			form.recbrAllRecords().newRow(urinalysis, (urinalysis.getAuthoringInformationIsNotNull() && urinalysis.getAuthoringInformation().getAuthoringDateTime() != null ? urinalysis.getAuthoringInformation().getAuthoringDateTime().toString() : "") + " - " + (urinalysis.getAuthoringInformationIsNotNull() && urinalysis.getAuthoringInformation().getAuthoringHcp() != null ? urinalysis.getAuthoringInformation().getAuthoringHcp().toString() : ""));
  		}
  
  		if (collUrinalysis.size() > 0 && form.getLocalContext().getSelectedUrinalysis() == null)
  		{
  			form.getLocalContext().setSelectedUrinalysis(collUrinalysis.get(0));
  		}
  		else if (collUrinalysis.size() > 0 && form.getLocalContext().getSelectedUrinalysisIsNotNull() && Boolean.FALSE.equals(form.getLocalContext().getSelectedUrinalysis().getIsActive()))
  		{
  			form.getLocalContext().setSelectedUrinalysis(collUrinalysis.get(0));
  		}
  	
  		form.recbrAllRecords().setValue(form.getLocalContext().getSelectedUrinalysis());
  	}
  
  	@Override
  	protected void onBtnSaveClick() throws PresentationLogicException
  	{
  		//WDEV-17337
  		form.getLocalContext().setSelectedEvent(EdAssessment_CustomControlsEvents.SAVE);
  		form.fireCustomControlValueChanged();
  		if (save())
  			open();
  	}
  
  	private boolean save()
  	{
  		Urinalysis urinalysisTosave = populateDataFromScreen(form.getLocalContext().getSelectedUrinalysis());
  
  		String[] errors = urinalysisTosave.validate(getUIErrors());
  
  		if (errors != null)
  		{
  			engine.showErrors("Validation Errors", errors);
  			return false;
  		}
  
  		try
  		{
  			form.getLocalContext().setSelectedUrinalysis(domain.save(urinalysisTosave));
  		}
  		catch (StaleObjectException e)
  		{
  			engine.showMessage(ims.configuration.gen.ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue());
  			open();
  			return false;
  		}
  		return true;
  	}
  	private String[] getUIErrors()
  	{
  		ArrayList<String> errors = new ArrayList<String>();
  
  		if (form.customControlAuthoringInfo().getValue()==null)
  		{
  			errors.add("Authoring Information is mandatory!");
  		}
  		
  		if (errors.size() > 0)
  		{
  			String[] UIErrors = new String[errors.size()];
  			errors.toArray(UIErrors);
  			return UIErrors;
  		}
  
  		return null;
  	}
  	
  	private Urinalysis populateDataFromScreen(Urinalysis voUrinalysis)
  	{
  		if (voUrinalysis == null)
  			voUrinalysis = new Urinalysis();
  		else
  			voUrinalysis = (Urinalysis) voUrinalysis.clone();
  
  		voUrinalysis.setCareContext(form.getGlobalContext().Core.getCurrentCareContext());
  		voUrinalysis.setClinicalContact(form.getGlobalContext().Core.getCurrentClinicalContact());
  		voUrinalysis.setAuthoringInformation(form.customControlAuthoringInfo().getValue());
  		voUrinalysis.setRecordingInformation(populateRecordingInfo(voUrinalysis.getRecordingInformation()));
  
  		voUrinalysis.setNoAbnormalityDetected(form.chkNoAbnormality().getValue());
  		voUrinalysis.setIsActive(!form.chkInactive().getValue());
  		voUrinalysis.setNoSample(form.chkNoSample().getValue());
  
  		if (form.grpLeucocytes() != null)
  			voUrinalysis.setLeucocytes(getLeucocytesID(form.grpLeucocytes().getValue()));
  
  		if (form.grpProtein() != null)
  			voUrinalysis.setProtein(getProteinID(form.grpProtein().getValue()));
  
  		if (form.grpBlood() != null)
  			voUrinalysis.setBlood(getBloodID(form.grpBlood().getValue()));
  
  		if (form.grpKetones() != null)
  			voUrinalysis.setKetones(getKetonesID(form.grpKetones().getValue()));
  
  		if (form.grpGlu() != null)
  			voUrinalysis.setGlucose(getGluID(form.grpGlu().getValue()));
  
  		if (form.grpAscorbic() != null)
  			voUrinalysis.setAscorbicAcid(getAscorbicID(form.grpAscorbic().getValue()));
  
  		if (form.grpBil() != null)
  			voUrinalysis.setBilirubin(getBilID(form.grpBil().getValue()));
  
  		if (form.grpUbg() != null)
  			voUrinalysis.setUrobilinogen(getUbgID(form.grpUbg().getValue()));
  
  		if (form.cmbPH() != null)
  			voUrinalysis.setPH(form.cmbPH().getValue());
  
  		if (form.decSpecificGravity() != null)
  			voUrinalysis.setSpecificGravity(form.decSpecificGravity().getValue());
  
  		if (form.grpNitrate().getValue() != null)
  		{
  			if (form.grpNitrate().getValue() == grpNitrateEnumeration.rdoNitratePos)
  				voUrinalysis.setNitrate(Boolean.TRUE);
  			else if (form.grpNitrate().getValue() == grpNitrateEnumeration.rdoNitrateNeg)
  				voUrinalysis.setNitrate(Boolean.FALSE);
  			else
  				// if 'No Abnormality Detected' is selected Nitrate must be cleared
  				voUrinalysis.setNitrate(null);
  		}
  
  		return voUrinalysis;
  	}
  
  	private UrinalysisResults getUbgID(grpUbgEnumeration enumUbg)
  	{
  		if (enumUbg == null)
  			return null;
  
  		if (enumUbg == grpUbgEnumeration.rdoUBGNeg)
  			return UrinalysisResults.NEGATIVE;
  
  		if (enumUbg == grpUbgEnumeration.rdoUBGPlus1)
  			return UrinalysisResults.PLUSONE;
  
  		if (enumUbg == grpUbgEnumeration.rdoUBGPlus2)
  			return UrinalysisResults.PLUSTWO;
  
  		if (enumUbg == grpUbgEnumeration.rdoUBGPlus3)
  			return UrinalysisResults.PLUSTHREE;
  
  		if (enumUbg == grpUbgEnumeration.rdoUBGPlus4)
  			return UrinalysisResults.PLUSFOUR;
  
  		if (enumUbg == grpUbgEnumeration.rdoUBGTrace)
  			return UrinalysisResults.TRACE;
  
  		return null;
  	}
  
  	private UrinalysisResults getBilID(grpBilEnumeration enumBil)
  	{
  		if (enumBil == null)
  			return null;
  
  		if (enumBil == grpBilEnumeration.rdoBILNeg)
  			return UrinalysisResults.NEGATIVE;
  
  		if (enumBil == grpBilEnumeration.rdoBILPlus)
  			return UrinalysisResults.PLUSONE;
  
  		if (enumBil == grpBilEnumeration.rdoBILPlus2)
  			return UrinalysisResults.PLUSTWO;
  
  		if (enumBil == grpBilEnumeration.rdoBILPlus3)
  			return UrinalysisResults.PLUSTHREE;
  
  		if (enumBil == grpBilEnumeration.rdoBILPlus4)
  			return UrinalysisResults.PLUSFOUR;
  
  		if (enumBil == grpBilEnumeration.rdoBILTrace)
  			return UrinalysisResults.TRACE;
  
  		return null;
  	}
  
  	private UrinalysisResults getAscorbicID(grpAscorbicEnumeration enumAscorbic)
  	{
  		if (enumAscorbic == null)
  			return null;
  
  		if (enumAscorbic == grpAscorbicEnumeration.rdoAscorbicNeg)
  			return UrinalysisResults.NEGATIVE;
  
  		if (enumAscorbic == grpAscorbicEnumeration.rdoAscorbicPlus)
  			return UrinalysisResults.PLUSONE;
  
  		if (enumAscorbic == grpAscorbicEnumeration.rdoAscorbicPlus2)
  			return UrinalysisResults.PLUSTWO;
  
  		if (enumAscorbic == grpAscorbicEnumeration.rdoAscorbicPlus3)
  			return UrinalysisResults.PLUSTHREE;
  
  		if (enumAscorbic == grpAscorbicEnumeration.rdoAscorbicPlus4)
  			return UrinalysisResults.PLUSFOUR;
  
  		if (enumAscorbic == grpAscorbicEnumeration.rdoAscorbicTrace)
  			return UrinalysisResults.TRACE;
  
  		return null;
  	}
  
  	private UrinalysisResults getGluID(grpGluEnumeration enumGlu)
  	{
  		if (enumGlu == null)
  			return null;
  
  		if (enumGlu == grpGluEnumeration.rdoGLUNeg)
  			return UrinalysisResults.NEGATIVE;
  
  		if (enumGlu == grpGluEnumeration.rdoGLUPlus1)
  			return UrinalysisResults.PLUSONE;
  
  		if (enumGlu == grpGluEnumeration.rdoGLUPlus2)
  			return UrinalysisResults.PLUSTWO;
  
  		if (enumGlu == grpGluEnumeration.rdoGLUPlus3)
  			return UrinalysisResults.PLUSTHREE;
  
  		if (enumGlu == grpGluEnumeration.rdoGLUPlus4)
  			return UrinalysisResults.PLUSFOUR;
  
  		if (enumGlu == grpGluEnumeration.rdoGLUTrace)
  			return UrinalysisResults.TRACE;
  
  		return null;
  	}
  
  	private UrinalysisResults getKetonesID(grpKetonesEnumeration enumKetones)
  	{
  		if (enumKetones == null)
  			return null;
  
  		if (enumKetones == grpKetonesEnumeration.rdoKetonesNeg)
  			return UrinalysisResults.NEGATIVE;
  
  		if (enumKetones == grpKetonesEnumeration.rdoKetonesPlus1)
  			return UrinalysisResults.PLUSONE;
  
  		if (enumKetones == grpKetonesEnumeration.rdoKetonesPlus2)
  			return UrinalysisResults.PLUSTWO;
  
  		if (enumKetones == grpKetonesEnumeration.rdoKetonesPlus3)
  			return UrinalysisResults.PLUSTHREE;
  
  		if (enumKetones == grpKetonesEnumeration.rdoKetonesPlus4)
  			return UrinalysisResults.PLUSFOUR;
  
  		if (enumKetones == grpKetonesEnumeration.rdoKetonesTrace)
  			return UrinalysisResults.TRACE;
  
  		return null;
  	}
  
  	private UrinalysisResults getBloodID(grpBloodEnumeration enumBlood)
  	{
  		if (enumBlood == null)
  			return null;
  
  		if (enumBlood == grpBloodEnumeration.rdoBloodNeg)
  			return UrinalysisResults.NEGATIVE;
  
  		if (enumBlood == grpBloodEnumeration.rdoBloodPlus1)
  			return UrinalysisResults.PLUSONE;
  
  		if (enumBlood == grpBloodEnumeration.rdoBloodPlus2)
  			return UrinalysisResults.PLUSTWO;
  
  		if (enumBlood == grpBloodEnumeration.rdoBloodPlus3)
  			return UrinalysisResults.PLUSTHREE;
  
  		if (enumBlood == grpBloodEnumeration.rdoBloodPlus4)
  			return UrinalysisResults.PLUSFOUR;
  
  		if (enumBlood == grpBloodEnumeration.rdoBloodTrace)
  			return UrinalysisResults.TRACE;
  
  		return null;
  	}
  
  	private UrinalysisResults getProteinID(grpProteinEnumeration enumProtein)
  	{
  		if (enumProtein == null)
  			return null;
  
  		if (enumProtein == grpProteinEnumeration.rdoProteinNeg)
  			return UrinalysisResults.NEGATIVE;
  
  		if (enumProtein == grpProteinEnumeration.rdoProteinPlus1)
  			return UrinalysisResults.PLUSONE;
  
  		if (enumProtein == grpProteinEnumeration.rdoProteinPlus2)
  			return UrinalysisResults.PLUSTWO;
  
  		if (enumProtein == grpProteinEnumeration.rdoProteinPlus3)
  			return UrinalysisResults.PLUSTHREE;
  
  		if (enumProtein == grpProteinEnumeration.rdoProteinPlus4)
  			return UrinalysisResults.PLUSFOUR;
  
  		if (enumProtein == grpProteinEnumeration.rdoProteinTrace)
  			return UrinalysisResults.TRACE;
  
  		return null;
  	}
  
  	private UrinalysisResults getLeucocytesID(grpLeucocytesEnumeration enumLeucocytes)
  	{
  		if (enumLeucocytes == null)
  			return null;
  
  		if (enumLeucocytes == grpLeucocytesEnumeration.rdoLeucocytesNeg)
  			return UrinalysisResults.NEGATIVE;
  
  		if (enumLeucocytes == grpLeucocytesEnumeration.rdoLeucocytesPlus1)
  			return UrinalysisResults.PLUSONE;
  
  		if (enumLeucocytes == grpLeucocytesEnumeration.rdoLeucocytesPlus2)
  			return UrinalysisResults.PLUSTWO;
  
  		if (enumLeucocytes == grpLeucocytesEnumeration.rdoLeucocytesPlus3)
  			return UrinalysisResults.PLUSTHREE;
  
  		if (enumLeucocytes == grpLeucocytesEnumeration.rdoLeucocytesPlus4)
  			return UrinalysisResults.PLUSFOUR;
  
  		if (enumLeucocytes == grpLeucocytesEnumeration.rdoLeucocytesTrace)
  			return UrinalysisResults.TRACE;
  
  		return null;
  	}
  
  	private RecordingUserInformationVo populateRecordingInfo(RecordingUserInformationVo recordingInformation)
  	{
  		if (recordingInformation == null)
  			recordingInformation = new RecordingUserInformationVo();
  
  		recordingInformation.setRecordingUser((MemberOfStaffLiteVo) form.cmbRecordingHCP().getValue());
  		recordingInformation.setRecordingDateTime(form.dtimRecordingDateTime().getValue());
  		return recordingInformation;
  	}
  
  	private void populateInstanceControlsFromData(Urinalysis voUrinalysis)
  	{
  		clearScreen();
  	
  		if (voUrinalysis == null)
  			return;
  
  		voUrinalysis = domain.getUrinalysis(voUrinalysis);
  
  		form.chkNoSample().setValue(voUrinalysis.getNoSample().booleanValue());
  		form.chkNoAbnormality().setValue(voUrinalysis.getNoAbnormalityDetected().booleanValue());
  
  		form.grpLeucocytes().setValue(populateLeucocytes(voUrinalysis.getLeucocytes()));
  		form.grpProtein().setValue(populateProtein(voUrinalysis.getProtein()));
  		form.grpBlood().setValue(populateBlood(voUrinalysis.getBlood()));
  		form.grpKetones().setValue(populateKetones(voUrinalysis.getKetones()));
  		form.grpGlu().setValue(populateGlucose(voUrinalysis.getGlucose()));
  		form.grpAscorbic().setValue(populateAscorbicAcid(voUrinalysis.getAscorbicAcid()));
  		form.grpBil().setValue(populateBilirubin(voUrinalysis.getBilirubin()));
  		form.grpUbg().setValue(populateUrobilinogen(voUrinalysis.getUrobilinogen()));
  		form.grpNitrate().setValue(populateNitrate(voUrinalysis.getNitrate()));
  
  		form.cmbPH().setValue(voUrinalysis.getPH());
  		form.decSpecificGravity().setValue(voUrinalysis.getSpecificGravity());
  
  		form.chkInactive().setValue(!voUrinalysis.getIsActive().booleanValue());
  
  		if (voUrinalysis.getAuthoringInformationIsNotNull())
  			form.customControlAuthoringInfo().setValue(voUrinalysis.getAuthoringInformation());
  		else
  			form.customControlAuthoringInfo().setValue(null);
  
  		form.cmbRecordingHCP().setValue(null);
  		form.dtimRecordingDateTime().setValue(null);
  
  		if (voUrinalysis.getRecordingInformationIsNotNull())
  		{
  			MemberOfStaffLiteVo mos = voUrinalysis.getRecordingInformation().getRecordingUser();
  			if (mos != null)
  			{
  				form.cmbRecordingHCP().newRow(mos, mos.toString());
  				form.cmbRecordingHCP().setValue(mos);
  			}
  			form.dtimRecordingDateTime().setValue(voUrinalysis.getRecordingInformation().getRecordingDateTime());
  		}
  
  	}
  
  	private void clearScreen()
  	{
  		form.customControlAuthoringInfo().setValue(null);
  		form.cmbRecordingHCP().setValue(null);
  		form.dtimRecordingDateTime().setValue(null);
  		clearUrinalysis();
  	}
  
  	private void clearUrinalysis()
  	{
  		setRadioGroupDefaults();
  
  		form.chkInactive().setValue(false);
  		form.chkNoAbnormality().setValue(false);
  		form.cmbPH().setValue(null);
  		form.decSpecificGravity().setValue(null);
  
  		// disable inactive chk
  		form.chkInactive().setEnabled(false);
  	}
  
  	private void setRadioGroupDefaults()
  	{
  		form.grpLeucocytes().setValue(null);
  		form.grpProtein().setValue(null);
  		form.grpBlood().setValue(null);
  		form.grpKetones().setValue(null);
  		form.grpGlu().setValue(null);
  		form.grpAscorbic().setValue(null);
  		form.grpBil().setValue(null);
  		form.grpUbg().setValue(null);
  		form.grpNitrate().setValue(null);
  	}
  
  	private grpGluEnumeration populateGlucose(UrinalysisResults voLookupResults)
  	{
  		if (voLookupResults == null)
  			return grpGluEnumeration.None;
  
  		if (voLookupResults.equals(UrinalysisResults.NEGATIVE))
  			return grpGluEnumeration.rdoGLUNeg;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSONE))
  			return grpGluEnumeration.rdoGLUPlus1;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSTWO))
  			return grpGluEnumeration.rdoGLUPlus2;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSTHREE))
  			return grpGluEnumeration.rdoGLUPlus3;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSFOUR))
  			return grpGluEnumeration.rdoGLUPlus4;
  
  		if (voLookupResults.equals(UrinalysisResults.TRACE))
  			return grpGluEnumeration.rdoGLUTrace;
  
  		return grpGluEnumeration.None;
  	}
  
  	private grpAscorbicEnumeration populateAscorbicAcid(UrinalysisResults voLookupResults)
  	{
  		if (voLookupResults == null)
  			return grpAscorbicEnumeration.None;
  
  		if (voLookupResults.equals(UrinalysisResults.NEGATIVE))
  			return grpAscorbicEnumeration.rdoAscorbicNeg;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSONE))
  			return grpAscorbicEnumeration.rdoAscorbicPlus;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSTWO))
  			return grpAscorbicEnumeration.rdoAscorbicPlus2;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSTHREE))
  			return grpAscorbicEnumeration.rdoAscorbicPlus3;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSFOUR))
  			return grpAscorbicEnumeration.rdoAscorbicPlus4;
  
  		if (voLookupResults.equals(UrinalysisResults.TRACE))
  			return grpAscorbicEnumeration.rdoAscorbicTrace;
  
  		return grpAscorbicEnumeration.None;
  	}
  
  	private grpBilEnumeration populateBilirubin(UrinalysisResults voLookupResults)
  	{
  		if (voLookupResults == null)
  			return grpBilEnumeration.None;
  
  		if (voLookupResults.equals(UrinalysisResults.NEGATIVE))
  			return grpBilEnumeration.rdoBILNeg;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSONE))
  			return grpBilEnumeration.rdoBILPlus;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSTWO))
  			return grpBilEnumeration.rdoBILPlus2;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSTHREE))
  			return grpBilEnumeration.rdoBILPlus3;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSFOUR))
  			return grpBilEnumeration.rdoBILPlus4;
  
  		if (voLookupResults.equals(UrinalysisResults.TRACE))
  			return grpBilEnumeration.rdoBILTrace;
  
  		return grpBilEnumeration.None;
  	}
  
  	private grpUbgEnumeration populateUrobilinogen(UrinalysisResults voLookupResults)
  	{
  		if (voLookupResults == null)
  			return grpUbgEnumeration.None;
  
  		if (voLookupResults.equals(UrinalysisResults.NEGATIVE))
  			return grpUbgEnumeration.rdoUBGNeg;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSONE))
  			return grpUbgEnumeration.rdoUBGPlus1;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSTWO))
  			return grpUbgEnumeration.rdoUBGPlus2;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSTHREE))
  			return grpUbgEnumeration.rdoUBGPlus3;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSFOUR))
  			return grpUbgEnumeration.rdoUBGPlus4;
  
  		if (voLookupResults.equals(UrinalysisResults.TRACE))
  			return grpUbgEnumeration.rdoUBGTrace;
  
  		return grpUbgEnumeration.None;
  	}
  
  	private grpKetonesEnumeration populateKetones(UrinalysisResults voLookupResults)
  	{
  		if (voLookupResults == null)
  			return grpKetonesEnumeration.None;
  
  		if (voLookupResults.equals(UrinalysisResults.NEGATIVE))
  			return grpKetonesEnumeration.rdoKetonesNeg;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSONE))
  			return grpKetonesEnumeration.rdoKetonesPlus1;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSTWO))
  			return grpKetonesEnumeration.rdoKetonesPlus2;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSTHREE))
  			return grpKetonesEnumeration.rdoKetonesPlus3;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSFOUR))
  			return grpKetonesEnumeration.rdoKetonesPlus4;
  
  		if (voLookupResults.equals(UrinalysisResults.TRACE))
  			return grpKetonesEnumeration.rdoKetonesTrace;
  
  		return grpKetonesEnumeration.None;
  	}
  
  	private grpBloodEnumeration populateBlood(UrinalysisResults voLookupResults)
  	{
  		if (voLookupResults == null)
  			return grpBloodEnumeration.None;
  
  		if (voLookupResults.equals(UrinalysisResults.NEGATIVE))
  			return grpBloodEnumeration.rdoBloodNeg;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSONE))
  			return grpBloodEnumeration.rdoBloodPlus1;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSTWO))
  			return grpBloodEnumeration.rdoBloodPlus2;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSTHREE))
  			return grpBloodEnumeration.rdoBloodPlus3;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSFOUR))
  			return grpBloodEnumeration.rdoBloodPlus4;
  
  		if (voLookupResults.equals(UrinalysisResults.TRACE))
  			return grpBloodEnumeration.rdoBloodTrace;
  
  		return grpBloodEnumeration.None;
  	}
  
  	private grpProteinEnumeration populateProtein(UrinalysisResults voLookupResults)
  	{
  		if (voLookupResults == null)
  			return grpProteinEnumeration.None;
  
  		if (voLookupResults.equals(UrinalysisResults.NEGATIVE))
  			return grpProteinEnumeration.rdoProteinNeg;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSONE))
  			return grpProteinEnumeration.rdoProteinPlus1;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSTWO))
  			return grpProteinEnumeration.rdoProteinPlus2;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSTHREE))
  			return grpProteinEnumeration.rdoProteinPlus3;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSFOUR))
  			return grpProteinEnumeration.rdoProteinPlus4;
  
  		if (voLookupResults.equals(UrinalysisResults.TRACE))
  			return grpProteinEnumeration.rdoProteinTrace;
  
  		return grpProteinEnumeration.None;
  	}
  
  	private grpLeucocytesEnumeration populateLeucocytes(UrinalysisResults voLookupResults)
  	{
  		if (voLookupResults == null)
  			return grpLeucocytesEnumeration.None;
  
  		if (voLookupResults.equals(UrinalysisResults.NEGATIVE))
  			return grpLeucocytesEnumeration.rdoLeucocytesNeg;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSONE))
  			return grpLeucocytesEnumeration.rdoLeucocytesPlus1;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSTWO))
  			return grpLeucocytesEnumeration.rdoLeucocytesPlus2;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSTHREE))
  			return grpLeucocytesEnumeration.rdoLeucocytesPlus3;
  
  		if (voLookupResults.equals(UrinalysisResults.PLUSFOUR))
  			return grpLeucocytesEnumeration.rdoLeucocytesPlus4;
  
  		if (voLookupResults.equals(UrinalysisResults.TRACE))
  			return grpLeucocytesEnumeration.rdoLeucocytesTrace;
  
  		return grpLeucocytesEnumeration.None;
  	}
  
  	private grpNitrateEnumeration populateNitrate(Boolean bStatus)
  	{
  		if (bStatus == null)
  			return grpNitrateEnumeration.None;
  
  		if (bStatus.equals(Boolean.TRUE))
  			return grpNitrateEnumeration.rdoNitratePos;
  		else if (bStatus.equals(Boolean.FALSE))
  			return grpNitrateEnumeration.rdoNitrateNeg;
  
  		return null;
  	}
  
  	@Override
  	protected void onBtnCancelClick() throws PresentationLogicException
  	{
  		//WDEV-17337
  		form.getLocalContext().setSelectedEvent(EdAssessment_CustomControlsEvents.CANCEL);
  		form.fireCustomControlValueChanged();
  		open();
  	}
  
  	@Override
  	protected void onBtnEditClick() throws PresentationLogicException
  	{
  		// get latest values for the current record to avoid SOE
  		form.getLocalContext().setSelectedUrinalysis(domain.getUrinalysis(form.getLocalContext().getSelectedUrinalysis()));
  		populateInstanceControlsFromData(form.getLocalContext().getSelectedUrinalysis());
  
  		form.chkInactive().setEnabled(true);
  
  		form.setcustomControlAuthoringInfoEnabled(false);
  
  		if (form.chkNoSample().getValue() == true)
  		{
  			form.chkNoSample().setEnabled(false);
  			onChkNoSampleValueChanged();
  		}
  		form.setMode(FormMode.EDIT);
  	}
  
  	@Override
  	protected void onBtnNewClick() throws PresentationLogicException
  	{
  		clearScreen();
  		form.customControlAuthoringInfo().initializeComponent();
  
  		form.getLocalContext().setSelectedUrinalysis(null);
  		form.chkNoSample().setValue(false);
  
  		form.setcustomControlAuthoringInfoEnabled(true);
  		Object mos = domain.getMosUser();
  