git-svn-id: https://svn.coded.pt/svn/SIPRP@725 bb69d46d-e84e-40c8-a05a-06db0d633741

lxbfYeaa
Tiago Simão 18 years ago
parent ea470a36bf
commit d8f56fbb77

@ -3,7 +3,6 @@ package leaf;
import static info.clearthought.layout.TableLayoutConstants.FILL; import static info.clearthought.layout.TableLayoutConstants.FILL;
import static leaf.LeafLogic.ACTION_CANCEL; import static leaf.LeafLogic.ACTION_CANCEL;
import static leaf.LeafLogic.ACTION_STARTUP; import static leaf.LeafLogic.ACTION_STARTUP;
import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints; import info.clearthought.layout.TableLayoutConstraints;
@ -146,7 +145,7 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
/** /**
* Run later actions * Run later actions
*/ */
private Queue<String> listRunLater = new LinkedList<String>(); private Queue<Pair<String, Object>> listRunLater = new LinkedList<Pair<String, Object>>();
/** /**
* Creates a new LeafWindow binded with given 'logicController' * Creates a new LeafWindow binded with given 'logicController'
@ -262,10 +261,15 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
} }
public void runActionLater( String action ) public void runActionLater( String action )
{
runActionLater( action, null );
}
public void runActionLater( String action, Object argument )
{ {
if( action != null && mapActionByName.containsKey( action ) ) if( action != null && mapActionByName.containsKey( action ) )
{ {
listRunLater.add( action ); listRunLater.add( new Pair<String, Object>( action, argument ) );
} }
} }
@ -546,11 +550,12 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection
return result; return result;
} }
private void runPendingActions() public void runPendingActions()
{ {
while( listRunLater.size() > 0 ) while( listRunLater.size() > 0 )
{ {
runAction( listRunLater.poll() ); Pair<String, Object > p = listRunLater.poll();
runAction( p.getCar(), p.getCdr() );
} }
} }

@ -53,6 +53,7 @@ public class SIPRPTracker extends WindowTracker
private final AvisosPanel avisos; private final AvisosPanel avisos;
private ClientesWindow clientesWindow; private ClientesWindow clientesWindow;
private MedicinaWindow medicinaWindow; private MedicinaWindow medicinaWindow;
private MedicinaProcessoWindow medicinaProcessoWindow;
private MarcacoesHigieneWindow higieneWindow; private MarcacoesHigieneWindow higieneWindow;
/** Creates a new instance of SIPRPTracker */ /** Creates a new instance of SIPRPTracker */
@ -152,7 +153,11 @@ public class SIPRPTracker extends WindowTracker
public TrackableWindow create() public TrackableWindow create()
throws Exception throws Exception
{ {
return new MedicinaProcessoWindow(); if( medicinaProcessoWindow == null )
{
medicinaProcessoWindow = new MedicinaProcessoWindow();
}
return medicinaProcessoWindow;
} }
} ); } );
@ -282,6 +287,21 @@ public class SIPRPTracker extends WindowTracker
return medicinaWindow; return medicinaWindow;
} }
public MedicinaProcessoWindow getMedicinaProcessoWindow()
{
if( medicinaProcessoWindow == null )
{
try
{
medicinaProcessoWindow = new MedicinaProcessoWindow();
} catch( Exception e )
{
e.printStackTrace();
}
}
return medicinaProcessoWindow;
}
public MarcacoesHigieneWindow getHigieneWindow() public MarcacoesHigieneWindow getHigieneWindow()
{ {
return higieneWindow; return higieneWindow;

@ -104,6 +104,14 @@ public class SIPRPDataLoader implements CompanyDataLoader
// Singleton.setInstance( SingletonConstants.LOCAL_URL, "10.158.2.3:5432" ); // Singleton.setInstance( SingletonConstants.LOCAL_URL, "10.158.2.3:5432" );
// Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, "siprp_local" ); // Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, "siprp_local" );
// Singleton.setInstance( SingletonConstants.LOCAL_DRIVER_NAME, "org.postgresql.Driver" ); // Singleton.setInstance( SingletonConstants.LOCAL_DRIVER_NAME, "org.postgresql.Driver" );
Singleton.setInstance( SingletonConstants.LOCAL_USER, "postgres" );
Singleton.setInstance( SingletonConstants.LOCAL_PASSWORD, "Typein" );
Singleton.setInstance( SingletonConstants.LOCAL_URL_PREFIX, "jdbc:postgresql://" );
Singleton.setInstance( SingletonConstants.LOCAL_URL, "dbserver:5432" );
Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, "siprp_local" );
Singleton.setInstance( SingletonConstants.LOCAL_DRIVER_NAME, "org.postgresql.Driver" );
// //
// Singleton.setInstance( SingletonConstants.LOCAL_USER, "postgres" ); // Singleton.setInstance( SingletonConstants.LOCAL_USER, "postgres" );
// Singleton.setInstance( SingletonConstants.LOCAL_PASSWORD, "Typein" ); // Singleton.setInstance( SingletonConstants.LOCAL_PASSWORD, "Typein" );
@ -112,12 +120,12 @@ public class SIPRPDataLoader implements CompanyDataLoader
// Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, "siprp_local" ); // Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, "siprp_local" );
// Singleton.setInstance( SingletonConstants.LOCAL_DRIVER_NAME, "org.postgresql.Driver" ); // Singleton.setInstance( SingletonConstants.LOCAL_DRIVER_NAME, "org.postgresql.Driver" );
Singleton.setInstance( SingletonConstants.LOCAL_USER, "postgres" ); // Singleton.setInstance( SingletonConstants.LOCAL_USER, "postgres" );
Singleton.setInstance( SingletonConstants.LOCAL_PASSWORD, "Typein" ); // Singleton.setInstance( SingletonConstants.LOCAL_PASSWORD, "Typein" );
Singleton.setInstance( SingletonConstants.LOCAL_URL_PREFIX, "jdbc:postgresql://" ); // Singleton.setInstance( SingletonConstants.LOCAL_URL_PREFIX, "jdbc:postgresql://" );
Singleton.setInstance( SingletonConstants.LOCAL_URL, "192.168.1.1:5432" ); // Singleton.setInstance( SingletonConstants.LOCAL_URL, "192.168.1.1:5432" );
Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, "siprp_local" ); // Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, "siprp_local" );
Singleton.setInstance( SingletonConstants.LOCAL_DRIVER_NAME, "org.postgresql.Driver" ); // Singleton.setInstance( SingletonConstants.LOCAL_DRIVER_NAME, "org.postgresql.Driver" );
} }
} }

