forked from Coded/SIPRP
git-svn-id: https://svn.coded.pt/svn/SIPRP@1365 bb69d46d-e84e-40c8-a05a-06db0d633741
parent
da1e2eb1e2
commit
c5918ecd24
@ -1,618 +0,0 @@
|
||||
/*
|
||||
* ProcessoDataProvider.java
|
||||
*
|
||||
* Created on March 20, 2007, 5:14 PM
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package siprp.medicina.processo;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Vector;
|
||||
|
||||
import siprp.MedicinaConstants;
|
||||
import siprp.ProcessoConstants;
|
||||
import siprp.data.outer.TrabalhadoresConsultasData;
|
||||
import siprp.data.outer.TrabalhadoresConsultasDatasData;
|
||||
import siprp.data.outer.TrabalhadoresEcdsData;
|
||||
import siprp.data.outer.TrabalhadoresEcdsDatasData;
|
||||
import siprp.data.outer.TrabalhadoresProcessoData;
|
||||
|
||||
import com.evolute.entity.ProviderInterface;
|
||||
import com.evolute.utils.Singleton;
|
||||
import com.evolute.utils.arrays.Virtual2DArray;
|
||||
import com.evolute.utils.data.IDObject;
|
||||
import com.evolute.utils.data.MappableObject;
|
||||
import com.evolute.utils.db.DBManager;
|
||||
import com.evolute.utils.db.Executer;
|
||||
import com.evolute.utils.sql.Assignment;
|
||||
import com.evolute.utils.sql.Expression;
|
||||
import com.evolute.utils.sql.Field;
|
||||
import com.evolute.utils.sql.Insert;
|
||||
import com.evolute.utils.sql.Select;
|
||||
import com.evolute.utils.sql.Select2;
|
||||
import com.evolute.utils.sql.Update;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fpalma
|
||||
*/
|
||||
public class ProcessoDataProvider
|
||||
implements MedicinaConstants, ProcessoConstants
|
||||
{
|
||||
private static final DateFormat D_F = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) );
|
||||
|
||||
public static final HashMap<String,String> ESTADO_PROCESSO_BY_CODE =
|
||||
new HashMap<String,String>();
|
||||
|
||||
static
|
||||
{
|
||||
ESTADO_PROCESSO_BY_CODE.put( PROCESSO_ABERTO_CODE, PROCESSO_ABERTO_DESCRIPTION );
|
||||
ESTADO_PROCESSO_BY_CODE.put( PROCESSO_FECHADO_CODE, PROCESSO_FECHADO_DESCRIPTION );
|
||||
ESTADO_PROCESSO_BY_CODE.put( PROCESSO_CANCELADO_CODE, PROCESSO_CANCELADO_DESCRIPTION );
|
||||
}
|
||||
|
||||
private static final Object LOCK = new Object();
|
||||
private static ProcessoDataProvider instance = null;
|
||||
private Executer EXECUTER;
|
||||
private ProviderInterface JDO;
|
||||
|
||||
/** Creates a new instance of ProcessoDataProvider */
|
||||
public ProcessoDataProvider()
|
||||
throws Exception
|
||||
{
|
||||
DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
|
||||
EXECUTER = dbm.getSharedExecuter( this );
|
||||
JDO = ( ProviderInterface ) Singleton.getInstance( Singleton.DEFAULT_EVO_DATA_PROVIDER );
|
||||
}
|
||||
|
||||
public static ProcessoDataProvider getProvider()
|
||||
throws Exception
|
||||
{
|
||||
synchronized( LOCK )
|
||||
{
|
||||
if( instance == null )
|
||||
{
|
||||
instance = new ProcessoDataProvider();
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public Integer[] getIDsProcessosByTrabalhador( Integer trabalhadorID )
|
||||
throws Exception
|
||||
{
|
||||
Select select =
|
||||
new Select2( new String[]{ "trabalhadores_processo" },
|
||||
new Integer[ 0 ],
|
||||
new Expression[ 0 ],
|
||||
new String[]{ "id", "data_inicio" },
|
||||
new Field( "trabalhadores_processo.trabalhador_id" ).isEqual( trabalhadorID ),
|
||||
new String[]{ "data_inicio DESC" },
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray array = EXECUTER.executeQuery( select );
|
||||
Integer ids[] = new Integer[ array.columnLength() ];
|
||||
for( int n = 0; n < ids.length; n++ )
|
||||
{
|
||||
ids[ n ] = ( Integer ) array.get( n, 0 );
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
public TrabalhadoresProcessoData getProcessoByID( Integer id )
|
||||
throws Exception
|
||||
{
|
||||
return ( TrabalhadoresProcessoData ) JDO.load( TrabalhadoresProcessoData.class, id );
|
||||
}
|
||||
|
||||
public void saveProcesso( TrabalhadoresProcessoData processo )
|
||||
throws Exception
|
||||
{
|
||||
processo.save();
|
||||
}
|
||||
|
||||
public String getDescricaoEstadoProcessoByCodigo( String codigo )
|
||||
{
|
||||
return ESTADO_PROCESSO_BY_CODE.get( codigo );
|
||||
}
|
||||
|
||||
public Object[][] getElementosProcesso( Integer processoID )
|
||||
throws Exception
|
||||
{
|
||||
Vector<Object[]> elementosVector = new Vector<Object[]>();
|
||||
|
||||
Select select =
|
||||
new Select2( new String[]{ "trabalhadores_ecds" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "id", "data", "estado", "" + TIPO_ECDS },
|
||||
new Field( "processo_id" ).isEqual( processoID ),
|
||||
new String[]{ "data", "id" },
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray array = EXECUTER.executeQuery( select );
|
||||
elementosVector.addAll( Arrays.asList( array.getObjects() ) );
|
||||
|
||||
select =
|
||||
new Select2( new String[]{ "trabalhadores_consultas" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "id", "data", "estado", "" + TIPO_CONSULTA },
|
||||
new Field( "processo_id" ).isEqual( processoID ),
|
||||
new String[]{ "data", "id" },
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
array = EXECUTER.executeQuery( select );
|
||||
elementosVector.addAll( Arrays.asList( array.getObjects() ) );
|
||||
|
||||
select =
|
||||
new Select2( new String[]{ "trabalhadores_fichas_aptidao", "exames" },
|
||||
new Integer[]{ Select2.JOIN_INNER },
|
||||
new Expression[]{ new Field( "trabalhadores_fichas_aptidao.exame_id" ).isEqual( new Field( "exames.id" ) ) },
|
||||
new String[]{ "exames.id", "exames.data", "resultado", "" + TIPO_FICHA_APTIDAO },
|
||||
new Field( "trabalhadores_fichas_aptidao.processo_id" ).isEqual( processoID ).and(
|
||||
new Field( "exames.inactivo" ).isDifferent( "y" ) ),
|
||||
new String[]{ "exames.data", "exames.id" },
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
array = EXECUTER.executeQuery( select );
|
||||
elementosVector.addAll( Arrays.asList( array.getObjects() ) );
|
||||
|
||||
Object elementos[][] = elementosVector.toArray( new Object[ elementosVector.size() ][] );
|
||||
Arrays.sort( elementos, new Comparator< Object >(){
|
||||
public int compare( Object o1, Object o2 )
|
||||
{
|
||||
return ( (Date)( ( Object[] ) o1 )[ 1 ] ).compareTo( ( (Date)( ( Object[] ) o2 )[ 1 ] ) );
|
||||
}
|
||||
} );
|
||||
return elementos;
|
||||
}
|
||||
|
||||
public Object[][] getDatasConsulta( Integer consultaID )
|
||||
throws Exception
|
||||
{
|
||||
Select select =
|
||||
new Select2( new String[]{ "trabalhadores_consultas_datas" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "id", "data", "prestador_id", "estado" },
|
||||
new Field( "trabalhadores_consultas_id" ).isEqual( consultaID ),
|
||||
new String[]{ "data DESC" },
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray array = EXECUTER.executeQuery( select );
|
||||
return array.getObjects();
|
||||
}
|
||||
|
||||
public Object[][] getDatasECDs( Integer consultaID )
|
||||
throws Exception
|
||||
{
|
||||
Select select =
|
||||
new Select2( new String[]{ "trabalhadores_ecds_datas" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "id", "data", "estado" },
|
||||
new Field( "consulta_id" ).isEqual( consultaID ),
|
||||
new String[]{ "data DESC" },
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray array = EXECUTER.executeQuery( select );
|
||||
return array.getObjects();
|
||||
}
|
||||
|
||||
public IDObject getObservacoesConsultaData( Integer consultaDataID )
|
||||
throws Exception
|
||||
{
|
||||
Select select =
|
||||
new Select2( new String[]{ "trabalhadores_consultas_datas_observacoes" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "id", "observacao" },
|
||||
new Field( "trabalhadores_consultas_datas_id" ).isEqual( consultaDataID ),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray array = EXECUTER.executeQuery( select );
|
||||
if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new MappableObject( ( Integer ) array.get( 0, 0 ), ( String ) array.get( 0, 1 ) );
|
||||
}
|
||||
}
|
||||
|
||||
public void saveObservacoesConsultaData( Integer consultaDataID, String observacao )
|
||||
throws Exception
|
||||
{
|
||||
IDObject observacaoAntiga = getObservacoesConsultaData( consultaDataID );
|
||||
if( observacaoAntiga != null )
|
||||
{
|
||||
Update update =
|
||||
new Update( "trabalhadores_consultas_datas_observacoes",
|
||||
new Assignment[]{
|
||||
new Assignment( "observacao", observacao ) },
|
||||
new Field( "id" ).isEqual( observacaoAntiga.getID() ) );
|
||||
EXECUTER.executeQuery( update );
|
||||
}
|
||||
else
|
||||
{
|
||||
Insert insert =
|
||||
new Insert( "trabalhadores_consultas_datas_observacoes",
|
||||
new Assignment[]{
|
||||
new Assignment( "observacao", observacao ),
|
||||
new Assignment( "trabalhadores_consultas_datas_id", consultaDataID ) } );
|
||||
EXECUTER.executeQuery( insert );
|
||||
}
|
||||
}
|
||||
|
||||
public IDObject[] getEmailConsultaData( Integer consultaDataID )
|
||||
throws Exception
|
||||
{
|
||||
Select select =
|
||||
new Select2( new String[]{ "trabalhadores_consultas_datas_emails" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "id", "data", "subject" },
|
||||
new Field( "trabalhadores_consultas_datas_id" ).isEqual( consultaDataID ),
|
||||
new String[]{ "data DESC" },
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray array = EXECUTER.executeQuery( select );
|
||||
IDObject mails[] = new IDObject[ array.columnLength() ];
|
||||
for( int n = 0; n < mails.length; n++ )
|
||||
{
|
||||
Date data = ( Date ) array.get( n, 1 );
|
||||
String desc = D_F.format( data ) + " : " + array.get( n, 2 );
|
||||
mails[ n ] = new MappableObject( ( Integer ) array.get( n, 0 ), desc );
|
||||
}
|
||||
return mails;
|
||||
}
|
||||
|
||||
public void saveEmailConsultaData( Integer consultaDataID, String destination,
|
||||
String subject, String body )
|
||||
throws Exception
|
||||
{
|
||||
Insert insert =
|
||||
new Insert( "trabalhadores_consultas_datas_emails",
|
||||
new Assignment[]{
|
||||
new Assignment( "destination", destination ),
|
||||
new Assignment( "subject", subject ),
|
||||
new Assignment( "body", body ),
|
||||
new Assignment( "data", new Date() ),
|
||||
new Assignment( "trabalhadores_consultas_datas_id", consultaDataID ) } );
|
||||
EXECUTER.executeQuery( insert );
|
||||
}
|
||||
|
||||
public Integer getLastConsultaDataIDForConsulta( Integer consultaID )
|
||||
throws Exception
|
||||
{
|
||||
Select select =
|
||||
new Select2( new String[]{ "trabalhadores_consultas_datas" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "MAX( id )" },
|
||||
new Field( "trabalhadores_consultas_id" ).isEqual( consultaID ),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray array = EXECUTER.executeQuery( select );
|
||||
if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ( Integer ) array.get( 0, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
public IDObject getObservacoesECDsData( Integer ecdsDataID )
|
||||
throws Exception
|
||||
{
|
||||
Select select =
|
||||
new Select2( new String[]{ "trabalhadores_consultas_datas_observacoes" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "id", "observacao" },
|
||||
new Field( "trabalhadores_ecds_datas_id" ).isEqual( ecdsDataID ),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray array = EXECUTER.executeQuery( select );
|
||||
if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new MappableObject( ( Integer ) array.get( 0, 0 ), ( String ) array.get( 0, 1 ) );
|
||||
}
|
||||
}
|
||||
|
||||
public void saveObservacoesECDsData( Integer ecdsDataID, String observacao )
|
||||
throws Exception
|
||||
{
|
||||
IDObject observacaoAntiga = getObservacoesECDsData( ecdsDataID );
|
||||
if( observacaoAntiga != null )
|
||||
{
|
||||
Update update =
|
||||
new Update( "trabalhadores_ecds_datas_observacoes",
|
||||
new Assignment[]{
|
||||
new Assignment( "observacao", observacao ) },
|
||||
new Field( "id" ).isEqual( observacaoAntiga.getID() ) );
|
||||
EXECUTER.executeQuery( update );
|
||||
}
|
||||
else
|
||||
{
|
||||
Insert insert =
|
||||
new Insert( "trabalhadores_ecds_datas_observacoes",
|
||||
new Assignment[]{
|
||||
new Assignment( "observacao", observacao ),
|
||||
new Assignment( "trabalhadores_ecds_datas_id", ecdsDataID ) } );
|
||||
EXECUTER.executeQuery( insert );
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getLastECDsDataIDForECDs( Integer ecdsID )
|
||||
throws Exception
|
||||
{
|
||||
Select select =
|
||||
new Select2( new String[]{ "trabalhadores_ecds_datas" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "MAX( id )" },
|
||||
new Field( "trabalhadores_ecds_id" ).isEqual( ecdsID ),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray array = EXECUTER.executeQuery( select );
|
||||
if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ( Integer ) array.get( 0, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getProcessoTemConsultasPorRealizar( Integer processoID )
|
||||
throws Exception
|
||||
{
|
||||
Select select =
|
||||
new Select2( new String[]{ "trabalhadores_consultas" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "id", "estado" },
|
||||
new Field( "processo_id" ).isEqual( processoID ),
|
||||
new String[]{ "estado" },
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray array = EXECUTER.executeQuery( select );
|
||||
return ( array.columnLength() > 0 ) && ( new Integer( ESTADO_POR_REALIZAR ).equals( array.get( 0, 1 ) ) );
|
||||
}
|
||||
|
||||
public boolean getProcessoTemECDsPorRealizar( Integer processoID )
|
||||
throws Exception
|
||||
{
|
||||
Select select =
|
||||
new Select2( new String[]{ "trabalhadores_ecds" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "id", "estado" },
|
||||
new Field( "processo_id" ).isEqual( processoID ),
|
||||
new String[]{ "estado" },
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray array = EXECUTER.executeQuery( select );
|
||||
return ( array.columnLength() > 0 ) && ( new Integer( ESTADO_POR_REALIZAR ).equals( array.get( 0, 1 ) ) );
|
||||
}
|
||||
|
||||
public Integer[] getConsultaIDsForProcesso( Integer processoID )
|
||||
throws Exception
|
||||
{
|
||||
Select select =
|
||||
new Select2( new String[]{ "trabalhadores_consultas" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "id" },
|
||||
new Field( "processo_id" ).isEqual( processoID ),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray array = EXECUTER.executeQuery( select );
|
||||
Integer ids[] = new Integer[ array.columnLength() ];
|
||||
for( int n = 0; n < ids.length; n++ )
|
||||
{
|
||||
ids[ n ] = ( Integer ) array.get( n, 0 );
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
public Integer[] getECDsIDsForProcesso( Integer processoID )
|
||||
throws Exception
|
||||
{
|
||||
Select select =
|
||||
new Select2( new String[]{ "trabalhadores_ecds" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "id" },
|
||||
new Field( "processo_id" ).isEqual( processoID ),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray array = EXECUTER.executeQuery( select );
|
||||
Integer ids[] = new Integer[ array.columnLength() ];
|
||||
for( int n = 0; n < ids.length; n++ )
|
||||
{
|
||||
ids[ n ] = ( Integer ) array.get( n, 0 );
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
public Integer getConsultaEmAbertoForProcesso( Integer processoID )
|
||||
throws Exception
|
||||
{
|
||||
Select select =
|
||||
new Select2( new String[]{ "trabalhadores_consultas" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "id" },
|
||||
new Field( "processo_id" ).isEqual( processoID ).and(
|
||||
new Field( "estado" ).isDifferent( new Integer( ESTADO_REALIZADO ) ) ),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray array = EXECUTER.executeQuery( select );
|
||||
if( array.columnLength() == 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ( Integer ) array.get( 0, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getECDsEmAbertoForProcesso( Integer processoID )
|
||||
throws Exception
|
||||
{
|
||||
Select select =
|
||||
new Select2( new String[]{ "trabalhadores_ecds" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "id" },
|
||||
new Field( "processo_id" ).isEqual( processoID ).and(
|
||||
new Field( "estado" ).isDifferent( new Integer( ESTADO_POR_REALIZAR ) ) ),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray array = EXECUTER.executeQuery( select );
|
||||
if( array.columnLength() == 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ( Integer ) array.get( 0, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
public TrabalhadoresConsultasData getConsultaByID( Integer id )
|
||||
throws Exception
|
||||
{
|
||||
return ( TrabalhadoresConsultasData ) JDO.load( TrabalhadoresConsultasData.class, id );
|
||||
}
|
||||
|
||||
public void saveConsulta( TrabalhadoresConsultasData consulta )
|
||||
throws Exception
|
||||
{
|
||||
consulta.save();
|
||||
}
|
||||
|
||||
public TrabalhadoresConsultasDatasData getConsultaDataByID( Integer id )
|
||||
throws Exception
|
||||
{
|
||||
return ( TrabalhadoresConsultasDatasData ) JDO.load( TrabalhadoresConsultasDatasData.class, id );
|
||||
}
|
||||
|
||||
public void saveConsultaData( TrabalhadoresConsultasDatasData consultaData )
|
||||
throws Exception
|
||||
{
|
||||
consultaData.save();
|
||||
}
|
||||
|
||||
public TrabalhadoresEcdsData getEcdsByID( Integer id )
|
||||
throws Exception
|
||||
{
|
||||
return ( TrabalhadoresEcdsData ) JDO.load( TrabalhadoresEcdsData.class, id );
|
||||
}
|
||||
|
||||
public void saveEcds( TrabalhadoresEcdsData ecds )
|
||||
throws Exception
|
||||
{
|
||||
ecds.save();
|
||||
}
|
||||
|
||||
public TrabalhadoresEcdsDatasData getEcdsDataByID( Integer id )
|
||||
throws Exception
|
||||
{
|
||||
return ( TrabalhadoresEcdsDatasData ) JDO.load( TrabalhadoresEcdsDatasData.class, id );
|
||||
}
|
||||
|
||||
public void saveEcdsData( TrabalhadoresEcdsDatasData EcdsData )
|
||||
throws Exception
|
||||
{
|
||||
EcdsData.save();
|
||||
}
|
||||
|
||||
public boolean verificarDataValidaForConsulta( Integer consultaID, Date data )
|
||||
throws Exception
|
||||
{
|
||||
Select select =
|
||||
new Select2( new String[]{ "trabalhadores_consultas_datas" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "id" },
|
||||
new Field( "trabalhadores_consultas_id" ).isEqual( consultaID ).and(
|
||||
new Field( "estado" ).isDifferent( new Integer( ESTADO_POR_REALIZAR ) ) ).and(
|
||||
new Field( "data" ).isGreater( data ) ),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray array = EXECUTER.executeQuery( select );
|
||||
return array.columnLength() == 0;
|
||||
}
|
||||
|
||||
public boolean verificarDataValidaForECDs( Integer ecdsID, Date data )
|
||||
throws Exception
|
||||
{
|
||||
Select select =
|
||||
new Select2( new String[]{ "trabalhadores_ecds_datas" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "id" },
|
||||
new Field( "trabalhadores_ecdss_id" ).isEqual( ecdsID ).and(
|
||||
new Field( "estado" ).isDifferent( new Integer( ESTADO_POR_REALIZAR ) ) ).and(
|
||||
new Field( "data" ).isGreater( data ) ),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray array = EXECUTER.executeQuery( select );
|
||||
return array.columnLength() == 0;
|
||||
}
|
||||
|
||||
public void saveLigacaoProcessoFichaAptidao( Integer processoID, Integer fichaID )
|
||||
throws Exception
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
package siprp.medicina.processo.database;
|
||||
|
||||
public class MedicinaProcessoDAO
|
||||
{
|
||||
|
||||
}
|
||||
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* ConsultaMutableTreeNode.java
|
||||
*
|
||||
* Created on 29 de Abril de 2007, 19:31
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package siprp.medicina.processo.estrutura;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Arrays;
|
||||
|
||||
import siprp.MedicinaConstants;
|
||||
import siprp.data.outer.TrabalhadoresConsultasData;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Frederico
|
||||
*/
|
||||
public class ConsultaMutableTreeNode extends MarcacaoMutableTreeNode
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final String ICON_PATH = "siprp/medicina/processo/estrutura/icons/consulta.png";
|
||||
|
||||
/** Creates a new instance of ConsultaMutableTreeNode */
|
||||
public ConsultaMutableTreeNode( TrabalhadoresConsultasData userObject )
|
||||
{
|
||||
super( userObject );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getColor()
|
||||
{
|
||||
Integer[] markedEstados = new Integer[]
|
||||
{
|
||||
MedicinaConstants.ESTADO_POR_MARCAR,
|
||||
MedicinaConstants.ESTADO_POR_REALIZAR,
|
||||
MedicinaConstants.ESTADO_PARCIALMENTE_REALIZADO
|
||||
};
|
||||
if(userObject != null && Arrays.asList( markedEstados ).contains( ((TrabalhadoresConsultasData)userObject).getEstado()))
|
||||
{
|
||||
return Color.RED;
|
||||
}
|
||||
return Color.BLACK;
|
||||
}
|
||||
|
||||
protected String getIconPath()
|
||||
{
|
||||
return ICON_PATH;
|
||||
}
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* DataMutableTreeNode.java
|
||||
*
|
||||
* Created on 29 de Abril de 2007, 19:32
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package siprp.medicina.processo.estrutura;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Frederico
|
||||
*/
|
||||
public class DataMutableTreeNode extends EstruturaProcessoMutableTreeNode
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final String ICON_PATH = "siprp/medicina/processo/estrutura/icons/data.png";
|
||||
|
||||
/** Creates a new instance of DataMutableTreeNode */
|
||||
public DataMutableTreeNode( Object userObject )
|
||||
{
|
||||
super( userObject );
|
||||
}
|
||||
|
||||
protected String getIconPath()
|
||||
{
|
||||
return ICON_PATH;
|
||||
}
|
||||
}
|
||||
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* ECDsMutableTreeNode.java
|
||||
*
|
||||
* Created on 29 de Abril de 2007, 19:31
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package siprp.medicina.processo.estrutura;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Arrays;
|
||||
|
||||
import siprp.MedicinaConstants;
|
||||
import siprp.data.outer.TrabalhadoresEcdsData;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Frederico
|
||||
*/
|
||||
public class ECDsMutableTreeNode extends MarcacaoMutableTreeNode
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final String ICON_PATH = "siprp/medicina/processo/estrutura/icons/ecds.png";
|
||||
|
||||
/** Creates a new instance of ECDsMutableTreeNode */
|
||||
public ECDsMutableTreeNode( TrabalhadoresEcdsData userObject )
|
||||
{
|
||||
super( userObject );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getColor()
|
||||
{
|
||||
Integer[] markedEstados = new Integer[]
|
||||
{
|
||||
MedicinaConstants.ESTADO_POR_MARCAR,
|
||||
MedicinaConstants.ESTADO_POR_REALIZAR,
|
||||
MedicinaConstants.ESTADO_PARCIALMENTE_REALIZADO
|
||||
};
|
||||
if(userObject != null && Arrays.asList( markedEstados ).contains( ((TrabalhadoresEcdsData)userObject).getEstado()))
|
||||
{
|
||||
return Color.RED;
|
||||
}
|
||||
return Color.BLACK;
|
||||
}
|
||||
|
||||
protected String getIconPath()
|
||||
{
|
||||
return ICON_PATH;
|
||||
}
|
||||
}
|
||||
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* EstruturaProcessoMutableTreeNode.java
|
||||
*
|
||||
* Created on 29 de Abril de 2007, 18:57
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package siprp.medicina.processo.estrutura;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
|
||||
import com.evolute.utils.error.ErrorLogger;
|
||||
import com.evolute.utils.images.ImageIconLoader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Frederico
|
||||
*/
|
||||
abstract public class EstruturaProcessoMutableTreeNode extends DefaultMutableTreeNode
|
||||
{
|
||||
protected Icon icon = null;
|
||||
protected Color color = null;
|
||||
|
||||
|
||||
/** Creates a new instance of EstruturaProcessoMutableTreeNode */
|
||||
public EstruturaProcessoMutableTreeNode( Object userObject )
|
||||
{
|
||||
super( userObject );
|
||||
}
|
||||
|
||||
abstract protected String getIconPath();
|
||||
|
||||
public Icon getIcon()
|
||||
{
|
||||
loadIcon();
|
||||
return icon;
|
||||
}
|
||||
|
||||
public Color getColor()
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
||||
protected void loadIcon()
|
||||
{
|
||||
if( icon == null && getIconPath() != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
icon = ImageIconLoader.loadImageIcon( getIconPath() );
|
||||
}
|
||||
catch( Exception ex )
|
||||
{
|
||||
ErrorLogger.logException( ex );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,421 +0,0 @@
|
||||
///*
|
||||
// * EstruturaProcessoPanel.java
|
||||
// *
|
||||
// * Created on March 20, 2007, 12:07 PM
|
||||
// *
|
||||
// * To change this template, choose Tools | Template Manager
|
||||
// * and open the template in the editor.
|
||||
// */
|
||||
//
|
||||
package siprp.medicina.processo.estrutura;
|
||||
//
|
||||
//import com.evolute.utils.data.IDObject;
|
||||
//import com.evolute.utils.ui.DialogException;
|
||||
//import java.awt.*;
|
||||
//import java.text.DateFormat;
|
||||
//import java.util.Arrays;
|
||||
//import java.util.Date;
|
||||
//import java.util.Enumeration;
|
||||
//import java.util.HashMap;
|
||||
//import java.util.Locale;
|
||||
//import java.util.Vector;
|
||||
//import javax.swing.*;
|
||||
//import javax.swing.event.TreeSelectionEvent;
|
||||
//import javax.swing.event.TreeSelectionListener;
|
||||
//import javax.swing.tree.DefaultMutableTreeNode;
|
||||
//import javax.swing.tree.DefaultTreeModel;
|
||||
//import javax.swing.tree.TreePath;
|
||||
//import siprp.medicina.MedicinaConstants;
|
||||
//import siprp.medicina.MedicinaDataProvider;
|
||||
//import siprp.medicina.processo.*;
|
||||
//import siprp.medicina.processo.data.TrabalhadoresConsultasData;
|
||||
//import siprp.medicina.processo.data.TrabalhadoresProcessoData;
|
||||
//
|
||||
///**
|
||||
// *
|
||||
// * @author fpalma
|
||||
// */
|
||||
//public class EstruturaProcessoPanel extends JPanel
|
||||
// implements TreeSelectionListener
|
||||
//{
|
||||
// protected static final DateFormat D_F = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) );
|
||||
//
|
||||
// protected JScrollPane mainScroll;
|
||||
// protected TrabalhadorMutableTreeNode rootNode;
|
||||
// protected JTree mainTree;
|
||||
//
|
||||
// protected ProcessoDataProvider provider;
|
||||
//
|
||||
// protected IDObject trabalhador;
|
||||
// protected final HashMap<Integer, TrabalhadoresProcessoData> PROCESSOS_POR_ID =
|
||||
// new HashMap<Integer,TrabalhadoresProcessoData>();
|
||||
//
|
||||
// private final Vector<ProcessoListener> PROCESSO_LISTENERS = new Vector<ProcessoListener>();
|
||||
//
|
||||
// /** Creates a new instance of EstruturaProcessoPanel */
|
||||
// public EstruturaProcessoPanel()
|
||||
// throws Exception
|
||||
// {
|
||||
// provider = ProcessoDataProvider.getProvider();
|
||||
// setupComponents();
|
||||
//// setTrabalhador( new MappableObject( new Integer( 12 ), "Alexandre de Matos Monge" ) );
|
||||
// }
|
||||
//
|
||||
// private void setupComponents()
|
||||
// {
|
||||
// mainScroll = new JScrollPane();
|
||||
// mainScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED );
|
||||
// mainScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED );
|
||||
//// rootNode = new DefaultMutableTreeNode( new MappableObject( new Integer( 12 ), "Frederico Palma" ) );
|
||||
// rootNode = new TrabalhadorMutableTreeNode( new Integer( -1 ), "" );
|
||||
// mainTree = new JTree( rootNode );
|
||||
// mainTree.addTreeSelectionListener( this );
|
||||
// mainTree.setCellRenderer( new EstruturaProcessoRenderer() );
|
||||
// mainScroll.setViewportView( mainTree );
|
||||
// setLayout( new GridLayout( 1, 1 ) );
|
||||
// add( mainScroll );
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public void setTrabalhador( IDObject trabalhador )
|
||||
// {
|
||||
// clear();
|
||||
// if( trabalhador == null )
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// this.trabalhador = trabalhador;
|
||||
//// rootNode.removeAllChildren();
|
||||
//// PROCESSOS_POR_ID.clear();
|
||||
// rootNode.setID( trabalhador.getID() );
|
||||
// rootNode.setDescricao( trabalhador.toString() );
|
||||
// DefaultMutableTreeNode nodes[] =
|
||||
// loadProcessos( trabalhador.getID() );
|
||||
// rootNode.add( criarProcessoVazio() );
|
||||
// for( int n = 0; n < nodes.length; n++ )
|
||||
// {
|
||||
// rootNode.add( nodes[ n ] );
|
||||
// }
|
||||
// int count = mainTree.getRowCount();
|
||||
// for( int n = count - 1; n >= 0; n-- )
|
||||
// {
|
||||
// mainTree.expandRow( n );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// protected DefaultMutableTreeNode[] loadProcessos( Integer trabalhadorID )
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// Integer ids[] = provider.getIDsProcessosByTrabalhador( trabalhadorID );
|
||||
// DefaultMutableTreeNode nodes[] = new DefaultMutableTreeNode[ ids.length ];
|
||||
// for( int n = 0; n < ids.length; n++ )
|
||||
// {
|
||||
// nodes[ n ] = loadProcesso( ids[ n ], null );
|
||||
// }
|
||||
////System.out.println( "nl: " + nodes.length );
|
||||
// return nodes;
|
||||
// }
|
||||
// catch( Exception ex )
|
||||
// {
|
||||
// DialogException.showExceptionMessage( ex, "Erro a carregar dados", true );
|
||||
// return new DefaultMutableTreeNode[ 0 ];
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// protected ProcessoMutableTreeNode loadProcesso( Integer id, ProcessoMutableTreeNode node )
|
||||
// throws Exception
|
||||
// {
|
||||
// TrabalhadoresProcessoData processo = provider.getProcessoByID( id );
|
||||
// Date dataInicio = ( Date ) processo.get( TrabalhadoresProcessoData.DATA_INICIO );
|
||||
// Date dataFim = ( Date ) processo.get( TrabalhadoresProcessoData.DATA_FIM );
|
||||
// String codigoEstado = ( String ) processo.get( TrabalhadoresProcessoData.ESTADO );
|
||||
// String estado = provider.getDescricaoEstadoProcessoByCodigo( codigoEstado );
|
||||
// String desc = D_F.format( dataInicio );
|
||||
// Integer motivo = ( Integer ) processo.get( TrabalhadoresProcessoData.MOTIVO );
|
||||
// desc += ": " + MedicinaDataProvider.MOTIVOS_BY_ID.get( motivo ) + " : " + estado;
|
||||
// PROCESSOS_POR_ID.put( id, processo );
|
||||
// ProcessoMutableTreeNode processoNode;
|
||||
// if( node == null )
|
||||
// {
|
||||
// processoNode = new ProcessoMutableTreeNode( id, desc );
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// processoNode = node;
|
||||
// processoNode.setID( id );
|
||||
// processoNode.setDescricao( desc );
|
||||
// }
|
||||
// processoNode.removeAllChildren();
|
||||
// MarcacaoMutableTreeNode marcacoes[] = loadMarcacoes( id );
|
||||
//// processoNode.add( new ECDsMutableTreeNode( new Integer( 35 ), "ECDS de 2006/01/01 : Realizado" ) );
|
||||
// for( int n = 0; n < marcacoes.length; n++ )
|
||||
// {
|
||||
// processoNode.add( marcacoes[ n ] );
|
||||
// }
|
||||
//
|
||||
//// processoNode.add( new FichaAptidaoMutableTreeNode( new Integer( 35 ), "Ficha de Aptid\u00e3o de 2006/01/01 : Apto" ) );
|
||||
// ( ( DefaultTreeModel ) mainTree.getModel() ).nodeStructureChanged( processoNode );
|
||||
// return processoNode;
|
||||
// }
|
||||
//
|
||||
// public MarcacaoMutableTreeNode[] loadMarcacoes( Integer processoID )
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// Integer consultaIDs[] = provider.getConsultaIDsForProcesso( processoID );
|
||||
// Vector<MarcacaoMutableTreeNode> nodesVector = new Vector<MarcacaoMutableTreeNode>();
|
||||
// for( int n = 0; n < consultaIDs.length; n++ )
|
||||
// {
|
||||
// nodesVector.add( loadConsulta( consultaIDs[ n ], null ) );
|
||||
// }
|
||||
//
|
||||
// MarcacaoMutableTreeNode nodes[] = nodesVector.toArray( new MarcacaoMutableTreeNode[ nodesVector.size() ] );
|
||||
// Arrays.sort( nodes );
|
||||
// return nodes;
|
||||
// }
|
||||
// catch( Exception ex )
|
||||
// {
|
||||
// DialogException.showExceptionMessage( ex, "Erro a carregar dados", true );
|
||||
// return new MarcacaoMutableTreeNode[ 0 ];
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public ConsultaMutableTreeNode loadConsulta( Integer id, ConsultaMutableTreeNode node )
|
||||
// throws Exception
|
||||
// {
|
||||
// TrabalhadoresConsultasData consulta = provider.getConsultaByID( id );
|
||||
// Date data = ( Date ) consulta.get( TrabalhadoresConsultasData.DATA );
|
||||
// Integer estado = ( Integer ) consulta.get( TrabalhadoresConsultasData.ESTADO );
|
||||
// String estadoStr = MedicinaConstants.ESTADOS_CONSULTA_STR[ estado != null ? estado.intValue() : 0 ];
|
||||
//
|
||||
// String desc = "Consulta de " + ( data != null ? D_F.format( data ) : "--" );
|
||||
// desc += ": " + estadoStr;
|
||||
// ConsultaMutableTreeNode consultaNode;
|
||||
// if( node == null )
|
||||
// {
|
||||
// consultaNode = new ConsultaMutableTreeNode( id, desc );
|
||||
// consultaNode.setData( data );
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// consultaNode = node;
|
||||
// consultaNode.setID( id );
|
||||
// consultaNode.setDescricao( desc );
|
||||
// consultaNode.setData( data );
|
||||
// }
|
||||
// consultaNode.removeAllChildren();
|
||||
// Object datas[][] = provider.getDatasConsulta( id );
|
||||
// for( int n = 0; n < datas.length; n++ )
|
||||
// {
|
||||
// Integer dataID = ( Integer ) datas[ n ][ 0 ];
|
||||
// Date dataData = ( Date ) datas[ n ][ 1 ];
|
||||
// Integer dataEstado = ( Integer ) datas[ n ][ 3 ];
|
||||
// String dataEstadoStr = MedicinaConstants.ESTADOS_CONSULTA_STR[ dataEstado != null ? dataEstado.intValue() : 0 ];
|
||||
// String dataDesc = D_F.format( dataData ) + ": " + dataEstadoStr;
|
||||
// DataMutableTreeNode dataNode = new DataMutableTreeNode( dataID, dataDesc );
|
||||
// IDObject observacoes = provider.getObservacoesConsultaData( dataID );
|
||||
// if( observacoes != null )
|
||||
// {
|
||||
// ObservacoesMutableTreeNode observacoesNode = new ObservacoesMutableTreeNode( observacoes.getID(), observacoes.toString() );
|
||||
// dataNode.add( observacoesNode );
|
||||
// }
|
||||
// IDObject emails[] = provider.getEmailConsultaData( dataID );
|
||||
// for( int em = 0; em < emails.length; em++ )
|
||||
// {
|
||||
// MailMutableTreeNode mailNode = new MailMutableTreeNode( emails[ em ].getID(), emails[ em ].toString() );
|
||||
// dataNode.add( mailNode );
|
||||
// }
|
||||
// consultaNode.add( dataNode );
|
||||
// }
|
||||
//
|
||||
// ( ( DefaultTreeModel ) mainTree.getModel() ).nodeStructureChanged( consultaNode );
|
||||
// return consultaNode;
|
||||
// }
|
||||
//
|
||||
// public void valueChanged( TreeSelectionEvent e )
|
||||
// {
|
||||
// Object components[] = e.getPath().getPath();
|
||||
// int tipo = ProcessoEvent.ACCAO_ESCOLHER_PROCESSO;
|
||||
// if( components == null || components.length == 0 ||
|
||||
// components[ components.length - 1 ] instanceof TrabalhadorMutableTreeNode ||
|
||||
// components[ components.length - 1 ] instanceof ProcessoMutableTreeNode )
|
||||
// {
|
||||
// tipo = ProcessoEvent.ACCAO_ESCOLHER_PROCESSO;
|
||||
// }
|
||||
// else if( components[ components.length - 1 ] instanceof ConsultaMutableTreeNode )
|
||||
// {
|
||||
// tipo = ProcessoEvent.ACCAO_ESCOLHER_CONSULTA;
|
||||
// }
|
||||
// else if( components[ components.length - 1 ] instanceof ECDsMutableTreeNode )
|
||||
// {
|
||||
// tipo = ProcessoEvent.ACCAO_ESCOLHER_ECDS;
|
||||
// }
|
||||
// else if( components[ components.length - 1 ] instanceof FichaAptidaoMutableTreeNode )
|
||||
// {
|
||||
// tipo = ProcessoEvent.ACCAO_ESCOLHER_FA;
|
||||
// }
|
||||
// else if( components[ components.length - 1 ] instanceof DataMutableTreeNode )
|
||||
// {
|
||||
// tipo = ProcessoEvent.ACCAO_ESCOLHER_DATA;
|
||||
// }
|
||||
// else if( components[ components.length - 1 ] instanceof ObservacoesMutableTreeNode )
|
||||
// {
|
||||
// tipo = ProcessoEvent.ACCAO_ESCOLHER_OBSERVACOES;
|
||||
// }
|
||||
// else if( components[ components.length - 1 ] instanceof MailMutableTreeNode )
|
||||
// {
|
||||
// tipo = ProcessoEvent.ACCAO_ESCOLHER_MAIL;
|
||||
// }
|
||||
// HashMap<Integer,Integer> ids = new HashMap<Integer,Integer>();
|
||||
// for( int n = 0; components != null && n < components.length; n++ )
|
||||
// {
|
||||
// Integer id = ( ( EstruturaProcessoMutableTreeNode ) components[ n ] ).getID();
|
||||
// if( components[ n ] instanceof ProcessoMutableTreeNode )
|
||||
// {
|
||||
// ids.put( ProcessoEvent.TIPO_PROCESSO, id );
|
||||
// }
|
||||
// else if( components[ n ] instanceof ConsultaMutableTreeNode )
|
||||
// {
|
||||
// ids.put( ProcessoEvent.TIPO_CONSULTA, id );
|
||||
// }
|
||||
// else if( components[ n ] instanceof ECDsMutableTreeNode )
|
||||
// {
|
||||
// ids.put( ProcessoEvent.TIPO_ECDS, id );
|
||||
// }
|
||||
// else if( components[ n ] instanceof FichaAptidaoMutableTreeNode )
|
||||
// {
|
||||
// ids.put( ProcessoEvent.TIPO_FICHA_APTIDAO, id );
|
||||
// }
|
||||
// else if( components[ n ] instanceof DataMutableTreeNode )
|
||||
// {
|
||||
// ids.put( ProcessoEvent.TIPO_DATA, id );
|
||||
// }
|
||||
// else if( components[ n ] instanceof ObservacoesMutableTreeNode )
|
||||
// {
|
||||
// ids.put( ProcessoEvent.TIPO_OBSERVACOES, id );
|
||||
// }
|
||||
// else if( components[ n ] instanceof MailMutableTreeNode )
|
||||
// {
|
||||
// ids.put( ProcessoEvent.TIPO_MAIL, id );
|
||||
// }
|
||||
// }
|
||||
// ProcessoEvent event = new ProcessoEvent( this, tipo, ids );
|
||||
// for( int n = 0; n < PROCESSO_LISTENERS.size(); n++ )
|
||||
// {
|
||||
// PROCESSO_LISTENERS.get( n ).processoStateChanged( event );
|
||||
// }
|
||||
// }
|
||||
////
|
||||
//// public TrabalhadoresProcessoData getProcessoEscolhido()
|
||||
//// {
|
||||
//// TreePath path = mainTree.getSelectionPath();
|
||||
//// TrabalhadoresProcessoData processo = null;
|
||||
//// if( path != null )
|
||||
//// {
|
||||
//// EstruturaProcessoMutableTreeNode escolhido = ( EstruturaProcessoMutableTreeNode ) path.getLastPathComponent();
|
||||
//// if( escolhido != null )
|
||||
//// {
|
||||
//// processo = PROCESSOS_POR_ID.get( escolhido.getID() );
|
||||
//// if( processo == null )
|
||||
//// {
|
||||
//// processo = new TrabalhadoresProcessoData();
|
||||
//// PROCESSOS_POR_ID.put( escolhido.getID(), processo );
|
||||
//// }
|
||||
//// }
|
||||
//// }
|
||||
////
|
||||
//// return processo;
|
||||
//// }
|
||||
//
|
||||
// public void addProcessoListener( ProcessoListener listener )
|
||||
// {
|
||||
// PROCESSO_LISTENERS.add( listener );
|
||||
// }
|
||||
//
|
||||
// public void removeProcessoListener( ProcessoListener listener )
|
||||
// {
|
||||
// PROCESSO_LISTENERS.remove( listener );
|
||||
// }
|
||||
//
|
||||
// public IDObject getTrabalhador()
|
||||
// {
|
||||
// return trabalhador;
|
||||
// }
|
||||
//
|
||||
// public void actualizarProcessoEscolhido( Integer id )
|
||||
// throws Exception
|
||||
// {
|
||||
// TreePath path = mainTree.getSelectionPath();
|
||||
// Enumeration<TreePath> expandedDescendants = mainTree.getExpandedDescendants( path );
|
||||
// ProcessoMutableTreeNode processoNode = ( ProcessoMutableTreeNode ) path.getPathComponent( 1 );
|
||||
// boolean vazio = processoNode.getID().intValue() == -1;
|
||||
// loadProcesso( id, processoNode );
|
||||
// ( ( DefaultTreeModel ) mainTree.getModel() ).nodeChanged( processoNode ) ;
|
||||
// if( vazio )
|
||||
// {
|
||||
// ProcessoMutableTreeNode novo = criarProcessoVazio();
|
||||
// rootNode.insert( novo, 0 );
|
||||
// ( ( DefaultTreeModel ) mainTree.getModel() ).nodesWereInserted( rootNode, new int[]{ 0 } ) ;
|
||||
// }
|
||||
// mainTree.expandPath( path );
|
||||
// mainTree.setSelectionPath( path );
|
||||
//// while( expandedDescendants.hasMoreElements() )
|
||||
//// {
|
||||
//// mainTree.expandPath( expandedDescendants.nextElement() );
|
||||
//// }
|
||||
// }
|
||||
//
|
||||
// public void actualizarMarcacaoEscolhida( Integer processoID, Integer marcacaoID )
|
||||
// throws Exception
|
||||
// {
|
||||
// TreePath path = mainTree.getSelectionPath();
|
||||
// Enumeration<TreePath> expandedDescendants = mainTree.getExpandedDescendants( path );
|
||||
// ProcessoMutableTreeNode processoNode = ( ProcessoMutableTreeNode ) path.getPathComponent( 1 );
|
||||
// int countOld = processoNode.getChildCount();
|
||||
// actualizarProcessoEscolhido( processoID );
|
||||
// int count = processoNode.getChildCount();
|
||||
// if( count > countOld )
|
||||
// {
|
||||
// ( ( DefaultTreeModel ) mainTree.getModel() ).nodesWereInserted( processoNode, new int[]{ countOld } ) ;
|
||||
// }
|
||||
// mainTree.expandPath( path );
|
||||
//// mainTree.expandPath( path );
|
||||
//// while( expandedDescendants.hasMoreElements() )
|
||||
//// {
|
||||
//// mainTree.expandPath( expandedDescendants.nextElement() );
|
||||
//// }
|
||||
//// TreePath path = mainTree.getSelectionPath();
|
||||
//// MarcacaoMutableTreeNode processoNode = ( ProcessoMutableTreeNode ) path.getPathComponent( 1 );
|
||||
//// boolean vazio = processoNode.getID().intValue() == -1;
|
||||
//// loadProcesso( id, processoNode );
|
||||
//// ( ( DefaultTreeModel ) mainTree.getModel() ).nodeChanged( processoNode ) ;
|
||||
//// if( vazio )
|
||||
//// {
|
||||
//// ProcessoMutableTreeNode novo = criarProcessoVazio();
|
||||
//// rootNode.insert( novo, 0 );
|
||||
//// ( ( DefaultTreeModel ) mainTree.getModel() ).nodesWereInserted( rootNode, new int[]{ 0 } ) ;
|
||||
//// }
|
||||
// }
|
||||
//
|
||||
// public ProcessoMutableTreeNode criarProcessoVazio()
|
||||
// {
|
||||
// return new ProcessoMutableTreeNode( new Integer( -1 ), "Novo Processo..." );
|
||||
// }
|
||||
//
|
||||
// public void reload()
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public void clear()
|
||||
// {
|
||||
// mainTree.clearSelection();
|
||||
// mainTree.setRootVisible( true );
|
||||
// this.trabalhador = null;
|
||||
// rootNode.removeAllChildren();
|
||||
// PROCESSOS_POR_ID.clear();
|
||||
// rootNode.setID( null );
|
||||
// rootNode.setDescricao( "" );
|
||||
// ( ( DefaultTreeModel ) mainTree.getModel() ).nodeStructureChanged( rootNode );
|
||||
// }
|
||||
//}
|
||||
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* EstruturaProcessoRenderer.java
|
||||
*
|
||||
* Created on 29 de Abril de 2007, 18:52
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package siprp.medicina.processo.estrutura;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.tree.DefaultTreeCellRenderer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Frederico
|
||||
*/
|
||||
public class EstruturaProcessoRenderer extends DefaultTreeCellRenderer
|
||||
{
|
||||
|
||||
/** Creates a new instance of EstruturaProcessoRenderer */
|
||||
public EstruturaProcessoRenderer()
|
||||
{
|
||||
}
|
||||
|
||||
public Component getTreeCellRendererComponent(
|
||||
JTree tree,
|
||||
Object value,
|
||||
boolean sel,
|
||||
boolean expanded,
|
||||
boolean leaf,
|
||||
int row,
|
||||
boolean hasFocus) {
|
||||
|
||||
super.getTreeCellRendererComponent(
|
||||
tree, value, sel,
|
||||
expanded, leaf, row,
|
||||
hasFocus);
|
||||
EstruturaProcessoMutableTreeNode node = ( EstruturaProcessoMutableTreeNode ) value;
|
||||
Icon icon = node.getIcon();
|
||||
Color color = node.getColor();
|
||||
if( icon != null )
|
||||
{
|
||||
setIcon( icon );
|
||||
}
|
||||
if(color != null)
|
||||
{
|
||||
setForeground( color );
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
/*
|
||||
* FichaAptidaoMutableTreeNode.java
|
||||
*
|
||||
* Created on 29 de Abril de 2007, 19:32
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package siprp.medicina.processo.estrutura;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Frederico
|
||||
*/
|
||||
public class FichaAptidaoMutableTreeNode extends EstruturaProcessoMutableTreeNode
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final String ICON_PATH = "siprp/medicina/processo/estrutura/icons/fichaaptidao.png";
|
||||
|
||||
/** Creates a new instance of FichaAptidaoMutableTreeNode */
|
||||
public FichaAptidaoMutableTreeNode( Object userObject )
|
||||
{
|
||||
super( userObject );
|
||||
}
|
||||
|
||||
protected String getIconPath()
|
||||
{
|
||||
return ICON_PATH;
|
||||
}
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* MailMutableTreeNode.java
|
||||
*
|
||||
* Created on 29 de Abril de 2007, 19:32
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package siprp.medicina.processo.estrutura;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Frederico
|
||||
*/
|
||||
public class MailMutableTreeNode extends EstruturaProcessoMutableTreeNode
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final String ICON_PATH = "siprp/medicina/processo/estrutura/icons/mail.png";
|
||||
|
||||
/** Creates a new instance of MailMutableTreeNode */
|
||||
public MailMutableTreeNode( Object userObject )
|
||||
{
|
||||
super( userObject );
|
||||
}
|
||||
|
||||
protected String getIconPath()
|
||||
{
|
||||
return ICON_PATH;
|
||||
}
|
||||
}
|
||||
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* MarcacaoMutableTreeNode.java
|
||||
*
|
||||
* Created on 18 de Maio de 2007, 7:02
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package siprp.medicina.processo.estrutura;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Frederico
|
||||
*/
|
||||
public abstract class MarcacaoMutableTreeNode extends EstruturaProcessoMutableTreeNode
|
||||
implements Comparable<MarcacaoMutableTreeNode>
|
||||
{
|
||||
protected Date data;
|
||||
|
||||
/** Creates a new instance of MarcacaoMutableTreeNode */
|
||||
public MarcacaoMutableTreeNode( Object userObject )
|
||||
{
|
||||
super( userObject );
|
||||
}
|
||||
|
||||
public void setData( Date data )
|
||||
{
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public Date getData()
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
public int compareTo( MarcacaoMutableTreeNode other )
|
||||
{
|
||||
if( !( other instanceof MarcacaoMutableTreeNode ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
MarcacaoMutableTreeNode om = ( MarcacaoMutableTreeNode ) other;
|
||||
if( data == null )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if( om == null || om.getData() == null )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1 * getData().compareTo( om.getData() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* ObservacoesMutableTreeNode.java
|
||||
*
|
||||
* Created on 29 de Abril de 2007, 19:32
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package siprp.medicina.processo.estrutura;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Frederico
|
||||
*/
|
||||
public class ObservacoesMutableTreeNode extends EstruturaProcessoMutableTreeNode
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final String ICON_PATH = "siprp/medicina/processo/estrutura/icons/observacoes.png";
|
||||
|
||||
/** Creates a new instance of ObservacoesMutableTreeNode */
|
||||
public ObservacoesMutableTreeNode( Object userObject )
|
||||
{
|
||||
super( userObject );
|
||||
}
|
||||
|
||||
protected String getIconPath()
|
||||
{
|
||||
return ICON_PATH;
|
||||
}
|
||||
}
|
||||
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* ProcessoMutableTreeNode.java
|
||||
*
|
||||
* Created on 29 de Abril de 2007, 19:31
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package siprp.medicina.processo.estrutura;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import siprp.ProcessoConstants;
|
||||
import siprp.data.outer.TrabalhadoresProcessoData;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Frederico
|
||||
*/
|
||||
public class ProcessoMutableTreeNode extends EstruturaProcessoMutableTreeNode
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final String ICON_PATH = "siprp/medicina/processo/estrutura/icons/processo.png";
|
||||
|
||||
/** Creates a new instance of ProcessoMutableTreeNode */
|
||||
public ProcessoMutableTreeNode( TrabalhadoresProcessoData userObject )
|
||||
{
|
||||
super( userObject );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getColor()
|
||||
{
|
||||
if(userObject != null && ProcessoConstants.PROCESSO_ABERTO_CODE.equals( ((TrabalhadoresProcessoData)userObject).getEstado()))
|
||||
{
|
||||
return Color.RED;
|
||||
}
|
||||
return Color.BLACK;
|
||||
}
|
||||
|
||||
protected String getIconPath()
|
||||
{
|
||||
return ICON_PATH;
|
||||
}
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* TrabalhadorMutableTreeNode.java
|
||||
*
|
||||
* Created on 29 de Abril de 2007, 23:53
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package siprp.medicina.processo.estrutura;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Frederico
|
||||
*/
|
||||
public class TrabalhadorMutableTreeNode extends EstruturaProcessoMutableTreeNode
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final String ICON_PATH = "siprp/medicina/processo/estrutura/icons/trabalhador.png";
|
||||
|
||||
/** Creates a new instance of TrabalhadorMutableTreeNode */
|
||||
public TrabalhadorMutableTreeNode( Object userObject )
|
||||
{
|
||||
super( userObject );
|
||||
}
|
||||
|
||||
protected String getIconPath()
|
||||
{
|
||||
return null;
|
||||
// return ICON_PATH;
|
||||
}
|
||||
}
|
||||
@ -1,929 +0,0 @@
|
||||
package siprp.medicina.processo.logic;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
|
||||
import leaf.ui.LeafDialog;
|
||||
import leaf.ui.LeafLogic;
|
||||
import leaf.ui.LeafWindow.LeafObject;
|
||||
import siprp.MedicinaConstants;
|
||||
import siprp.ProcessoConstants;
|
||||
import siprp.data.BaseObject;
|
||||
import siprp.data.outer.EmpresasData;
|
||||
import siprp.data.outer.EstabelecimentosData;
|
||||
import siprp.data.outer.ExamesData;
|
||||
import siprp.data.outer.LembretesData;
|
||||
import siprp.data.outer.PrestadoresData;
|
||||
import siprp.data.outer.TrabalhadoresConsultasData;
|
||||
import siprp.data.outer.TrabalhadoresConsultasDatasData;
|
||||
import siprp.data.outer.TrabalhadoresConsultasDatasEmailsData;
|
||||
import siprp.data.outer.TrabalhadoresConsultasDatasObservacoesData;
|
||||
import siprp.data.outer.TrabalhadoresData;
|
||||
import siprp.data.outer.TrabalhadoresEcdData;
|
||||
import siprp.data.outer.TrabalhadoresEcdsData;
|
||||
import siprp.data.outer.TrabalhadoresEcdsDatasData;
|
||||
import siprp.data.outer.TrabalhadoresEcdsDatasEmailsData;
|
||||
import siprp.data.outer.TrabalhadoresEcdsDatasObservacoesData;
|
||||
import siprp.data.outer.TrabalhadoresFichasAptidaoData;
|
||||
import siprp.data.outer.TrabalhadoresProcessoData;
|
||||
import siprp.data.provider.MedicinaDataProvider;
|
||||
import siprp.ficha.FichaWindow;
|
||||
import siprp.ficha.SaveExameListener;
|
||||
import siprp.lembretes.LembretesConstants;
|
||||
import siprp.lembretes.LembretesDataProvider;
|
||||
import siprp.medicina.processo.estrutura.FichaAptidaoMutableTreeNode;
|
||||
|
||||
public class MedicinaProcessoLogic extends LeafLogic
|
||||
{
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_EMPRESA = "SELECT_EMPRESA";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_ESTABELECIMENTO = "SELECT_ESTABLECIMENTO";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String LOAD_TRABALHADOR = "LOAD_TRABALHADOR";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_TRABALHADOR = "SELECT_TRABALHADOR";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_PROCESSO = "SELECT_PROCESSO";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_CONSULTA = "SELECT_CONSULTA";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_CONSULTA_MARCACAO = "SELECT_CONSULTA_MARCACAO";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_CONSULTA_MARCACAO_EMAIL = "SELECT_CONSULTA_MARCACAO_EMAIL";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_CONSULTA_MARCACAO_OBSERVACAO = "SELECT_CONSULTA_MARCACAO_OBSERVACAO";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_EXAME = "SELECT_EXAME";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_EXAME_MARCACAO = "SELECT_EXAME_MARCACAO";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_EXAME_MARCACAO_EMAIL = "SELECT_EXAME_MARCACAO_EMAIL";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_EXAME_MARCACAO_OBSERVACAO = "SELECT_EXAME_MARCACAO_OBSERVACAO";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_FICHA = "SELECT_FICHA";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String SELECT_TREE_NODE = "SELECT_TREE_NODE";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String CREATE_PROCESSO = "CREATE_PROCESSO";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String CREATE_LEMBRETE = "CREATE_LEMBRETE";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String CREATE_FICHA = "CREATE_FICHA";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String CREATE_CONSULTA = "CREATE_CONSULTA";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String CREATE_CONSULTA_MARCACAO = "CREATE_CONSULTA_MARCACAO";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String CREATE_CONSULTA_MARCACAO_EMAIL = "CREATE_CONSULTA_MARCACAO_EMAIL";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String CREATE_CONSULTA_MARCACAO_EMAIL_VACINAS = "CREATE_CONSULTA_MARCACAO_EMAIL_VACINAS";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String CREATE_CONSULTA_MARCACAO_OBSERVACOES = "CREATE_CONSULTA_MARCACAO_OBSERVACOES";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String CREATE_EXAME = "CREATE_EXAME";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String CREATE_EXAME_MARCACAO = "CREATE_EXAME_MARCACAO";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String CREATE_EXAME_MARCACAO_EMAIL = "CREATE_EXAME_MARCACAO_EMAIL";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String CREATE_EXAME_MARCACAO_OBSERVACOES = "CREATE_EXAME_MARCACAO_OBSERVACOES";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String SAVE_PROCESSO = "SAVE_PROCESSO";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String SAVE_LEMBRETE = "SAVE_LEMBRETE";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String SAVE_CONSULTA = "SAVE_CONSULTA";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String SAVE_CONSULTA_MARCACAO = "SAVE_CONSULTA_MARCACAO";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String SAVE_CONSULTA_MARCACAO_EMAIL = "SAVE_CONSULTA_MARCACAO_EMAIL";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String SAVE_CONSULTA_MARCACAO_OBSERVACOES = "SAVE_CONSULTA_MARCACAO_OBSERVACOES";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String SAVE_FICHA = "SAVE_FICHA";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String SAVE_EXAME = "SAVE_EXAME";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String SAVE_EXAME_MARCACAO = "SAVE_EXAME_MARCACAO";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String SAVE_EXAME_MARCACAO_EMAIL = "SAVE_EXAME_MARCACAO_EMAIL";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String SAVE_EXAME_MARCACAO_OBSERVACOES = "SAVE_EXAME_MARCACAO_OBSERVACOES";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String FECHAR_PROCESSO = "FECHAR_PROCESSO";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String APAGAR_PROCESSO = "APAGAR_PROCESSO";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String APAGAR_CONSULTA = "APAGAR_CONSULTA";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String APAGAR_CONSULTA_MARCACAO = "APAGAR_CONSULTA_MARCACAO";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String APAGAR_EXAME = "APAGAR_EXAME";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String APAGAR_EXAME_MARCACAO = "APAGAR_EXAME_MARCACAO";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String REFRESH = "REFRESH";
|
||||
|
||||
@Action(isSave = false)
|
||||
public static final String CLOSE = "CLOSE";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String DESMARCAR_SIPRP_CONSULTA_MARCACAO = "DESMARCAR_SIPRP_CONSULTA_MARCACAO";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String DESMARCAR_TRABALHADOR_CONSULTA_MARCACAO = "DESMARCAR_TRABALHADOR_CONSULTA_MARCACAO";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String REALIZAR_CONSULTA_MARCACAO = "REALIZAR_CONSULTA_MARCACAO";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String FALTOU_CONSULTA_MARCACAO = "FALTOU_CONSULTA_MARCACAO";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String DESMARCAR_SIPRP_EXAME_MARCACAO = "DESMARCAR_SIPRP_EXAME_MARCACAO";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String DESMARCAR_TRABALHADOR_EXAME_MARCACAO = "DESMARCAR_TRABALHADOR_EXAME_MARCACAO";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String REALIZAR_EXAME_MARCACAO = "REALIZAR_EXAME_MARCACAO";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String REALIZAR_PARCIAL_EXAME_MARCACAO = "REALIZAR_PARCIAL_EXAME_MARCACAO";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String FALTOU_EXAME_MARCACAO = "FALTOU_EXAME_MARCACAO";
|
||||
|
||||
@Action(isSave = true)
|
||||
public static final String ANULAR_EXAME_MARCACAO = "ANULAR_EXAME_MARCACAO";
|
||||
|
||||
private LembretesDataProvider lembretesDataProvider = null;
|
||||
|
||||
private MedicinaDataProvider provider = null;
|
||||
|
||||
public EmpresasData currentEmpresa = null;
|
||||
|
||||
public EstabelecimentosData currentEstabelecimento = null;
|
||||
|
||||
@LeafObject(useWith = LOAD_TRABALHADOR)
|
||||
public TrabalhadoresData currentTrabalhador = null;
|
||||
|
||||
@LeafObject(useWith = {
|
||||
SAVE_PROCESSO, APAGAR_PROCESSO
|
||||
})
|
||||
public TrabalhadoresProcessoData currentProcesso = null;
|
||||
|
||||
@LeafObject(useWith = {
|
||||
SAVE_CONSULTA, APAGAR_CONSULTA
|
||||
})
|
||||
public TrabalhadoresConsultasData currentConsulta = null;
|
||||
|
||||
@LeafObject(useWith = {
|
||||
SAVE_CONSULTA_MARCACAO, APAGAR_CONSULTA_MARCACAO
|
||||
})
|
||||
public TrabalhadoresConsultasDatasData currentConsultaMarcacao = null;
|
||||
|
||||
@LeafObject(useWith = SAVE_CONSULTA_MARCACAO_EMAIL)
|
||||
public TrabalhadoresConsultasDatasEmailsData currentConsultaMarcacaoEmail = null;
|
||||
|
||||
@LeafObject(useWith = SAVE_CONSULTA_MARCACAO_OBSERVACOES)
|
||||
public TrabalhadoresConsultasDatasObservacoesData currentConsultaMarcacaoObservacao = null;
|
||||
|
||||
@LeafObject(useWith = SAVE_FICHA)
|
||||
public TrabalhadoresFichasAptidaoData currentFicha = null;
|
||||
|
||||
@LeafObject(useWith = SAVE_EXAME_MARCACAO_OBSERVACOES)
|
||||
public TrabalhadoresEcdsDatasObservacoesData currentExameMarcacaoObservacao = null;
|
||||
|
||||
@LeafObject(useWith = SAVE_EXAME_MARCACAO_EMAIL)
|
||||
public TrabalhadoresEcdsDatasEmailsData currentExameMarcacaoEmail = null;
|
||||
|
||||
@LeafObject(useWith = {
|
||||
SAVE_EXAME_MARCACAO, REALIZAR_PARCIAL_EXAME_MARCACAO, APAGAR_EXAME_MARCACAO
|
||||
})
|
||||
public TrabalhadoresEcdsDatasData currentExameMarcacao = null;
|
||||
|
||||
@LeafObject(useWith = {
|
||||
SAVE_EXAME, APAGAR_EXAME
|
||||
})
|
||||
public TrabalhadoresEcdsData currentExame = null;
|
||||
|
||||
public Integer currentFichaExameID = null;
|
||||
|
||||
public MedicinaProcessoLogic()
|
||||
{
|
||||
try
|
||||
{
|
||||
provider = MedicinaDataProvider.getProvider();
|
||||
lembretesDataProvider = new LembretesDataProvider();
|
||||
} catch( Exception e )
|
||||
{
|
||||
e.printStackTrace( System.out );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = {
|
||||
ACTION_STARTUP
|
||||
})
|
||||
public List<EmpresasData> getAllEmpresas()
|
||||
{
|
||||
return provider.getAllEmpresas();
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = {
|
||||
SELECT_EMPRESA
|
||||
})
|
||||
public EmpresasData setEmpresa( EmpresasData empresa )
|
||||
{
|
||||
currentEmpresa = empresa;
|
||||
return currentEmpresa;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = {
|
||||
SELECT_ESTABELECIMENTO
|
||||
})
|
||||
public EstabelecimentosData setEstabelecimento( EstabelecimentosData estabelecimento )
|
||||
{
|
||||
currentEstabelecimento = estabelecimento;
|
||||
return currentEstabelecimento;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = {
|
||||
LOAD_TRABALHADOR
|
||||
})
|
||||
public TrabalhadoresData getDadosTrabalhador( TrabalhadoresData trabalhador )
|
||||
{
|
||||
// Trabalhadores result = null;
|
||||
// if( id != null )
|
||||
// {
|
||||
// result = provider.getTrabalhadorByID( id );
|
||||
// }
|
||||
currentTrabalhador = trabalhador;
|
||||
return currentTrabalhador;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = FECHAR_PROCESSO)
|
||||
public void fecharProcesso()
|
||||
{
|
||||
if( currentProcesso != null )
|
||||
{
|
||||
currentProcesso.setData_fim( new Date() );
|
||||
currentProcesso.setEstado( ProcessoConstants.PROCESSO_FECHADO_CODE );
|
||||
runActionLater( SAVE_PROCESSO );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = APAGAR_PROCESSO)
|
||||
public void apagarProcesso()
|
||||
{
|
||||
if( currentProcesso != null && currentProcesso.isEmpty() )
|
||||
{
|
||||
currentProcesso.setActivo( "n" );
|
||||
runActionLater( SAVE_PROCESSO );
|
||||
}
|
||||
}
|
||||
|
||||
private void novoLembreteRemarcacao( String mensagem, boolean isConsulta )
|
||||
{
|
||||
Integer tipoID = lembretesDataProvider.getTipoLembreteIDByCodigo( LembretesConstants.CODE_REMARCACOES );
|
||||
try
|
||||
{
|
||||
if( isConsulta && currentEmpresa != null && currentEstabelecimento != null && currentTrabalhador != null && currentConsultaMarcacao != null )
|
||||
{
|
||||
lembretesDataProvider.criarLembreteConsulta( tipoID, new Date(), mensagem, null, currentEmpresa.getId(), currentEstabelecimento.getId(), currentTrabalhador.getId(), currentConsultaMarcacao.getId() );
|
||||
}
|
||||
else
|
||||
{
|
||||
lembretesDataProvider.criarLembreteExame( tipoID, new Date(), mensagem, null, currentEmpresa.getId(), currentEstabelecimento.getId(), currentTrabalhador.getId(), currentExameMarcacao.getId() );
|
||||
}
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = DESMARCAR_SIPRP_CONSULTA_MARCACAO)
|
||||
public void desmarcarConsultaSiprp()
|
||||
{
|
||||
if( currentConsultaMarcacao != null )
|
||||
{
|
||||
currentConsultaMarcacao.setEstado( MedicinaConstants.ESTADO_DESMARCADO_EMPRESA );
|
||||
novoLembreteRemarcacao( MedicinaConstants.LEMBRETE_DESMARCOU_SIPRP_STRING, true );
|
||||
runActionLater( SAVE_CONSULTA_MARCACAO );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = DESMARCAR_TRABALHADOR_CONSULTA_MARCACAO)
|
||||
public void desmarcarConsultaTrabalhador()
|
||||
{
|
||||
if( currentConsultaMarcacao != null )
|
||||
{
|
||||
currentConsultaMarcacao.setEstado( MedicinaConstants.ESTADO_DESMARCADO_TRABALHADOR );
|
||||
novoLembreteRemarcacao( MedicinaConstants.LEMBRETE_DESMARCOU_TRABALHADOR_STRING, true );
|
||||
runActionLater( SAVE_CONSULTA_MARCACAO );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = FALTOU_CONSULTA_MARCACAO)
|
||||
public void faltouConsulta()
|
||||
{
|
||||
if( currentConsultaMarcacao != null )
|
||||
{
|
||||
currentConsultaMarcacao.setEstado( MedicinaConstants.ESTADO_FALTOU );
|
||||
novoLembreteRemarcacao( MedicinaConstants.LEMBRETE_FALTOU_TRABALHADOR_STRING, true );
|
||||
runActionLater( SAVE_CONSULTA_MARCACAO );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = REALIZAR_CONSULTA_MARCACAO)
|
||||
public void realizarConsulta()
|
||||
{
|
||||
if( currentConsultaMarcacao != null )
|
||||
{
|
||||
currentConsultaMarcacao.setEstado( MedicinaConstants.ESTADO_REALIZADO );
|
||||
runActionLater( SAVE_CONSULTA_MARCACAO );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = DESMARCAR_SIPRP_EXAME_MARCACAO)
|
||||
public void desmarcarExameSiprp()
|
||||
{
|
||||
if( currentExameMarcacao != null )
|
||||
{
|
||||
currentExameMarcacao.desmarcarSIPRP();
|
||||
novoLembreteRemarcacao( MedicinaConstants.LEMBRETE_DESMARCOU_SIPRP_STRING, false );
|
||||
runActionLater( SAVE_EXAME_MARCACAO );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = DESMARCAR_TRABALHADOR_EXAME_MARCACAO)
|
||||
public void desmarcarExameTrabalhador()
|
||||
{
|
||||
if( currentExameMarcacao != null )
|
||||
{
|
||||
currentExameMarcacao.desmarcarTrabalhador();
|
||||
novoLembreteRemarcacao( MedicinaConstants.LEMBRETE_DESMARCOU_TRABALHADOR_STRING, false );
|
||||
runActionLater( SAVE_EXAME_MARCACAO );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = FALTOU_EXAME_MARCACAO)
|
||||
public void faltouExame()
|
||||
{
|
||||
if( currentExameMarcacao != null )
|
||||
{
|
||||
currentExameMarcacao.faltou();
|
||||
novoLembreteRemarcacao( MedicinaConstants.LEMBRETE_FALTOU_TRABALHADOR_STRING, false );
|
||||
runActionLater( SAVE_EXAME_MARCACAO );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = ANULAR_EXAME_MARCACAO)
|
||||
public void anularExame()
|
||||
{
|
||||
if( currentExameMarcacao != null )
|
||||
{
|
||||
currentExameMarcacao.anular();
|
||||
runActionLater( SAVE_EXAME_MARCACAO );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = REALIZAR_EXAME_MARCACAO)
|
||||
public void realizarExame()
|
||||
{
|
||||
if( currentExameMarcacao != null )
|
||||
{
|
||||
currentExameMarcacao.realizar();
|
||||
runActionLater( SAVE_EXAME_MARCACAO );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = REALIZAR_PARCIAL_EXAME_MARCACAO)
|
||||
public void realizarParcialExame()
|
||||
{
|
||||
if( currentExameMarcacao != null )
|
||||
{
|
||||
runActionLater( SAVE_EXAME_MARCACAO );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = SELECT_TRABALHADOR)
|
||||
public TrabalhadoresData selectTrabalhador( TrabalhadoresData trabalhador )
|
||||
{
|
||||
this.currentTrabalhador = trabalhador;
|
||||
return this.currentTrabalhador;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = SELECT_PROCESSO)
|
||||
public TrabalhadoresProcessoData selectProcesso( TrabalhadoresProcessoData processo )
|
||||
{
|
||||
this.currentProcesso = processo;
|
||||
return this.currentProcesso;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = SELECT_CONSULTA)
|
||||
public TrabalhadoresConsultasData selectConsulta( TrabalhadoresConsultasData consulta )
|
||||
{
|
||||
this.currentConsulta = consulta;
|
||||
return this.currentConsulta;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = SELECT_CONSULTA_MARCACAO)
|
||||
public TrabalhadoresConsultasDatasData selectConsultaMarcacao( TrabalhadoresConsultasDatasData consultaMarcacao )
|
||||
{
|
||||
this.currentConsultaMarcacao = consultaMarcacao;
|
||||
return this.currentConsultaMarcacao;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = SELECT_CONSULTA_MARCACAO_EMAIL)
|
||||
public TrabalhadoresConsultasDatasEmailsData selectConsultaMarcacaoEmail( TrabalhadoresConsultasDatasEmailsData consultaMarcacaoEmail )
|
||||
{
|
||||
this.currentConsultaMarcacaoEmail = consultaMarcacaoEmail;
|
||||
return this.currentConsultaMarcacaoEmail;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = SELECT_CONSULTA_MARCACAO_OBSERVACAO)
|
||||
public TrabalhadoresConsultasDatasObservacoesData selectConsultaMarcacaoObservacoes( TrabalhadoresConsultasDatasObservacoesData consultaMarcacaoObservacoes )
|
||||
{
|
||||
this.currentConsultaMarcacaoObservacao = consultaMarcacaoObservacoes;
|
||||
return this.currentConsultaMarcacaoObservacao;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = SELECT_EXAME)
|
||||
public TrabalhadoresEcdsData selectExame( TrabalhadoresEcdsData exame )
|
||||
{
|
||||
this.currentExame = exame;
|
||||
return this.currentExame;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = SELECT_EXAME_MARCACAO)
|
||||
public TrabalhadoresEcdsDatasData selectExameMarcacao( TrabalhadoresEcdsDatasData exameMarcacao )
|
||||
{
|
||||
this.currentExameMarcacao = exameMarcacao;
|
||||
return this.currentExameMarcacao;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = SELECT_EXAME_MARCACAO_EMAIL)
|
||||
public TrabalhadoresEcdsDatasEmailsData selectExameMarcacaoEmail( TrabalhadoresEcdsDatasEmailsData exameMarcacaoEmail )
|
||||
{
|
||||
this.currentExameMarcacaoEmail = exameMarcacaoEmail;
|
||||
return this.currentExameMarcacaoEmail;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = SELECT_EXAME_MARCACAO_OBSERVACAO)
|
||||
public TrabalhadoresEcdsDatasObservacoesData selectExameMarcacaoObservacoes( TrabalhadoresEcdsDatasObservacoesData exameMarcacaoObservacoes )
|
||||
{
|
||||
this.currentExameMarcacaoObservacao = exameMarcacaoObservacoes;
|
||||
return this.currentExameMarcacaoObservacao;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = SELECT_FICHA)
|
||||
public TrabalhadoresFichasAptidaoData selectFichaAptidao( TrabalhadoresFichasAptidaoData ficha )
|
||||
{
|
||||
this.currentFicha = ficha;
|
||||
return this.currentFicha;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = {
|
||||
SELECT_TREE_NODE
|
||||
})
|
||||
public DefaultMutableTreeNode nodeSelected( DefaultMutableTreeNode node )
|
||||
{
|
||||
String action = null;
|
||||
if( node.getUserObject() == null )
|
||||
{
|
||||
}
|
||||
else if( node.getUserObject() instanceof TrabalhadoresData )
|
||||
{
|
||||
action = SELECT_TRABALHADOR;
|
||||
}
|
||||
else if( node.getUserObject() instanceof TrabalhadoresProcessoData )
|
||||
{
|
||||
action = SELECT_PROCESSO;
|
||||
}
|
||||
else if( node.getUserObject() instanceof TrabalhadoresConsultasData )
|
||||
{
|
||||
action = SELECT_CONSULTA;
|
||||
}
|
||||
else if( node.getUserObject() instanceof TrabalhadoresConsultasDatasData )
|
||||
{
|
||||
action = SELECT_CONSULTA_MARCACAO;
|
||||
}
|
||||
else if( node.getUserObject() instanceof TrabalhadoresConsultasDatasObservacoesData )
|
||||
{
|
||||
action = SELECT_CONSULTA_MARCACAO_OBSERVACAO;
|
||||
}
|
||||
else if( node.getUserObject() instanceof TrabalhadoresConsultasDatasEmailsData )
|
||||
{
|
||||
action = SELECT_CONSULTA_MARCACAO_EMAIL;
|
||||
}
|
||||
else if( node.getUserObject() instanceof TrabalhadoresEcdsData )
|
||||
{
|
||||
action = SELECT_EXAME;
|
||||
}
|
||||
else if( node.getUserObject() instanceof TrabalhadoresEcdsDatasData )
|
||||
{
|
||||
action = SELECT_EXAME_MARCACAO;
|
||||
}
|
||||
else if( node.getUserObject() instanceof TrabalhadoresEcdsDatasEmailsData )
|
||||
{
|
||||
action = SELECT_EXAME_MARCACAO_EMAIL;
|
||||
}
|
||||
else if( node.getUserObject() instanceof TrabalhadoresEcdsDatasObservacoesData )
|
||||
{
|
||||
action = SELECT_EXAME_MARCACAO_OBSERVACAO;
|
||||
}
|
||||
else if( node instanceof FichaAptidaoMutableTreeNode )
|
||||
{
|
||||
action = SELECT_FICHA;
|
||||
}
|
||||
runAction( action, node.getUserObject() );
|
||||
return node;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = {
|
||||
CREATE_FICHA
|
||||
})
|
||||
public void createFicha()
|
||||
{
|
||||
try
|
||||
{
|
||||
FichaWindow fichaWindow = FichaWindow.getWindow();
|
||||
if( fichaWindow != null )
|
||||
{
|
||||
currentFicha = new TrabalhadoresFichasAptidaoData();
|
||||
currentFicha.setToProcesso_id( currentProcesso );
|
||||
Date data = getUltimaConsultaMarcacaoDateForProcesso();
|
||||
fichaWindow.editTrabalhador( currentTrabalhador.getId(), data, currentProcesso.getMotivo(), new SaveExameListener()
|
||||
{
|
||||
@Override
|
||||
public void exameSaved( Integer trabalhadorID, Integer exameID )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( trabalhadorID != null && exameID != null )
|
||||
{
|
||||
if( trabalhadorID.equals( currentTrabalhador.getId() ) )
|
||||
{
|
||||
currentFichaExameID = exameID;
|
||||
ExamesData exame = provider.getExameForExameID( currentFichaExameID );
|
||||
if( exame != null )
|
||||
{
|
||||
currentFicha.setToExame_id( exame );
|
||||
currentFicha.save();
|
||||
runAction( REFRESH );
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch( Exception e )
|
||||
{
|
||||
LeafDialog.error( e );
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
} catch( Exception e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private Date getUltimaConsultaMarcacaoDateForProcesso()
|
||||
{
|
||||
Date result = null;
|
||||
if( currentProcesso != null )
|
||||
{
|
||||
List<TrabalhadoresConsultasData> consultas = currentProcesso.fromTrabalhadoresConsultas_processo_id();
|
||||
for( TrabalhadoresConsultasData consulta : consultas )
|
||||
{
|
||||
if( new Integer( MedicinaConstants.ESTADO_REALIZADO ).equals( consulta.getEstado() ) )
|
||||
{
|
||||
List<TrabalhadoresConsultasDatasData> marcacoes = consulta.fromTrabalhadoresConsultasDatas_trabalhadores_consultas_id();
|
||||
for( TrabalhadoresConsultasDatasData marcacao : marcacoes )
|
||||
{
|
||||
if( new Integer( MedicinaConstants.ESTADO_REALIZADO ).equals( marcacao.getEstado() ) )
|
||||
{
|
||||
Date marcacaoDate = marcacao.getData();
|
||||
if( marcacaoDate != null && (result == null || result.before( marcacaoDate )) )
|
||||
{
|
||||
result = marcacaoDate;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = {
|
||||
CREATE_CONSULTA
|
||||
})
|
||||
public TrabalhadoresConsultasData createConsulta()
|
||||
{
|
||||
currentConsulta = new TrabalhadoresConsultasData();
|
||||
currentConsulta.setToTrabalhador_id( currentTrabalhador );
|
||||
currentConsulta.setToProcesso_id( currentProcesso );
|
||||
currentConsulta.setToPrestador_id( getPrestador( true ) );
|
||||
currentConsulta.setEstado( MedicinaConstants.ESTADO_POR_REALIZAR );
|
||||
return currentConsulta;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = {
|
||||
CREATE_CONSULTA_MARCACAO
|
||||
})
|
||||
public TrabalhadoresConsultasDatasData createConsultaMarcacao()
|
||||
{
|
||||
currentConsultaMarcacao = new TrabalhadoresConsultasDatasData();
|
||||
currentConsultaMarcacao.setToTrabalhadores_consultas_id( currentConsulta );
|
||||
currentConsultaMarcacao.setToPrestador_id( getPrestador( true ) );
|
||||
currentConsultaMarcacao.setEstado( MedicinaConstants.ESTADO_POR_REALIZAR );
|
||||
runActionLater( SAVE_CONSULTA_MARCACAO );
|
||||
return currentConsultaMarcacao;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = {
|
||||
CREATE_CONSULTA_MARCACAO_EMAIL
|
||||
})
|
||||
public TrabalhadoresConsultasDatasEmailsData createConsultaMarcacaoEmails()
|
||||
{
|
||||
currentConsultaMarcacaoEmail = new TrabalhadoresConsultasDatasEmailsData();
|
||||
currentConsultaMarcacaoEmail.setToTrabalhadores_consultas_datas_id( currentConsultaMarcacao );
|
||||
runActionLater( SAVE_CONSULTA_MARCACAO_EMAIL );
|
||||
return currentConsultaMarcacaoEmail;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = {
|
||||
CREATE_CONSULTA_MARCACAO_EMAIL_VACINAS
|
||||
})
|
||||
public TrabalhadoresConsultasDatasEmailsData createConsultaMarcacaoEmailsVacinas()
|
||||
{
|
||||
currentConsultaMarcacaoEmail = new TrabalhadoresConsultasDatasEmailsData();
|
||||
currentConsultaMarcacaoEmail.setToTrabalhadores_consultas_datas_id( currentConsultaMarcacao );
|
||||
runActionLater( SAVE_CONSULTA_MARCACAO_EMAIL );
|
||||
return currentConsultaMarcacaoEmail;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = {
|
||||
CREATE_CONSULTA_MARCACAO_OBSERVACOES
|
||||
})
|
||||
public TrabalhadoresConsultasDatasObservacoesData createConsultaMarcacaoObservacoes()
|
||||
{
|
||||
currentConsultaMarcacaoObservacao = new TrabalhadoresConsultasDatasObservacoesData();
|
||||
currentConsultaMarcacaoObservacao.setToTrabalhadores_consultas_datas_id( currentConsultaMarcacao );
|
||||
runActionLater( SAVE_CONSULTA_MARCACAO_OBSERVACOES );
|
||||
return currentConsultaMarcacaoObservacao;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = CREATE_EXAME)
|
||||
public TrabalhadoresEcdsData createExame()
|
||||
{
|
||||
currentExame = new TrabalhadoresEcdsData();
|
||||
currentExame.setToTrabalhador_id( currentTrabalhador );
|
||||
currentExame.setToProcesso_id( currentProcesso );
|
||||
currentExame.setEstado( MedicinaConstants.ESTADO_POR_REALIZAR );
|
||||
runActionLater( SAVE_EXAME );
|
||||
return currentExame;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = CREATE_EXAME_MARCACAO)
|
||||
public TrabalhadoresEcdsDatasData createExameMarcacao()
|
||||
{
|
||||
currentExameMarcacao = new TrabalhadoresEcdsDatasData();
|
||||
currentExameMarcacao.setToTrabalhadores_ecds_id( currentExame );
|
||||
currentExameMarcacao.setToPrestador_id( getPrestador( false ) );
|
||||
currentExameMarcacao.setToAnalisador_id( getAnalisador() );
|
||||
currentExameMarcacao.porRealizar();
|
||||
runActionLater( SAVE_EXAME_MARCACAO );
|
||||
return currentExameMarcacao;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = CREATE_EXAME_MARCACAO_OBSERVACOES)
|
||||
public TrabalhadoresEcdsDatasObservacoesData createExameMarcacaoObservacao()
|
||||
{
|
||||
currentExameMarcacaoObservacao = new TrabalhadoresEcdsDatasObservacoesData();
|
||||
currentExameMarcacaoObservacao.setToTrabalhadores_ecds_datas_id( currentExameMarcacao );
|
||||
runActionLater( SAVE_EXAME_MARCACAO_OBSERVACOES );
|
||||
return currentExameMarcacaoObservacao;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = CREATE_EXAME_MARCACAO_EMAIL)
|
||||
public TrabalhadoresEcdsDatasEmailsData createExameMarcacaoEmail()
|
||||
{
|
||||
currentExameMarcacaoEmail = new TrabalhadoresEcdsDatasEmailsData();
|
||||
currentExameMarcacaoEmail.setToTrabalhadores_ecds_datas_id( currentExameMarcacao );
|
||||
runActionLater( SAVE_EXAME_MARCACAO_EMAIL );
|
||||
return currentExameMarcacaoEmail;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = CREATE_PROCESSO)
|
||||
public TrabalhadoresProcessoData createProcesso()
|
||||
{
|
||||
currentProcesso = new TrabalhadoresProcessoData();
|
||||
currentProcesso.setData_inicio( new Date() );
|
||||
currentProcesso.setEstado( ProcessoConstants.PROCESSO_ABERTO_CODE );
|
||||
currentProcesso.setToTrabalhador_id( currentTrabalhador );
|
||||
currentProcesso.setActivo( "y" );
|
||||
runActionLater( SAVE_PROCESSO );
|
||||
return currentProcesso;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = CREATE_LEMBRETE)
|
||||
public LembretesData createLembrete()
|
||||
{
|
||||
LembretesData result = new LembretesData();
|
||||
result.setToTrabalhador_id( currentTrabalhador );
|
||||
result.setToEmpresa_id( currentEmpresa );
|
||||
result.setToEstabelecimento_id( currentEstabelecimento );
|
||||
result.setToTipo_id( provider.getTipoLembretesCustomizavel() );
|
||||
runActionLater( SAVE_LEMBRETE, result );
|
||||
return result;
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = {
|
||||
SAVE_PROCESSO, SAVE_LEMBRETE, SAVE_CONSULTA, SAVE_CONSULTA_MARCACAO, SAVE_CONSULTA_MARCACAO_EMAIL, SAVE_CONSULTA_MARCACAO_OBSERVACOES, SAVE_EXAME, SAVE_EXAME_MARCACAO, SAVE_EXAME_MARCACAO_EMAIL, SAVE_EXAME_MARCACAO_OBSERVACOES
|
||||
})
|
||||
public void saveObject( BaseObject object )
|
||||
{
|
||||
try
|
||||
{
|
||||
object.save();
|
||||
runActionLater( REFRESH );
|
||||
} catch( Exception e )
|
||||
{
|
||||
LeafDialog.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = {
|
||||
APAGAR_CONSULTA, APAGAR_EXAME
|
||||
})
|
||||
public void deleteObject( BaseObject object )
|
||||
{
|
||||
if( object instanceof TrabalhadoresConsultasData )
|
||||
{
|
||||
apagarConsulta( (TrabalhadoresConsultasData) object );
|
||||
}
|
||||
if( object instanceof TrabalhadoresEcdsData )
|
||||
{
|
||||
apagarExame( (TrabalhadoresEcdsData) object );
|
||||
}
|
||||
runActionLater( SELECT_PROCESSO );
|
||||
}
|
||||
|
||||
private void apagarConsulta( TrabalhadoresConsultasData consulta )
|
||||
{
|
||||
try
|
||||
{
|
||||
List<TrabalhadoresConsultasDatasData> marcacoes = consulta.fromTrabalhadoresConsultasDatas_trabalhadores_consultas_id();
|
||||
if( marcacoes != null )
|
||||
{
|
||||
for( TrabalhadoresConsultasDatasData marcacao : marcacoes )
|
||||
{
|
||||
List<TrabalhadoresConsultasDatasEmailsData> emails = marcacao.fromTrabalhadoresConsultasDatasEmails_trabalhadores_consultas_datas_id();
|
||||
if( emails != null )
|
||||
{
|
||||
for( TrabalhadoresConsultasDatasEmailsData email : emails )
|
||||
{
|
||||
email.delete();
|
||||
}
|
||||
}
|
||||
List<TrabalhadoresConsultasDatasObservacoesData> observacoes = marcacao.fromTrabalhadoresConsultasDatasObservacoes_trabalhadores_consultas_datas_id();
|
||||
if( observacoes != null )
|
||||
{
|
||||
for( TrabalhadoresConsultasDatasObservacoesData observacao : observacoes )
|
||||
{
|
||||
observacao.delete();
|
||||
}
|
||||
}
|
||||
marcacao.delete();
|
||||
}
|
||||
consulta.delete();
|
||||
}
|
||||
} catch( Exception e )
|
||||
{
|
||||
LeafDialog.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void apagarExame( TrabalhadoresEcdsData exame )
|
||||
{
|
||||
try
|
||||
{
|
||||
List<TrabalhadoresEcdsDatasData> marcacoes = exame.fromTrabalhadoresEcdsDatas_trabalhadores_ecds_id();
|
||||
if( marcacoes != null )
|
||||
{
|
||||
for( TrabalhadoresEcdsDatasData marcacao : marcacoes )
|
||||
{
|
||||
List<TrabalhadoresEcdData> ecds = marcacao.fromTrabalhadoresEcd_trabalhadores_ecds_datas_id();
|
||||
if( ecds != null )
|
||||
{
|
||||
for( TrabalhadoresEcdData ecd : ecds )
|
||||
{
|
||||
ecd.delete();
|
||||
}
|
||||
}
|
||||
List<TrabalhadoresEcdsDatasEmailsData> emails = marcacao.fromTrabalhadoresEcdsDatasEmails_trabalhadores_ecds_datas_id();
|
||||
if( emails != null )
|
||||
{
|
||||
for( TrabalhadoresEcdsDatasEmailsData email : emails )
|
||||
{
|
||||
email.delete();
|
||||
}
|
||||
}
|
||||
List<TrabalhadoresEcdsDatasObservacoesData> observacoes = marcacao.fromTrabalhadoresEcdsDatasObservacoes_trabalhadores_ecds_datas_id();
|
||||
if( observacoes != null )
|
||||
{
|
||||
for( TrabalhadoresEcdsDatasObservacoesData observacao : observacoes )
|
||||
{
|
||||
observacao.delete();
|
||||
}
|
||||
}
|
||||
marcacao.delete();
|
||||
}
|
||||
exame.delete();
|
||||
}
|
||||
} catch( Exception e )
|
||||
{
|
||||
LeafDialog.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@LeafLogicActionBinding(actions = ACTION_CANCEL)
|
||||
public void abortAction()
|
||||
{
|
||||
//FIXME : rollback
|
||||
// provider.rollback();
|
||||
runAction( LOAD_TRABALHADOR );
|
||||
runAction( SELECT_TRABALHADOR );
|
||||
}
|
||||
|
||||
private PrestadoresData getPrestador( boolean consulta )
|
||||
{
|
||||
PrestadoresData result = null;
|
||||
if( currentTrabalhador != null && currentTrabalhador.toEstabelecimento_id() != null )
|
||||
{
|
||||
result = consulta ? currentTrabalhador.toEstabelecimento_id().toPrestador_consulta_id() : currentTrabalhador.toEstabelecimento_id().toPrestador_ecds_id();
|
||||
if( PrestadoresData.prestadorNulo.equals( result ) )
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private PrestadoresData getAnalisador()
|
||||
{
|
||||
return getPrestador( false );
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,212 +0,0 @@
|
||||
package siprp.medicina.processo.ui;
|
||||
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CLOSE;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_LEMBRETE;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.REALIZAR_PARCIAL_EXAME_MARCACAO;
|
||||
import info.clearthought.layout.TableLayout;
|
||||
import info.clearthought.layout.TableLayoutConstraints;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JSeparator;
|
||||
|
||||
import leaf.ui.LeafCalendarDialog;
|
||||
import leaf.ui.LeafOptionDialog;
|
||||
import leaf.ui.LeafTextDialog;
|
||||
import leaf.ui.LeafWindow;
|
||||
import leaf.ui.LeafLogic.LeafUIActionBinding;
|
||||
import siprp.MedicinaConstants;
|
||||
import siprp.data.outer.LembretesData;
|
||||
import siprp.data.outer.PrtGruposProtocoloData;
|
||||
import siprp.data.outer.TrabalhadoresData;
|
||||
import siprp.data.outer.TrabalhadoresEcdData;
|
||||
import siprp.data.outer.TrabalhadoresEcdsDatasData;
|
||||
import siprp.medicina.processo.logic.MedicinaProcessoLogic;
|
||||
|
||||
import com.evolute.adt.OrderedMap;
|
||||
|
||||
public class MedicinaProcessoWindow extends LeafWindow
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Dimension WINDOW_DIMENSION = new Dimension( 1024, 700 );
|
||||
|
||||
public static final String TITLE = "Processos de Trabalhadores";
|
||||
|
||||
private static final Dimension DIMENSION_TRABALHADORES_CHOOSER = new Dimension( 0, 200 );
|
||||
private static final Dimension DIMENSION_PROCESSO_TOOLBAR = new Dimension( 150, 0 );
|
||||
|
||||
public final JSeparator separator = new JSeparator();
|
||||
@LeafPanel
|
||||
public final ProcessoDadosPanel panelProcessoDados;
|
||||
@LeafPanel
|
||||
public final ProcessoAccoesPanel panelProcessoToolbar;
|
||||
@LeafPanel
|
||||
public final ProcessoTreePanel panelProcessoTree;
|
||||
@LeafPanel
|
||||
public final TrabalhadoresChooserPanel panelTrabalhadoresChooser;
|
||||
|
||||
public MedicinaProcessoWindow() throws Exception
|
||||
{
|
||||
super( new MedicinaProcessoLogic() );
|
||||
panelProcessoDados = new ProcessoDadosPanel( this );
|
||||
panelProcessoToolbar = new ProcessoAccoesPanel( this );
|
||||
panelProcessoTree = new ProcessoTreePanel( this );
|
||||
panelTrabalhadoresChooser = new TrabalhadoresChooserPanel( this );
|
||||
|
||||
startup();
|
||||
}
|
||||
|
||||
public MedicinaProcessoWindow(TrabalhadoresData trabalhador) throws Exception
|
||||
{
|
||||
super( new MedicinaProcessoLogic() );
|
||||
panelProcessoDados = new ProcessoDadosPanel( this );
|
||||
panelProcessoToolbar = new ProcessoAccoesPanel( this );
|
||||
panelProcessoTree = new ProcessoTreePanel( this );
|
||||
panelTrabalhadoresChooser = new TrabalhadoresChooserPanel( this );
|
||||
startup();
|
||||
runAction( MedicinaProcessoLogic.LOAD_TRABALHADOR, trabalhador );
|
||||
}
|
||||
|
||||
private void startup()
|
||||
{
|
||||
setSize( WINDOW_DIMENSION );
|
||||
setTitle( TITLE );
|
||||
setupLayout();
|
||||
setupComponents();
|
||||
placeComponents();
|
||||
completeSetup();
|
||||
}
|
||||
|
||||
private void setupLayout()
|
||||
{
|
||||
double[] cols = new double[] {
|
||||
TableLayout.PREFERRED, TableLayout.FILL, TableLayout.FILL
|
||||
};
|
||||
double[] rows = new double[] {
|
||||
TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL
|
||||
};
|
||||
TableLayout layout = new TableLayout( cols, rows );
|
||||
layout.setVGap( 5 );
|
||||
layout.setHGap( 5 );
|
||||
this.setLayout( layout );
|
||||
}
|
||||
|
||||
private void setupComponents()
|
||||
{
|
||||
panelTrabalhadoresChooser.setPreferredSize( DIMENSION_TRABALHADORES_CHOOSER );
|
||||
panelProcessoToolbar.setPreferredSize( DIMENSION_PROCESSO_TOOLBAR );
|
||||
}
|
||||
|
||||
private void placeComponents()
|
||||
{
|
||||
this.add( panelTrabalhadoresChooser, new TableLayoutConstraints( 0, 0, 2, 0 ) );
|
||||
this.add( separator, new TableLayoutConstraints( 0, 1, 2, 1 ) );
|
||||
this.add( panelProcessoToolbar, new TableLayoutConstraints( 0, 2 ) );
|
||||
this.add( panelProcessoTree, new TableLayoutConstraints( 1, 2 ) );
|
||||
this.add( panelProcessoDados, new TableLayoutConstraints( 2, 2 ) );
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CLOSE)
|
||||
public void closeWindow()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = REALIZAR_PARCIAL_EXAME_MARCACAO)
|
||||
public void realizarExameParcial( TrabalhadoresEcdsDatasData marcacao )
|
||||
{
|
||||
boolean atLeastOneRealizado = false;
|
||||
boolean atLeastOneFalta = false;
|
||||
if( marcacao != null )
|
||||
{
|
||||
List<TrabalhadoresEcdData> ecds = marcacao.fromTrabalhadoresEcd_trabalhadores_ecds_datas_id();
|
||||
if( ecds != null )
|
||||
{
|
||||
OrderedMap<PrtGruposProtocoloData> allGrupos = marcacao.getStatesForeGruposExames();
|
||||
OrderedMap<PrtGruposProtocoloData> grupos = new OrderedMap<PrtGruposProtocoloData>();
|
||||
for( int row = 0; row < allGrupos.rows(); ++row )
|
||||
{
|
||||
List<Object> grupo = allGrupos.getRow( row );
|
||||
if( grupo != null && grupo.size() > 1 )
|
||||
{
|
||||
String estado = grupo.get( 1 ).toString();
|
||||
if( MedicinaConstants.ESTADOS_EXAME_STR[MedicinaConstants.ESTADO_POR_REALIZAR].equals( estado ) )
|
||||
{
|
||||
PrtGruposProtocoloData key = allGrupos.getKeyForValue( grupo );
|
||||
grupos.addRow( key, grupo );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LeafOptionDialog<PrtGruposProtocoloData> option = new LeafOptionDialog<PrtGruposProtocoloData>( this, grupos, null, null, "Marcar falta para:", "Faltou >>" );
|
||||
List<PrtGruposProtocoloData> selected = option.getSelected();
|
||||
if( selected != null )
|
||||
{
|
||||
for( TrabalhadoresEcdData ecd : ecds )
|
||||
{
|
||||
if( selected.contains( ecd.toEcd_id().toGrupo_protocolo_id() ) )
|
||||
{
|
||||
ecd.setEstado( MedicinaConstants.ESTADO_FALTOU );
|
||||
atLeastOneFalta = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ecd.setEstado( MedicinaConstants.ESTADO_REALIZADO );
|
||||
atLeastOneRealizado = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if( atLeastOneFalta )
|
||||
{
|
||||
if( atLeastOneRealizado )
|
||||
{
|
||||
marcacao.setEstado( MedicinaConstants.ESTADO_PARCIALMENTE_REALIZADO );
|
||||
}
|
||||
else
|
||||
{
|
||||
marcacao.setEstado( MedicinaConstants.ESTADO_FALTOU );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( atLeastOneRealizado )
|
||||
{
|
||||
marcacao.setEstado( MedicinaConstants.ESTADO_REALIZADO );
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_LEMBRETE)
|
||||
public void createLembrete( LembretesData lembrete )
|
||||
{
|
||||
if( lembrete != null )
|
||||
{
|
||||
Date date = new LeafCalendarDialog( this ).getDate();
|
||||
if( date != null && date.getTime() != 0 )
|
||||
{
|
||||
String text = new LeafTextDialog( this, null, "", true ).getText();
|
||||
if( text != null && !text.trim().equals( "" ) )
|
||||
{
|
||||
lembrete.setData( date );
|
||||
lembrete.setDescricao( text );
|
||||
}
|
||||
else
|
||||
{
|
||||
abortAction( true );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
abortAction( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,551 +0,0 @@
|
||||
package siprp.medicina.processo.ui;
|
||||
|
||||
import static com.evolute.utils.strings.UnicodeLatin1Map.atilde;
|
||||
import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil;
|
||||
import static com.evolute.utils.strings.UnicodeLatin1Map.otilde;
|
||||
import static info.clearthought.layout.TableLayoutConstants.FILL;
|
||||
import static info.clearthought.layout.TableLayoutConstants.MINIMUM;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.ANULAR_EXAME_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.APAGAR_CONSULTA;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.APAGAR_CONSULTA_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.APAGAR_EXAME;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.APAGAR_EXAME_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.APAGAR_PROCESSO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO_EMAIL;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO_EMAIL_VACINAS;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO_OBSERVACOES;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME_MARCACAO_EMAIL;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME_MARCACAO_OBSERVACOES;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_FICHA;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_LEMBRETE;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_PROCESSO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.DESMARCAR_SIPRP_CONSULTA_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.DESMARCAR_SIPRP_EXAME_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.DESMARCAR_TRABALHADOR_CONSULTA_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.DESMARCAR_TRABALHADOR_EXAME_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.FALTOU_CONSULTA_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.FALTOU_EXAME_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.FECHAR_PROCESSO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.LOAD_TRABALHADOR;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.REALIZAR_CONSULTA_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.REALIZAR_EXAME_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.REALIZAR_PARCIAL_EXAME_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA_MARCACAO_EMAIL;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA_MARCACAO_OBSERVACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME_MARCACAO_EMAIL;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME_MARCACAO_OBSERVACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_FICHA;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_PROCESSO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_TRABALHADOR;
|
||||
import info.clearthought.layout.TableLayout;
|
||||
import info.clearthought.layout.TableLayoutConstraints;
|
||||
|
||||
import java.awt.CardLayout;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import leaf.ui.LeafButton;
|
||||
import leaf.ui.LeafWindow;
|
||||
import leaf.ui.LeafLogic.LeafUIActionBinding;
|
||||
import leaf.ui.LeafWindow.ActionActivation;
|
||||
import siprp.MedicinaConstants;
|
||||
import siprp.ProcessoConstants;
|
||||
import siprp.data.outer.TrabalhadoresConsultasData;
|
||||
import siprp.data.outer.TrabalhadoresConsultasDatasData;
|
||||
import siprp.data.outer.TrabalhadoresConsultasDatasEmailsData;
|
||||
import siprp.data.outer.TrabalhadoresConsultasDatasObservacoesData;
|
||||
import siprp.data.outer.TrabalhadoresData;
|
||||
import siprp.data.outer.TrabalhadoresEcdsData;
|
||||
import siprp.data.outer.TrabalhadoresEcdsDatasData;
|
||||
import siprp.data.outer.TrabalhadoresEcdsDatasEmailsData;
|
||||
import siprp.data.outer.TrabalhadoresEcdsDatasObservacoesData;
|
||||
import siprp.data.outer.TrabalhadoresFichasAptidaoData;
|
||||
import siprp.data.outer.TrabalhadoresProcessoData;
|
||||
|
||||
public class ProcessoAccoesPanel extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final LeafWindow parentWindow;
|
||||
|
||||
private static final String PANEL_START_NAME = "START_PANEL";
|
||||
|
||||
private static final String PANEL_TRABALHADOR_NAME = "TRABALHADOR_PANEL";
|
||||
|
||||
private static final String PANEL_PROCESSO_NAME = "PROCESSO_PANEL";
|
||||
|
||||
private static final String PANEL_FICHA_NAME = "PANEL_FICHA_NAME";
|
||||
|
||||
private static final String PANEL_CONSULTA_NAME = "PANEL_CONSULTA_NAME";
|
||||
|
||||
private static final String PANEL_CONSULTA_MARCACAO_NAME = "PANEL_CONSULTA_MARCACAO_NAME";
|
||||
|
||||
private static final String PANEL_EXAME_NAME = "EXAME_PANEL";
|
||||
|
||||
private static final String PANEL_EXAME_MARCACAO_NAME = "PANEL_EXAME_MARCACAO_NAME";
|
||||
|
||||
private final JPanel cardPanel = new JPanel();
|
||||
|
||||
private final CardLayout cardLayout = new CardLayout();
|
||||
|
||||
// panels
|
||||
private final JPanel panelExame = new JPanel();
|
||||
private final JPanel panelExameMarcacao = new JPanel();
|
||||
|
||||
private final JPanel panelConsulta = new JPanel();
|
||||
private final JPanel panelConsultaMarcacao = new JPanel();
|
||||
|
||||
private final JPanel panelProcesso = new JPanel();
|
||||
|
||||
private final JPanel panelFicha = new JPanel();
|
||||
|
||||
private final JPanel panelTrabalhador = new JPanel();
|
||||
|
||||
private final JPanel panelStart = new JPanel();
|
||||
|
||||
// trabalhador
|
||||
@ActionActivation(onSelect = CREATE_PROCESSO, onChange = "")
|
||||
public final LeafButton buttonNovoTrabalhadorProcesso = new LeafButton( "Novo Processo" );
|
||||
|
||||
@ActionActivation(onSelect = CREATE_LEMBRETE, onChange = "")
|
||||
public final LeafButton buttonNovoLembrete = new LeafButton( "Novo Lembrete" );
|
||||
|
||||
// processo
|
||||
@ActionActivation(onSelect = FECHAR_PROCESSO, onChange = "")
|
||||
public final LeafButton buttonFecharProcesso = new LeafButton( "Fechar Processo" );
|
||||
|
||||
@ActionActivation(onSelect = CREATE_FICHA, onChange = "")
|
||||
public final LeafButton buttonCriarFicha = new LeafButton( "Ficha de Aptid"+atilde+"o" );
|
||||
|
||||
@ActionActivation(onSelect = {
|
||||
CREATE_CONSULTA, CREATE_CONSULTA_MARCACAO
|
||||
}, onChange = "")
|
||||
public final LeafButton buttonNovoProcessoConsulta = new LeafButton( "Nova Consulta" );
|
||||
|
||||
@ActionActivation(onSelect = {
|
||||
CREATE_EXAME, CREATE_EXAME_MARCACAO
|
||||
}, onChange = "")
|
||||
public final LeafButton buttonNovoProcessoExame = new LeafButton( "Novo Exame" );
|
||||
|
||||
@ActionActivation(onSelect = APAGAR_PROCESSO, onChange = "")
|
||||
public final LeafButton buttonApagarProcesso = new LeafButton( "Remover Processo" );
|
||||
|
||||
// consulta
|
||||
|
||||
@ActionActivation(onSelect = APAGAR_CONSULTA, onChange = "")
|
||||
public final LeafButton buttonApagarConsulta = new LeafButton( "Apagar Consulta" );
|
||||
|
||||
// marcacao consulta
|
||||
|
||||
@ActionActivation(onSelect = CREATE_CONSULTA_MARCACAO, onChange = "")
|
||||
public final LeafButton buttonNovoConsultaMarcacao = new LeafButton( "Nova Marca" + ccedil + atilde + "o" );
|
||||
|
||||
@ActionActivation(onSelect = APAGAR_CONSULTA_MARCACAO, onChange = "")
|
||||
public final LeafButton buttonApagarConsultaMarcacao = new LeafButton( "Apagar Marca" + ccedil + atilde + "o" );
|
||||
|
||||
@ActionActivation(onSelect = CREATE_CONSULTA_MARCACAO_EMAIL, onChange = "")
|
||||
public final LeafButton buttonNovoConsultaMarcacaoEmail = new LeafButton( "e-Mail" );
|
||||
|
||||
@ActionActivation(onSelect = CREATE_CONSULTA_MARCACAO_EMAIL_VACINAS, onChange = "")
|
||||
public final LeafButton buttonNovoConsultaMarcacaoEmailVacinas = new LeafButton( "e-Mail: Boletim" );
|
||||
|
||||
@ActionActivation(onSelect = CREATE_CONSULTA_MARCACAO_OBSERVACOES, onChange = "")
|
||||
public final LeafButton buttonNovoConsultaMarcacaoObservacoes = new LeafButton( "Adicionar Observa" + ccedil + atilde + "o" );
|
||||
|
||||
@ActionActivation(onSelect = DESMARCAR_SIPRP_CONSULTA_MARCACAO, onChange = "")
|
||||
public final LeafButton buttonConsultaMarcacaoDesmarcarSiprp = new LeafButton( "Desmarcar (SIPRP)" );
|
||||
|
||||
@ActionActivation(onSelect = DESMARCAR_TRABALHADOR_CONSULTA_MARCACAO, onChange = "")
|
||||
public final LeafButton buttonConsultaMarcacaoDesmarcarTrabalhador = new LeafButton( "Desmarcar (Trab)" );
|
||||
|
||||
@ActionActivation(onSelect = REALIZAR_CONSULTA_MARCACAO, onChange = "")
|
||||
public final LeafButton buttonConsultaMarcacaoRealizar = new LeafButton( "Realizar" );
|
||||
|
||||
@ActionActivation(onSelect = FALTOU_CONSULTA_MARCACAO, onChange = "")
|
||||
public final LeafButton buttonConsultaMarcacaoFaltou = new LeafButton( "Faltou" );
|
||||
|
||||
// email marcacao consulta
|
||||
|
||||
// observacoes marcacao consulta
|
||||
|
||||
// exame
|
||||
@ActionActivation(onSelect = APAGAR_EXAME, onChange = "")
|
||||
public final LeafButton buttonApagarExame = new LeafButton( "Apagar Exame" );
|
||||
|
||||
// marcacao exame
|
||||
|
||||
@ActionActivation(onSelect = CREATE_EXAME_MARCACAO, onChange = "")
|
||||
public final LeafButton buttonNovoExameMarcacao = new LeafButton( "Nova Marca" + ccedil + atilde + "o" );
|
||||
|
||||
@ActionActivation(onSelect = APAGAR_EXAME_MARCACAO, onChange = "")
|
||||
public final LeafButton buttonApagarExameMarcacao = new LeafButton( "Apagar Marca" + ccedil + atilde + "o" );
|
||||
|
||||
@ActionActivation(onSelect = CREATE_EXAME_MARCACAO_EMAIL, onChange = "")
|
||||
public final LeafButton buttonNovoExameMarcacaoEmail = new LeafButton( "e-Mail" );
|
||||
@ActionActivation(onSelect = CREATE_EXAME_MARCACAO_OBSERVACOES, onChange = "")
|
||||
public final LeafButton buttonNovoExameMarcacaoObservacoes = new LeafButton( "Adicionar Observa" + ccedil + atilde + "o" );
|
||||
|
||||
@ActionActivation(onSelect = DESMARCAR_SIPRP_EXAME_MARCACAO, onChange = "")
|
||||
public final LeafButton buttonExameMarcacaoDesmarcarSiprp = new LeafButton( "Desmarcar (SIPRP)" );
|
||||
|
||||
@ActionActivation(onSelect = DESMARCAR_TRABALHADOR_EXAME_MARCACAO, onChange = "")
|
||||
public final LeafButton buttonExameMarcacaoDesmarcarTrabalhador = new LeafButton( "Desmarcar (Trab)" );
|
||||
|
||||
@ActionActivation(onSelect = REALIZAR_EXAME_MARCACAO, onChange = "")
|
||||
public final LeafButton buttonExameMarcacaoRealizar = new LeafButton( "Realizar" );
|
||||
|
||||
@ActionActivation(onSelect = REALIZAR_PARCIAL_EXAME_MARCACAO, onChange = "")
|
||||
public final LeafButton buttonExameMarcacaoRealizarParcial = new LeafButton( "Realizar Parcial." );
|
||||
|
||||
@ActionActivation(onSelect = FALTOU_EXAME_MARCACAO, onChange = "")
|
||||
public final LeafButton buttonExameMarcacaoFaltou = new LeafButton( "Faltou" );
|
||||
|
||||
@ActionActivation(onSelect = ANULAR_EXAME_MARCACAO, onChange = "")
|
||||
public final LeafButton buttonExameMarcacaoAnular = new LeafButton( "Anular" );
|
||||
|
||||
// email marcacao exame
|
||||
|
||||
// observacoes marcacao exame
|
||||
|
||||
// control
|
||||
|
||||
public ProcessoAccoesPanel(LeafWindow parentWindow)
|
||||
{
|
||||
this.parentWindow = parentWindow;
|
||||
setupLayout();
|
||||
setupComponents();
|
||||
placeComponents();
|
||||
}
|
||||
|
||||
private void setupLayout()
|
||||
{
|
||||
TableLayout layout = new TableLayout( new double[] {
|
||||
TableLayout.FILL
|
||||
}, new double[] {
|
||||
TableLayout.FILL
|
||||
} );
|
||||
this.setLayout( layout );
|
||||
cardPanel.setLayout( cardLayout );
|
||||
}
|
||||
|
||||
private void setupComponents()
|
||||
{
|
||||
this.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Ac" + ccedil + otilde + "es" ) );
|
||||
setupStartPanel();
|
||||
setupTrabalhadorPanel();
|
||||
setupProcessoPanel();
|
||||
setupFichaPanel();
|
||||
setupConsultaPanel();
|
||||
setupConsultaMarcacaoPanel();
|
||||
setupExamePanel();
|
||||
setupExameMarcacaoPanel();
|
||||
}
|
||||
|
||||
private void placeComponents()
|
||||
{
|
||||
cardPanel.add( panelStart, PANEL_START_NAME );
|
||||
cardPanel.add( panelTrabalhador, PANEL_TRABALHADOR_NAME );
|
||||
cardPanel.add( panelProcesso, PANEL_PROCESSO_NAME );
|
||||
cardPanel.add( panelFicha, PANEL_FICHA_NAME);
|
||||
cardPanel.add( panelConsulta, PANEL_CONSULTA_NAME );
|
||||
cardPanel.add( panelConsultaMarcacao, PANEL_CONSULTA_MARCACAO_NAME );
|
||||
cardPanel.add( panelExame, PANEL_EXAME_NAME );
|
||||
cardPanel.add( panelExameMarcacao, PANEL_EXAME_MARCACAO_NAME );
|
||||
this.add( cardPanel, new TableLayoutConstraints( 0, 0 ) );
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = {
|
||||
LOAD_TRABALHADOR, SELECT_TRABALHADOR
|
||||
})
|
||||
public void setForTrabalhador( TrabalhadoresData trabalhador )
|
||||
{
|
||||
if( trabalhador != null )
|
||||
{
|
||||
boolean processoAberto = false;
|
||||
for( TrabalhadoresProcessoData processo : (List<TrabalhadoresProcessoData>) trabalhador.fromTrabalhadoresProcesso_trabalhador_id() )
|
||||
{
|
||||
if( ProcessoConstants.PROCESSO_ABERTO_CODE.equals( processo.getEstado() ) )
|
||||
{
|
||||
processoAberto = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
buttonNovoTrabalhadorProcesso.setEnabled( !processoAberto );
|
||||
buttonNovoLembrete.setEnabled( true );
|
||||
cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_START_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_PROCESSO)
|
||||
public void setForProcesso( TrabalhadoresProcessoData processo )
|
||||
{
|
||||
if( processo != null )
|
||||
{
|
||||
buttonFecharProcesso.setEnabled( !ProcessoConstants.PROCESSO_FECHADO_CODE.equals( processo.getEstado() ) );
|
||||
buttonApagarProcesso.setEnabled( processo.isEmpty() );
|
||||
boolean consultaAberta = false;
|
||||
for( TrabalhadoresConsultasData consulta : (List<TrabalhadoresConsultasData>) processo.fromTrabalhadoresConsultas_processo_id() )
|
||||
{
|
||||
if( new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ).equals( consulta.getEstado() ) )
|
||||
{
|
||||
consultaAberta = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
buttonNovoProcessoConsulta.setEnabled( !consultaAberta );
|
||||
|
||||
cardLayout.show( cardPanel, PANEL_PROCESSO_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_FICHA)
|
||||
public void setForFicha( TrabalhadoresFichasAptidaoData ficha)
|
||||
{
|
||||
if( ficha != null )
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_FICHA_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_CONSULTA)
|
||||
public void setForConsulta( TrabalhadoresConsultasData consulta )
|
||||
{
|
||||
if( consulta != null )
|
||||
{
|
||||
boolean marcacaoAberta = false;
|
||||
for( TrabalhadoresConsultasDatasData marcacao : (List<TrabalhadoresConsultasDatasData>) consulta.fromTrabalhadoresConsultasDatas_trabalhadores_consultas_id() )
|
||||
{
|
||||
if( new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ).equals( marcacao.getEstado() ) )
|
||||
{
|
||||
marcacaoAberta = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
buttonNovoConsultaMarcacao.setEnabled( !marcacaoAberta && !new Integer( MedicinaConstants.ESTADO_REALIZADO ).equals( consulta.getEstado() ) );
|
||||
buttonApagarConsulta.setEnabled( marcacaoAberta );
|
||||
cardLayout.show( cardPanel, PANEL_CONSULTA_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_CONSULTA_MARCACAO)
|
||||
public void setForConsultaMarcacao( TrabalhadoresConsultasDatasData marcacao )
|
||||
{
|
||||
if( marcacao != null )
|
||||
{
|
||||
boolean porRealizar = new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ).equals( marcacao.getEstado() );
|
||||
boolean realizada = new Integer( MedicinaConstants.ESTADO_REALIZADO ).equals( marcacao.getEstado() );
|
||||
List list = marcacao.fromTrabalhadoresConsultasDatasObservacoes_trabalhadores_consultas_datas_id();
|
||||
boolean noObservacoes = (list == null || list.size() == 0) ? true : false;
|
||||
buttonConsultaMarcacaoDesmarcarSiprp.setEnabled( porRealizar );
|
||||
buttonConsultaMarcacaoDesmarcarTrabalhador.setEnabled( porRealizar );
|
||||
buttonConsultaMarcacaoFaltou.setEnabled( porRealizar );
|
||||
buttonConsultaMarcacaoRealizar.setEnabled( porRealizar );
|
||||
buttonNovoConsultaMarcacaoObservacoes.setEnabled( noObservacoes );
|
||||
buttonNovoConsultaMarcacaoEmailVacinas.setEnabled( realizada );
|
||||
buttonApagarConsultaMarcacao.setEnabled( porRealizar );
|
||||
cardLayout.show( cardPanel, PANEL_CONSULTA_MARCACAO_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_CONSULTA_MARCACAO_EMAIL)
|
||||
public void setForConsultaMarcacaoEmail( TrabalhadoresConsultasDatasEmailsData email )
|
||||
{
|
||||
if( email != null )
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_START_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_CONSULTA_MARCACAO_OBSERVACAO)
|
||||
public void setForConsultaMarcacaoObservacao( TrabalhadoresConsultasDatasObservacoesData obs )
|
||||
{
|
||||
if( obs != null )
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_START_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_EXAME)
|
||||
public void setForExame( TrabalhadoresEcdsData exame )
|
||||
{
|
||||
if( exame != null )
|
||||
{
|
||||
boolean porMarcar = new Integer( MedicinaConstants.ESTADO_POR_MARCAR ).equals( exame.getEstado() );
|
||||
boolean porRealizado = new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ).equals( exame.getEstado() );
|
||||
buttonNovoExameMarcacao.setEnabled( porMarcar );
|
||||
buttonApagarExame.setEnabled( porRealizado );
|
||||
cardLayout.show( cardPanel, PANEL_EXAME_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_EXAME_MARCACAO)
|
||||
public void setForExameMarcacao( TrabalhadoresEcdsDatasData marcacao )
|
||||
{
|
||||
if( marcacao != null )
|
||||
{
|
||||
boolean porRealizar = new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ).equals( marcacao.getEstado() );
|
||||
List list = marcacao.fromTrabalhadoresEcdsDatasObservacoes_trabalhadores_ecds_datas_id();
|
||||
boolean noObservacoes = (list == null || list.size() == 0) ? true : false;
|
||||
buttonExameMarcacaoDesmarcarSiprp.setEnabled( porRealizar );
|
||||
buttonExameMarcacaoDesmarcarTrabalhador.setEnabled( porRealizar );
|
||||
buttonExameMarcacaoFaltou.setEnabled( porRealizar );
|
||||
buttonExameMarcacaoRealizar.setEnabled( porRealizar );
|
||||
buttonExameMarcacaoRealizarParcial.setEnabled( porRealizar );
|
||||
buttonExameMarcacaoAnular.setEnabled( porRealizar );
|
||||
buttonApagarExameMarcacao.setEnabled( porRealizar );
|
||||
buttonNovoExameMarcacaoObservacoes.setEnabled( noObservacoes );
|
||||
cardLayout.show( cardPanel, PANEL_EXAME_MARCACAO_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_EXAME_MARCACAO_EMAIL)
|
||||
public void setForExameMarcacaoEmail( TrabalhadoresEcdsDatasEmailsData email )
|
||||
{
|
||||
if( email != null )
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_START_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_EXAME_MARCACAO_OBSERVACAO)
|
||||
public void setForExameMarcacaoObservacao( TrabalhadoresEcdsDatasObservacoesData obs )
|
||||
{
|
||||
if( obs != null )
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_START_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
private void setupStartPanel()
|
||||
{
|
||||
}
|
||||
|
||||
private void setupTrabalhadorPanel()
|
||||
{
|
||||
setupSimpleActionsPanel( panelTrabalhador, buttonNovoTrabalhadorProcesso, buttonNovoLembrete, new JPanel() );
|
||||
}
|
||||
|
||||
private void setupProcessoPanel()
|
||||
{
|
||||
JPanel panelTopProcesso = new JPanel();
|
||||
JPanel panelBottomProcesso = new JPanel();
|
||||
setupSimpleActionsPanel( panelTopProcesso, buttonNovoProcessoConsulta, buttonNovoProcessoExame );
|
||||
setupSimpleActionsPanel( panelBottomProcesso, buttonCriarFicha, buttonFecharProcesso, buttonApagarProcesso );
|
||||
setupTopBottomSimpleActionsPanel( panelProcesso, panelTopProcesso, panelBottomProcesso );
|
||||
}
|
||||
|
||||
private void setupFichaPanel()
|
||||
{
|
||||
setupSimpleActionsPanel( panelFicha, new JPanel() );
|
||||
}
|
||||
|
||||
private void setupConsultaPanel()
|
||||
{
|
||||
setupSimpleActionsPanel( panelConsulta, buttonNovoConsultaMarcacao, buttonApagarConsulta, new JPanel() );
|
||||
}
|
||||
|
||||
private void setupConsultaMarcacaoPanel()
|
||||
{
|
||||
JPanel consultaMarcacaoUpperPanel = new JPanel();
|
||||
JPanel consultaMarcacaoLowerPanel = new JPanel();
|
||||
setupSimpleActionsPanel( consultaMarcacaoUpperPanel, buttonNovoConsultaMarcacaoEmail, buttonNovoConsultaMarcacaoEmailVacinas, buttonNovoConsultaMarcacaoObservacoes );
|
||||
setupSimpleActionsPanel( consultaMarcacaoLowerPanel, buttonConsultaMarcacaoRealizar, buttonConsultaMarcacaoDesmarcarSiprp, buttonConsultaMarcacaoDesmarcarTrabalhador, buttonConsultaMarcacaoFaltou, buttonApagarConsultaMarcacao);
|
||||
setupTopBottomSimpleActionsPanel(panelConsultaMarcacao, consultaMarcacaoUpperPanel, consultaMarcacaoLowerPanel);
|
||||
}
|
||||
|
||||
private void setupExameMarcacaoPanel()
|
||||
{
|
||||
JPanel exameMarcacaoUpperPanel = new JPanel();
|
||||
JPanel exameMarcacaoLowerPanel = new JPanel();
|
||||
setupSimpleActionsPanel( exameMarcacaoUpperPanel, buttonNovoExameMarcacaoEmail, buttonNovoExameMarcacaoObservacoes, new JPanel() );
|
||||
setupSimpleActionsPanel( exameMarcacaoLowerPanel, buttonExameMarcacaoRealizar, buttonExameMarcacaoRealizarParcial, buttonExameMarcacaoFaltou, buttonExameMarcacaoAnular, buttonExameMarcacaoDesmarcarTrabalhador, buttonExameMarcacaoDesmarcarSiprp, buttonApagarExameMarcacao );
|
||||
setupTopBottomSimpleActionsPanel(panelExameMarcacao, exameMarcacaoUpperPanel, exameMarcacaoLowerPanel);
|
||||
}
|
||||
|
||||
private void setupExamePanel()
|
||||
{
|
||||
setupSimpleActionsPanel( panelExame, buttonNovoExameMarcacao, buttonApagarExame, new JPanel() );
|
||||
}
|
||||
|
||||
private void setupTopBottomSimpleActionsPanel(JPanel panel, JPanel top, JPanel bottom)
|
||||
{
|
||||
TableLayout layout = new TableLayout(new double[]{TableLayout.FILL}, new double[]{TableLayout.MINIMUM, TableLayout.FILL,TableLayout.MINIMUM});
|
||||
panel.setLayout( layout );
|
||||
panel.add( top, new TableLayoutConstraints(0,0) );
|
||||
panel.add( new JPanel(), new TableLayoutConstraints(0,1) );
|
||||
panel.add( bottom, new TableLayoutConstraints(0,2) );
|
||||
}
|
||||
|
||||
private void setupSimpleActionsPanel( JPanel panel, JComponent... field )
|
||||
{
|
||||
double[] cols = new double[] {
|
||||
FILL
|
||||
};
|
||||
double[] rows = new double[field.length];
|
||||
for( int i = 0; i < field.length; rows[i++] = MINIMUM )
|
||||
;
|
||||
rows[rows.length - 1] = FILL;
|
||||
TableLayout layout = new TableLayout( cols, rows );
|
||||
panel.setLayout( layout );
|
||||
|
||||
for( int i = 0; i < field.length; ++i )
|
||||
{
|
||||
panel.add( field[i], new TableLayoutConstraints( 0, i ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,902 +0,0 @@
|
||||
package siprp.medicina.processo.ui;
|
||||
|
||||
import static com.evolute.utils.strings.UnicodeLatin1Map.atilde;
|
||||
import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil;
|
||||
import static com.evolute.utils.strings.UnicodeLatin1Map.iacute;
|
||||
import static com.evolute.utils.strings.UnicodeLatin1Map.otilde;
|
||||
import static info.clearthought.layout.TableLayoutConstants.FILL;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO_EMAIL;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO_EMAIL_VACINAS;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO_OBSERVACOES;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME_MARCACAO_EMAIL;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME_MARCACAO_OBSERVACOES;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_PROCESSO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.LOAD_TRABALHADOR;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SAVE_CONSULTA_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SAVE_CONSULTA_MARCACAO_OBSERVACOES;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SAVE_EXAME_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SAVE_EXAME_MARCACAO_OBSERVACOES;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SAVE_PROCESSO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA_MARCACAO_EMAIL;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA_MARCACAO_OBSERVACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME_MARCACAO_EMAIL;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME_MARCACAO_OBSERVACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_FICHA;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_PROCESSO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_TRABALHADOR;
|
||||
import info.clearthought.layout.TableLayout;
|
||||
import info.clearthought.layout.TableLayoutConstraints;
|
||||
|
||||
import java.awt.CardLayout;
|
||||
import java.io.File;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import leaf.ui.LeafCalendarDialog;
|
||||
import leaf.ui.LeafInputField;
|
||||
import leaf.ui.LeafOptionDialog;
|
||||
import leaf.ui.LeafTextDialog;
|
||||
import leaf.ui.LeafWindow;
|
||||
import leaf.ui.LeafLogic.LeafUIActionBinding;
|
||||
import leaf.ui.LeafWindow.ActionActivation;
|
||||
import siprp.CompanyDataLoader;
|
||||
import siprp.MedicinaConstants;
|
||||
import siprp.ProcessoConstants;
|
||||
import siprp.SingletonConstants;
|
||||
import siprp.data.outer.ContactosData;
|
||||
import siprp.data.outer.EstabelecimentosData;
|
||||
import siprp.data.outer.PrestadoresData;
|
||||
import siprp.data.outer.PrtGruposProtocoloData;
|
||||
import siprp.data.outer.TrabalhadoresConsultasData;
|
||||
import siprp.data.outer.TrabalhadoresConsultasDatasData;
|
||||
import siprp.data.outer.TrabalhadoresConsultasDatasEmailsData;
|
||||
import siprp.data.outer.TrabalhadoresConsultasDatasObservacoesData;
|
||||
import siprp.data.outer.TrabalhadoresData;
|
||||
import siprp.data.outer.TrabalhadoresEcdData;
|
||||
import siprp.data.outer.TrabalhadoresEcdsData;
|
||||
import siprp.data.outer.TrabalhadoresEcdsDatasData;
|
||||
import siprp.data.outer.TrabalhadoresEcdsDatasEmailsData;
|
||||
import siprp.data.outer.TrabalhadoresEcdsDatasObservacoesData;
|
||||
import siprp.data.outer.TrabalhadoresFichasAptidaoData;
|
||||
import siprp.data.outer.TrabalhadoresProcessoData;
|
||||
import siprp.medicina.MedicinaDataProvider;
|
||||
import siprp.medicina.processo.mail.MailDialog;
|
||||
|
||||
import com.evolute.adt.OrderedMap;
|
||||
import com.evolute.utils.Singleton;
|
||||
|
||||
public class ProcessoDadosPanel extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final LeafWindow parentWindow;
|
||||
|
||||
private static final String PANEL_START_NAME = "START_PANEL";
|
||||
|
||||
private static final String PANEL_TRABALHADOR_NAME = "TRABALHADOR_PANEL";
|
||||
|
||||
private static final String PANEL_PROCESSO_NAME = "PROCESSO_PANEL";
|
||||
|
||||
private static final String PANEL_FICHA_NAME = "PANEL_FICHA_NAME";
|
||||
|
||||
private static final String PANEL_CONSULTA_NAME = "PANEL_CONSULTA_NAME";
|
||||
private static final String PANEL_CONSULTA_MARCACAO_NAME = "PANEL_CONSULTA_MARCACAO_NAME";
|
||||
private static final String PANEL_CONSULTA_MARCACAO_EMAIL_NAME = "PANEL_CONSULTA_MARCACAO_EMAIL_NAME";
|
||||
private static final String PANEL_CONSULTA_MARCACAO_OBSERVACOES_NAME = "PANEL_CONSULTA_MARCACAO_OBSERVACOES_NAME";
|
||||
|
||||
private static final String PANEL_EXAME_NAME = "EXAME_PANEL";
|
||||
private static final String PANEL_EXAME_MARCACAO_NAME = "PANEL_EXAME_MARCACAO_NAME";
|
||||
private static final String PANEL_EXAME_MARCACAO_EMAIL_NAME = "PANEL_EXAME_MARCACAO_EMAIL_NAME";
|
||||
private static final String PANEL_EXAME_MARCACAO_OBSERVACAO_NAME = "PANEL_EXAME_MARCACAO_OBSERVACAO_NAME";
|
||||
|
||||
private final CardLayout cardLayout = new CardLayout();
|
||||
|
||||
// panels
|
||||
private final JPanel panelExame = new JPanel();
|
||||
private final JPanel panelExameMarcacao = new JPanel();
|
||||
private final JPanel panelExameMarcacaoEmail = new JPanel();
|
||||
private final JPanel panelExameMarcacaoObservacao = new JPanel();
|
||||
|
||||
private final JPanel panelConsulta = new JPanel();
|
||||
private final JPanel panelConsultaMarcacao = new JPanel();
|
||||
private final JPanel panelConsultaMarcacaoEmail = new JPanel();
|
||||
private final JPanel panelConsultaMarcacaoObservacao = new JPanel();
|
||||
|
||||
private final JPanel panelProcesso = new JPanel();
|
||||
|
||||
private final JPanel panelTrabalhador = new JPanel();
|
||||
|
||||
private final JPanel panelFicha = new JPanel();
|
||||
|
||||
private final JPanel panelStart = new JPanel();
|
||||
|
||||
// trabalhador
|
||||
private final JLabel labelTrabalhadorNome = new JLabel( "Nome" );
|
||||
private final JLabel labelTrabalhadorSexo = new JLabel( "Sexo" );
|
||||
private final JLabel labelTrabalhadoresDataNascimento = new JLabel( "Data de Nascimento" );
|
||||
private final JLabel labelTrabalhadorNacionalidade = new JLabel( "Nacionalidade" );
|
||||
private final JLabel labelTrabalhadorBI = new JLabel( "B.I." );
|
||||
private final JLabel labelTrabalhadorObservacoes = new JLabel( "Observa" + ccedil + otilde + "es" );
|
||||
private final JLabel labelTrabalhadoresDataAdmissao = new JLabel( "Data de Admiss" + atilde + "o" );
|
||||
|
||||
public final LeafInputField<String> inputTrabalhadorNome = new LeafInputField<String>();
|
||||
public final LeafInputField<HashMap<String, String>> inputTrabalhadorSexo = new LeafInputField<HashMap<String, String>>();
|
||||
public final LeafInputField<Date> inputTrabalhadoresDataNascimento = new LeafInputField<Date>();
|
||||
public final LeafInputField<String> inputTrabalhadorNacionalidade = new LeafInputField<String>();
|
||||
public final LeafInputField<String> inputTrabalhadorBI = new LeafInputField<String>();
|
||||
public final LeafInputField<String> inputTrabalhadorObservacoes = new LeafInputField<String>();
|
||||
public final LeafInputField<Date> inputTrabalhadoresDataAdmissao = new LeafInputField<Date>();
|
||||
|
||||
// processo
|
||||
|
||||
private final JLabel labelProcessoEstado = new JLabel( "Estado" );
|
||||
private final JLabel labelProcessoDataInicio = new JLabel( "In" + iacute + "cio" );
|
||||
private final JLabel labelProcessoDataFim = new JLabel( "Fim" );
|
||||
private final JLabel labelProcessoMotivo = new JLabel( "Motivo" );
|
||||
|
||||
public final LeafInputField<HashMap<String, String>> inputProcessoEstado = new LeafInputField<HashMap<String, String>>();
|
||||
public final LeafInputField<Date> inputProcessoDataInicio = new LeafInputField<Date>();
|
||||
public final LeafInputField<Date> inputProcessoDataFim = new LeafInputField<Date>();
|
||||
@ActionActivation(onSelect = "", onChange = SAVE_PROCESSO)
|
||||
public final LeafInputField<HashMap<Integer, String>> inputProcessoMotivo = new LeafInputField<HashMap<Integer, String>>();
|
||||
|
||||
// consulta
|
||||
private final JLabel labelConsultaEstado = new JLabel( "Estado" );
|
||||
private final JLabel labelConsultaData = new JLabel( "Data" );
|
||||
private final JLabel labelConsultaPrestador = new JLabel( "Prestador" );
|
||||
|
||||
public final LeafInputField<HashMap<Integer, String>> inputConsultaEstado = new LeafInputField<HashMap<Integer, String>>();
|
||||
public final LeafInputField<Date> inputConsultaData = new LeafInputField<Date>();
|
||||
public final LeafInputField<String> inputConsultaPrestador = new LeafInputField<String>();
|
||||
|
||||
// marcacao consulta
|
||||
private final JLabel labelConsultaMarcacaoEstado = new JLabel( "Estado" );
|
||||
private final JLabel labelConsultaMarcacaoData = new JLabel( "Data" );
|
||||
private final JLabel labelConsultaMarcacaoPrestador = new JLabel( "Prestador" );
|
||||
|
||||
public final LeafInputField<HashMap<Integer, String>> inputConsultaMarcacaoEstado = new LeafInputField<HashMap<Integer, String>>();
|
||||
public final LeafInputField<Date> inputConsultaMarcacaoData = new LeafInputField<Date>();
|
||||
@ActionActivation(onSelect = "", onChange = SAVE_CONSULTA_MARCACAO)
|
||||
public final LeafInputField<OrderedMap<PrestadoresData>> inputConsultaMarcacaoPrestador = new LeafInputField<OrderedMap<PrestadoresData>>();
|
||||
|
||||
// email marcacao consulta
|
||||
private final JLabel labelConsultaMarcacaoEmailData = new JLabel( "Data" );
|
||||
private final JLabel labelConsultaMarcacaoEmailSubject = new JLabel( "Assunto" );
|
||||
private final JLabel labelConsultaMarcacaoEmailBody = new JLabel( "Mensagem" );
|
||||
|
||||
public final LeafInputField<Date> inputConsultaMarcacaoEmailData = new LeafInputField<Date>();
|
||||
public final LeafInputField<String> inputConsultaMarcacaoEmailSubject = new LeafInputField<String>();
|
||||
public final LeafInputField<String> inputConsultaMarcacaoEmailBody = new LeafInputField<String>();
|
||||
|
||||
// observacao marcacao consulta
|
||||
@ActionActivation(onSelect = "", onChange = SAVE_CONSULTA_MARCACAO_OBSERVACOES)
|
||||
public final LeafInputField<String> inputConsultaMarcacaoObsMensagem = new LeafInputField<String>();
|
||||
|
||||
// exame
|
||||
private final JLabel labelExameEstado = new JLabel( "Estado" );
|
||||
private final JLabel labelExameData = new JLabel( "Data" );
|
||||
private final JLabel labelExameGruposEcds = new JLabel( "ECDs" );
|
||||
|
||||
public final LeafInputField<HashMap<Integer, String>> inputExameEstado = new LeafInputField<HashMap<Integer, String>>();
|
||||
public final LeafInputField<OrderedMap<PrtGruposProtocoloData>> inputExameGruposEcds = new LeafInputField<OrderedMap<PrtGruposProtocoloData>>();
|
||||
public final LeafInputField<Date> inputExameData = new LeafInputField<Date>();
|
||||
|
||||
// marcacao exame
|
||||
private final JLabel labelExameMarcacaoEstado = new JLabel( "Estado" );
|
||||
private final JLabel labelExameMarcacaoData = new JLabel( "Data" );
|
||||
private final JLabel labelExameMarcacaoGruposEcds = new JLabel( "ECDs" );
|
||||
private final JLabel labelExameMarcacaoPrestador = new JLabel( "Prestador" );
|
||||
private final JLabel labelExameMarcacaoAnalisador = new JLabel( "Analisadores" );
|
||||
private final JLabel labelExameMarcacaoDataRecepcao = new JLabel( "Data de recep" + ccedil + atilde + "o" );
|
||||
|
||||
public final LeafInputField<HashMap<Integer, String>> inputExameMarcacaoEstado = new LeafInputField<HashMap<Integer, String>>();
|
||||
public final LeafInputField<Date> inputExameMarcacaoData = new LeafInputField<Date>();
|
||||
@ActionActivation(onSelect = "", onChange = SAVE_EXAME_MARCACAO)
|
||||
public final LeafInputField<Date> inputExameMarcacaoDataRecepcao = new LeafInputField<Date>();
|
||||
public final LeafInputField<OrderedMap<PrtGruposProtocoloData>> inputExameMarcacaoGruposEcds = new LeafInputField<OrderedMap<PrtGruposProtocoloData>>();
|
||||
@ActionActivation(onSelect = "", onChange = SAVE_EXAME_MARCACAO)
|
||||
public final LeafInputField<OrderedMap<PrestadoresData>> inputExameMarcacaoPrestador = new LeafInputField<OrderedMap<PrestadoresData>>();
|
||||
@ActionActivation(onSelect = "", onChange = SAVE_EXAME_MARCACAO)
|
||||
public final LeafInputField<OrderedMap<PrtGruposProtocoloData>> inputExameMarcacaoAnalisador = new LeafInputField<OrderedMap<PrtGruposProtocoloData>>();
|
||||
|
||||
// email marcacao exame
|
||||
private final JLabel labelExameMarcacaoEmailData = new JLabel( "Data" );
|
||||
private final JLabel labelExameMarcacaoEmailSubject = new JLabel( "Assunto" );
|
||||
private final JLabel labelExameMarcacaoEmailBody = new JLabel( "Mensagem" );
|
||||
|
||||
public final LeafInputField<Date> inputExameMarcacaoEmailData = new LeafInputField<Date>();
|
||||
public final LeafInputField<String> inputExameMarcacaoEmailSubject = new LeafInputField<String>();
|
||||
public final LeafInputField<String> inputExameMarcacaoEmailBody = new LeafInputField<String>();
|
||||
|
||||
// observacao marcacao exame
|
||||
@ActionActivation(onSelect = "", onChange = SAVE_EXAME_MARCACAO_OBSERVACOES)
|
||||
public final LeafInputField<String> inputExameMarcacaoObsMensagem = new LeafInputField<String>();
|
||||
|
||||
public ProcessoDadosPanel(LeafWindow parentWindow)
|
||||
{
|
||||
this.parentWindow = parentWindow;
|
||||
setupLayout();
|
||||
setupComponents();
|
||||
placeComponents();
|
||||
}
|
||||
|
||||
private void setupLayout()
|
||||
{
|
||||
this.setLayout( cardLayout );
|
||||
}
|
||||
|
||||
private void setupComponents()
|
||||
{
|
||||
setupStartPanel();
|
||||
setupTrabalhadorPanel();
|
||||
setupProcessoPanel();
|
||||
setupFichaPanel();
|
||||
setupConsultaPanel();
|
||||
setupConsultaMarcacaoPanel();
|
||||
setupConsultaMarcacaoEmailPanel();
|
||||
setupConsultaMarcacaoObservacoesPanel();
|
||||
setupExamePanel();
|
||||
setupExameMarcacaoPanel();
|
||||
setupExameMarcacaoEmailPanel();
|
||||
setupExameMarcacaoObservacoesPanel();
|
||||
}
|
||||
|
||||
private void placeComponents()
|
||||
{
|
||||
add( panelStart, PANEL_START_NAME );
|
||||
add( panelTrabalhador, PANEL_TRABALHADOR_NAME );
|
||||
add( panelFicha, PANEL_FICHA_NAME );
|
||||
add( panelProcesso, PANEL_PROCESSO_NAME );
|
||||
add( panelConsulta, PANEL_CONSULTA_NAME );
|
||||
add( panelConsultaMarcacao, PANEL_CONSULTA_MARCACAO_NAME );
|
||||
add( panelConsultaMarcacaoEmail, PANEL_CONSULTA_MARCACAO_EMAIL_NAME );
|
||||
add( panelConsultaMarcacaoObservacao, PANEL_CONSULTA_MARCACAO_OBSERVACOES_NAME );
|
||||
add( panelExame, PANEL_EXAME_NAME );
|
||||
add( panelExameMarcacao, PANEL_EXAME_MARCACAO_NAME );
|
||||
add( panelExameMarcacaoEmail, PANEL_EXAME_MARCACAO_EMAIL_NAME );
|
||||
add( panelExameMarcacaoObservacao, PANEL_EXAME_MARCACAO_OBSERVACAO_NAME );
|
||||
}
|
||||
|
||||
private int getIdade( Date nascimento )
|
||||
{
|
||||
int result = 0;
|
||||
if( nascimento != null )
|
||||
{
|
||||
Calendar now = Calendar.getInstance();
|
||||
Calendar birth = Calendar.getInstance();
|
||||
birth.setTime( nascimento );
|
||||
int birthYear = birth.get( Calendar.YEAR );
|
||||
int currentYear = now.get( Calendar.YEAR );
|
||||
if( birthYear < currentYear )
|
||||
{
|
||||
result = currentYear - birthYear;
|
||||
birth.add( Calendar.YEAR, result );
|
||||
if( birth.after( now ) )
|
||||
{
|
||||
--result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = {
|
||||
LOAD_TRABALHADOR, SELECT_TRABALHADOR
|
||||
})
|
||||
public void setForTrabalhador( TrabalhadoresData trabalhador )
|
||||
{
|
||||
if( trabalhador != null )
|
||||
{
|
||||
inputTrabalhadoresDataNascimento.setObject( trabalhador.getData_nascimento() );
|
||||
inputTrabalhadorSexo.setObject( trabalhador.getSexos(), trabalhador.getSexo() );
|
||||
inputTrabalhadorNome.setObject( trabalhador.getNome() );
|
||||
inputTrabalhadorNacionalidade.setObject( trabalhador.getNacionalidade() );
|
||||
inputTrabalhadorBI.setObject( trabalhador.getBi() );
|
||||
inputTrabalhadorObservacoes.setObject( trabalhador.getObservacoes_gestao() );
|
||||
inputTrabalhadoresDataAdmissao.setObject( trabalhador.getData_admissao() );
|
||||
labelTrabalhadoresDataNascimento.setText( "Data de Nascimento (" + getIdade( trabalhador.getData_nascimento() ) + " anos)" );
|
||||
|
||||
cardLayout.show( this, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( this, PANEL_START_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_PROCESSO)
|
||||
public void setForProcesso( TrabalhadoresProcessoData processo )
|
||||
{
|
||||
if( processo != null )
|
||||
{
|
||||
boolean isFechado = ProcessoConstants.PROCESSO_FECHADO_CODE.equals( processo.getEstado() );
|
||||
inputProcessoDataFim.setObject( processo.getData_fim() );
|
||||
inputProcessoDataInicio.setObject( processo.getData_inicio() );
|
||||
inputProcessoEstado.setObject( processo.getEstados(), processo.getEstado() );
|
||||
inputProcessoMotivo.setEditable( !isFechado );
|
||||
inputProcessoMotivo.setObject( processo.getMotivos(), processo.getMotivo() );
|
||||
cardLayout.show( this, PANEL_PROCESSO_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( this, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_FICHA)
|
||||
public void setForFicha( TrabalhadoresFichasAptidaoData ficha )
|
||||
{
|
||||
if( ficha != null )
|
||||
{
|
||||
cardLayout.show( this, PANEL_FICHA_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( this, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_CONSULTA)
|
||||
public void setForConsulta( TrabalhadoresConsultasData consulta )
|
||||
{
|
||||
if( consulta != null )
|
||||
{
|
||||
inputConsultaEstado.setObject( MedicinaDataProvider.getConsultaEstados(), consulta.getEstado() );
|
||||
inputConsultaData.setObject( consulta.getData() == null ? new Date( 0 ) : consulta.getData() );
|
||||
|
||||
inputConsultaPrestador.setObject( (consulta.toPrestador_id() == null || consulta.toPrestador_id().getNome() == null) ? " " : consulta.toPrestador_id().getNome() );
|
||||
|
||||
cardLayout.show( this, PANEL_CONSULTA_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( this, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_CONSULTA_MARCACAO)
|
||||
public void setForConsultaMarcacao( TrabalhadoresConsultasDatasData marcacao )
|
||||
{
|
||||
if( marcacao != null )
|
||||
{
|
||||
inputConsultaMarcacaoData.setObject( marcacao.getData() );
|
||||
inputConsultaMarcacaoEstado.setObject( MedicinaDataProvider.getConsultaEstados(), marcacao.getEstado() );
|
||||
|
||||
inputConsultaMarcacaoPrestador.setEditable( true );
|
||||
|
||||
PrestadoresData prestador = marcacao.toPrestador_id();
|
||||
List<PrestadoresData> allPrestadores = PrestadoresData.getAllPrestadores();
|
||||
inputConsultaMarcacaoPrestador.setObject( new OrderedMap<PrestadoresData>( allPrestadores ), prestador == null ? PrestadoresData.prestadorNulo : prestador );
|
||||
cardLayout.show( this, PANEL_CONSULTA_MARCACAO_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( this, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_CONSULTA_MARCACAO_EMAIL)
|
||||
public void setForConsultaMarcacaoEmail( TrabalhadoresConsultasDatasEmailsData email )
|
||||
{
|
||||
if( email != null )
|
||||
{
|
||||
inputConsultaMarcacaoEmailBody.setObject( email.getBody() );
|
||||
inputConsultaMarcacaoEmailSubject.setObject( email.getSubject() );
|
||||
inputConsultaMarcacaoEmailData.setObject( email.getData() );
|
||||
cardLayout.show( this, PANEL_CONSULTA_MARCACAO_EMAIL_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( this, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_CONSULTA_MARCACAO_OBSERVACAO)
|
||||
public void setForConsultaMarcacaoObs( TrabalhadoresConsultasDatasObservacoesData obs )
|
||||
{
|
||||
if( obs != null )
|
||||
{
|
||||
inputConsultaMarcacaoObsMensagem.setEditable( true );
|
||||
inputConsultaMarcacaoObsMensagem.setObject( obs.getObservacao() == null ? "" : obs.getObservacao() );
|
||||
cardLayout.show( this, PANEL_CONSULTA_MARCACAO_OBSERVACOES_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( this, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_EXAME)
|
||||
public void setForExame( TrabalhadoresEcdsData exame )
|
||||
{
|
||||
if( exame != null )
|
||||
{
|
||||
inputExameData.setObject( exame.getData() );
|
||||
inputExameEstado.setObject( exame.getEstados(), exame.getEstado() );
|
||||
OrderedMap<PrtGruposProtocoloData> grupos = exame.getGruposExamesForPerfil();
|
||||
inputExameGruposEcds.setCollapseOptions( false );
|
||||
inputExameGruposEcds.setObject( grupos, grupos.getFirst() );
|
||||
cardLayout.show( this, PANEL_EXAME_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( this, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_EXAME_MARCACAO)
|
||||
public void setForExameMarcacao( TrabalhadoresEcdsDatasData exameMarcacao )
|
||||
{
|
||||
if( exameMarcacao != null )
|
||||
{
|
||||
inputExameMarcacaoData.setObject( exameMarcacao.getData() );
|
||||
Date dataRecepcao = exameMarcacao.getData_recepcao();
|
||||
inputExameMarcacaoDataRecepcao.setObject( dataRecepcao == null ? new Date(0) : dataRecepcao );
|
||||
inputExameMarcacaoDataRecepcao.setEditable( true );
|
||||
inputExameMarcacaoEstado.setObject( exameMarcacao.getEstados(), exameMarcacao.getEstado() );
|
||||
OrderedMap<PrtGruposProtocoloData> grupos = exameMarcacao.getStatesForeGruposExames();
|
||||
inputExameMarcacaoGruposEcds.setCollapseOptions( false );
|
||||
inputExameMarcacaoGruposEcds.setObject( grupos, grupos.getFirst() );
|
||||
|
||||
PrestadoresData prestador = exameMarcacao.toPrestador_id();
|
||||
List<PrestadoresData> allPrestadores = PrestadoresData.getAllPrestadores();
|
||||
|
||||
if( prestador == null )
|
||||
{
|
||||
prestador = PrestadoresData.prestadorNulo;
|
||||
}
|
||||
|
||||
inputExameMarcacaoPrestador.setEditable( true );
|
||||
inputExameMarcacaoPrestador.setObject( new OrderedMap<PrestadoresData>( allPrestadores ), prestador );
|
||||
|
||||
boolean editable = PrestadoresData.prestadorNulo.equals( prestador );
|
||||
inputExameMarcacaoAnalisador.setCollapseOptions( false );
|
||||
|
||||
List<TrabalhadoresEcdData> allECDS = exameMarcacao.fromTrabalhadoresEcd_trabalhadores_ecds_datas_id();
|
||||
OrderedMap<PrtGruposProtocoloData> analisadoresForGrupos = new OrderedMap<PrtGruposProtocoloData>();
|
||||
|
||||
if( allECDS != null )
|
||||
{
|
||||
for( TrabalhadoresEcdData current : allECDS )
|
||||
{
|
||||
PrestadoresData currentAnalisador = current.toAnalisador_id();
|
||||
|
||||
if( !prestador.equals( PrestadoresData.prestadorNulo ) )
|
||||
{
|
||||
currentAnalisador = prestador;
|
||||
}
|
||||
else if( currentAnalisador == null )
|
||||
{
|
||||
currentAnalisador = PrestadoresData.prestadorNulo;
|
||||
}
|
||||
|
||||
PrtGruposProtocoloData grupo = current.toEcd_id().toGrupo_protocolo_id();
|
||||
if( !analisadoresForGrupos.containsKey( grupo ) )
|
||||
{
|
||||
analisadoresForGrupos.putLast( grupo, grupo.getDescricao() );
|
||||
LeafInputField<OrderedMap<PrestadoresData>> leaf = new LeafInputField<OrderedMap<PrestadoresData>>();
|
||||
leaf.setObject( new OrderedMap<PrestadoresData>( allPrestadores ), currentAnalisador );
|
||||
leaf.setEditable( editable );
|
||||
analisadoresForGrupos.putLast( grupo, leaf );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inputExameMarcacaoAnalisador.setObject( analisadoresForGrupos );
|
||||
|
||||
inputExameMarcacaoAnalisador.setEditable( PrestadoresData.prestadorNulo.equals( prestador ) );
|
||||
|
||||
cardLayout.show( this, PANEL_EXAME_MARCACAO_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( this, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_EXAME_MARCACAO_EMAIL)
|
||||
public void setForExameMarcacaoEmail( TrabalhadoresEcdsDatasEmailsData email )
|
||||
{
|
||||
if( email != null )
|
||||
{
|
||||
inputExameMarcacaoEmailBody.setObject( email.getBody() );
|
||||
inputExameMarcacaoEmailSubject.setObject( email.getSubject() );
|
||||
inputExameMarcacaoEmailData.setObject( email.getData() );
|
||||
cardLayout.show( this, PANEL_EXAME_MARCACAO_EMAIL_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( this, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_EXAME_MARCACAO_OBSERVACAO)
|
||||
public void setForExameMarcacaoObs( TrabalhadoresEcdsDatasObservacoesData obs )
|
||||
{
|
||||
if( obs != null )
|
||||
{
|
||||
inputExameMarcacaoObsMensagem.setObject( obs.getObservacao() == null ? "" : obs.getObservacao() );
|
||||
inputExameMarcacaoObsMensagem.setEditable( true );
|
||||
cardLayout.show( this, PANEL_EXAME_MARCACAO_OBSERVACAO_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
cardLayout.show( this, PANEL_TRABALHADOR_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_PROCESSO)
|
||||
public void setForNewProcesso( TrabalhadoresProcessoData processo )
|
||||
{
|
||||
HashMap<Integer, String> tipos = processo.getMotivos();
|
||||
LeafOptionDialog<Integer> option = new LeafOptionDialog<Integer>( parentWindow, tipos, "Escolha o tipo de processo:" );
|
||||
Integer chosen = option.getOption();
|
||||
if( chosen != null )
|
||||
{
|
||||
processo.setMotivo( chosen );
|
||||
}
|
||||
inputProcessoMotivo.setObject( tipos, chosen );
|
||||
inputProcessoDataInicio.setObject( processo.getData_inicio() );
|
||||
inputProcessoDataFim.setObject( processo.getData_fim() );
|
||||
inputProcessoEstado.setObject( processo.getEstados(), processo.getEstado() );
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO)
|
||||
public void setForNewConsultaMarcacao( TrabalhadoresConsultasDatasData marcacao )
|
||||
{
|
||||
LeafCalendarDialog calendar = new LeafCalendarDialog( parentWindow, false, true );
|
||||
Date date = calendar.getDate();
|
||||
if( date == null )
|
||||
{
|
||||
parentWindow.abortAction( true );
|
||||
}
|
||||
marcacao.setData( date );
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO_EMAIL)
|
||||
public void setForNewConsultaMarcacaoEmail( TrabalhadoresConsultasDatasEmailsData email )
|
||||
{
|
||||
if( email != null )
|
||||
{
|
||||
TrabalhadoresConsultasDatasData consultaMarcacao = email.toTrabalhadores_consultas_datas_id();
|
||||
if( consultaMarcacao != null )
|
||||
{
|
||||
TrabalhadoresConsultasData consulta = consultaMarcacao.toTrabalhadores_consultas_id();
|
||||
if( consulta != null )
|
||||
{
|
||||
String[] subjectAndBody = MedicinaConstants.ESTADO_REALIZADO == consulta.getEstado() ? sendMail( consulta.toTrabalhador_id(), consultaMarcacao.getDataString(), "", "" ) : sendMail( consulta.toTrabalhador_id(), consultaMarcacao.getDataString(), SingletonConstants.LETTER_CONSULTA, SingletonConstants.SUBJECT_CONSULTA );
|
||||
if( subjectAndBody != null )
|
||||
{
|
||||
email.setSubject( subjectAndBody[0] );
|
||||
email.setBody( subjectAndBody[1] );
|
||||
}
|
||||
else
|
||||
{
|
||||
parentWindow.abortAction( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO_EMAIL_VACINAS)
|
||||
public void setForNewConsultaMarcacaoEmailVacinas( TrabalhadoresConsultasDatasEmailsData email )
|
||||
{
|
||||
if( email != null )
|
||||
{
|
||||
TrabalhadoresConsultasDatasData consultaMarcacao = email.toTrabalhadores_consultas_datas_id();
|
||||
if( consultaMarcacao != null )
|
||||
{
|
||||
TrabalhadoresConsultasData consulta = consultaMarcacao.toTrabalhadores_consultas_id();
|
||||
if( consulta != null )
|
||||
{
|
||||
String[] subjectAndBody = sendMail( consulta.toTrabalhador_id(), consultaMarcacao.getDataString(), SingletonConstants.LETTER_CONSULTA_VACINAS, SingletonConstants.SUBJECT_CONSULTA_VACINAS );
|
||||
if( subjectAndBody != null )
|
||||
{
|
||||
email.setSubject( subjectAndBody[0] );
|
||||
email.setBody( subjectAndBody[1] );
|
||||
}
|
||||
else
|
||||
{
|
||||
parentWindow.abortAction( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String[] sendMail( TrabalhadoresData trabalhador, String data, String letterName, String subjectName )
|
||||
{
|
||||
String[] result = null;
|
||||
if( trabalhador != null )
|
||||
{
|
||||
EstabelecimentosData estabelecimento = trabalhador.toEstabelecimento_id();
|
||||
if( estabelecimento != null )
|
||||
{
|
||||
String to = "";
|
||||
String bcc = "";
|
||||
String subject = "";
|
||||
String body = "";
|
||||
|
||||
subject = (String) Singleton.getInstance( subjectName );
|
||||
if( subject == null )
|
||||
{
|
||||
subject = "";
|
||||
}
|
||||
subject = subject.replaceAll( CompanyDataLoader.NOME, trabalhador.getNome() );
|
||||
|
||||
body = (String) Singleton.getInstance( letterName );
|
||||
if( body == null )
|
||||
{
|
||||
body = "";
|
||||
}
|
||||
body = body.replaceAll( CompanyDataLoader.DATA, data );
|
||||
body = body.replaceAll( CompanyDataLoader.NOME, trabalhador.getNome() );
|
||||
// body = body.replaceAll( CompanyDataLoader.MORADA, morada );
|
||||
body = body.replaceAll( "%0A", "<br>" );
|
||||
|
||||
ContactosData estabelecimentoContacto = estabelecimento.toContacto_id();
|
||||
if( estabelecimentoContacto != null )
|
||||
{
|
||||
String estabelecimentoEmail = estabelecimentoContacto.getEmail();
|
||||
if( estabelecimentoEmail != null )
|
||||
{
|
||||
to = estabelecimentoEmail;
|
||||
try
|
||||
{
|
||||
MailDialog mailDialog = new MailDialog( parentWindow, to, bcc, subject, body, new Vector<File>() );
|
||||
result = new String[2];
|
||||
result[0] = mailDialog.getSubject();
|
||||
result[1] = mailDialog.getMessage();
|
||||
} catch( Exception e )
|
||||
{
|
||||
e.printStackTrace( System.out );
|
||||
e.printStackTrace();
|
||||
result = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO_OBSERVACOES)
|
||||
public void setForNewConsultaMarcacaoObservacoes( TrabalhadoresConsultasDatasObservacoesData observacoes )
|
||||
{
|
||||
LeafTextDialog textDialog = new LeafTextDialog( parentWindow, this, "", true );
|
||||
String text = textDialog.getText();
|
||||
observacoes.setObservacao( text );
|
||||
inputConsultaMarcacaoObsMensagem.setEditable( true );
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_EXAME_MARCACAO)
|
||||
public void setForNewExameMarcacao( TrabalhadoresEcdsDatasData marcacao )
|
||||
{
|
||||
LeafCalendarDialog calendar = new LeafCalendarDialog( parentWindow, false, true );
|
||||
Date date = calendar.getDate();
|
||||
if( date == null )
|
||||
{
|
||||
parentWindow.abortAction( true );
|
||||
}
|
||||
marcacao.setData( date );
|
||||
|
||||
OrderedMap<PrtGruposProtocoloData> allGrupos = marcacao.toTrabalhadores_ecds_id().getGruposExamesForPerfil();
|
||||
OrderedMap<PrtGruposProtocoloData> grupos = new OrderedMap<PrtGruposProtocoloData>();
|
||||
Map<PrtGruposProtocoloData, Boolean> gruposSelected = new HashMap<PrtGruposProtocoloData, Boolean>();
|
||||
for( int row = 0; row < allGrupos.rows(); ++row )
|
||||
{
|
||||
List<Object> grupo = allGrupos.getRow( row );
|
||||
if( grupo != null && grupo.size() > 1 )
|
||||
{
|
||||
String estado = grupo.get( 1 ).toString();
|
||||
if( MedicinaConstants.ESTADOS_EXAME_STR[MedicinaConstants.ESTADO_POR_MARCAR].equals( estado ) )
|
||||
{
|
||||
PrtGruposProtocoloData key = allGrupos.getKeyForValue( grupo );
|
||||
gruposSelected.put( key, true );
|
||||
grupos.addRow( key, grupo );
|
||||
}
|
||||
}
|
||||
}
|
||||
LeafOptionDialog<PrtGruposProtocoloData> gruposChosen = new LeafOptionDialog<PrtGruposProtocoloData>( parentWindow, grupos, gruposSelected, null, "Escolha os ECDs para esta marca" + ccedil + atilde + "o", "Marcar >>" );
|
||||
for( PrtGruposProtocoloData grupo : gruposChosen.getSelected() )
|
||||
{
|
||||
marcacao.marcarGrupoExames( grupo );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_EXAME_MARCACAO_EMAIL)
|
||||
public void setForNewExameMarcacaoEmail( TrabalhadoresEcdsDatasEmailsData email )
|
||||
{
|
||||
if( email != null )
|
||||
{
|
||||
TrabalhadoresEcdsDatasData exameMarcacao = email.toTrabalhadores_ecds_datas_id();
|
||||
if( exameMarcacao != null )
|
||||
{
|
||||
TrabalhadoresEcdsData exame = exameMarcacao.toTrabalhadores_ecds_id();
|
||||
if( exame != null )
|
||||
{
|
||||
String[] subjectAndBody = MedicinaConstants.ESTADO_REALIZADO == exame.getEstado() ?
|
||||
sendMail( exame.toTrabalhador_id(), exame.getDataString(), "", "" )
|
||||
:
|
||||
sendMail( exame.toTrabalhador_id(), exameMarcacao.getDataString(), SingletonConstants.LETTER_EXAMES, SingletonConstants.SUBJECT_EXAMES );
|
||||
if( subjectAndBody != null )
|
||||
{
|
||||
email.setSubject( subjectAndBody[0] );
|
||||
email.setBody( subjectAndBody[1] );
|
||||
}
|
||||
else
|
||||
{
|
||||
parentWindow.abortAction( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_EXAME_MARCACAO_OBSERVACOES)
|
||||
public void setForNewExameMarcacaoObservacoes( TrabalhadoresEcdsDatasObservacoesData observacoes )
|
||||
{
|
||||
LeafTextDialog textDialog = new LeafTextDialog( parentWindow, this, "", true );
|
||||
String text = textDialog.getText();
|
||||
observacoes.setObservacao( text );
|
||||
inputExameMarcacaoObsMensagem.setEditable( true );
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SAVE_PROCESSO)
|
||||
public void updateToSaveProcesso( TrabalhadoresProcessoData processo )
|
||||
{
|
||||
processo.setMotivo( (Integer) inputProcessoMotivo.getSelectedObject() );
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SAVE_CONSULTA_MARCACAO)
|
||||
public void updateToSaveConsultaMarcacao( TrabalhadoresConsultasDatasData marcacao )
|
||||
{
|
||||
PrestadoresData prestador = (PrestadoresData) inputConsultaMarcacaoPrestador.getSelectedObject();
|
||||
prestador = PrestadoresData.prestadorNulo.equals( prestador ) ? null : prestador;
|
||||
marcacao.setToPrestador_id( prestador );
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SAVE_CONSULTA_MARCACAO_OBSERVACOES)
|
||||
public void updateToSaveConsultaMarcacaoObservacoes( TrabalhadoresConsultasDatasObservacoesData observacoes )
|
||||
{
|
||||
observacoes.setObservacao( inputConsultaMarcacaoObsMensagem.getObject() );
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SAVE_EXAME_MARCACAO)
|
||||
public void updateToSaveExameMarcacao( TrabalhadoresEcdsDatasData marcacao )
|
||||
{
|
||||
Date dataRecepcao = inputExameMarcacaoDataRecepcao.getObject();
|
||||
if( dataRecepcao == null || dataRecepcao.getTime() == 0l )
|
||||
{
|
||||
marcacao.setData_recepcao( null );
|
||||
}
|
||||
else
|
||||
{
|
||||
marcacao.setData_recepcao( dataRecepcao );
|
||||
}
|
||||
PrestadoresData prestador = (PrestadoresData) inputExameMarcacaoPrestador.getSelectedObject();
|
||||
prestador = PrestadoresData.prestadorNulo.equals( prestador ) ? null : prestador;
|
||||
marcacao.setToPrestador_id( prestador );
|
||||
|
||||
List<TrabalhadoresEcdData> allEcd = marcacao.fromTrabalhadoresEcd_trabalhadores_ecds_datas_id();
|
||||
if( allEcd != null )
|
||||
{
|
||||
OrderedMap<PrtGruposProtocoloData> map = inputExameMarcacaoAnalisador.getObject();
|
||||
for( TrabalhadoresEcdData ecd : allEcd )
|
||||
{
|
||||
PrtGruposProtocoloData grupo = ecd.toEcd_id().toGrupo_protocolo_id();
|
||||
Object value = map.getValue( grupo, 1 );
|
||||
if( value != null )
|
||||
{
|
||||
LeafInputField<OrderedMap<PrestadoresData>> leaf = (LeafInputField<OrderedMap<PrestadoresData>>) value;
|
||||
PrestadoresData ecdAnalisador = PrestadoresData.prestadorNulo.equals( (PrestadoresData) leaf.getSelectedObject() ) ? null : ((PrestadoresData) leaf.getSelectedObject());
|
||||
ecd.setToAnalisador_id( ecdAnalisador );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SAVE_EXAME_MARCACAO_OBSERVACOES)
|
||||
public void updateToSaveExameMarcacaoObservacoes( TrabalhadoresEcdsDatasObservacoesData observacoes )
|
||||
{
|
||||
observacoes.setObservacao( inputExameMarcacaoObsMensagem.getObject() );
|
||||
}
|
||||
|
||||
private void setupStartPanel()
|
||||
{
|
||||
}
|
||||
|
||||
private void setupSimpleDataPanel( JPanel panel, String name, JComponent... field )
|
||||
{
|
||||
double[] cols = new double[] {
|
||||
FILL
|
||||
};
|
||||
double[] rows = new double[field.length];
|
||||
for( int i = 0; i < field.length; rows[i++] = TableLayout.PREFERRED )
|
||||
;
|
||||
rows[rows.length - 1] = FILL;
|
||||
TableLayout layout = new TableLayout( cols, rows );
|
||||
layout.setHGap( 5 );
|
||||
layout.setVGap( 5 );
|
||||
panel.setLayout( layout );
|
||||
if( name != null )
|
||||
{
|
||||
panel.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), name ) );
|
||||
}
|
||||
|
||||
for( int i = 0; i < field.length; ++i )
|
||||
{
|
||||
panel.add( field[i], new TableLayoutConstraints( 0, i ) );
|
||||
}
|
||||
}
|
||||
|
||||
private void setupTrabalhadorPanel()
|
||||
{
|
||||
setupSimpleDataPanel( panelTrabalhador, "Trabalhador", labelTrabalhadorNome, inputTrabalhadorNome, labelTrabalhadorSexo, inputTrabalhadorSexo, labelTrabalhadorBI, inputTrabalhadorBI, labelTrabalhadorNacionalidade, inputTrabalhadorNacionalidade, labelTrabalhadoresDataNascimento, inputTrabalhadoresDataNascimento, labelTrabalhadoresDataAdmissao, inputTrabalhadoresDataAdmissao, labelTrabalhadorObservacoes, inputTrabalhadorObservacoes );
|
||||
}
|
||||
|
||||
private void setupProcessoPanel()
|
||||
{
|
||||
setupSimpleDataPanel( panelProcesso, "Processo", labelProcessoEstado, inputProcessoEstado, labelProcessoDataInicio, inputProcessoDataInicio, labelProcessoDataFim, inputProcessoDataFim, labelProcessoMotivo, inputProcessoMotivo, new JPanel() );
|
||||
}
|
||||
|
||||
private void setupConsultaPanel()
|
||||
{
|
||||
setupSimpleDataPanel( panelConsulta, "Consulta", labelConsultaEstado, inputConsultaEstado, labelConsultaData, inputConsultaData, labelConsultaPrestador, inputConsultaPrestador, new JPanel() );
|
||||
}
|
||||
|
||||
private void setupFichaPanel()
|
||||
{
|
||||
setupSimpleDataPanel( panelFicha, "Ficha de Aptid" + atilde + "o", new JPanel() );
|
||||
}
|
||||
|
||||
private void setupConsultaMarcacaoPanel()
|
||||
{
|
||||
setupSimpleDataPanel( panelConsultaMarcacao, "Marca" + ccedil + atilde + "o de Consulta", labelConsultaMarcacaoEstado, inputConsultaMarcacaoEstado, labelConsultaMarcacaoData, inputConsultaMarcacaoData, labelConsultaMarcacaoPrestador, inputConsultaMarcacaoPrestador, new JPanel() );
|
||||
}
|
||||
|
||||
private void setupConsultaMarcacaoEmailPanel()
|
||||
{
|
||||
setupSimpleDataPanel( panelConsultaMarcacaoEmail, "Email", labelConsultaMarcacaoEmailData, inputConsultaMarcacaoEmailData, labelConsultaMarcacaoEmailSubject, inputConsultaMarcacaoEmailSubject, labelConsultaMarcacaoEmailBody, inputConsultaMarcacaoEmailBody );
|
||||
}
|
||||
|
||||
private void setupConsultaMarcacaoObservacoesPanel()
|
||||
{
|
||||
setupSimpleDataPanel( panelConsultaMarcacaoObservacao, "Observa" + ccedil + otilde + "es", inputConsultaMarcacaoObsMensagem );
|
||||
}
|
||||
|
||||
private void setupExamePanel()
|
||||
{
|
||||
setupSimpleDataPanel( panelExame, "Exame", labelExameEstado, inputExameEstado, labelExameData, inputExameData, labelExameGruposEcds, inputExameGruposEcds, new JPanel() );
|
||||
}
|
||||
|
||||
private void setupExameMarcacaoPanel()
|
||||
{
|
||||
setupSimpleDataPanel( panelExameMarcacao, "Marca" + ccedil + atilde + "o de Exame", labelExameMarcacaoEstado, inputExameMarcacaoEstado, labelExameMarcacaoData, inputExameMarcacaoData, labelExameMarcacaoGruposEcds, inputExameMarcacaoGruposEcds, labelExameMarcacaoPrestador, inputExameMarcacaoPrestador, labelExameMarcacaoAnalisador, inputExameMarcacaoAnalisador, labelExameMarcacaoDataRecepcao, inputExameMarcacaoDataRecepcao, new JPanel() );
|
||||
}
|
||||
|
||||
private void setupExameMarcacaoEmailPanel()
|
||||
{
|
||||
setupSimpleDataPanel( panelExameMarcacaoEmail, "Email", labelExameMarcacaoEmailData, inputExameMarcacaoEmailData, labelExameMarcacaoEmailSubject, inputExameMarcacaoEmailSubject, labelExameMarcacaoEmailBody, inputExameMarcacaoEmailBody );
|
||||
}
|
||||
|
||||
private void setupExameMarcacaoObservacoesPanel()
|
||||
{
|
||||
setupSimpleDataPanel( panelExameMarcacaoObservacao, "Observa" + ccedil + otilde + "es", inputExameMarcacaoObsMensagem );
|
||||
}
|
||||
}
|
||||
@ -1,496 +0,0 @@
|
||||
package siprp.medicina.processo.ui;
|
||||
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.APAGAR_CONSULTA;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.APAGAR_CONSULTA_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.APAGAR_EXAME_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.APAGAR_PROCESSO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO_EMAIL;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO_OBSERVACOES;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME_MARCACAO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME_MARCACAO_EMAIL;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME_MARCACAO_OBSERVACOES;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_FICHA;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_PROCESSO;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.LOAD_TRABALHADOR;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.REFRESH;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_TREE_NODE;
|
||||
import info.clearthought.layout.TableLayout;
|
||||
import info.clearthought.layout.TableLayoutConstraints;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
import javax.swing.tree.TreePath;
|
||||
|
||||
import leaf.ui.LeafWindow;
|
||||
import leaf.ui.LeafLogic.LeafUIActionBinding;
|
||||
import leaf.ui.LeafWindow.ActionActivation;
|
||||
import siprp.data.outer.TrabalhadoresConsultasData;
|
||||
import siprp.data.outer.TrabalhadoresConsultasDatasData;
|
||||
import siprp.data.outer.TrabalhadoresConsultasDatasEmailsData;
|
||||
import siprp.data.outer.TrabalhadoresConsultasDatasObservacoesData;
|
||||
import siprp.data.outer.TrabalhadoresData;
|
||||
import siprp.data.outer.TrabalhadoresEcdsData;
|
||||
import siprp.data.outer.TrabalhadoresEcdsDatasData;
|
||||
import siprp.data.outer.TrabalhadoresEcdsDatasEmailsData;
|
||||
import siprp.data.outer.TrabalhadoresEcdsDatasObservacoesData;
|
||||
import siprp.data.outer.TrabalhadoresFichasAptidaoData;
|
||||
import siprp.data.outer.TrabalhadoresProcessoData;
|
||||
import siprp.medicina.processo.ProcessoDataProvider;
|
||||
import siprp.medicina.processo.estrutura.ConsultaMutableTreeNode;
|
||||
import siprp.medicina.processo.estrutura.DataMutableTreeNode;
|
||||
import siprp.medicina.processo.estrutura.ECDsMutableTreeNode;
|
||||
import siprp.medicina.processo.estrutura.EstruturaProcessoRenderer;
|
||||
import siprp.medicina.processo.estrutura.FichaAptidaoMutableTreeNode;
|
||||
import siprp.medicina.processo.estrutura.MailMutableTreeNode;
|
||||
import siprp.medicina.processo.estrutura.ObservacoesMutableTreeNode;
|
||||
import siprp.medicina.processo.estrutura.ProcessoMutableTreeNode;
|
||||
import siprp.medicina.processo.estrutura.TrabalhadorMutableTreeNode;
|
||||
|
||||
import com.evolute.entity.evo.EvoDataObject;
|
||||
|
||||
public class ProcessoTreePanel extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final LeafWindow parentWindow;
|
||||
|
||||
private final JScrollPane mainScroll = new JScrollPane();;
|
||||
|
||||
protected TrabalhadorMutableTreeNode rootNode;
|
||||
|
||||
private final Map<EvoDataObject, DefaultMutableTreeNode> nodeByObject = new HashMap<EvoDataObject, DefaultMutableTreeNode>();
|
||||
|
||||
@ActionActivation(onSelect = SELECT_TREE_NODE, onChange = "")
|
||||
public JTree mainTree;
|
||||
|
||||
protected ProcessoDataProvider provider;
|
||||
|
||||
public ProcessoTreePanel(LeafWindow parentWindow)
|
||||
{
|
||||
super();
|
||||
this.parentWindow = parentWindow;
|
||||
try
|
||||
{
|
||||
provider = ProcessoDataProvider.getProvider();
|
||||
|
||||
} catch( Exception e )
|
||||
{
|
||||
provider = null;
|
||||
e.printStackTrace();
|
||||
}
|
||||
setupLayout();
|
||||
setupComponents();
|
||||
placeComponents();
|
||||
}
|
||||
|
||||
private void setupLayout()
|
||||
{
|
||||
double[] cols = new double[] {
|
||||
TableLayout.FILL
|
||||
};
|
||||
double[] rows = new double[] {
|
||||
TableLayout.FILL
|
||||
};
|
||||
TableLayout layout = new TableLayout( cols, rows );
|
||||
this.setLayout( layout );
|
||||
}
|
||||
|
||||
private void setupComponents()
|
||||
{
|
||||
this.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Processos" ) );
|
||||
mainScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED );
|
||||
mainScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED );
|
||||
rootNode = new TrabalhadorMutableTreeNode( "" );
|
||||
mainTree = new JTree( rootNode );
|
||||
mainTree.setExpandsSelectedPaths( true );
|
||||
mainTree.setCellRenderer( new EstruturaProcessoRenderer() );
|
||||
mainScroll.setViewportView( mainTree );
|
||||
}
|
||||
|
||||
private void placeComponents()
|
||||
{
|
||||
this.add( mainScroll, new TableLayoutConstraints( 0, 0 ) );
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = LOAD_TRABALHADOR)
|
||||
public void setTrabalhador( TrabalhadoresData trabalhador )
|
||||
{
|
||||
clear();
|
||||
if( trabalhador == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
rootNode.setUserObject( trabalhador );
|
||||
List<DefaultMutableTreeNode> nodes = loadProcessos( trabalhador );
|
||||
for( DefaultMutableTreeNode node : nodes )
|
||||
{
|
||||
addNodeTo( node, rootNode );
|
||||
}
|
||||
((DefaultTreeModel) mainTree.getModel()).nodeStructureChanged( rootNode );
|
||||
int count = mainTree.getRowCount();
|
||||
for( int n = count - 1; n >= 0; n-- )
|
||||
{
|
||||
mainTree.expandRow( n );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_PROCESSO)
|
||||
public void createProcessoNode( TrabalhadoresProcessoData processo )
|
||||
{
|
||||
if( processo != null )
|
||||
{
|
||||
ProcessoMutableTreeNode node = new ProcessoMutableTreeNode( processo );
|
||||
addAndRefresh( node, rootNode );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_FICHA)
|
||||
public void createFichaNode()
|
||||
{
|
||||
// if( ficha != null )
|
||||
// {
|
||||
// FichaAptidaoMutableTreeNode node = new FichaAptidaoMutableTreeNode(
|
||||
// ficha );
|
||||
// DefaultMutableTreeNode parentNode = nodeByObject.get(
|
||||
// ficha.getToTrabalhadoresProcesso() );
|
||||
// addAndRefresh( node, parentNode );
|
||||
// }
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = APAGAR_PROCESSO)
|
||||
public void apagarProcessoNode( TrabalhadoresProcessoData processo )
|
||||
{
|
||||
if( processo != null )
|
||||
{
|
||||
for( int i = 0; i < rootNode.getChildCount(); ++i )
|
||||
{
|
||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode) rootNode.getChildAt( i );
|
||||
|
||||
if( processo.equals( node.getUserObject() ) )
|
||||
{
|
||||
removeNode( node );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = APAGAR_CONSULTA)
|
||||
public void apagarConsultaNode( TrabalhadoresConsultasData consulta )
|
||||
{
|
||||
if( consulta != null )
|
||||
{
|
||||
DefaultMutableTreeNode node = nodeByObject.get( consulta );
|
||||
if( node != null )
|
||||
{
|
||||
removeNode( node );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = APAGAR_CONSULTA_MARCACAO)
|
||||
public void apagarConsultaMarcacaoNode( TrabalhadoresConsultasDatasData consulta )
|
||||
{
|
||||
if( consulta != null )
|
||||
{
|
||||
DefaultMutableTreeNode node = nodeByObject.get( consulta );
|
||||
if( node != null )
|
||||
{
|
||||
removeNode( node );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = APAGAR_EXAME_MARCACAO)
|
||||
public void apagarExameMarcacaoNode( TrabalhadoresEcdsDatasData exame )
|
||||
{
|
||||
if( exame != null )
|
||||
{
|
||||
DefaultMutableTreeNode node = nodeByObject.get( exame );
|
||||
if( node != null )
|
||||
{
|
||||
removeNode( node );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_CONSULTA)
|
||||
public void createConsultaNode( TrabalhadoresConsultasData consulta )
|
||||
{
|
||||
if( consulta != null )
|
||||
{
|
||||
DefaultMutableTreeNode parentNode = nodeByObject.get( consulta.toProcesso_id() );
|
||||
ConsultaMutableTreeNode node = new ConsultaMutableTreeNode( consulta );
|
||||
node.setData( consulta.getData() );
|
||||
addAndRefresh( node, parentNode );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO)
|
||||
public void createConsultaMarcacaoNode( TrabalhadoresConsultasDatasData marcacao )
|
||||
{
|
||||
if( marcacao != null )
|
||||
{
|
||||
DefaultMutableTreeNode parentNode = nodeByObject.get( marcacao.toTrabalhadores_consultas_id() );
|
||||
DataMutableTreeNode node = new DataMutableTreeNode( marcacao );
|
||||
addAndRefresh( node, parentNode );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO_EMAIL)
|
||||
public void createConsultaMarcacaoEmailNode( TrabalhadoresConsultasDatasEmailsData email )
|
||||
{
|
||||
if( email != null )
|
||||
{
|
||||
DefaultMutableTreeNode parentNode = nodeByObject.get( email.toTrabalhadores_consultas_datas_id() );
|
||||
MailMutableTreeNode node = new MailMutableTreeNode( email );
|
||||
addAndRefresh( node, parentNode );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO_OBSERVACOES)
|
||||
public void createConsultaMarcacaoObservacoesNode( TrabalhadoresConsultasDatasObservacoesData observacoes )
|
||||
{
|
||||
if( observacoes != null )
|
||||
{
|
||||
DefaultMutableTreeNode parentNode = nodeByObject.get( observacoes.toTrabalhadores_consultas_datas_id() );
|
||||
ObservacoesMutableTreeNode node = new ObservacoesMutableTreeNode( observacoes );
|
||||
addNodeTo( node, parentNode );
|
||||
((DefaultTreeModel) mainTree.getModel()).nodeStructureChanged( parentNode );
|
||||
mainTree.setSelectionPath( new TreePath( node.getPath() ) );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_EXAME)
|
||||
public void createExameNode( TrabalhadoresEcdsData exame )
|
||||
{
|
||||
if( exame != null )
|
||||
{
|
||||
DefaultMutableTreeNode parentNode = nodeByObject.get( exame.toProcesso_id() );
|
||||
ECDsMutableTreeNode node = new ECDsMutableTreeNode( exame );
|
||||
node.setData( exame.getData() );
|
||||
addAndRefresh( node, parentNode );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_EXAME_MARCACAO)
|
||||
public void createExameMarcacaoNode( TrabalhadoresEcdsDatasData marcacao )
|
||||
{
|
||||
if( marcacao != null )
|
||||
{
|
||||
DefaultMutableTreeNode parentNode = nodeByObject.get( marcacao.toTrabalhadores_ecds_id() );
|
||||
DataMutableTreeNode node = new DataMutableTreeNode( marcacao );
|
||||
addAndRefresh( node, parentNode );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_EXAME_MARCACAO_EMAIL)
|
||||
public void createExameMarcacaoEmailNode( TrabalhadoresEcdsDatasEmailsData email )
|
||||
{
|
||||
if( email != null )
|
||||
{
|
||||
DefaultMutableTreeNode parentNode = nodeByObject.get( email.toTrabalhadores_ecds_datas_id() );
|
||||
MailMutableTreeNode node = new MailMutableTreeNode( email );
|
||||
addAndRefresh( node, parentNode );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = CREATE_EXAME_MARCACAO_OBSERVACOES)
|
||||
public void createConsultaMarcacaoObservacoesNode( TrabalhadoresEcdsDatasObservacoesData observacoes )
|
||||
{
|
||||
if( observacoes != null )
|
||||
{
|
||||
DefaultMutableTreeNode parentNode = nodeByObject.get( observacoes.toTrabalhadores_ecds_datas_id() );
|
||||
ObservacoesMutableTreeNode node = new ObservacoesMutableTreeNode( observacoes );
|
||||
addNodeTo( node, parentNode );
|
||||
((DefaultTreeModel) mainTree.getModel()).nodeStructureChanged( parentNode );
|
||||
mainTree.setSelectionPath( new TreePath( node.getPath() ) );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = REFRESH)
|
||||
public void refresh()
|
||||
{
|
||||
DefaultMutableTreeNode selected = getSelectedNode();
|
||||
if( selected != null )
|
||||
{
|
||||
// ((DefaultTreeModel) mainTree.getModel()).nodeStructureChanged(
|
||||
// rootNode );
|
||||
mainTree.setSelectionPath( new TreePath( rootNode.getPath() ) );
|
||||
mainTree.setSelectionPath( new TreePath( selected.getPath() ) );
|
||||
}
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
|
||||
protected List<DefaultMutableTreeNode> loadProcessos( TrabalhadoresData trabalhador )
|
||||
{
|
||||
List<DefaultMutableTreeNode> result = new ArrayList<DefaultMutableTreeNode>();
|
||||
List<TrabalhadoresProcessoData> processos = trabalhador.fromTrabalhadoresProcesso_trabalhador_id();
|
||||
for( TrabalhadoresProcessoData trabalhadoresProcesso : processos )
|
||||
{
|
||||
result.add( loadProcesso( trabalhadoresProcesso ) );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private ProcessoMutableTreeNode loadProcesso( TrabalhadoresProcessoData processo )
|
||||
{
|
||||
ProcessoMutableTreeNode node = new ProcessoMutableTreeNode( processo );
|
||||
node.removeAllChildren();
|
||||
for( TrabalhadoresConsultasData current : processo.fromTrabalhadoresConsultas_processo_id() )
|
||||
{
|
||||
addNodeTo( loadConsulta( current ), node );
|
||||
}
|
||||
for( TrabalhadoresEcdsData current : processo.fromTrabalhadoresEcds_processo_id() )
|
||||
{
|
||||
addNodeTo( loadExame( current ), node );
|
||||
}
|
||||
|
||||
List<TrabalhadoresFichasAptidaoData> fichas = processo.fromTrabalhadoresFichasAptidao_processo_id();
|
||||
if( fichas != null )
|
||||
{
|
||||
TrabalhadoresFichasAptidaoData ficha = null;
|
||||
for( TrabalhadoresFichasAptidaoData currentFicha : fichas )
|
||||
{
|
||||
if( ficha == null || ficha.getId() < currentFicha.getId() )
|
||||
{
|
||||
ficha = currentFicha;
|
||||
}
|
||||
}
|
||||
if( ficha != null )
|
||||
{
|
||||
addNodeTo( loadFicha( ficha ), node );
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
private FichaAptidaoMutableTreeNode loadFicha( TrabalhadoresFichasAptidaoData ficha )
|
||||
{
|
||||
FichaAptidaoMutableTreeNode result = new FichaAptidaoMutableTreeNode( ficha );
|
||||
return result;
|
||||
}
|
||||
|
||||
private ECDsMutableTreeNode loadExame( TrabalhadoresEcdsData exame )
|
||||
{
|
||||
ECDsMutableTreeNode node = new ECDsMutableTreeNode( exame );
|
||||
node.setData( exame.getData() );
|
||||
node.removeAllChildren();
|
||||
List<TrabalhadoresEcdsDatasData> marcacoes = exame.fromTrabalhadoresEcdsDatas_trabalhadores_ecds_id();
|
||||
for( TrabalhadoresEcdsDatasData marcacao : marcacoes )
|
||||
{
|
||||
addNodeTo( loadExameMarcacao( marcacao ), node );
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
private DataMutableTreeNode loadExameMarcacao( TrabalhadoresEcdsDatasData marcacao )
|
||||
{
|
||||
DataMutableTreeNode node = new DataMutableTreeNode( marcacao );
|
||||
for( TrabalhadoresEcdsDatasEmailsData email : marcacao.fromTrabalhadoresEcdsDatasEmails_trabalhadores_ecds_datas_id() )
|
||||
{
|
||||
addNodeTo( new MailMutableTreeNode( email ), node );
|
||||
}
|
||||
for( TrabalhadoresEcdsDatasObservacoesData observacoes : marcacao.fromTrabalhadoresEcdsDatasObservacoes_trabalhadores_ecds_datas_id() )
|
||||
{
|
||||
addNodeTo( new ObservacoesMutableTreeNode( observacoes ), node );
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
private ConsultaMutableTreeNode loadConsulta( TrabalhadoresConsultasData consulta )
|
||||
{
|
||||
ConsultaMutableTreeNode node = new ConsultaMutableTreeNode( consulta );
|
||||
node.setData( consulta.getData() );
|
||||
node.removeAllChildren();
|
||||
List<TrabalhadoresConsultasDatasData> marcacoes = consulta.fromTrabalhadoresConsultasDatas_trabalhadores_consultas_id();
|
||||
for( TrabalhadoresConsultasDatasData marcacao : marcacoes )
|
||||
{
|
||||
addNodeTo( loadMarcacao( marcacao ), node );
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
private DataMutableTreeNode loadMarcacao( TrabalhadoresConsultasDatasData marcacao )
|
||||
{
|
||||
DataMutableTreeNode node = new DataMutableTreeNode( marcacao );
|
||||
for( TrabalhadoresConsultasDatasEmailsData email : marcacao.fromTrabalhadoresConsultasDatasEmails_trabalhadores_consultas_datas_id() )
|
||||
{
|
||||
addNodeTo( new MailMutableTreeNode( email ), node );
|
||||
}
|
||||
for( TrabalhadoresConsultasDatasObservacoesData observacoes : marcacao.fromTrabalhadoresConsultasDatasObservacoes_trabalhadores_consultas_datas_id() )
|
||||
{
|
||||
addNodeTo( new ObservacoesMutableTreeNode( observacoes ), node );
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
private void addNodeTo( DefaultMutableTreeNode node, DefaultMutableTreeNode to )
|
||||
{
|
||||
if( node.getUserObject() != null && node.getUserObject() instanceof EvoDataObject )
|
||||
{
|
||||
nodeByObject.put( (EvoDataObject) node.getUserObject(), node );
|
||||
}
|
||||
to.add( node );
|
||||
}
|
||||
|
||||
private void addAndRefresh( DefaultMutableTreeNode node, DefaultMutableTreeNode parentNode )
|
||||
{
|
||||
addNodeTo( node, parentNode );
|
||||
refresh( node, parentNode );
|
||||
}
|
||||
|
||||
private void removeNode( DefaultMutableTreeNode node )
|
||||
{
|
||||
if( node != null )
|
||||
{
|
||||
DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent();
|
||||
if( parent == null )
|
||||
{
|
||||
parent = rootNode;
|
||||
}
|
||||
node.removeFromParent();
|
||||
nodeByObject.remove( node.getUserObject() );
|
||||
refresh( parent, rootNode );
|
||||
}
|
||||
}
|
||||
|
||||
private void refresh( DefaultMutableTreeNode newSelection, DefaultMutableTreeNode parentNode )
|
||||
{
|
||||
((DefaultTreeModel) mainTree.getModel()).nodeStructureChanged( parentNode );
|
||||
mainTree.setSelectionPath( new TreePath( newSelection.getPath() ) );
|
||||
}
|
||||
|
||||
private DefaultMutableTreeNode getSelectedNode()
|
||||
{
|
||||
DefaultMutableTreeNode result = null;
|
||||
Object[] nodes = mainTree.getSelectionPath() == null ? null : mainTree.getSelectionPath().getPath();
|
||||
if( nodes != null && nodes.length > 0 && nodes[nodes.length - 1] instanceof DefaultMutableTreeNode )
|
||||
{
|
||||
result = (DefaultMutableTreeNode) nodes[nodes.length - 1];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
rootNode.setUserObject( "" );
|
||||
mainTree.clearSelection();
|
||||
mainTree.setRootVisible( true );
|
||||
rootNode.removeAllChildren();
|
||||
((DefaultTreeModel) mainTree.getModel()).nodeStructureChanged( rootNode );
|
||||
}
|
||||
}
|
||||
@ -1,133 +0,0 @@
|
||||
package siprp.medicina.processo.ui;
|
||||
|
||||
import static leaf.ui.LeafLogic.ACTION_STARTUP;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.LOAD_TRABALHADOR;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EMPRESA;
|
||||
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_ESTABELECIMENTO;
|
||||
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.ListSelectionModel;
|
||||
|
||||
import leaf.ui.LeafTableModel;
|
||||
import leaf.ui.LeafWindow;
|
||||
import leaf.ui.LeafLogic.LeafUIActionBinding;
|
||||
import leaf.ui.LeafWindow.ActionActivation;
|
||||
import siprp.data.outer.EmpresasData;
|
||||
import siprp.data.outer.EstabelecimentosData;
|
||||
|
||||
import com.evolute.utils.tables.BaseTable;
|
||||
|
||||
public class TrabalhadoresChooserPanel extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final LeafWindow parentWindow;
|
||||
|
||||
@ActionActivation(onSelect = SELECT_EMPRESA, onChange = "")
|
||||
public BaseTable empresasTable;
|
||||
public LeafTableModel empresasModel;
|
||||
|
||||
@ActionActivation(onSelect = SELECT_ESTABELECIMENTO, onChange = "")
|
||||
public BaseTable estabelecimentosTable;
|
||||
public LeafTableModel estabelecimentosModel;
|
||||
|
||||
@ActionActivation(onSelect = LOAD_TRABALHADOR, onChange = "")
|
||||
public BaseTable trabalhadoresTable;
|
||||
public LeafTableModel trabalhadoresModel;
|
||||
|
||||
public TrabalhadoresChooserPanel(LeafWindow parentWindow)
|
||||
{
|
||||
super();
|
||||
this.parentWindow = parentWindow;
|
||||
|
||||
setupComponents();
|
||||
}
|
||||
|
||||
private void setupComponents()
|
||||
{
|
||||
empresasModel = new LeafTableModel( new String[] {
|
||||
"Empresas"
|
||||
} );
|
||||
empresasTable = new BaseTable( empresasModel );
|
||||
empresasTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
|
||||
empresasTable.setNonResizableNorReordable();
|
||||
JScrollPane empresasScroll = new JScrollPane( empresasTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
|
||||
estabelecimentosModel = new LeafTableModel( new String[] {
|
||||
"Estabelecimentos"
|
||||
} );
|
||||
estabelecimentosTable = new BaseTable( estabelecimentosModel );
|
||||
estabelecimentosTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
|
||||
estabelecimentosTable.setNonResizableNorReordable();
|
||||
JScrollPane estabelecimentosScroll = new JScrollPane( estabelecimentosTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
|
||||
trabalhadoresModel = new LeafTableModel( new String[] {
|
||||
"Trabalhadores"
|
||||
} );
|
||||
trabalhadoresTable = new BaseTable( trabalhadoresModel );
|
||||
trabalhadoresTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
|
||||
trabalhadoresTable.setNonResizableNorReordable();
|
||||
JScrollPane trabalhadoresScroll = new JScrollPane( trabalhadoresTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
|
||||
|
||||
GridBagLayout gridbag = new GridBagLayout();
|
||||
setLayout( gridbag );
|
||||
GridBagConstraints constraints = new GridBagConstraints();
|
||||
constraints.insets = new Insets( 1, 1, 1, 1 );
|
||||
constraints.fill = GridBagConstraints.BOTH;
|
||||
constraints.gridwidth = 1;
|
||||
constraints.gridheight = 1;
|
||||
constraints.weightx = 0.3;
|
||||
constraints.weighty = 1;
|
||||
|
||||
gridbag.setConstraints( empresasScroll, constraints );
|
||||
|
||||
gridbag.setConstraints( estabelecimentosScroll, constraints );
|
||||
|
||||
constraints.weightx = 0.4;
|
||||
constraints.gridheight = GridBagConstraints.REMAINDER;
|
||||
gridbag.setConstraints( trabalhadoresScroll, constraints );
|
||||
|
||||
add( empresasScroll );
|
||||
add( estabelecimentosScroll );
|
||||
add( trabalhadoresScroll );
|
||||
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action= ACTION_STARTUP)
|
||||
public void fillEmpresas( Collection<EmpresasData> allEmpresas )
|
||||
{
|
||||
empresasTable.clearSelection();
|
||||
empresasModel.clearAll();
|
||||
if( allEmpresas != null )
|
||||
{
|
||||
empresasModel.setValues( allEmpresas );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_EMPRESA)
|
||||
public void fillEstablecimentos( EmpresasData empresa )
|
||||
{
|
||||
estabelecimentosTable.clearSelection();
|
||||
estabelecimentosModel.clearAll();
|
||||
if( empresa != null )
|
||||
{
|
||||
estabelecimentosModel.setValues( empresa.fromEstabelecimentos_empresa_id() );
|
||||
}
|
||||
}
|
||||
|
||||
@LeafUIActionBinding(action = SELECT_ESTABELECIMENTO)
|
||||
public void fillTrabalhadores(EstabelecimentosData estabelecimento)
|
||||
{
|
||||
trabalhadoresTable.clearSelection();
|
||||
trabalhadoresModel.clearAll();
|
||||
if( estabelecimento != null )
|
||||
{
|
||||
trabalhadoresModel.setValues( estabelecimento.fromTrabalhadores_estabelecimento_id() );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue