forked from Coded/SIPRP
git-svn-id: https://svn.coded.pt/svn/SIPRP@1428 bb69d46d-e84e-40c8-a05a-06db0d633741
parent
aba7c5fd97
commit
55272cdee6
Binary file not shown.
@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
* AvisoConstants.java
|
|
||||||
*
|
|
||||||
* Created on 11 de Outubro de 2004, 13:03
|
|
||||||
*/
|
|
||||||
|
|
||||||
package siprp.data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author fpalma
|
|
||||||
*/
|
|
||||||
public interface AvisoConstants
|
|
||||||
{
|
|
||||||
public static final int TIPO_TRABALHADOR = 0;
|
|
||||||
public static final int TIPO_ESTABELECIMENTO = 1;
|
|
||||||
public static final int TIPO_EMPRESA = 2;
|
|
||||||
}
|
|
||||||
@ -1,102 +1,7 @@
|
|||||||
package siprp.data;
|
package siprp.data;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import com.evolute.adt.Pair;
|
public abstract class BaseObject extends shst.data.object.BaseObject
|
||||||
import com.evolute.entity.evo.EvoDataException;
|
|
||||||
import com.evolute.entity.evo.EvoDataObject;
|
|
||||||
import com.evolute.utils.strings.UnicodeChecker;
|
|
||||||
|
|
||||||
public abstract class BaseObject extends EvoDataObject
|
|
||||||
{
|
|
||||||
|
|
||||||
static
|
|
||||||
{
|
|
||||||
UnicodeChecker.setUseDoubleSlash( true );
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private static final String [] SOFT_DELETE_KEYS = new String[]{ "deleted_stamp", "deleted_date", "inactivo" };
|
|
||||||
|
|
||||||
public static final DateFormat DATE_FORMAT = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) );
|
|
||||||
|
|
||||||
protected static final String isNewMessage = " ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List fromReference(Class clazz, Integer id, String referingProperty, String... order) throws EvoDataException
|
|
||||||
{
|
|
||||||
List result = new LinkedList();
|
|
||||||
for( Object o : super.fromReference(clazz, id, referingProperty, order) )
|
|
||||||
{
|
|
||||||
Object inactivoString = ((EvoDataObject)o).get("inactivo");
|
|
||||||
Object deletedDateValue = ((EvoDataObject)o).get("deleted_date");
|
|
||||||
if( deletedDateValue == null && !"y".equals( inactivoString ) )
|
|
||||||
{
|
|
||||||
result.add( o );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Object getSoftDeleteObject( Class<?> returnClass )
|
|
||||||
{
|
|
||||||
Object result = null;
|
|
||||||
if( Timestamp.class.isAssignableFrom( returnClass ) )
|
|
||||||
{
|
|
||||||
result = new Timestamp( System.currentTimeMillis() );
|
|
||||||
}
|
|
||||||
else if( Date.class.isAssignableFrom( returnClass ) )
|
|
||||||
{
|
{
|
||||||
result = new Date();
|
|
||||||
}
|
|
||||||
else if( String.class.isAssignableFrom( returnClass ) )
|
|
||||||
{
|
|
||||||
result = "y";
|
|
||||||
}
|
|
||||||
else if( Boolean.class.isAssignableFrom( returnClass ) )
|
|
||||||
{
|
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Pair<String,Object> getSoftDelete()
|
|
||||||
{
|
|
||||||
String resultKey = null;
|
|
||||||
Object resultObject = null;
|
|
||||||
List<String> keys = Arrays.asList( getFieldNames() );
|
|
||||||
for( String key : SOFT_DELETE_KEYS )
|
|
||||||
{
|
|
||||||
if( keys.contains( key ) )
|
|
||||||
{
|
|
||||||
resultKey = key;
|
|
||||||
resultObject = getSoftDeleteObject( getFieldClass( key ) );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return resultKey == null ? null : new Pair<String, Object>(resultKey,resultObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete() throws EvoDataException
|
|
||||||
{
|
|
||||||
Pair<String,Object> softDelete = getSoftDelete();
|
|
||||||
if( softDelete != null )
|
|
||||||
{
|
|
||||||
set( softDelete.getLeft(), softDelete.getRight() );
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
super.delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,17 +0,0 @@
|
|||||||
/*
|
|
||||||
* MarcacaoTrabalhadorConstants.java
|
|
||||||
*
|
|
||||||
* Created on 11 de Outubro de 2004, 13:18
|
|
||||||
*/
|
|
||||||
|
|
||||||
package siprp.data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author fpalma
|
|
||||||
*/
|
|
||||||
public interface MarcacaoTrabalhadorConstants
|
|
||||||
{
|
|
||||||
public static final int TIPO_EXAMES = 0;
|
|
||||||
public static final int TIPO_CONSULTA = 1;
|
|
||||||
}
|
|
||||||
@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* MarcacaoConsultaExtendedPanel.java
|
|
||||||
*
|
|
||||||
* Created on 13 de Fevereiro de 2007, 20:36
|
|
||||||
*
|
|
||||||
* To change this template, choose Tools | Template Manager
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package siprp.medicina;
|
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Frederico
|
|
||||||
*/
|
|
||||||
public class MarcacaoConsultaExtendedPanel extends JPanel
|
|
||||||
{
|
|
||||||
|
|
||||||
/** Creates a new instance of MarcacaoConsultaExtendedPanel */
|
|
||||||
public MarcacaoConsultaExtendedPanel()
|
|
||||||
{
|
|
||||||
setupComponents();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupComponents()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,321 +0,0 @@
|
|||||||
package siprp.medicina;
|
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.GridBagConstraints;
|
|
||||||
import java.awt.GridBagLayout;
|
|
||||||
import java.awt.Insets;
|
|
||||||
import java.util.Hashtable;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
|
|
||||||
import siprp.data.outer.MarcacoesTrabalhadorData;
|
|
||||||
|
|
||||||
import com.evolute.utils.Singleton;
|
|
||||||
import com.evolute.utils.data.IDObject;
|
|
||||||
import com.evolute.utils.data.MappableObject;
|
|
||||||
import com.evolute.utils.data.PropertyObject;
|
|
||||||
import com.evolute.utils.dataui.ComponentController;
|
|
||||||
import com.evolute.utils.dataui.ComponentsHashtable;
|
|
||||||
import com.evolute.utils.dataui.ControllableComponent;
|
|
||||||
import com.evolute.utils.dataui.DataClassAware;
|
|
||||||
import com.evolute.utils.db.DBManager;
|
|
||||||
import com.evolute.utils.db.SQLExecuter;
|
|
||||||
import com.evolute.utils.ui.calendar.JCalendarPanel;
|
|
||||||
import com.evolute.utils.ui.panel.RadioButtonFixedPanel;
|
|
||||||
import com.evolute.utils.ui.text.StateTextArea;
|
|
||||||
|
|
||||||
public class MarcacaoConsultaPanel
|
|
||||||
extends JPanel
|
|
||||||
implements ControllableComponent, DataClassAware
|
|
||||||
{
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private MarcacoesTrabalhadorData marcacaoTrabalhadoresData;
|
|
||||||
private final ComponentsHashtable components = new ComponentsHashtable();
|
|
||||||
|
|
||||||
protected final SQLExecuter EXECUTER;
|
|
||||||
|
|
||||||
private final JLabel dataLabel = new JLabel( "Data da consulta", JLabel.RIGHT );
|
|
||||||
private final JCalendarPanel dataPanel = new JCalendarPanel( null );
|
|
||||||
private final JButton emailButton = new JButton( "Enviar Email" );
|
|
||||||
private final JLabel dataFichaLabel = new JLabel( "Data da Ficha de Aptid\u00e3o", JLabel.RIGHT );
|
|
||||||
private final JCalendarPanel dataFichaPanel = new JCalendarPanel( null );
|
|
||||||
private RadioButtonFixedPanel tipoList;
|
|
||||||
private RadioButtonFixedPanel estadoList;
|
|
||||||
private final JScrollPane observacoesTextScroll = new JScrollPane();
|
|
||||||
private final StateTextArea observacoesText = new StateTextArea();
|
|
||||||
|
|
||||||
public MarcacaoConsultaPanel()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
DBManager dbm = ( DBManager )Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
|
|
||||||
if( dbm != null )
|
|
||||||
{
|
|
||||||
EXECUTER = ( SQLExecuter )dbm.getSharedExecuter( this );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EXECUTER = null;
|
|
||||||
}
|
|
||||||
setupComponents();
|
|
||||||
setupComponentsHashtable();
|
|
||||||
place();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setupComponents()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
dataPanel.setMinimumSize( new Dimension( 300, 20 ) );
|
|
||||||
dataPanel.setPreferredSize( new Dimension( 100, 20 ) );
|
|
||||||
|
|
||||||
emailButton.setMinimumSize( new Dimension( 300, 20 ) );
|
|
||||||
emailButton.setPreferredSize( new Dimension( 200, 20 ) );
|
|
||||||
|
|
||||||
dataFichaPanel.setMinimumSize( new Dimension( 300, 20 ) );
|
|
||||||
dataFichaPanel.setPreferredSize( new Dimension( 100, 20 ) );
|
|
||||||
|
|
||||||
IDObject tipoListOptions[] = new IDObject[]{
|
|
||||||
new MappableObject( new Integer( 1 ), "Admiss\u00e3o" ),
|
|
||||||
new MappableObject( new Integer( 2 ), "Peri\u00f3dico" ),
|
|
||||||
new MappableObject( new Integer( 5 ), "Peri\u00f3dico inicial" ),
|
|
||||||
new MappableObject( new Integer( 3 ), "Ocasional" ),
|
|
||||||
};
|
|
||||||
tipoList = new RadioButtonFixedPanel( tipoListOptions, 4, 1, RadioButtonFixedPanel.ORIENTATION_VERTICAL, false, null );
|
|
||||||
tipoList.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Tipo" ) );
|
|
||||||
|
|
||||||
IDObject estadoListOptions[] = new IDObject[]{
|
|
||||||
new MappableObject( new Integer( 0 ), "Por realizar" ),
|
|
||||||
new MappableObject( new Integer( 2 ), "Realizada" ),
|
|
||||||
new MappableObject( new Integer( 3 ), "Desmarcada pelo trabalhador" ),
|
|
||||||
new MappableObject( new Integer( 4 ), "Desmarcada pela SIPRP" ),
|
|
||||||
new MappableObject( new Integer( 5 ), "Faltou" ),
|
|
||||||
};
|
|
||||||
estadoList = new RadioButtonFixedPanel( estadoListOptions, 6, 1, RadioButtonFixedPanel.ORIENTATION_VERTICAL, false, null );
|
|
||||||
estadoList.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Estado" ) );
|
|
||||||
|
|
||||||
observacoesText.setLineWrap( true );
|
|
||||||
observacoesText.setWrapStyleWord( true );
|
|
||||||
observacoesText.setRows( 5 );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void place()
|
|
||||||
{
|
|
||||||
JPanel MarcacaoConsultaPanel = this;
|
|
||||||
GridBagConstraints MarcacaoConsultaPanelGBC = new GridBagConstraints();
|
|
||||||
MarcacaoConsultaPanelGBC.insets = new Insets( 1, 1, 1, 1 );
|
|
||||||
GridBagLayout MarcacaoConsultaPanelLayout = new GridBagLayout();
|
|
||||||
MarcacaoConsultaPanel.setLayout( MarcacaoConsultaPanelLayout );
|
|
||||||
MarcacaoConsultaPanelGBC.gridx = 0;
|
|
||||||
MarcacaoConsultaPanelGBC.gridy = 0;
|
|
||||||
MarcacaoConsultaPanelGBC.gridwidth = 1;
|
|
||||||
MarcacaoConsultaPanelGBC.gridheight = 1;
|
|
||||||
MarcacaoConsultaPanelGBC.weightx = 0.0;
|
|
||||||
MarcacaoConsultaPanelGBC.weighty = 0.0;
|
|
||||||
MarcacaoConsultaPanelGBC.fill = GridBagConstraints.HORIZONTAL;
|
|
||||||
MarcacaoConsultaPanelLayout.setConstraints( dataLabel, MarcacaoConsultaPanelGBC );
|
|
||||||
MarcacaoConsultaPanel.add( dataLabel );
|
|
||||||
|
|
||||||
MarcacaoConsultaPanelGBC.gridx = 1;
|
|
||||||
MarcacaoConsultaPanelGBC.gridy = 0;
|
|
||||||
MarcacaoConsultaPanelGBC.gridwidth = 1;
|
|
||||||
MarcacaoConsultaPanelGBC.gridheight = 1;
|
|
||||||
MarcacaoConsultaPanelGBC.weightx = 0.5;
|
|
||||||
MarcacaoConsultaPanelGBC.weighty = 0.0;
|
|
||||||
MarcacaoConsultaPanelGBC.fill = GridBagConstraints.HORIZONTAL;
|
|
||||||
MarcacaoConsultaPanelLayout.setConstraints( dataPanel, MarcacaoConsultaPanelGBC );
|
|
||||||
MarcacaoConsultaPanel.add( dataPanel );
|
|
||||||
|
|
||||||
MarcacaoConsultaPanelGBC.gridx = 2;
|
|
||||||
MarcacaoConsultaPanelGBC.gridy = 0;
|
|
||||||
MarcacaoConsultaPanelGBC.gridwidth = 1;
|
|
||||||
MarcacaoConsultaPanelGBC.gridheight = 1;
|
|
||||||
MarcacaoConsultaPanelGBC.weightx = 0.5;
|
|
||||||
MarcacaoConsultaPanelGBC.weighty = 0.0;
|
|
||||||
MarcacaoConsultaPanelGBC.fill = GridBagConstraints.NONE;
|
|
||||||
MarcacaoConsultaPanelLayout.setConstraints( emailButton, MarcacaoConsultaPanelGBC );
|
|
||||||
MarcacaoConsultaPanel.add( emailButton );
|
|
||||||
|
|
||||||
MarcacaoConsultaPanelGBC.gridx = 0;
|
|
||||||
MarcacaoConsultaPanelGBC.gridy = 1;
|
|
||||||
MarcacaoConsultaPanelGBC.gridwidth = 1;
|
|
||||||
MarcacaoConsultaPanelGBC.gridheight = 1;
|
|
||||||
MarcacaoConsultaPanelGBC.weightx = 0.0;
|
|
||||||
MarcacaoConsultaPanelGBC.weighty = 0.0;
|
|
||||||
MarcacaoConsultaPanelGBC.fill = GridBagConstraints.HORIZONTAL;
|
|
||||||
MarcacaoConsultaPanelLayout.setConstraints( dataFichaLabel, MarcacaoConsultaPanelGBC );
|
|
||||||
MarcacaoConsultaPanel.add( dataFichaLabel );
|
|
||||||
|
|
||||||
MarcacaoConsultaPanelGBC.gridx = 1;
|
|
||||||
MarcacaoConsultaPanelGBC.gridy = 1;
|
|
||||||
MarcacaoConsultaPanelGBC.gridwidth = 1;
|
|
||||||
MarcacaoConsultaPanelGBC.gridheight = 1;
|
|
||||||
MarcacaoConsultaPanelGBC.weightx = 0.5;
|
|
||||||
MarcacaoConsultaPanelGBC.weighty = 0.0;
|
|
||||||
MarcacaoConsultaPanelGBC.fill = GridBagConstraints.HORIZONTAL;
|
|
||||||
MarcacaoConsultaPanelLayout.setConstraints( dataFichaPanel, MarcacaoConsultaPanelGBC );
|
|
||||||
MarcacaoConsultaPanel.add( dataFichaPanel );
|
|
||||||
|
|
||||||
MarcacaoConsultaPanelGBC.gridx = 0;
|
|
||||||
MarcacaoConsultaPanelGBC.gridy = 2;
|
|
||||||
MarcacaoConsultaPanelGBC.gridwidth = 2;
|
|
||||||
MarcacaoConsultaPanelGBC.gridheight = 1;
|
|
||||||
MarcacaoConsultaPanelGBC.weightx = 0.5;
|
|
||||||
MarcacaoConsultaPanelGBC.weighty = 0.0;
|
|
||||||
MarcacaoConsultaPanelGBC.fill = GridBagConstraints.BOTH;
|
|
||||||
MarcacaoConsultaPanelLayout.setConstraints( tipoList, MarcacaoConsultaPanelGBC );
|
|
||||||
MarcacaoConsultaPanel.add( tipoList );
|
|
||||||
|
|
||||||
MarcacaoConsultaPanelGBC.gridx = 2;
|
|
||||||
MarcacaoConsultaPanelGBC.gridy = 2;
|
|
||||||
MarcacaoConsultaPanelGBC.gridwidth = 1;
|
|
||||||
MarcacaoConsultaPanelGBC.gridheight = 1;
|
|
||||||
MarcacaoConsultaPanelGBC.weightx = 0.5;
|
|
||||||
MarcacaoConsultaPanelGBC.weighty = 0.0;
|
|
||||||
MarcacaoConsultaPanelGBC.fill = GridBagConstraints.BOTH;
|
|
||||||
MarcacaoConsultaPanelLayout.setConstraints( estadoList, MarcacaoConsultaPanelGBC );
|
|
||||||
MarcacaoConsultaPanel.add( estadoList );
|
|
||||||
|
|
||||||
MarcacaoConsultaPanelGBC.gridx = 0;
|
|
||||||
MarcacaoConsultaPanelGBC.gridy = 3;
|
|
||||||
MarcacaoConsultaPanelGBC.gridwidth = 3;
|
|
||||||
MarcacaoConsultaPanelGBC.gridheight = 1;
|
|
||||||
MarcacaoConsultaPanelGBC.weightx = 1.0;
|
|
||||||
MarcacaoConsultaPanelGBC.weighty = 1.0;
|
|
||||||
observacoesTextScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
|
|
||||||
observacoesTextScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED );
|
|
||||||
observacoesTextScroll.setViewportView( observacoesText );
|
|
||||||
MarcacaoConsultaPanelGBC.fill = GridBagConstraints.BOTH;
|
|
||||||
|
|
||||||
JPanel obsPanel = new JPanel( new BorderLayout() );
|
|
||||||
obsPanel.setBorder( BorderFactory.createTitledBorder( "Observa\u00e7\u00f5es" ) );
|
|
||||||
obsPanel.add( observacoesTextScroll, BorderLayout.CENTER );
|
|
||||||
MarcacaoConsultaPanelLayout.setConstraints( obsPanel, MarcacaoConsultaPanelGBC );
|
|
||||||
MarcacaoConsultaPanel.add( obsPanel );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupComponentsHashtable()
|
|
||||||
{
|
|
||||||
components.putComponent( MarcacoesTrabalhadorData.DATA, dataPanel );
|
|
||||||
components.putComponent( MarcacoesTrabalhadorData.DATA_RELATORIO, dataFichaPanel );
|
|
||||||
components.putComponent( MarcacoesTrabalhadorData.MOTIVO, tipoList );
|
|
||||||
components.putComponent( MarcacoesTrabalhadorData.ESTADO, estadoList );
|
|
||||||
components.putComponent( MarcacoesTrabalhadorData.OBSERVACOES, observacoesText );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void fill( Object toFill )
|
|
||||||
{
|
|
||||||
clear();
|
|
||||||
if( toFill == null || !( toFill instanceof PropertyObject ) )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Map<String,Object> data = null;
|
|
||||||
if( toFill instanceof PropertyObject )
|
|
||||||
{
|
|
||||||
data = ( (PropertyObject) toFill ).getHashData();
|
|
||||||
if( toFill instanceof MarcacoesTrabalhadorData )
|
|
||||||
{
|
|
||||||
marcacaoTrabalhadoresData = (MarcacoesTrabalhadorData) toFill;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( toFill instanceof Hashtable )
|
|
||||||
{
|
|
||||||
data = (Hashtable) toFill;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if( marcacaoTrabalhadoresData == null )
|
|
||||||
{
|
|
||||||
marcacaoTrabalhadoresData = new MarcacoesTrabalhadorData();
|
|
||||||
marcacaoTrabalhadoresData.setHashData( data );
|
|
||||||
}
|
|
||||||
PropertyObject po = (PropertyObject) toFill;
|
|
||||||
String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
|
|
||||||
ComponentController.fill( properties, po.getHashData(), components );
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object save()
|
|
||||||
{
|
|
||||||
if( marcacaoTrabalhadoresData == null )
|
|
||||||
{
|
|
||||||
marcacaoTrabalhadoresData = new MarcacoesTrabalhadorData();
|
|
||||||
}
|
|
||||||
Map<String,Object> data = marcacaoTrabalhadoresData.getHashData();
|
|
||||||
String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
|
|
||||||
ComponentController.save( properties, data, components );
|
|
||||||
if( !( marcacaoTrabalhadoresData instanceof PropertyObject ) )
|
|
||||||
{
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
marcacaoTrabalhadoresData.setHashData( data );
|
|
||||||
return marcacaoTrabalhadoresData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
marcacaoTrabalhadoresData = null;
|
|
||||||
String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
|
|
||||||
ComponentController.clear( properties, components );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnabled( boolean enable )
|
|
||||||
{
|
|
||||||
String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
|
|
||||||
ComponentController.setEnabled( properties, enable, components );
|
|
||||||
}
|
|
||||||
|
|
||||||
public Class getDataClass()
|
|
||||||
{
|
|
||||||
return MarcacoesTrabalhadorData.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JLabel getDataFichaLabel()
|
|
||||||
{
|
|
||||||
return dataFichaLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JCalendarPanel getDataFichaPanel()
|
|
||||||
{
|
|
||||||
return dataFichaPanel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JLabel getDataLabel()
|
|
||||||
{
|
|
||||||
return dataLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JCalendarPanel getDataPanel()
|
|
||||||
{
|
|
||||||
return dataPanel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JButton getEmailButton()
|
|
||||||
{
|
|
||||||
return emailButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RadioButtonFixedPanel getEstadoList()
|
|
||||||
{
|
|
||||||
return estadoList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StateTextArea getObservacoesText()
|
|
||||||
{
|
|
||||||
return observacoesText;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RadioButtonFixedPanel getTipoList()
|
|
||||||
{
|
|
||||||
return tipoList;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,281 +0,0 @@
|
|||||||
package siprp.medicina;
|
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.GridBagConstraints;
|
|
||||||
import java.awt.GridBagLayout;
|
|
||||||
import java.awt.Insets;
|
|
||||||
import java.util.Hashtable;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JComponent;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
|
|
||||||
import siprp.data.outer.MarcacoesTrabalhadorData;
|
|
||||||
|
|
||||||
import com.evolute.utils.Singleton;
|
|
||||||
import com.evolute.utils.data.IDObject;
|
|
||||||
import com.evolute.utils.data.MappableObject;
|
|
||||||
import com.evolute.utils.data.PropertyObject;
|
|
||||||
import com.evolute.utils.dataui.ComponentController;
|
|
||||||
import com.evolute.utils.dataui.ComponentsHashtable;
|
|
||||||
import com.evolute.utils.dataui.ControllableComponent;
|
|
||||||
import com.evolute.utils.dataui.DataClassAware;
|
|
||||||
import com.evolute.utils.dataui.wrappers.JPanelControllable;
|
|
||||||
import com.evolute.utils.db.DBManager;
|
|
||||||
import com.evolute.utils.db.SQLExecuter;
|
|
||||||
import com.evolute.utils.ui.calendar.JCalendarPanel;
|
|
||||||
import com.evolute.utils.ui.panel.RadioButtonFixedPanel;
|
|
||||||
import com.evolute.utils.ui.text.StateTextArea;
|
|
||||||
|
|
||||||
public class MarcacaoExamePanel
|
|
||||||
extends JPanel
|
|
||||||
implements ControllableComponent, DataClassAware
|
|
||||||
{
|
|
||||||
private MarcacoesTrabalhadorData marcacaoTrabalhadoresData;
|
|
||||||
private final ComponentsHashtable components = new ComponentsHashtable();
|
|
||||||
|
|
||||||
protected final SQLExecuter EXECUTER;
|
|
||||||
|
|
||||||
private final JLabel dataLabel = new JLabel( "Data dos Exames", JLabel.RIGHT );
|
|
||||||
private final JCalendarPanel dataPanel = new JCalendarPanel( null );
|
|
||||||
private final JButton emailButton = new JButton( "Enviar Email" );
|
|
||||||
private final JPanelControllable detalhesPanel = new JPanelControllable();
|
|
||||||
private RadioButtonFixedPanel estadoList;
|
|
||||||
private final JScrollPane observacoesTextScroll = new JScrollPane();
|
|
||||||
private final StateTextArea observacoesText = new StateTextArea();
|
|
||||||
|
|
||||||
public MarcacaoExamePanel()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
DBManager dbm = ( DBManager )Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
|
|
||||||
if( dbm != null )
|
|
||||||
{
|
|
||||||
EXECUTER = ( SQLExecuter )dbm.getSharedExecuter( this );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EXECUTER = null;
|
|
||||||
}
|
|
||||||
setupComponents();
|
|
||||||
setupComponentsHashtable();
|
|
||||||
place();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setupComponents()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
JComponent MarcacaoExamePanel = this;
|
|
||||||
emailButton.setMinimumSize( new Dimension( 300, 20 ) );
|
|
||||||
emailButton.setPreferredSize( new Dimension( 200, 20 ) );
|
|
||||||
|
|
||||||
detalhesPanel.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Detalhes" ) );
|
|
||||||
|
|
||||||
IDObject estadoListOptions[] = new IDObject[]{
|
|
||||||
new MappableObject( new Integer( 0 ), "Por realizar" ),
|
|
||||||
new MappableObject( new Integer( 1 ), "Parcialmente realizados" ),
|
|
||||||
new MappableObject( new Integer( 2 ), "Realizados" ),
|
|
||||||
new MappableObject( new Integer( 3 ), "Desmarcados pelo trabalhador" ),
|
|
||||||
new MappableObject( new Integer( 4 ), "Desmarcados pela SIPRP" ),
|
|
||||||
new MappableObject( new Integer( 5 ), "Faltou" ),
|
|
||||||
};
|
|
||||||
estadoList = new RadioButtonFixedPanel( estadoListOptions, 6, 1, RadioButtonFixedPanel.ORIENTATION_VERTICAL, false, null );
|
|
||||||
estadoList.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Estado" ) );
|
|
||||||
|
|
||||||
observacoesText.setLineWrap( true );
|
|
||||||
observacoesText.setWrapStyleWord( true );
|
|
||||||
observacoesText.setRows( 5 );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void place()
|
|
||||||
{
|
|
||||||
JPanel MarcacaoExamePanel = this;
|
|
||||||
GridBagConstraints detalhesPanelGBC = new GridBagConstraints();
|
|
||||||
detalhesPanelGBC.insets = new Insets( 1, 1, 1, 1 );
|
|
||||||
GridBagLayout detalhesPanelLayout = new GridBagLayout();
|
|
||||||
detalhesPanel.setLayout( detalhesPanelLayout );
|
|
||||||
GridBagConstraints MarcacaoExamePanelGBC = new GridBagConstraints();
|
|
||||||
MarcacaoExamePanelGBC.insets = new Insets( 1, 1, 1, 1 );
|
|
||||||
GridBagLayout MarcacaoExamePanelLayout = new GridBagLayout();
|
|
||||||
MarcacaoExamePanel.setLayout( MarcacaoExamePanelLayout );
|
|
||||||
MarcacaoExamePanelGBC.gridx = 0;
|
|
||||||
MarcacaoExamePanelGBC.gridy = 0;
|
|
||||||
MarcacaoExamePanelGBC.gridwidth = 1;
|
|
||||||
MarcacaoExamePanelGBC.gridheight = 1;
|
|
||||||
MarcacaoExamePanelGBC.weightx = 0.0;
|
|
||||||
MarcacaoExamePanelGBC.weighty = 0.0;
|
|
||||||
MarcacaoExamePanelGBC.fill = GridBagConstraints.HORIZONTAL;
|
|
||||||
MarcacaoExamePanelLayout.setConstraints( dataLabel, MarcacaoExamePanelGBC );
|
|
||||||
MarcacaoExamePanel.add( dataLabel );
|
|
||||||
|
|
||||||
MarcacaoExamePanelGBC.gridx = 1;
|
|
||||||
MarcacaoExamePanelGBC.gridy = 0;
|
|
||||||
MarcacaoExamePanelGBC.gridwidth = 1;
|
|
||||||
MarcacaoExamePanelGBC.gridheight = 1;
|
|
||||||
MarcacaoExamePanelGBC.weightx = 0.5;
|
|
||||||
MarcacaoExamePanelGBC.weighty = 0.0;
|
|
||||||
MarcacaoExamePanelGBC.fill = GridBagConstraints.HORIZONTAL;
|
|
||||||
MarcacaoExamePanelLayout.setConstraints( dataPanel, MarcacaoExamePanelGBC );
|
|
||||||
MarcacaoExamePanel.add( dataPanel );
|
|
||||||
|
|
||||||
MarcacaoExamePanelGBC.gridx = 2;
|
|
||||||
MarcacaoExamePanelGBC.gridy = 0;
|
|
||||||
MarcacaoExamePanelGBC.gridwidth = 1;
|
|
||||||
MarcacaoExamePanelGBC.gridheight = 1;
|
|
||||||
MarcacaoExamePanelGBC.weightx = 0.5;
|
|
||||||
MarcacaoExamePanelGBC.weighty = 0.0;
|
|
||||||
MarcacaoExamePanelGBC.fill = GridBagConstraints.NONE;
|
|
||||||
MarcacaoExamePanelLayout.setConstraints( emailButton, MarcacaoExamePanelGBC );
|
|
||||||
MarcacaoExamePanel.add( emailButton );
|
|
||||||
|
|
||||||
MarcacaoExamePanelGBC.gridx = 0;
|
|
||||||
MarcacaoExamePanelGBC.gridy = 1;
|
|
||||||
MarcacaoExamePanelGBC.gridwidth = 2;
|
|
||||||
MarcacaoExamePanelGBC.gridheight = 1;
|
|
||||||
MarcacaoExamePanelGBC.weightx = 0.5;
|
|
||||||
MarcacaoExamePanelGBC.weighty = 0.0;
|
|
||||||
MarcacaoExamePanelGBC.fill = GridBagConstraints.BOTH;
|
|
||||||
MarcacaoExamePanelLayout.setConstraints( detalhesPanel, MarcacaoExamePanelGBC );
|
|
||||||
MarcacaoExamePanel.add( detalhesPanel );
|
|
||||||
|
|
||||||
MarcacaoExamePanelGBC.gridx = 2;
|
|
||||||
MarcacaoExamePanelGBC.gridy = 1;
|
|
||||||
MarcacaoExamePanelGBC.gridwidth = 1;
|
|
||||||
MarcacaoExamePanelGBC.gridheight = 1;
|
|
||||||
MarcacaoExamePanelGBC.weightx = 0.5;
|
|
||||||
MarcacaoExamePanelGBC.weighty = 0.0;
|
|
||||||
MarcacaoExamePanelGBC.fill = GridBagConstraints.BOTH;
|
|
||||||
MarcacaoExamePanelLayout.setConstraints( estadoList, MarcacaoExamePanelGBC );
|
|
||||||
MarcacaoExamePanel.add( estadoList );
|
|
||||||
|
|
||||||
MarcacaoExamePanelGBC.gridx = 0;
|
|
||||||
MarcacaoExamePanelGBC.gridy = 2;
|
|
||||||
MarcacaoExamePanelGBC.gridwidth = 3;
|
|
||||||
MarcacaoExamePanelGBC.gridheight = 1;
|
|
||||||
MarcacaoExamePanelGBC.weightx = 1.0;
|
|
||||||
MarcacaoExamePanelGBC.weighty = 1.0;
|
|
||||||
observacoesTextScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
|
|
||||||
observacoesTextScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED );
|
|
||||||
observacoesTextScroll.setViewportView( observacoesText );
|
|
||||||
MarcacaoExamePanelGBC.fill = GridBagConstraints.BOTH;
|
|
||||||
JPanel obsPanel = new JPanel( new BorderLayout() );
|
|
||||||
obsPanel.add( observacoesTextScroll, BorderLayout.CENTER );
|
|
||||||
obsPanel.setBorder( BorderFactory.createTitledBorder( "Observa\u00e7\u00f5es" ) );
|
|
||||||
|
|
||||||
MarcacaoExamePanelLayout.setConstraints( obsPanel, MarcacaoExamePanelGBC );
|
|
||||||
MarcacaoExamePanel.add( obsPanel );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupComponentsHashtable()
|
|
||||||
{
|
|
||||||
components.putComponent( MarcacoesTrabalhadorData.DATA, dataPanel );
|
|
||||||
components.putComponent( MarcacoesTrabalhadorData.ESTADO, estadoList );
|
|
||||||
components.putComponent( MarcacoesTrabalhadorData.OBSERVACOES, observacoesText );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void fill( Object toFill )
|
|
||||||
{
|
|
||||||
clear();
|
|
||||||
if( toFill == null || !( toFill instanceof PropertyObject ) )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Map<String,Object> data = null;
|
|
||||||
if( toFill instanceof PropertyObject )
|
|
||||||
{
|
|
||||||
data = ( (PropertyObject) toFill ).getHashData();
|
|
||||||
if( toFill instanceof MarcacoesTrabalhadorData )
|
|
||||||
{
|
|
||||||
marcacaoTrabalhadoresData = (MarcacoesTrabalhadorData) toFill;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( toFill instanceof Hashtable )
|
|
||||||
{
|
|
||||||
data = (Hashtable) toFill;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if( marcacaoTrabalhadoresData == null )
|
|
||||||
{
|
|
||||||
marcacaoTrabalhadoresData = new MarcacoesTrabalhadorData();
|
|
||||||
marcacaoTrabalhadoresData.setHashData( data );
|
|
||||||
}
|
|
||||||
PropertyObject po = (PropertyObject) toFill;
|
|
||||||
String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
|
|
||||||
ComponentController.fill( properties, po.getHashData(), components );
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object save()
|
|
||||||
{
|
|
||||||
if( marcacaoTrabalhadoresData == null )
|
|
||||||
{
|
|
||||||
marcacaoTrabalhadoresData = new MarcacoesTrabalhadorData();
|
|
||||||
}
|
|
||||||
Map<String,Object> data = marcacaoTrabalhadoresData.getHashData();
|
|
||||||
String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
|
|
||||||
ComponentController.save( properties, data, components );
|
|
||||||
if( !( marcacaoTrabalhadoresData instanceof PropertyObject ) )
|
|
||||||
{
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
marcacaoTrabalhadoresData.setHashData( data );
|
|
||||||
return marcacaoTrabalhadoresData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
marcacaoTrabalhadoresData = null;
|
|
||||||
String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
|
|
||||||
ComponentController.clear( properties, components );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnabled( boolean enable )
|
|
||||||
{
|
|
||||||
String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
|
|
||||||
ComponentController.setEnabled( properties, enable, components );
|
|
||||||
}
|
|
||||||
|
|
||||||
public Class getDataClass()
|
|
||||||
{
|
|
||||||
return MarcacoesTrabalhadorData.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JLabel getDataLabel()
|
|
||||||
{
|
|
||||||
return dataLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JCalendarPanel getDataPanel()
|
|
||||||
{
|
|
||||||
return dataPanel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JPanelControllable getDetalhesPanel()
|
|
||||||
{
|
|
||||||
return detalhesPanel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JButton getEmailButton()
|
|
||||||
{
|
|
||||||
return emailButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RadioButtonFixedPanel getEstadoList()
|
|
||||||
{
|
|
||||||
return estadoList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StateTextArea getObservacoesText()
|
|
||||||
{
|
|
||||||
return observacoesText;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,95 +0,0 @@
|
|||||||
/*
|
|
||||||
* MarcacoesMedicinaHandler.java
|
|
||||||
*
|
|
||||||
* Created on 28 de Abril de 2006, 9:56
|
|
||||||
*
|
|
||||||
* To change this template, choose Tools | Template Manager
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package siprp.medicina;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import siprp.data.Marcacao;
|
|
||||||
import siprp.data.outer.MarcacoesTrabalhadorData;
|
|
||||||
import siprp.data.outer.TrabalhadoresData;
|
|
||||||
|
|
||||||
import com.evolute.entity.ProviderInterface;
|
|
||||||
import com.evolute.utils.Singleton;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Classe auxiliar para tratamento de marcações de Medicina.
|
|
||||||
*
|
|
||||||
* @author Frederico
|
|
||||||
*/
|
|
||||||
public class MarcacoesMedicinaHandler
|
|
||||||
{
|
|
||||||
/** Creates a new instance of MarcacoesMedicinaHandler */
|
|
||||||
public MarcacoesMedicinaHandler()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ajusta os estado das marações corrente e seguinte para uma trabalhador.
|
|
||||||
* Este método é usado pelo sistema de marcaç&atild;o de fichas de aptidaão para ajustar
|
|
||||||
* as marcações existentes às escolhidas na ficha.
|
|
||||||
*
|
|
||||||
* @param trabalhadorID um inteiro que representa o trabalhador em questão
|
|
||||||
* @param motivoCorrente um inteiro que representa o motivo da marcação corrente (admissão/periódico/ocasional)
|
|
||||||
* @param dataCorrente a data que se pretende para a marcação corrente
|
|
||||||
* @param motivoSeguinte um inteiro que representa o motivo da marcação seguinte (admissão/periódico/ocasional)
|
|
||||||
* @param dataSeguinte a data que se pretende para a marcação seguinte
|
|
||||||
* @throws Exception se houver um erro na comunicação com a Base de Dados
|
|
||||||
*/
|
|
||||||
public void ajustarMarcacoes( Integer trabalhadorID, Integer motivoCorrente, Date dataCorrente,
|
|
||||||
Integer motivoSeguinte, Date dataSeguinte )
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Integer idCorrente;
|
|
||||||
Integer idSeguinte;
|
|
||||||
MedicinaDataProvider provider = ( MedicinaDataProvider ) MedicinaDataProvider.getProvider();
|
|
||||||
ProviderInterface JDO = ( ProviderInterface ) Singleton.getInstance( Singleton.DEFAULT_EVO_DATA_PROVIDER );
|
|
||||||
TrabalhadoresData trabalhador = (TrabalhadoresData)JDO.load( TrabalhadoresData.class, trabalhadorID );
|
|
||||||
|
|
||||||
idCorrente = provider.getConsultaIDByTrabalhadorMotivoAndDate( trabalhadorID, motivoCorrente, dataCorrente );
|
|
||||||
MarcacoesTrabalhadorData consultaCorrente;
|
|
||||||
if( idCorrente == null )
|
|
||||||
{
|
|
||||||
consultaCorrente = new MarcacoesTrabalhadorData();
|
|
||||||
consultaCorrente.setToTrabalhador_id( trabalhador );
|
|
||||||
consultaCorrente.set( MarcacoesTrabalhadorData.TIPO, new Integer( MarcacoesTrabalhadorData.TIPO_CONSULTA ) );
|
|
||||||
consultaCorrente.set( Marcacao.DATA, dataCorrente );
|
|
||||||
consultaCorrente.set( MarcacoesTrabalhadorData.MOTIVO, motivoCorrente );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
consultaCorrente = ( MarcacoesTrabalhadorData ) JDO.load( MarcacoesTrabalhadorData.class, idCorrente );
|
|
||||||
}
|
|
||||||
consultaCorrente.set( Marcacao.REALIZADA, "y" );
|
|
||||||
consultaCorrente.set( MarcacoesTrabalhadorData.ESTADO, new Integer( siprp.medicina.MedicinaDataProvider.ESTADO_REALIZADO ) );
|
|
||||||
consultaCorrente.save();
|
|
||||||
|
|
||||||
idSeguinte = provider.getConsultaIDByTrabalhadorMotivoAndDate( trabalhadorID, motivoSeguinte, dataSeguinte );
|
|
||||||
if( idSeguinte == null )
|
|
||||||
{
|
|
||||||
idSeguinte = provider.getProximaConsultaIDByTrabalhadorMotivoAndDate( trabalhadorID, motivoSeguinte, dataCorrente );
|
|
||||||
MarcacoesTrabalhadorData consultaSeguinte;
|
|
||||||
if( idSeguinte == null )
|
|
||||||
{
|
|
||||||
consultaSeguinte = new MarcacoesTrabalhadorData();
|
|
||||||
consultaSeguinte.setToTrabalhador_id( trabalhador );
|
|
||||||
consultaSeguinte.set( MarcacoesTrabalhadorData.TIPO, new Integer( MarcacoesTrabalhadorData.TIPO_CONSULTA ) );
|
|
||||||
consultaSeguinte.set( MarcacoesTrabalhadorData.MOTIVO, motivoSeguinte );
|
|
||||||
consultaSeguinte.set( Marcacao.REALIZADA, "y" );
|
|
||||||
consultaSeguinte.set( MarcacoesTrabalhadorData.ESTADO, new Integer( siprp.medicina.MedicinaDataProvider.ESTADO_POR_REALIZAR ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
consultaSeguinte = ( MarcacoesTrabalhadorData ) JDO.load( MarcacoesTrabalhadorData.class, idSeguinte );
|
|
||||||
}
|
|
||||||
consultaSeguinte.set( Marcacao.DATA, dataSeguinte );
|
|
||||||
consultaSeguinte.save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,479 +0,0 @@
|
|||||||
/*
|
|
||||||
* MedicinaDataProvider.java
|
|
||||||
*
|
|
||||||
* Created on January 29, 2006, 12:27 AM
|
|
||||||
*
|
|
||||||
* To change this template, choose Tools | Template Manager
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package siprp.medicina;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import siprp.MedicinaConstants;
|
|
||||||
import siprp.data.Marcacao;
|
|
||||||
|
|
||||||
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.metadb.MetaProvider;
|
|
||||||
import com.evolute.utils.sql.Assignment;
|
|
||||||
import com.evolute.utils.sql.Delete;
|
|
||||||
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.tables.ColumnizedMappable;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author fpalma
|
|
||||||
*/
|
|
||||||
public class MedicinaDataProvider extends MetaProvider
|
|
||||||
implements MedicinaConstants
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
public static final String TIPOS_CONSULTAS[] =
|
|
||||||
new String[]{ "", MOTIVO_ADMISSAO_STR, MOTIVO_PERIODICO_STR, MOTIVO_OCASIONAL_STR, "", MOTIVO_PERIODICO_INICIAL_STR };
|
|
||||||
|
|
||||||
|
|
||||||
public static final HashMap<Integer,String> SUB_MOTIVOS_BY_ID =
|
|
||||||
new HashMap<Integer,String>();
|
|
||||||
|
|
||||||
public static final HashMap<Integer,Integer[]> SUB_MOTIVOS_IDS_BY_MOTIVO_ID =
|
|
||||||
new HashMap<Integer,Integer[]>();
|
|
||||||
|
|
||||||
// public static final String ESTADOS_EXAME_STR[] =
|
|
||||||
// new String[]{ "Por realizar", "Parcialmente realizado", "Realizado",
|
|
||||||
// "Desmarcado trabalhador",
|
|
||||||
// "Desmarcado " + Singleton.getInstance( SingletonConstants.COMPANY_ACRONYM ),
|
|
||||||
// "Faltou" };
|
|
||||||
//
|
|
||||||
// public static final String ESTADOS_CONSULTA_STR[] =
|
|
||||||
// new String[]{ "Por realizar", "Parcialmente realizada", "Realizada",
|
|
||||||
// "Desmarcada trabalhador",
|
|
||||||
// "Desmarcada " + Singleton.getInstance( SingletonConstants.COMPANY_ACRONYM ),
|
|
||||||
// "Faltou" };
|
|
||||||
|
|
||||||
private static final Object LOCK = new Object();
|
|
||||||
private static MedicinaDataProvider instance = null;
|
|
||||||
|
|
||||||
static
|
|
||||||
{
|
|
||||||
|
|
||||||
SUB_MOTIVOS_BY_ID.put( SUB_MOTIVO_APOS_DOENCA_INTEGER, SUB_MOTIVO_APOS_DOENCA_STR );
|
|
||||||
SUB_MOTIVOS_BY_ID.put( SUB_MOTIVO_APOS_ACIDENTE_INTEGER, SUB_MOTIVO_APOS_ACIDENTE_STR );
|
|
||||||
SUB_MOTIVOS_BY_ID.put( SUB_MOTIVO_PEDIDO_TRABALHADOR_INTEGER, SUB_MOTIVO_PEDIDO_TRABALHADOR_STR );
|
|
||||||
SUB_MOTIVOS_BY_ID.put( SUB_MOTIVO_PEDIDO_SERVICO_INTEGER, SUB_MOTIVO_PEDIDO_SERVICO_STR );
|
|
||||||
SUB_MOTIVOS_BY_ID.put( SUB_MOTIVO_MUDANCA_FUNCAO_INTEGER, SUB_MOTIVO_MUDANCA_FUNCAO_STR );
|
|
||||||
SUB_MOTIVOS_BY_ID.put( SUB_MOTIVO_ALTERACAO_CONDICOES_INTEGER, SUB_MOTIVO_ALTERACAO_CONDICOES_STR );
|
|
||||||
SUB_MOTIVOS_BY_ID.put( SUB_MOTIVO_OUTRO_INTEGER, SUB_MOTIVO_OUTRO_STR );
|
|
||||||
|
|
||||||
SUB_MOTIVOS_IDS_BY_MOTIVO_ID.put( MOTIVO_OCASIONAL_INTEGER,
|
|
||||||
new Integer[]{ SUB_MOTIVO_APOS_DOENCA_INTEGER, SUB_MOTIVO_APOS_ACIDENTE_INTEGER,
|
|
||||||
SUB_MOTIVO_PEDIDO_TRABALHADOR_INTEGER, SUB_MOTIVO_PEDIDO_SERVICO_INTEGER,
|
|
||||||
SUB_MOTIVO_MUDANCA_FUNCAO_INTEGER, SUB_MOTIVO_ALTERACAO_CONDICOES_INTEGER,
|
|
||||||
SUB_MOTIVO_OUTRO_INTEGER } );
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Executer executer;
|
|
||||||
|
|
||||||
public static HashMap<Integer, String> getConsultaEstados()
|
|
||||||
{
|
|
||||||
HashMap<Integer, String> result = new HashMap<Integer, String>();
|
|
||||||
for( int i = 0; i < MedicinaConstants.ESTADOS_CONSULTA_STR.length; ++i )
|
|
||||||
{
|
|
||||||
if( MedicinaConstants.ESTADOS_CONSULTA_STR[i] != null)
|
|
||||||
{
|
|
||||||
result.put( new Integer( i ), MedicinaConstants.ESTADOS_CONSULTA_STR[i] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Creates a new instance of MedicinaDataProvider */
|
|
||||||
public MedicinaDataProvider()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER /*SingletonConstants.DBMANAGER*/ );
|
|
||||||
executer = dbm.getSharedExecuter( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MetaProvider getProvider()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
synchronized( LOCK )
|
|
||||||
{
|
|
||||||
if( instance == null )
|
|
||||||
{
|
|
||||||
instance = new MedicinaDataProvider();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String []getEmpresaEstabelecimento( Integer empresaID, Integer estabelecimentoID )
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
String nomes[] = new String[ 2 ];
|
|
||||||
Select select = new Select( new String[]{ "empresas" },
|
|
||||||
new String[]{ "designacao_social" },
|
|
||||||
new Field( "id" ).isEqual( empresaID ) );
|
|
||||||
Virtual2DArray array = executer.executeQuery( select );
|
|
||||||
nomes[ 0 ] = ( String ) array.get( 0, 0 );
|
|
||||||
|
|
||||||
select = new Select( new String[]{ "estabelecimentos" },
|
|
||||||
new String[]{ "nome" },
|
|
||||||
new Field( "id" ).isEqual( estabelecimentoID ) );
|
|
||||||
array = executer.executeQuery( select );
|
|
||||||
nomes[ 1 ] = ( String ) array.get( 0, 0 );
|
|
||||||
|
|
||||||
return nomes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IDObject[] getDetalhesValidosTrabalhador( Integer empresaID, Integer trabalhadorID )
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Select select =
|
|
||||||
new Select( new String[]{ "trabalhadores" },
|
|
||||||
new String[]{ "perfil" },
|
|
||||||
new Field( "id" ).isEqual( trabalhadorID ) );
|
|
||||||
Virtual2DArray array = executer.executeQuery( select );
|
|
||||||
Integer perfil = ( Integer ) array.get( 0, 0 );
|
|
||||||
if( perfil == null )
|
|
||||||
{
|
|
||||||
return new IDObject[ 0 ];
|
|
||||||
}
|
|
||||||
select =
|
|
||||||
new Select( new String[]{ "prt_elementos_protocolo", "prt_tipos_elementos_protocolo",
|
|
||||||
"prt_grupos_protocolo" },
|
|
||||||
new String[]{ "prt_grupos_protocolo.id" , "prt_grupos_protocolo.descricao",
|
|
||||||
"prt_grupos_protocolo.ordem"},
|
|
||||||
new Field( "prt_elementos_protocolo.empresa_id" ).isEqual( empresaID ).and(
|
|
||||||
new Field( "prt_elementos_protocolo.tipo_elemento_protocolo_id" ).isEqual(
|
|
||||||
new Field( "prt_tipos_elementos_protocolo.id" ) ) ).and(
|
|
||||||
new Field( "prt_tipos_elementos_protocolo.grupo_protocolo_id" ).isEqual(
|
|
||||||
new Field( "prt_grupos_protocolo.id" ) ) ).and(
|
|
||||||
new Field( "prt_elementos_protocolo.numero_perfil" ).isEqual( perfil ) ),
|
|
||||||
new String[]{ "prt_grupos_protocolo.ordem" },
|
|
||||||
null );
|
|
||||||
array = executer.executeQuery( select );
|
|
||||||
Vector detalhes = new Vector();
|
|
||||||
Integer oldID = null;
|
|
||||||
for( int n = 0; n < array.columnLength(); n++ )
|
|
||||||
{
|
|
||||||
Integer id = ( Integer ) array.get( n, 0 );
|
|
||||||
if( id.equals( oldID ) )
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
oldID = id;
|
|
||||||
String descricao = ( String ) array.get( n, 1 );
|
|
||||||
detalhes.add( new MappableObject( id, descricao ) );
|
|
||||||
}
|
|
||||||
return ( IDObject[] ) detalhes.toArray( new IDObject[ detalhes.size() ] );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDetalhesRealziadosForMarcacao( Integer marcacaoID, Integer detalhes[] )
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Delete delete =
|
|
||||||
new Delete( "marcacoes_grupos_realizados",
|
|
||||||
new Field( "marcacao_trabalhador_id" ).isEqual( marcacaoID ) );
|
|
||||||
executer.executeQuery( delete );
|
|
||||||
Insert insert =
|
|
||||||
new Insert( "marcacoes_grupos_realizados",
|
|
||||||
new Assignment[]{
|
|
||||||
new Assignment( new Field( "marcacao_trabalhador_id" ), marcacaoID ),
|
|
||||||
new Assignment( new Field( "grupo_protocolo_id" ), detalhes ) } );
|
|
||||||
executer.executeQuery( insert, null );
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer[] getDetalhesRealizadosForMarcacao( Integer marcacaoID )
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Select select =
|
|
||||||
new Select( new String[]{ "marcacoes_grupos_realizados" },
|
|
||||||
new String[]{ "grupo_protocolo_id" },
|
|
||||||
new Field( "marcacao_trabalhador_id" ).isEqual( marcacaoID ) );
|
|
||||||
Virtual2DArray array = executer.executeQuery( select );
|
|
||||||
Integer ids[] = new Integer[ array.columnLength() ];
|
|
||||||
for( int n = 0; n < array.columnLength(); n++ )
|
|
||||||
{
|
|
||||||
ids[ n ] = ( Integer ) array.get( n, 0 );
|
|
||||||
}
|
|
||||||
return ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer[] getDetalhesRealizadosForEstadosMarcacao( Integer marcacaoID )
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Select select =
|
|
||||||
new Select( new String[]{ "marcacoes_grupos_realizados", "marcacoes_trabalhador_estados" },
|
|
||||||
new String[]{ "grupo_protocolo_id" },
|
|
||||||
new Field( "marcacoes_trabalhador_estados.marcacao_id" ).isEqual( marcacaoID ).and(
|
|
||||||
new Field( "marcacoes_trabalhador_estados.id" ).isEqual(
|
|
||||||
new Field( "marcacoes_grupos_realizados.marcacoes_trabalhador_estado_id" ) ) ) );
|
|
||||||
Virtual2DArray array = executer.executeQuery( select );
|
|
||||||
Integer ids[] = new Integer[ array.columnLength() ];
|
|
||||||
for( int n = 0; n < array.columnLength(); n++ )
|
|
||||||
{
|
|
||||||
ids[ n ] = ( Integer ) array.get( n, 0 );
|
|
||||||
}
|
|
||||||
return ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteDetalhesRealizadosForMarcacao( Integer marcacaoID )
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Delete delete =
|
|
||||||
new Delete( "marcacoes_grupos_realizados",
|
|
||||||
new Field( "marcacao_trabalhador_id" ).isEqual( marcacaoID ) );
|
|
||||||
executer.executeQuery( delete );
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object[][] getExamesTrabalhador( Integer trabalhadorID )
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Select select =
|
|
||||||
new Select( new String[]{ "marcacoes_trabalhador" },
|
|
||||||
new String[]{ "id", "data", "estado" },
|
|
||||||
new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and(
|
|
||||||
new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ) ),
|
|
||||||
new String[]{ "data desc" },
|
|
||||||
null );
|
|
||||||
Virtual2DArray array = executer.executeQuery( select );
|
|
||||||
Object data[][] = array.getObjects();
|
|
||||||
for( int n = 0; n < data.length; n++ )
|
|
||||||
{
|
|
||||||
int estado = ( ( Integer ) data[ n ][ 2 ] ).intValue();
|
|
||||||
data[ n ][ 2 ] = ESTADOS_EXAME_STR[ estado ];
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object[][] getConsultasTrabalhador( Integer trabalhadorID )
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Select select =
|
|
||||||
new Select( new String[]{ "marcacoes_trabalhador" },
|
|
||||||
new String[]{ "id", "data", "estado" },
|
|
||||||
new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and(
|
|
||||||
new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ),
|
|
||||||
new String[]{ "data desc" },
|
|
||||||
null );
|
|
||||||
Virtual2DArray array = executer.executeQuery( select );
|
|
||||||
Object data[][] = array.getObjects();
|
|
||||||
for( int n = 0; n < data.length; n++ )
|
|
||||||
{
|
|
||||||
int estado = ( ( Integer ) data[ n ][ 2 ] ).intValue();
|
|
||||||
data[ n ][ 2 ] = ESTADOS_CONSULTA_STR[ estado ];
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ColumnizedMappable[] getAllEmpresas()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Select select =
|
|
||||||
new Select( new String[]{ "empresas" },
|
|
||||||
new String[]{ "id", "designacao_social", "designacao_social_plain" },
|
|
||||||
new Field( "inactivo" ).isDifferent( "y" ),
|
|
||||||
new String[]{ "designacao_social_plain" },
|
|
||||||
null );
|
|
||||||
Virtual2DArray array = executer.executeQuery( select );
|
|
||||||
ColumnizedMappable empresas[] = new ColumnizedMappable[ array.columnLength() ];
|
|
||||||
for( int n = 0; n < empresas.length; n++ )
|
|
||||||
{
|
|
||||||
Integer id = ( Integer ) array.get( n, 0 );
|
|
||||||
String designacao = ( String ) array.get( n, 1 );
|
|
||||||
empresas[ n ] = new ColumnizedMappable( id, designacao );
|
|
||||||
}
|
|
||||||
return empresas;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ColumnizedMappable[] getAllEstabelecimentosForEmpresa( Integer empresaID )
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Select select =
|
|
||||||
new Select( new String[]{ "estabelecimentos" },
|
|
||||||
new String[]{ "id", "nome", "nome_plain" },
|
|
||||||
new Field( "empresa_id" ).isEqual( empresaID ).and(
|
|
||||||
new Field( "inactivo" ).isDifferent( "y" ) ),
|
|
||||||
new String[]{ "nome_plain" },
|
|
||||||
null );
|
|
||||||
Virtual2DArray array = executer.executeQuery( select );
|
|
||||||
ColumnizedMappable estabelecimentos[] = new ColumnizedMappable[ array.columnLength() ];
|
|
||||||
for( int n = 0; n < estabelecimentos.length; n++ )
|
|
||||||
{
|
|
||||||
Integer id = ( Integer ) array.get( n, 0 );
|
|
||||||
String nome = ( String ) array.get( n, 1 );
|
|
||||||
estabelecimentos[ n ] = new ColumnizedMappable( id, nome );
|
|
||||||
}
|
|
||||||
return estabelecimentos;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ColumnizedMappable[] getAllTrabalhadoresForEstabelecimento( Integer estabelecimentoID )
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Select select =
|
|
||||||
new Select( new String[]{ "trabalhadores" },
|
|
||||||
new String[]{ "id", "nome", "nome_plain" },
|
|
||||||
new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ).and(
|
|
||||||
new Field( "inactivo" ).isDifferent( "y" ) ),
|
|
||||||
new String[]{ "nome_plain" },
|
|
||||||
null );
|
|
||||||
Virtual2DArray array = executer.executeQuery( select );
|
|
||||||
ColumnizedMappable trabalhadores[] = new ColumnizedMappable[ array.columnLength() ];
|
|
||||||
for( int n = 0; n < trabalhadores.length; n++ )
|
|
||||||
{
|
|
||||||
Integer id = ( Integer ) array.get( n, 0 );
|
|
||||||
String nome = ( String ) array.get( n, 1 );
|
|
||||||
trabalhadores[ n ] = new ColumnizedMappable( id, nome );
|
|
||||||
}
|
|
||||||
return trabalhadores;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Devolve o identificador da consulta de um trabalhador para um dado motivo e dia.
|
|
||||||
*
|
|
||||||
* @param trabalhadorID o identificador do trabalhador
|
|
||||||
* @param motivo o identificador do motivo da marcacao
|
|
||||||
* @param data a data da marcacao
|
|
||||||
* @return o identificador da consulta ou <code>null</code> se não houver nenhuma
|
|
||||||
* @throws Exception se houver um erro na ligaço à Base de Dados
|
|
||||||
*/
|
|
||||||
public Integer getConsultaIDByTrabalhadorMotivoAndDate( Integer trabalhadorID, Integer motivo, Date data )
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Integer motivos[];
|
|
||||||
if( motivo != null && ( motivo.intValue() == MOTIVO_PERIODICO || motivo.intValue() == MOTIVO_PERIODICO_INICIAL ) )
|
|
||||||
{
|
|
||||||
motivos = new Integer[]{ MOTIVO_PERIODICO_INTEGER, MOTIVO_PERIODICO_INICIAL_INTEGER };
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
motivos = new Integer[]{ motivo };
|
|
||||||
}
|
|
||||||
Select select =
|
|
||||||
new Select( new String[]{ "marcacoes_trabalhador" },
|
|
||||||
new String[]{ "id" },
|
|
||||||
new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and(
|
|
||||||
new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ).and(
|
|
||||||
new Field( "data" ).isEqual( data ) ).and(
|
|
||||||
new Field( "motivo" ).in( motivos ) ) );
|
|
||||||
Virtual2DArray array = executer.executeQuery( select );
|
|
||||||
Integer id;
|
|
||||||
if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
|
|
||||||
{
|
|
||||||
id = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
id = ( Integer ) array.get( 0, 0 );
|
|
||||||
}
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Devolve o identificador da primeira consulta de um trabalhador n&ão realizada depois de um diapara um dado motivo.
|
|
||||||
*
|
|
||||||
* @param trabalhadorID o identificador do trabalhador
|
|
||||||
* @param motivo o identificador do motivo da marcacao
|
|
||||||
* @param data a data de início de procura
|
|
||||||
* @return o identificador da consulta ou <code>null</code> se não houver nenhuma
|
|
||||||
* @throws Exception se houver um erro na ligaço à Base de Dados
|
|
||||||
*/
|
|
||||||
public Integer getProximaConsultaIDByTrabalhadorMotivoAndDate( Integer trabalhadorID, Integer motivo, Date data )
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Select select =
|
|
||||||
new Select( new String[]{ "marcacoes_trabalhador" },
|
|
||||||
new String[]{ "id", "data" },
|
|
||||||
new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and(
|
|
||||||
new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ).and(
|
|
||||||
new Field( "data" ).isGreater( data ) ).and(
|
|
||||||
new Field( "motivo" ).isEqual( motivo ) ).and(
|
|
||||||
new Field( "estado" ).isEqual( new Integer( 0 ) ) ),
|
|
||||||
new String[]{ "data" },
|
|
||||||
null );
|
|
||||||
Virtual2DArray array = executer.executeQuery( select );
|
|
||||||
Integer id;
|
|
||||||
if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
|
|
||||||
{
|
|
||||||
id = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
id = ( Integer ) array.get( 0, 0 );
|
|
||||||
}
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object[][] getListaConsultasByData( Date data )
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Select2 select =
|
|
||||||
new Select2( new String[]{ "marcacoes_trabalhador", "trabalhadores", "estabelecimentos", "empresas" },
|
|
||||||
new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER },
|
|
||||||
new Expression[]{
|
|
||||||
new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ),
|
|
||||||
new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ),
|
|
||||||
new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ) },
|
|
||||||
new String[]{ "marcacoes_trabalhador.id", "trabalhadores.nome", "trabalhadores.nome_plain",
|
|
||||||
"empresas.designacao_social", "marcacoes_trabalhador.tipo", "prestador_id" },
|
|
||||||
new Field( "marcacoes_trabalhador.data" ).isEqual( data ).and(
|
|
||||||
new Field( "marcacoes_trabalhador.estado" ).isEqual(
|
|
||||||
new Integer( Marcacao.ESTADO_POR_REALIZAR ) ) ).and(
|
|
||||||
new Field( "marcacoes_trabalhador.tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ),
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null );
|
|
||||||
Virtual2DArray array = executer.executeQuery( select );
|
|
||||||
return array.getObjects();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object[][] getListaECDsByData( Date data )
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Select2 select =
|
|
||||||
new Select2( new String[]{ "marcacoes_trabalhador", "trabalhadores", "estabelecimentos", "empresas" },
|
|
||||||
new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER },
|
|
||||||
new Expression[]{
|
|
||||||
new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ),
|
|
||||||
new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ),
|
|
||||||
new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ) },
|
|
||||||
new String[]{ "marcacoes_trabalhador.id", "trabalhadores.nome", "trabalhadores.nome_plain",
|
|
||||||
"empresas.designacao_social", "marcacoes_trabalhador.tipo", "prestador_id" },
|
|
||||||
new Field( "marcacoes_trabalhador.data" ).isEqual( data ).and(
|
|
||||||
new Field( "marcacoes_trabalhador.estado" ).isEqual(
|
|
||||||
new Integer( Marcacao.ESTADO_POR_REALIZAR ) ) ).and(
|
|
||||||
new Field( "marcacoes_trabalhador.tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ) ),
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null );
|
|
||||||
Virtual2DArray array = executer.executeQuery( select );
|
|
||||||
return array.getObjects();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getTrabalhadorIDByMarcacaoID( Integer marcacaoID )
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Select select =
|
|
||||||
new Select( new String[]{ "marcacoes_trabalhador" },
|
|
||||||
new String[]{ "trabalhador_id" },
|
|
||||||
new Field( "id" ).isEqual( marcacaoID ) );
|
|
||||||
Virtual2DArray array = executer.executeQuery( select );
|
|
||||||
return ( Integer ) array.get( 0, 0 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,261 +0,0 @@
|
|||||||
/*
|
|
||||||
* MedicinaUpperPanel.java
|
|
||||||
*
|
|
||||||
* Created on February 1, 2006, 6:48 PM
|
|
||||||
*
|
|
||||||
* To change this template, choose Tools | Template Manager
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package siprp.medicina;
|
|
||||||
|
|
||||||
import java.awt.GridBagConstraints;
|
|
||||||
import java.awt.GridBagLayout;
|
|
||||||
import java.awt.Insets;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.ListSelectionModel;
|
|
||||||
import javax.swing.event.ListSelectionEvent;
|
|
||||||
import javax.swing.event.ListSelectionListener;
|
|
||||||
|
|
||||||
import com.evolute.utils.dataui.ControllableComponent;
|
|
||||||
import com.evolute.utils.tables.BaseTable;
|
|
||||||
import com.evolute.utils.tables.ColumnizedMappable;
|
|
||||||
import com.evolute.utils.tables.VectorTableModel;
|
|
||||||
import com.evolute.utils.ui.DialogException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author fpalma
|
|
||||||
*/
|
|
||||||
public class MedicinaUpperPanel extends JPanel
|
|
||||||
implements ListSelectionListener, ControllableComponent
|
|
||||||
{
|
|
||||||
protected BaseTable empresasTable;
|
|
||||||
protected VectorTableModel empresasModel;
|
|
||||||
protected BaseTable estabelecimentosTable;
|
|
||||||
protected VectorTableModel estabelecimentosModel;
|
|
||||||
protected BaseTable trabalhadoresTable;
|
|
||||||
protected VectorTableModel trabalhadoresModel;
|
|
||||||
|
|
||||||
protected MedicinaDataProvider provider;
|
|
||||||
|
|
||||||
protected final Vector listeners;
|
|
||||||
|
|
||||||
protected boolean editing = false;
|
|
||||||
|
|
||||||
/** Creates a new instance of MedicinaUpperPanel */
|
|
||||||
public MedicinaUpperPanel()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
provider = ( MedicinaDataProvider ) MedicinaDataProvider.getProvider();
|
|
||||||
listeners = new Vector();
|
|
||||||
setupComponents();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupComponents()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
empresasModel = new VectorTableModel( 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 );
|
|
||||||
empresasTable.getSelectionModel().addListSelectionListener( this );
|
|
||||||
estabelecimentosModel = new VectorTableModel( 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 );
|
|
||||||
estabelecimentosTable.getSelectionModel().addListSelectionListener( this );
|
|
||||||
trabalhadoresModel = new VectorTableModel( 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 );
|
|
||||||
trabalhadoresTable.getSelectionModel().addListSelectionListener( this );
|
|
||||||
|
|
||||||
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 );
|
|
||||||
|
|
||||||
ColumnizedMappable empresas[] = provider.getAllEmpresas();
|
|
||||||
Vector values = empresasModel.getValues();
|
|
||||||
values.addAll( Arrays.asList( empresas ) );
|
|
||||||
empresasModel.setValues( values );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void valueChanged( ListSelectionEvent e )
|
|
||||||
{
|
|
||||||
Object source = e.getSource();
|
|
||||||
if( e.getValueIsAdjusting() )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if( source.equals( empresasTable.getSelectionModel() ) )
|
|
||||||
{
|
|
||||||
carregarEstabelecimentos();
|
|
||||||
}
|
|
||||||
else if( source.equals( estabelecimentosTable.getSelectionModel() ) )
|
|
||||||
{
|
|
||||||
carregarTrabalhadores();
|
|
||||||
}
|
|
||||||
else if( source.equals( trabalhadoresTable.getSelectionModel() ) )
|
|
||||||
{
|
|
||||||
notifyListeners( e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void carregarEstabelecimentos()
|
|
||||||
{
|
|
||||||
estabelecimentosTable.clearSelection();
|
|
||||||
int selected = empresasTable.getSelectedRow();
|
|
||||||
estabelecimentosModel.clearAll();
|
|
||||||
if( selected > -1 )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Integer empresaID = ( ( ColumnizedMappable ) empresasModel.getRowAt( selected ) ).getID();
|
|
||||||
ColumnizedMappable estabelecimentos[] = provider.getAllEstabelecimentosForEmpresa( empresaID);
|
|
||||||
Vector values = estabelecimentosModel.getValues();
|
|
||||||
values.addAll( Arrays.asList( estabelecimentos ) );
|
|
||||||
estabelecimentosModel.setValues( values );
|
|
||||||
}
|
|
||||||
catch( Exception ex )
|
|
||||||
{
|
|
||||||
DialogException.showExceptionMessage( ex, "Erro a carregar os estabelecimentos.", true );
|
|
||||||
estabelecimentosModel.clearAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void carregarTrabalhadores()
|
|
||||||
{
|
|
||||||
trabalhadoresTable.clearSelection();
|
|
||||||
int selected = estabelecimentosTable.getSelectedRow();
|
|
||||||
trabalhadoresModel.clearAll();
|
|
||||||
if( selected > -1 )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Integer estabelecimentoID = ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( selected ) ).getID();
|
|
||||||
ColumnizedMappable trabalhadores[] = provider.getAllTrabalhadoresForEstabelecimento( estabelecimentoID );
|
|
||||||
Vector values = trabalhadoresModel.getValues();
|
|
||||||
values.addAll( Arrays.asList( trabalhadores ) );
|
|
||||||
trabalhadoresModel.setValues( values );
|
|
||||||
}
|
|
||||||
catch( Exception ex )
|
|
||||||
{
|
|
||||||
DialogException.showExceptionMessage( ex, "Erro a carregar trabalhadores.", true );
|
|
||||||
trabalhadoresModel.clearAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void notifyListeners( ListSelectionEvent e )
|
|
||||||
{
|
|
||||||
for( int n = 0; n < listeners.size(); n++ )
|
|
||||||
{
|
|
||||||
ListSelectionEvent event =
|
|
||||||
new ListSelectionEvent( this, e.getFirstIndex(), e.getLastIndex(), e.getValueIsAdjusting() );
|
|
||||||
( ( ListSelectionListener ) listeners.elementAt( n ) ).valueChanged( event );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addListSelectionListener( ListSelectionListener listener )
|
|
||||||
{
|
|
||||||
listeners.add( listener );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeSelectionListener( ListSelectionListener listener )
|
|
||||||
{
|
|
||||||
listeners.remove( listener );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
// empresasTable.clearSelection();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void fill( Object value )
|
|
||||||
{
|
|
||||||
if( value == null )
|
|
||||||
{
|
|
||||||
clear();
|
|
||||||
}
|
|
||||||
Integer ids[] = ( Integer [] ) value;
|
|
||||||
for( int n = 0; n < empresasTable.getRowCount(); n++ )
|
|
||||||
{
|
|
||||||
if( ( ( ColumnizedMappable ) empresasModel.getRowAt( n ) ).getID().equals( ids[ 0 ] ) )
|
|
||||||
{
|
|
||||||
empresasTable.setRowSelectionInterval( n, n );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for( int n = 0; n < estabelecimentosTable.getRowCount(); n++ )
|
|
||||||
{
|
|
||||||
if( ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( n ) ).getID().equals( ids[ 1 ] ) )
|
|
||||||
{
|
|
||||||
estabelecimentosTable.setRowSelectionInterval( n, n );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for( int n = 0; n < trabalhadoresTable.getRowCount(); n++ )
|
|
||||||
{
|
|
||||||
if( ( ( ColumnizedMappable ) trabalhadoresModel.getRowAt( n ) ).getID().equals( ids[ 2 ] ) )
|
|
||||||
{
|
|
||||||
trabalhadoresTable.setRowSelectionInterval( n, n );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object save()
|
|
||||||
{
|
|
||||||
int empresaSelected = empresasTable.getSelectedRow();
|
|
||||||
int estabelecimentoSelected = estabelecimentosTable.getSelectedRow();
|
|
||||||
int trabalhadorSelected = trabalhadoresTable.getSelectedRow();
|
|
||||||
return new Integer[]{
|
|
||||||
empresaSelected == -1 ? null : ( ( ColumnizedMappable ) empresasModel.getRowAt( empresaSelected ) ).getID(),
|
|
||||||
estabelecimentoSelected == -1 ? null : ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( estabelecimentoSelected ) ).getID(),
|
|
||||||
trabalhadorSelected == -1 ? null : ( ( ColumnizedMappable ) trabalhadoresModel.getRowAt( trabalhadorSelected ) ).getID()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnabled( boolean enable )
|
|
||||||
{
|
|
||||||
editing = !enable;
|
|
||||||
empresasTable.setEnabled( enable );
|
|
||||||
estabelecimentosTable.setEnabled( enable );
|
|
||||||
trabalhadoresTable.setEnabled( enable );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,706 +0,0 @@
|
|||||||
/*
|
|
||||||
* MedicinaWindow.java
|
|
||||||
*
|
|
||||||
* Created on 17 de Janeiro de 2006, 19:43
|
|
||||||
*
|
|
||||||
* To change this template, choose Tools | Options and locate the template under
|
|
||||||
* the Source Creation and Management node. Right-click the template and choose
|
|
||||||
* Open. You can then make changes to the template in the Source Editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package siprp.medicina;
|
|
||||||
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.GridBagConstraints;
|
|
||||||
import java.awt.GridBagLayout;
|
|
||||||
import java.awt.GridLayout;
|
|
||||||
import java.awt.Insets;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.event.ListSelectionEvent;
|
|
||||||
import javax.swing.event.ListSelectionListener;
|
|
||||||
|
|
||||||
import shst.SHSTTrackerInterface;
|
|
||||||
import shst.medicina.MedicinaWindowInterface;
|
|
||||||
import siprp.FichaDataProvider;
|
|
||||||
import siprp.SingletonConstants;
|
|
||||||
import siprp.clientes.AvisosPanel;
|
|
||||||
import siprp.companydataloaders.CompanyDataLoader;
|
|
||||||
import siprp.data.AvisoConstants;
|
|
||||||
import siprp.data.Marcacao;
|
|
||||||
import siprp.data.outer.ContactosData;
|
|
||||||
import siprp.data.outer.EstabelecimentosData;
|
|
||||||
import siprp.data.outer.MarcacoesTrabalhadorData;
|
|
||||||
import siprp.data.outer.TrabalhadoresData;
|
|
||||||
import siprp.ui.SIPRPTabbedWindow;
|
|
||||||
|
|
||||||
import com.evolute.entity.ProviderInterface;
|
|
||||||
import com.evolute.utils.Singleton;
|
|
||||||
import com.evolute.utils.arrays.Object2DArray;
|
|
||||||
import com.evolute.utils.data.IDObject;
|
|
||||||
import com.evolute.utils.ui.DialogException;
|
|
||||||
import com.evolute.utils.ui.panel.CheckBoxPanel;
|
|
||||||
import com.evolute.utils.ui.panel.TableEditorPanel;
|
|
||||||
import com.evolute.utils.ui.text.CopyPasteHandler;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author fpalma
|
|
||||||
*/
|
|
||||||
public class MedicinaWindow extends SIPRPTabbedWindow
|
|
||||||
implements ActionListener, ListSelectionListener, MedicinaWindowInterface
|
|
||||||
{
|
|
||||||
private static int iPermissionArray[][] =
|
|
||||||
new int[][]{ {},
|
|
||||||
{ NEW_INDEX, EDIT_INDEX, SAVE_INDEX, DELETE_INDEX, CANCEL_INDEX },
|
|
||||||
{ NEW_INDEX, EDIT_INDEX, SAVE_INDEX, DELETE_INDEX, CANCEL_INDEX } };
|
|
||||||
|
|
||||||
private static final int TAB_CONSULTA = 0;
|
|
||||||
private static final int TAB_EXAME = 1;
|
|
||||||
|
|
||||||
private static final int INDEX_MAIN = 0;
|
|
||||||
private static final int INDEX_CONSULTA = 1;
|
|
||||||
private static final int INDEX_EXAME = 2;
|
|
||||||
|
|
||||||
private static final String tabNames[] =
|
|
||||||
new String[]{ "Consultas", "Exames" };
|
|
||||||
|
|
||||||
private static final DateFormat DATE_FORMAT =
|
|
||||||
DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "PT", "pt" ) );
|
|
||||||
|
|
||||||
protected MedicinaDataProvider provider;
|
|
||||||
protected FichaDataProvider fichaProvider;
|
|
||||||
protected ProviderInterface JDO;
|
|
||||||
protected SHSTTrackerInterface tracker;
|
|
||||||
|
|
||||||
protected MedicinaUpperPanel upperPanel;
|
|
||||||
protected MarcacaoConsultaPanel marcacaoConsultaPanel;
|
|
||||||
protected TableEditorPanel marcacaoConsultaEditorPanel;
|
|
||||||
protected MarcacaoExamePanel marcacaoExamePanel;
|
|
||||||
protected TableEditorPanel marcacaoExameEditorPanel;
|
|
||||||
protected CheckBoxPanel detalhesExamePanel;
|
|
||||||
|
|
||||||
protected Integer empresaID;
|
|
||||||
protected String empresa;
|
|
||||||
protected Integer estabelecimentoID;
|
|
||||||
protected String estabelecimento;
|
|
||||||
protected Integer trabalhadorID;
|
|
||||||
protected TrabalhadoresData trabalhador;
|
|
||||||
protected boolean estado[] = new boolean[]{ false, false };
|
|
||||||
|
|
||||||
/** Creates a new instance of MedicinaWindow */
|
|
||||||
public MedicinaWindow()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
super( new MedicinaUpperPanel(), tabNames, 0.7, createPermissions( iPermissionArray ) );
|
|
||||||
upperPanel = ( MedicinaUpperPanel ) getUpperPanel();
|
|
||||||
provider = ( MedicinaDataProvider ) MedicinaDataProvider.getProvider();
|
|
||||||
fichaProvider = ( FichaDataProvider ) FichaDataProvider.getProvider();
|
|
||||||
JDO = ( ProviderInterface ) Singleton.getInstance( Singleton.DEFAULT_EVO_DATA_PROVIDER );
|
|
||||||
setupComponents();
|
|
||||||
maximizeOnNextActivate();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupComponents()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
setTitle( "Medicina" );
|
|
||||||
setupConsultaComponents();
|
|
||||||
setupExameComponents();
|
|
||||||
upperPanel.addListSelectionListener( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupConsultaComponents()
|
|
||||||
{
|
|
||||||
JPanel panel = getTab( TAB_CONSULTA );
|
|
||||||
|
|
||||||
panel.setBorder(
|
|
||||||
BorderFactory.createTitledBorder(
|
|
||||||
BorderFactory.createEtchedBorder(), "Consultas" ) );
|
|
||||||
|
|
||||||
changeGroupName( INDEX_CONSULTA, "Consultas" );
|
|
||||||
setActionName( INDEX_CONSULTA, NEW_INDEX, "Nova" );
|
|
||||||
setActionTooltip( INDEX_CONSULTA, NEW_INDEX, "Nova" );
|
|
||||||
JPanel toolbar = getToolbarPanel( INDEX_CONSULTA );
|
|
||||||
|
|
||||||
GridBagLayout gridbag = new GridBagLayout();
|
|
||||||
GridBagConstraints constraints = new GridBagConstraints();
|
|
||||||
panel.setLayout( gridbag );
|
|
||||||
constraints.insets = new Insets( 2, 2, 2, 2 );
|
|
||||||
constraints.fill = GridBagConstraints.BOTH;
|
|
||||||
constraints.gridwidth = GridBagConstraints.REMAINDER;
|
|
||||||
constraints.weightx = 1.0;
|
|
||||||
|
|
||||||
gridbag.setConstraints( toolbar, constraints );
|
|
||||||
panel.add( toolbar );
|
|
||||||
|
|
||||||
constraints.gridheight = 1;
|
|
||||||
constraints.weighty = 1.0;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
marcacaoConsultaEditorPanel =
|
|
||||||
new TableEditorPanel( new String[]{ "Data",
|
|
||||||
"Estado" },
|
|
||||||
new int[]{0,2}, new int[]{0,0},
|
|
||||||
0.0, 1.0, new Dimension( 350, 100 ) );
|
|
||||||
marcacaoConsultaPanel = new MarcacaoConsultaPanel();
|
|
||||||
new CopyPasteHandler( marcacaoConsultaPanel.getObservacoesText() );
|
|
||||||
marcacaoConsultaEditorPanel.addComponent( marcacaoConsultaPanel,
|
|
||||||
new int[]{0,2}, new int[]{1,2},
|
|
||||||
1.0, 1.0 );
|
|
||||||
marcacaoConsultaEditorPanel.addListSelectionListener( new ListSelectionListener(){
|
|
||||||
public void valueChanged(javax.swing.event.ListSelectionEvent listSelectionEvent)
|
|
||||||
{
|
|
||||||
if( marcacaoConsultaEditorPanel.getID() != null )
|
|
||||||
{
|
|
||||||
reload(INDEX_CONSULTA);
|
|
||||||
select(INDEX_CONSULTA);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
clear( INDEX_CONSULTA );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}catch( Exception ex )
|
|
||||||
{
|
|
||||||
DialogException.showException( ex );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
gridbag.setConstraints( marcacaoConsultaEditorPanel, constraints );
|
|
||||||
panel.add( marcacaoConsultaEditorPanel );
|
|
||||||
marcacaoConsultaPanel.getEmailButton().addActionListener( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupExameComponents()
|
|
||||||
{
|
|
||||||
JPanel panel = getTab( TAB_EXAME );
|
|
||||||
|
|
||||||
panel.setBorder(
|
|
||||||
BorderFactory.createTitledBorder(
|
|
||||||
BorderFactory.createEtchedBorder(), "Exames" ) );
|
|
||||||
|
|
||||||
changeGroupName( INDEX_EXAME, "Exames" );
|
|
||||||
JPanel toolbar = getToolbarPanel( INDEX_EXAME );
|
|
||||||
|
|
||||||
GridBagLayout gridbag = new GridBagLayout();
|
|
||||||
GridBagConstraints constraints = new GridBagConstraints();
|
|
||||||
panel.setLayout( gridbag );
|
|
||||||
constraints.insets = new Insets( 2, 2, 2, 2 );
|
|
||||||
constraints.fill = GridBagConstraints.BOTH;
|
|
||||||
constraints.gridwidth = GridBagConstraints.REMAINDER;
|
|
||||||
constraints.weightx = 1.0;
|
|
||||||
|
|
||||||
gridbag.setConstraints( toolbar, constraints );
|
|
||||||
panel.add( toolbar );
|
|
||||||
|
|
||||||
constraints.gridheight = 1;
|
|
||||||
constraints.weighty = 1.0;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
marcacaoExameEditorPanel =
|
|
||||||
new TableEditorPanel( new String[]{ "Data",
|
|
||||||
"Estado" },
|
|
||||||
new int[]{0,2}, new int[]{0,0},
|
|
||||||
0.0, 1.0, new Dimension( 350, 100 ) );
|
|
||||||
marcacaoExamePanel = new MarcacaoExamePanel();
|
|
||||||
new CopyPasteHandler( marcacaoExamePanel.getObservacoesText() );
|
|
||||||
marcacaoExameEditorPanel.addComponent( marcacaoExamePanel,
|
|
||||||
new int[]{0,2}, new int[]{1,2},
|
|
||||||
1.0, 1.0 );
|
|
||||||
marcacaoExameEditorPanel.addListSelectionListener( new ListSelectionListener(){
|
|
||||||
public void valueChanged(javax.swing.event.ListSelectionEvent listSelectionEvent)
|
|
||||||
{
|
|
||||||
if( marcacaoExameEditorPanel.getID() != null )
|
|
||||||
{
|
|
||||||
reload(INDEX_EXAME);
|
|
||||||
select(INDEX_EXAME);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
clear( INDEX_EXAME );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}catch( Exception ex )
|
|
||||||
{
|
|
||||||
DialogException.showException( ex );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
gridbag.setConstraints( marcacaoExameEditorPanel, constraints );
|
|
||||||
panel.add( marcacaoExameEditorPanel );
|
|
||||||
marcacaoExamePanel.getEmailButton().addActionListener( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean save(int index)
|
|
||||||
{
|
|
||||||
Date data;
|
|
||||||
switch( index )
|
|
||||||
{
|
|
||||||
case INDEX_EXAME:
|
|
||||||
MarcacoesTrabalhadorData exame = ( MarcacoesTrabalhadorData ) marcacaoExamePanel.save();
|
|
||||||
data = ( Date ) exame.get( MarcacoesTrabalhadorData.DATA );
|
|
||||||
if( data == null )
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog( this, "Tem de preencher uma data para os exames.",
|
|
||||||
"Erro", JOptionPane.ERROR_MESSAGE );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
exame.set( MarcacoesTrabalhadorData.TIPO,
|
|
||||||
new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) );
|
|
||||||
exame.setToTrabalhador_id( trabalhador );
|
|
||||||
try
|
|
||||||
{
|
|
||||||
exame.set( MarcacoesTrabalhadorData.REALIZADA,
|
|
||||||
( ( Integer )exame.get( MarcacoesTrabalhadorData.ESTADO ) ).intValue() ==
|
|
||||||
provider.ESTADO_REALIZADO ? "y" : "n" );
|
|
||||||
exame.save();
|
|
||||||
Integer exameID = ( Integer ) exame.get( MarcacoesTrabalhadorData.ID );
|
|
||||||
Integer detalhesRealizados[] = detalhesExamePanel.getSelected();
|
|
||||||
provider.setDetalhesRealziadosForMarcacao( exameID, detalhesRealizados );
|
|
||||||
}
|
|
||||||
catch( Exception ex )
|
|
||||||
{
|
|
||||||
DialogException.showExceptionMessage( ex, "Erro a gravar", true );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case INDEX_CONSULTA:
|
|
||||||
MarcacoesTrabalhadorData consulta = ( MarcacoesTrabalhadorData ) marcacaoConsultaPanel.save();
|
|
||||||
data = ( Date ) consulta.get( MarcacoesTrabalhadorData.DATA );
|
|
||||||
if( data == null )
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog( this, "Tem de preencher uma data para a consulta.",
|
|
||||||
"Erro", JOptionPane.ERROR_MESSAGE );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
consulta.set( MarcacoesTrabalhadorData.TIPO,
|
|
||||||
new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) );
|
|
||||||
consulta.setToTrabalhador_id( trabalhador );
|
|
||||||
try
|
|
||||||
{
|
|
||||||
consulta.set( MarcacoesTrabalhadorData.REALIZADA,
|
|
||||||
( ( Integer )consulta.get( MarcacoesTrabalhadorData.ESTADO ) ).intValue() ==
|
|
||||||
provider.ESTADO_REALIZADO ? "y" : "n" );
|
|
||||||
consulta.save();
|
|
||||||
}
|
|
||||||
catch( Exception ex )
|
|
||||||
{
|
|
||||||
DialogException.showExceptionMessage( ex, "Erro a gravar", true );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
reload( INDEX_MAIN );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean delete(int index)
|
|
||||||
{
|
|
||||||
int option = JOptionPane.showConfirmDialog( this, "Tem a certeza que quer apagar a marca\u00e7\u00e3o?",
|
|
||||||
"Apagar", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE );
|
|
||||||
if( option == JOptionPane.OK_OPTION )
|
|
||||||
{
|
|
||||||
switch( index )
|
|
||||||
{
|
|
||||||
case INDEX_CONSULTA:
|
|
||||||
MarcacoesTrabalhadorData consulta = ( MarcacoesTrabalhadorData ) marcacaoConsultaPanel.save();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
consulta.delete();
|
|
||||||
}
|
|
||||||
catch( Exception ex )
|
|
||||||
{
|
|
||||||
DialogException.showExceptionMessage( ex, "Erro a apagar.", true );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case INDEX_EXAME:
|
|
||||||
MarcacoesTrabalhadorData exame = ( MarcacoesTrabalhadorData ) marcacaoExamePanel.save();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
exame.delete();
|
|
||||||
}
|
|
||||||
catch( Exception ex )
|
|
||||||
{
|
|
||||||
DialogException.showExceptionMessage( ex, "Erro a apagar.", true );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
reload( INDEX_MAIN );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clear(int index)
|
|
||||||
{
|
|
||||||
switch( index )
|
|
||||||
{
|
|
||||||
case INDEX_MAIN:
|
|
||||||
empresaID = null;
|
|
||||||
empresa = null;
|
|
||||||
estabelecimentoID = null;
|
|
||||||
estabelecimento = null;
|
|
||||||
trabalhadorID = null;
|
|
||||||
trabalhador = null;
|
|
||||||
upperPanel.clear();
|
|
||||||
marcacaoExameEditorPanel.clear();
|
|
||||||
marcacaoConsultaEditorPanel.clear();
|
|
||||||
// marcacaoExamePanel.getDetalhesPanel().removeAll();
|
|
||||||
detalhesExamePanel = null;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case INDEX_CONSULTA:
|
|
||||||
marcacaoConsultaPanel.clear();
|
|
||||||
marcacaoConsultaPanel.getEmailButton().setText( "Enviar email" );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case INDEX_EXAME:
|
|
||||||
marcacaoExamePanel.clear();
|
|
||||||
marcacaoExamePanel.getEmailButton().setText( "Enviar email" );
|
|
||||||
if( detalhesExamePanel != null )
|
|
||||||
{
|
|
||||||
detalhesExamePanel.clear();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void enableComponents(int index, boolean enable)
|
|
||||||
{
|
|
||||||
switch( index )
|
|
||||||
{
|
|
||||||
case INDEX_MAIN:
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case INDEX_EXAME:
|
|
||||||
marcacaoExamePanel.setEnabled( enable );
|
|
||||||
marcacaoExamePanel.getEmailButton().setEnabled( enable );
|
|
||||||
if( detalhesExamePanel != null )
|
|
||||||
{
|
|
||||||
detalhesExamePanel.setEnabled( enable );
|
|
||||||
}
|
|
||||||
upperPanel.setEnabled( !enable );
|
|
||||||
estado[ 0 ] = enable;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case INDEX_CONSULTA:
|
|
||||||
marcacaoConsultaPanel.setEnabled( enable );
|
|
||||||
marcacaoConsultaPanel.getEmailButton().setEnabled( enable );
|
|
||||||
upperPanel.setEnabled( !enable );
|
|
||||||
estado[ 1 ] = enable;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if( tracker != null )
|
|
||||||
{
|
|
||||||
(( AvisosPanel )tracker.getAvisosPanel()).setEnabled( (!estado[ 0 ]) && (!estado[1]),
|
|
||||||
AvisoConstants.TIPO_TRABALHADOR );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// public boolean searchByName()
|
|
||||||
// {
|
|
||||||
// fichaProvider.setSearch( FichaDataProvider.SEARCH_EMPRESAS );
|
|
||||||
// SearchDialog search;
|
|
||||||
//
|
|
||||||
// search = new SearchDialog( fichaProvider, null, false, null, true );
|
|
||||||
// empresaID = ( Integer )search.getSelected();
|
|
||||||
//
|
|
||||||
// if( empresaID == null )
|
|
||||||
// {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// fichaProvider.setSearch( FichaDataProvider.SEARCH_ESTABELECIMENTOS );
|
|
||||||
// fichaProvider.setSearchID( FichaDataProvider.SEARCH_EMPRESAS, empresaID.intValue() );
|
|
||||||
//
|
|
||||||
// search = new SearchDialog( fichaProvider, null, false, null, true );
|
|
||||||
// estabelecimentoID = ( Integer )search.getSelected();
|
|
||||||
//
|
|
||||||
// if( estabelecimentoID == null )
|
|
||||||
// {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// fichaProvider.setSearch( FichaDataProvider.SEARCH_TRABALHADORES );
|
|
||||||
// fichaProvider.setSearchID( FichaDataProvider.SEARCH_ESTABELECIMENTOS, estabelecimentoID.intValue() );
|
|
||||||
// search = new SearchDialog( fichaProvider, null, false, null, true );
|
|
||||||
// trabalhadorID = ( Integer )search.getSelected();
|
|
||||||
//
|
|
||||||
// if( trabalhadorID == null )
|
|
||||||
// {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// reload(0);
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
protected void enableSelect( int index, boolean select )
|
|
||||||
{
|
|
||||||
switch( index )
|
|
||||||
{
|
|
||||||
case INDEX_EXAME:
|
|
||||||
marcacaoExameEditorPanel.setEnabled( select );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case INDEX_CONSULTA:
|
|
||||||
marcacaoConsultaEditorPanel.setEnabled( select );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reload( int index )
|
|
||||||
{
|
|
||||||
switch( index )
|
|
||||||
{
|
|
||||||
case INDEX_MAIN:
|
|
||||||
try
|
|
||||||
{
|
|
||||||
String nomes[] =
|
|
||||||
provider.getEmpresaEstabelecimento( empresaID, estabelecimentoID );
|
|
||||||
empresa = nomes[ 0 ];
|
|
||||||
estabelecimento = nomes[ 1 ];
|
|
||||||
trabalhador = ( TrabalhadoresData ) JDO.load( TrabalhadoresData.class, trabalhadorID );
|
|
||||||
// upperPanel.getEmpresaText().setText( empresa );
|
|
||||||
// upperPanel.getEstabelecimentoText().setText( estabelecimento );
|
|
||||||
// upperPanel.getTrabalhadorText().setText( ( String ) trabalhador.get( TrabalhadoresData.NOME ) );
|
|
||||||
IDObject detalhesExame[] = provider.getDetalhesValidosTrabalhador( empresaID, trabalhadorID );
|
|
||||||
detalhesExamePanel = new CheckBoxPanel( detalhesExame );
|
|
||||||
JPanel detalhesExameOuterPanel = marcacaoExamePanel.getDetalhesPanel();
|
|
||||||
detalhesExameOuterPanel.setLayout( new GridLayout( 1, 1 ) );
|
|
||||||
detalhesExameOuterPanel.removeAll();
|
|
||||||
detalhesExameOuterPanel.add( detalhesExamePanel );
|
|
||||||
detalhesExameOuterPanel.validate();
|
|
||||||
Object examesTrabalhador[][] = provider.getExamesTrabalhador( trabalhadorID );
|
|
||||||
Object consultasTrabalhador[][] = provider.getConsultasTrabalhador( trabalhadorID );
|
|
||||||
if( examesTrabalhador.length > 0 )
|
|
||||||
{
|
|
||||||
marcacaoExameEditorPanel.setData( new Object2DArray( examesTrabalhador ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
marcacaoExameEditorPanel.clear();
|
|
||||||
}
|
|
||||||
if( consultasTrabalhador.length > 0 )
|
|
||||||
{
|
|
||||||
marcacaoConsultaEditorPanel.setData( new Object2DArray( consultasTrabalhador ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
marcacaoConsultaEditorPanel.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch( Exception ex )
|
|
||||||
{
|
|
||||||
DialogException.showExceptionMessage( ex, "Erro a carregar os dados.", true );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case INDEX_EXAME:
|
|
||||||
Integer exameID = marcacaoExameEditorPanel.getID();
|
|
||||||
if( exameID == null )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
MarcacoesTrabalhadorData exame =
|
|
||||||
( MarcacoesTrabalhadorData ) JDO.load( MarcacoesTrabalhadorData.class, exameID );
|
|
||||||
marcacaoExamePanel.fill( exame );
|
|
||||||
Date dataEmailExame = ( Date ) exame.get( MarcacoesTrabalhadorData.DATA_EMAIL );
|
|
||||||
if( dataEmailExame != null )
|
|
||||||
{
|
|
||||||
marcacaoExamePanel.getEmailButton().setText( "Enviar email (" + DATE_FORMAT.format( dataEmailExame ) + ")" );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
marcacaoExamePanel.getEmailButton().setText( "Enviar email" );
|
|
||||||
}
|
|
||||||
Integer detalhesRealizados[] = provider.getDetalhesRealizadosForMarcacao( exameID );
|
|
||||||
detalhesExamePanel.setSelected( detalhesRealizados );
|
|
||||||
}
|
|
||||||
catch( Exception ex )
|
|
||||||
{
|
|
||||||
DialogException.showExceptionMessage( ex, "Erro a carregar os dados do exame.", true );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case INDEX_CONSULTA:
|
|
||||||
Integer consultaID = marcacaoConsultaEditorPanel.getID();
|
|
||||||
if( consultaID == null )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
MarcacoesTrabalhadorData consulta =
|
|
||||||
( MarcacoesTrabalhadorData ) JDO.load( MarcacoesTrabalhadorData.class, consultaID );
|
|
||||||
marcacaoConsultaPanel.fill( consulta );
|
|
||||||
Date dataEmailConsulta = ( Date ) consulta.get( MarcacoesTrabalhadorData.DATA_EMAIL );
|
|
||||||
if( dataEmailConsulta != null )
|
|
||||||
{
|
|
||||||
marcacaoConsultaPanel.getEmailButton().setText( "Enviar email (" + DATE_FORMAT.format( dataEmailConsulta ) + ")" );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
marcacaoConsultaPanel.getEmailButton().setText( "Enviar email" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch( Exception ex )
|
|
||||||
{
|
|
||||||
DialogException.showExceptionMessage( ex, "Erro a carregar os dados da consulta.", true );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void actionPerformed( ActionEvent e )
|
|
||||||
{
|
|
||||||
Object source = e.getSource();
|
|
||||||
if( source.equals( marcacaoExamePanel.getEmailButton() ) )
|
|
||||||
{
|
|
||||||
enviarEmailExame();
|
|
||||||
}
|
|
||||||
else if( source.equals( marcacaoConsultaPanel.getEmailButton() ) )
|
|
||||||
{
|
|
||||||
enviarEmailConsulta();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void enviarEmailConsulta()
|
|
||||||
{
|
|
||||||
MarcacoesTrabalhadorData consulta = ( MarcacoesTrabalhadorData ) marcacaoConsultaPanel.save();
|
|
||||||
|
|
||||||
String subject = ( String ) Singleton.getInstance( SingletonConstants.SUBJECT_CONSULTA );
|
|
||||||
String texto = ( String ) Singleton.getInstance( SingletonConstants.LETTER_CONSULTA );
|
|
||||||
|
|
||||||
Date today = new Date();
|
|
||||||
marcacaoConsultaPanel.getEmailButton().setText( "Enviar email (" + DATE_FORMAT.format( today ) + ")" );
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
enviarEmail( subject, texto, ( Date )consulta.get( MarcacoesTrabalhadorData.DATA ) );
|
|
||||||
consulta.set( Marcacao.DATA_EMAIL, today );
|
|
||||||
}
|
|
||||||
catch( Exception ex )
|
|
||||||
{
|
|
||||||
DialogException.showExceptionMessage( ex, "Erro a enviar mail", true );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void enviarEmailExame()
|
|
||||||
{
|
|
||||||
MarcacoesTrabalhadorData exame = ( MarcacoesTrabalhadorData ) marcacaoExamePanel.save();
|
|
||||||
|
|
||||||
String subject = ( String ) Singleton.getInstance( SingletonConstants.SUBJECT_EXAMES );
|
|
||||||
String texto = ( String ) Singleton.getInstance( SingletonConstants.LETTER_EXAMES );
|
|
||||||
|
|
||||||
Date today = new Date();
|
|
||||||
marcacaoExamePanel.getEmailButton().setText( "Enviar email (" + DATE_FORMAT.format( today ) + ")" );
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
enviarEmail( subject, texto, ( Date )exame.get( MarcacoesTrabalhadorData.DATA ) );
|
|
||||||
exame.set( Marcacao.DATA_EMAIL, today );
|
|
||||||
}
|
|
||||||
catch( Exception ex )
|
|
||||||
{
|
|
||||||
DialogException.showExceptionMessage( ex, "Erro a enviar mail", true );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void enviarEmail( String subject, String texto, Date data )
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
String nome = ( String ) trabalhador.get( TrabalhadoresData.NOME );
|
|
||||||
String dataStr = DATE_FORMAT.format( data );
|
|
||||||
|
|
||||||
subject = subject.replaceAll( CompanyDataLoader.NOME, nome );
|
|
||||||
texto = texto.replaceAll( CompanyDataLoader.DATA, dataStr );
|
|
||||||
texto = texto.replaceAll( CompanyDataLoader.NOME, nome );
|
|
||||||
|
|
||||||
EstabelecimentosData estabelecimento =
|
|
||||||
( EstabelecimentosData ) JDO.load( EstabelecimentosData.class, estabelecimentoID );
|
|
||||||
ContactosData contacto = ( ContactosData ) estabelecimento.toContacto_id();
|
|
||||||
String mail = "";
|
|
||||||
if( contacto != null )
|
|
||||||
{
|
|
||||||
mail = ( String )contacto.getEmail();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( System.getProperty( "os.name" ).startsWith( "Windows" ) )
|
|
||||||
{
|
|
||||||
mail = mail.replaceAll( " ", "%20" );
|
|
||||||
subject = subject.replaceAll( " ", "%20" );
|
|
||||||
texto = texto.replaceAll( " ", "%20" );
|
|
||||||
Process proc = Runtime.getRuntime().exec( "cmd.exe /c start mailto:\"" + mail
|
|
||||||
+ "?subject=" + subject + "&body="
|
|
||||||
|
|
||||||
+ texto
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mail = mail.replaceAll( " ", "%20" );
|
|
||||||
subject = subject.replaceAll( " ", "%20" );
|
|
||||||
texto = texto.replaceAll( " ", "%20" );
|
|
||||||
|
|
||||||
Process proc = Runtime.getRuntime().exec( new String[]{ "/usr/bin/open", "/Applications/Mail.app", "mailto:" + mail
|
|
||||||
+ "?subject=" + subject + "&body="
|
|
||||||
+ texto } );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void valueChanged( ListSelectionEvent e )
|
|
||||||
{
|
|
||||||
Object source = e.getSource();
|
|
||||||
if( source.equals( upperPanel ) )
|
|
||||||
{
|
|
||||||
Integer ids[] = ( Integer [] ) upperPanel.save();
|
|
||||||
empresaID = ids[ 0 ];
|
|
||||||
estabelecimentoID = ids[ 1 ];
|
|
||||||
trabalhadorID = ids[ 2 ];
|
|
||||||
if( ids[ 2 ] == null )
|
|
||||||
{
|
|
||||||
clear( INDEX_MAIN );
|
|
||||||
unselect( INDEX_MAIN );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
reload( INDEX_MAIN );
|
|
||||||
select( INDEX_MAIN );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEmpresaAndEstabelecimentoAndTrabalhador( Integer empresaID, Integer estabelecimentoID, Integer trabalhadorID )
|
|
||||||
{
|
|
||||||
if( upperPanel.editing )
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog( this, "Esta janela est\u00e1 em edi\u00e7\u00e3o.", "Erro...",
|
|
||||||
JOptionPane.ERROR_MESSAGE );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
upperPanel.fill( new Integer[]{ empresaID, estabelecimentoID, trabalhadorID } );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTracker( SHSTTrackerInterface tracker )
|
|
||||||
{
|
|
||||||
this.tracker = tracker;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* Test.java
|
|
||||||
*
|
|
||||||
* Created on 17 de Janeiro de 2006, 18:37
|
|
||||||
*
|
|
||||||
* To change this template, choose Tools | Options and locate the template under
|
|
||||||
* the Source Creation and Management node. Right-click the template and choose
|
|
||||||
* Open. You can then make changes to the template in the Source Editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package siprp.medicina;
|
|
||||||
|
|
||||||
import siprp.ui.SIPRPTabbedWindow;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author fpalma
|
|
||||||
*/
|
|
||||||
public class Test
|
|
||||||
{
|
|
||||||
|
|
||||||
public static void main( String args[] )
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
SIPRPTabbedWindow frm = new MedicinaWindow();
|
|
||||||
// frm.getContentPane().setLayout( new GridLayout() );
|
|
||||||
// frm.getContentPane().add( new MedicinaUpperPanel() );
|
|
||||||
// frm.setSize( new Dimension( 600, 600 ) );
|
|
||||||
frm.setVisible( true );
|
|
||||||
frm.setExtendedState(frm.getExtendedState() | frm.MAXIMIZED_BOTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Creates a new instance of Test */
|
|
||||||
public Test()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Loading…
Reference in new issue