@ -15,6 +15,7 @@ import siprp.database.cayenne.objects.Empresas;
import siprp.database.cayenne.objects.Prestadores; import siprp.database.cayenne.objects.Prestadores;
import siprp.database.cayenne.objects.PrtGruposProtocolo; import siprp.database.cayenne.objects.PrtGruposProtocolo;
import siprp.database.cayenne.objects.Trabalhadores; import siprp.database.cayenne.objects.Trabalhadores;
import siprp.database.cayenne.objects.TrabalhadoresConsultasDatas;
import siprp.database.cayenne.objects.TrabalhadoresEcd; import siprp.database.cayenne.objects.TrabalhadoresEcd;
import siprp.database.cayenne.objects.TrabalhadoresEcdsDatas; import siprp.database.cayenne.objects.TrabalhadoresEcdsDatas;
import siprp.database.cayenne.objects.TrabalhadoresProcesso; import siprp.database.cayenne.objects.TrabalhadoresProcesso;
@ -31,6 +32,17 @@ public class MedicinaDAO extends MainDAO implements MedicinaConstants
return (Trabalhadores) DataObjectUtils.objectForPK( context, Trabalhadores.class, id ); return (Trabalhadores) DataObjectUtils.objectForPK( context, Trabalhadores.class, id );
} }
public TrabalhadoresConsultasDatas getConsultaMarcacaoByID( Integer id )
{
return (TrabalhadoresConsultasDatas) DataObjectUtils.objectForPK( context, TrabalhadoresConsultasDatas.class, id );
}
public TrabalhadoresEcdsDatas getExameMarcacaoByID( Integer id )
{
return (TrabalhadoresEcdsDatas) DataObjectUtils.objectForPK( context, TrabalhadoresEcdsDatas.class, id );
}
public List<Empresas> getAllEmpresas() public List<Empresas> getAllEmpresas()
{ {
SelectQuery query = new SelectQuery( Empresas.class ); SelectQuery query = new SelectQuery( Empresas.class );

@ -30,6 +30,8 @@ public class Lembrete
protected boolean enviarEmail; protected boolean enviarEmail;
protected Integer periodicidadeDias; protected Integer periodicidadeDias;
protected Integer periodicidadeMeses; protected Integer periodicidadeMeses;
protected Integer consultaDataID;
protected Integer exameDataID;
/** Creates a new instance of Lembrete */ /** Creates a new instance of Lembrete */
public Lembrete( Integer id, public Lembrete( Integer id,
@ -44,7 +46,9 @@ public class Lembrete
Integer marcacaoTrabalhadorID, Integer marcacaoTrabalhadorID,
boolean enviarEmail, boolean enviarEmail,
Integer periodicidadeDias, Integer periodicidadeDias,
Integer periodicidadeMeses ) Integer periodicidadeMeses,
Integer consultaDataID,
Integer exameDataID )
{ {
setId( id ); setId( id );
setTipoID( tipoID ); setTipoID( tipoID );
@ -59,6 +63,8 @@ public class Lembrete
setEnviarEmail( enviarEmail ); setEnviarEmail( enviarEmail );
setPeriodicidadeDias( periodicidadeDias ); setPeriodicidadeDias( periodicidadeDias );
setPeriodicidadeMeses( periodicidadeMeses ); setPeriodicidadeMeses( periodicidadeMeses );
setConsultaDataID( consultaDataID );
setExameDataID( exameDataID );
} }
public Integer getTipoID() public Integer getTipoID()
@ -191,4 +197,23 @@ public class Lembrete
this.id = id; this.id = id;
} }
public void setConsultaDataID( Integer consultaDataID )
{
this.consultaDataID = consultaDataID;
}
public void setExameDataID( Integer exameDataID )
{
this.exameDataID = exameDataID;
}
public Integer getConsultaDataID()
{
return consultaDataID;
}
public Integer getExameDataID()
{
return exameDataID;
}
} }

@ -86,6 +86,24 @@ public class LembretesDataProvider
return tiposLembrete; return tiposLembrete;
} }
public Integer getTipoLembreteIDByCodigo( String codigo )
{
Integer result = null;
TipoLembrete tipo;
try
{
tipo = getTipoLembreteByCodigo( codigo );
if( tipo != null )
{
result = tipo.getID();
}
} catch( Exception e )
{
e.printStackTrace();
}
return result;
}
public TipoLembrete getTipoLembreteByCodigo( String codigo ) public TipoLembrete getTipoLembreteByCodigo( String codigo )
throws Exception throws Exception
{ {
@ -132,6 +150,39 @@ public class LembretesDataProvider
EXECUTER.executeQuery( insert ); EXECUTER.executeQuery( insert );
} }
public void criarLembreteConsulta( Integer tipoID, Date date, String descricao, String texto, Integer empresaID, Integer estabelecimentoID, Integer trabalhadorID, Integer consultaMarcacaoID )
{
criarLembreteNew( tipoID, date, descricao, texto, empresaID, estabelecimentoID, trabalhadorID, consultaMarcacaoID, true);
}
public void criarLembreteExame( Integer tipoID, Date date, String descricao, String texto, Integer empresaID, Integer estabelecimentoID, Integer trabalhadorID, Integer consultaExameID )
{
criarLembreteNew( tipoID, date, descricao, texto, empresaID, estabelecimentoID, trabalhadorID, consultaExameID, false );
}
private void criarLembreteNew( Integer tipoID, Date date, String descricao, String texto, Integer empresaID, Integer estabelecimentoID, Integer trabalhadorID, Integer marcacaoID, boolean isConsulta )
{
try
{
Insert insert =
new Insert( "lembretes",
new Assignment[]{
new Assignment( new Field( "tipo_id" ), tipoID ),
new Assignment( new Field( "data" ), date ),
new Assignment( new Field( "descricao" ), descricao ),
new Assignment( new Field( "texto" ), texto ),
new Assignment( new Field( "empresa_id" ), empresaID ),
new Assignment( new Field( "estabelecimento_id" ), estabelecimentoID ),
new Assignment( new Field( "trabalhador_id" ), trabalhadorID ),
new Assignment( new Field( isConsulta ? "trabalhadores_consultas_datas_id" : "trabalhadores_ecds_datas_id" ), marcacaoID ) } );
EXECUTER.executeQuery( insert );
}
catch( Exception e )
{
e.printStackTrace();
}
}
public void apagarLembreteByID( Integer id ) public void apagarLembreteByID( Integer id )
throws Exception throws Exception
{ {
@ -179,7 +230,7 @@ public class LembretesDataProvider
"texto", "empresa_id", "estabelecimento_id", "texto", "empresa_id", "estabelecimento_id",
"trabalhador_id", "marcacao_estabelecimento_id", "trabalhador_id", "marcacao_estabelecimento_id",
"marcacao_trabalhador_id", "enviar_email", "marcacao_trabalhador_id", "enviar_email",
"periodicidade_dias", "periodicidade_meses" }, "periodicidade_dias", "periodicidade_meses" , "trabalhadores_consultas_datas_id", "trabalhadores_ecds_datas_id" },
new Field( "tipo_id" ).isEqual( tipoID ).and( new Field( "tipo_id" ).isEqual( tipoID ).and(
new Field( "data" ).isLessOrEqual( new Date() ) ) ); new Field( "data" ).isLessOrEqual( new Date() ) ) );
Virtual2DArray array = EXECUTER.executeQuery( select ); Virtual2DArray array = EXECUTER.executeQuery( select );
@ -198,10 +249,12 @@ public class LembretesDataProvider
boolean enviarEmail = "y".equals( array.get( n, 10 ) ); boolean enviarEmail = "y".equals( array.get( n, 10 ) );
Integer periodicidadeDias = ( Integer ) array.get( n, 11 ); Integer periodicidadeDias = ( Integer ) array.get( n, 11 );
Integer periodicidadeMeses = ( Integer ) array.get( n, 12 ); Integer periodicidadeMeses = ( Integer ) array.get( n, 12 );
Integer consultaDataID = ( Integer ) array.get( 0, 13 );
Integer exameDataID = ( Integer ) array.get( 0, 14 );
lembretes[ n ] = new Lembrete( id, tipoID, data, descricao, texto, lembretes[ n ] = new Lembrete( id, tipoID, data, descricao, texto,
empresaID, estabelecimentoID, trabalhadorID, empresaID, estabelecimentoID, trabalhadorID,
marcacaoEstabelecimentoID, marcacaoTrabalhadorID, marcacaoEstabelecimentoID, marcacaoTrabalhadorID,
enviarEmail, periodicidadeDias, periodicidadeMeses ); enviarEmail, periodicidadeDias, periodicidadeMeses, consultaDataID, exameDataID );
} }
return lembretes; return lembretes;
} }
@ -215,7 +268,7 @@ public class LembretesDataProvider
"texto", "empresa_id", "estabelecimento_id", "texto", "empresa_id", "estabelecimento_id",
"trabalhador_id", "marcacao_estabelecimento_id", "trabalhador_id", "marcacao_estabelecimento_id",
"marcacao_trabalhador_id", "enviar_email", "marcacao_trabalhador_id", "enviar_email",
"periodicidade_dias", "periodicidade_meses" }, "periodicidade_dias", "periodicidade_meses", "trabalhadores_consultas_datas_id", "trabalhadores_ecds_datas_id" },
new Field( "id" ).isEqual( id ) ); new Field( "id" ).isEqual( id ) );
Virtual2DArray array = EXECUTER.executeQuery( select ); Virtual2DArray array = EXECUTER.executeQuery( select );
if( array.columnLength() == 0 ) if( array.columnLength() == 0 )
@ -236,10 +289,13 @@ public class LembretesDataProvider
boolean enviarEmail = "y".equals( array.get( 0, 10 ) ); boolean enviarEmail = "y".equals( array.get( 0, 10 ) );
Integer periodicidadeDias = ( Integer ) array.get( 0, 11 ); Integer periodicidadeDias = ( Integer ) array.get( 0, 11 );
Integer periodicidadeMeses = ( Integer ) array.get( 0, 12 ); Integer periodicidadeMeses = ( Integer ) array.get( 0, 12 );
Integer consultaDataID = ( Integer ) array.get( 0, 13 );
Integer exameDataID = ( Integer ) array.get( 0, 14 );
return new Lembrete( id, tipoID, data, descricao, texto, return new Lembrete( id, tipoID, data, descricao, texto,
empresaID, estabelecimentoID, trabalhadorID, empresaID, estabelecimentoID, trabalhadorID,
marcacaoEstabelecimentoID, marcacaoTrabalhadorID, marcacaoEstabelecimentoID, marcacaoTrabalhadorID,
enviarEmail, periodicidadeDias, periodicidadeMeses ); enviarEmail, periodicidadeDias, periodicidadeMeses, consultaDataID, exameDataID );
} }
} }
} }

