From 9e0233bdc1eba5dc84b3e569ff2983255a99ac2f Mon Sep 17 00:00:00 2001 From: Frederico Palma Date: Mon, 13 Feb 2006 02:37:46 +0000 Subject: [PATCH] no message git-svn-id: https://svn.coded.pt/svn/SIPRP@214 bb69d46d-e84e-40c8-a05a-06db0d633741 --- trunk/siprp/FichaDataProvider.java | 35 ++++++++++++++++++++++++++++++ trunk/siprp/ficha/ExamePanel.java | 6 +++++ 2 files changed, 41 insertions(+) diff --git a/trunk/siprp/FichaDataProvider.java b/trunk/siprp/FichaDataProvider.java index f3370ced..8ccaf1ff 100644 --- a/trunk/siprp/FichaDataProvider.java +++ b/trunk/siprp/FichaDataProvider.java @@ -19,6 +19,8 @@ import com.evolute.utils.ui.search.*; import com.evolute.utils.sql.*; import com.evolute.utils.strings.*; +import siprp.data.*; + /** * * @author pars @@ -523,4 +525,37 @@ public class FichaDataProvider extends MetaProvider implements SearchExecuter { return objects; } + public Object[] getDadosUltimaMarcacao( Integer trabalhadorID ) + throws Exception + { + Select select = + new Select( new String[]{ "marcacoes_trabalhador" }, + new String[]{ "MAX( data )" }, + new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and( + new Field( "tipo" ).isEqual( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ).and( + new Field( "realizada" ).isEqual( "y" ).or( + new Field( "estado" ).isEqual( new Integer( 2 ) ) ) ) ); + Virtual2DArray array = executer.executeQuery( select ); + if( array.columnLength() == 0 || array.get( 0, 0 ) == null ) + { + return new Object[]{ null, null }; + } + Date data = ( Date ) array.get( 0, 0 ); + select = + new Select( new String[]{ "marcacoes_trabalhador" }, + new String[]{ "motivo", "id" }, + new Field( "data" ).isEqual( data ).and( + new Field( "trabalhador_id" ).isEqual( trabalhadorID ) ).and( + new Field( "tipo" ).isEqual( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ).and( + new Field( "realizada" ).isEqual( "y" ).or( + new Field( "estado" ).isEqual( new Integer( 2 ) ) ) ), + new String[]{ "id" }, null ); + array = executer.executeQuery( select ); + Integer tipo = ( Integer ) array.get( 0, 0 ); + if( tipo.intValue() == 5 ) + { + tipo = new Integer( 2 ); + } + return new Object[]{ data, tipo }; + } } diff --git a/trunk/siprp/ficha/ExamePanel.java b/trunk/siprp/ficha/ExamePanel.java index a5056a8d..af5f46d5 100644 --- a/trunk/siprp/ficha/ExamePanel.java +++ b/trunk/siprp/ficha/ExamePanel.java @@ -303,8 +303,14 @@ public class ExamePanel extends JPanel try { Integer marcacaoID = provider.getMarcacaoIDByTrabalhador( trabalhadorID ); + if( marcacaoID == null ) { + Object dadosMarcacao[] = provider.getDadosUltimaMarcacao( trabalhadorID ); + dataExamePanel.setDate( ( Date ) dadosMarcacao[ 0 ] ); + Integer tipo = ( Integer ) dadosMarcacao[ 1 ]; + int tipoValue = tipo != null ? tipo.intValue() : 0; + tipoGroup.setIntSelected( tipoValue > 0 ? tipoValue - 1 : 0 ); return; } marcacao = ( MarcacaoTrabalhadorData ) JDO.load( MarcacaoTrabalhadorData.class, marcacaoID );