@ -9,19 +9,33 @@
package siprp.lembretes; package siprp.lembretes;
import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import javax.swing.*; import javax.swing.*;
import com.evolute.utils.tables.*; import com.evolute.utils.tables.*;
import com.evolute.utils.tables.special.ComboBoxData;
import com.evolute.utils.tracker.TrackableWindow; import com.evolute.utils.tracker.TrackableWindow;
import com.evolute.utils.ui.DialogException; import com.evolute.utils.ui.DialogException;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.util.List;
import java.util.Vector; import java.util.Vector;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionListener;
import siprp.database.cayenne.objects.Empresas;
import siprp.database.cayenne.objects.Estabelecimentos;
import siprp.database.cayenne.providers.MedicinaDAO;
import siprp.lembretes.remarcacoes.LembretesRemarcacaoPanel; import siprp.lembretes.remarcacoes.LembretesRemarcacaoPanel;
/** /**
@ -34,11 +48,21 @@ public class LembretesWindow extends JFrame
{ {
public static final String TITLE = "Lembretes"; public static final String TITLE = "Lembretes";
private static final int LEFT_COLUMN_WIDTH = 302;
protected VectorTableModel tiposModel; protected VectorTableModel tiposModel;
protected BaseTable tiposTable; protected BaseTable tiposTable;
protected JPanel lembretesPanel; protected JPanel lembretesPanel;
protected JButton recarregarButton; protected JButton recarregarButton;
private final JPanel leftPanel = new JPanel();
private final JCheckBox checkEmpresas = new JCheckBox();
private final JComboBox comboEmpresas = new JComboBox( );
private final JCheckBox checkEstabelecimentos = new JCheckBox();
private final JComboBox comboEstabelecimentos = new JComboBox( );
private final MedicinaDAO medicinaDao = new MedicinaDAO();
protected LembretesDataProvider provider; protected LembretesDataProvider provider;
/** Creates a new instance of LembretesWindow */ /** Creates a new instance of LembretesWindow */
@ -61,16 +85,54 @@ public class LembretesWindow extends JFrame
JScrollPane scp = JScrollPane scp =
new JScrollPane( tiposTable, JScrollPane.VERTICAL_SCROLLBAR_NEVER, new JScrollPane( tiposTable, JScrollPane.VERTICAL_SCROLLBAR_NEVER,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
scp.setPreferredSize( new Dimension( 300, 20 ) ); scp.setPreferredSize( new Dimension( LEFT_COLUMN_WIDTH, 100 ) );
lembretesPanel = new JPanel(); lembretesPanel = new JPanel();
lembretesPanel.setLayout( new GridLayout( 1, 1 ) ); lembretesPanel.setLayout( new GridLayout( 1, 1 ) );
recarregarButton = new JButton( "Recarregar" ); recarregarButton = new JButton( "Recarregar" );
recarregarButton.addActionListener( this ); recarregarButton.addActionListener( this );
getContentPane().setLayout( new BorderLayout() ); loadEmpresas();
getContentPane().add( scp, BorderLayout.WEST ); loadEstabelecimentos();
getContentPane().add( lembretesPanel, BorderLayout.CENTER );
getContentPane().add( recarregarButton, BorderLayout.SOUTH ); double[] cols = new double[]{ TableLayout.MINIMUM, TableLayout.FILL };
double[] rows = new double[]{ TableLayout.PREFERRED, TableLayout.PREFERRED,
TableLayout.MINIMUM, TableLayout.MINIMUM,
TableLayout.MINIMUM, TableLayout.MINIMUM,
TableLayout.MINIMUM
};
TableLayout tableLayout = new TableLayout( cols, rows );
tableLayout.setHGap( 5 );
tableLayout.setVGap( 5 );
leftPanel.setPreferredSize( new Dimension( LEFT_COLUMN_WIDTH, 0 ) );
leftPanel.setLayout( tableLayout );
comboEmpresas.setPreferredSize( new Dimension( LEFT_COLUMN_WIDTH - 50, 0 ) );
comboEstabelecimentos.setPreferredSize( new Dimension( LEFT_COLUMN_WIDTH - 50, 0 ) );
checkEstabelecimentos.setEnabled( false );
comboEstabelecimentos.setEnabled( false );
leftPanel.add( scp, new TableLayoutConstraints(0,0,1,0) );
leftPanel.add( new JSeparator(), new TableLayoutConstraints(0,1,1,1) );
leftPanel.add( new JLabel( "Filtrar por:"), new TableLayoutConstraints(0,2,1,2) );
leftPanel.add( checkEmpresas, new TableLayoutConstraints(0,3) );
leftPanel.add( new JLabel( "Empresa"), new TableLayoutConstraints(1,3) );
leftPanel.add( comboEmpresas, new TableLayoutConstraints(1,4) );
leftPanel.add( checkEstabelecimentos, new TableLayoutConstraints(0,5) );
leftPanel.add( new JLabel( "Estabelecimento"), new TableLayoutConstraints(1,5) );
leftPanel.add( comboEstabelecimentos, new TableLayoutConstraints(1,6) );
cols = new double[]{ TableLayout.PREFERRED, TableLayout.FILL };
rows = new double[]{ TableLayout.FILL, TableLayout.MINIMUM };
tableLayout = new TableLayout( cols, rows );
tableLayout.setHGap( 5 );
tableLayout.setVGap( 5 );
// getContentPane().setPreferredSize( new Dimension( 300, 20 ) );
getContentPane().setLayout( tableLayout );
getContentPane().setLayout( tableLayout );
getContentPane().add( leftPanel, new TableLayoutConstraints( 0, 0 ) );
getContentPane().add( lembretesPanel, new TableLayoutConstraints( 1, 0 ) );
getContentPane().add( recarregarButton, new TableLayoutConstraints( 0, 1, 1, 1 ) );
addWindowListener( new WindowAdapter(){ addWindowListener( new WindowAdapter(){
public void windowClosing( WindowEvent e ) public void windowClosing( WindowEvent e )
@ -85,6 +147,74 @@ public class LembretesWindow extends JFrame
reloadTotais(); reloadTotais();
} }
} ); } );
setupComboListeners();
setupCheckBoxListeners();
}
private void setupComboListeners()
{
comboEmpresas.addItemListener( new ItemListener()
{
@Override
public void itemStateChanged( ItemEvent e )
{
if( e.getStateChange() == ItemEvent.SELECTED )
{
loadEstabelecimentos();
if( checkEmpresas.isEnabled() && checkEmpresas.isEnabled() )
{
reloadLembretes();
}
}
}
} );
comboEstabelecimentos.addItemListener( new ItemListener()
{
@Override
public void itemStateChanged( ItemEvent e )
{
if( e.getStateChange() == ItemEvent.SELECTED && checkEstabelecimentos.isEnabled() )
{
reloadLembretes();
}
}
} );
}
private void setupCheckBoxListeners()
{
checkEmpresas.addChangeListener( new ChangeListener()
{
@Override
public void stateChanged( ChangeEvent e )
{
empresasChecked();
reloadLembretes();
}
});
checkEstabelecimentos.addChangeListener( new ChangeListener()
{
@Override
public void stateChanged( ChangeEvent e )
{
reloadLembretes();
}
});
}
private void empresasChecked()
{
boolean filtrarEmpresas = checkEmpresas.isSelected();
checkEstabelecimentos.setEnabled( filtrarEmpresas );
comboEstabelecimentos.setEnabled( filtrarEmpresas );
if( !filtrarEmpresas )
{
checkEstabelecimentos.setSelected( false );
}
} }
public void refresh() public void refresh()
@ -137,6 +267,10 @@ public class LembretesWindow extends JFrame
{ {
ColumnizedObjectArray line = ( ColumnizedObjectArray ) tiposModel.getRowAt( selected ); ColumnizedObjectArray line = ( ColumnizedObjectArray ) tiposModel.getRowAt( selected );
Integer tipoID = line.getID(); Integer tipoID = line.getID();
Empresas empresa = (Empresas) comboEmpresas.getSelectedItem();
Estabelecimentos estabelecimento = (Estabelecimentos) comboEstabelecimentos.getSelectedItem();
Integer empresaID = ( empresa != null && checkEmpresas.isSelected() ) ? empresa.getId() : null;
Integer estabelecimentoID = ( estabelecimento != null && checkEstabelecimentos.isSelected() ) ? estabelecimento.getId() : null;
try try
{ {
TipoLembrete tipo = provider.getTipoLembreteByID( tipoID ); TipoLembrete tipo = provider.getTipoLembreteByID( tipoID );
@ -146,7 +280,7 @@ public class LembretesWindow extends JFrame
} }
if( CODE_REMARCACOES.equals( tipo.getCodigo() ) ) if( CODE_REMARCACOES.equals( tipo.getCodigo() ) )
{ {
lembretesPanel.add( new LembretesRemarcacaoPanel() ); lembretesPanel.add( new LembretesRemarcacaoPanel( empresaID, estabelecimentoID ) );
} }
if( CODE_MARCACOES.equals( tipo.getCodigo() ) ) if( CODE_MARCACOES.equals( tipo.getCodigo() ) )
{ {
@ -165,6 +299,34 @@ public class LembretesWindow extends JFrame
repaint(); repaint();
} }
private void loadEmpresas()
{
comboEmpresas.removeAllItems();
List<Empresas> allEmpresas = medicinaDao.getAllEmpresas();
for( Empresas empresa : allEmpresas )
{
comboEmpresas.addItem( empresa );
}
}
private void loadEstabelecimentos()
{
comboEstabelecimentos.removeAllItems();
Object selectedEmpresa = comboEmpresas.getSelectedItem();
if( selectedEmpresa != null )
{
if( selectedEmpresa instanceof Empresas )
{
List<Estabelecimentos> allEstabelecimentos = ((Empresas) selectedEmpresa).getEstabelecimentosArray();
for( Estabelecimentos estabelecimento : allEstabelecimentos )
{
comboEstabelecimentos.addItem( estabelecimento );
}
}
}
}
public boolean closeIfPossible() public boolean closeIfPossible()
{ {
close(); close();
@ -177,6 +339,8 @@ public class LembretesWindow extends JFrame
if( source.equals( recarregarButton ) ) if( source.equals( recarregarButton ) )
{ {
reloadTotais(); reloadTotais();
loadEmpresas();
loadEstabelecimentos();
} }
} }

@ -36,12 +36,17 @@ public class LembretesRemarcacaoPanel extends JPanel
protected RemarcacoesDataProvider provider; protected RemarcacoesDataProvider provider;
private final Integer empresaID;
private final Integer estabelecimentoID;
private JDOProvider JDO; private JDOProvider JDO;
/** Creates a new instance of LembretesRemarcacaoPanel */ /** Creates a new instance of LembretesRemarcacaoPanel */
public LembretesRemarcacaoPanel() public LembretesRemarcacaoPanel( Integer empresaID, Integer estabelecimentoID )
throws Exception throws Exception
{ {
this.empresaID = empresaID;
this.estabelecimentoID = estabelecimentoID;
provider = RemarcacoesDataProvider.getProvider(); provider = RemarcacoesDataProvider.getProvider();
setupComponents(); setupComponents();
} }
@ -77,7 +82,7 @@ public class LembretesRemarcacaoPanel extends JPanel
estabelecimentosPanel.add( new JLabel( "Higiene e Seguran\u00e7a", JLabel.CENTER ), BorderLayout.NORTH ); estabelecimentosPanel.add( new JLabel( "Higiene e Seguran\u00e7a", JLabel.CENTER ), BorderLayout.NORTH );
estabelecimentosPanel.add( listEstabelecimentosScroll, BorderLayout.CENTER ); estabelecimentosPanel.add( listEstabelecimentosScroll, BorderLayout.CENTER );
listTrabalhadoresPanel.showList( provider.getLembretesRemarcacaoTrabalhador() ); listTrabalhadoresPanel.showList( provider.getLembretesRemarcacaoTrabalhador( empresaID, estabelecimentoID ) );
// listEstabelecimentosPanel.showList( estabelecimentos.toArray( new IDObject[ estabelecimentos.size() ] ) ); // listEstabelecimentosPanel.showList( estabelecimentos.toArray( new IDObject[ estabelecimentos.size() ] ) );
} }

@ -23,8 +23,10 @@ import java.text.DateFormat;
import java.util.Date; import java.util.Date;
import java.util.Locale; import java.util.Locale;
import siprp.data.Marcacao; import siprp.data.Marcacao;
import siprp.database.cayenne.providers.MedicinaDAO;
import siprp.lembretes.LembretesConstants; import siprp.lembretes.LembretesConstants;
import siprp.lembretes.LembretesDataProvider; import siprp.lembretes.LembretesDataProvider;
import siprp.medicina.processo.database.MedicinaProcessoDAO;
/** /**
* *
@ -62,30 +64,56 @@ public class RemarcacoesDataProvider
return instance; return instance;
} }
public IDObject[] getLembretesRemarcacaoTrabalhador() private Expression whereExpressionLembretesRemarcacao( Integer empresaID, Integer estabelecimentoID ) throws Exception
{
Expression result = new Field( "lembretes.tipo_id" ).isEqual(
lembretesProvider.getTipoLembreteByCodigo( LembretesConstants.CODE_REMARCACOES ).getID() ).and(
new Field( "lembretes.data" ).isLessOrEqual( new Field( "current_date" ) ) );
if( empresaID != null )
{
result = result.and( new Field("empresas.id").isEqual( empresaID ) );
if( estabelecimentoID != null )
{
result = result.and( new Field("estabelecimentos.id").isEqual( estabelecimentoID ) );
}
}
return result;
}
public IDObject[] getLembretesRemarcacaoTrabalhador( Integer empresaID, Integer estabelecimentoID )
throws Exception throws Exception
{ {
Select select = Select select =
new Select2( new String[]{ "lembretes", "marcacoes_trabalhador", "trabalhadores", new Select2( new String[]{ "lembretes", "marcacoes_trabalhador", "trabalhadores",
"estabelecimentos", "empresas" }, "estabelecimentos", "empresas", "trabalhadores_consultas_datas", "trabalhadores_ecds_datas"},
new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER }, new Integer [] {
Select2.JOIN_LEFT_OUTER, Select2.JOIN_LEFT_OUTER,
Select2.JOIN_LEFT_OUTER, Select2.JOIN_LEFT_OUTER,
Select2.JOIN_LEFT_OUTER, Select2.JOIN_LEFT_OUTER
},
new Expression[]{ new Expression[]{
new Field( "lembretes.marcacao_trabalhador_id" ).isEqual( new Field( "marcacoes_trabalhador.id" ) ), new Field( "lembretes.marcacao_trabalhador_id" ).isEqual( new Field( "marcacoes_trabalhador.id" ) ),/*.or(
new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ), new Field( "lembretes.trabalhadores_consultas_datas_id" ).isEqual( new Field( "trabalhadores_consultas_datas.id" ) )
).or(
new Field( "lembretes.trabalhadores_ecds_datas_id" ).isEqual( new Field( "trabalhadores_ecds_datas.id" ) )
),
*/
new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).or( new Field( "lembretes.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) ),
new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ), new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ),
new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ), new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ),
new Field( "lembretes.trabalhadores_consultas_datas_id" ).isEqual( new Field( "trabalhadores_consultas_datas.id" ) ),
new Field( "lembretes.trabalhadores_ecds_datas_id" ).isEqual( new Field( "trabalhadores_ecds_datas.id" ) )
}, },
new String[]{ "lembretes.id", "lembretes.descricao", new String[]{ "lembretes.id", "lembretes.descricao",
"marcacoes_trabalhador.tipo", "marcacoes_trabalhador.data", "marcacoes_trabalhador.tipo", "marcacoes_trabalhador.data",
"trabalhadores.nome", "estabelecimentos.nome", "empresas.designacao_social", "trabalhadores.nome", "estabelecimentos.nome", "empresas.designacao_social",
"trabalhadores.nome_plain" }, "trabalhadores.nome_plain", "trabalhadores_consultas_datas.data", "trabalhadores_ecds_datas.data" },
new Field( "lembretes.tipo_id" ).isEqual( whereExpressionLembretesRemarcacao( empresaID, estabelecimentoID ),
lembretesProvider.getTipoLembreteByCodigo( LembretesConstants.CODE_REMARCACOES ).getID() ).and(
new Field( "lembretes.data" ).isLessOrEqual( new Field( "current_date" ) ) ),
new String[]{ "trabalhadores.nome_plain" }, new String[]{ "trabalhadores.nome_plain" },
null, null,
null, null,
null ); null
);
Virtual2DArray array = EXECUTER.executeQuery( select ); Virtual2DArray array = EXECUTER.executeQuery( select );
IDObject lembretes[] = new IDObject[ array.columnLength() ]; IDObject lembretes[] = new IDObject[ array.columnLength() ];
for( int n = 0; n < lembretes.length; n++ ) for( int n = 0; n < lembretes.length; n++ )
@ -93,6 +121,22 @@ public class RemarcacoesDataProvider
Integer id = ( Integer ) array.get( n, 0 ); Integer id = ( Integer ) array.get( n, 0 );
String descricao = ( String ) array.get( n, 1 ); String descricao = ( String ) array.get( n, 1 );
Integer tipoMarcacao = ( Integer ) array.get( n, 2 ); Integer tipoMarcacao = ( Integer ) array.get( n, 2 );
Date trabalhadorConsultaDataData = ( Date ) array.get( n, 8 );
Date trabalhadorExameDataData = ( Date ) array.get( n, 9 );
Date data = ( Date ) array.get( n, 3 );
if( tipoMarcacao == null )
{
if( trabalhadorConsultaDataData != null )
{
tipoMarcacao = Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA;
data = trabalhadorConsultaDataData;
}
else if( trabalhadorExameDataData != null )
{
tipoMarcacao = Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES;
data = trabalhadorExameDataData;
}
}
String tipoMarcacaoStr = ""; String tipoMarcacaoStr = "";
switch( tipoMarcacao.intValue() ) switch( tipoMarcacao.intValue() )
{ {
@ -104,7 +148,6 @@ public class RemarcacoesDataProvider
tipoMarcacaoStr = "Consulta"; tipoMarcacaoStr = "Consulta";
break; break;
} }
Date data = ( Date ) array.get( n, 3 );
String trabalhador = ( String ) array.get( n, 4 ); String trabalhador = ( String ) array.get( n, 4 );
String split[] = trabalhador.split( " " ); String split[] = trabalhador.split( " " );
trabalhador = split[ 0 ] + " " + ( split.length > 2 ? split[ 1 ].charAt( 0 ) + ". " : " " ) + trabalhador = split[ 0 ] + " " + ( split.length > 2 ? split[ 1 ].charAt( 0 ) + ". " : " " ) +

@ -22,8 +22,20 @@ import siprp.data.EmpresaData;
import siprp.data.EstabelecimentoData; import siprp.data.EstabelecimentoData;
import siprp.data.MarcacaoTrabalhadorData; import siprp.data.MarcacaoTrabalhadorData;
import siprp.data.TrabalhadorData; import siprp.data.TrabalhadorData;
import siprp.database.cayenne.objects.Empresas;
import siprp.database.cayenne.objects.Estabelecimentos;
import siprp.database.cayenne.objects.Trabalhadores;
import siprp.database.cayenne.objects.TrabalhadoresConsultas;
import siprp.database.cayenne.objects.TrabalhadoresConsultasDatas;
import siprp.database.cayenne.objects.TrabalhadoresEcds;
import siprp.database.cayenne.objects.TrabalhadoresEcdsDatas;
import siprp.database.cayenne.objects.TrabalhadoresProcesso;
import siprp.database.cayenne.providers.MedicinaDAO;
import siprp.lembretes.Lembrete; import siprp.lembretes.Lembrete;
import siprp.lembretes.LembretesDataProvider; import siprp.lembretes.LembretesDataProvider;
import siprp.medicina.processo.data.TrabalhadoresConsultasData;
import siprp.medicina.processo.logic.MedicinaProcessoLogic;
import siprp.medicina.processo.ui.MedicinaProcessoWindow;
/** /**
* *
@ -37,6 +49,8 @@ public class TratarMarcacaoTrabalhadorAction extends AbstractAction
private Integer lembreteID; private Integer lembreteID;
private MedicinaDAO medicinaDAO = new MedicinaDAO();
/** /**
* Creates a new instance of TratarMarcacaoTrabalhadorAction * Creates a new instance of TratarMarcacaoTrabalhadorAction
*/ */
@ -67,6 +81,9 @@ public class TratarMarcacaoTrabalhadorAction extends AbstractAction
JOptionPane.WARNING_MESSAGE ); JOptionPane.WARNING_MESSAGE );
return; return;
} }
if( lembrete.getMarcacaoTrabalhadorID() != null )
{
// old model
MarcacaoTrabalhadorData marcacao = ( MarcacaoTrabalhadorData ) JDO.load( MarcacaoTrabalhadorData.class, lembrete.getMarcacaoTrabalhadorID() ); MarcacaoTrabalhadorData marcacao = ( MarcacaoTrabalhadorData ) JDO.load( MarcacaoTrabalhadorData.class, lembrete.getMarcacaoTrabalhadorID() );
TrabalhadorData trabalhador = ( TrabalhadorData ) marcacao.get( MarcacaoTrabalhadorData.TRABALHADOR ); TrabalhadorData trabalhador = ( TrabalhadorData ) marcacao.get( MarcacaoTrabalhadorData.TRABALHADOR );
EstabelecimentoData estabelecimento = ( EstabelecimentoData ) trabalhador.get( TrabalhadorData.ESTABELECIMENTO ); EstabelecimentoData estabelecimento = ( EstabelecimentoData ) trabalhador.get( TrabalhadorData.ESTABELECIMENTO );
@ -79,6 +96,48 @@ public class TratarMarcacaoTrabalhadorAction extends AbstractAction
( Integer ) estabelecimento.get( EstabelecimentoData.ID ), ( Integer ) estabelecimento.get( EstabelecimentoData.ID ),
( Integer ) trabalhador.get( TrabalhadorData.ID ) ); ( Integer ) trabalhador.get( TrabalhadorData.ID ) );
} }
else
{
// new model
Integer consultaID = lembrete.getConsultaDataID();
Integer exameID = lembrete.getExameDataID();
TrabalhadoresConsultasDatas consultaMarcacao = null;
TrabalhadoresConsultas consulta = null;
TrabalhadoresEcdsDatas exameMarcacao = null;
TrabalhadoresEcds exame = null;
TrabalhadoresProcesso processo = null;
Trabalhadores trabalhador = null;
Estabelecimentos estabelecimento = null;
Empresas empresa = null;
if( consultaID != null )
{
consultaMarcacao = medicinaDAO.getConsultaMarcacaoByID( consultaID );
consulta = consultaMarcacao.getToTrabalhadoresConsultas();
processo = consulta.getToTrabalhadoresProcesso();
}
else if( exameID != null )
{
exameMarcacao = medicinaDAO.getExameMarcacaoByID( exameID );
exame = exameMarcacao.getToTrabalhadoresEcds();
processo = exame.getToTrabalhadoresProcesso();
}
trabalhador = processo.getToTrabalhadores();
estabelecimento = trabalhador.getToEstabelecimentos();
empresa = estabelecimento.getToEmpresas();
MedicinaProcessoWindow window = tracker.getMedicinaProcessoWindow();
window.runActionLater( MedicinaProcessoLogic.SELECT_EMPRESA, empresa );
window.runActionLater( MedicinaProcessoLogic.SELECT_ESTABELECIMENTO, estabelecimento );
window.runActionLater( MedicinaProcessoLogic.LOAD_TRABALHADOR, trabalhador );
window.runActionLater( MedicinaProcessoLogic.SELECT_TRABALHADOR, trabalhador );
window.runActionLater( MedicinaProcessoLogic.SELECT_PROCESSO, processo );
window.runActionLater( consulta == null ? MedicinaProcessoLogic.SELECT_EXAME : MedicinaProcessoLogic.SELECT_CONSULTA, consulta == null ? exame : consulta );
window.runActionLater( consulta == null ? MedicinaProcessoLogic.CREATE_EXAME_MARCACAO : MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO, null );
window.runPendingActions();
window.setVisible( true );
lembretesProvider.apagarLembreteByID( lembreteID );
}
}
catch( Exception ex ) catch( Exception ex )
{ {
DialogException.showExceptionMessage( ex, "Erro a tratar", true ); DialogException.showExceptionMessage( ex, "Erro a tratar", true );

@ -74,4 +74,8 @@ public interface MedicinaConstants
public static final String ESTADOS_STR[][] = public static final String ESTADOS_STR[][] =
new String[][]{ ESTADOS_EXAME_STR, ESTADOS_CONSULTA_STR }; new String[][]{ ESTADOS_EXAME_STR, ESTADOS_CONSULTA_STR };
public static final String LEMBRETE_DESMARCOU_SIPRP_STRING = "SIPRP Desmarcou";
public static final String LEMBRETE_DESMARCOU_TRABALHADOR_STRING = "Trabalhador Desmarcou";
public static final String LEMBRETE_FALTOU_TRABALHADOR_STRING = "Trabalhador Faltou";
} }

@ -1,6 +1,5 @@
package siprp.medicina.processo.logic; package siprp.medicina.processo.logic;
import java.awt.Dialog.ModalExclusionType;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -24,8 +23,9 @@ import siprp.database.cayenne.objects.TrabalhadoresEcdsDatasObservacoes;
import siprp.database.cayenne.objects.TrabalhadoresFichasAptidao; import siprp.database.cayenne.objects.TrabalhadoresFichasAptidao;
import siprp.database.cayenne.objects.TrabalhadoresProcesso; import siprp.database.cayenne.objects.TrabalhadoresProcesso;
import siprp.database.cayenne.providers.MedicinaDAO; import siprp.database.cayenne.providers.MedicinaDAO;
import siprp.ficha.FichaAptidaoCreator;
import siprp.ficha.FichaWindow; import siprp.ficha.FichaWindow;
import siprp.lembretes.LembretesConstants;
import siprp.lembretes.LembretesDataProvider;
import siprp.medicina.MedicinaConstants; import siprp.medicina.MedicinaConstants;
import siprp.medicina.processo.ProcessoConstants; import siprp.medicina.processo.ProcessoConstants;
import siprp.medicina.processo.estrutura.FichaAptidaoMutableTreeNode; import siprp.medicina.processo.estrutura.FichaAptidaoMutableTreeNode;
@ -179,6 +179,8 @@ public class MedicinaProcessoLogic extends LeafLogic
@Action(isSave = true) @Action(isSave = true)
public static final String ANULAR_EXAME_MARCACAO = "ANULAR_EXAME_MARCACAO"; public static final String ANULAR_EXAME_MARCACAO = "ANULAR_EXAME_MARCACAO";
private LembretesDataProvider lembretesDataProvider = null;
private MedicinaDAO provider = null; private MedicinaDAO provider = null;
public Empresas currentEmpresa = null; public Empresas currentEmpresa = null;
@ -227,6 +229,7 @@ public class MedicinaProcessoLogic extends LeafLogic
try try
{ {
provider = new MedicinaDAO(); provider = new MedicinaDAO();
lembretesDataProvider = new LembretesDataProvider();
} catch( Exception e ) } catch( Exception e )
{ {
e.printStackTrace( System.out ); e.printStackTrace( System.out );
@ -294,12 +297,32 @@ public class MedicinaProcessoLogic extends LeafLogic
} }
} }
private void novoLembreteRemarcacao( String mensagem, boolean isConsulta)
{
Integer tipoID = lembretesDataProvider.getTipoLembreteIDByCodigo( LembretesConstants.CODE_REMARCACOES );
try
{
if( isConsulta )
{
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) @LeafLogicActionBinding(actions = DESMARCAR_SIPRP_CONSULTA_MARCACAO)
public void desmarcarConsultaSiprp() public void desmarcarConsultaSiprp()
{ {
if( currentConsultaMarcacao != null ) if( currentConsultaMarcacao != null )
{ {
currentConsultaMarcacao.setEstado( MedicinaConstants.ESTADO_DESMARCADO_EMPRESA ); currentConsultaMarcacao.setEstado( MedicinaConstants.ESTADO_DESMARCADO_EMPRESA );
novoLembreteRemarcacao( MedicinaConstants.LEMBRETE_DESMARCOU_SIPRP_STRING, true );
runActionLater( SAVE_CONSULTA_MARCACAO ); runActionLater( SAVE_CONSULTA_MARCACAO );
} }
} }
@ -310,6 +333,7 @@ public class MedicinaProcessoLogic extends LeafLogic
if( currentConsultaMarcacao != null ) if( currentConsultaMarcacao != null )
{ {
currentConsultaMarcacao.setEstado( MedicinaConstants.ESTADO_DESMARCADO_TRABALHADOR ); currentConsultaMarcacao.setEstado( MedicinaConstants.ESTADO_DESMARCADO_TRABALHADOR );
novoLembreteRemarcacao( MedicinaConstants.LEMBRETE_DESMARCOU_TRABALHADOR_STRING, true );
runActionLater( SAVE_CONSULTA_MARCACAO ); runActionLater( SAVE_CONSULTA_MARCACAO );
} }
} }
@ -320,6 +344,7 @@ public class MedicinaProcessoLogic extends LeafLogic
if( currentConsultaMarcacao != null ) if( currentConsultaMarcacao != null )
{ {
currentConsultaMarcacao.setEstado( MedicinaConstants.ESTADO_FALTOU ); currentConsultaMarcacao.setEstado( MedicinaConstants.ESTADO_FALTOU );
novoLembreteRemarcacao( MedicinaConstants.LEMBRETE_FALTOU_TRABALHADOR_STRING, true );
runActionLater( SAVE_CONSULTA_MARCACAO ); runActionLater( SAVE_CONSULTA_MARCACAO );
} }
} }
@ -340,6 +365,7 @@ public class MedicinaProcessoLogic extends LeafLogic
if( currentExameMarcacao != null ) if( currentExameMarcacao != null )
{ {
currentExameMarcacao.desmarcarSIPRP(); currentExameMarcacao.desmarcarSIPRP();
novoLembreteRemarcacao( MedicinaConstants.LEMBRETE_DESMARCOU_SIPRP_STRING, false );
runActionLater( SAVE_EXAME_MARCACAO ); runActionLater( SAVE_EXAME_MARCACAO );
} }
} }
@ -350,6 +376,7 @@ public class MedicinaProcessoLogic extends LeafLogic
if( currentExameMarcacao != null ) if( currentExameMarcacao != null )
{ {
currentExameMarcacao.desmarcarTrabalhador(); currentExameMarcacao.desmarcarTrabalhador();
novoLembreteRemarcacao( MedicinaConstants.LEMBRETE_DESMARCOU_TRABALHADOR_STRING, false );
runActionLater( SAVE_EXAME_MARCACAO ); runActionLater( SAVE_EXAME_MARCACAO );
} }
} }
@ -360,6 +387,7 @@ public class MedicinaProcessoLogic extends LeafLogic
if( currentExameMarcacao != null ) if( currentExameMarcacao != null )
{ {
currentExameMarcacao.faltou(); currentExameMarcacao.faltou();
novoLembreteRemarcacao( MedicinaConstants.LEMBRETE_FALTOU_TRABALHADOR_STRING, false );
runActionLater( SAVE_EXAME_MARCACAO ); runActionLater( SAVE_EXAME_MARCACAO );
} }
} }
@ -393,6 +421,83 @@ public class MedicinaProcessoLogic extends LeafLogic
} }
} }
@LeafLogicActionBinding(actions=SELECT_TRABALHADOR)
public Trabalhadores selectTrabalhador( Trabalhadores trabalhador )
{
this.currentTrabalhador = trabalhador;
return this.currentTrabalhador;
}
@LeafLogicActionBinding(actions=SELECT_PROCESSO)
public TrabalhadoresProcesso selectProcesso( TrabalhadoresProcesso processo )
{
this.currentProcesso = processo;
return this.currentProcesso;
}
@LeafLogicActionBinding(actions=SELECT_CONSULTA)
public TrabalhadoresConsultas selectConsulta( TrabalhadoresConsultas consulta )
{
this.currentConsulta = consulta;
return this.currentConsulta;
}
@LeafLogicActionBinding(actions=SELECT_CONSULTA_MARCACAO)
public TrabalhadoresConsultasDatas selectConsultaMarcacao( TrabalhadoresConsultasDatas consultaMarcacao )
{
this.currentConsultaMarcacao = consultaMarcacao;
return this.currentConsultaMarcacao;
}
@LeafLogicActionBinding(actions=SELECT_CONSULTA_MARCACAO_EMAIL)
public TrabalhadoresConsultasDatasEmails selectConsultaMarcacaoEmail( TrabalhadoresConsultasDatasEmails consultaMarcacaoEmail )
{
this.currentConsultaMarcacaoEmail = consultaMarcacaoEmail;
return this.currentConsultaMarcacaoEmail;
}
@LeafLogicActionBinding(actions=SELECT_CONSULTA_MARCACAO_OBSERVACAO)
public TrabalhadoresConsultasDatasObservacoes selectConsultaMarcacaoObservacoes( TrabalhadoresConsultasDatasObservacoes consultaMarcacaoObservacoes )
{
this.currentConsultaMarcacaoObservacao = consultaMarcacaoObservacoes;
return this.currentConsultaMarcacaoObservacao;
}
@LeafLogicActionBinding(actions=SELECT_EXAME)
public TrabalhadoresEcds selectExame( TrabalhadoresEcds exame )
{
this.currentExame = exame;
return this.currentExame;
}
@LeafLogicActionBinding(actions=SELECT_EXAME_MARCACAO)
public TrabalhadoresEcdsDatas selectExameMarcacao( TrabalhadoresEcdsDatas exameMarcacao )
{
this.currentExameMarcacao = exameMarcacao;
return this.currentExameMarcacao;
}
@LeafLogicActionBinding(actions=SELECT_EXAME_MARCACAO_EMAIL)
public TrabalhadoresEcdsDatasEmails selectExameMarcacaoEmail( TrabalhadoresEcdsDatasEmails exameMarcacaoEmail )
{
this.currentExameMarcacaoEmail = exameMarcacaoEmail;
return this.currentExameMarcacaoEmail;
}
@LeafLogicActionBinding(actions=SELECT_EXAME_MARCACAO_OBSERVACAO)
public TrabalhadoresEcdsDatasObservacoes selectExameMarcacaoObservacoes( TrabalhadoresEcdsDatasObservacoes exameMarcacaoObservacoes )
{
this.currentExameMarcacaoObservacao = exameMarcacaoObservacoes;
return this.currentExameMarcacaoObservacao;
}
@LeafLogicActionBinding(actions=SELECT_FICHA)
public TrabalhadoresFichasAptidao selectFichaAptidao( TrabalhadoresFichasAptidao ficha )
{
this.currentFicha= ficha;
return this.currentFicha;
}
@LeafLogicActionBinding(actions = { @LeafLogicActionBinding(actions = {
SELECT_TREE_NODE SELECT_TREE_NODE
}) })
@ -405,57 +510,46 @@ public class MedicinaProcessoLogic extends LeafLogic
else if( node.getUserObject() instanceof Trabalhadores ) else if( node.getUserObject() instanceof Trabalhadores )
{ {
action = SELECT_TRABALHADOR; action = SELECT_TRABALHADOR;
currentTrabalhador = (Trabalhadores) node.getUserObject();
} }
else if( node.getUserObject() instanceof TrabalhadoresProcesso ) else if( node.getUserObject() instanceof TrabalhadoresProcesso )
{ {
action = SELECT_PROCESSO; action = SELECT_PROCESSO;
currentProcesso = (TrabalhadoresProcesso) node.getUserObject();
} }
else if( node.getUserObject() instanceof TrabalhadoresConsultas ) else if( node.getUserObject() instanceof TrabalhadoresConsultas )
{ {
action = SELECT_CONSULTA; action = SELECT_CONSULTA;
currentConsulta = (TrabalhadoresConsultas) node.getUserObject();
} }
else if( node.getUserObject() instanceof TrabalhadoresConsultasDatas ) else if( node.getUserObject() instanceof TrabalhadoresConsultasDatas )
{ {
action = SELECT_CONSULTA_MARCACAO; action = SELECT_CONSULTA_MARCACAO;
currentConsultaMarcacao = (TrabalhadoresConsultasDatas) node.getUserObject();
} }
else if( node.getUserObject() instanceof TrabalhadoresConsultasDatasObservacoes ) else if( node.getUserObject() instanceof TrabalhadoresConsultasDatasObservacoes )
{ {
action = SELECT_CONSULTA_MARCACAO_OBSERVACAO; action = SELECT_CONSULTA_MARCACAO_OBSERVACAO;
currentConsultaMarcacaoObservacao = (TrabalhadoresConsultasDatasObservacoes) node.getUserObject();
} }
else if( node.getUserObject() instanceof TrabalhadoresConsultasDatasEmails ) else if( node.getUserObject() instanceof TrabalhadoresConsultasDatasEmails )
{ {
action = SELECT_CONSULTA_MARCACAO_EMAIL; action = SELECT_CONSULTA_MARCACAO_EMAIL;
currentConsultaMarcacaoEmail = (TrabalhadoresConsultasDatasEmails) node.getUserObject();
} }
else if( node.getUserObject() instanceof TrabalhadoresEcds ) else if( node.getUserObject() instanceof TrabalhadoresEcds )
{ {
action = SELECT_EXAME; action = SELECT_EXAME;
currentExame = (TrabalhadoresEcds) node.getUserObject();
} }
else if( node.getUserObject() instanceof TrabalhadoresEcdsDatas ) else if( node.getUserObject() instanceof TrabalhadoresEcdsDatas )
{ {
action = SELECT_EXAME_MARCACAO; action = SELECT_EXAME_MARCACAO;
currentExameMarcacao = (TrabalhadoresEcdsDatas) node.getUserObject();
} }
else if( node.getUserObject() instanceof TrabalhadoresEcdsDatasEmails ) else if( node.getUserObject() instanceof TrabalhadoresEcdsDatasEmails )
{ {
action = SELECT_EXAME_MARCACAO_EMAIL; action = SELECT_EXAME_MARCACAO_EMAIL;
currentExameMarcacaoEmail = (TrabalhadoresEcdsDatasEmails) node.getUserObject();
} }
else if( node.getUserObject() instanceof TrabalhadoresEcdsDatasObservacoes ) else if( node.getUserObject() instanceof TrabalhadoresEcdsDatasObservacoes )
{ {
action = SELECT_EXAME_MARCACAO_OBSERVACAO; action = SELECT_EXAME_MARCACAO_OBSERVACAO;
currentExameMarcacaoObservacao = (TrabalhadoresEcdsDatasObservacoes) node.getUserObject();
} }
else if( node instanceof FichaAptidaoMutableTreeNode ) else if( node instanceof FichaAptidaoMutableTreeNode )
{ {
action = SELECT_FICHA; action = SELECT_FICHA;
currentFicha = (TrabalhadoresFichasAptidao) node.getUserObject();
} }
runAction( action, node.getUserObject() ); runAction( action, node.getUserObject() );
return node; return node;

@ -31,7 +31,8 @@ public class UpdateList
new siprp.update.updates.V7_9_To_V8_0(), new siprp.update.updates.V8_0_To_V8_1(), new siprp.update.updates.V7_9_To_V8_0(), new siprp.update.updates.V8_0_To_V8_1(),
new siprp.update.updates.V8_1_To_V8_2(), new siprp.update.updates.V8_2_To_V8_3(), new siprp.update.updates.V8_1_To_V8_2(), new siprp.update.updates.V8_2_To_V8_3(),
new siprp.update.updates.V8_3_To_V8_4(), new siprp.update.updates.V8_4_To_V8_5(), new siprp.update.updates.V8_3_To_V8_4(), new siprp.update.updates.V8_4_To_V8_5(),
new siprp.update.updates.V8_5_To_V8_6(), new siprp.update.updates.V8_6_To_V8_7() }; new siprp.update.updates.V8_5_To_V8_6(), new siprp.update.updates.V8_6_To_V8_7(),
new siprp.update.updates.V8_7_To_V8_8() };
protected static Executer EXECUTER; protected static Executer EXECUTER;
protected static double version = -1; protected static double version = -1;

@ -0,0 +1,65 @@
/*
* V8_1_To_V8_2.java
*
* Created on December 19, 2007, 3:12 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.update.updates;
import com.evolute.utils.Singleton;
import com.evolute.utils.db.DBManager;
import com.evolute.utils.db.Executer;
/**
*
* @author fpalma
*/
public class V8_7_To_V8_8
implements siprp.update.Update
{
/**
* Creates a new instance of V8_6_To_V8_7
*/
public V8_7_To_V8_8()
{
}
public String []listChanges()
{
return new String[]{ "Adicionada coluna em 'lembretes' que referencia nova tabela das marcacoes (trabalhadores_consultas_datas)" };
}
public double getStartVersion()
{
return 8.7;
}
public double getEndVersion()
{
return 8.8;
}
public void doUpdate()
throws Exception
{
DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
Executer executer = dbm.getSharedExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"ALTER TABLE lembretes ADD COLUMN trabalhadores_consultas_datas_id int4 REFERENCES trabalhadores_consultas_datas(id);" );
executer.executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"ALTER TABLE lembretes ADD COLUMN trabalhadores_ecds_datas_id int4 REFERENCES trabalhadores_ecds_datas(id);" );
executer.executeQuery( update );
}
public String toString()
{
return "v" + getStartVersion() + " para v" + getEndVersion();
}
}
Loading…
Cancel
Save